Adding 'no-matches' signal support to gtkentrycompletion

Add a new 'no-matches' signal and add a function pointer to gtkentrycompletionclass
and remove one from the padding at the end.

https://bugzilla.gnome.org/show_bug.cgi?id=726566
This commit is contained in:
Saurabh 2014-06-27 22:11:09 +05:30 committed by Matthias Clasen
parent aa30278e6b
commit 931958f9f4
2 changed files with 27 additions and 1 deletions

View File

@ -98,6 +98,7 @@ enum
MATCH_SELECTED,
ACTION_ACTIVATED,
CURSOR_ON_MATCH,
NO_MATCHES,
LAST_SIGNAL
};
@ -211,6 +212,7 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
klass->match_selected = gtk_entry_completion_match_selected;
klass->insert_prefix = gtk_entry_completion_real_insert_prefix;
klass->cursor_on_match = gtk_entry_completion_cursor_on_match;
klass->no_matches = NULL;
/**
* GtkEntryCompletion::insert-prefix:
@ -298,6 +300,26 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
GTK_TYPE_TREE_MODEL,
GTK_TYPE_TREE_ITER);
/**
* GtkEntryCompletion::no-matches:
* @widget: the object which received the signal
*
* Gets emitted when the filter model has zero
* number of rows in completion_complete method.
* (In other words when GtkEntryCompletion is out of
* suggestions)
*
* Since: 3.14
*/
entry_completion_signals[NO_MATCHES] =
g_signal_new (I_("no-matches"),
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkEntryCompletionClass, no_matches),
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
/**
* GtkEntryCompletion::action-activated:
* @widget: the object which received the signal
@ -1256,6 +1278,7 @@ void
gtk_entry_completion_complete (GtkEntryCompletion *completion)
{
gchar *tmp;
GtkTreeIter iter;
g_return_if_fail (GTK_IS_ENTRY_COMPLETION (completion));
g_return_if_fail (GTK_IS_ENTRY (completion->priv->entry));
@ -1272,6 +1295,9 @@ gtk_entry_completion_complete (GtkEntryCompletion *completion)
gtk_tree_model_filter_refilter (completion->priv->filter_model);
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (completion->priv->filter_model), &iter))
g_signal_emit (completion, entry_completion_signals[NO_MATCHES], 0);
if (gtk_widget_get_visible (completion->priv->popup_window))
_gtk_entry_completion_resize_popup (completion);
}

View File

@ -87,12 +87,12 @@ struct _GtkEntryCompletionClass
gboolean (* cursor_on_match) (GtkEntryCompletion *completion,
GtkTreeModel *model,
GtkTreeIter *iter);
void (* no_matches) (GtkEntryCompletion *completion);
/* Padding for future expansion */
void (*_gtk_reserved0) (void);
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
};
/* core */