[pygobject] [gtk-demo] printing.py: exit Gtk mainloop when done and correctly handle printing errors



commit 1aebc1565752840075027b9452fe2a67217bf53b
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Tue Aug 23 11:28:05 2011 +0200

    [gtk-demo] printing.py: exit Gtk mainloop when done and correctly handle printing errors

 demos/gtk-demo/demos/printing.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/demos/gtk-demo/demos/printing.py b/demos/gtk-demo/demos/printing.py
index 0855df0..1e0a9fc 100644
--- a/demos/gtk-demo/demos/printing.py
+++ b/demos/gtk-demo/demos/printing.py
@@ -68,18 +68,23 @@ class PrintingApp:
         settings.set(Gtk.PRINT_SETTINGS_OUTPUT_URI, uri)
         self.operation.set_print_settings(settings)
 
-        try:
-            self.operation.run(Gtk.PrintOperationAction.PRINT_DIALOG, None)
-        except GLib.Error as e:
+    def run(self):
+        result = self.operation.run(Gtk.PrintOperationAction.PRINT_DIALOG, None)
+
+        if result == Gtk.PrintOperationResult.ERROR:
+            message = self.operation.get_error()
+
             dialog = Gtk.MessageDialog(None,
                                        0,
                                        Gtk.MessageType.ERROR,
                                        Gtk.ButtonsType.CLOSE,
-                                       e.message)
+                                       message)
 
             dialog.run()
             dialog.destroy()
 
+        Gtk.main_quit()
+
     def begin_print(self, operation, print_ctx, print_data):
         height = print_ctx.get_height() - self.HEADER_HEIGHT - self.HEADER_GAP
         print_data['lines_per_page'] = \
@@ -167,6 +172,7 @@ class PrintingApp:
 
 def main(demoapp=None):
     app = PrintingApp()
+    GLib.idle_add(app.run)
     Gtk.main()
 
 if __name__ == '__main__':



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]