Index: ephy-session.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-session.c,v
retrieving revision 1.15
diff -u -p -r1.15 ephy-session.c
--- ephy-session.c	5 Apr 2004 18:06:14 -0000	1.15
+++ ephy-session.c	1 Jun 2004 16:05:54 -0000
@@ -857,4 +859,54 @@ ephy_session_get_active_window (EphySess
 	}
 
 	return window;
+}
+
+/**
+ * ephy_session_present_window:
+ * @session: a #EphySession
+ * @address: a URL
+ *
+ * Searches the open windows for a tab with address @address. If found, presents
+ * the window and switches the window's active tab to it.
+ *
+ * Return value: %TRUE if a tab was found
+ **/
+gboolean
+ephy_session_present_window (EphySession *session,
+			     const char *address)
+{
+	EphyWindow *window = NULL;
+	EphyTab *tab = NULL;
+	GList *tabs, *w, *t;
+	gboolean found = FALSE;
+
+	g_return_val_if_fail (EPHY_IS_SESSION (session), FALSE);
+	g_return_val_if_fail (address != NULL, FALSE);
+
+	for (w = session->priv->windows; w != NULL && found == FALSE; w = w->next)
+	{
+		if (!EPHY_IS_WINDOW (w->data)) continue;
+
+		window = EPHY_WINDOW (w->data);
+
+		tabs = ephy_window_get_tabs (window);
+		for (t = tabs; t != NULL && found == FALSE; t = t->next)
+		{
+			tab = EPHY_TAB (t->data);
+			char *tab_address;
+
+			tab_address = ephy_embed_get_location (ephy_tab_get_embed (tab), TRUE);
+			found = tab_address != NULL && strcmp (tab_address, address) == 0;
+			g_free (tab_address);
+		}
+		g_list_free (tabs);
+	}
+
+	if (found)
+	{
+		ephy_window_jump_to_tab (window, tab);
+		gtk_window_present (GTK_WINDOW (window));
+	}
+
+	return found;
 }
Index: ephy-session.h
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-session.h,v
retrieving revision 1.2
diff -u -p -r1.2 ephy-session.h
--- ephy-session.h	19 Nov 2003 19:19:57 -0000	1.2
+++ ephy-session.h	1 Jun 2004 16:05:54 -0000
@@ -77,6 +77,9 @@ void		 ephy_session_add_window	(EphySess
 void		ephy_session_remove_window	(EphySession *session,
 						 GtkWindow *window);
 
+gboolean	ephy_session_present_window	(EphySession *session,
+						 const char *address);
+
 G_END_DECLS
 
 #endif
Index: ephy-automation.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-automation.c,v
retrieving revision 1.21
diff -u -p -r1.21 ephy-automation.c
--- ephy-automation.c	8 May 2004 20:13:13 -0000	1.21
+++ ephy-automation.c	1 Jun 2004 16:05:54 -0000
@@ -58,7 +58,7 @@ impl_ephy_automation_loadurl (PortableSe
 	session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
 	g_return_if_fail (session != NULL);
 
-	if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL))
+	if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL) || !url)
 	{
 		url = "";
 	}
@@ -67,6 +67,12 @@ impl_ephy_automation_loadurl (PortableSe
 	{
 		/* no need to open the homepage,
 		* we did already open session windows */
+		return;
+	}
+
+	/* Check if there's already a window open with that url */
+	if (ephy_session_present_window (session, url))
+	{
 		return;
 	}
 
Index: bookmarks/ephy-bookmarks-editor.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/bookmarks/ephy-bookmarks-editor.c,v
retrieving revision 1.135
diff -u -p -r1.135 ephy-bookmarks-editor.c
--- bookmarks/ephy-bookmarks-editor.c	19 May 2004 10:33:19 -0000	1.135
+++ bookmarks/ephy-bookmarks-editor.c	1 Jun 2004 16:05:55 -0000
@@ -913,14 +913,21 @@ ephy_bookmarks_editor_node_activated_cb 
 				         EphyNode *node,
 					 EphyBookmarksEditor *editor)
 {
+	EphySession *session;
 	const char *location;
 
 	location = ephy_node_get_property_string
 		(node, EPHY_NODE_BMK_PROP_LOCATION);
 	g_return_if_fail (location != NULL);
 
-	ephy_shell_new_tab (ephy_shell, NULL, NULL, location,
-			    EPHY_NEW_TAB_OPEN_PAGE);
+	session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
+
+	/* only open a new window if there isn't already on open for this url */
+	if (ephy_session_present_window (session, location) == FALSE)
+	{
+		ephy_shell_new_tab (ephy_shell, NULL, NULL, location,
+				    EPHY_NEW_TAB_OPEN_PAGE);
+	}
 }
 
 static void
