mirror of https://github.com/GNOME/gimp.git
libgimpwidgets: add a Clear icon to the GimpBrowser's Search entry
This commit is contained in:
parent
2f9e2662c4
commit
1832ba6b37
|
@ -40,11 +40,15 @@ enum
|
|||
};
|
||||
|
||||
|
||||
static void gimp_browser_destroy (GtkObject *object);
|
||||
static void gimp_browser_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_browser_entry_changed (GtkEditable *editable,
|
||||
GimpBrowser *browser);
|
||||
static gboolean gimp_browser_search_timeout (gpointer data);
|
||||
static void gimp_browser_entry_changed (GtkEditable *editable,
|
||||
GimpBrowser *browser);
|
||||
static void gimp_browser_entry_icon_press (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
GdkEvent *event,
|
||||
GimpBrowser *browser);
|
||||
static gboolean gimp_browser_search_timeout (gpointer data);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpBrowser, gimp_browser, GTK_TYPE_HPANED)
|
||||
|
@ -108,6 +112,17 @@ gimp_browser_init (GimpBrowser *browser)
|
|||
G_CALLBACK (gimp_browser_entry_changed),
|
||||
browser);
|
||||
|
||||
gtk_entry_set_icon_from_stock (GTK_ENTRY (browser->search_entry),
|
||||
GTK_ENTRY_ICON_SECONDARY,
|
||||
GTK_STOCK_CLEAR);
|
||||
gtk_entry_set_icon_activatable (GTK_ENTRY (browser->search_entry),
|
||||
GTK_ENTRY_ICON_SECONDARY,
|
||||
TRUE);
|
||||
|
||||
g_signal_connect (browser->search_entry, "icon-press",
|
||||
G_CALLBACK (gimp_browser_entry_icon_press),
|
||||
browser);
|
||||
|
||||
/* count label */
|
||||
|
||||
browser->count_label = gtk_label_new (_("No matches"));
|
||||
|
@ -310,6 +325,18 @@ gimp_browser_entry_changed (GtkEditable *editable,
|
|||
g_timeout_add (100, gimp_browser_search_timeout, browser);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_browser_entry_icon_press (GtkEntry *entry,
|
||||
GtkEntryIconPosition icon_pos,
|
||||
GdkEvent *event,
|
||||
GimpBrowser *browser)
|
||||
{
|
||||
if (((GdkEventButton*) event)->button == 1)
|
||||
{
|
||||
gtk_entry_set_text (entry, "");
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_browser_search_timeout (gpointer data)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue