[PATCH] Tell user why open_uri() don't work

Now that we start having users running meld on windows,
we should try to help them not create useless bug reports.

The misc.open_uri() method needs a more recent pygtk
version than the one currently available for windows or
gnome libraries. So don't fail silently if they ask for the
help window or to go report a bug...

Please review

Vincent Legoll
diff --git a/meldapp.py b/meldapp.py
index 55c63f0..094cd84 100644
--- a/meldapp.py
+++ b/meldapp.py
@@ -769,13 +769,16 @@ class MeldApp(gnomeglade.Component):
     # Toolbar and menu items (help)
     def on_menu_help_activate(self, button):
-        misc.open_uri("ghelp:///"+os.path.abspath(paths.help_dir("C/meld.xml")))
+        misc.open_uri("ghelp:///" + os.path.abspath(paths.help_dir("C/meld.xml")),
+                      error_msg=_("Unable to display the help window."))
     def on_menu_help_bug_activate(self, button):
-        misc.open_uri("http://bugzilla.gnome.org/buglist.cgi?query=product%3Ameld";)
+        misc.open_uri("http://bugzilla.gnome.org/buglist.cgi?query=product%3Ameld";,
+                      error_msg=_("Unable to open a web browser to the bug tracking web site."))
     def on_menu_about_activate(self, *extra):
-        gtk.about_dialog_set_url_hook(lambda dialog, uri: misc.open_uri(uri))
+        error_msg = _("Unable to open a web browser to the meld web site.")
+        gtk.about_dialog_set_url_hook(lambda dialog, uri: misc.open_uri(uri, error_msg=error_msg))
         about = gtk.glade.XML(paths.share_dir("glade2/meldapp.glade"),"about").get_widget("about")
         about.props.version = version
diff --git a/misc.py b/misc.py
index 91f5ea5..52e4a2f 100644
--- a/misc.py
+++ b/misc.py
@@ -79,7 +79,7 @@ def run_dialog( text, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonstype=
     return ret
-def open_uri(uri, timestamp=0):
+def open_uri(uri, timestamp=0, error_msg=''):
     # TODO: should be 2.14 when released
     if gtk.pygtk_version >= (2, 13, 0):
         gtk.show_uri(gtk.gdk.screen_get_default(), uri, timestamp)
@@ -88,7 +88,9 @@ def open_uri(uri, timestamp=0):
             import gnome
         except ImportError:
-            pass
+            error_msg += ('\n\n' + _("You don't have a recent enough pygtk version nor the python gnome libraries installed.") +
+                          '\n\n' + uri)
+            run_dialog(error_msg, buttonstype=gtk.BUTTONS_OK)
 # Taken from epiphany
 def position_menu_under_widget(menu, widget):

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