[gtk+] GtkSearchEntry: improve clear icon implementation
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkSearchEntry: improve clear icon implementation
- Date: Mon, 29 Jul 2013 01:52:21 +0000 (UTC)
commit 1b135b28c0d8202b3fcc46682e3334af85e51b3b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 28 20:21:28 2013 -0400
GtkSearchEntry: improve clear icon implementation
Instead of connecting to our own signal, which is generally
considered somewhat unclean, override the class handler
for the icon-release signal.
gtk/gtksearchentry.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c
index c785a08..0487098 100644
--- a/gtk/gtksearchentry.c
+++ b/gtk/gtksearchentry.c
@@ -75,20 +75,23 @@ gtk_search_entry_finalize (GObject *object)
}
static void
+search_entry_clear_cb (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos)
+{
+ if (icon_pos == GTK_ENTRY_ICON_SECONDARY)
+ gtk_entry_set_text (entry, "");
+}
+
+static void
gtk_search_entry_class_init (GtkSearchEntryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gtk_search_entry_finalize;
-}
-static void
-search_entry_clear_cb (GtkEntry *entry,
- GtkEntryIconPosition icon_pos,
- gpointer user_data)
-{
- if (icon_pos == GTK_ENTRY_ICON_SECONDARY)
- gtk_entry_set_text (entry, "");
+ g_signal_override_class_handler ("icon-release",
+ GTK_TYPE_SEARCH_ENTRY,
+ G_CALLBACK (search_entry_clear_cb));
}
static gboolean
@@ -170,8 +173,6 @@ gtk_search_entry_init (GtkSearchEntry *entry)
{
g_signal_connect (entry, "changed",
G_CALLBACK (search_entry_changed_cb), NULL);
- g_signal_connect (entry, "icon-release",
- G_CALLBACK (search_entry_clear_cb), NULL);
g_object_set (entry,
"primary-icon-name", "edit-find-symbolic",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]