[gtk+] Adding 'no-matches' signal support to gtkentrycompletion
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Adding 'no-matches' signal support to gtkentrycompletion
- Date: Sat, 28 Jun 2014 04:41:47 +0000 (UTC)
commit 931958f9f48d0791b65073ed02047904aedaa10f
Author: Saurabh <srp201201051 gmail com>
Date: Fri Jun 27 22:11:09 2014 +0530
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
gtk/gtkentrycompletion.c | 26 ++++++++++++++++++++++++++
gtk/gtkentrycompletion.h | 2 +-
2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index e4d5736..9bd55f8 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 69f74c8..d0f5d08 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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]