diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-07-11 03:23:45 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-07-11 03:23:45 +0800 |
commit | 22932f6b1bd176b72473df2a9e05d04448929006 (patch) | |
tree | 3a95f9bc9e414df196e2daa40fdc40bb35473834 | |
parent | bff7388803ea3dad3ef1dac686a24bd2e1edb9b0 (diff) | |
download | gsoc2013-epiphany-22932f6b1bd176b72473df2a9e05d04448929006.tar gsoc2013-epiphany-22932f6b1bd176b72473df2a9e05d04448929006.tar.gz gsoc2013-epiphany-22932f6b1bd176b72473df2a9e05d04448929006.tar.bz2 gsoc2013-epiphany-22932f6b1bd176b72473df2a9e05d04448929006.tar.lz gsoc2013-epiphany-22932f6b1bd176b72473df2a9e05d04448929006.tar.xz gsoc2013-epiphany-22932f6b1bd176b72473df2a9e05d04448929006.tar.zst gsoc2013-epiphany-22932f6b1bd176b72473df2a9e05d04448929006.zip |
Fix middle-click and ctrl-enter in the location entry autocompletion
2006-07-10 Christian Persch <chpe@cvs.gnome.org>
* lib/widgets/ephy-location-entry.c: (entry_key_press_cb),
(entry_key_press_after_cb), (entry_activate_after_cb),
(match_selected_cb), (action_activated_after_cb),
(ephy_location_entry_construct_contents),
(ephy_location_entry_set_completion):
* src/ephy-location-action.c: (action_activated_cb):
Fix middle-click and ctrl-enter in the location entry autocompletion
drop-down. Bug #345934, based on a patch by johannes@sipsolutions.net.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 66 | ||||
-rw-r--r-- | src/ephy-location-action.c | 9 |
3 files changed, 78 insertions, 9 deletions
@@ -1,3 +1,15 @@ +2006-07-10 Christian Persch <chpe@cvs.gnome.org> + + * lib/widgets/ephy-location-entry.c: (entry_key_press_cb), + (entry_key_press_after_cb), (entry_activate_after_cb), + (match_selected_cb), (action_activated_after_cb), + (ephy_location_entry_construct_contents), + (ephy_location_entry_set_completion): + * src/ephy-location-action.c: (action_activated_cb): + + Fix middle-click and ctrl-enter in the location entry autocompletion + drop-down. Bug #345934, based on a patch by johannes@sipsolutions.net. + 2006-07-06 Jean-François Rameau <jframeau@cvs.gnome.org> * embed/mozilla/MozDownload.cpp: (OnProgressChange64): diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c index 7fb12c928..d55a8de28 100644 --- a/lib/widgets/ephy-location-entry.c +++ b/lib/widgets/ephy-location-entry.c @@ -32,6 +32,7 @@ #include "egg-editable-toolbar.h" #include "ephy-stock-icons.h" #include "ephy-debug.h" +#include "ephy-gui.h" #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> @@ -81,6 +82,7 @@ struct _EphyLocationEntryPrivate guint original_address : 1; guint secure : 1; guint apply_colours : 1; + guint needs_reset : 1; }; static const struct @@ -381,6 +383,24 @@ entry_key_press_cb (GtkEntry *entry, { guint state = event->state & gtk_accelerator_get_default_mod_mask (); + if (event->keyval == GDK_Escape && state == 0) + { + ephy_location_entry_reset (lentry); + /* don't return TRUE since we want to cancel the autocompletion popup too */ + } + + return FALSE; +} + +static gboolean +entry_key_press_after_cb (GtkEntry *entry, + GdkEventKey *event, + EphyLocationEntry *lentry) +{ + EphyLocationEntryPrivate *priv = lentry->priv; + + guint state = event->state & gtk_accelerator_get_default_mod_mask (); + if ((event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || event->keyval == GDK_ISO_Enter) && @@ -389,18 +409,26 @@ entry_key_press_cb (GtkEntry *entry, { gtk_im_context_reset (entry->im_context); + priv->needs_reset = TRUE; g_signal_emit_by_name (entry, "activate"); return TRUE; } - if (event->keyval == GDK_Escape && state == 0) + return FALSE; +} + +static void +entry_activate_after_cb (GtkEntry *entry, + EphyLocationEntry *lentry) +{ + EphyLocationEntryPrivate *priv = lentry->priv; + + if (priv->needs_reset) { ephy_location_entry_reset (lentry); - /* don't return TRUE since we want to cancel the autocompletion popup too */ + priv->needs_reset = FALSE; } - - return FALSE; } static gboolean @@ -493,11 +521,17 @@ match_selected_cb (GtkEntryCompletion *completion, { EphyLocationEntryPrivate *priv = entry->priv; char *item = NULL; + guint state; gtk_tree_model_get (model, iter, priv->action_col, &item, -1); if (item == NULL) return FALSE; + ephy_gui_get_current_event (NULL, &state, NULL); + + priv->needs_reset = (state == GDK_CONTROL_MASK || + state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)); + ephy_location_entry_set_location (entry, item, NULL); g_signal_emit_by_name (priv->icon_entry->entry, "activate"); @@ -506,6 +540,22 @@ match_selected_cb (GtkEntryCompletion *completion, return TRUE; } +static void +action_activated_after_cb (GtkEntryCompletion *completion, + gint index, + EphyLocationEntry *lentry) +{ + guint state, button; + + ephy_gui_get_current_event (NULL, &state, &button); + if ((state == GDK_CONTROL_MASK || + state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) || + button == 2) + { + ephy_location_entry_reset (lentry); + } +} + static gboolean toolbar_is_editable (GtkWidget *widget) { @@ -851,6 +901,10 @@ ephy_location_entry_construct_contents (EphyLocationEntry *entry) G_CALLBACK (entry_populate_popup_cb), entry); g_signal_connect (priv->icon_entry->entry, "key-press-event", G_CALLBACK (entry_key_press_cb), entry); + g_signal_connect_after (priv->icon_entry->entry, "key-press-event", + G_CALLBACK (entry_key_press_after_cb), entry); + g_signal_connect_after (priv->icon_entry->entry, "activate", + G_CALLBACK (entry_activate_after_cb), entry); g_signal_connect (priv->icon_entry->entry, "button-press-event", G_CALLBACK (entry_button_press_cb), entry); g_signal_connect (priv->icon_entry->entry, "changed", @@ -934,8 +988,10 @@ ephy_location_entry_set_completion (EphyLocationEntry *le, gtk_entry_completion_set_model (completion, sort_model); g_object_unref (sort_model); gtk_entry_completion_set_match_func (completion, completion_func, le, NULL); - g_signal_connect (completion, "match_selected", + g_signal_connect (completion, "match-selected", G_CALLBACK (match_selected_cb), le); + g_signal_connect_after (completion, "action-activated", + G_CALLBACK (action_activated_after_cb), le); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (completion), diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 922f14298..927c09396 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -135,12 +135,13 @@ action_activated_cb (GtkEntryCompletion *completion, url = ephy_bookmarks_resolve_address (action->priv->bookmarks, smart_url, content); - g_return_if_fail (url != NULL); + g_free (content); + if (url == NULL) return; + + ephy_link_open (EPHY_LINK (action), url, NULL, + ephy_link_flags_from_current_event ()); - ephy_link_open (EPHY_LINK (action), url, NULL, 0); - g_free (url); - g_free (content); } } |