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 | |
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
-rw-r--r-- | data/org.gnome.epiphany.gschema.xml.in | 4 | ||||
-rw-r--r-- | lib/ephy-prefs.h | 1 | ||||
-rw-r--r-- | src/window-commands.c | 44 |
3 files changed, 36 insertions, 13 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml.in b/data/org.gnome.epiphany.gschema.xml.in index 019026460..0c856f4cc 100644 --- a/data/org.gnome.epiphany.gschema.xml.in +++ b/data/org.gnome.epiphany.gschema.xml.in @@ -61,6 +61,10 @@ <summary>Active extensions</summary> <description>Lists the active extensions.</description> </key> + <key type="b" name="internal-view-source"> + <default>true</default> + <summary>Don't use an external application to view page source.</summary> + </key> </schema> <schema path="/org/gnome/epiphany/ui/" id="org.gnome.Epiphany.ui"> <key type="b" name="show-toolbars"> diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h index 45ca6bac2..5cd9dd889 100644 --- a/lib/ephy-prefs.h +++ b/lib/ephy-prefs.h @@ -103,6 +103,7 @@ typedef enum #define EPHY_PREFS_ENABLE_SMOOTH_SCROLLING "enable-smooth-scrolling" #define EPHY_PREFS_ENABLE_CARET_BROWSING "enable-caret-browsing" #define EPHY_PREFS_ENABLED_EXTENSIONS "enabled-extensions" +#define EPHY_PREFS_INTERNAL_VIEW_SOURCE "internal-view-source" #define EPHY_PREFS_LOCKDOWN_SCHEMA "org.gnome.Epiphany.lockdown" #define EPHY_PREFS_LOCKDOWN_FULLSCREEN "disable-fullscreen" 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://")) |