Fixes based on comments from Marco Pesenti Gritti.
Sat Oct 11 15:23:27 2003 Kristian Rietveld <kris@gtk.org> Fixes based on comments from Marco Pesenti Gritti. * gtk/gtkentry.c (gtk_entry_set_text): block the completion changed signal handler, avoids the completion popup to popup when text is set programmatically in most cases (we actually have to handle this in the _editable functions as well, but that will break popping up when the user actually typed something :), (gtk_entry_completion_key_press): when handling enter, bail out when nothing has been selected, (gtk_entry_completion_changed): don't popdown when the entry content changed. * gtk/gtkentrycompletion.c (gtk_entry_completion_init), (gtk_entry_completion_selected_changed): unselect_all on the first selected changed signal. Avoids having a default row selected, (_gtk_entry_completion_popup): don't select the first row by default. * gtk/gtkentryprivate.h (struct _GtkEntryCompletionPrivate): add a first_sel_changed field.
This commit is contained in:
committed by
Kristian Rietveld
parent
3b2003c9a2
commit
c3841e7019
22
ChangeLog
22
ChangeLog
@@ -1,3 +1,25 @@
|
||||
Sat Oct 11 15:23:27 2003 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
Fixes based on comments from Marco Pesenti Gritti.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_text): block the completion changed
|
||||
signal handler, avoids the completion popup to popup when text is
|
||||
set programmatically in most cases (we actually have to handle this
|
||||
in the _editable functions as well, but that will break popping up
|
||||
when the user actually typed something :),
|
||||
(gtk_entry_completion_key_press): when handling enter, bail out
|
||||
when nothing has been selected,
|
||||
(gtk_entry_completion_changed): don't popdown when the entry content
|
||||
changed.
|
||||
|
||||
* gtk/gtkentrycompletion.c (gtk_entry_completion_init),
|
||||
(gtk_entry_completion_selected_changed): unselect_all on the
|
||||
first selected changed signal. Avoids having a default row selected,
|
||||
(_gtk_entry_completion_popup): don't select the first row by default.
|
||||
|
||||
* gtk/gtkentryprivate.h (struct _GtkEntryCompletionPrivate): add a
|
||||
first_sel_changed field.
|
||||
|
||||
Fri Oct 10 23:02:58 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* demos/gtk-demo/menus.c: Replace GtkItemFactory by GtkUIManager
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
Sat Oct 11 15:23:27 2003 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
Fixes based on comments from Marco Pesenti Gritti.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_text): block the completion changed
|
||||
signal handler, avoids the completion popup to popup when text is
|
||||
set programmatically in most cases (we actually have to handle this
|
||||
in the _editable functions as well, but that will break popping up
|
||||
when the user actually typed something :),
|
||||
(gtk_entry_completion_key_press): when handling enter, bail out
|
||||
when nothing has been selected,
|
||||
(gtk_entry_completion_changed): don't popdown when the entry content
|
||||
changed.
|
||||
|
||||
* gtk/gtkentrycompletion.c (gtk_entry_completion_init),
|
||||
(gtk_entry_completion_selected_changed): unselect_all on the
|
||||
first selected changed signal. Avoids having a default row selected,
|
||||
(_gtk_entry_completion_popup): don't select the first row by default.
|
||||
|
||||
* gtk/gtkentryprivate.h (struct _GtkEntryCompletionPrivate): add a
|
||||
first_sel_changed field.
|
||||
|
||||
Fri Oct 10 23:02:58 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* demos/gtk-demo/menus.c: Replace GtkItemFactory by GtkUIManager
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
Sat Oct 11 15:23:27 2003 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
Fixes based on comments from Marco Pesenti Gritti.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_text): block the completion changed
|
||||
signal handler, avoids the completion popup to popup when text is
|
||||
set programmatically in most cases (we actually have to handle this
|
||||
in the _editable functions as well, but that will break popping up
|
||||
when the user actually typed something :),
|
||||
(gtk_entry_completion_key_press): when handling enter, bail out
|
||||
when nothing has been selected,
|
||||
(gtk_entry_completion_changed): don't popdown when the entry content
|
||||
changed.
|
||||
|
||||
* gtk/gtkentrycompletion.c (gtk_entry_completion_init),
|
||||
(gtk_entry_completion_selected_changed): unselect_all on the
|
||||
first selected changed signal. Avoids having a default row selected,
|
||||
(_gtk_entry_completion_popup): don't select the first row by default.
|
||||
|
||||
* gtk/gtkentryprivate.h (struct _GtkEntryCompletionPrivate): add a
|
||||
first_sel_changed field.
|
||||
|
||||
Fri Oct 10 23:02:58 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* demos/gtk-demo/menus.c: Replace GtkItemFactory by GtkUIManager
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
Sat Oct 11 15:23:27 2003 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
Fixes based on comments from Marco Pesenti Gritti.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_text): block the completion changed
|
||||
signal handler, avoids the completion popup to popup when text is
|
||||
set programmatically in most cases (we actually have to handle this
|
||||
in the _editable functions as well, but that will break popping up
|
||||
when the user actually typed something :),
|
||||
(gtk_entry_completion_key_press): when handling enter, bail out
|
||||
when nothing has been selected,
|
||||
(gtk_entry_completion_changed): don't popdown when the entry content
|
||||
changed.
|
||||
|
||||
* gtk/gtkentrycompletion.c (gtk_entry_completion_init),
|
||||
(gtk_entry_completion_selected_changed): unselect_all on the
|
||||
first selected changed signal. Avoids having a default row selected,
|
||||
(_gtk_entry_completion_popup): don't select the first row by default.
|
||||
|
||||
* gtk/gtkentryprivate.h (struct _GtkEntryCompletionPrivate): add a
|
||||
first_sel_changed field.
|
||||
|
||||
Fri Oct 10 23:02:58 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* demos/gtk-demo/menus.c: Replace GtkItemFactory by GtkUIManager
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
Sat Oct 11 15:23:27 2003 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
Fixes based on comments from Marco Pesenti Gritti.
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_text): block the completion changed
|
||||
signal handler, avoids the completion popup to popup when text is
|
||||
set programmatically in most cases (we actually have to handle this
|
||||
in the _editable functions as well, but that will break popping up
|
||||
when the user actually typed something :),
|
||||
(gtk_entry_completion_key_press): when handling enter, bail out
|
||||
when nothing has been selected,
|
||||
(gtk_entry_completion_changed): don't popdown when the entry content
|
||||
changed.
|
||||
|
||||
* gtk/gtkentrycompletion.c (gtk_entry_completion_init),
|
||||
(gtk_entry_completion_selected_changed): unselect_all on the
|
||||
first selected changed signal. Avoids having a default row selected,
|
||||
(_gtk_entry_completion_popup): don't select the first row by default.
|
||||
|
||||
* gtk/gtkentryprivate.h (struct _GtkEntryCompletionPrivate): add a
|
||||
first_sel_changed field.
|
||||
|
||||
Fri Oct 10 23:02:58 2003 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* demos/gtk-demo/menus.c: Replace GtkItemFactory by GtkUIManager
|
||||
|
||||
@@ -3447,10 +3447,14 @@ gtk_entry_set_text (GtkEntry *entry,
|
||||
const gchar *text)
|
||||
{
|
||||
gint tmp_pos;
|
||||
GtkEntryCompletion *completion;
|
||||
|
||||
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||
g_return_if_fail (text != NULL);
|
||||
|
||||
completion = gtk_entry_get_completion (entry);
|
||||
g_signal_handler_block (entry, completion->priv->changed_id);
|
||||
|
||||
/* Actually setting the text will affect the cursor and selection;
|
||||
* if the contents don't actually change, this will look odd to the user.
|
||||
*/
|
||||
@@ -3461,6 +3465,8 @@ gtk_entry_set_text (GtkEntry *entry,
|
||||
|
||||
tmp_pos = 0;
|
||||
gtk_editable_insert_text (GTK_EDITABLE (entry), text, strlen (text), &tmp_pos);
|
||||
|
||||
g_signal_handler_unblock (entry, completion->priv->changed_id);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4476,7 +4482,8 @@ gtk_entry_completion_timeout (gpointer data)
|
||||
|
||||
completion->priv->completion_timeout = 0;
|
||||
|
||||
if (strlen (gtk_entry_get_text (GTK_ENTRY (completion->priv->entry))) >= completion->priv->minimum_key_length)
|
||||
if (strlen (gtk_entry_get_text (GTK_ENTRY (completion->priv->entry)))
|
||||
>= completion->priv->minimum_key_length)
|
||||
{
|
||||
gint matches;
|
||||
gint actions;
|
||||
@@ -4573,7 +4580,8 @@ gtk_entry_completion_key_press (GtkWidget *widget,
|
||||
gboolean entry_set;
|
||||
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
|
||||
gtk_tree_selection_get_selected (sel, &model, &iter);
|
||||
if (!gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||
return FALSE;
|
||||
|
||||
g_signal_emit_by_name (completion, "match_selected",
|
||||
model, &iter, &entry_set);
|
||||
@@ -4619,9 +4627,6 @@ gtk_entry_completion_changed (GtkWidget *entry,
|
||||
{
|
||||
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (user_data);
|
||||
|
||||
if (GTK_WIDGET_MAPPED (completion->priv->popup_window))
|
||||
_gtk_entry_completion_popdown (completion);
|
||||
|
||||
/* (re)install completion timeout */
|
||||
if (completion->priv->completion_timeout)
|
||||
g_source_remove (completion->priv->completion_timeout);
|
||||
|
||||
@@ -100,6 +100,8 @@ static gboolean gtk_entry_completion_list_button_press (GtkWidget
|
||||
static gboolean gtk_entry_completion_action_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer user_data);
|
||||
static void gtk_entry_completion_selection_changed (GtkTreeSelection *selection,
|
||||
gpointer data);
|
||||
|
||||
static void gtk_entry_completion_insert_action (GtkEntryCompletion *completion,
|
||||
gint index,
|
||||
@@ -241,6 +243,10 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree_view));
|
||||
gtk_tree_selection_set_mode (sel, GTK_SELECTION_SINGLE);
|
||||
gtk_tree_selection_unselect_all (sel);
|
||||
g_signal_connect (sel, "changed",
|
||||
G_CALLBACK (gtk_entry_completion_selection_changed),
|
||||
completion);
|
||||
priv->first_sel_changed = TRUE;
|
||||
|
||||
priv->column = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree_view), priv->column);
|
||||
@@ -663,6 +669,19 @@ gtk_entry_completion_action_data_func (GtkTreeViewColumn *tree_column,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_entry_completion_selection_changed (GtkTreeSelection *selection,
|
||||
gpointer data)
|
||||
{
|
||||
GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
|
||||
|
||||
if (completion->priv->first_sel_changed)
|
||||
{
|
||||
completion->priv->first_sel_changed = FALSE;
|
||||
gtk_tree_selection_unselect_all (selection);
|
||||
}
|
||||
}
|
||||
|
||||
/* public API */
|
||||
|
||||
/**
|
||||
@@ -1017,11 +1036,12 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
|
||||
gint x, y, x_border, y_border;
|
||||
gint items;
|
||||
gint height;
|
||||
GtkTreePath *path;
|
||||
|
||||
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);
|
||||
@@ -1041,12 +1061,8 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
|
||||
if (items <= 0)
|
||||
gtk_widget_hide (completion->priv->scrolled_window);
|
||||
|
||||
/* default on the first match */
|
||||
path = gtk_tree_path_new_from_indices (0, -1);
|
||||
gtk_tree_view_set_cursor (GTK_TREE_VIEW (completion->priv->tree_view), path,
|
||||
NULL, FALSE);
|
||||
completion->priv->current_selected = 0;
|
||||
gtk_tree_path_free (path);
|
||||
/* default on no match */
|
||||
completion->priv->current_selected = -1;
|
||||
|
||||
items = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->actions), NULL);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ struct _GtkEntryCompletionPrivate
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeModelFilter *filter_model;
|
||||
GtkListStore *actions;
|
||||
gboolean first_sel_changed;
|
||||
|
||||
GtkEntryCompletionMatchFunc match_func;
|
||||
gpointer match_data;
|
||||
|
||||
Reference in New Issue
Block a user