[epiphany] ephy-location-action.c: unblock address sync on switch-page too



commit b2dbd47c3f06203d4394c10599011734ad77ae32
Author: Xan Lopez <xan gnome org>
Date:   Thu Sep 10 16:34:47 2009 +0300

    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 files changed, 46 insertions(+), 6 deletions(-)
---
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index 0394d6e..66a3c63 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,11 +419,14 @@ 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);
 	}
 	
@@ -425,6 +434,23 @@ focus_out_event_cb (GtkWidget *entry,
 }
 
 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)
 {
 	if (EPHY_IS_LOCATION_ENTRY (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);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]