diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-02-26 08:59:17 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-02-26 08:59:17 +0800 |
commit | 2227b7a87f73bea0b61e92aa003d7a5a77c1a583 (patch) | |
tree | f58ff04b5234fae159b52a2976c6ab1b33121f85 /lib | |
parent | a19a320b865685d726ed8a50b36872596ddd70be (diff) | |
download | gsoc2013-epiphany-2227b7a87f73bea0b61e92aa003d7a5a77c1a583.tar gsoc2013-epiphany-2227b7a87f73bea0b61e92aa003d7a5a77c1a583.tar.gz gsoc2013-epiphany-2227b7a87f73bea0b61e92aa003d7a5a77c1a583.tar.bz2 gsoc2013-epiphany-2227b7a87f73bea0b61e92aa003d7a5a77c1a583.tar.lz gsoc2013-epiphany-2227b7a87f73bea0b61e92aa003d7a5a77c1a583.tar.xz gsoc2013-epiphany-2227b7a87f73bea0b61e92aa003d7a5a77c1a583.tar.zst gsoc2013-epiphany-2227b7a87f73bea0b61e92aa003d7a5a77c1a583.zip |
Remove Tab autocompletion. Behavior still not optimal, but that code is
2003-02-26 Marco Pesenti Gritti <marco@it.gnome.org>
* lib/ephy-autocompletion.c: (ephy_autocompletion_init),
(ephy_autocompletion_reset), (ephy_autocompletion_set_key),
(ephy_autocompletion_update_matches):
* lib/ephy-autocompletion.h:
* lib/widgets/ephy-location-entry.c:
(ephy_location_entry_key_press_event_cb),
(ephy_location_entry_autocompletion_sources_changed_cb):
Remove Tab autocompletion. Behavior still not optimal,
but that code is such a pain :(
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-autocompletion.c | 60 | ||||
-rw-r--r-- | lib/ephy-autocompletion.h | 1 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 140 |
3 files changed, 1 insertions, 200 deletions
diff --git a/lib/ephy-autocompletion.c b/lib/ephy-autocompletion.c index 3fd67a5df..24578f126 100644 --- a/lib/ephy-autocompletion.c +++ b/lib/ephy-autocompletion.c @@ -52,7 +52,6 @@ struct _EphyAutocompletionPrivate { gchar **prefixes; guint *prefix_lengths; - gchar *common_prefix; ACMatchArray matches; EphyAutocompletionStatus status; gboolean sorted; @@ -121,7 +120,6 @@ ephy_autocompletion_init (EphyAutocompletion *ac) EphyAutocompletionPrivate *p = g_new0 (EphyAutocompletionPrivate, 1); ac->priv = p; p->sources = NULL; - p->common_prefix = NULL; acma_init (&p->matches); p->status = GAS_NEEDS_FULL_UPDATE; @@ -174,8 +172,6 @@ ephy_autocompletion_reset (EphyAutocompletion *ac) START_PROFILER ("Resetting autocompletion") - g_free (p->common_prefix); - p->common_prefix = NULL; p->status = GAS_NEEDS_FULL_UPDATE; STOP_PROFILER ("Resetting autocompletion") @@ -231,20 +227,10 @@ ephy_autocompletion_set_key (EphyAutocompletion *ac, { p->status = GAS_NEEDS_REFINE; } - if (p->common_prefix) - { - if (strncmp (p->common_prefix, key, keylen)) - { - g_free (p->common_prefix); - p->common_prefix = NULL; - } - } } else { p->status = GAS_NEEDS_FULL_UPDATE; - g_free (p->common_prefix); - p->common_prefix = NULL; } for (i = 0; p->prefixes[i]; ++i) @@ -256,50 +242,6 @@ ephy_autocompletion_set_key (EphyAutocompletion *ac, } -gchar * -ephy_autocompletion_get_common_prefix (EphyAutocompletion *ac) -{ - EphyAutocompletionPrivate *p = ac->priv; - ephy_autocompletion_update_matches (ac); - if (!p->common_prefix) - { - guint common_length = 0; - guint i; - - START_PROFILER ("Get Common Prefix") - - for (i = 0; i < p->matches.num_matches; i++) - { - EphyAutocompletionMatch *mi = &p->matches.array[i]; - const gchar *realmatch = mi->title + mi->offset; - if (!p->common_prefix) - { - p->common_prefix = g_strdup (realmatch); - common_length = strlen (p->common_prefix); - continue; - } - else if (!strncmp (realmatch, p->common_prefix, common_length)) - { - continue; - } - else - { - common_length = 0; - while (realmatch[common_length] - && realmatch[common_length] == p->common_prefix[common_length]) - { - ++common_length; - } - g_free (p->common_prefix); - p->common_prefix = g_strndup (realmatch, common_length); - } - } - - STOP_PROFILER ("Get Common Prefix") - } - return g_strdup (p->common_prefix); -} - const EphyAutocompletionMatch * ephy_autocompletion_get_matches (EphyAutocompletion *ac) { @@ -387,8 +329,6 @@ ephy_autocompletion_update_matches (EphyAutocompletion *ac) ephy_autocompletion_refine_matches (ac); } - g_free (p->common_prefix); - p->common_prefix = NULL; p->status = GAS_UPDATED; } diff --git a/lib/ephy-autocompletion.h b/lib/ephy-autocompletion.h index 06dcc71dc..7a31c0c9f 100644 --- a/lib/ephy-autocompletion.h +++ b/lib/ephy-autocompletion.h @@ -94,7 +94,6 @@ void ephy_autocompletion_set_prefixes (EphyAutocompletion *ac, const gchar **prefixes); void ephy_autocompletion_set_key (EphyAutocompletion *ac, const gchar *key); -gchar * ephy_autocompletion_get_common_prefix (EphyAutocompletion *ac); const EphyAutocompletionMatch *ephy_autocompletion_get_matches (EphyAutocompletion *ac); const EphyAutocompletionMatch *ephy_autocompletion_get_matches_sorted_by_score (EphyAutocompletion *ac, diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c index a2e86e345..e6fde2889 100644 --- a/lib/widgets/ephy-location-entry.c +++ b/lib/widgets/ephy-location-entry.c @@ -68,7 +68,6 @@ static void ephy_location_entry_activate_cb (GtkEntry *entry, EphyLocationEntry *w); static void ephy_location_entry_autocompletion_sources_changed_cb (EphyAutocompletion *aw, EphyLocationEntry *w); -static gint ephy_location_entry_autocompletion_to (EphyLocationEntry *w); static gint ephy_location_entry_autocompletion_show_alternatives_to (EphyLocationEntry *w); static void ephy_location_entry_autocompletion_window_url_activated_cb /***/ (EphyAutocompletionWindow *aw, @@ -290,70 +289,6 @@ ephy_location_entry_autocompletion_unselect_alternatives (EphyLocationEntry *w) } } -static gint -ephy_location_entry_autocompletion_to (EphyLocationEntry *w) -{ - EphyLocationEntryPrivate *p = w->priv; - gchar *text; - gchar *common_prefix; - - LOG ("Autocompletion to") - - ephy_location_entry_set_autocompletion_key (w); - - { - GtkEditable *editable = GTK_EDITABLE (p->entry); - gint sstart, send; - gint pos = gtk_editable_get_position (editable); - const gchar *text = gtk_entry_get_text (GTK_ENTRY (p->entry)); - gint text_len = strlen (text); - gtk_editable_get_selection_bounds (editable, &sstart, &send); - - if (pos != text_len - || send != text_len) - { - /* the user is editing the entry, don't mess it */ - LOG ("The user seems editing the text: pos = %d, strlen (text) = %d, sstart = %d, send = %d", - pos, strlen (text), sstart, send) - p->autocompletion_timeout = 0; - return FALSE; - } - } - - common_prefix = ephy_autocompletion_get_common_prefix (p->autocompletion); - - LOG ("common_prefix: %s", common_prefix) - - if (common_prefix && (!p->before_completion || p->before_completion[0] == '\0')) - { - text = ephy_location_entry_get_location (w); - g_free (p->before_completion); - p->before_completion = text; - } - - if (common_prefix) - { - /* check original length */ - guint text_len = strlen (p->autocompletion_key); - - p->block_set_autocompletion_key = TRUE; - - /* set entry to completed text */ - gtk_entry_set_text (GTK_ENTRY (p->entry), common_prefix); - - /* move selection appropriately */ - gtk_editable_select_region (GTK_EDITABLE (p->entry), text_len, -1); - - p->block_set_autocompletion_key = FALSE; - - g_free (p->last_completion); - p->last_completion = common_prefix; - } - - p->autocompletion_timeout = 0; - return FALSE; -} - static int get_editable_number_of_chars (GtkEditable *editable) { @@ -392,7 +327,6 @@ static gboolean ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, EphyLocationEntry *w) { EphyLocationEntryPrivate *p = w->priv; - static gboolean suggest = FALSE; guint keyval = event->keyval; if (p->autocompletion_timeout != 0) @@ -407,12 +341,6 @@ ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, Ep p->show_alternatives_timeout = 0; } - /* only suggest heuristic completions if TAB is hit twice */ - if (event->keyval != GDK_Tab) - { - suggest = FALSE; - } - if (((event->state & GDK_Control_L || event->state & GDK_Control_R) && (keyval == GDK_a || keyval == GDK_b || keyval == GDK_c || keyval == GDK_d || keyval == GDK_e || keyval == GDK_f || @@ -448,70 +376,13 @@ ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, Ep { case GDK_Left: case GDK_Right: - ephy_location_entry_autocompletion_hide_alternatives (w); - return FALSE; case GDK_Up: case GDK_Down: + case GDK_Escape: case GDK_Page_Up: case GDK_Page_Down: ephy_location_entry_autocompletion_hide_alternatives (w); return FALSE; - case GDK_Tab: - { - gchar *common_prefix = NULL; - gchar *text; - - ephy_location_entry_set_autocompletion_key (w); - - gtk_editable_delete_selection (GTK_EDITABLE (p->entry)); - text = ephy_location_entry_get_location (w); - ephy_location_entry_autocompletion_unselect_alternatives (w); - - if (p->autocompletion) - { - common_prefix = ephy_autocompletion_get_common_prefix (p->autocompletion); - } - suggest = FALSE; - if (common_prefix) - { - if (!p->before_completion) - { - p->before_completion = g_strdup (text); - } - - p->block_set_autocompletion_key = TRUE; - - gtk_entry_set_text (GTK_ENTRY (p->entry), common_prefix); - gtk_editable_set_position (GTK_EDITABLE (p->entry), -1); - - p->block_set_autocompletion_key = FALSE; - - ephy_location_entry_autocompletion_show_alternatives (w); - if (!strcmp (common_prefix, text)) - { - /* really suggest something the next time */ - suggest = TRUE; - } - g_free (common_prefix); - } - else - { - ephy_location_entry_autocompletion_hide_alternatives (w); - } - g_free (text); - return TRUE; - } - case GDK_Escape: - ephy_location_entry_autocompletion_hide_alternatives (w); - if (p->before_completion) - { - real_entry_set_location (w, p->before_completion); - g_free (p->before_completion); - p->before_completion = NULL; - gtk_editable_set_position (GTK_EDITABLE (p->entry), -1); - return TRUE; - } - break; default: w->priv->editing = TRUE; ephy_location_entry_autocompletion_unselect_alternatives (w); @@ -565,15 +436,6 @@ ephy_location_entry_autocompletion_sources_changed_cb (EphyAutocompletion *aw, LOG ("in ephy_location_entry_autocompletion_sources_changed_cb") - if (p->autocompletion_timeout == 0 - && p->last_completion - && !strcmp (p->last_completion, gtk_entry_get_text (GTK_ENTRY (p->entry)))) - { - p->autocompletion_timeout = g_timeout_add - (AUTOCOMPLETION_DELAY, - (GSourceFunc) ephy_location_entry_autocompletion_to, w); - } - if (p->show_alternatives_timeout == 0 && p->autocompletion_window_visible) { |