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 ++++++++++++++++++++++++++++++++++ user-interface.ui | 41 +++++++++++++++++++++++++++++++++++------ 2 files changed, 69 insertions(+), 6 deletions(-) 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(); diff --git a/user-interface.ui b/user-interface.ui index a2fafe0..ff33923 100644 --- a/user-interface.ui +++ b/user-interface.ui @@ -614,7 +614,7 @@ Lennart Weller <lhw@ring0.de> - 400 + 550 500 False 5 @@ -622,7 +622,7 @@ Lennart Weller <lhw@ring0.de> dialog - + False @@ -633,10 +633,11 @@ Lennart Weller <lhw@ring0.de> False end - - gtk-ok + + gtk-print False True + False True True False @@ -648,6 +649,22 @@ Lennart Weller <lhw@ring0.de> 0 + + + gtk-ok + False + True + True + True + False + True + + + False + True + 1 + + False @@ -666,6 +683,7 @@ Lennart Weller <lhw@ring0.de> True True stock-store + True 1 vertical @@ -673,7 +691,9 @@ Lennart Weller <lhw@ring0.de> - ID + EAN + True + 0 @@ -685,6 +705,8 @@ Lennart Weller <lhw@ring0.de> Name + True + 1 @@ -696,6 +718,8 @@ Lennart Weller <lhw@ring0.de> Amount + True + 2 @@ -707,6 +731,8 @@ Lennart Weller <lhw@ring0.de> Member Price + True + 3 @@ -718,6 +744,8 @@ Lennart Weller <lhw@ring0.de> Guest Price + True + 4 @@ -738,7 +766,8 @@ Lennart Weller <lhw@ring0.de> - button3 + stock-dialog-button-print + stock-dialog-button-ok -- cgit v1.2.3