diff options
author | Cosimo Cecchi <cosimoc@src.gnome.org> | 2008-05-20 03:36:47 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@src.gnome.org> | 2008-05-20 03:36:47 +0800 |
commit | ef289f5590cb8d65361e022a1e8af73a84602250 (patch) | |
tree | 2951d72d2baa646053759e7db06de421066439bf | |
parent | 53038cbd0c89c5cbda216b16db41f9f7c8038010 (diff) | |
download | gsoc2013-epiphany-ef289f5590cb8d65361e022a1e8af73a84602250.tar gsoc2013-epiphany-ef289f5590cb8d65361e022a1e8af73a84602250.tar.gz gsoc2013-epiphany-ef289f5590cb8d65361e022a1e8af73a84602250.tar.bz2 gsoc2013-epiphany-ef289f5590cb8d65361e022a1e8af73a84602250.tar.lz gsoc2013-epiphany-ef289f5590cb8d65361e022a1e8af73a84602250.tar.xz gsoc2013-epiphany-ef289f5590cb8d65361e022a1e8af73a84602250.tar.zst gsoc2013-epiphany-ef289f5590cb8d65361e022a1e8af73a84602250.zip |
Block updates of the location entry while it is keyboard-focused.
This is to avoid deletion of the text while the user is typing.
Close bug #488680.
svn path=/trunk/; revision=8239
-rw-r--r-- | src/ephy-location-action.c | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 99373f301..420e7c36a 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -58,6 +58,7 @@ struct _EphyLocationActionPrivate guint editable : 1; guint show_lock : 1; guint secure : 1; + gboolean sync_address_is_blocked; }; static void ephy_location_action_init (EphyLocationAction *action); @@ -243,11 +244,20 @@ action_activated_cb (GtkEntryCompletion *completion, static void entry_activate_cb (GtkEntry *entry, - EphyLocationAction *action) + EphyLocationAction *proxy) { EphyBookmarks *bookmarks; const char *content; char *address; + GtkAction *action; + + action = gtk_widget_get_action (GTK_WIDGET (proxy)); + + if (EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked) + { + EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked = FALSE; + g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy); + } content = gtk_entry_get_text (entry); if (content == NULL || content[0] == '\0') return; @@ -450,6 +460,40 @@ add_completion_actions (GtkAction *gaction, G_CALLBACK (action_activated_cb), action); } +static gboolean +focus_in_event_cb (GtkWidget *entry, + GdkEventFocus *event, + GtkWidget *proxy) +{ + GtkAction *action; + action = gtk_widget_get_action (proxy); + + if (!EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked) + { + EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked = TRUE; + g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), proxy); + } + + return FALSE; +} + +static gboolean +focus_out_event_cb (GtkWidget *entry, + GdkEventFocus *event, + GtkWidget *proxy) +{ + GtkAction *action; + action = gtk_widget_get_action (GTK_WIDGET (proxy)); + + if (EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked) + { + EPHY_LOCATION_ACTION (action)->priv->sync_address_is_blocked = FALSE; + g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy); + } + + return FALSE; +} + static void connect_proxy (GtkAction *action, GtkWidget *proxy) { @@ -501,7 +545,7 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) entry = ephy_location_entry_get_entry (lentry); g_signal_connect_object (entry, "activate", G_CALLBACK (entry_activate_cb), - action, 0); + proxy, 0); g_signal_connect_object (proxy, "user-changed", G_CALLBACK (user_changed_cb), action, 0); g_signal_connect_object (proxy, "lock-clicked", @@ -510,6 +554,10 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) G_CALLBACK (get_location_cb), action, 0); g_signal_connect_object (proxy, "get-title", G_CALLBACK (get_title_cb), action, 0); + g_signal_connect_object (entry, "focus-in-event", + G_CALLBACK (focus_in_event_cb), proxy, 0); + g_signal_connect_object (entry, "focus-out-event", + G_CALLBACK (focus_out_event_cb), proxy, 0); } GTK_ACTION_CLASS (ephy_location_action_parent_class)->connect_proxy (action, proxy); @@ -825,6 +873,7 @@ ephy_location_action_init (EphyLocationAction *action) priv->bookmarks = ephy_shell_get_bookmarks (ephy_shell); priv->smart_bmks = ephy_bookmarks_get_smart_bookmarks (action->priv->bookmarks); + priv->sync_address_is_blocked = FALSE; init_actions_list (action); |