2005-05-26 Matthias Clasen <mclasen@redhat.com>
+ * gtk/gtk.symbols:
+ * gtk/gtkentrycompletion.c: Add a property to suppress the
+ popup for single matches. (#154711)
+
+ * gtk/gtkentry.c (gtk_entry_completion_timeout): Respect it here.
+
+ * gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
+ Use it here.
+
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Queue the
redisplay after modifying the tag in the btree, otherwise
we end up showing the old tags until the next redraw comes
2005-05-26 Matthias Clasen <mclasen@redhat.com>
+ * gtk/gtk.symbols:
+ * gtk/gtkentrycompletion.c: Add a property to suppress the
+ popup for single matches. (#154711)
+
+ * gtk/gtkentry.c (gtk_entry_completion_timeout): Respect it here.
+
+ * gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
+ Use it here.
+
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Queue the
redisplay after modifying the tag in the btree, otherwise
we end up showing the old tags until the next redraw comes
2005-05-26 Matthias Clasen <mclasen@redhat.com>
+ * gtk/gtk.symbols:
+ * gtk/gtkentrycompletion.c: Add a property to suppress the
+ popup for single matches. (#154711)
+
+ * gtk/gtkentry.c (gtk_entry_completion_timeout): Respect it here.
+
+ * gtk/gtkfilechooserentry.c (_gtk_file_chooser_entry_set_action):
+ Use it here.
+
* gtk/gtktextbtree.c (_gtk_text_btree_tag): Queue the
redisplay after modifying the tag in the btree, otherwise
we end up showing the old tags until the next redraw comes
gtk_entry_completion_get_model
gtk_entry_completion_get_popup_completion
gtk_entry_completion_get_popup_set_width
+gtk_entry_completion_get_popup_single_match
gtk_entry_completion_get_text_column
gtk_entry_completion_get_type G_GNUC_CONST
gtk_entry_completion_insert_action_markup
gtk_entry_completion_set_model
gtk_entry_completion_set_popup_completion
gtk_entry_completion_set_popup_set_width
+gtk_entry_completion_set_popup_single_match
gtk_entry_completion_set_text_column
#endif
#endif
gint matches;
gint actions;
GtkTreeSelection *s;
+ gboolean popup_single;
gtk_entry_completion_complete (completion);
matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL);
actions = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->actions), NULL);
- if (matches > 0 || actions > 0)
+ g_object_get (completion, "popup-single-match", &popup_single, NULL);
+ if ((matches > (popup_single ? 0: 1)) || actions > 0)
{
if (GTK_WIDGET_VISIBLE (completion->priv->popup_window))
_gtk_entry_completion_resize_popup (completion);
PROP_TEXT_COLUMN,
PROP_INLINE_COMPLETION,
PROP_POPUP_COMPLETION,
- PROP_POPUP_SET_WIDTH
+ PROP_POPUP_SET_WIDTH,
+ PROP_POPUP_SINGLE_MATCH
};
#define GTK_ENTRY_COMPLETION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionPrivate))
TRUE,
GTK_PARAM_READWRITE));
+ /**
+ * GtkEntryCompletion:popup-single-match:
+ *
+ * Determines whether the completions popup window will shown
+ * for a single possible completion. You probably want to set
+ * this to %FALSE if you are using
+ * <link linkend="GtkEntryCompletion--inline-completion">inline
+ * completion</link>.
+ *
+ * Since: 2.8
+ */
+ g_object_class_install_property (object_class,
+ PROP_POPUP_SINGLE_MATCH,
+ g_param_spec_boolean ("popup-single-match",
+ P_("Popup single match"),
+ P_("If TRUE, the popup window will appear for a single match."),
+ TRUE,
+ GTK_PARAM_READWRITE));
+
g_type_class_add_private (object_class, sizeof (GtkEntryCompletionPrivate));
}
priv->inline_completion = FALSE;
priv->popup_completion = TRUE;
priv->popup_set_width = TRUE;
+ priv->popup_single_match = TRUE;
/* completions */
priv->filter_model = NULL;
priv->popup_set_width = g_value_get_boolean (value);
break;
+ case PROP_POPUP_SINGLE_MATCH:
+ priv->popup_single_match = g_value_get_boolean (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
g_value_set_boolean (value, gtk_entry_completion_get_popup_set_width (completion));
break;
+ case PROP_POPUP_SINGLE_MATCH:
+ g_value_set_boolean (value, gtk_entry_completion_get_popup_single_match (completion));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
+/**
+ * gtk_entry_completion_set_popup_single_match:
+ * @completion: a #GtkEntryCompletion
+ * @popup_single_match: %TRUE if the popup should appear even for a single
+ * match
+ *
+ * Sets whether the completion popup window will appear even if there is
+ * only a single match. You may want to set this to %FALSE if you
+ * are using <link linkend="GtkEntryCompletion--inline-completion">inline
+ * completion</link>.
+ *
+ * Since: 2.8
+ */
+void
+gtk_entry_completion_set_popup_single_match (GtkEntryCompletion *completion,
+ gboolean popup_single_match)
+{
+ g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
+
+ popup_single_match = popup_single_match != FALSE;
+
+ if (completion->priv->popup_single_match != popup_single_match)
+ {
+ completion->priv->popup_single_match = popup_single_match;
+
+ g_object_notify (G_OBJECT (completion), "popup-single-match");
+ }
+}
+
+/**
+ * gtk_entry_completion_get_popup_single_match:
+ * @completion: a #GtkEntryCompletion
+ *
+ * Returns whether the completion popup window will appear even if there is
+ * only a single match.
+ *
+ * Return value: %TRUE if the popup window will appear regardless of the
+ * number of matches.
+ *
+ * Since: 2.8
+ **/
+gboolean
+gtk_entry_completion_get_popup_single_match (GtkEntryCompletion *completion)
+{
+ g_return_val_if_fail (GTK_IS_ENTRY_COMPLETION (completion), TRUE);
+
+ return completion->priv->popup_single_match;
+}
+
+
#define __GTK_ENTRY_COMPLETION_C__
#include "gtkaliasdef.c"
guint inline_completion : 1;
guint popup_completion : 1;
guint popup_set_width : 1;
+ guint popup_single_match : 1;
GSource *check_completion_idle;
};
GtkCellRenderer *cell;
comp = gtk_entry_completion_new ();
+ gtk_entry_completion_set_popup_single_match (comp, FALSE);
gtk_entry_completion_set_match_func (comp,
completion_match_func,
{
g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (chooser_entry));
- if ( chooser_entry->action != action)
+ if (chooser_entry->action != action)
{
+ GtkEntryCompletion *comp;
+
chooser_entry->action = action;
+
+ comp = gtk_entry_get_completion (GTK_ENTRY (chooser_entry));
+
+ switch (action)
+ {
+ case GTK_FILE_CHOOSER_ACTION_OPEN:
+ case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
+ gtk_entry_completion_set_popup_single_match (comp, FALSE);
+ break;
+ case GTK_FILE_CHOOSER_ACTION_SAVE:
+ case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
+ gtk_entry_completion_set_popup_single_match (comp, TRUE);
+ break;
+ }
}
}