Commit 6bd2df1a authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Add a property to suppress the popup for single matches. (#154711)

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.
parent d1137a95
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
......
......@@ -1108,6 +1108,7 @@ gtk_entry_completion_get_minimum_key_length
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
......@@ -1120,6 +1121,7 @@ gtk_entry_completion_set_minimum_key_length
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
......
......@@ -4934,6 +4934,7 @@ gtk_entry_completion_timeout (gpointer data)
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);
......@@ -4946,7 +4947,8 @@ gtk_entry_completion_timeout (gpointer data)
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);
......
......@@ -59,7 +59,8 @@ enum
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))
......@@ -351,6 +352,25 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
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));
}
......@@ -383,6 +403,7 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
priv->inline_completion = FALSE;
priv->popup_completion = TRUE;
priv->popup_set_width = TRUE;
priv->popup_single_match = TRUE;
/* completions */
priv->filter_model = NULL;
......@@ -516,6 +537,10 @@ gtk_entry_completion_set_property (GObject *object,
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;
......@@ -557,6 +582,10 @@ gtk_entry_completion_get_property (GObject *object,
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;
......@@ -1688,5 +1717,55 @@ gtk_entry_completion_get_popup_set_width (GtkEntryCompletion *completion)
}
/**
* 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"
......@@ -62,6 +62,7 @@ struct _GtkEntryCompletionPrivate
guint inline_completion : 1;
guint popup_completion : 1;
guint popup_set_width : 1;
guint popup_single_match : 1;
GSource *check_completion_idle;
};
......
......@@ -177,6 +177,7 @@ gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry)
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,
......@@ -968,9 +969,25 @@ _gtk_file_chooser_entry_set_action (GtkFileChooserEntry *chooser_entry,
{
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;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment