From: Christian Dywan Date: Mon, 14 Sep 2009 21:57:57 +0000 (+0200) Subject: Display source code in a tab if no editor is specified X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d502518434cb458b4722b0d1bcfd41a4e1c936a6;p=midori Display source code in a tab if no editor is specified This uses view source mode available since WebKitGTK+ 1.1.14. --- diff --git a/midori/midori-browser.c b/midori/midori-browser.c index ac58f11f..f406d929 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -3070,10 +3070,22 @@ _action_source_view_activate (GtkAction* action, text_editor = NULL; uri = midori_view_get_display_uri (MIDORI_VIEW (view)); - if (!g_strcmp0 (text_editor, "")) + if (!(text_editor && *text_editor)) { - GFile* file = g_file_new_for_uri (uri); + #if WEBKIT_CHECK_VERSION (1, 1, 14) + GtkWidget* source; + GtkWidget* web_view; + source = midori_view_new (browser->net); + midori_view_set_uri (MIDORI_VIEW (source), ""); + web_view = gtk_bin_get_child (GTK_BIN (source)); + webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (web_view), TRUE); + webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), uri); + gtk_widget_show (source); + midori_browser_add_tab (browser, source); + return; + #else + GFile* file = g_file_new_for_uri (uri); gchar* content_type; GAppInfo* app_info; GList* files; @@ -3104,6 +3116,7 @@ _action_source_view_activate (GtkAction* action, g_free (text_editor); return; } + #endif } katze_net_load_uri (browser->net, uri, NULL,