[gimp] libgimpwidgets: add a Clear icon to the GimpBrowser's Search entry



commit 1832ba6b37667f75183fed988ea4a6fa22bba723
Author: Sven Neumann <sven gimp org>
Date:   Sun May 24 17:02:55 2009 +0200

    libgimpwidgets: add a Clear icon to the GimpBrowser's Search entry
---
 libgimpwidgets/gimpbrowser.c |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/libgimpwidgets/gimpbrowser.c b/libgimpwidgets/gimpbrowser.c
index e6f6615..9dc6b5d 100644
--- a/libgimpwidgets/gimpbrowser.c
+++ b/libgimpwidgets/gimpbrowser.c
@@ -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)
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]