From ea9ea2673df404ad2dbf5718eaa3ded4b2956f79 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Wed, 8 Aug 2012 20:54:35 +0200 Subject: prepare printing of stock dialog --- ui.vala | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'ui.vala') diff --git a/ui.vala b/ui.vala index a5d37a4..76b484d 100644 --- a/ui.vala +++ b/ui.vala @@ -88,6 +88,40 @@ public void show_stock_dialog() { (builder.get_object("stock-dialog") as Gtk.Window).show(); } +public void stock_dialog_handle_response(Gtk.Dialog dialog, int responseid) { + if(responseid == 1) { + stock_dialog_print(dialog); + } else { + dialog.hide(); + } +} + +public void stock_dialog_print(Gtk.Window parentw) { + var operation = new Gtk.PrintOperation(); + + operation.begin_print.connect(begin_print); + operation.draw_page.connect(draw_page); + operation.end_print.connect(end_print); + + try { + operation.run(Gtk.PrintOperationAction.PRINT_DIALOG, parentw); + } catch(Error e) { + error("error while printing: %s\n", e.message); + } +} + +public void begin_print(Gtk.PrintContext context) { + /* TODO: find out how many pages we need */ +} + +public void draw_page(Gtk.PrintContext context, int nr) { + /* TODO: do some cairo magic */ +} + +public void end_print(Gtk.PrintContext context) { + /* TODO: free allocated resources */ +} + [PrintfFormat] public void write_to_log(string format, ...) { var arguments = va_list(); -- cgit v1.2.3