[Rhythmbox-devel] Clear button patch --with-clear-button



Apply this patch, ./configure --with-clear-button and compile.
I think that this patch should satisfy both people who are for and against clear button for search field.


If you don't want clear button just use configure without this option.
Clear button is disabled by default.

Best regards
Index: configure.ac
===================================================================
RCS file: /cvs/gnome/rhythmbox/configure.ac,v
retrieving revision 1.165
diff -u -r1.165 configure.ac
--- configure.ac	7 Sep 2005 04:29:09 -0000	1.165
+++ configure.ac	9 Sep 2005 10:28:21 -0000
@@ -129,6 +129,15 @@
 fi      
 AM_CONDITIONAL(WITH_OLD_ART, test "x$with_old" == "xyes")
 
+AC_ARG_WITH(clear-button,
+	    AC_HELP_STRING([--with-clear-button],
+			   [Enable clear button next to search field]),,
+	    with_clear_button=no)
+if test x$with_clear_button == xyes; then
+  AC_DEFINE(WITH_CLEAR_BUTTON, 1, [Define if you want to have a clear button next to search field visible])
+fi
+AM_CONDITIONAL(WITH_CLEAR_BUTTON, test "x$with_clear_button" == "xyes")
+
 dnl Database debugging
 AC_ARG_WITH(rhythmdb-debug,
               AC_HELP_STRING([--with-rhythmdb-debug=0|1|2],
@@ -582,6 +591,10 @@
 	AC_MSG_NOTICE([   D-BUS control/activation disabled])
 fi
 
+if test x$with_clear_button == xyes; then
+	AC_MSG_NOTICE([** Clear button is enabled])
+fi
+
 dnl if test "x$enable_audiocd" != "xyes"; then
 dnl 	AC_MSG_NOTICE([   Audio CD support is disabled])
 dnl else
Index: widgets/rb-search-entry.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/widgets/rb-search-entry.c,v
retrieving revision 1.4
diff -u -r1.4 rb-search-entry.c
--- widgets/rb-search-entry.c	15 Aug 2005 13:37:53 -0000	1.4
+++ widgets/rb-search-entry.c	9 Sep 2005 10:28:34 -0000
@@ -29,6 +29,11 @@
 
 #include "rb-search-entry.h"
 
+#ifdef WITH_CLEAR_BUTTON
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkstock.h>
+#endif
+
 static void rb_search_entry_class_init (RBSearchEntryClass *klass);
 static void rb_search_entry_init (RBSearchEntry *entry);
 static void rb_search_entry_finalize (GObject *object);
@@ -41,6 +46,10 @@
 				                    GdkEventFocus *event,
 				                    RBSearchEntry *entry);
 
+#ifdef WITH_CLEAR_BUTTON
+static void rb_search_entry_clean(GtkWidget *clear_button, RBSearchEntry *entry);
+#endif
+
 struct RBSearchEntryPrivate
 {
 	GtkWidget *entry;
@@ -150,6 +159,19 @@
 				 "activate",
 				 G_CALLBACK (rb_search_entry_activate_cb),
 				 entry, 0);
+	#ifdef WITH_CLEAR_BUTTON
+	GtkWidget *clear_button,*image;
+	image = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
+					 GTK_ICON_SIZE_SMALL_TOOLBAR);
+	clear_button = gtk_button_new();
+	gtk_container_add (GTK_CONTAINER(clear_button), image);
+	gtk_box_pack_end (GTK_BOX (entry), clear_button, FALSE, TRUE, 0);
+	
+	g_signal_connect_object (G_OBJECT (clear_button),
+			"clicked",
+				G_CALLBACK (rb_search_entry_clean),
+				entry, 0);
+	#endif
 }
 
 static void
@@ -263,3 +285,10 @@
 {
 	g_signal_emit (G_OBJECT (entry), rb_search_entry_signals[ACTIVATE], 0);
 }
+
+#ifdef WITH_CLEAR_BUTTON
+static void rb_search_entry_clean(GtkWidget *clear_button, RBSearchEntry *entry)
+{
+gtk_entry_set_text (GTK_ENTRY (entry->priv->entry), "");
+}
+#endif


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