]> spindle.queued.net Git - midori/commitdiff
Enable View Source only if GIO really supports HTTP
authorChristian Dywan <christian@twotoasts.de>
Sun, 17 Aug 2008 17:11:43 +0000 (19:11 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 17 Aug 2008 17:11:43 +0000 (19:11 +0200)
midori/midori-browser.c
midori/sokoke.c
midori/sokoke.h

index 38151edeb55dbac3f55c399dd2b655ab4d5c3c78..66a6c88df7817c9a5af7459910fe532c2efaadc0 100644 (file)
@@ -257,9 +257,8 @@ _midori_browser_update_interface (MidoriBrowser* browser)
     _action_set_sensitive (browser, "ZoomOut", web_view != NULL);
     _action_set_sensitive (browser, "ZoomNormal", web_view != NULL
         && webkit_web_view_get_zoom_level (WEBKIT_WEB_VIEW (web_view)) != 1.0);
-    #if GLIB_CHECK_VERSION (2, 16, 0)
-    _action_set_sensitive (browser, "SourceView", web_view != NULL);
-    #endif
+    if (sokoke_gio_supports_http ())
+        _action_set_sensitive (browser, "SourceView", web_view != NULL);
     _action_set_sensitive (browser, "FindNext", web_view != NULL);
     _action_set_sensitive (browser, "FindPrevious", web_view != NULL);
     /* _action_set_sensitive (browser, "FindQuick", web_view != NULL); */
@@ -3602,9 +3601,8 @@ midori_browser_init (MidoriBrowser* browser)
 
     g_object_unref (ui_manager);
 
-    #if !GLIB_CHECK_VERSION (2, 16, 0)
-    _action_set_sensitive (browser, "SourceView", FALSE);
-    #endif
+    _action_set_sensitive (browser, "SourceView", sokoke_gio_supports_http ());
+
     #ifndef WEBKIT_CHECK_VERSION
     _action_set_sensitive (browser, "ZoomIn", FALSE);
     _action_set_sensitive (browser, "ZoomOut", FALSE);
index ea476f93d8bb70e2a0a16402cb72bf57ac9020b4..0ab823dee862a31905746a421436281f313a6603 100644 (file)
@@ -625,3 +625,26 @@ sokoke_action_create_popup_menu_item (GtkAction* action)
 
     return menuitem;
 }
+
+gboolean
+sokoke_gio_supports_http (void)
+{
+    #if HAVE_GIO
+    static gboolean supports_http;
+    static gboolean tested;
+    const gchar* const* schemes = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
+
+    if (tested)
+        return supports_http;
+    while (*schemes)
+    {
+        if (!strcmp (*schemes, "http"))
+            supports_http = TRUE;
+        schemes++;
+    }
+    tested = TRUE;
+    return supports_http;
+    #else
+    return FALSE;
+    #endif
+}
index 616c601f2db59effa575b51c7a37a1fc162884c2..873e3704254fd8df36d3acba784070d99a2199d5 100644 (file)
@@ -131,4 +131,7 @@ sokoke_object_get_boolean            (gpointer       object,
 GtkWidget*
 sokoke_action_create_popup_menu_item (GtkAction*     action);
 
+gboolean
+sokoke_gio_supports_http             (void                 );
+
 #endif /* !__SOKOKE_H__ */