aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ephy-tab.c100
-rw-r--r--src/ephy-tab.h3
-rw-r--r--src/ephy-window.c119
-rw-r--r--src/ephy-window.h1
4 files changed, 124 insertions, 99 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 35a50e712..5aab758b2 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -876,7 +876,7 @@ ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height,
g_list_free (tabs);
}
-static void
+void
ephy_tab_set_event (EphyTab *tab,
EphyEmbedEvent *event)
{
@@ -885,71 +885,6 @@ ephy_tab_set_event (EphyTab *tab,
tab->priv->event = event;
}
-static void
-popup_menu_at_coords (GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
- gpointer user_data)
-{
- EphyEmbedEvent *event = user_data;
-
- *x = event->x;
- *y = event->y;
- *push_in = FALSE;
-}
-
-static void
-ephy_tab_show_embed_popup (EphyTab *tab, EphyEmbedEvent *event)
-{
- EmbedEventContext context;
- const char *popup;
- const GValue *value;
- gboolean framed;
- EphyWindow *window;
- char *path;
- GtkWidget *widget;
-
- g_return_if_fail (IS_EPHY_TAB (tab));
- window = tab->priv->window;
-
- ephy_embed_event_get_property (event, "framed_page", &value);
- framed = g_value_get_int (value);
-
- ephy_embed_event_get_context (event, &context);
-
- if ((context & EMBED_CONTEXT_LINK) &&
- (context & EMBED_CONTEXT_IMAGE))
- {
- popup = "EphyImageLinkPopup";
- }
- else if (context & EMBED_CONTEXT_LINK)
- {
- popup = "EphyLinkPopup";
- }
- else if (context & EMBED_CONTEXT_IMAGE)
- {
- popup = "EphyImagePopup";
- }
- else if (context & EMBED_CONTEXT_INPUT)
- {
- popup = "EphyInputPopup";
- }
- else
- {
- popup = framed ? "EphyFramedDocumentPopup" :
- "EphyDocumentPopup";
- }
-
- path = g_strconcat ("/popups/", popup, NULL);
- widget = egg_menu_merge_get_widget (EGG_MENU_MERGE (window->ui_merge),
- path);
- g_free (path);
-
- g_return_if_fail (widget != NULL);
-
- ephy_tab_set_event (tab, event);
- gtk_menu_popup (GTK_MENU (widget), NULL, NULL, popup_menu_at_coords, event, 2,
- gtk_get_current_event_time ());
-}
-
static gint
ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
EphyEmbedEvent *event,
@@ -993,36 +928,6 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
return FALSE;
}
-static gint
-ephy_tab_context_menu_cb (EphyEmbed *embed,
- EphyEmbedEvent *event,
- EphyTab *tab)
-{
- EphyWindow *window;
- EphyEmbedEventType type;
-
- g_assert (IS_EPHY_EMBED_EVENT(event));
-
- window = ephy_tab_get_window (tab);
- g_return_val_if_fail (window != NULL, FALSE);
-
- ephy_embed_event_get_event_type (event, &type);
-
- if (type == EPHY_EMBED_EVENT_MOUSE_BUTTON3)
- {
- ephy_tab_show_embed_popup (tab, event);
- }
- else
- {
- int x, y;
-
- ephy_embed_event_get_coords (event, &x, &y);
- ephy_tab_show_embed_popup (tab, event);
- }
-
- return FALSE;
-}
-
static void
ephy_tab_security_change_cb (EphyEmbed *embed, EmbedSecurityLevel level,
EphyTab *tab)
@@ -1119,9 +1024,6 @@ ephy_tab_init (EphyTab *tab)
g_signal_connect (embed, "ge_size_to",
G_CALLBACK (ephy_tab_size_to_cb),
tab);
- g_signal_connect (embed, "ge_context_menu",
- G_CALLBACK (ephy_tab_context_menu_cb),
- tab);
g_signal_connect (embed, "ge_dom_mouse_click",
G_CALLBACK (ephy_tab_dom_mouse_click_cb),
tab);
diff --git a/src/ephy-tab.h b/src/ephy-tab.h
index 96b40d6ed..cad8754eb 100644
--- a/src/ephy-tab.h
+++ b/src/ephy-tab.h
@@ -68,6 +68,9 @@ EggAction * ephy_tab_get_action (EphyTab *tab);
EphyEmbed * ephy_tab_get_embed (EphyTab *tab);
+void ephy_tab_set_event (EphyTab *tab,
+ EphyEmbedEvent *event);
+
EphyEmbedEvent *ephy_tab_get_event (EphyTab *tab);
void ephy_tab_set_window (EphyTab *tab,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index d7bbd9e24..a4ff3bada 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1024,9 +1024,116 @@ sync_tab_zoom (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
}
static void
+popup_menu_at_coords (GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
+ gpointer user_data)
+{
+ EphyEmbedEvent *event = user_data;
+
+ *x = event->x;
+ *y = event->y;
+ *push_in = FALSE;
+}
+
+static void
+show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
+{
+ EggActionGroup *action_group;
+ EggAction *action;
+ EmbedEventContext context;
+ const char *popup;
+ char *path;
+ const GValue *value;
+ gboolean framed, has_background;
+ GtkWidget *widget;
+
+ ephy_embed_event_get_property (event, "framed_page", &value);
+ framed = g_value_get_int (value);
+
+ has_background = ephy_embed_event_has_property (event, "background_image");
+
+ ephy_embed_event_get_context (event, &context);
+
+ if ((context & EMBED_CONTEXT_LINK) &&
+ (context & EMBED_CONTEXT_IMAGE))
+ {
+ popup = "EphyImageLinkPopup";
+ }
+ else if (context & EMBED_CONTEXT_LINK)
+ {
+ popup = "EphyLinkPopup";
+ }
+ else if (context & EMBED_CONTEXT_IMAGE)
+ {
+ popup = "EphyImagePopup";
+ }
+ else if (context & EMBED_CONTEXT_INPUT)
+ {
+ popup = "EphyInputPopup";
+ }
+ else
+ {
+ popup = framed ? "EphyFramedDocumentPopup" :
+ "EphyDocumentPopup";
+ }
+
+ action_group = window->priv->popups_action_group;
+ action = egg_action_group_get_action (action_group, "SaveBackgroundAs");
+ g_object_set (action, "sensitive", has_background,
+ "visible", has_background, NULL);
+
+ path = g_strconcat ("/popups/", popup, NULL);
+ widget = egg_menu_merge_get_widget (EGG_MENU_MERGE (window->ui_merge),
+ path);
+ g_free (path);
+
+ g_return_if_fail (widget != NULL);
+
+ ephy_tab_set_event (tab, event);
+ gtk_menu_popup (GTK_MENU (widget), NULL, NULL, popup_menu_at_coords, event, 2,
+ gtk_get_current_event_time ());
+}
+
+static gint
+tab_context_menu_cb (EphyEmbed *embed,
+ EphyEmbedEvent *event,
+ EphyWindow *window)
+{
+ EphyTab *tab;
+ EphyEmbedEventType type;
+
+ g_return_val_if_fail (IS_EPHY_WINDOW (window), FALSE);
+ g_return_val_if_fail (IS_EPHY_EMBED (embed), FALSE);
+ g_assert (IS_EPHY_EMBED_EVENT(event));
+
+ tab = EPHY_TAB (g_object_get_data (G_OBJECT (embed), "EphyTab"));
+ g_return_val_if_fail (IS_EPHY_TAB (tab), FALSE);
+ g_return_val_if_fail (window->priv->active_tab == tab, FALSE);
+
+ window = ephy_tab_get_window (tab);
+ g_return_val_if_fail (window != NULL, FALSE);
+
+ ephy_embed_event_get_event_type (event, &type);
+
+ if (type == EPHY_EMBED_EVENT_MOUSE_BUTTON3)
+ {
+ show_embed_popup (window, tab, event);
+ }
+ else
+ {
+ int x, y;
+
+ ephy_embed_event_get_coords (event, &x, &y); // Why?
+ show_embed_popup (window, tab, event);
+ }
+
+ return FALSE;
+}
+
+static void
ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
{
EphyTab *old_tab;
+ EphyEmbed *embed;
g_return_if_fail (IS_EPHY_WINDOW (window));
if (ephy_tab_get_window (new_tab) != window) return;
@@ -1064,6 +1171,11 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab),
G_CALLBACK (sync_tab_zoom),
window);
+
+ embed = ephy_tab_get_embed (old_tab);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (embed),
+ G_CALLBACK (tab_context_menu_cb),
+ window);
}
window->priv->active_tab = new_tab;
@@ -1116,6 +1228,11 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
"notify::zoom",
G_CALLBACK (sync_tab_zoom),
window, 0);
+
+ embed = ephy_tab_get_embed (new_tab);
+ g_signal_connect_object (embed, "ge_context_menu",
+ G_CALLBACK (tab_context_menu_cb),
+ window, 0);
}
}
@@ -1461,6 +1578,8 @@ ephy_window_set_chrome (EphyWindow *window,
GtkWidget *
ephy_window_get_notebook (EphyWindow *window)
{
+ g_return_val_if_fail (IS_EPHY_WINDOW (window), NULL);
+
return GTK_WIDGET (window->priv->notebook);
}
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 378dc76d2..67c6f4000 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -22,6 +22,7 @@
#include "ephy-embed.h"
#include "ephy-dialog.h"
#include "ephy-notebook.h"
+
#include <glib-object.h>
#include <glib.h>
#include <gtk/gtkwindow.h>