[epiphany] entry: make EphyLocationEntry a GtkEntry



commit 90e79ffec92b47fbc6ad8b575b9691b1f7621f3b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jan 18 12:59:57 2012 -0500

    entry: make EphyLocationEntry a GtkEntry
    
    Instead of a GtkToolItem. A future commit will move the code in
    EphyLocationAction not to be a GtkAction, which is why this was a
    GtkToolItem in the first place.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668206

 lib/widgets/ephy-location-entry.c |  107 +++++++++++++-----------------------
 lib/widgets/ephy-location-entry.h |    6 +--
 src/ephy-location-action.c        |   54 ++++++-------------
 src/ephy-toolbar.c                |   12 ++++-
 src/ephy-toolbar.h                |    2 +
 src/ephy-window.c                 |   74 +++-----------------------
 tests/ephy-location-entry.c       |    4 +-
 7 files changed, 79 insertions(+), 180 deletions(-)
---
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 6300205..0e26f32 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -50,7 +50,6 @@
 
 struct _EphyLocationEntryPrivate
 {
-	GtkWidget *entry;
 	GIcon *lock_gicon;
 	GdkPixbuf *favicon;
 
@@ -112,7 +111,7 @@ enum signalsEnum
 };
 static gint signals[LAST_SIGNAL] = { 0 };
 
-G_DEFINE_TYPE (EphyLocationEntry, ephy_location_entry, GTK_TYPE_TOOL_ITEM)
+G_DEFINE_TYPE (EphyLocationEntry, ephy_location_entry, GTK_TYPE_ENTRY)
 
 inline static void
 free_search_terms (GSList *search_terms)
@@ -243,7 +242,7 @@ update_address_state (EphyLocationEntry *entry)
 	EphyLocationEntryPrivate *priv = entry->priv;
 	const char *text;
 
-	text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+	text = gtk_entry_get_text (GTK_ENTRY (entry));
 	priv->original_address = text != NULL &&
 				 g_str_hash (text) == priv->hash;
 }
@@ -252,7 +251,7 @@ static void
 update_favicon (EphyLocationEntry *lentry)
 {
 	EphyLocationEntryPrivate *priv = lentry->priv;
-	GtkEntry *entry = GTK_ENTRY (priv->entry);
+	GtkEntry *entry = GTK_ENTRY (lentry);
 
 	/* Only show the favicon if the entry's text is the
 	 * address of the current page.
@@ -486,8 +485,8 @@ match_selected_cb (GtkEntryCompletion *completion,
 			     state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
 
 	ephy_location_entry_set_location (entry, item);
-	//gtk_im_context_reset (GTK_ENTRY (entry->priv->entry)->im_context);
-	g_signal_emit_by_name (priv->entry, "activate");
+	//gtk_im_context_reset (GTK_ENTRY (entry)->im_context);
+	g_signal_emit_by_name (entry, "activate");
 
 	g_free (item);
 
@@ -537,7 +536,7 @@ entry_clear_activate_cb (GtkMenuItem *item,
 	EphyLocationEntryPrivate *priv = entry->priv;
 
 	priv->block_update = TRUE;
-	gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
+	gtk_entry_set_text (GTK_ENTRY (entry), "");
 	priv->block_update = FALSE;
 	priv->user_changed = TRUE;
 }
@@ -580,7 +579,7 @@ entry_populate_popup_cb (GtkEntry *entry,
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (clear_menuitem), image);
 	g_signal_connect (clear_menuitem , "activate",
 			  G_CALLBACK (entry_clear_activate_cb), lentry);
-	is_editable = gtk_editable_get_editable (GTK_EDITABLE (priv->entry));
+	is_editable = gtk_editable_get_editable (GTK_EDITABLE (entry));
 	gtk_widget_set_sensitive (clear_menuitem, is_editable);
 	gtk_widget_show (clear_menuitem);
 
@@ -687,7 +686,7 @@ favicon_create_drag_surface (EphyLocationEntry *entry,
 	context = gtk_widget_get_pango_context (widget);
 	layout = pango_layout_new (context);
 
-	style = gtk_widget_get_style_context (priv->entry);
+	style = gtk_widget_get_style_context (GTK_WIDGET (entry));
 	metrics = pango_context_get_metrics (context,
 		                             gtk_style_context_get_font (style, GTK_STATE_FLAG_NORMAL),
 					     pango_context_get_language (context));
@@ -840,35 +839,32 @@ icon_button_press_event_cb (GtkWidget *entry,
 static void
 ephy_location_entry_construct_contents (EphyLocationEntry *lentry)
 {
-	EphyLocationEntryPrivate *priv = lentry->priv;
+	GtkWidget *entry = GTK_WIDGET (lentry);
 	GtkTargetList *targetlist;
 
 	LOG ("EphyLocationEntry constructing contents %p", lentry);
 
-	priv->entry = gtk_entry_new ();
-	gtk_container_add (GTK_CONTAINER (lentry), priv->entry);
-
 	/* Favicon */
 	targetlist = gtk_target_list_new (url_drag_types,
 					  G_N_ELEMENTS (url_drag_types));
-	gtk_entry_set_icon_drag_source (GTK_ENTRY (priv->entry),
+	gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
 					GTK_ENTRY_ICON_PRIMARY,
 					targetlist,
 					GDK_ACTION_ASK | GDK_ACTION_COPY | GDK_ACTION_LINK);
 	gtk_target_list_unref (targetlist);
 
-	gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->entry),
+	gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
 					 GTK_ENTRY_ICON_PRIMARY,
 					 _("Drag and drop this icon to create a link to this page"));
 
-	gtk_entry_set_icon_activatable (GTK_ENTRY (priv->entry),
+	gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
 					GTK_ENTRY_ICON_PRIMARY,
 					TRUE);
-	gtk_entry_set_icon_activatable (GTK_ENTRY (priv->entry),
+	gtk_entry_set_icon_activatable (GTK_ENTRY (entry),
 					GTK_ENTRY_ICON_SECONDARY,
 					TRUE);
 
-	g_object_connect (priv->entry,
+	g_object_connect (entry,
 			  "signal::icon-press", G_CALLBACK (icon_button_press_event_cb), lentry,
 			  "signal::populate-popup", G_CALLBACK (entry_populate_popup_cb), lentry,
 			  "signal::key-press-event", G_CALLBACK (entry_key_press_cb), lentry,
@@ -878,14 +874,12 @@ ephy_location_entry_construct_contents (EphyLocationEntry *lentry)
 			  "signal::drag-data-get", G_CALLBACK (favicon_drag_data_get_cb), lentry,
 			  NULL);
 			  
-	g_signal_connect_after (priv->entry, "key-press-event",
+	g_signal_connect_after (entry, "key-press-event",
 				G_CALLBACK (entry_key_press_after_cb), lentry);
-	g_signal_connect_after (priv->entry, "activate",
+	g_signal_connect_after (entry, "activate",
 				G_CALLBACK (entry_activate_after_cb), lentry);
-	g_signal_connect_after (priv->entry, "drag-begin",
+	g_signal_connect_after (entry, "drag-begin",
 				G_CALLBACK (favicon_drag_begin_cb), lentry);
-
-	gtk_widget_show (priv->entry);
 }
 
 static void
@@ -906,8 +900,6 @@ ephy_location_entry_init (EphyLocationEntry *le)
 	p->dns_prefetch_handler = 0;
 
 	ephy_location_entry_construct_contents (le);
-
-	gtk_tool_item_set_expand (GTK_TOOL_ITEM (le), TRUE);
 }
 
 GtkWidget *
@@ -995,6 +987,7 @@ textcell_data_func (GtkCellLayout *cell_layout,
 			GtkTreeIter *iter,
 			gpointer data)
 {
+	GtkWidget *entry;
 	EphyLocationEntryPrivate *priv;
 	PangoAttrList *list;
 	PangoAttribute *att;
@@ -1011,6 +1004,7 @@ textcell_data_func (GtkCellLayout *cell_layout,
 
 	GValue text = { 0, };
 
+	entry = GTK_WIDGET (data);
 	priv = EPHY_LOCATION_ENTRY (data)->priv;
 	gtk_tree_model_get (tree_model, iter,
 			priv->text_col, &title,
@@ -1029,7 +1023,7 @@ textcell_data_func (GtkCellLayout *cell_layout,
 
 		ctext = g_strdup_printf ("%s\n%s", title, url);
 
-		style = gtk_widget_get_style_context (priv->entry);
+		style = gtk_widget_get_style_context (entry);
 		gtk_style_context_get_color (style, GTK_STATE_FLAG_INSENSITIVE,
 					     &color);
 
@@ -1131,10 +1125,9 @@ ephy_location_entry_set_match_func (EphyLocationEntry *entry,
 				gpointer user_data,
 				GDestroyNotify notify)
 {
-	EphyLocationEntryPrivate *priv = entry->priv;
 	GtkEntryCompletion *completion;
 	
-	completion = gtk_entry_get_completion (GTK_ENTRY (priv->entry));
+	completion = gtk_entry_get_completion (GTK_ENTRY (entry));
 	gtk_entry_completion_set_match_func (completion, match_func, user_data, notify);
 }
 
@@ -1167,7 +1160,6 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
 				    guint extra_col,
 				    guint favicon_col)
 {
-	EphyLocationEntryPrivate *priv = entry->priv;
 	GtkTreeModel *sort_model;
 	GtkEntryCompletion *completion;
 	GtkCellRenderer *cell;
@@ -1238,7 +1230,7 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
 	g_signal_connect (completion, "cursor-on-match",
 			  G_CALLBACK (cursor_on_match_cb), entry);
 
-	gtk_entry_set_completion (GTK_ENTRY (priv->entry), completion);
+	gtk_entry_set_completion (GTK_ENTRY (entry), completion);
 	g_object_unref (completion);
 }
 
@@ -1253,6 +1245,7 @@ void
 ephy_location_entry_set_location (EphyLocationEntry *entry,
 				  const char *address)
 {
+	GtkWidget *widget = GTK_WIDGET (entry);
 	EphyLocationEntryPrivate *priv = entry->priv;
 	GtkClipboard *clipboard;
 	const char *text;
@@ -1264,17 +1257,17 @@ ephy_location_entry_set_location (EphyLocationEntry *entry,
 	 * bug #155824. So we save the selection iff the clipboard was owned by
 	 * the location entry.
 	 */
-	if (gtk_widget_get_realized (GTK_WIDGET (priv->entry)))
+	if (gtk_widget_get_realized (widget))
 	{
-		clipboard = gtk_widget_get_clipboard (priv->entry,
+		clipboard = gtk_widget_get_clipboard (widget,
 						      GDK_SELECTION_PRIMARY);
 		g_return_if_fail (clipboard != NULL);
 
-		if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (priv->entry) &&
-		    gtk_editable_get_selection_bounds (GTK_EDITABLE (priv->entry),
+		if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (widget) &&
+		    gtk_editable_get_selection_bounds (GTK_EDITABLE (widget),
 	     					       &start, &end))
 		{
-			selection = gtk_editable_get_chars (GTK_EDITABLE (priv->entry),
+			selection = gtk_editable_get_chars (GTK_EDITABLE (widget),
 							    start, end);
 		}
 	}
@@ -1295,7 +1288,7 @@ ephy_location_entry_set_location (EphyLocationEntry *entry,
 	priv->hash = g_str_hash (effective_text ? effective_text : text);
 
 	priv->block_update = TRUE;
-	gtk_entry_set_text (GTK_ENTRY (priv->entry), effective_text ? effective_text : text);
+	gtk_entry_set_text (GTK_ENTRY (widget), effective_text ? effective_text : text);
 	priv->block_update = FALSE;
 	g_free (effective_text);
 
@@ -1364,9 +1357,7 @@ ephy_location_entry_get_can_redo (EphyLocationEntry *entry)
 const char *
 ephy_location_entry_get_location (EphyLocationEntry *entry)
 {
-	EphyLocationEntryPrivate *priv = entry->priv;
-
-	return gtk_entry_get_text (GTK_ENTRY (priv->entry));
+	return gtk_entry_get_text (GTK_ENTRY (entry));
 }
 
 static gboolean
@@ -1380,7 +1371,7 @@ ephy_location_entry_reset_internal (EphyLocationEntry *entry,
 
 	g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
 	text = url != NULL ? url : "";
-	old_text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+	old_text = gtk_entry_get_text (GTK_ENTRY (entry));
 	old_text = old_text != NULL ? old_text : "";
 
 	g_free (priv->saved_text);
@@ -1414,7 +1405,7 @@ ephy_location_entry_undo_reset (EphyLocationEntry *entry)
 {
 	EphyLocationEntryPrivate *priv = entry->priv;
 	
-	gtk_entry_set_text (GTK_ENTRY (priv->entry), priv->saved_text);
+	gtk_entry_set_text (GTK_ENTRY (entry), priv->saved_text);
 	priv->can_redo = FALSE;
 	priv->user_changed = TRUE;
 }
@@ -1447,32 +1438,14 @@ ephy_location_entry_reset (EphyLocationEntry *entry)
 void
 ephy_location_entry_activate (EphyLocationEntry *entry)
 {
-	EphyLocationEntryPrivate *priv = entry->priv;
-	GtkWidget *toplevel;
+	GtkWidget *toplevel, *widget = GTK_WIDGET (entry);
 
-	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry));
+	toplevel = gtk_widget_get_toplevel (widget);
 
-	gtk_editable_select_region (GTK_EDITABLE (priv->entry),
+	gtk_editable_select_region (GTK_EDITABLE (entry),
 				    0, -1);
 	gtk_window_set_focus (GTK_WINDOW (toplevel),
-			      priv->entry);
-}
-
-/**
- * ephy_location_entry_get_entry:
- * @entry: an #EphyLocationEntry widget
- *
- * Retrieve the internal #GtkEntry of the #EphyIconEntry inside @entry.
- *
- * Return value: a pointer to the internal #GtkEntry of @entry
- *
- **/
-GtkWidget *
-ephy_location_entry_get_entry (EphyLocationEntry *entry)
-{
-	EphyLocationEntryPrivate *priv = entry->priv;
-
-	return priv->entry;
+			      widget);
 }
 
 /**
@@ -1523,7 +1496,7 @@ ephy_location_entry_set_show_lock (EphyLocationEntry *entry,
 
 	priv->show_lock = show_lock != FALSE;
 
-	gtk_entry_set_icon_from_gicon (GTK_ENTRY (priv->entry),
+	gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry),
 				       GTK_ENTRY_ICON_SECONDARY,
 				       show_lock ? priv->lock_gicon : NULL);
 }
@@ -1563,7 +1536,7 @@ ephy_location_entry_set_lock_stock (EphyLocationEntry *entry,
 		priv->lock_gicon = g_themed_icon_new_with_default_fallbacks ("channel-secure-symbolic");
 
 	if (priv->show_lock)
-		gtk_entry_set_icon_from_gicon (GTK_ENTRY (priv->entry),
+		gtk_entry_set_icon_from_gicon (GTK_ENTRY (entry),
 					       GTK_ENTRY_ICON_SECONDARY,
 					       priv->lock_gicon);
 }
@@ -1580,9 +1553,7 @@ void
 ephy_location_entry_set_lock_tooltip (EphyLocationEntry *entry,
 				      const char *tooltip)
 {
-	EphyLocationEntryPrivate *priv = entry->priv;
-
-	gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->entry),
+	gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
 					 GTK_ENTRY_ICON_SECONDARY,
 					 tooltip);
 }
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index b1abd62..6d40f3d 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -43,7 +43,7 @@ typedef struct _EphyLocationEntryPrivate	EphyLocationEntryPrivate;
 
 struct _EphyLocationEntryClass
 {
-	GtkToolItemClass parent_class;
+	GtkEntryClass parent_class;
 
 	/* Signals */
 	void   (* user_changed)	(EphyLocationEntry *entry);
@@ -55,7 +55,7 @@ struct _EphyLocationEntryClass
 
 struct _EphyLocationEntry
 {
-	GtkToolItem parent_object;
+	GtkEntry parent_object;
 
 	/*< private >*/
 	EphyLocationEntryPrivate *priv;
@@ -97,8 +97,6 @@ void		ephy_location_entry_undo_reset		(EphyLocationEntry *entry);
 
 void		ephy_location_entry_activate		(EphyLocationEntry *entry);
 
-GtkWidget      *ephy_location_entry_get_entry		(EphyLocationEntry *entry);
-
 void		ephy_location_entry_set_favicon		(EphyLocationEntry *entry,
 							 GdkPixbuf *pixbuf);
 
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index 0a867a4..8223f38 100644
--- a/src/ephy-location-action.c
+++ b/src/ephy-location-action.c
@@ -177,21 +177,19 @@ action_activated_cb (GtkEntryCompletion *completion,
 
 static void
 entry_activate_cb (GtkEntry *entry,
-		   EphyLocationAction *proxy)
+		   GtkAction *action)
 {
 	EphyBookmarks *bookmarks;
 	const char *content;
 	char *address;
-	GtkAction *action;
 	EphyLocationActionPrivate *priv;
-	
-	action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
+
 	priv = EPHY_LOCATION_ACTION (action)->priv;
 
 	if (priv->sync_address_is_blocked)
 	{
 		priv->sync_address_is_blocked = FALSE;
-		g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy);
+		g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), entry);
 	}	
 
 	content = gtk_entry_get_text (entry);
@@ -252,10 +250,8 @@ sync_editable (GtkAction *gaction,
 {
 	EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
 	EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
-	GtkWidget *entry;
 
-	entry = ephy_location_entry_get_entry (lentry);
-	gtk_editable_set_editable (GTK_EDITABLE (entry), action->priv->editable);
+	gtk_editable_set_editable (GTK_EDITABLE (lentry), action->priv->editable);
 }
 
 static void
@@ -337,12 +333,10 @@ remove_completion_actions (GtkAction *gaction,
 {
 	EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
 	EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
-	GtkWidget *entry;
 	GtkEntryCompletion *completion;
 	GList *l;
 
-	entry = ephy_location_entry_get_entry (lentry);
-	completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+	completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
 
 	for (l = action->priv->actions; l != NULL; l = l->next)
 	{
@@ -359,12 +353,10 @@ add_completion_actions (GtkAction *gaction,
 {
 	EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
 	EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
-	GtkWidget *entry;
 	GtkEntryCompletion *completion;
 	GList *l;
 
-	entry = ephy_location_entry_get_entry (lentry);
-	completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+	completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
 
 	for (l = action->priv->actions; l != NULL; l = l->next)
 	{
@@ -385,18 +377,15 @@ add_completion_actions (GtkAction *gaction,
 static gboolean
 focus_in_event_cb (GtkWidget *entry,
 		   GdkEventFocus *event,
-		   GtkWidget *proxy)
+		   GtkAction *action)
 {
-	GtkAction *action;
 	EphyLocationActionPrivate *priv;
 
-	action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
-
 	priv = EPHY_LOCATION_ACTION (action)->priv;
 	if (!priv->sync_address_is_blocked)
 	{		
 		priv->sync_address_is_blocked = TRUE;
-		g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), proxy);
+		g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), entry);
 	}
 	
 	return FALSE;
@@ -405,18 +394,16 @@ focus_in_event_cb (GtkWidget *entry,
 static gboolean
 focus_out_event_cb (GtkWidget *entry,
 		    GdkEventFocus *event,
-		    GtkWidget *proxy)
+		    GtkAction *action)
 {
-	GtkAction *action;
 	EphyLocationActionPrivate *priv;
 
-	action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
 	priv = EPHY_LOCATION_ACTION (action)->priv;
 
 	if (priv->sync_address_is_blocked)
 	{
 		priv->sync_address_is_blocked = FALSE;
-		g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy);
+		g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), entry);
 	}
 	
 	return FALSE;
@@ -444,9 +431,7 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
 {
 	if (EPHY_IS_LOCATION_ENTRY (proxy))
 	{
-		EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
 		EphyCompletionModel *model;
-		GtkWidget *entry;
 		GtkWidget *notebook;
 		EphyLocationActionPrivate *priv;
 
@@ -496,10 +481,9 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
 		g_signal_connect_object (action, "notify::show-lock",
 					 G_CALLBACK (sync_show_lock), proxy, 0);
 
-		entry = ephy_location_entry_get_entry (lentry);
-		g_signal_connect_object (entry, "activate",
+		g_signal_connect_object (proxy, "activate",
 					 G_CALLBACK (entry_activate_cb),
-					 proxy, 0);
+					 action, 0);
 		g_signal_connect_object (proxy, "user-changed",
 					 G_CALLBACK (user_changed_cb), action, 0);
 		g_signal_connect_object (proxy, "lock-clicked",
@@ -508,10 +492,10 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
 					 G_CALLBACK (get_location_cb), action, 0);
 		g_signal_connect_object (proxy, "get-title",
 					 G_CALLBACK (get_title_cb), action, 0);
-		g_signal_connect_object (entry, "focus-in-event",
-					 G_CALLBACK (focus_in_event_cb), proxy, 0);
-		g_signal_connect_object (entry, "focus-out-event",
-					 G_CALLBACK (focus_out_event_cb), proxy, 0);
+		g_signal_connect_object (proxy, "focus-in-event",
+					 G_CALLBACK (focus_in_event_cb), action, 0);
+		g_signal_connect_object (proxy, "focus-out-event",
+					 G_CALLBACK (focus_out_event_cb), action, 0);
 	}
 
 	GTK_ACTION_CLASS (ephy_location_action_parent_class)->connect_proxy (action, proxy);
@@ -524,22 +508,18 @@ disconnect_proxy (GtkAction *action, GtkWidget *proxy)
 
 	if (EPHY_IS_LOCATION_ENTRY (proxy))
 	{
-		EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
-		GtkWidget *entry, *notebook;
+		GtkWidget *notebook;
 		EphyLocationActionPrivate *priv;
 
 		priv = EPHY_LOCATION_ACTION (action)->priv;
 		priv->proxy = NULL;
 
-		entry = ephy_location_entry_get_entry (lentry);
 		notebook = ephy_window_get_notebook (priv->window);
 
 		g_signal_handlers_disconnect_matched (action, G_SIGNAL_MATCH_DATA,
 						      0, 0, NULL, NULL, proxy);
 		g_signal_handlers_disconnect_matched (proxy, G_SIGNAL_MATCH_DATA,
 						      0, 0, NULL, NULL, action);
-		g_signal_handlers_disconnect_matched (entry, G_SIGNAL_MATCH_DATA,
-						      0, 0, NULL, NULL, action);
 		g_signal_handlers_disconnect_matched (notebook, G_SIGNAL_MATCH_DATA,
 						      0, 0, NULL, NULL, action);
 	}
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 48447eb..0263639 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -36,7 +36,8 @@ enum {
 static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
 
 struct _EphyToolbarPrivate {
-    EphyWindow *window;
+  EphyWindow *window;
+  GtkWidget *entry;
 };
 
 static void
@@ -136,6 +137,7 @@ ephy_toolbar_constructed (GObject *object)
   /* Location */
   action = gtk_action_group_get_action (action_group, "Location");
   location = gtk_action_create_tool_item (action);
+  priv->entry = location;
   gtk_box_pack_start (GTK_BOX (box), location,
                       TRUE, TRUE, 0);
   gtk_style_context_add_class (gtk_widget_get_style_context (box),
@@ -156,7 +158,7 @@ ephy_toolbar_constructed (GObject *object)
                            GTK_WIDGET (location_stop_reload),
                            "expand", TRUE,
                            NULL);
-                           
+  
   gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (location_stop_reload));
   gtk_widget_set_margin_right (GTK_WIDGET (location_stop_reload), 12);
   gtk_widget_show_all (GTK_WIDGET (location_stop_reload));
@@ -214,3 +216,9 @@ ephy_toolbar_new (EphyWindow *window)
                                      "window", window,
                                      NULL));
 }
+
+GtkWidget *
+ephy_toolbar_get_location_entry (EphyToolbar *toolbar)
+{
+  return toolbar->priv->entry;
+}
diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h
index 2ecc97f..d1d26b8 100644
--- a/src/ephy-toolbar.h
+++ b/src/ephy-toolbar.h
@@ -57,6 +57,8 @@ GType      ephy_toolbar_get_type (void) G_GNUC_CONST;
 
 GtkWidget *ephy_toolbar_new      (EphyWindow *window);
 
+GtkWidget *ephy_toolbar_get_location_entry (EphyToolbar *toolbar);
+
 G_END_DECLS
 
 #endif /* EPHY_TOOLBAR_H */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index e86188c..2492b1b 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -426,7 +426,6 @@ struct _EphyWindowPrivate
 	GHashTable *tabs_to_remove;
 	EphyEmbedEvent *context_event;
 	guint idle_worker;
-	GtkWidget *entry;
 	GtkWidget *downloads_box;
 
 	guint clear_progress_timeout_id;
@@ -759,26 +758,6 @@ sync_chromes_visibility (EphyWindow *window)
 }
 
 static void
-ensure_location_entry (EphyWindow *window)
-{
-	GtkActionGroup *toolbar_action_group;
-	GtkAction *action;
-	GSList *proxies;
-	GtkWidget *proxy;
-	EphyWindowPrivate *priv = window->priv;
-
-	toolbar_action_group = priv->toolbar_action_group;
-	action = gtk_action_group_get_action (toolbar_action_group,
-					      "Location");
-	proxies = gtk_action_get_proxies (action);
-	if (proxies)
-	{
-		proxy = GTK_WIDGET (proxies->data);
-		priv->entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (proxy));
-	}
-}
-
-static void
 ephy_window_fullscreen (EphyWindow *window)
 {
 	EphyWindowPrivate *priv = window->priv;
@@ -804,8 +783,6 @@ ephy_window_fullscreen (EphyWindow *window)
 	sync_tab_load_status (ephy_embed_get_web_view (embed), NULL, window);
 	sync_tab_security (ephy_embed_get_web_view (embed), NULL, window);
 
-	ensure_location_entry (window);
-
 	sync_chromes_visibility (window);
 }
 
@@ -816,8 +793,6 @@ ephy_window_unfullscreen (EphyWindow *window)
 
 	destroy_fullscreen_popup (window);
 
-	ensure_location_entry (window);
-
 	sync_chromes_visibility (window);
 }
 
@@ -1118,17 +1093,10 @@ update_edit_actions_sensitivity (EphyWindow *window, gboolean hide)
 
 	if (GTK_IS_EDITABLE (widget))
 	{
+		GtkWidget *entry;
 		gboolean has_selection;
-		GtkActionGroup *action_group;
-		GtkAction *location_action;
-		GSList *proxies;
-		GtkWidget *proxy;
-		
-		action_group = window->priv->toolbar_action_group;
-		location_action = gtk_action_group_get_action (action_group,
-							       "Location");
-		proxies = gtk_action_get_proxies (location_action);
-		proxy = GTK_WIDGET (proxies->data);
+
+		entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->priv->toolbar));
 		
 		has_selection = gtk_editable_get_selection_bounds
 			(GTK_EDITABLE (widget), NULL, NULL);
@@ -1136,18 +1104,8 @@ update_edit_actions_sensitivity (EphyWindow *window, gboolean hide)
 		can_copy = has_selection;
 		can_cut = has_selection;
 		can_paste = TRUE;
-		if (proxy != NULL &&
-		    EPHY_IS_LOCATION_ENTRY (proxy) &&
-		    widget == ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (proxy)))
-		{
-			can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (proxy));
-			can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (proxy));
-		}
-		else
-		{
-			can_undo = FALSE;
-			can_redo = FALSE;
-		}
+		can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (entry));
+		can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (entry));
 	}
 	else
 	{
@@ -3779,8 +3737,6 @@ ephy_window_constructor (GType type,
 
 	sync_chromes_visibility (window);
 
-	ensure_location_entry (window);
-
 	return object;
 }
 
@@ -3843,26 +3799,10 @@ static void
 _ephy_window_activate_location (EphyWindow *window)
 {
 	EphyWindowPrivate *priv = window->priv;
-	GtkAction *action;
-	GSList *proxies;
-	GtkWidget *entry = NULL;
+	GtkWidget *entry;
 	gboolean visible;
 
-	action = gtk_action_group_get_action (priv->toolbar_action_group, "Location");
-	proxies = gtk_action_get_proxies (action);
-
-	if (proxies != NULL && EPHY_IS_LOCATION_ENTRY (proxies->data))
-	{
-		entry = GTK_WIDGET (proxies->data);
-	}
-
-	if (entry == NULL)
-	{
-		/* happens when the user has removed the location entry from
-		 * the toolbars.
-		 */
-		return;
-	}
+	entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (priv->toolbar));
 
 	g_object_get (G_OBJECT (priv->toolbar), "visible", &visible, NULL);
 	if (visible == FALSE)
diff --git a/tests/ephy-location-entry.c b/tests/ephy-location-entry.c
index 6ce9c86..159a7a4 100644
--- a/tests/ephy-location-entry.c
+++ b/tests/ephy-location-entry.c
@@ -43,7 +43,7 @@ test_entry_get_entry (void)
   EphyLocationEntry *entry;
   entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ());
 
-  g_assert (GTK_IS_ENTRY (ephy_location_entry_get_entry (entry)));
+  g_assert (GTK_IS_ENTRY (entry));
 }
 
 static void
@@ -113,7 +113,7 @@ test_entry_can_undo (void)
   /* Use gtk_* function or otherwise user_changed won't be correctly handled
    * internally by the location entry (see editable_changed_cb and
    * block_update) */
-  gtk_entry_set_text (GTK_ENTRY (ephy_location_entry_get_entry (entry)), test);
+  gtk_entry_set_text (GTK_ENTRY (entry), test);
   g_assert_cmpint (ephy_location_entry_get_can_undo (entry), ==, TRUE);
 }
 



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