[gedit/wip/gtkapp: 28/38] Keep everything in the app startup



commit 942feda05cc20858353dea9ea108c887c591eef0
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue Jul 31 15:35:27 2012 +0200

    Keep everything in the app startup

 gedit/gedit-app.c |  110 +++++++++++++++++++++++++++-------------------------
 gedit/gedit.c     |    7 ---
 2 files changed, 57 insertions(+), 60 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index d3578ff..07db797 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -79,6 +79,8 @@ enum
 
 struct _GeditAppPrivate
 {
+	GeditPluginsEngine *engine;
+
 	GeditWindow       *active_window;
 
 	GeditLockdownMask  lockdown;
@@ -90,11 +92,6 @@ struct _GeditAppPrivate
 	GSettings         *window_settings;
 
 	PeasExtensionSet  *extensions;
-
-#ifndef ENABLE_GVFS_METADATA
-	const gchar *cache_dir;
-	gchar *metadata_filename;
-#endif
 };
 
 static GeditApp *app_instance = NULL;
@@ -227,6 +224,8 @@ gedit_app_dispose (GObject *object)
 	   all extensions which in turn will deactivate the extension */
 	g_clear_object (&app->priv->extensions);
 
+	g_clear_object (&app->priv->engine);
+
 	G_OBJECT_CLASS (gedit_app_parent_class)->dispose (object);
 }
 
@@ -358,10 +357,34 @@ gedit_app_set_window_title_impl (GeditApp    *app,
 }
 
 static void
+extension_added (PeasExtensionSet *extensions,
+		 PeasPluginInfo   *info,
+		 PeasExtension    *exten,
+		 GeditApp         *app)
+{
+	gedit_app_activatable_activate (GEDIT_APP_ACTIVATABLE (exten));
+}
+
+static void
+extension_removed (PeasExtensionSet *extensions,
+		   PeasPluginInfo   *info,
+		   PeasExtension    *exten,
+		   GeditApp         *app)
+{
+	gedit_app_activatable_deactivate (GEDIT_APP_ACTIVATABLE (exten));
+}
+
+static void
 gedit_app_startup (GApplication *application)
 {
+	GeditApp *app = GEDIT_APP (application);
+	GtkSourceStyleSchemeManager *manager;
 	const gchar *dir;
 	gchar *icon_dir;
+#ifndef ENABLE_GVFS_METADATA
+	const gchar *cache_dir;
+	gchar *metadata_filename;
+#endif
 
 	G_APPLICATION_CLASS (gedit_app_parent_class)->startup (application);
 
@@ -398,6 +421,35 @@ gedit_app_startup (GApplication *application)
 
 	g_free (metadata_filename);
 #endif
+
+	/*
+	 * We use the default gtksourceview style scheme manager so that plugins
+	 * can obtain it easily without a gedit specific api, but we need to
+	 * add our search path at startup before the manager is actually used.
+	 */
+	manager = gtk_source_style_scheme_manager_get_default ();
+	gtk_source_style_scheme_manager_append_search_path (manager,
+							    gedit_dirs_get_user_styles_dir ());
+
+	app->priv->engine = gedit_plugins_engine_get_default ();
+	app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (app->priv->engine),
+							GEDIT_TYPE_APP_ACTIVATABLE,
+							"app", app,
+							NULL);
+
+	g_signal_connect (app->priv->extensions,
+			  "extension-added",
+			  G_CALLBACK (extension_added),
+			  app);
+
+	g_signal_connect (app->priv->extensions,
+			  "extension-removed",
+			  G_CALLBACK (extension_removed),
+			  app);
+
+	peas_extension_set_foreach (app->priv->extensions,
+	                            (PeasExtensionSetForeachFunc) extension_added,
+	                            app);
 }
 
 static void
@@ -1078,28 +1130,8 @@ load_print_settings (GeditApp *app)
 }
 
 static void
-extension_added (PeasExtensionSet *extensions,
-		 PeasPluginInfo   *info,
-		 PeasExtension    *exten,
-		 GeditApp         *app)
-{
-	gedit_app_activatable_activate (GEDIT_APP_ACTIVATABLE (exten));
-}
-
-static void
-extension_removed (PeasExtensionSet *extensions,
-		   PeasPluginInfo   *info,
-		   PeasExtension    *exten,
-		   GeditApp         *app)
-{
-	gedit_app_activatable_deactivate (GEDIT_APP_ACTIVATABLE (exten));
-}
-
-static void
 gedit_app_init (GeditApp *app)
 {
-	GtkSourceStyleSchemeManager *manager;
-
 	app->priv = GEDIT_APP_GET_PRIVATE (app);
 
 	/* Load settings */
@@ -1108,34 +1140,6 @@ gedit_app_init (GeditApp *app)
 
 	/* initial lockdown state */
 	app->priv->lockdown = gedit_settings_get_lockdown (GEDIT_SETTINGS (app->priv->settings));
-
-	/*
-	 * We use the default gtksourceview style scheme manager so that plugins
-	 * can obtain it easily without a gedit specific api, but we need to
-	 * add our search path at startup before the manager is actually used.
-	 */
-	manager = gtk_source_style_scheme_manager_get_default ();
-	gtk_source_style_scheme_manager_append_search_path (manager,
-							    gedit_dirs_get_user_styles_dir ());
-
-	app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (gedit_plugins_engine_get_default ()),
-							GEDIT_TYPE_APP_ACTIVATABLE,
-							"app", app,
-							NULL);
-
-	g_signal_connect (app->priv->extensions,
-			  "extension-added",
-			  G_CALLBACK (extension_added),
-			  app);
-
-	g_signal_connect (app->priv->extensions,
-			  "extension-removed",
-			  G_CALLBACK (extension_removed),
-			  app);
-
-	peas_extension_set_foreach (app->priv->extensions,
-	                            (PeasExtensionSetForeachFunc) extension_added,
-	                            app);
 }
 
 /* FIXME: lets kill this method */
diff --git a/gedit/gedit.c b/gedit/gedit.c
index fbed444..52d0bd6 100644
--- a/gedit/gedit.c
+++ b/gedit/gedit.c
@@ -52,8 +52,6 @@ int
 main (int argc, char *argv[])
 {
 	GeditApp *app;
-	GeditPluginsEngine *engine;
-	const gchar *dir;
 	gint status;
 
 #ifndef ENABLE_GVFS_METADATA
@@ -61,17 +59,12 @@ main (int argc, char *argv[])
 	gchar *metadata_filename;
 #endif
 
-	/* Init plugins en thegine */
-	gedit_debug_message (DEBUG_APP, "Init plugins");
-	engine = gedit_plugins_engine_get_default ();
-
 	gedit_debug_message (DEBUG_APP, "Run application");
 	app = gedit_app_get_default ();
 	status = g_application_run (G_APPLICATION (app), argc, argv);
 
 	/* Cleanup */
 	g_object_unref (app);
-	g_object_unref (engine);
 
 	return status;
 }



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