Commit 1b135b28 authored by Matthias Clasen's avatar Matthias Clasen

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.
parent 0e350eee
......@@ -74,21 +74,24 @@ gtk_search_entry_finalize (GObject *object)
G_OBJECT_CLASS (gtk_search_entry_parent_class)->finalize (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",
......
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