2013-03-06 [colin] 3.9.0cvs107
authorColin Leroy <colin@colino.net>
Wed, 6 Mar 2013 14:59:03 +0000 (14:59 +0000)
committerColin Leroy <colin@colino.net>
Wed, 6 Mar 2013 14:59:03 +0000 (14:59 +0000)
* src/plugins/fancy/fancy_prefs.c
* src/plugins/fancy/fancy_prefs.h
* src/plugins/fancy/fancy_viewer.c
* src/plugins/fancy/fancy_viewer.h
Fix bug #2882, "Reverse preference for external content"
"Block external content" was the only negative preference
along the other "Enable ..." positive ones, but also had
several shortcomings, in that it only blocked user-
requested interactions, like
- prevent clicking on links
- prevent right-click/Download link
- prevent right-click/Save image
But NOT
- prevent auto download of images (that's controlled by
  Auto-load images)
- prevent auto download of javascript (that's controlled
  by Enable scripts)
- prevent auto download of applets (that's controlled by
  Enable java)
- prevent auto download of css (that can't be disabled)
New preference to replace it is "Enable inner navigation"
and allows to control whether one can click on links to
navigate inside Fancy viewer. If disabled and "Open in
external browser" is set, links will be opened in external
browser; else nothing will happen. In any state of these
preferences, right-clicking and choosing "Open in viewer"
or "Open in browser" will do what asked.

ChangeLog
PATCHSETS
configure.ac
src/plugins/fancy/fancy_prefs.c
src/plugins/fancy/fancy_prefs.h
src/plugins/fancy/fancy_viewer.c
src/plugins/fancy/fancy_viewer.h

index 771db9603c86fc1b66a7b6673adc328819303ecd..eea7a9e19e0f2f42927efc30f76d1fa06b79a2ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2013-03-06 [colin]     3.9.0cvs107
+
+       * src/plugins/fancy/fancy_prefs.c
+       * src/plugins/fancy/fancy_prefs.h
+       * src/plugins/fancy/fancy_viewer.c
+       * src/plugins/fancy/fancy_viewer.h
+               Fix bug #2882, "Reverse preference for external content"
+               "Block external content" was the only negative preference
+               along the other "Enable ..." positive ones, but also had
+               several shortcomings, in that it only blocked user-
+               requested interactions, like
+               - prevent clicking on links
+               - prevent right-click/Download link
+               - prevent right-click/Save image
+               But NOT
+               - prevent auto download of images (that's controlled by
+                 Auto-load images)
+               - prevent auto download of javascript (that's controlled
+                 by Enable scripts)
+               - prevent auto download of applets (that's controlled by
+                 Enable java)
+               - prevent auto download of css (that can't be disabled)
+               New preference to replace it is "Enable inner navigation"
+               and allows to control whether one can click on links to
+               navigate inside Fancy viewer. If disabled and "Open in
+               external browser" is set, links will be opened in external
+               browser; else nothing will happen. In any state of these
+               preferences, right-clicking and choosing "Open in viewer"
+               or "Open in browser" will do what asked.
+
 2013-03-06 [colin]     3.9.0cvs106
 
        * src/plugins/fancy/fancy_viewer.c
index e5b8079c0e275a18ac7a9c76c0db36c46ccd869c..3cf324932da71a3cd732f704dc6c6d181e8af931 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.8.2.67 -r 1.8.2.68 README;  ) > 3.9.0cvs104.patchset
 ( cvs diff -u -r 1.654.2.4681 -r 1.654.2.4682 configure.ac;  cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/perl/Makefile.am;  diff -u /dev/null src/plugins/perl/cm_perl.pod;  diff -u /dev/null src/plugins/perl/tools/.cvsignore;  diff -u /dev/null src/plugins/perl/tools/Makefile.am;  diff -u /dev/null src/plugins/perl/tools/insert_perl.pl;  diff -u /dev/null src/plugins/perl/tools/matcherrc2perlfilter.pl;  ) > 3.9.0cvs105.patchset
 ( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/fancy/fancy_viewer.c;  ) > 3.9.0cvs106.patchset
+( cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/fancy/fancy_prefs.c;  cvs diff -u -r 1.1.2.1 -r 1.1.2.2 src/plugins/fancy/fancy_prefs.h;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/fancy/fancy_viewer.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/plugins/fancy/fancy_viewer.h;  ) > 3.9.0cvs107.patchset
index 74aee4a2a6f969bc3cc96a1529e802b4ebc1e17e..73cc59898c8f8549f77e65fdc0f373702ee580f6 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=106
+EXTRA_VERSION=107
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8ddef3535427d6ed7de2a81d439c03339bb858f3..fa17a32df3ef37797b3ac9ea253f7be065f5b50f 100644 (file)
@@ -47,8 +47,8 @@
 FancyPrefs fancy_prefs;
 
 static void prefs_set_proxy_entry_sens(GtkWidget *button, GtkEntry *entry_str);
-static void prefs_set_block_external_sens(GtkWidget *button, GtkWidget *open_external);
-#ifdef HAVE_LIBSOUP_GNOME    
+
+#ifdef HAVE_LIBSOUP_GNOME
 static void prefs_disable_fancy_proxy(GtkWidget *checkbox, GtkWidget *block);
 #endif
 typedef struct _FancyPrefsPage FancyPrefsPage;
@@ -56,7 +56,7 @@ typedef struct _FancyPrefsPage FancyPrefsPage;
 struct _FancyPrefsPage {
        PrefsPage page;
        GtkWidget *auto_load_images;
-       GtkWidget *block_extern_content;
+       GtkWidget *enable_inner_navigation;
        GtkWidget *enable_scripts;
        GtkWidget *enable_plugins;
        GtkWidget *enable_java;
@@ -71,7 +71,7 @@ struct _FancyPrefsPage {
 static PrefParam param[] = {
                {"auto_load_images", "FALSE", &fancy_prefs.auto_load_images, P_BOOL, 
                NULL, NULL, NULL},
-               {"block_extern_content", "TRUE", &fancy_prefs.block_extern_content, P_BOOL, 
+               {"enable_inner_navigation", "TRUE", &fancy_prefs.enable_inner_navigation, P_BOOL, 
                NULL, NULL, NULL},
                {"enable_scripts", "FALSE", &fancy_prefs.enable_scripts, P_BOOL, 
                NULL, NULL, NULL},
@@ -130,6 +130,18 @@ void fancy_prefs_done(void)
        prefs_gtk_unregister_page((PrefsPage *) &fancy_prefs_page);
 }
 
+static void open_external_set_label_cb(GtkWidget *button, FancyPrefsPage *prefs_page)
+{
+       GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(prefs_page->open_external));
+       GtkTreeIter iter;
+       if (gtk_tree_model_get_iter_first (model, &iter)) {
+               if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(prefs_page->enable_inner_navigation)))
+                       gtk_list_store_set(model, &iter, COMBOBOX_TEXT, _("Open in viewer"), -1);
+               else
+                       gtk_list_store_set(model, &iter, COMBOBOX_TEXT, _("Do nothing"), -1);
+       }
+
+}
 static void create_fancy_prefs_page(PrefsPage *page, GtkWindow *window, 
                                                                        gpointer data)
 {
@@ -145,7 +157,6 @@ static void create_fancy_prefs_page(PrefsPage *page, GtkWindow *window,
        GtkWidget *checkbox2;
        GtkWidget *checkbox3;
        GtkWidget *checkbox4;
-       GtkWidget *checkbox5;
        GtkWidget *checkbox6;
 
        vbox = gtk_vbox_new(FALSE, 3);
@@ -185,9 +196,9 @@ static void create_fancy_prefs_page(PrefsPage *page, GtkWindow *window,
        gtk_box_pack_start(GTK_BOX(vbox), checkbox1, FALSE, FALSE, 0);
        gtk_widget_show(checkbox1);
 
-       checkbox2 = gtk_check_button_new_with_label(_("Block external content"));
+       checkbox2 = gtk_check_button_new_with_label(_("Enable inner navigation"));
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox2),
-                                                                fancy_prefs.block_extern_content);
+                                                                fancy_prefs.enable_inner_navigation);
        gtk_box_pack_start(GTK_BOX(vbox), checkbox2, FALSE, FALSE, 0);
        gtk_widget_show(checkbox2);
        
@@ -207,13 +218,25 @@ static void create_fancy_prefs_page(PrefsPage *page, GtkWindow *window,
                                                                 fancy_prefs.enable_java);
        gtk_box_pack_start(GTK_BOX(vbox), checkbox6, FALSE, FALSE, 0);
        gtk_widget_show(checkbox6);
-       checkbox5 = gtk_check_button_new_with_label(_("Open links with external browser"));
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox5),
-                                                                fancy_prefs.open_external);
-       g_signal_connect(G_OBJECT(checkbox2), "toggled",
-                                        G_CALLBACK(prefs_set_block_external_sens), checkbox5);
-       gtk_box_pack_start(GTK_BOX(vbox), checkbox5, FALSE, FALSE, 0);
-       gtk_widget_show(checkbox5);
+
+       GtkWidget *hbox_ext = gtk_hbox_new(FALSE, 8);
+       GtkWidget *open_external_label = gtk_label_new(_("When clicking on a link, by default:"));
+       GtkWidget *optmenu_open_external = gtkut_sc_combobox_create(NULL, FALSE);
+       GtkListStore *menu = GTK_LIST_STORE(gtk_combo_box_get_model(
+                               GTK_COMBO_BOX(optmenu_open_external)));
+       gtk_widget_show (optmenu_open_external);
+       GtkTreeIter iter;
+
+       COMBOBOX_ADD (menu, "DEFAULT_ACTION", FALSE);
+       COMBOBOX_ADD (menu, _("Open in external browser"), TRUE);
+
+       gtk_box_pack_start(GTK_BOX(hbox_ext), open_external_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox_ext), optmenu_open_external, FALSE, FALSE, 0);
+       gtk_widget_show_all(hbox_ext);
+       gtk_box_pack_start(GTK_BOX(vbox), hbox_ext, FALSE, FALSE, 0);
+
+       combobox_select_by_data(GTK_COMBO_BOX(optmenu_open_external),
+                       fancy_prefs.open_external);
 
 #ifdef HAVE_LIBSOUP_GNOME    
        prefs_page->gnome_proxy_checkbox = gnome_proxy_checkbox;
@@ -221,21 +244,23 @@ static void create_fancy_prefs_page(PrefsPage *page, GtkWindow *window,
        prefs_page->proxy_checkbox = proxy_checkbox;
        prefs_page->proxy_str = proxy_str;
        prefs_page->auto_load_images = checkbox1;
-       prefs_page->block_extern_content = checkbox2;
+       prefs_page->enable_inner_navigation = checkbox2;
        prefs_page->enable_scripts = checkbox3;
        prefs_page->enable_plugins = checkbox4;
        prefs_page->enable_java = checkbox6;
-       prefs_page->open_external = checkbox5;
+       prefs_page->open_external = optmenu_open_external;
        prefs_page->page.widget = vbox;
+
+       g_signal_connect(G_OBJECT(prefs_page->enable_inner_navigation), "toggled",
+                                        G_CALLBACK(open_external_set_label_cb), prefs_page);
+       open_external_set_label_cb(NULL, prefs_page);
 }
+
 static void prefs_set_proxy_entry_sens(GtkWidget *button, GtkEntry *entry_str) {
        gtk_widget_set_sensitive(GTK_WIDGET(entry_str), 
                                                           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
 }
-static void prefs_set_block_external_sens(GtkWidget *button, GtkWidget *open_external) {
-       gtk_widget_set_sensitive(open_external, 
-                                                          !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
-}
+
 #ifdef HAVE_LIBSOUP_GNOME    
 static void prefs_disable_fancy_proxy(GtkWidget *checkbox, GtkWidget *block) {
        gboolean toggle = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox));
@@ -287,16 +312,16 @@ static void save_fancy_prefs_page(PrefsPage *page)
 #endif
                fancy_prefs.auto_load_images = gtk_toggle_button_get_active
                                (GTK_TOGGLE_BUTTON(prefs_page->auto_load_images));
-               fancy_prefs.block_extern_content = gtk_toggle_button_get_active
-                               (GTK_TOGGLE_BUTTON(prefs_page->block_extern_content));
+               fancy_prefs.enable_inner_navigation = gtk_toggle_button_get_active
+                               (GTK_TOGGLE_BUTTON(prefs_page->enable_inner_navigation));
                fancy_prefs.enable_scripts = gtk_toggle_button_get_active
                                (GTK_TOGGLE_BUTTON(prefs_page->enable_scripts));
                fancy_prefs.enable_plugins = gtk_toggle_button_get_active
                                (GTK_TOGGLE_BUTTON(prefs_page->enable_plugins));
                fancy_prefs.enable_java = gtk_toggle_button_get_active
                                (GTK_TOGGLE_BUTTON(prefs_page->enable_java));
-               fancy_prefs.open_external = gtk_toggle_button_get_active
-                               (GTK_TOGGLE_BUTTON(prefs_page->open_external));
+               fancy_prefs.open_external = combobox_get_active_data
+                               (GTK_COMBO_BOX(prefs_page->open_external));
                fancy_prefs.enable_proxy = gtk_toggle_button_get_active
                                (GTK_TOGGLE_BUTTON(prefs_page->proxy_checkbox));
                fancy_prefs.proxy_str = pref_get_pref_from_entry(GTK_ENTRY(prefs_page->proxy_str));
index cf6732c840fa7b3d56f6eea01028eeb570d4b7a9..4ba7f361d0adbd65306a55a0cbd76e10de416d24 100644 (file)
@@ -29,13 +29,13 @@ struct _FancyPrefs
        WebKitWebSettings *web_settings;
        
        gboolean auto_load_images;
-       gboolean block_extern_content;
+       gboolean enable_inner_navigation;
        gboolean enable_scripts;
        gboolean enable_plugins;
        gboolean enable_java;
        gboolean open_external;
        gint zoom_level;
-#ifdef HAVE_LIBSOUP_GNOME    
+#ifdef HAVE_LIBSOUP_GNOME
        gboolean enable_gnome_proxy;
 #endif
        gboolean enable_proxy;
index f9ef4381dcbe2ecf75f20cc21eb69dc94b17688f..f02a05e1620dba9661cb356df12c48353c592cd9 100644 (file)
@@ -74,8 +74,9 @@ static void zoom_in_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer);
 static void zoom_out_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer);
 static gboolean fancy_prefs_cb(GtkWidget *widget, GdkEventButton *ev, FancyViewer *viewer);
 static void zoom_100_cb(GtkWidget *widget, GdkEvent *ev, FancyViewer *viewer);
+static void open_inner_cb(GtkWidget *widget, FancyViewer *viewer);
 static void open_in_browser_cb(GtkWidget *widget, FancyViewer *viewer);
-static WebKitNavigationResponse fancy_open_uri (FancyViewer *viewer, gboolean external);
+static WebKitNavigationResponse fancy_open_uri (FancyViewer *viewer);
 static void fancy_create_popup_prefs_menu(FancyViewer *viewer);
 static void fancy_show_notice(FancyViewer *viewer, const gchar *message);
 static size_t download_file_curl_write_cb(void *buffer, size_t size, 
@@ -97,6 +98,26 @@ static GtkWidget *fancy_get_widget(MimeViewer *_viewer)
        return GTK_WIDGET(viewer->vbox);
 }
 
+static void fancy_set_defaults(FancyViewer *viewer)
+{
+       viewer->override_prefs_inner_navigation = fancy_prefs.enable_inner_navigation;
+       viewer->override_prefs_external = fancy_prefs.open_external;
+       viewer->override_prefs_images = fancy_prefs.auto_load_images;
+       viewer->override_prefs_scripts = fancy_prefs.enable_scripts;
+       viewer->override_prefs_plugins = fancy_prefs.enable_plugins;
+       viewer->override_prefs_java = fancy_prefs.enable_java;
+}
+
+static void fancy_load_uri(FancyViewer *viewer, const gchar *uri)
+{
+       viewer->load_page = FALSE;
+#if WEBKIT_CHECK_VERSION(1,1,1)
+       webkit_web_view_load_uri(viewer->view, uri);
+#else
+       webkit_web_view_open(viewer->view, uri);
+#endif
+}
+
 static gboolean fancy_show_mimepart_real(MimeViewer *_viewer)
 {
        FancyViewer *viewer = (FancyViewer *) _viewer;
@@ -141,11 +162,10 @@ static gboolean fancy_show_mimepart_real(MimeViewer *_viewer)
                gchar *tmp = g_filename_to_uri(viewer->filename, NULL, NULL);
                debug_print("zoom_level: %i\n", fancy_prefs.zoom_level);
                webkit_web_view_set_zoom_level(viewer->view, (fancy_prefs.zoom_level / 100.0));
-#if WEBKIT_CHECK_VERSION(1,1,1)
-               webkit_web_view_load_uri(viewer->view, tmp);
-#else
-               webkit_web_view_open(viewer->view, tmp);
-#endif
+               fancy_set_defaults(viewer);
+
+               fancy_load_uri(viewer, tmp);
+
                g_free(tmp);
        }
        viewer->loading = FALSE;
@@ -225,7 +245,7 @@ static void fancy_print(MimeViewer *_viewer)
 
        outfile = get_tmp_file();
        cmd = g_strdup_printf("%s%s -o %s %s", program, 
-                                                 fancy_prefs.auto_load_images?"":" -T", outfile, 
+                                                 viewer->override_prefs_images ? "":" -T", outfile, 
                                                  viewer->filename);
 
        g_free(program);
@@ -320,23 +340,17 @@ static gchar *fancy_get_selection (MimeViewer *_viewer)
        }
        return sel; 
 }
+
 static void fancy_clear_viewer(MimeViewer *_viewer)
 {
        FancyViewer *viewer = (FancyViewer *) _viewer;
        GtkAdjustment *vadj;
-       viewer->load_page = FALSE;    
+       viewer->load_page = FALSE;
        viewer->cur_link = NULL;
-       viewer->override_prefs_block_extern_content = FALSE;
-       viewer->override_prefs_external = FALSE;
-       viewer->override_prefs_images = FALSE;
-       viewer->override_prefs_scripts = FALSE;
-       viewer->override_prefs_plugins = FALSE;
-       viewer->override_prefs_java = FALSE;
-#if WEBKIT_CHECK_VERSION(1,1,1)
-       webkit_web_view_load_uri(viewer->view, "about:blank");
-#else
-       webkit_web_view_open(viewer->view, "about:blank");
-#endif
+       fancy_set_defaults(viewer);
+
+       fancy_load_uri(viewer, "about:blank");
+
        debug_print("fancy_clear_viewer\n");
        fancy_prefs.zoom_level = webkit_web_view_get_zoom_level(viewer->view) * 100;
        viewer->to_load = NULL;
@@ -354,18 +368,13 @@ static void fancy_destroy_viewer(MimeViewer *_viewer)
        g_free(viewer);
 }
 
-static WebKitNavigationResponse fancy_open_uri (FancyViewer *viewer, gboolean external) {
+static WebKitNavigationResponse fancy_open_uri (FancyViewer *viewer) {
        if (viewer->load_page) {
                /* handle mailto scheme */
                if (!strncmp(viewer->cur_link,"mailto:", 7)) {
                        compose_new(NULL, viewer->cur_link + 7, NULL);
                        return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
                }
-               /* If we're not blocking, do we open with internal or external? */
-               else if(external) {
-                       open_in_browser_cb(NULL, viewer);
-                       return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
-               }
                else {
                        viewer->load_page = TRUE;
                        return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
@@ -381,40 +390,53 @@ static WebKitNavigationResponse
 navigation_requested_cb(WebKitWebView *view, WebKitWebFrame *frame, 
                                                WebKitNetworkRequest *netreq, FancyViewer *viewer)
 {
+       debug_print("nav to %s\n", webkit_network_request_get_uri(netreq));
+
        g_object_set(viewer->settings, "auto-load-images",
-               fancy_prefs.auto_load_images || viewer->override_prefs_images,
-               NULL);
+               viewer->override_prefs_images, NULL);
        g_object_set(viewer->settings, "enable-scripts",
-               fancy_prefs.enable_scripts || viewer->override_prefs_scripts,
-               NULL);
+               viewer->override_prefs_scripts, NULL);
        g_object_set(viewer->settings, "enable-plugins",
-               fancy_prefs.enable_plugins || viewer->override_prefs_plugins,
-               NULL);
+               viewer->override_prefs_plugins, NULL);
        g_object_set(viewer->settings, "enable-java-applet",
-               fancy_prefs.enable_java || viewer->override_prefs_java,
-               NULL);
+               viewer->override_prefs_java, NULL);
 
        webkit_web_view_set_settings(viewer->view, viewer->settings);
 
-       if (fancy_prefs.block_extern_content && !viewer->override_prefs_block_extern_content) {
-               if (viewer->load_page) {
-                       gchar *message = g_strdup_printf(_("Navigation to %s blocked"), viewer->cur_link);
-                       fancy_show_notice(viewer, message);
-                       g_free(message);
-                       return WEBKIT_NAVIGATION_RESPONSE_IGNORE; 
+       if (viewer->load_page) {
+               switch(viewer->nav_mode) {
+               case NAV_DEFAULT:
+                       debug_print("Open default\n");
+                       /* will be handled besides */
+                       break;
+               case NAV_INNER:
+                       debug_print("Open inner\n");
+                       viewer->nav_mode = NAV_DEFAULT;
+                       return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
+                       break;
+               case NAV_OUTER:
+                       debug_print("Open outer\n");
+                       viewer->nav_mode = NAV_DEFAULT;
+                       return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
+                       break;
                }
-       } 
-
-       if (viewer->cur_link) {
-               if (!fancy_prefs.open_external && !viewer->override_prefs_external)
-                       return fancy_open_uri(viewer, FALSE);
-               else 
-                       return fancy_open_uri(viewer, TRUE);
+       } else {
+               viewer->load_page = TRUE;
+               return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
        }
 
-       viewer->load_page = TRUE;
-       return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
+       if (viewer->override_prefs_external) {
+               open_uri(webkit_network_request_get_uri(netreq),
+                        prefs_common_get_uri_cmd());
+               return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
+       } else if (viewer->override_prefs_inner_navigation) {
+               return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
+       } else {
+               fancy_show_notice(viewer, _("Navigation is disabled."));
+               return WEBKIT_NAVIGATION_RESPONSE_IGNORE; 
+       }
 }
+
 #if WEBKIT_CHECK_VERSION (1,1,14)
 static void resource_request_starting_cb(WebKitWebView                 *view, 
                                                                                 WebKitWebFrame                 *frame,
@@ -460,91 +482,65 @@ static gboolean fancy_text_search(MimeViewer *_viewer, gboolean backward,
                                                                           case_sens, !backward, TRUE);
 }
 
-static void fancy_auto_load_images_activated(GtkMenuItem *item, FancyViewer *viewer) {
+static void fancy_auto_load_images_activated(GtkCheckMenuItem *item, FancyViewer *viewer) {
        viewer->load_page = FALSE;
-       viewer->override_prefs_images = TRUE;
+       viewer->override_prefs_images = gtk_check_menu_item_get_active(item);
        webkit_web_view_reload (viewer->view);
 }
-static void fancy_block_extern_content_activated(GtkMenuItem *item, FancyViewer *viewer) {
-       viewer->override_prefs_block_extern_content = TRUE;
-       gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE);
+
+static void fancy_enable_inner_navigation_activated(GtkCheckMenuItem *item, FancyViewer *viewer) {
+       viewer->override_prefs_inner_navigation = gtk_check_menu_item_get_active(item);
 }
-static void fancy_enable_scripts_activated(GtkMenuItem *item, FancyViewer *viewer) {
+
+static void fancy_enable_scripts_activated(GtkCheckMenuItem *item, FancyViewer *viewer) {
        viewer->load_page = FALSE;
-       viewer->override_prefs_scripts = TRUE;
-       gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE);
+       viewer->override_prefs_scripts = gtk_check_menu_item_get_active(item);
        webkit_web_view_reload (viewer->view);
 }
-static void fancy_enable_plugins_activated(GtkMenuItem *item, FancyViewer *viewer) {
+
+static void fancy_enable_plugins_activated(GtkCheckMenuItem *item, FancyViewer *viewer) {
        viewer->load_page = FALSE;
-       viewer->override_prefs_plugins = TRUE;
-       gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE);
+       viewer->override_prefs_plugins = gtk_check_menu_item_get_active(item);
        webkit_web_view_reload (viewer->view);
 }
-static void fancy_enable_java_activated(GtkMenuItem *item, FancyViewer *viewer) {
+
+static void fancy_enable_java_activated(GtkCheckMenuItem *item, FancyViewer *viewer) {
        viewer->load_page = FALSE;
-       viewer->override_prefs_java = TRUE;
-       gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE);
+       viewer->override_prefs_java = gtk_check_menu_item_get_active(item);
        webkit_web_view_reload (viewer->view);
 }
-static void fancy_open_external_activated(GtkMenuItem *item, FancyViewer *viewer) {
-       viewer->override_prefs_external = TRUE;
-       gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE);
+
+static void fancy_open_external_activated(GtkCheckMenuItem *item, FancyViewer *viewer) {
+       viewer->override_prefs_external = gtk_check_menu_item_get_active(item);
 }
 
 static gboolean fancy_prefs_cb(GtkWidget *widget, GdkEventButton *ev, FancyViewer *viewer)
 {
        if ((ev->button == 1) && (ev->type == GDK_BUTTON_PRESS)) {
                /* Set sensitivity according to preferences and overrides */
-               if (fancy_prefs.auto_load_images)
-                       gtk_widget_set_sensitive(viewer->auto_load_images, FALSE);
-               else { 
-                       if (viewer->override_prefs_images)
-                               gtk_widget_set_sensitive(viewer->auto_load_images, FALSE);
-                       else
-                               gtk_widget_set_sensitive(viewer->auto_load_images, TRUE);
-               }
-               if (fancy_prefs.enable_scripts)
-                       gtk_widget_set_sensitive(viewer->enable_scripts, FALSE);
-               else {
-                       if (viewer->override_prefs_scripts)
-                               gtk_widget_set_sensitive(viewer->enable_scripts, FALSE);
-                       else
-                               gtk_widget_set_sensitive(viewer->enable_scripts, TRUE);
-               }
+               gtk_check_menu_item_set_active(
+                       GTK_CHECK_MENU_ITEM(viewer->auto_load_images),
+                       viewer->override_prefs_images);
 
-               if (fancy_prefs.enable_plugins)
-                       gtk_widget_set_sensitive(viewer->enable_plugins, FALSE);
-               else {
-                       if (viewer->override_prefs_plugins) 
-                               gtk_widget_set_sensitive(viewer->enable_plugins, FALSE);
-                       else
-                               gtk_widget_set_sensitive(viewer->enable_plugins, TRUE);
-               }
-               if (fancy_prefs.enable_java)
-                       gtk_widget_set_sensitive(viewer->enable_java, FALSE);
-               else {
-                       if (viewer->override_prefs_java) 
-                               gtk_widget_set_sensitive(viewer->enable_java, FALSE);
-                       else
-                               gtk_widget_set_sensitive(viewer->enable_java, TRUE);
-               }
-               if (!fancy_prefs.block_extern_content)
-                       gtk_widget_set_sensitive(viewer->block_extern_content, FALSE);
-               else {
-                       if (viewer->override_prefs_block_extern_content)
-                               gtk_widget_set_sensitive(viewer->block_extern_content, FALSE);
-                       else
-                               gtk_widget_set_sensitive(viewer->block_extern_content, TRUE);
-               }
-               if (fancy_prefs.open_external)
-                       gtk_widget_set_sensitive(viewer->open_external, FALSE);
-               else {
-                       if (viewer->override_prefs_external)
-                               gtk_widget_set_sensitive(viewer->open_external, FALSE);
-                       else
-                               gtk_widget_set_sensitive(viewer->open_external, TRUE);
-               }
+               gtk_check_menu_item_set_active(
+                       GTK_CHECK_MENU_ITEM(viewer->enable_scripts),
+                       viewer->override_prefs_scripts);
+
+               gtk_check_menu_item_set_active(
+                       GTK_CHECK_MENU_ITEM(viewer->enable_plugins),
+                       viewer->override_prefs_plugins);
+
+               gtk_check_menu_item_set_active(
+                       GTK_CHECK_MENU_ITEM(viewer->enable_java),
+                       viewer->override_prefs_java);
+
+               gtk_check_menu_item_set_active(
+                       GTK_CHECK_MENU_ITEM(viewer->enable_inner_navigation),
+                       viewer->override_prefs_inner_navigation);
+
+               gtk_check_menu_item_set_active(
+                       GTK_CHECK_MENU_ITEM(viewer->open_external),
+                       viewer->override_prefs_external);
 
                gtk_menu_popup(GTK_MENU(viewer->fancy_prefs_menu), NULL, NULL, NULL, NULL,
                                           ev->button, ev->time);
@@ -555,50 +551,39 @@ static gboolean fancy_prefs_cb(GtkWidget *widget, GdkEventButton *ev, FancyViewe
 
 static void fancy_create_popup_prefs_menu(FancyViewer *viewer) {
        GtkWidget *auto_load_images;
-       GtkWidget *item_image;
-       GtkWidget *block_extern_content;
+       GtkWidget *enable_inner_navigation;
        GtkWidget *enable_scripts;
        GtkWidget *enable_plugins;
        GtkWidget *enable_java;
        GtkWidget *open_external;
 
-       auto_load_images = gtk_image_menu_item_new_with_label(_("Load images"));
-       item_image = gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
-       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(auto_load_images), item_image);
-
-       block_extern_content = gtk_image_menu_item_new_with_label(_("Unblock external content"));
-       item_image = gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
-       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(block_extern_content), item_image);
-
-       enable_scripts = gtk_image_menu_item_new_with_label(_("Enable Javascript"));
-       item_image = gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
-       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(enable_scripts), item_image);
-       item_image = gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
-       enable_plugins = gtk_image_menu_item_new_with_label(_("Enable Plugins"));
-       item_image = gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
-       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(enable_plugins), item_image);
-       enable_java = gtk_image_menu_item_new_with_label(_("Enable Java"));
-       item_image = gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
-       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(enable_java), item_image);
-       open_external = gtk_image_menu_item_new_with_label(_("Open links with external browser"));
-       item_image = gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU);
-       gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(open_external), item_image);
-
-       g_signal_connect(G_OBJECT(auto_load_images), "activate",
+       auto_load_images = gtk_check_menu_item_new_with_label(_("Load images"));
+
+       enable_inner_navigation = gtk_check_menu_item_new_with_label(_("Enable inner navigation"));
+
+       enable_scripts = gtk_check_menu_item_new_with_label(_("Enable Javascript"));
+
+       enable_plugins = gtk_check_menu_item_new_with_label(_("Enable Plugins"));
+
+       enable_java = gtk_check_menu_item_new_with_label(_("Enable Java"));
+
+       open_external = gtk_check_menu_item_new_with_label(_("Open links with external browser"));
+
+       g_signal_connect(G_OBJECT(auto_load_images), "toggled",
                                         G_CALLBACK (fancy_auto_load_images_activated), viewer);
-       g_signal_connect(G_OBJECT(block_extern_content), "activate",
-                                        G_CALLBACK (fancy_block_extern_content_activated), viewer);
-       g_signal_connect(G_OBJECT(enable_scripts), "activate",
+       g_signal_connect(G_OBJECT(enable_inner_navigation), "toggled",
+                                        G_CALLBACK (fancy_enable_inner_navigation_activated), viewer);
+       g_signal_connect(G_OBJECT(enable_scripts), "toggled",
                                         G_CALLBACK (fancy_enable_scripts_activated), viewer);
-       g_signal_connect(G_OBJECT(enable_plugins), "activate",
+       g_signal_connect(G_OBJECT(enable_plugins), "toggled",
                                         G_CALLBACK (fancy_enable_plugins_activated), viewer);
-       g_signal_connect(G_OBJECT(enable_java), "activate",
+       g_signal_connect(G_OBJECT(enable_java), "toggled",
                                         G_CALLBACK (fancy_enable_java_activated), viewer);
-       g_signal_connect(G_OBJECT(open_external), "activate",
+       g_signal_connect(G_OBJECT(open_external), "toggled",
                                         G_CALLBACK (fancy_open_external_activated), viewer);
 
        gtk_menu_shell_append(GTK_MENU_SHELL(viewer->fancy_prefs_menu), auto_load_images);
-       gtk_menu_shell_append(GTK_MENU_SHELL(viewer->fancy_prefs_menu), block_extern_content);
+       gtk_menu_shell_append(GTK_MENU_SHELL(viewer->fancy_prefs_menu), enable_inner_navigation);
        gtk_menu_shell_append(GTK_MENU_SHELL(viewer->fancy_prefs_menu), enable_scripts);
        gtk_menu_shell_append(GTK_MENU_SHELL(viewer->fancy_prefs_menu), enable_plugins);
        gtk_menu_shell_append(GTK_MENU_SHELL(viewer->fancy_prefs_menu), enable_java);
@@ -611,7 +596,7 @@ static void fancy_create_popup_prefs_menu(FancyViewer *viewer) {
        viewer->enable_scripts = enable_scripts;
        viewer->enable_plugins = enable_plugins;
        viewer->enable_java = enable_java;
-       viewer->block_extern_content = block_extern_content;
+       viewer->enable_inner_navigation = enable_inner_navigation;
        viewer->open_external = open_external;
 
 }
@@ -712,10 +697,20 @@ static void search_the_web_cb(GtkWidget *widget, FancyViewer *viewer)
        }
 }
 
+static void open_inner_cb(GtkWidget *widget, FancyViewer *viewer)
+{
+       debug_print("open inner: %s\n", viewer->cur_link);
+       if(viewer->cur_link) {
+               viewer->nav_mode = NAV_INNER;
+               fancy_load_uri(viewer, viewer->cur_link);
+       }
+}
+
 static void open_in_browser_cb(GtkWidget *widget, FancyViewer *viewer)
 {
-       debug_print("link: %s\n", viewer->cur_link);
-       open_uri(viewer->cur_link, prefs_common_get_uri_cmd());
+       debug_print("open outer: %s\n", viewer->cur_link);
+       if(viewer->cur_link)
+               open_uri(viewer->cur_link, prefs_common_get_uri_cmd());
 }
 
 static size_t download_file_curl_write_cb(void *buffer, size_t size, 
@@ -804,35 +799,41 @@ static void viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer)
 {
        const gchar *g_name = gtk_widget_get_name(GTK_WIDGET(menuitem));
        if (!g_ascii_strcasecmp(g_name, "GtkImageMenuItem")) {
-               
+
                GtkWidget *menul = gtk_bin_get_child(GTK_BIN(menuitem));
-        
+
         if (!g_ascii_strcasecmp(gtk_label_get_text(GTK_LABEL(menul)), 
                                                                "Search the Web")) {
                        gtk_label_set_text(GTK_LABEL(menul), _("Search the Web"));
-                
-                       if (fancy_prefs.block_extern_content) {
-                               gtk_widget_set_sensitive(GTK_WIDGET(menul), FALSE);
-                       } else {
-                               viewer->cur_link = NULL;
-                               GtkImageMenuItem *m_search = GTK_IMAGE_MENU_ITEM(menuitem);
-                               g_signal_connect(G_OBJECT(m_search), "activate",
-                                                                G_CALLBACK(search_the_web_cb),
-                                                                (gpointer *) viewer);
-                       }
+                       viewer->cur_link = NULL;
+                       GtkImageMenuItem *m_search = GTK_IMAGE_MENU_ITEM(menuitem);
+                       g_signal_connect(G_OBJECT(m_search), "activate",
+                                                        G_CALLBACK(search_the_web_cb),
+                                                        (gpointer *) viewer);
+               }
+
+               if (!g_ascii_strcasecmp(gtk_label_get_text(GTK_LABEL(menul)), 
+                                                               "Open Link" )) {
+
+                       gtk_label_set_text(GTK_LABEL(menul), _("Open in Viewer"));
+
+                       GtkImageMenuItem *m_new = GTK_IMAGE_MENU_ITEM(menuitem);
+                       g_signal_connect(G_OBJECT(m_new), "activate",
+                                                        G_CALLBACK(open_inner_cb),
+                                                        (gpointer *) viewer);
                }
 
                if (!g_ascii_strcasecmp(gtk_label_get_text(GTK_LABEL(menul)), 
                                                                "Open Link in New Window" )) {
-                
+
                        gtk_label_set_text(GTK_LABEL(menul), _("Open in Browser"));
-               
+
                        GtkImageMenuItem *m_new = GTK_IMAGE_MENU_ITEM(menuitem);
                        g_signal_connect(G_OBJECT(m_new), "activate",
                                                         G_CALLBACK(open_in_browser_cb),
                                                         (gpointer *) viewer);
                }
-            
+
                if (!g_ascii_strcasecmp(gtk_label_get_text(GTK_LABEL(menul)), 
                                                                "Open Image in New Window" )) {
                        gtk_label_set_text(GTK_LABEL(menul), _("Open Image"));
@@ -853,17 +854,6 @@ static void viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer)
                        gtk_label_set_text(GTK_LABEL(menul), _("Download Link"));
 
                        GtkImageMenuItem *m_dlink = GTK_IMAGE_MENU_ITEM(menuitem);
-                       if (!fancy_prefs.block_extern_content) {
-                               gtk_widget_set_sensitive(GTK_WIDGET(menul), TRUE);
-                       }
-                       else {
-                               if (viewer->override_prefs_block_extern_content) {
-                                       gtk_widget_set_sensitive(GTK_WIDGET(menul), TRUE);
-                               }
-                               else {
-                                       gtk_widget_set_sensitive(GTK_WIDGET(menul), FALSE);
-                               }
-                       }
                        g_signal_connect(G_OBJECT(m_dlink), "activate",
                                                         G_CALLBACK(download_file_cb),
                                                         (gpointer *) viewer);
@@ -875,17 +865,6 @@ static void viewer_menu_handler(GtkWidget *menuitem, FancyViewer *viewer)
                        gtk_label_set_text(GTK_LABEL(menul), _("Save Image As"));
 
                        GtkImageMenuItem *m_simage = GTK_IMAGE_MENU_ITEM(menuitem);
-                       if (!fancy_prefs.block_extern_content) {
-                               gtk_widget_set_sensitive(GTK_WIDGET(menul), TRUE);
-                       }
-                       else {
-                               if (viewer->override_prefs_block_extern_content) {
-                                       gtk_widget_set_sensitive(GTK_WIDGET(menul), TRUE);
-                               }
-                               else {
-                                       gtk_widget_set_sensitive(GTK_WIDGET(menul), FALSE);
-                }
-                       }
                        g_signal_connect(G_OBJECT(m_simage), "activate", 
                                                         G_CALLBACK(download_file_cb), (gpointer *) viewer);
                }
index 954a8a093ee6f18066b34d3d8089520448875c2d..dd12534325cd5191b5da7838e80a6214950c2a9e 100644 (file)
 #include <libsoup/soup-gnome.h>
 #endif
 
+typedef enum _NavigationMode {
+       NAV_DEFAULT,
+       NAV_INNER,
+       NAV_OUTER
+} NavigationMode;
+
 typedef struct _FancyViewer FancyViewer;
 struct _FancyViewer
 {
@@ -87,7 +93,7 @@ struct _FancyViewer
        GtkWidget         *enable_scripts;
        GtkWidget         *enable_plugins;
        GtkWidget                 *enable_java;
-       GtkWidget         *block_extern_content;
+       GtkWidget         *enable_inner_navigation;
        GtkWidget         *open_external;
 
        GtkWidget         *progress;
@@ -95,7 +101,7 @@ struct _FancyViewer
        gboolean          load_page;
        gboolean          printing;
        gboolean          override_prefs_images;
-       gboolean          override_prefs_block_extern_content;
+       gboolean          override_prefs_inner_navigation;
        gboolean          override_prefs_scripts;
        gboolean          override_prefs_plugins;
        gboolean          override_prefs_external;
@@ -111,6 +117,7 @@ struct _FancyViewer
        gint              tag;
        gint              loading;
        gint              stop_previous;
+       NavigationMode    nav_mode;
 
        /* DOM Objects */
 #if WEBKIT_CHECK_VERSION(1,5,1)