diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-08-08 20:54:35 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-08-08 20:54:35 +0200 |
commit | ea9ea2673df404ad2dbf5718eaa3ded4b2956f79 (patch) | |
tree | ec95b2f3b722e518ff5b9c5a6e73e86f2b2c20c9 | |
parent | b11374fbf4a9e8900c1471dc1e8350a07d8a4a68 (diff) | |
download | serial-barcode-scanner-ea9ea2673df404ad2dbf5718eaa3ded4b2956f79.tar.bz2 |
prepare printing of stock dialog
-rw-r--r-- | ui.vala | 34 | ||||
-rw-r--r-- | user-interface.ui | 41 |
2 files changed, 69 insertions, 6 deletions
@@ -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></property> </columns> </object> <object class="GtkDialog" id="stock-dialog"> - <property name="width_request">400</property> + <property name="width_request">550</property> <property name="height_request">500</property> <property name="can_focus">False</property> <property name="border_width">5</property> @@ -622,7 +622,7 @@ Lennart Weller <lhw@ring0.de></property> <property name="type_hint">dialog</property> <signal name="close" handler="gtk_widget_hide" swapped="no"/> <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/> - <signal name="response" handler="gtk_widget_hide" swapped="no"/> + <signal name="response" handler="stock_dialog_handle_response" swapped="no"/> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox4"> <property name="can_focus">False</property> @@ -633,10 +633,11 @@ Lennart Weller <lhw@ring0.de></property> <property name="can_focus">False</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="button3"> - <property name="label">gtk-ok</property> + <object class="GtkButton" id="stock-dialog-button-print"> + <property name="label">gtk-print</property> <property name="use_action_appearance">False</property> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_action_appearance">False</property> @@ -648,6 +649,22 @@ Lennart Weller <lhw@ring0.de></property> <property name="position">0</property> </packing> </child> + <child> + <object class="GtkButton" id="stock-dialog-button-ok"> + <property name="label">gtk-ok</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -666,6 +683,7 @@ Lennart Weller <lhw@ring0.de></property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="model">stock-store</property> + <property name="reorderable">True</property> <property name="search_column">1</property> <property name="enable_grid_lines">vertical</property> <child internal-child="selection"> @@ -673,7 +691,9 @@ Lennart Weller <lhw@ring0.de></property> </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn1"> - <property name="title" translatable="yes">ID</property> + <property name="title" translatable="yes">EAN</property> + <property name="sort_indicator">True</property> + <property name="sort_column_id">0</property> <child> <object class="GtkCellRendererText" id="cellrenderertext1"/> <attributes> @@ -685,6 +705,8 @@ Lennart Weller <lhw@ring0.de></property> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn2"> <property name="title" translatable="yes">Name</property> + <property name="sort_indicator">True</property> + <property name="sort_column_id">1</property> <child> <object class="GtkCellRendererText" id="cellrenderertext2"/> <attributes> @@ -696,6 +718,8 @@ Lennart Weller <lhw@ring0.de></property> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn3"> <property name="title" translatable="yes">Amount</property> + <property name="sort_indicator">True</property> + <property name="sort_column_id">2</property> <child> <object class="GtkCellRendererText" id="cellrenderertext3"/> <attributes> @@ -707,6 +731,8 @@ Lennart Weller <lhw@ring0.de></property> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn4"> <property name="title" translatable="yes">Member Price</property> + <property name="sort_indicator">True</property> + <property name="sort_column_id">3</property> <child> <object class="GtkCellRendererText" id="cellrenderertext4"/> <attributes> @@ -718,6 +744,8 @@ Lennart Weller <lhw@ring0.de></property> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn5"> <property name="title" translatable="yes">Guest Price</property> + <property name="sort_indicator">True</property> + <property name="sort_column_id">4</property> <child> <object class="GtkCellRendererText" id="cellrenderertext5"/> <attributes> @@ -738,7 +766,8 @@ Lennart Weller <lhw@ring0.de></property> </object> </child> <action-widgets> - <action-widget response="0">button3</action-widget> + <action-widget response="1">stock-dialog-button-print</action-widget> + <action-widget response="0">stock-dialog-button-ok</action-widget> </action-widgets> </object> </interface> |