[epiphany] ephy-lockdown: de-extensionify



commit b6707ebdfd970548177789562234cbf3cfa4dfc7
Author: Xan Lopez <xan igalia com>
Date:   Sun Oct 7 07:53:59 2012 -0400

    ephy-lockdown: de-extensionify
    
    Simply connect to 'window-added' in EphyShell instead of making this
    an extension.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685631

 src/ephy-lockdown.c |   37 ++++++++++++++++++-------------------
 src/ephy-shell.c    |   10 +---------
 2 files changed, 19 insertions(+), 28 deletions(-)
---
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index d48f13f..97d33b4 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -2,7 +2,7 @@
 /*
  *  Copyright  2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti
  *  Copyright  2003, 2004, 2005 Christian Persch
- *  Copyright  2010 Igalia S.L.
+ *  Copyright  2010, 2012 Igalia S.L.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,19 +28,15 @@
 #include "ephy-embed-container.h"
 #include "ephy-embed-shell.h"
 #include "ephy-embed-utils.h"
-#include "ephy-extension.h"
 #include "ephy-prefs.h"
 #include "ephy-private.h"
 #include "ephy-settings.h"
-#include "ephy-web-view.h"
 
 #include <gtk/gtk.h>
 #include <string.h>
 
 #define LOCKDOWN_FLAG 1 << 8
 
-static void ephy_lockdown_iface_init (EphyExtensionIface *iface);
-
 static int
 find_name (GtkActionGroup *action_group,
 	   const char *name)
@@ -198,8 +194,9 @@ bind_location_controller (GSettings *settings,
 }
 
 static void
-impl_attach_window (EphyExtension *extension,
-		    EphyWindow *window)
+window_added_cb (GtkApplication *application,
+		 GtkWindow *window,
+		 EphyLockdown *lockdown)
 {
 	GtkUIManager *manager;
 	GtkActionGroup *action_group;
@@ -207,6 +204,9 @@ impl_attach_window (EphyExtension *extension,
 	GSettings *settings;
 	EphyLocationController *location_controller;
 
+	if (!EPHY_IS_WINDOW (window))
+		return;
+
 	g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
 			  "changed::" EPHY_PREFS_LOCKDOWN_FULLSCREEN,
 			  G_CALLBACK (fullscreen_cb), window);
@@ -216,11 +216,11 @@ impl_attach_window (EphyExtension *extension,
 
 	/* Trigger an initial state on these elements. */
 	fullscreen_cb (EPHY_SETTINGS_LOCKDOWN,
-		       EPHY_PREFS_LOCKDOWN_FULLSCREEN, window);
+		       EPHY_PREFS_LOCKDOWN_FULLSCREEN, EPHY_WINDOW (window));
 	arbitrary_url_cb (EPHY_SETTINGS_LOCKDOWN,
-			  EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, window);
+			  EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, EPHY_WINDOW (window));
 
-	manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
+	manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (EPHY_WINDOW (window)));
 
 	action_group = find_action_group (manager, "WindowActions");
 	bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
@@ -243,24 +243,23 @@ impl_attach_window (EphyExtension *extension,
 				   action_group, special_toolbar_actions,
 				   G_N_ELEMENTS (special_toolbar_actions));
 
-	location_controller = ephy_window_get_location_controller (window);
+	location_controller = ephy_window_get_location_controller (EPHY_WINDOW (window));
 	bind_location_controller (EPHY_SETTINGS_LOCKDOWN, location_controller);
 }
 
+G_DEFINE_TYPE (EphyLockdown, ephy_lockdown, G_TYPE_OBJECT)
+
 static void
 ephy_lockdown_init (EphyLockdown *lockdown)
 {
+	EphyShell *shell;
+
 	LOG ("EphyLockdown initialising");
-}
 
-G_DEFINE_TYPE_WITH_CODE (EphyLockdown, ephy_lockdown, G_TYPE_OBJECT,
-			 G_IMPLEMENT_INTERFACE (EPHY_TYPE_EXTENSION,
-						ephy_lockdown_iface_init))
+	shell = ephy_shell_get_default ();
 
-static void
-ephy_lockdown_iface_init (EphyExtensionIface *iface)
-{
-	iface->attach_window = impl_attach_window;
+	g_signal_connect (shell, "window-added",
+			  G_CALLBACK (window_added_cb), lockdown);
 }
 
 static void
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 7dda80a..6931a6b 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -901,17 +901,9 @@ ephy_shell_get_lockdown (EphyShell *shell)
 {
   g_return_val_if_fail (EPHY_IS_SHELL (shell), NULL);
 
-  if (shell->priv->lockdown == NULL) {
-    EphyExtensionsManager *manager;
-
+  if (shell->priv->lockdown == NULL)
     shell->priv->lockdown = g_object_new (EPHY_TYPE_LOCKDOWN, NULL);
 
-    manager = EPHY_EXTENSIONS_MANAGER
-      (ephy_shell_get_extensions_manager (shell));
-    ephy_extensions_manager_register (manager,
-                                      G_OBJECT (shell->priv->lockdown));
-  }
-
   return G_OBJECT (shell->priv->session);
 }
 



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