From 027d69003ef4c1e8178e62e0e25532e0ef7e03b8 Mon Sep 17 00:00:00 2001 From: Kristian Rietveld Date: Mon, 13 Oct 2003 19:07:34 +0000 Subject: [PATCH] remove the reset of first_sel_changed, as after the first popup the Mon Oct 13 21:01:43 2003 Kristian Rietveld * gtk/gtkentrycompletion.c (gtk_entry_completion_popup): remove the reset of first_sel_changed, as after the first popup the treeview will always have a row selected and will thus not focus_to_cursor. * gtk/gtkentry.c (keyval_is_cursor_move): new function to determine whether the keyval should move the completion selection cursor (used to avoid ending up with extreme cluttered code), also added all KP_ equivalents of the keys here, (gtk_entry_completion_key_press): Keynav tweaks based on comments from Dave Bordoley and Marco Pesenti Gritti; add the -1 state as possible current selection, implement Home/End keys, modified the down key to stop cycling. Maybe page up/down should be implemented at some later time. --- ChangeLog | 16 ++++++++++++++++ ChangeLog.pre-2-10 | 16 ++++++++++++++++ ChangeLog.pre-2-4 | 16 ++++++++++++++++ ChangeLog.pre-2-6 | 16 ++++++++++++++++ ChangeLog.pre-2-8 | 16 ++++++++++++++++ gtk/gtkentry.c | 41 +++++++++++++++++++++++++++++++++------- gtk/gtkentrycompletion.c | 2 -- 7 files changed, 114 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index dd5c551702..968952d8ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Mon Oct 13 21:01:43 2003 Kristian Rietveld + + * gtk/gtkentrycompletion.c (gtk_entry_completion_popup): remove + the reset of first_sel_changed, as after the first popup the treeview + will always have a row selected and will thus not focus_to_cursor. + + * gtk/gtkentry.c (keyval_is_cursor_move): new function to determine + whether the keyval should move the completion selection cursor (used + to avoid ending up with extreme cluttered code), also added + all KP_ equivalents of the keys here, + (gtk_entry_completion_key_press): Keynav tweaks based on comments + from Dave Bordoley and Marco Pesenti Gritti; add the -1 state + as possible current selection, implement Home/End keys, modified + the down key to stop cycling. Maybe page up/down should be implemented + at some later time. + Mon Oct 13 20:58:07 2003 Matthias Clasen * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon): Make it work diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index dd5c551702..968952d8ab 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,19 @@ +Mon Oct 13 21:01:43 2003 Kristian Rietveld + + * gtk/gtkentrycompletion.c (gtk_entry_completion_popup): remove + the reset of first_sel_changed, as after the first popup the treeview + will always have a row selected and will thus not focus_to_cursor. + + * gtk/gtkentry.c (keyval_is_cursor_move): new function to determine + whether the keyval should move the completion selection cursor (used + to avoid ending up with extreme cluttered code), also added + all KP_ equivalents of the keys here, + (gtk_entry_completion_key_press): Keynav tweaks based on comments + from Dave Bordoley and Marco Pesenti Gritti; add the -1 state + as possible current selection, implement Home/End keys, modified + the down key to stop cycling. Maybe page up/down should be implemented + at some later time. + Mon Oct 13 20:58:07 2003 Matthias Clasen * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon): Make it work diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index dd5c551702..968952d8ab 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,19 @@ +Mon Oct 13 21:01:43 2003 Kristian Rietveld + + * gtk/gtkentrycompletion.c (gtk_entry_completion_popup): remove + the reset of first_sel_changed, as after the first popup the treeview + will always have a row selected and will thus not focus_to_cursor. + + * gtk/gtkentry.c (keyval_is_cursor_move): new function to determine + whether the keyval should move the completion selection cursor (used + to avoid ending up with extreme cluttered code), also added + all KP_ equivalents of the keys here, + (gtk_entry_completion_key_press): Keynav tweaks based on comments + from Dave Bordoley and Marco Pesenti Gritti; add the -1 state + as possible current selection, implement Home/End keys, modified + the down key to stop cycling. Maybe page up/down should be implemented + at some later time. + Mon Oct 13 20:58:07 2003 Matthias Clasen * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon): Make it work diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index dd5c551702..968952d8ab 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,19 @@ +Mon Oct 13 21:01:43 2003 Kristian Rietveld + + * gtk/gtkentrycompletion.c (gtk_entry_completion_popup): remove + the reset of first_sel_changed, as after the first popup the treeview + will always have a row selected and will thus not focus_to_cursor. + + * gtk/gtkentry.c (keyval_is_cursor_move): new function to determine + whether the keyval should move the completion selection cursor (used + to avoid ending up with extreme cluttered code), also added + all KP_ equivalents of the keys here, + (gtk_entry_completion_key_press): Keynav tweaks based on comments + from Dave Bordoley and Marco Pesenti Gritti; add the -1 state + as possible current selection, implement Home/End keys, modified + the down key to stop cycling. Maybe page up/down should be implemented + at some later time. + Mon Oct 13 20:58:07 2003 Matthias Clasen * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon): Make it work diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index dd5c551702..968952d8ab 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,19 @@ +Mon Oct 13 21:01:43 2003 Kristian Rietveld + + * gtk/gtkentrycompletion.c (gtk_entry_completion_popup): remove + the reset of first_sel_changed, as after the first popup the treeview + will always have a row selected and will thus not focus_to_cursor. + + * gtk/gtkentry.c (keyval_is_cursor_move): new function to determine + whether the keyval should move the completion selection cursor (used + to avoid ending up with extreme cluttered code), also added + all KP_ equivalents of the keys here, + (gtk_entry_completion_key_press): Keynav tweaks based on comments + from Dave Bordoley and Marco Pesenti Gritti; add the -1 state + as possible current selection, implement Home/End keys, modified + the down key to stop cycling. Maybe page up/down should be implemented + at some later time. + Mon Oct 13 20:58:07 2003 Matthias Clasen * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon): Make it work diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 7385b991d2..7576d72872 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -4511,6 +4511,24 @@ gtk_entry_completion_timeout (gpointer data) return FALSE; } +static inline gboolean +keyval_is_cursor_move (guint keyval) +{ + if (keyval == GDK_Up || keyval == GDK_KP_Up) + return TRUE; + + if (keyval == GDK_Down || keyval == GDK_KP_Down) + return TRUE; + + if (keyval == GDK_Home || keyval == GDK_KP_Home) + return TRUE; + + if (keyval == GDK_End || keyval == GDK_KP_End) + return TRUE; + + return FALSE; +} + static gboolean gtk_entry_completion_key_press (GtkWidget *widget, GdkEventKey *event, @@ -4527,24 +4545,33 @@ gtk_entry_completion_key_press (GtkWidget *widget, if (completion->priv->actions) actions = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->actions), NULL); - if (event->keyval == GDK_Up || event->keyval == GDK_Down) + if (keyval_is_cursor_move (event->keyval)) { GtkTreePath *path = NULL; - if (event->keyval == GDK_Up) + if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up) { completion->priv->current_selected--; - if (completion->priv->current_selected < 0) - completion->priv->current_selected = 0; + if (completion->priv->current_selected < -1) + completion->priv->current_selected = -1; } - else + else if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down) { completion->priv->current_selected++; if (completion->priv->current_selected >= matches + actions) - completion->priv->current_selected = 0; + completion->priv->current_selected = matches + actions; } + else if (event->keyval == GDK_Home || event->keyval == GDK_KP_Home) + completion->priv->current_selected = -1; + else if (event->keyval == GDK_End || event->keyval == GDK_KP_End) + completion->priv->current_selected = matches + actions - 1; - if (completion->priv->current_selected < matches) + if (completion->priv->current_selected < 0) + { + gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view))); + gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->action_view))); + } + else if (completion->priv->current_selected < matches) { gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->action_view))); diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index 73f642189f..74eacfdae6 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -1040,8 +1040,6 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion) if (GTK_WIDGET_MAPPED (completion->priv->popup_window)) return; - completion->priv->first_sel_changed = TRUE; - gtk_widget_show_all (completion->priv->vbox); gdk_window_get_origin (completion->priv->entry->window, &x, &y);