diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-06-16 00:15:10 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-06-16 00:15:10 +0800 |
commit | d5b5f70b1cca8ea489ca5be9900d0b47275b5a23 (patch) | |
tree | d797809cd8b2903ba01dde9b147b1a65291d5b32 /embed/mozilla/mozilla-embed.cpp | |
parent | 41eafad36cb938d63f242ccd8dc2ad4988653614 (diff) | |
download | gsoc2013-epiphany-d5b5f70b1cca8ea489ca5be9900d0b47275b5a23.tar gsoc2013-epiphany-d5b5f70b1cca8ea489ca5be9900d0b47275b5a23.tar.gz gsoc2013-epiphany-d5b5f70b1cca8ea489ca5be9900d0b47275b5a23.tar.bz2 gsoc2013-epiphany-d5b5f70b1cca8ea489ca5be9900d0b47275b5a23.tar.lz gsoc2013-epiphany-d5b5f70b1cca8ea489ca5be9900d0b47275b5a23.tar.xz gsoc2013-epiphany-d5b5f70b1cca8ea489ca5be9900d0b47275b5a23.tar.zst gsoc2013-epiphany-d5b5f70b1cca8ea489ca5be9900d0b47275b5a23.zip |
Shift+F10 show context menus on the embed. (Less invasive way until
2003-06-15 Marco Pesenti Gritti <marco@it.gnome.org>
* embed/ephy-embed-event.c: (ephy_embed_event_init):
* embed/ephy-embed-event.h:
* embed/ephy-embed-popup-bw.c: (popup_menu_at_coords),
(ephy_embed_popup_bw_show_impl):
* embed/ephy-embed.c: (ephy_embed_base_init):
* embed/ephy-embed.h:
* embed/mozilla/EventContext.cpp:
* embed/mozilla/EventContext.h:
* embed/mozilla/mozilla-embed.cpp:
* src/ephy-tab.c: (popup_menu_at_coords),
(ephy_tab_show_embed_popup), (ephy_tab_context_menu_cb),
(ephy_tab_init):
Shift+F10 show context menus on the embed.
(Less invasive way until gtkmozembed has a context_menu
signal)
From galeon.
Diffstat (limited to 'embed/mozilla/mozilla-embed.cpp')
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index f578fb198..95dd0190e 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -206,6 +206,9 @@ mozilla_embed_security_change_cb (GtkMozEmbed *embed, guint state, MozillaEmbed *membed); static EmbedSecurityLevel mozilla_embed_security_level (MozillaEmbed *membed); +static gint +mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed, gpointer dom_event, + MozillaEmbed *membed); /* signals to connect on each embed widget */ static const struct @@ -228,6 +231,7 @@ signal_connections[] = { "size_to", (void *) mozilla_embed_size_to_cb }, { "new_window", (void *) mozilla_embed_new_window_cb }, { "security_change", (void *) mozilla_embed_security_change_cb }, + { "dom_key_down", (void *) mozilla_embed_dom_key_down_cb }, /* terminator -- must be last in the list! */ { NULL, NULL } @@ -1312,6 +1316,63 @@ mozilla_embed_visibility_cb (GtkMozEmbed *embed, gboolean visibility, } } +static gint +mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed, gpointer dom_event, + MozillaEmbed *membed) +{ + nsCOMPtr<nsIDOMKeyEvent> ev = static_cast<nsIDOMKeyEvent*>(dom_event); + if (!ev) + { + return FALSE; + } + + EphyWrapper *wrapper = MOZILLA_EMBED(membed)->priv->wrapper; + g_return_val_if_fail (wrapper != NULL, G_FAILED); + + EphyEmbedEvent *info; + info = ephy_embed_event_new (); + + gboolean ret = FALSE; + + // Just check for Shift-F10 so that we know to popup the context menu. + // + // The DOM_VK_* keycodes are not compatible with the keycodes defined + // in GDK, so making a generic dom_key_down signal is probably not + // worth the trouble. + + nsresult rv; + EventContext ctx; + ctx.Init (wrapper); + rv = ctx.GetKeyEventInfo (ev, info); + if (NS_SUCCEEDED(rv) && + (info->keycode == nsIDOMKeyEvent::DOM_VK_F10 && + info->modifier == GDK_SHIFT_MASK)) + { + // Translate relative coordinates to absolute values, and try + // to avoid covering links by adding a little offset. + + int x, y; + gdk_window_get_origin (GTK_WIDGET(membed)->window, &x, &y); + info->x += x + 6; + info->y += y + 6; + + nsCOMPtr<nsIDOMDocument> doc; + rv = ctx.GetTargetDocument (getter_AddRefs(doc)); + if (NS_SUCCEEDED(rv)) + { + rv = wrapper->PushTargetDocument (doc); + if (NS_SUCCEEDED(rv)) + { + g_signal_emit_by_name (membed, "ge_context_menu", info, &ret); + wrapper->PopTargetDocument (); + } + } + } + + g_object_unref (info); + return ret; +} + static void mozilla_embed_destroy_brsr_cb (GtkMozEmbed *embed, MozillaEmbed *membed) @@ -1371,8 +1432,18 @@ static gint mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, MozillaEmbed *membed) { - return mozilla_embed_emit_mouse_signal + int ret; + + ret = mozilla_embed_emit_mouse_signal (membed, dom_event, "ge_dom_mouse_down"); + + if (!ret) + { + ret = mozilla_embed_emit_mouse_signal + (membed, dom_event, "ge_context_menu"); + } + + return ret; } static void |