diff options
author | Diego Escalante Urrelo <descalante@igalia.com> | 2011-03-24 08:47:51 +0800 |
---|---|---|
committer | Diego Escalante Urrelo <descalante@igalia.com> | 2011-04-19 13:35:10 +0800 |
commit | 351a6f2e63d8baf417865f108b334c9c9fd26b24 (patch) | |
tree | 863541d906d1ded4d9a5db76c4e8d4d0de623dc9 /src | |
parent | bfc6e9f79606c6143ab106d00653ab6fc759c877 (diff) | |
download | gsoc2013-epiphany-351a6f2e63d8baf417865f108b334c9c9fd26b24.tar gsoc2013-epiphany-351a6f2e63d8baf417865f108b334c9c9fd26b24.tar.gz gsoc2013-epiphany-351a6f2e63d8baf417865f108b334c9c9fd26b24.tar.bz2 gsoc2013-epiphany-351a6f2e63d8baf417865f108b334c9c9fd26b24.tar.lz gsoc2013-epiphany-351a6f2e63d8baf417865f108b334c9c9fd26b24.tar.xz gsoc2013-epiphany-351a6f2e63d8baf417865f108b334c9c9fd26b24.tar.zst gsoc2013-epiphany-351a6f2e63d8baf417865f108b334c9c9fd26b24.zip |
Add a preference to force internal view-source
Using the view-source feature provided by WebKitGTK+ can be handier than
opening gedit or the default text/html application in your system.
This adds "internal-view-source" to org.gnome.Epiphany to force the
internal-viewer always.
Based on Ole Laursen's patch.
Bug #597156
Diffstat (limited to 'src')
-rw-r--r-- | src/window-commands.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/src/window-commands.c b/src/window-commands.c index 3e4fdee34..61d6080a9 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -647,6 +647,25 @@ window_cmd_view_zoom_normal (GtkAction *action, } static void +view_source_embedded (const char *uri, EphyEmbed *embed) +{ + EphyEmbed *new_embed; + + new_embed = ephy_shell_new_tab + (ephy_shell_get_default (), + EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))), + embed, + NULL, + EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_IN_EXISTING_WINDOW | EPHY_NEW_TAB_APPEND_AFTER); + + webkit_web_view_set_view_source_mode + (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), TRUE); + webkit_web_view_load_uri + (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), uri); +} + + +static void save_temp_source_close_cb (GOutputStream *ostream, GAsyncResult *result, gpointer data) { char *uri; @@ -664,30 +683,21 @@ save_temp_source_close_cb (GOutputStream *ostream, GAsyncResult *result, gpointe uri = (char*)g_object_get_data (G_OBJECT (ostream), "ephy-save-temp-source-uri"); file = g_file_new_for_uri (uri); + if (!ephy_file_launch_handler ("text/plain", file, gtk_get_current_event_time ())) { /* Fallback to view the source inside the browser */ const char *uri; - EphyEmbed *embed, *new_embed; + EphyEmbed *embed; uri = (const char*) g_object_get_data (G_OBJECT (ostream), "ephy-original-source-uri"); embed = (EphyEmbed*)g_object_get_data (G_OBJECT (ostream), "ephy-save-temp-source-embed"); - - new_embed = ephy_shell_new_tab (ephy_shell_get_default (), - EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))), - embed, - NULL, - EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_IN_EXISTING_WINDOW); - - webkit_web_view_set_view_source_mode (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), - TRUE); - webkit_web_view_load_uri (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), - uri); + view_source_embedded (uri, embed); } - g_object_unref (ostream); + g_object_unref (file); } @@ -832,6 +842,14 @@ window_cmd_view_page_source (GtkAction *action, g_return_if_fail (embed != NULL); address = ephy_web_view_get_address (ephy_embed_get_web_view (embed)); + + if (g_settings_get_boolean (EPHY_SETTINGS_MAIN, + EPHY_PREFS_INTERNAL_VIEW_SOURCE)) + { + view_source_embedded (address, embed); + return; + } + user_time = gtk_get_current_event_time (); if (g_str_has_prefix (address, "file://")) |