diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 59 | ||||
-rw-r--r-- | src/ephy-tab.c | 276 |
3 files changed, 158 insertions, 191 deletions
@@ -1,3 +1,17 @@ +2003-05-10 Marco Pesenti Gritti <marco@it.gnome.org> + + * embed/mozilla/mozilla-embed.cpp: + + Share signal emission for all dom mouse events, so + they dont go out of sync. + + * src/ephy-tab.c: (ephy_tab_dom_mouse_click_cb), + (ephy_tab_dom_mouse_down_cb), (ephy_tab_security_change_cb), + (ephy_tab_init): + + Take middle click actions on click instead of on mouse down. + Cleanups. + 2003-05-09 Christopher Blizzard <blizzard@redhat.com> * src/ephy-navigation-action.c (activate_up_menu_item_cb): diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index c65f50a34..aaca63203 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -1318,8 +1318,9 @@ mozilla_embed_destroy_brsr_cb (GtkMozEmbed *embed, } static gint -mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event, - MozillaEmbed *membed) +mozilla_embed_emit_mouse_signal (MozillaEmbed *membed, + gpointer dom_event, + const char *signal_name) { EphyEmbedEvent *info; EventContext event_context; @@ -1334,40 +1335,6 @@ mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event, event_context.Init ((nsIDOMEvent*)dom_event, wrapper); result = event_context.GetMouseEventInfo (info); - - nsCOMPtr<nsIDOMDocument> domDoc; - result = event_context.GetTargetDocument (getter_AddRefs(domDoc)); - if (NS_SUCCEEDED(result)) - { - result = wrapper->PushTargetDocument (domDoc); - } - - g_signal_emit_by_name (membed, "ge_dom_mouse_click", info, &return_value); - - wrapper->PopTargetDocument (); - - g_object_unref (info); - - return return_value; -} - -static gint -mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, - MozillaEmbed *membed) -{ - EphyEmbedEvent *info; - EventContext event_context; - gint return_value = 0; - EphyWrapper *wrapper; - nsresult result; - - info = ephy_embed_event_new (); - - wrapper = MOZILLA_EMBED(membed)->priv->wrapper; - g_return_val_if_fail (wrapper != NULL, G_FAILED); - - event_context.Init ((nsIDOMEvent*)dom_event, wrapper); - result = event_context.GetMouseEventInfo (info); if (NS_SUCCEEDED(result)) { nsCOMPtr<nsIDOMDocument> domDoc; @@ -1377,19 +1344,35 @@ mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, result = wrapper->PushTargetDocument (domDoc); if (NS_SUCCEEDED(result)) { - g_signal_emit_by_name (membed, "ge_dom_mouse_down", + g_signal_emit_by_name (membed, signal_name, info, &return_value); wrapper->PopTargetDocument (); } } } - + g_object_unref (info); return return_value; } +static gint +mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event, + MozillaEmbed *membed) +{ + return mozilla_embed_emit_mouse_signal + (membed, dom_event, "ge_dom_mouse_click"); +} + +static gint +mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, + MozillaEmbed *membed) +{ + return mozilla_embed_emit_mouse_signal + (membed, dom_event, "ge_dom_mouse_down"); +} + static void mozilla_embed_size_to_cb (GtkMozEmbed *embed, gint width, gint height, MozillaEmbed *membed) diff --git a/src/ephy-tab.c b/src/ephy-tab.c index cbf981ebc..e146562d6 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -63,12 +63,9 @@ struct EphyTabPrivate int height; }; -static void -ephy_tab_class_init (EphyTabClass *klass); -static void -ephy_tab_init (EphyTab *tab); -static void -ephy_tab_finalize (GObject *object); +static void ephy_tab_class_init (EphyTabClass *klass); +static void ephy_tab_init (EphyTab *tab); +static void ephy_tab_finalize (GObject *object); enum { @@ -76,53 +73,6 @@ enum PROP_EPHY_SHELL }; -static void -ephy_tab_set_favicon (EphyTab *tab, - GdkPixbuf *favicon); -static void -ephy_tab_favicon_cb (EphyEmbed *embed, - const char *url, - EphyTab *tab); -static void -ephy_tab_favicon_cache_changed_cb (EphyFaviconCache *cache, - char *url, - EphyTab *tab); -static void -ephy_tab_link_message_cb (EphyEmbed *embed, - const char *message, - EphyTab *tab); -static void -ephy_tab_location_cb (EphyEmbed *embed, EphyTab *tab); -static void -ephy_tab_title_cb (EphyEmbed *embed, EphyTab *tab); -static void -ephy_tab_net_state_cb (EphyEmbed *embed, const char *uri, - EmbedState state, EphyTab *tab); -static void -ephy_tab_new_window_cb (EphyEmbed *embed, EphyEmbed **new_embed, - EmbedChromeMask chromemask, EphyTab *tab); -static void -ephy_tab_visibility_cb (EphyEmbed *embed, gboolean visibility, - EphyTab *tab); -static void -ephy_tab_destroy_brsr_cb (EphyEmbed *embed, EphyTab *tab); -static gint -ephy_tab_open_uri_cb (EphyEmbed *embed, const char *uri, - EphyTab *tab); -static void -ephy_tab_size_to_cb (EphyEmbed *embed, gint width, gint height, - EphyTab *tab); -static gint -ephy_tab_dom_mouse_down_cb (EphyEmbed *embed, - EphyEmbedEvent *event, - EphyTab *tab); -static void -ephy_tab_security_change_cb (EphyEmbed *embed, EmbedSecurityLevel level, - EphyTab *tab); -static void -ephy_tab_zoom_changed_cb (EphyEmbed *embed, gint zoom, - EphyTab *tab); - static GObjectClass *parent_class = NULL; /* Class functions */ @@ -186,97 +136,6 @@ ephy_tab_embed_destroy_cb (GtkWidget *widget, EphyTab *tab) } static void -ephy_tab_init (EphyTab *tab) -{ - GObject *embed, *embed_widget; - EphyEmbedSingle *single; - EphyFaviconCache *cache; - - single = ephy_embed_shell_get_embed_single - (EPHY_EMBED_SHELL (ephy_shell)); - - tab->priv = g_new0 (EphyTabPrivate, 1); - - tab->priv->window = NULL; - tab->priv->event = NULL; - tab->priv->is_active = FALSE; - *tab->priv->status_message = '\0'; - tab->priv->link_message = NULL; - *tab->priv->favicon_url = '\0'; - tab->priv->load_status = TAB_LOAD_NONE; - tab->priv->load_percent = 0; - tab->priv->title = NULL; - tab->priv->location = NULL; - tab->priv->total_requests = 0; - tab->priv->cur_requests = 0; - tab->priv->width = -1; - tab->priv->height = -1; - - tab->priv->embed = ephy_embed_new (G_OBJECT(single)); - ephy_embed_shell_add_embed (EPHY_EMBED_SHELL (ephy_shell), - tab->priv->embed); - - embed = G_OBJECT (tab->priv->embed); - embed_widget = G_OBJECT (tab->priv->embed); - - /* set a pointer in the embed's widget back to the tab */ - g_object_set_data (embed_widget, "EphyTab", tab); - - g_signal_connect (embed_widget, "parent_set", - G_CALLBACK (ephy_tab_parent_set_cb), - tab); - g_signal_connect (embed_widget, "destroy", - GTK_SIGNAL_FUNC (ephy_tab_embed_destroy_cb), - tab); - g_signal_connect (embed, "ge_link_message", - GTK_SIGNAL_FUNC (ephy_tab_link_message_cb), - tab); - g_signal_connect (embed, "ge_location", - GTK_SIGNAL_FUNC (ephy_tab_location_cb), - tab); - g_signal_connect (embed, "ge_title", - GTK_SIGNAL_FUNC (ephy_tab_title_cb), - tab); - g_signal_connect (embed, "ge_zoom_change", - GTK_SIGNAL_FUNC (ephy_tab_zoom_changed_cb), - tab); - g_signal_connect (embed, "ge_net_state", - GTK_SIGNAL_FUNC (ephy_tab_net_state_cb), - tab); - g_signal_connect (embed, "ge_new_window", - GTK_SIGNAL_FUNC (ephy_tab_new_window_cb), - tab); - g_signal_connect (embed, "ge_visibility", - GTK_SIGNAL_FUNC (ephy_tab_visibility_cb), - tab); - g_signal_connect (embed, "ge_destroy_brsr", - GTK_SIGNAL_FUNC (ephy_tab_destroy_brsr_cb), - tab); - g_signal_connect (embed, "ge_open_uri", - GTK_SIGNAL_FUNC (ephy_tab_open_uri_cb), - tab); - g_signal_connect (embed, "ge_size_to", - GTK_SIGNAL_FUNC (ephy_tab_size_to_cb), - tab); - g_signal_connect (embed, "ge_dom_mouse_down", - GTK_SIGNAL_FUNC (ephy_tab_dom_mouse_down_cb), - tab); - g_signal_connect (embed, "ge_security_change", - GTK_SIGNAL_FUNC (ephy_tab_security_change_cb), - tab); - g_signal_connect (embed, "ge_favicon", - GTK_SIGNAL_FUNC (ephy_tab_favicon_cb), - tab); - - cache = ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell)); - g_signal_connect_object (G_OBJECT (cache), "changed", - G_CALLBACK (ephy_tab_favicon_cache_changed_cb), - tab, 0); -} - -/* Destructor */ - -static void ephy_tab_finalize (GObject *object) { EphyTab *tab; @@ -963,9 +822,9 @@ ephy_tab_show_embed_popup (EphyTab *tab, EphyEmbedEvent *event) } static gint -ephy_tab_dom_mouse_down_cb (EphyEmbed *embed, - EphyEmbedEvent *event, - EphyTab *tab) +ephy_tab_dom_mouse_click_cb (EphyEmbed *embed, + EphyEmbedEvent *event, + EphyTab *tab) { EphyWindow *window; int button; @@ -979,12 +838,8 @@ ephy_tab_dom_mouse_down_cb (EphyEmbed *embed, ephy_embed_event_get_mouse_button (event, &button); ephy_embed_event_get_context (event, &context); - if (button == 2) - { - ephy_tab_show_embed_popup (tab, event); - } - else if (button == 1 - && (context & EMBED_CONTEXT_LINK)) + if (button == 1 + && (context & EMBED_CONTEXT_LINK)) { const GValue *value; @@ -1008,6 +863,29 @@ ephy_tab_dom_mouse_down_cb (EphyEmbed *embed, return FALSE; } +static gint +ephy_tab_dom_mouse_down_cb (EphyEmbed *embed, + EphyEmbedEvent *event, + EphyTab *tab) +{ + EphyWindow *window; + int button; + + 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_mouse_button (event, &button); + + if (button == 2) + { + ephy_tab_show_embed_popup (tab, event); + } + + return FALSE; +} + static void ephy_tab_security_change_cb (EphyEmbed *embed, EmbedSecurityLevel level, EphyTab *tab) @@ -1018,6 +896,98 @@ ephy_tab_security_change_cb (EphyEmbed *embed, EmbedSecurityLevel level, StatusbarSecurityControl); } +static void +ephy_tab_init (EphyTab *tab) +{ + GObject *embed, *embed_widget; + EphyEmbedSingle *single; + EphyFaviconCache *cache; + + single = ephy_embed_shell_get_embed_single + (EPHY_EMBED_SHELL (ephy_shell)); + + tab->priv = g_new0 (EphyTabPrivate, 1); + + tab->priv->window = NULL; + tab->priv->event = NULL; + tab->priv->is_active = FALSE; + *tab->priv->status_message = '\0'; + tab->priv->link_message = NULL; + *tab->priv->favicon_url = '\0'; + tab->priv->load_status = TAB_LOAD_NONE; + tab->priv->load_percent = 0; + tab->priv->title = NULL; + tab->priv->location = NULL; + tab->priv->total_requests = 0; + tab->priv->cur_requests = 0; + tab->priv->width = -1; + tab->priv->height = -1; + + tab->priv->embed = ephy_embed_new (G_OBJECT(single)); + ephy_embed_shell_add_embed (EPHY_EMBED_SHELL (ephy_shell), + tab->priv->embed); + + embed = G_OBJECT (tab->priv->embed); + embed_widget = G_OBJECT (tab->priv->embed); + + /* set a pointer in the embed's widget back to the tab */ + g_object_set_data (embed_widget, "EphyTab", tab); + + g_signal_connect (embed_widget, "parent_set", + G_CALLBACK (ephy_tab_parent_set_cb), + tab); + g_signal_connect (embed_widget, "destroy", + G_CALLBACK (ephy_tab_embed_destroy_cb), + tab); + g_signal_connect (embed, "ge_link_message", + G_CALLBACK (ephy_tab_link_message_cb), + tab); + g_signal_connect (embed, "ge_location", + G_CALLBACK (ephy_tab_location_cb), + tab); + g_signal_connect (embed, "ge_title", + G_CALLBACK (ephy_tab_title_cb), + tab); + g_signal_connect (embed, "ge_zoom_change", + G_CALLBACK (ephy_tab_zoom_changed_cb), + tab); + g_signal_connect (embed, "ge_net_state", + G_CALLBACK (ephy_tab_net_state_cb), + tab); + g_signal_connect (embed, "ge_new_window", + G_CALLBACK (ephy_tab_new_window_cb), + tab); + g_signal_connect (embed, "ge_visibility", + G_CALLBACK (ephy_tab_visibility_cb), + tab); + g_signal_connect (embed, "ge_destroy_brsr", + G_CALLBACK (ephy_tab_destroy_brsr_cb), + tab); + g_signal_connect (embed, "ge_open_uri", + G_CALLBACK (ephy_tab_open_uri_cb), + tab); + g_signal_connect (embed, "ge_size_to", + G_CALLBACK (ephy_tab_size_to_cb), + tab); + g_signal_connect (embed, "ge_dom_mouse_down", + G_CALLBACK (ephy_tab_dom_mouse_down_cb), + tab); + g_signal_connect (embed, "ge_dom_mouse_click", + G_CALLBACK (ephy_tab_dom_mouse_click_cb), + tab); + g_signal_connect (embed, "ge_security_change", + G_CALLBACK (ephy_tab_security_change_cb), + tab); + g_signal_connect (embed, "ge_favicon", + G_CALLBACK (ephy_tab_favicon_cb), + tab); + + cache = ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell)); + g_signal_connect_object (G_OBJECT (cache), "changed", + G_CALLBACK (ephy_tab_favicon_cache_changed_cb), + tab, 0); +} + TabLoadStatus ephy_tab_get_load_status (EphyTab *tab) { |