rhythmbox r6239 - in trunk: . widgets



Author: jmatthew
Date: Fri Mar 20 09:12:45 2009
New Revision: 6239
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6239&view=rev

Log:
2009-03-20  Jonathan Matthew  <jonathan d14n org>

	* configure.ac:
	* widgets/rb-search-entry.c: (rb_search_entry_init),
	(rb_search_entry_clear_cb):
	If available, use gtk 2.16's new GtkEntry API for the 'clear' icon
	in the search entry, rather than libsexy's SexyIconEntry.
	Incidentally fixes #513828.


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/widgets/rb-search-entry.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Fri Mar 20 09:12:45 2009
@@ -476,11 +476,14 @@
 AC_DEFINE_UNQUOTED(METADATA_UNINSTALLED_DIR,"`pwd`/metadata",[path to metadata build dir])
 AC_SUBST(ROOT_UNINSTALLED_DIR)
 
+dnl libsexy is only required with gtk < 2.16
+PKG_CHECK_EXISTS(gtk+-2.0 >= 2.16, [need_libsexy=no], [need_libsexy=yes])
+
 AC_ARG_WITH(internal-libsexy,
             AC_HELP_STRING([--with-internal-libsexy],
 			   [Build using internal libsexy library]),,
 	      with_internal_libsexy=no)
-if test "x$with_internal_libsexy" = "xno"; then
+if test "x$need_libsexy" = "xyes" && test "x$with_internal_libsexy" = "xno"; then
 	PKG_CHECK_MODULES(LIBSEXY, libsexy >= 0.1.5,
 		          with_internal_libsexy=no,
 		          with_internal_libsexy=yes)
@@ -928,10 +931,12 @@
 else
 	AC_MSG_NOTICE([   gnome-keyring support disabled])
 fi
-if test x"$with_internal_libsexy" = xyes; then
-	AC_MSG_NOTICE([   using internal libsexy])
-else
-	AC_MSG_NOTICE([** using system-wide libsexy])
+if test x"$need_libsexy" = xyes; then
+	if test x"$with_internal_libsexy" = xyes; then
+		AC_MSG_NOTICE([   using internal libsexy])
+	else
+		AC_MSG_NOTICE([** using system-wide libsexy])
+	fi
 fi
 if test "x$enable_fm_radio" != xno; then
 	AC_MSG_NOTICE([** FM radio support enabled])

Modified: trunk/widgets/rb-search-entry.c
==============================================================================
--- trunk/widgets/rb-search-entry.c	(original)
+++ trunk/widgets/rb-search-entry.c	Fri Mar 20 09:12:45 2009
@@ -35,7 +35,10 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+
+#if !GTK_CHECK_VERSION(2,16,0)
 #include "libsexy/sexy-icon-entry.h"
+#endif
 
 #include "rb-search-entry.h"
 
@@ -50,6 +53,12 @@
 static gboolean rb_search_entry_focus_out_event_cb (GtkWidget *widget,
 				                    GdkEventFocus *event,
 				                    RBSearchEntry *entry);
+#if GTK_CHECK_VERSION(2,16,0)
+static void rb_search_entry_clear_cb (GtkEntry *entry,
+				      GtkEntryIconPosition icon_pos,
+				      GdkEvent *event,
+				      RBSearchEntry *search_entry);
+#endif
 
 struct RBSearchEntryPrivate
 {
@@ -70,8 +79,8 @@
  * @short_description: text entry widget for the search box
  *
  * The search entry contains a label and a text entry box.
- * The text entry box (a SexyIconEntry) contains an icon
- * that acts as a 'clear' button.
+ * The text entry box contains an icon that acts as a 'clear'
+ * button.
  *
  * Signals are emitted when the search text changes,
  * arbitrarily rate-limited to one every 300ms.
@@ -157,8 +166,22 @@
 	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
 	gtk_box_pack_start (GTK_BOX (entry), label, FALSE, TRUE, 0);
 
+#if GTK_CHECK_VERSION(2,16,0)
+	entry->priv->entry = gtk_entry_new ();
+	gtk_entry_set_icon_from_stock (GTK_ENTRY (entry->priv->entry),
+				       GTK_ENTRY_ICON_SECONDARY,
+				       GTK_STOCK_CLEAR);
+	gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry->priv->entry),
+					 GTK_ENTRY_ICON_SECONDARY,
+					 _("Clear the search text"));
+	g_signal_connect_object (GTK_ENTRY (entry->priv->entry),
+				 "icon-press",
+				 G_CALLBACK (rb_search_entry_clear_cb),
+				 entry, 0);
+#else
 	entry->priv->entry = sexy_icon_entry_new ();
 	sexy_icon_entry_add_clear_button (SEXY_ICON_ENTRY (entry->priv->entry));
+#endif
 
 	gtk_label_set_mnemonic_widget (GTK_LABEL (label),
 				       entry->priv->entry);
@@ -357,3 +380,14 @@
 {
 	gtk_widget_grab_focus (GTK_WIDGET (entry->priv->entry));
 }
+
+#if GTK_CHECK_VERSION(2,16,0)
+static void
+rb_search_entry_clear_cb (GtkEntry *entry,
+			  GtkEntryIconPosition icon_pos,
+			  GdkEvent *event,
+			  RBSearchEntry *search_entry)
+{
+	rb_search_entry_set_text (search_entry, "");
+}
+#endif



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