[Commits] fancy_prefs.c 1.1.2.1 1.1.2.2 fancy_prefs.h 1.1.2.1 1.1.2.2 fancy_viewer.c 1.1.2.3 1.1.2.4 fancy_viewer.h 1.1.2.3 1.1.2.4
colin at claws-mail.org
colin at claws-mail.org
Wed Mar 6 15:59:05 CET 2013
Update of /home/claws-mail/claws/src/plugins/fancy
In directory srv:/tmp/cvs-serv32557/src/plugins/fancy
Modified Files:
Tag: gtk2
fancy_prefs.c fancy_prefs.h fancy_viewer.c fancy_viewer.h
Log Message:
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.
Index: fancy_prefs.c
===================================================================
RCS file: /home/claws-mail/claws/src/plugins/fancy/Attic/fancy_prefs.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- fancy_prefs.c 13 Feb 2013 16:38:37 -0000 1.1.2.1
+++ fancy_prefs.c 6 Mar 2013 14:59:03 -0000 1.1.2.2
@@ -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 @@
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 @@
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 @@
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 @@
GtkWidget *checkbox2;
GtkWidget *checkbox3;
GtkWidget *checkbox4;
- GtkWidget *checkbox5;
GtkWidget *checkbox6;
vbox = gtk_vbox_new(FALSE, 3);
@@ -185,9 +196,9 @@
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 @@
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 @@
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 @@
#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: fancy_prefs.h
===================================================================
RCS file: /home/claws-mail/claws/src/plugins/fancy/Attic/fancy_prefs.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- fancy_prefs.h 13 Feb 2013 16:38:37 -0000 1.1.2.1
+++ fancy_prefs.h 6 Mar 2013 14:59:03 -0000 1.1.2.2
@@ -29,13 +29,13 @@
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: fancy_viewer.h
===================================================================
RCS file: /home/claws-mail/claws/src/plugins/fancy/Attic/fancy_viewer.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- fancy_viewer.h 20 Feb 2013 12:43:32 -0000 1.1.2.3
+++ fancy_viewer.h 6 Mar 2013 14:59:03 -0000 1.1.2.4
@@ -61,6 +61,12 @@
#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 @@
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 @@
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 @@
gint tag;
gint loading;
gint stop_previous;
+ NavigationMode nav_mode;
/* DOM Objects */
#if WEBKIT_CHECK_VERSION(1,5,1)
Index: fancy_viewer.c
===================================================================
RCS file: /home/claws-mail/claws/src/plugins/fancy/Attic/fancy_viewer.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- fancy_viewer.c 6 Mar 2013 11:22:54 -0000 1.1.2.3
+++ fancy_viewer.c 6 Mar 2013 14:59:03 -0000 1.1.2.4
@@ -74,8 +74,9 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 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);
+ auto_load_images = gtk_check_menu_item_new_with_label(_("Load images"));
- 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_inner_navigation = gtk_check_menu_item_new_with_label(_("Enable inner navigation"));
- 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);
+ enable_scripts = gtk_check_menu_item_new_with_label(_("Enable Javascript"));
- g_signal_connect(G_OBJECT(auto_load_images), "activate",
+ 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 @@
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 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 @@
{
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 @@
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 @@
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);
}
More information about the Commits
mailing list