[epiphany/overview: 15/26] Move implementation of EmbedContainer from Window to Notebook



commit d970ef46e0d7cb141d5198bf9c0c96c385664660
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu May 3 15:28:56 2012 +0300

    Move implementation of EmbedContainer from Window to Notebook
    
    The properties that made sense in window were already moved there
    in the previous commit, everything else makes more sense in notebook.

 embed/ephy-embed.c                   |   16 ++++++
 embed/ephy-embed.h                   |    1 +
 embed/ephy-web-view.c                |   21 +++++---
 src/ephy-encoding-dialog.c           |    3 +-
 src/ephy-encoding-menu.c             |    6 +-
 src/ephy-extensions-manager.c        |    9 ++--
 src/ephy-location-controller.c       |    4 +-
 src/ephy-lockdown.c                  |    2 +-
 src/ephy-navigation-history-action.c |    3 +-
 src/ephy-notebook.c                  |   77 ++++++++++++++++++++++++++-
 src/ephy-session.c                   |   11 +++--
 src/ephy-shell.c                     |    5 +-
 src/ephy-window.c                    |   98 +++------------------------------
 src/popup-commands.c                 |   18 +++---
 src/window-commands.c                |   58 +++++++++++---------
 15 files changed, 182 insertions(+), 150 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 381dd41..4f8d4af 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -1001,3 +1001,19 @@ ephy_embed_remove_top_widget (EphyEmbed *embed, GtkWidget *widget)
   gtk_container_remove (GTK_CONTAINER (embed->priv->top_widgets_vbox),
                         GTK_WIDGET (widget));
 }
+
+/**
+ * ephy_embed_get_container:
+ * @embed: a #EphyEmbed
+ *
+ * Returns the container where @embed is
+ *
+ * Return value: (transfer none): the container
+ **/
+GtkWidget *
+ephy_embed_get_container (EphyEmbed *embed)
+{
+  g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
+
+  return gtk_widget_get_parent (GTK_WIDGET (embed));
+}
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 91fc06e..a4988f8 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -61,6 +61,7 @@ void         ephy_embed_auto_download_url        (EphyEmbed  *embed,
                                                   const char *url);
 void         ephy_embed_entering_fullscreen      (EphyEmbed *embed);
 void         ephy_embed_leaving_fullscreen       (EphyEmbed *embed);
+GtkWidget*   ephy_embed_get_container            (EphyEmbed *embed);
 
 G_END_DECLS
 
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 2a21b0b..ed13efc 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -190,11 +190,13 @@ popups_manager_new_window_info (EphyEmbedContainer *container)
 {
   EphyEmbed *embed;
   EphyWebViewChrome chrome;
+  GtkWidget *window;
   GtkAllocation allocation;
   gboolean is_popup;
   char *features;
 
-  g_object_get (container, "chrome", &chrome, "is-popup", &is_popup, NULL);
+  window = gtk_widget_get_toplevel (GTK_WIDGET (container));
+  g_object_get (window, "chrome", &chrome, "is-popup", &is_popup, NULL);
   g_return_val_if_fail (is_popup, g_strdup (""));
 
   embed = ephy_embed_container_get_active_child (container);
@@ -255,6 +257,7 @@ popups_manager_hide (EphyEmbedContainer *container,
   EphyEmbed *embed;
   char *location;
   char *features;
+  GtkWidget *window;
 
   embed = ephy_embed_container_get_active_child (container);
   g_return_if_fail (EPHY_IS_EMBED (embed));
@@ -265,8 +268,8 @@ popups_manager_hide (EphyEmbedContainer *container,
   features = popups_manager_new_window_info (container);
 
   popups_manager_add (parent_view, location, "" /* FIXME? maybe _blank? */, features);
-
-  gtk_widget_destroy (GTK_WIDGET (container));
+  window = gtk_widget_get_toplevel (GTK_WIDGET (container));
+  gtk_widget_destroy (GTK_WIDGET (window));
 
   g_free (location);
   g_free (features);
@@ -1664,8 +1667,8 @@ new_window_cb (EphyWebView *view,
 
   g_return_if_fail (new_view != NULL);
 
-  container = EPHY_EMBED_CONTAINER (gtk_widget_get_toplevel (GTK_WIDGET (new_view)));
-  g_return_if_fail (container != NULL || !gtk_widget_is_toplevel (GTK_WIDGET (container)));
+  container = EPHY_EMBED_CONTAINER
+    (ephy_embed_get_container (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (new_view)));
 
   popups_manager_add_window (view, container);
 }
@@ -2555,13 +2558,17 @@ close_web_view_cb (WebKitWebView *web_view,
                    gpointer user_data)
 #endif
 {
-  GtkWidget *widget = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+  GtkWidget *widget;
+  EphyEmbed *embed;
 
   LOG ("close web view");
 
+  embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view);
+  widget = ephy_embed_get_container (embed);
+
   if (EPHY_IS_EMBED_CONTAINER (widget))
     ephy_embed_container_remove_child (EPHY_EMBED_CONTAINER (widget),
-                                       EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view));
+                                       embed);
   else
     gtk_widget_destroy (widget);
 
diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c
index 95a0b07..30779e4 100644
--- a/src/ephy-encoding-dialog.c
+++ b/src/ephy-encoding-dialog.c
@@ -158,7 +158,8 @@ sync_active_tab (EphyWindow *window, GParamSpec *pspec, EphyEncodingDialog *dial
 {
 	EphyEmbed *embed;
 
-	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (dialog->priv->window));
+	embed = ephy_embed_container_get_active_child
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (dialog->priv->window)));
 
 	g_object_set (G_OBJECT (dialog), "embed", embed, NULL);
 }
diff --git a/src/ephy-encoding-menu.c b/src/ephy-encoding-menu.c
index 86fe2c2..9f6a23a 100644
--- a/src/ephy-encoding-menu.c
+++ b/src/ephy-encoding-menu.c
@@ -136,7 +136,7 @@ update_encoding_menu_cb (GtkAction *dummy, EphyEncodingMenu *menu)
 	/* get most recently used encodings */
 	recent = ephy_encodings_get_recent (p->encodings);
 
-	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (p->window));
+	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (p->window)));
 	view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
 #ifdef HAVE_WEBKIT2
 	encoding = webkit_web_view_get_custom_charset (view);
@@ -255,7 +255,7 @@ encoding_activate_cb (GtkAction *action, EphyEncodingMenu *menu)
 	name = gtk_action_get_name (GTK_ACTION (action));
 	encoding = name + strlen("Encoding");
 
-	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (menu->priv->window));
+	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (menu->priv->window)));
 
 	view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
 #ifdef HAVE_WEBKIT2
@@ -331,7 +331,7 @@ ephy_encoding_menu_automatic_cb (GtkAction *action, EphyEncodingMenu *menu)
 	}
 
 	embed = ephy_embed_container_get_active_child 
-          (EPHY_EMBED_CONTAINER (menu->priv->window));
+	   (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (menu->priv->window)));
 
 	/* setting NULL will clear the forced encoding */
 	view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
diff --git a/src/ephy-extensions-manager.c b/src/ephy-extensions-manager.c
index d45d2d2..0dd4bd3 100644
--- a/src/ephy-extensions-manager.c
+++ b/src/ephy-extensions-manager.c
@@ -517,7 +517,7 @@ attach_window (EphyWindow *window,
 	ephy_extension_attach_window (extension, window);
 
 	tabs = ephy_embed_container_get_children 
-          (EPHY_EMBED_CONTAINER (window));
+	   (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	for (l = tabs; l; l = l->next)
 	{
 		ephy_extension_attach_tab (extension, window,
@@ -580,8 +580,8 @@ detach_window (EphyWindow *window,
 {
 	GList *tabs, *l;
 
-	tabs = ephy_embed_container_get_children 
-          (EPHY_EMBED_CONTAINER (window));
+	tabs = ephy_embed_container_get_children
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	for (l = tabs; l; l = l->next)
 	{
 		ephy_extension_detach_tab (extension, window,
@@ -1074,7 +1074,8 @@ impl_detach_window (EphyExtension *extension,
 	g_object_ref (window);
 
 	/* Detach tabs (uses impl_detach_tab) */
-	tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window));
+	tabs = ephy_embed_container_get_children
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	for (l = tabs; l; l = l->next)
 	{
 		ephy_extension_detach_tab (extension, window,
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 463606e..48c55c5 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -230,7 +230,7 @@ get_location_cb (EphyLocationEntry *entry,
 	EphyEmbed *embed;
 	
 	embed = ephy_embed_container_get_active_child 
-	  (EPHY_EMBED_CONTAINER (priv->window));
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (priv->window)));
 
 	return g_strdup (ephy_web_view_get_address (ephy_embed_get_web_view (embed)));
 }
@@ -242,7 +242,7 @@ get_title_cb (EphyLocationEntry *entry,
 	EphyEmbed *embed;
 
 	embed = ephy_embed_container_get_active_child 
-	  (EPHY_EMBED_CONTAINER (controller->priv->window));
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (controller->priv->window)));
 
 	return g_strdup (ephy_web_view_get_title (ephy_embed_get_web_view (embed)));
 }
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 0d03607..39fddc6 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -72,7 +72,7 @@ arbitrary_url_cb (GSettings *settings,
 	/* Restore the real web page address when disabling entry */
 	if (g_settings_get_boolean (settings, key))
 	{
-		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 		/* embed is NULL on startup */
 		if (embed == NULL)
 			return;
diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c
index f8892bf..52dbdb4 100644
--- a/src/ephy-navigation-history-action.c
+++ b/src/ephy-navigation-history-action.c
@@ -91,7 +91,8 @@ action_activate (GtkAction *action)
 
   history_action = EPHY_NAVIGATION_HISTORY_ACTION (action);
   window = ephy_window_action_get_window (EPHY_WINDOW_ACTION (action));
-  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+  embed = ephy_embed_container_get_active_child
+    (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
   g_return_if_fail (embed != NULL);
 
   web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 6a43412..f72af06 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -25,6 +25,7 @@
 
 #include "ephy-debug.h"
 #include "ephy-dnd.h"
+#include "ephy-embed-container.h"
 #include "ephy-embed-utils.h"
 #include "ephy-embed.h"
 #include "ephy-file-helpers.h"
@@ -77,7 +78,8 @@ static const GtkTargetEntry url_drag_types [] =
 enum
 {
 	PROP_0,
-	PROP_TABS_ALLOWED
+	PROP_TABS_ALLOWED,
+	PROP_ACTIVE_CHILD,
 };
 
 enum
@@ -88,9 +90,76 @@ enum
 
 static guint signals[LAST_SIGNAL];
 
+static int
+impl_add_child (EphyEmbedContainer *container,
+		EphyEmbed *child,
+		int position,
+		gboolean active)
+{
+	EphyWindow *window;
+	EphyNotebook *notebook = EPHY_NOTEBOOK (container);
+
+	window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (container)));
+	g_return_val_if_fail (!ephy_window_get_is_popup (window) ||
+			      gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) < 1, -1);
+
+	return ephy_notebook_add_tab (EPHY_NOTEBOOK (notebook),
+				      child, position, active);
+}
+
+static void
+impl_set_active_child (EphyEmbedContainer *container,
+		       EphyEmbed *child)
+{
+	int page;
+	GtkNotebook *notebook;
+
+	notebook = GTK_NOTEBOOK (container);
+
+	page = gtk_notebook_page_num (notebook, GTK_WIDGET (child));
+	gtk_notebook_set_current_page (notebook, page);
+}
+
+static void
+impl_remove_child (EphyEmbedContainer *container,
+		   EphyEmbed *child)
+{
+	g_signal_emit_by_name (container, "tab-close-request",
+			       child);
+}
+
+static EphyEmbed *
+impl_get_active_child (EphyEmbedContainer *container)
+{
+	EphyNotebook *notebook = EPHY_NOTEBOOK (container);
+	int active;
+
+	active = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+	return EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), active));
+}
+
+/* Fixme: I'd remove this method from the interface altogether. */
+static GList *
+impl_get_children (EphyEmbedContainer *container)
+{
+	return gtk_container_get_children (GTK_CONTAINER (container));
+}
+
+static void
+ephy_notebook_embed_container_iface_init (EphyEmbedContainerIface *iface)
+{
+	iface->add_child = impl_add_child;
+	iface->set_active_child = impl_set_active_child;
+	iface->remove_child = impl_remove_child;
+	iface->get_active_child = impl_get_active_child;
+	iface->get_children = impl_get_children;
+}
+
 G_DEFINE_TYPE_WITH_CODE (EphyNotebook, ephy_notebook, GTK_TYPE_NOTEBOOK,
 			 G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
-						NULL))
+						NULL)
+			 G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_CONTAINER,
+						ephy_notebook_embed_container_iface_init))
 
 static void
 ephy_notebook_get_property (GObject *object,
@@ -157,6 +226,10 @@ ephy_notebook_class_init (EphyNotebookClass *klass)
 							       TRUE,
 							       G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
+	g_object_class_override_property (object_class,
+					  PROP_ACTIVE_CHILD,
+					  "active-child");
+
 	g_type_class_add_private (object_class, sizeof (EphyNotebookPrivate));
 }
 
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 61e669e..e23e0af 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -376,7 +376,8 @@ session_command_open_uris (EphySession *session,
 		{
 			EphyWebView *web_view;
 			
-			embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (priv->resume_window));
+			embed = ephy_embed_container_get_active_child
+			  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (EPHY_WINDOW (priv->resume_window))));
 			web_view = ephy_embed_get_web_view (embed);
 			ephy_web_view_load_url (web_view, url);
 		}
@@ -796,8 +797,8 @@ write_ephy_window (xmlTextWriterPtr writer,
 	const char *role;
 	int ret;
 
-	tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window));
 	notebook = ephy_window_get_notebook (window);
+	tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (notebook));
 
 	/* Do not save an empty EphyWindow.
 	 * This only happens when the window was newly opened.
@@ -989,7 +990,8 @@ parse_embed (xmlNodePtr child,
 					EphyWebView *web_view;
 					EphyEmbed *embed;
 
-					embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+					embed = ephy_embed_container_get_active_child
+					  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (EPHY_WINDOW (window))));
 					web_view = ephy_embed_get_web_view (embed);
 					ephy_web_view_load_url (web_view, recover_url);
 
@@ -1174,7 +1176,8 @@ ephy_session_load_from_string (EphySession *session,
 
 			if (ephy_embed_shell_get_mode (embed_shell) != EPHY_EMBED_SHELL_MODE_TEST)
 			{
-				active_child = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+				active_child = ephy_embed_container_get_active_child
+					(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 				gtk_widget_grab_focus (GTK_WIDGET (active_child));
 				gtk_widget_show (widget);
 			}
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 56c524d..4eacd37 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -752,7 +752,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
 
   if (flags & EPHY_NEW_TAB_FROM_EXTERNAL) {
     /* If the active embed is blank, use that to open the url and jump to it */
-    embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+    embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
     if (embed != NULL) {
       if (ephy_web_view_get_is_blank (ephy_embed_get_web_view (embed)) &&
           ephy_web_view_is_loading (ephy_embed_get_web_view (embed)) == FALSE) {
@@ -766,7 +766,8 @@ ephy_shell_new_tab_full (EphyShell *shell,
     g_assert (embed != NULL);
     gtk_widget_show (GTK_WIDGET (embed));
 
-    ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (window), embed, position, jump_to);
+    ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)),
+                                    embed, position, jump_to);
   }
 
   if (copy_history && previous_embed != NULL) {
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 7e0bb1e..dc4c599 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -370,7 +370,6 @@ struct _EphyWindowPrivate
 enum
 {
 	PROP_0,
-	PROP_ACTIVE_CHILD,
 	PROP_CHROME,
 	PROP_IS_POPUP,
 	PROP_OVERVIEW_MODE
@@ -387,36 +386,6 @@ enum
 	SENS_FLAG_IS_BLANK	= 1 << 5
 };
 
-static gint
-impl_add_child (EphyEmbedContainer *container,
-		EphyEmbed *child,
-		gint position,
-		gboolean jump_to)
-{
-	EphyWindow *window = EPHY_WINDOW (container);
-
-	g_return_val_if_fail (!window->priv->is_popup ||
-			      gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) < 1, -1);
-
-	return ephy_notebook_add_tab (EPHY_NOTEBOOK (window->priv->notebook),
-				      child, position, jump_to);
-}
-
-static void
-impl_set_active_child (EphyEmbedContainer *container,
-		       EphyEmbed *child)
-{
-	int page;
-	EphyWindow *window;
-
-	window = EPHY_WINDOW (container);
-
-	page = gtk_notebook_page_num
-		(window->priv->notebook, GTK_WIDGET (child));
-	gtk_notebook_set_current_page
-		(window->priv->notebook, page);
-}
-
 static GtkWidget *
 construct_confirm_close_dialog (EphyWindow *window,
 				const char *title,
@@ -487,42 +456,6 @@ confirm_close_with_downloads (EphyWindow *window)
 	return response == GTK_RESPONSE_ACCEPT;
 }
 
-static void
-impl_remove_child (EphyEmbedContainer *container,
-		   EphyEmbed *child)
-{
-	EphyWindow *window;
-
-	window = EPHY_WINDOW (container);
-	g_signal_emit_by_name (window->priv->notebook,
-			       "tab-close-request",
-			       child, window);
-}
-
-static EphyEmbed *
-impl_get_active_child (EphyEmbedContainer *container)
-{
-	return EPHY_WINDOW (container)->priv->active_embed;
-}
-
-static GList *
-impl_get_children (EphyEmbedContainer *container)
-{
-	EphyWindow *window = EPHY_WINDOW (container);
-
-	return gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
-}
-
-static void
-ephy_window_embed_container_iface_init (EphyEmbedContainerIface *iface)
-{
-	iface->add_child = impl_add_child;
-	iface->set_active_child = impl_set_active_child;
-	iface->remove_child = impl_remove_child;
-	iface->get_active_child = impl_get_active_child;
-	iface->get_children = impl_get_children;
-}
-
 /**
  * ephy_window_get_is_popup:
  * @window: a #EphyWindow
@@ -639,9 +572,7 @@ ephy_window_link_iface_init (EphyLinkIface *iface)
 
 G_DEFINE_TYPE_WITH_CODE (EphyWindow, ephy_window, GTK_TYPE_APPLICATION_WINDOW,
 			 G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
-						ephy_window_link_iface_init)
-			 G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_CONTAINER,
-						ephy_window_embed_container_iface_init))
+						ephy_window_link_iface_init))
 
 /* FIXME: fix this! */
 static void
@@ -1002,7 +933,7 @@ ephy_window_delete_event (GtkWidget *widget,
 	if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
 				    EPHY_PREFS_LOCKDOWN_QUIT)) return TRUE;
 
-	tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
+	tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window->priv->notebook));
 	for (l = tabs; l != NULL; l = l->next)
 	{
 		EphyEmbed *embed = (EphyEmbed *) l->data;
@@ -1021,8 +952,8 @@ ephy_window_delete_event (GtkWidget *widget,
 	if (modified)
 	{
 		/* jump to the first tab with modified forms */
-		impl_set_active_child (EPHY_EMBED_CONTAINER (window),
-				       modified_embed);
+		ephy_embed_container_set_active_child (EPHY_EMBED_CONTAINER (window->priv->notebook),
+						       modified_embed);
 
 		if (confirm_close_with_modified_forms (window) == FALSE)
 		{
@@ -2529,7 +2460,7 @@ policy_decision_required_cb (WebKitWebView *web_view,
 		}
 
 		embed = ephy_embed_container_get_active_child
-			(EPHY_EMBED_CONTAINER (window));
+			(EPHY_EMBED_CONTAINER (window->priv->notebook));
 
 		ephy_shell_new_tab_full (ephy_shell_get_default (),
 					 window,
@@ -2647,7 +2578,7 @@ ephy_window_connect_active_embed (EphyWindow *window)
 				 G_CALLBACK (ephy_window_visibility_cb),
 				 window, 0);
 
-	g_object_notify (G_OBJECT (window), "active-child");
+	g_object_notify (G_OBJECT (window->priv->notebook), "active-child");
 }
 
 static void
@@ -2767,7 +2698,7 @@ embed_modal_alert_cb (EphyEmbed *embed,
 	 * (since the alert is modal, the user won't be able to do anything
 	 * with his current window anyway :|)
 	 */
-	impl_set_active_child (EPHY_EMBED_CONTAINER (window), embed);
+	ephy_embed_container_set_active_child (EPHY_EMBED_CONTAINER (window->priv->notebook), embed);
 	gtk_window_present (GTK_WINDOW (window));
 
 	/* make sure the location entry shows the real URL of the tab's page */
@@ -3308,10 +3239,6 @@ ephy_window_set_property (GObject *object,
 
 	switch (prop_id)
 	{
-		case PROP_ACTIVE_CHILD:
-			impl_set_active_child (EPHY_EMBED_CONTAINER (window),
-					       g_value_get_object (value));
-			break;
 		case PROP_CHROME:
 			ephy_window_set_chrome (window, g_value_get_flags (value));
 			break;
@@ -3337,9 +3264,6 @@ ephy_window_get_property (GObject *object,
 
 	switch (prop_id)
 	{
-		case PROP_ACTIVE_CHILD:
-			g_value_set_object (value, window->priv->active_embed);
-			break;
 		case PROP_CHROME:
 			g_value_set_flags (value, window->priv->chrome);
 			break;
@@ -3439,7 +3363,7 @@ allow_popups_notifier (GSettings *settings,
 
 	g_return_if_fail (EPHY_IS_WINDOW (window));
 
-	tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
+	tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window->priv->notebook));
 
 	for (; tabs; tabs = g_list_next (tabs))
 	{
@@ -3477,7 +3401,7 @@ sync_user_input_cb (EphyLocationController *action,
 
 	if (priv->updating_address) return;
 
-	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window->priv->notebook));
 	g_assert (EPHY_IS_EMBED (embed));
 
 	address = ephy_location_controller_get_address (action);
@@ -3803,10 +3727,6 @@ ephy_window_class_init (EphyWindowClass *klass)
 	widget_class->window_state_event = ephy_window_state_event;
 	widget_class->delete_event = ephy_window_delete_event;
 
-	g_object_class_override_property (object_class,
-					  PROP_ACTIVE_CHILD,
-					  "active-child");
-
 	g_object_class_install_property (object_class,
 					 PROP_CHROME,
 					 g_param_spec_flags ("chrome", NULL, NULL,
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 939d6e3..de13798 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -50,8 +50,8 @@ popup_cmd_link_in_new_window (GtkAction *action,
 	EphyEmbed *embed;
 	GValue value = { 0, };
 
-	embed = ephy_embed_container_get_active_child 
-		(EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 
 	event = ephy_window_get_context_event (window);
 	g_return_if_fail (event != NULL);
@@ -74,7 +74,7 @@ popup_cmd_link_in_new_tab (GtkAction *action,
 	GValue value = { 0, };
 
 	embed = ephy_embed_container_get_active_child
-		(EPHY_EMBED_CONTAINER (window));
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 
 	event = ephy_window_get_context_event (window);
 	g_return_if_fail (event != NULL);
@@ -269,8 +269,8 @@ popup_cmd_open_link (GtkAction *action,
 	GValue value = { 0, };
 	EphyEmbed *embed;
 
-	embed = ephy_embed_container_get_active_child 
-		(EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	event = ephy_window_get_context_event (window);
@@ -467,8 +467,8 @@ popup_replace_spelling (GtkAction *action,
 	WebKitDOMDocument *document;
 	WebKitDOMDOMWindow *default_view;
 
-	embed = ephy_embed_container_get_active_child 
-		(EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	view = WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed));
@@ -498,7 +498,7 @@ popup_cmd_open_image (GtkAction *action,
 	g_return_if_fail (event != NULL);
 
 	embed = ephy_embed_container_get_active_child 
-		(EPHY_EMBED_CONTAINER (window));
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	ephy_embed_event_get_property (event, "image-uri", &value);
@@ -538,7 +538,7 @@ popup_cmd_inspect_element (GtkAction *action, EphyWindow *window)
 	guint x, y;
 
 	embed = ephy_embed_container_get_active_child
-		(EPHY_EMBED_CONTAINER (window));
+		(EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 
 	event = ephy_window_get_context_event (window);
 	g_return_if_fail (event != NULL);
diff --git a/src/window-commands.c b/src/window-commands.c
index 96cfef8..73398cb 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -72,7 +72,7 @@ window_cmd_file_print (GtkAction *action,
 	EphyWebView *view;
 
 	embed = ephy_embed_container_get_active_child 
-          (EPHY_EMBED_CONTAINER (window));
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (EPHY_IS_EMBED (embed));
 	view = ephy_embed_get_web_view (embed);
 
@@ -90,7 +90,7 @@ window_cmd_file_send_to	(GtkAction *action,
 	GError *error = NULL;
 
 	embed = ephy_embed_container_get_active_child 
-          (EPHY_EMBED_CONTAINER (window));
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	location = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
@@ -164,8 +164,8 @@ window_cmd_view_stop (GtkAction *action,
 {
 	EphyEmbed *embed;
 	
-	embed = ephy_embed_container_get_active_child 
-          (EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	gtk_widget_grab_focus (GTK_WIDGET (embed));
@@ -181,7 +181,7 @@ window_cmd_view_reload (GtkAction *action,
 	WebKitWebView *view;
 
 	embed = ephy_embed_container_get_active_child 
-          (EPHY_EMBED_CONTAINER (window));
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	gtk_widget_grab_focus (GTK_WIDGET (embed));
@@ -199,8 +199,8 @@ window_cmd_file_bookmark_page (GtkAction *action,
 {
 	EphyEmbed *embed;
 
-	embed = ephy_embed_container_get_active_child 
-          (EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (window),
@@ -325,7 +325,8 @@ window_cmd_file_save_as (GtkAction *action,
 	char *suggested_filename;
 	EphyWebView *view;
 
-	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	dialog = ephy_file_chooser_new (_("Save"),
@@ -619,7 +620,8 @@ window_cmd_file_save_as_application (GtkAction *action,
 	EphyWebView *view;
 	EphyApplicationDialogData *data;
 
-	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	view = EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
@@ -697,7 +699,8 @@ window_cmd_file_close_window (GtkAction *action,
 		return;
 	}
 
-	embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	g_signal_emit_by_name (notebook, "tab-close-request", embed);
@@ -774,7 +777,9 @@ window_cmd_edit_cut (GtkAction *action,
 	else
 	{
 		EphyEmbed *embed;
-		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+
+		embed = ephy_embed_container_get_active_child
+		  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 		g_return_if_fail (embed != NULL);
 
 #ifdef HAVE_WEBKIT2
@@ -799,7 +804,8 @@ window_cmd_edit_copy (GtkAction *action,
 	{
 		EphyEmbed *embed;
 
-		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+		embed = ephy_embed_container_get_active_child
+		  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 		g_return_if_fail (embed != NULL);
 #ifdef HAVE_WEBKIT2
 		webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), WEBKIT_EDITING_COMMAND_COPY);
@@ -823,7 +829,8 @@ window_cmd_edit_paste (GtkAction *action,
 	{
 		EphyEmbed *embed;
 
-		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+		embed = ephy_embed_container_get_active_child
+		  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 		g_return_if_fail (embed != NULL);
 
 #ifdef HAVE_WEBKIT2
@@ -848,7 +855,8 @@ window_cmd_edit_delete (GtkAction *action,
 	{
 		EphyEmbed *embed;
 
-		embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+		embed = ephy_embed_container_get_active_child
+		  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 		g_return_if_fail (embed != NULL);
 
 		/* FIXME: TODO */
@@ -873,8 +881,8 @@ window_cmd_edit_select_all (GtkAction *action,
 	{
 		EphyEmbed *embed;
 
-		embed = ephy_embed_container_get_active_child 
-                  (EPHY_EMBED_CONTAINER (window));
+		embed = ephy_embed_container_get_active_child
+		  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 		g_return_if_fail (embed != NULL);
 
 #ifdef HAVE_WEBKIT2
@@ -1180,8 +1188,8 @@ window_cmd_view_page_source (GtkAction *action,
 	const char *address;
 	guint32 user_time;
 
-	embed = ephy_embed_container_get_active_child 
-          (EPHY_EMBED_CONTAINER (window));
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
 	g_return_if_fail (embed != NULL);
 
 	address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
@@ -1427,13 +1435,13 @@ window_cmd_tabs_detach  (GtkAction *action,
         if (gtk_notebook_get_n_pages (notebook) <= 1)
                 return;
 
-        embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
-
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
         g_object_ref_sink (embed);
         gtk_notebook_remove_page (notebook, gtk_notebook_page_num (notebook, GTK_WIDGET (embed)));
 
         new_window = ephy_window_new ();
-        ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (new_window), embed, 0, FALSE);
+        ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)), embed, 0, FALSE);
         g_object_unref (embed);
 
         gtk_window_present (GTK_WINDOW (new_window));
@@ -1458,7 +1466,7 @@ window_cmd_load_location (GtkAction *action,
 		g_return_if_fail (address != NULL);
 
 		ephy_link_open (EPHY_LINK (window), address,
-			        ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window)),
+			        ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window))),
 				ephy_link_flags_from_current_event ());
 	}
 }
@@ -1470,9 +1478,9 @@ window_cmd_browse_with_caret (GtkAction *action,
 	gboolean active;
 	EphyEmbed *embed;
 
-	embed = ephy_embed_container_get_active_child 
-		(EPHY_EMBED_CONTAINER (window));
-	
+	embed = ephy_embed_container_get_active_child
+	  (EPHY_EMBED_CONTAINER (ephy_window_get_notebook (window)));
+
 	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
 	/* FIXME: perhaps a bit of a kludge; we check if there's an



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