From b2dbd47c3f06203d4394c10599011734ad77ae32 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Thu, 10 Sep 2009 16:34:47 +0300 Subject: ephy-location-action.c: unblock address sync on switch-page too We need to unblock the address syncing for the location on switch-page too, since it's not guaranteed that we'll receive a focus-out or activate event before we are interested in resyncing the URL entry again. For example, if the focus is on the entry and we switch tabs with the keyboard shortcut the entry will go out of sync, keeping the URL of the previous tab. Bug #594346 --- src/ephy-location-action.c | 52 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 0394d6e4a..66a3c6393 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -39,6 +39,7 @@ struct _EphyLocationActionPrivate { EphyWindow *window; + GtkWidget *proxy; GList *actions; char *address; char *typed_address; @@ -180,12 +181,14 @@ entry_activate_cb (GtkEntry *entry, const char *content; char *address; GtkAction *action; + EphyLocationActionPrivate *priv; action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)); + priv = EPHY_LOCATION_ACTION (action)->priv; - if (EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked) + if (priv->sync_address_is_blocked) { - EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked = FALSE; + priv->sync_address_is_blocked = FALSE; g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy); } @@ -396,11 +399,14 @@ focus_in_event_cb (GtkWidget *entry, GtkWidget *proxy) { GtkAction *action; + EphyLocationActionPrivate *priv; + action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)); - if (!EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked) + priv = EPHY_LOCATION_ACTION (action)->priv; + if (!priv->sync_address_is_blocked) { - EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked = TRUE; + priv->sync_address_is_blocked = TRUE; g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), proxy); } @@ -413,17 +419,37 @@ focus_out_event_cb (GtkWidget *entry, GtkWidget *proxy) { GtkAction *action; + EphyLocationActionPrivate *priv; + action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy)); + priv = EPHY_LOCATION_ACTION (action)->priv; - if (EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked) + if (priv->sync_address_is_blocked) { - EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked = FALSE; + priv->sync_address_is_blocked = FALSE; g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy); } return FALSE; } +static void +switch_page_cb (GtkNotebook *notebook, + GtkNotebookPage *page, + guint page_num, + GtkAction *action) +{ + EphyLocationActionPrivate *priv; + + priv = EPHY_LOCATION_ACTION (action)->priv; + + if (priv->sync_address_is_blocked == TRUE) + { + priv->sync_address_is_blocked = FALSE; + g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), priv->proxy); + } +} + static void connect_proxy (GtkAction *action, GtkWidget *proxy) { @@ -432,6 +458,16 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy); EphyCompletionModel *model; GtkWidget *entry; + GtkWidget *notebook; + EphyLocationActionPrivate *priv; + + priv = EPHY_LOCATION_ACTION (action)->priv; + priv->proxy = proxy; + + notebook = ephy_window_get_notebook (priv->window); + + g_signal_connect (notebook, "switch-page", + G_CALLBACK (switch_page_cb), action); model = ephy_completion_model_new (); ephy_location_entry_set_completion (EPHY_LOCATION_ENTRY (proxy), @@ -504,6 +540,10 @@ disconnect_proxy (GtkAction *action, GtkWidget *proxy) { EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy); GtkWidget *entry; + EphyLocationActionPrivate *priv; + + priv = EPHY_LOCATION_ACTION (action)->priv; + priv->proxy = NULL; entry = ephy_location_entry_get_entry (lentry); -- cgit