diff options
author | Dieter Verfaillie <dieterv@optionexplicit.be> | 2011-08-23 11:28:05 +0200 |
---|---|---|
committer | Dieter Verfaillie <dieterv@optionexplicit.be> | 2011-08-24 19:02:43 +0200 |
commit | 1aebc1565752840075027b9452fe2a67217bf53b (patch) | |
tree | a492d65e5f495e53bf4fa6a5519946aeec4cf1d7 /demos | |
parent | 1f9e4486c5b84209ce0038887738fc16a4ef7da3 (diff) | |
download | pygobject-1aebc1565752840075027b9452fe2a67217bf53b.tar.gz |
[gtk-demo] printing.py: exit Gtk mainloop when done and correctly handle printing errors
Diffstat (limited to 'demos')
-rw-r--r-- | 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 0855df00..1e0a9fcd 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__': |