+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
+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
+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
+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
+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
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.
*/
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
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;
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);
{
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);
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,
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);
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 */
/**
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);
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);
GtkTreeViewColumn *column;
GtkTreeModelFilter *filter_model;
GtkListStore *actions;
+ gboolean first_sel_changed;
GtkEntryCompletionMatchFunc match_func;
gpointer match_data;