epiphany r8653 - in trunk: lib/widgets src src/bookmarks



Author: xan
Date: Tue Dec 30 22:32:55 2008
New Revision: 8653
URL: http://svn.gnome.org/viewvc/epiphany?rev=8653&view=rev

Log:
Port EphySearchEntry to use GtkEntry.

Also fold into the widget the 'clear' icon instead of creating it
twice outside.

Modified:
   trunk/lib/widgets/ephy-search-entry.c
   trunk/lib/widgets/ephy-search-entry.h
   trunk/src/bookmarks/ephy-bookmarks-editor.c
   trunk/src/ephy-history-window.c

Modified: trunk/lib/widgets/ephy-search-entry.c
==============================================================================
--- trunk/lib/widgets/ephy-search-entry.c	(original)
+++ trunk/lib/widgets/ephy-search-entry.c	Tue Dec 30 22:32:55 2008
@@ -15,7 +15,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- *  $Id$
  */
 
 #include "config.h"
@@ -45,7 +44,7 @@
 
 static guint ephy_search_entry_signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE (EphySearchEntry, ephy_search_entry, EPHY_TYPE_ICON_ENTRY)
+G_DEFINE_TYPE (EphySearchEntry, ephy_search_entry, GTK_TYPE_ENTRY)
 
 static void
 ephy_search_entry_class_init (EphySearchEntryClass *klass)
@@ -69,9 +68,8 @@
 static gboolean
 ephy_search_entry_timeout_cb (EphySearchEntry *entry)
 {
-	g_signal_emit (G_OBJECT (entry), ephy_search_entry_signals[SEARCH], 0,
-				   gtk_entry_get_text (GTK_ENTRY (ephy_icon_entry_get_entry
-								  (EPHY_ICON_ENTRY (entry)))));
+	g_signal_emit (entry, ephy_search_entry_signals[SEARCH], 0,
+		       gtk_entry_get_text (GTK_ENTRY (entry)));
 	entry->priv->timeout = 0;
 
 	return FALSE;
@@ -83,9 +81,8 @@
 {
 	if (entry->priv->clearing == TRUE)
 	{
-		g_signal_emit (G_OBJECT (entry), ephy_search_entry_signals[SEARCH], 0,
-			       gtk_entry_get_text (GTK_ENTRY (ephy_icon_entry_get_entry
-							      (EPHY_ICON_ENTRY (entry)))));	
+		g_signal_emit (entry, ephy_search_entry_signals[SEARCH], 0,
+			       gtk_entry_get_text (GTK_ENTRY (entry)));
 		return;
 	}
 
@@ -109,16 +106,49 @@
 	}
 }
 
+static gboolean
+search_entry_clear_cb (GtkWidget *entry,
+		       GtkEntryIconPosition position,
+		       GdkEventButton *event,
+		       gpointer user_data)
+{
+	guint state = event->state & gtk_accelerator_get_default_mod_mask ();
+	
+	if (event->button == 1 /* left */ && 
+	    state == 0 &&
+	    position == GTK_ENTRY_ICON_SECONDARY)
+	{	
+		ephy_search_entry_clear (EPHY_SEARCH_ENTRY (entry));
+		
+		return TRUE;
+	}
+	
+	return FALSE;
+}
+
 static void
 ephy_search_entry_init (EphySearchEntry *entry)
 {
 	entry->priv = EPHY_SEARCH_ENTRY_GET_PRIVATE (entry);
 
-	g_signal_connect (ephy_icon_entry_get_entry (EPHY_ICON_ENTRY (entry)),
+	gtk_entry_set_icon_from_stock (GTK_ENTRY (entry),
+				       GTK_ENTRY_ICON_SECONDARY,
+				       GTK_STOCK_CLEAR);
+	gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
+					GTK_ENTRY_ICON_SECONDARY,
+					TRUE);
+	gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
+					 GTK_ENTRY_ICON_SECONDARY,
+					 _("Clear"));
+	g_signal_connect (entry,
+			  "icon-pressed",
+			  G_CALLBACK (search_entry_clear_cb),
+			  NULL);
+	g_signal_connect (entry,
 			  "destroy",
 			  G_CALLBACK (ephy_search_entry_destroy_cb),
 			  entry);
-	g_signal_connect (ephy_icon_entry_get_entry (EPHY_ICON_ENTRY (entry)),
+	g_signal_connect (entry,
 			  "changed",
 			  G_CALLBACK (ephy_search_entry_changed_cb),
 			  entry);
@@ -134,12 +164,7 @@
 GtkWidget *
 ephy_search_entry_new (void)
 {
-	GtkWidget *entry;
-
-	entry = GTK_WIDGET (g_object_new (EPHY_TYPE_SEARCH_ENTRY,
-					  NULL));
-
-	return entry;
+	return gtk_widget_new (EPHY_TYPE_SEARCH_ENTRY, NULL);
 }
 
 /**
@@ -160,8 +185,7 @@
 
 	entry->priv->clearing = TRUE;
 
-	gtk_entry_set_text (GTK_ENTRY (ephy_icon_entry_get_entry
-				       (EPHY_ICON_ENTRY (entry))), "");
+	gtk_entry_set_text (GTK_ENTRY (entry), "");
 
 	entry->priv->clearing = FALSE;
 }

Modified: trunk/lib/widgets/ephy-search-entry.h
==============================================================================
--- trunk/lib/widgets/ephy-search-entry.h	(original)
+++ trunk/lib/widgets/ephy-search-entry.h	Tue Dec 30 22:32:55 2008
@@ -25,7 +25,7 @@
 #ifndef EPHY_SEARCH_ENTRY_H
 #define EPHY_SEARCH_ENTRY_H
 
-#include "ephy-icon-entry.h"
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
@@ -42,14 +42,14 @@
 
 struct _EphySearchEntryClass
 {
-	EphyIconEntryClass parent;
+	GtkEntryClass parent;
 
 	void (*search) (EphySearchEntry *view, const char *text);
 };
 
 struct _EphySearchEntry
 {
-	EphyIconEntry parent;
+	GtkEntry parent;
 
 	/*< private >*/
 	EphySearchEntryPrivate *priv;

Modified: trunk/src/bookmarks/ephy-bookmarks-editor.c
==============================================================================
--- trunk/src/bookmarks/ephy-bookmarks-editor.c	(original)
+++ trunk/src/bookmarks/ephy-bookmarks-editor.c	Tue Dec 30 22:32:55 2008
@@ -1604,8 +1604,6 @@
 	GtkWidget *box;
 	GtkWidget *label;
 	GtkWidget *entry;
-	GtkWidget *cleaner;
-	GtkWidget *ebox;
 	char *str;
 
 	box = gtk_hbox_new (FALSE, 6);
@@ -1615,21 +1613,6 @@
 	entry = ephy_search_entry_new ();
 	editor->priv->search_entry = entry;
 	
-	cleaner = gtk_image_new_from_stock (GTK_STOCK_CLEAR,
-					    GTK_ICON_SIZE_MENU);
-	ebox = gtk_event_box_new ();
-	gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
-	
-	gtk_widget_add_events (ebox, GDK_BUTTON_PRESS_MASK |
-			       GDK_BUTTON_RELEASE_MASK);
-	g_signal_connect (ebox , "button-release-event",
-			  G_CALLBACK (search_entry_clear_cb), 
-			  entry);
-	gtk_widget_set_tooltip_text (ebox,
-			             _("Clear"));
-	gtk_container_add (GTK_CONTAINER (ebox), cleaner);
-	ephy_icon_entry_pack_widget ((EPHY_ICON_ENTRY (entry)), ebox, FALSE);
-	
 	g_signal_connect (G_OBJECT (entry), "search",
 			  G_CALLBACK (search_entry_search_cb),
 			  editor);

Modified: trunk/src/ephy-history-window.c
==============================================================================
--- trunk/src/ephy-history-window.c	(original)
+++ trunk/src/ephy-history-window.c	Tue Dec 30 22:32:55 2008
@@ -916,8 +916,7 @@
 {
 	const char *search_text;
 
-	search_text = gtk_entry_get_text (GTK_ENTRY (ephy_icon_entry_get_entry
-						     (EPHY_ICON_ENTRY (editor->priv->search_entry))));
+	search_text = gtk_entry_get_text (GTK_ENTRY (editor->priv->search_entry));
 	if (search_text == NULL) return;
 
 	ephy_node_filter_add_expression
@@ -1017,31 +1016,11 @@
 	setup_filters (editor, TRUE, TRUE);
 }
 
-static gboolean
-search_entry_clear_cb (GtkWidget *ebox,
-		       GdkEventButton *event,
-		       GtkWidget *entry)
-{
-	guint state = event->state & gtk_accelerator_get_default_mod_mask ();
-	
-	if (event->type == GDK_BUTTON_RELEASE && 
-	    event->button == 1 /* left */ && 
-	    state == 0)
-	{	
-		ephy_search_entry_clear (EPHY_SEARCH_ENTRY (entry));
-		
-		return TRUE;
-	}
-	
-	return FALSE;
-}
-
 static GtkWidget *
 build_search_box (EphyHistoryWindow *editor)
 {
 	GtkWidget *box, *label, *entry;
 	GtkWidget *combo;
-	GtkWidget *cleaner, *ebox;
 	char *str;
 	int time_range;
 
@@ -1054,21 +1033,6 @@
 	add_entry_monitor (editor, entry);
 	editor->priv->search_entry = entry;
     
-	cleaner = gtk_image_new_from_stock (GTK_STOCK_CLEAR,
-					    GTK_ICON_SIZE_MENU);
-	ebox = gtk_event_box_new ();
-	gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
-	
-	gtk_widget_add_events (ebox, GDK_BUTTON_PRESS_MASK |
-			       GDK_BUTTON_RELEASE_MASK);
-	g_signal_connect (ebox , "button-release-event",
-			  G_CALLBACK (search_entry_clear_cb), 
-			  entry);
-	gtk_widget_set_tooltip_text (ebox,
-			             _("Clear"));
-	gtk_container_add (GTK_CONTAINER (ebox), cleaner);
-	ephy_icon_entry_pack_widget ((EPHY_ICON_ENTRY (entry)), ebox, FALSE);
-    
 	gtk_widget_show_all (entry);
 
 	label = gtk_label_new (NULL);



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