diff options
author | Jon Trowbridge <trow@gnu.org> | 2001-03-06 17:47:08 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-03-06 17:47:08 +0800 |
commit | 10d0e730eccccf34fc53dc8c1d6145fca1f52f57 (patch) | |
tree | 231d378aa6256253d73d078251d5c8096b824a54 /widgets/text/e-entry.c | |
parent | 1bdc6e147f19384e42679512130cfc5f4d93364b (diff) | |
download | gsoc2013-evolution-10d0e730eccccf34fc53dc8c1d6145fca1f52f57.tar.gz gsoc2013-evolution-10d0e730eccccf34fc53dc8c1d6145fca1f52f57.tar.zst gsoc2013-evolution-10d0e730eccccf34fc53dc8c1d6145fca1f52f57.zip |
Added. This is part of a change of sematics that makes things much nicer
2001-03-06 Jon Trowbridge <trow@gnu.org>
* gal/e-text/e-entry.c (e_entry_text_keypress): Added. This is
part of a change of sematics that makes things much nicer for the
user --- auto-activate the completion popup only on keypresses
than also change the entry.
(e_entry_proxy_changed): Record that the underlying EText has
changed, and set up a timeout to clear the changed_since_keypress
flag in a very short amount of time.
(e_entry_init): Connect to the EText's "keypress" signal".
(e_entry_destroy): If our completion_delay_tag timeout is still
floating around out there when we are winding things down, remove
it.
* gal/e-text/e-text.c (e_text_class_init): Added keypress signal.
(e_text_text_model_reposition): Removed some old cruft.
(e_text_event): Emit our keypress signal after handling events of
type GDK_KEY_PRESS.
svn path=/trunk/; revision=8566
Diffstat (limited to 'widgets/text/e-entry.c')
-rw-r--r-- | widgets/text/e-entry.c | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/widgets/text/e-entry.c b/widgets/text/e-entry.c index 8c0682e370..64255c435e 100644 --- a/widgets/text/e-entry.c +++ b/widgets/text/e-entry.c @@ -119,6 +119,9 @@ struct _EEntryPrivate { gint completion_delay; guint completion_delay_tag; gboolean ptr_grab; + gboolean changed_since_keypress; + guint changed_since_keypress_tag; + gint last_completion_pos; guint draw_borders : 1; }; @@ -197,16 +200,43 @@ canvas_focus_in_event (GtkWidget *widget, GdkEventFocus *focus, EEntry *entry) } static void -e_entry_proxy_changed (EText *text, EEntry *entry) +e_entry_text_keypress (EText *text, guint keyval, guint state, EEntry *entry) +{ + if (entry->priv->changed_since_keypress_tag) { + gtk_timeout_remove (entry->priv->changed_since_keypress_tag); + entry->priv->changed_since_keypress_tag = 0; + } + + if (entry->priv->changed_since_keypress + || (entry->priv->popup_is_visible && e_entry_get_position (entry) != entry->priv->last_completion_pos)) { + if (e_entry_is_empty (entry)) { + e_entry_cancel_delayed_completion (entry); + e_entry_show_popup (entry, FALSE); + } else if (entry->priv->popup_is_visible) { + e_entry_start_delayed_completion (entry, 1); + } else if (entry->priv->completion) + e_entry_start_delayed_completion (entry, entry->priv->completion_delay); + } + entry->priv->changed_since_keypress = FALSE; +} + +static gint +changed_since_keypress_timeout_fn (gpointer user_data) { - if (e_entry_is_empty (entry)) { - e_entry_cancel_delayed_completion (entry); - e_entry_show_popup (entry, FALSE); - } else if (entry->priv->popup_is_visible) - e_entry_start_delayed_completion (entry, 1); - else if (entry->priv->completion) - e_entry_start_delayed_completion (entry, entry->priv->completion_delay); + EEntry *entry = E_ENTRY (user_data); + entry->priv->changed_since_keypress = FALSE; + entry->priv->changed_since_keypress_tag = 0; + return FALSE; +} +static void +e_entry_proxy_changed (EText *text, EEntry *entry) +{ + if (entry->priv->changed_since_keypress_tag) + gtk_timeout_remove (entry->priv->changed_since_keypress_tag); + entry->priv->changed_since_keypress = TRUE; + entry->priv->changed_since_keypress_tag = gtk_timeout_add (20, changed_since_keypress_timeout_fn, entry); + gtk_signal_emit (GTK_OBJECT (entry), e_entry_signals [E_ENTRY_CHANGED]); } @@ -260,6 +290,11 @@ e_entry_init (GtkObject *object) "editable", TRUE, NULL)); + gtk_signal_connect (GTK_OBJECT (entry->priv->item), + "keypress", + GTK_SIGNAL_FUNC (e_entry_text_keypress), + entry); + entry->priv->justification = GTK_JUSTIFY_LEFT; gtk_table_attach (gtk_table, GTK_WIDGET (entry->priv->canvas), 0, 1, 0, 1, @@ -458,6 +493,8 @@ e_entry_show_popup (EEntry *entry, gboolean visible) entry->priv->ptr_grab = FALSE; + entry->priv->last_completion_pos = -1; + } @@ -485,7 +522,7 @@ e_entry_start_completion (EEntry *entry) e_completion_begin_search (entry->priv->completion, e_entry_get_text (entry), - e_entry_get_position (entry), + entry->priv->last_completion_pos = e_entry_get_position (entry), 0); /* No limit. Probably a bad idea. */ } @@ -695,7 +732,6 @@ e_entry_enable_completion_full (EEntry *entry, ECompletion *completion, gint del e_completion_view_connect_keys (E_COMPLETION_VIEW (entry->priv->completion_view), GTK_WIDGET (entry->priv->canvas)); } - /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ static void @@ -1002,6 +1038,9 @@ e_entry_destroy (GtkObject *object) gtk_widget_destroy (entry->priv->completion_view_popup); g_free (entry->priv->pre_browse_text); + if (entry->priv->changed_since_keypress_tag) + gtk_timeout_remove (entry->priv->changed_since_keypress_tag); + if (entry->priv->ptr_grab) gdk_pointer_ungrab (GDK_CURRENT_TIME); |