summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaurabh <srp201201051@gmail.com>2014-06-27 22:11:09 +0530
committerMatthias Clasen <mclasen@redhat.com>2014-06-28 00:41:09 -0400
commit931958f9f48d0791b65073ed02047904aedaa10f (patch)
tree502a43e92c342dc5fd50c8ff2589f1358ff94672
parentaa30278e6b69bfe109d6a930c19078f8ff35d53b (diff)
downloadgtk+-931958f9f48d0791b65073ed02047904aedaa10f.tar.gz
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
-rw-r--r--gtk/gtkentrycompletion.c26
-rw-r--r--gtk/gtkentrycompletion.h2
2 files changed, 27 insertions, 1 deletions
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index e4d5736a6a..9bd55f894e 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -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:
@@ -299,6 +301,26 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass)
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
* @index: the index of the activated action
@@ -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);
}
diff --git a/gtk/gtkentrycompletion.h b/gtk/gtkentrycompletion.h
index 69f74c8629..d0f5d08e6d 100644
--- a/gtk/gtkentrycompletion.h
+++ b/gtk/gtkentrycompletion.h
@@ -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 */