All pastes #23115 Raw Edit

Diff

public text v1 · immutable
#23115 ·published 2005-09-16 16:48 UTC
rendered paste body
Index: src/bookmarks/ephy-bookmark-action.c===================================================================RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmark-action.c,vretrieving revision 1.66diff -u -p -r1.66 ephy-bookmark-action.c--- src/bookmarks/ephy-bookmark-action.c	26 Jul 2005 17:41:04 -0000	1.66+++ src/bookmarks/ephy-bookmark-action.c	16 Sep 2005 16:48:38 -0000@@ -304,84 +304,101 @@ ephy_bookmark_action_sync_label (GtkActi 	} } +static gint+find_tool_item_proxy(const GtkWidget *proxy, gconstpointer data)+{+	/* We try to retreive the toolbar widget in the GtkAction's proxy list */+	return GTK_IS_TOOL_ITEM (proxy) ? 0 : 1;+}+ static void-open_in_tab_activate_cb (GtkWidget *widget,-			 EphyBookmarkAction *action)+bookmark_activate_with_flags (GtkWidget *widget,+				EphyBookmarkAction *action,+				EphyLinkFlags flags) { 	EphyBookmarkActionPrivate *priv = action->priv; 	EphyBookmarks *bookmarks; 	const char *location;-	char *address;+	char *address = NULL, *text = NULL;  	g_return_if_fail (priv->node != NULL);  	location = ephy_node_get_property_string 			(priv->node, EPHY_NODE_BMK_PROP_LOCATION); 	g_return_if_fail (location != NULL);-+	 	bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());-	address = ephy_bookmarks_resolve_address (bookmarks, location, NULL);+	+	if (GTK_IS_EDITABLE (widget))+	{+		/* We got the callback because enter wa pressed in the gtk entry */+		text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);+	}+	else+	{+		/* We try to retreive any existing text from the TOOL_ITEM in+		   the proxy list */+		GSList *proxy_item = g_slist_find_custom (+								gtk_action_get_proxies (action),+								NULL,+								(GCompareFunc) find_tool_item_proxy);+		if (proxy_item != NULL)+		{+			text = gtk_editable_get_chars (+					GTK_EDITABLE (g_object_get_data (G_OBJECT (proxy_item->data), "entry")),+					0, -1);+		}+	}+	+	/* The entered search term is empty, and we have a smart bookmark */+	if (text == NULL && strstr (location, "%s") != NULL)+	{+		GnomeVFSURI *uri = gnome_vfs_uri_new (location);+		if (uri != NULL)+		{+			address = g_strconcat (+					gnome_vfs_uri_get_scheme (uri),+					"://",+					gnome_vfs_uri_get_host_name (uri),+					NULL);+			gnome_vfs_uri_unref (uri);+		}+	}++	if (address == NULL)+	{+		address = ephy_bookmarks_resolve_address (bookmarks, location, text);+	} 	g_return_if_fail (address != NULL); -	ephy_link_open (EPHY_LINK (action), address, NULL,-			EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);+	ephy_link_open (EPHY_LINK (action), address, NULL, flags);  	g_free (address);+	g_free (text); }  static void-open_in_window_activate_cb (GtkWidget *widget, EphyBookmarkAction *action)+open_in_tab_activate_cb (GtkWidget *widget,+			 EphyBookmarkAction *action) {-	EphyBookmarkActionPrivate *priv = action->priv;-	EphyBookmarks *bookmarks;-	const char *location;-	char *address;--	g_return_if_fail (priv->node != NULL);--	location = ephy_node_get_property_string-			(priv->node, EPHY_NODE_BMK_PROP_LOCATION);-	g_return_if_fail (location != NULL);--	bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());-	address = ephy_bookmarks_resolve_address (bookmarks, location, NULL);-	g_return_if_fail (address != NULL);--	ephy_link_open (EPHY_LINK (action), address, NULL, EPHY_LINK_NEW_WINDOW);+	bookmark_activate_with_flags(widget, action,+			EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);+} -	g_free (address);+static void+open_in_window_activate_cb (GtkWidget *widget,+			EphyBookmarkAction *action)+{+	bookmark_activate_with_flags(widget, action,+			EPHY_LINK_NEW_WINDOW); }  static void activate_cb (GtkWidget *widget,-	     EphyBookmarkAction *action)+	     	EphyBookmarkAction *action) {-	EphyBookmarkActionPrivate *priv = action->priv;-	EphyBookmarks *bookmarks;-	const char *location;-	char *address, *text = NULL;--	g_return_if_fail (priv->node != NULL);--	location = ephy_node_get_property_string-			(priv->node, EPHY_NODE_BMK_PROP_LOCATION);-	g_return_if_fail (location != NULL);--	if (GTK_IS_EDITABLE (widget))-	{-		text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);-	}--	bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());--	address = ephy_bookmarks_resolve_address (bookmarks, location, text);-	g_return_if_fail (address != NULL);--	ephy_link_open (EPHY_LINK (action), address, NULL,+	bookmark_activate_with_flags(widget, action, 			ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0);--	g_free (address);-	g_free (text); }  static voidIndex: src/bookmarks/ephy-bookmarks.c===================================================================RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks.c,vretrieving revision 1.114diff -u -p -r1.114 ephy-bookmarks.c--- src/bookmarks/ephy-bookmarks.c	15 Sep 2005 12:50:07 -0000	1.114+++ src/bookmarks/ephy-bookmarks.c	16 Sep 2005 16:48:38 -0000@@ -1342,25 +1342,6 @@ impl_resolve_address (EphyBookmarks *eb, 	char *pos, *oldpos, *arg, *escaped_arg, *encoding, *optionsend;  	if (address == NULL) return NULL;--	/* The entered search term is empty "" */-	if (content == NULL || content[0] == '\0')-	{-		GnomeVFSURI *uri = gnome_vfs_uri_new (address);-		if (uri != NULL)-		{-			char *real_address = g_strconcat (-					gnome_vfs_uri_get_scheme (uri),-					"://",-					gnome_vfs_uri_get_host_name (uri),-					NULL);-			gnome_vfs_uri_unref (uri);-			-			return real_address;-		}-	}-	-	/* Either there was a search term, or gnome-vfs URI had a problem */ 	if (content == NULL) content = "";  	result = g_string_new_len (NULL, strlen (content) + strlen (address));