[postr] Better error handling when an image does not exist



commit c8d7466ec40b6dc461b74ec7112aca0b35934a85
Author: GermÃn Poo-CaamaÃo <gpoo gnome org>
Date:   Wed Oct 3 18:32:20 2012 -0700

    Better error handling when an image does not exist
    
    https://bugzilla.gnome.org/show_bug.cgi?id=507228
    
    Signed-off-by: GermÃn Poo-CaamaÃo <gpoo gnome org>

 src/postr.py |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/src/postr.py b/src/postr.py
index 70dd838..33dc81d 100644
--- a/src/postr.py
+++ b/src/postr.py
@@ -22,7 +22,7 @@ from urlparse import urlparse
 from os.path import basename
 from tempfile import mkstemp
 
-from gi.repository import GObject, Gtk, GConf, GdkPixbuf, Gio, Gdk
+from gi.repository import GObject, Gtk, GConf, GdkPixbuf, Gio, Gdk, GLib
 
 #FIXME
 #import gnome.ui
@@ -734,10 +734,17 @@ class Postr(UniqueApp):
         return self.add_image_filename(uri)
 
     def add_image_filename(self, filename):
-        gfile = Gio.File.new_for_commandline_arg(filename)
-        fileinfo = gfile.query_info(_FILE_ATTRIBUTES,
-                                    Gio.FileQueryInfoFlags.NONE,
-                                    None)
+        try:
+            gfile = Gio.File.new_for_commandline_arg(filename)
+            fileinfo = gfile.query_info(_FILE_ATTRIBUTES,
+                                        Gio.FileQueryInfoFlags.NONE,
+                                        None)
+        except GLib.GError, e:
+            d = ErrorDialog(self.window)
+            d.set_from_exception(e)
+            d.show_all()
+            return
+
         self.add_image_file(gfile, fileinfo)
 
     def add_image_fileinfo(self, parent, fileinfo):



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