gedit r6501 - branches/new_plugins/gedit
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6501 - branches/new_plugins/gedit
- Date: Sun, 7 Sep 2008 15:13:18 +0000 (UTC)
Author: jessevdk
Date: Sun Sep 7 15:13:17 2008
New Revision: 6501
URL: http://svn.gnome.org/viewvc/gedit?rev=6501&view=rev
Log:
Fixed deactivate/activate mess in plugins
Modified:
branches/new_plugins/gedit/gedit-plugins-engine.c
branches/new_plugins/gedit/gedit-plugins-engine.h
branches/new_plugins/gedit/gedit-window-private.h
branches/new_plugins/gedit/gedit-window.c
Modified: branches/new_plugins/gedit/gedit-plugins-engine.c
==============================================================================
--- branches/new_plugins/gedit/gedit-plugins-engine.c (original)
+++ branches/new_plugins/gedit/gedit-plugins-engine.c Sun Sep 7 15:13:17 2008
@@ -567,8 +567,6 @@
GList *l;
gboolean res;
- return;
-
for (l = engine->priv->plugin_list; l != NULL; l = l->next)
{
GeditPluginInfo *info = (GeditPluginInfo *) l->data;
@@ -659,6 +657,7 @@
return TRUE;
g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
+
if (gedit_plugin_info_is_active (info))
save_active_plugin_list (engine);
@@ -710,15 +709,19 @@
return !gedit_plugin_info_is_active (info);
}
-static void
-reactivate_all (GeditPluginsEngine *engine,
- GeditWindow *window)
+void
+_gedit_plugins_engine_activate_plugins (GeditPluginsEngine *engine,
+ GeditWindow *window)
{
GList *pl;
GSList *active_plugins = NULL;
-
+
gedit_debug (DEBUG_PLUGINS);
+
+ g_return_if_fail (GEDIT_IS_PLUGINS_ENGINE (engine));
+ g_return_if_fail (GEDIT_IS_WINDOW (window));
+ /* the first time, we get the 'active' plugins from gconf */
if (engine->priv->activate_from_gconf)
{
active_plugins = gconf_client_get_list (engine->priv->gconf_client,
@@ -730,7 +733,6 @@
for (pl = engine->priv->plugin_list; pl; pl = pl->next)
{
GeditPluginInfo *info = (GeditPluginInfo*)pl->data;
-
if (engine->priv->activate_from_gconf &&
g_slist_find_custom (active_plugins,
@@ -755,23 +757,49 @@
}
gedit_debug_message (DEBUG_PLUGINS, "End");
+
+ /* also call update_ui after activation */
+ _gedit_plugins_engine_update_plugins_ui (engine, window);
}
void
-gedit_plugins_engine_update_plugins_ui (GeditPluginsEngine *engine,
- GeditWindow *window,
- gboolean new_window)
+_gedit_plugins_engine_deactivate_plugins (GeditPluginsEngine *engine,
+ GeditWindow *window)
{
GList *pl;
-
+
gedit_debug (DEBUG_PLUGINS);
+ g_return_if_fail (GEDIT_IS_PLUGINS_ENGINE (engine));
g_return_if_fail (GEDIT_IS_WINDOW (window));
+
+ for (pl = engine->priv->plugin_list; pl; pl = pl->next)
+ {
+ GeditPluginInfo *info = (GeditPluginInfo*)pl->data;
+
+ /* check if the plugin is actually active */
+ if (!gedit_plugin_info_is_active (info))
+ continue;
+
+ /* call deactivate for the plugin for this window */
+ gedit_plugin_deactivate (info->plugin, window);
+ }
+
+ gedit_debug_message (DEBUG_PLUGINS, "End");
+}
- if (new_window)
- reactivate_all (engine, window);
+void
+_gedit_plugins_engine_update_plugins_ui (GeditPluginsEngine *engine,
+ GeditWindow *window)
+{
+ GList *pl;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ g_return_if_fail (GEDIT_IS_PLUGINS_ENGINE (engine));
+ g_return_if_fail (GEDIT_IS_WINDOW (window));
- /* updated ui of all the plugins that implement update_ui */
+ /* call update_ui for all active plugins */
for (pl = engine->priv->plugin_list; pl; pl = pl->next)
{
GeditPluginInfo *info = (GeditPluginInfo*)pl->data;
@@ -780,7 +808,6 @@
continue;
gedit_debug_message (DEBUG_PLUGINS, "Updating UI of %s", info->name);
-
gedit_plugin_update_ui (info->plugin, window);
}
}
Modified: branches/new_plugins/gedit/gedit-plugins-engine.h
==============================================================================
--- branches/new_plugins/gedit/gedit-plugins-engine.h (original)
+++ branches/new_plugins/gedit/gedit-plugins-engine.h Sun Sep 7 15:13:17 2008
@@ -78,6 +78,8 @@
GeditPluginInfo *gedit_plugins_engine_get_plugin_info (GeditPluginsEngine *engine,
const gchar *name);
+
+/* plugin load and unloading (overall, for all windows) */
gboolean gedit_plugins_engine_activate_plugin (GeditPluginsEngine *engine,
GeditPluginInfo *info);
gboolean gedit_plugins_engine_deactivate_plugin (GeditPluginsEngine *engine,
@@ -87,13 +89,13 @@
GeditPluginInfo *info,
GtkWindow *parent);
-/*
- * new_window == TRUE if this function is called because a new top window
- * has been created
- */
-void gedit_plugins_engine_update_plugins_ui (GeditPluginsEngine *engine,
- GeditWindow *window,
- gboolean new_window);
+/* plugin activation/deactivation per window, private to GeditWindow */
+void _gedit_plugins_engine_activate_plugins (GeditPluginsEngine *engine,
+ GeditWindow *window);
+void _gedit_plugins_engine_deactivate_plugins (GeditPluginsEngine *engine,
+ GeditWindow *window);
+void _gedit_plugins_engine_update_plugins_ui (GeditPluginsEngine *engine,
+ GeditWindow *window);
G_END_DECLS
Modified: branches/new_plugins/gedit/gedit-window-private.h
==============================================================================
--- branches/new_plugins/gedit/gedit-window-private.h (original)
+++ branches/new_plugins/gedit/gedit-window-private.h Sun Sep 7 15:13:17 2008
@@ -90,6 +90,7 @@
gboolean removing_tabs : 1;
gboolean destroy_has_run : 1;
+ gboolean dispose_has_run : 1;
};
G_END_DECLS
Modified: branches/new_plugins/gedit/gedit-window.c
==============================================================================
--- branches/new_plugins/gedit/gedit-window.c (original)
+++ branches/new_plugins/gedit/gedit-window.c Sun Sep 7 15:13:17 2008
@@ -115,6 +115,7 @@
{
GeditWindow *window;
+ gedit_debug (DEBUG_WINDOW);
window = GEDIT_WINDOW (object);
/* First of all, force collection so that plugins
@@ -122,6 +123,14 @@
*/
gedit_plugins_engine_garbage_collect (gedit_plugins_engine_get_default ());
+ /* make sure to deactivate plugins for this window, but only once */
+ if (!window->priv->dispose_has_run)
+ {
+ _gedit_plugins_engine_deactivate_plugins (gedit_plugins_engine_get_default (),
+ window);
+ window->priv->dispose_has_run = TRUE;
+ }
+
if (window->priv->recents_handler_id != 0)
{
GtkRecentManager *recent_manager;
@@ -143,7 +152,7 @@
g_object_unref (window->priv->window_group);
window->priv->window_group = NULL;
}
-
+
/* Now that there have broken some reference loops,
* force collection again.
*/
@@ -157,6 +166,7 @@
{
GeditWindow *window;
+ gedit_debug (DEBUG_WINDOW);
window = GEDIT_WINDOW (object);
g_free (window->priv->default_path);
@@ -783,8 +793,8 @@
update_next_prev_doc_sensitivity (window, tab);
- gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
- window, FALSE);
+ _gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
+ window);
}
static void
@@ -2261,8 +2271,8 @@
g_free (escaped_name);
g_free (tip);
- gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
- window, FALSE);
+ _gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
+ window);
}
static GeditWindow *
@@ -2466,8 +2476,8 @@
GParamSpec *arg1,
GeditWindow *window)
{
- gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
- window, FALSE);
+ _gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
+ window);
}
static void
@@ -2649,8 +2659,8 @@
"ViewHighlightMode");
gtk_action_set_sensitive (action, FALSE);
- gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
- window, FALSE);
+ _gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
+ window);
}
if (window->priv->num_tabs <= 1)
@@ -3072,6 +3082,7 @@
window->priv->removing_tabs = FALSE;
window->priv->state = GEDIT_WINDOW_STATE_NORMAL;
window->priv->destroy_has_run = FALSE;
+ window->priv->dispose_has_run = FALSE;
window->priv->window_group = gtk_window_group_new ();
gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
@@ -3210,8 +3221,9 @@
NULL);
gedit_debug_message (DEBUG_WINDOW, "Update plugins ui");
- gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (),
- window, TRUE);
+
+ _gedit_plugins_engine_activate_plugins (gedit_plugins_engine_get_default (),
+ window);
/* set visibility of panes.
* This needs to be done after plugins activatation */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]