Display source code in a tab if no editor is specified

This uses view source mode available since WebKitGTK+ 1.1.14.
This commit is contained in:
Christian Dywan 2009-09-14 23:57:57 +02:00
parent 5f98925a02
commit d502518434

View file

@ -3070,10 +3070,22 @@ _action_source_view_activate (GtkAction* action,
text_editor = NULL; text_editor = NULL;
uri = midori_view_get_display_uri (MIDORI_VIEW (view)); 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; gchar* content_type;
GAppInfo* app_info; GAppInfo* app_info;
GList* files; GList* files;
@ -3104,6 +3116,7 @@ _action_source_view_activate (GtkAction* action,
g_free (text_editor); g_free (text_editor);
return; return;
} }
#endif
} }
katze_net_load_uri (browser->net, uri, NULL, katze_net_load_uri (browser->net, uri, NULL,