[libpeas] Rename 'activate_plugin'-type API to 'load_plugin'.
- From: Steve Frécinaux <sfre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Rename 'activate_plugin'-type API to 'load_plugin'.
- Date: Wed, 16 Jun 2010 18:13:54 +0000 (UTC)
commit 52f279cd1fe492c159b244f2b84f5f85254536a5
Author: Steve Frécinaux <code istique net>
Date: Wed Jun 16 19:43:01 2010 +0200
Rename 'activate_plugin'-type API to 'load_plugin'.
The reason is that the verb 'activate' let people think there will be
some kind of PeasActivatable-like activation, but the engine only
handles the actual loading. The application is responsible for the
handling of the extensions, eventually through PeasExtensionSet
instances.
https://bugzilla.gnome.org/show_bug.cgi?id=621646
docs/reference/libpeas-sections.txt | 10 ++--
libpeas/peas-engine.c | 137 +++++++++++++++++------------------
libpeas/peas-engine.h | 14 ++--
libpeas/peas-extension-set.c | 8 +-
libpeas/peas-plugin-info-priv.h | 4 +-
libpeas/peas-plugin-info.c | 10 ++--
libpeas/peas-plugin-info.h | 2 +-
libpeasui/peas-ui-plugin-manager.c | 20 +++---
peas-demo/peas-demo.c | 2 +-
9 files changed, 101 insertions(+), 106 deletions(-)
---
diff --git a/docs/reference/libpeas-sections.txt b/docs/reference/libpeas-sections.txt
index 8a15fad..1d0b0b4 100644
--- a/docs/reference/libpeas-sections.txt
+++ b/docs/reference/libpeas-sections.txt
@@ -40,11 +40,11 @@ PeasEngineClass
peas_engine_new
peas_engine_rescan_plugins
peas_engine_get_plugin_list
-peas_engine_get_active_plugins
-peas_engine_set_active_plugins
+peas_engine_get_loaded_plugins
+peas_engine_set_loaded_plugins
peas_engine_get_plugin_info
-peas_engine_activate_plugin
-peas_engine_deactivate_plugin
+peas_engine_load_plugin
+peas_engine_unload_plugin
peas_engine_garbage_collect
peas_engine_provides_extension
peas_engine_get_extension
@@ -161,7 +161,7 @@ PEAS_TYPE_PLUGIN_INFO
PEAS_PLUGIN_INFO
PeasPluginInfo
peas_plugin_info_get_type
-peas_plugin_info_is_active
+peas_plugin_info_is_loaded
peas_plugin_info_is_available
peas_plugin_info_get_module_name
peas_plugin_info_get_module_dir
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index d1caf9f..fc0e69c 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -48,8 +48,8 @@ G_DEFINE_TYPE (PeasEngine, peas_engine, G_TYPE_OBJECT);
/* Signals */
enum {
- ACTIVATE_PLUGIN,
- DEACTIVATE_PLUGIN,
+ LOAD_PLUGIN,
+ UNLOAD_PLUGIN,
LAST_SIGNAL
};
@@ -81,10 +81,10 @@ struct _PeasEnginePrivate {
GList *object_list;
};
-static void peas_engine_activate_plugin_real (PeasEngine *engine,
- PeasPluginInfo * info);
-static void peas_engine_deactivate_plugin_real (PeasEngine * engine,
- PeasPluginInfo * info);
+static void peas_engine_load_plugin_real (PeasEngine *engine,
+ PeasPluginInfo * info);
+static void peas_engine_unload_plugin_real (PeasEngine * engine,
+ PeasPluginInfo * info);
static void
load_plugin_info (PeasEngine *engine,
@@ -339,13 +339,13 @@ peas_engine_finalize (GObject *object)
PeasEngine *engine = PEAS_ENGINE (object);
GList *item;
- /* First deactivate all plugins */
+ /* First unload all the plugins */
for (item = engine->priv->plugin_list; item; item = item->next)
{
PeasPluginInfo *info = PEAS_PLUGIN_INFO (item->data);
- if (peas_plugin_info_is_active (info))
- peas_engine_deactivate_plugin_real (engine, info);
+ if (peas_plugin_info_is_loaded (info))
+ peas_engine_unload_plugin_real (engine, info);
}
/* unref the loaders */
@@ -374,8 +374,8 @@ peas_engine_class_init (PeasEngineClass *klass)
object_class->get_property = peas_engine_get_property;
object_class->constructed = peas_engine_constructed;
object_class->finalize = peas_engine_finalize;
- klass->activate_plugin = peas_engine_activate_plugin_real;
- klass->deactivate_plugin = peas_engine_deactivate_plugin_real;
+ klass->load_plugin = peas_engine_load_plugin_real;
+ klass->unload_plugin = peas_engine_unload_plugin_real;
/**
* PeasEngine:app-name:
@@ -456,18 +456,17 @@ peas_engine_class_init (PeasEngineClass *klass)
G_PARAM_STATIC_STRINGS));
/**
- * PeasEngine::activate-plugin:
+ * PeasEngine::load-plugin:
* @engine: A #PeasEngine.
* @info: A #PeasPluginInfo.
*
- * The activate-plugin signal is emitted when a plugin is being
- * activated.
+ * The load-plugin signal is emitted when a plugin is being loaded.
*/
- signals[ACTIVATE_PLUGIN] =
- g_signal_new ("activate-plugin",
+ signals[LOAD_PLUGIN] =
+ g_signal_new ("load-plugin",
the_type,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PeasEngineClass, activate_plugin),
+ G_STRUCT_OFFSET (PeasEngineClass, load_plugin),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,
@@ -476,18 +475,17 @@ peas_engine_class_init (PeasEngineClass *klass)
G_SIGNAL_TYPE_STATIC_SCOPE);
/**
- * PeasEngine::deactivate-plugin:
+ * PeasEngine::unload-plugin:
* @engine: A #PeasEngine.
* @info: A #PeasPluginInfo.
*
- * The activate-plugin signal is emitted when a plugin is being
- * deactivated.
+ * The unload-plugin signal is emitted when a plugin is being unloaded.
*/
- signals[DEACTIVATE_PLUGIN] =
- g_signal_new ("deactivate-plugin",
+ signals[UNLOAD_PLUGIN] =
+ g_signal_new ("unload-plugin",
the_type,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PeasEngineClass, deactivate_plugin),
+ G_STRUCT_OFFSET (PeasEngineClass, unload_plugin),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE,
@@ -658,7 +656,7 @@ load_plugin (PeasEngine *engine,
{
PeasPluginLoader *loader;
- if (peas_plugin_info_is_active (info))
+ if (peas_plugin_info_is_loaded (info))
return TRUE;
if (!peas_plugin_info_is_available (info))
@@ -674,9 +672,9 @@ load_plugin (PeasEngine *engine,
return FALSE;
}
- info->active = peas_plugin_loader_load (loader, info);
+ info->loaded = peas_plugin_loader_load (loader, info);
- if (info->active == FALSE)
+ if (info->loaded == FALSE)
{
g_warning ("Error loading plugin '%s'", info->name);
info->available = FALSE;
@@ -687,46 +685,45 @@ load_plugin (PeasEngine *engine,
}
static void
-peas_engine_activate_plugin_real (PeasEngine *engine,
- PeasPluginInfo *info)
+peas_engine_load_plugin_real (PeasEngine *engine,
+ PeasPluginInfo *info)
{
load_plugin (engine, info);
}
/**
- * peas_engine_activate_plugin:
+ * peas_engine_load_plugin:
* @engine: A #PeasEngine.
* @info: A #PeasPluginInfo.
*
- * Activates the plugin corresponding to @info on all the objects registered
- * against @engine, loading it if it's not already available.
+ * Loads the plugin corresponding to @info if it's not currently loaded.
*
- * Returns: whether the plugin has been successfuly activated.
+ * Returns: whether the plugin has been successfuly loaded.
*/
gboolean
-peas_engine_activate_plugin (PeasEngine *engine,
- PeasPluginInfo *info)
+peas_engine_load_plugin (PeasEngine *engine,
+ PeasPluginInfo *info)
{
g_return_val_if_fail (info != NULL, FALSE);
if (!peas_plugin_info_is_available (info))
return FALSE;
- if (peas_plugin_info_is_active (info))
+ if (peas_plugin_info_is_loaded (info))
return TRUE;
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
+ g_signal_emit (engine, signals[LOAD_PLUGIN], 0, info);
- return peas_plugin_info_is_active (info);
+ return peas_plugin_info_is_loaded (info);
}
static void
-peas_engine_deactivate_plugin_real (PeasEngine *engine,
- PeasPluginInfo *info)
+peas_engine_unload_plugin_real (PeasEngine *engine,
+ PeasPluginInfo *info)
{
PeasPluginLoader *loader;
- if (!peas_plugin_info_is_active (info) ||
+ if (!peas_plugin_info_is_loaded (info) ||
!peas_plugin_info_is_available (info))
return;
@@ -736,32 +733,30 @@ peas_engine_deactivate_plugin_real (PeasEngine *engine,
peas_plugin_loader_garbage_collect (loader);
peas_plugin_loader_unload (loader, info);
- info->active = FALSE;
+ info->loaded = FALSE;
}
/**
- * peas_engine_deactivate_plugin:
+ * peas_engine_unload_plugin:
* @engine: A #PeasEngine.
* @info: A #PeasPluginInfo.
*
- * Deactivates the plugin corresponding to @info on all the objects registered
- * against @engine, eventually unloading it when it has been completely
- * deactivated.
+ * Unloads the plugin corresponding to @info.
*
- * Returns: whether the plugin has been successfuly deactivated.
+ * Returns: whether the plugin has been successfuly unloaded.
*/
gboolean
-peas_engine_deactivate_plugin (PeasEngine *engine,
- PeasPluginInfo *info)
+peas_engine_unload_plugin (PeasEngine *engine,
+ PeasPluginInfo *info)
{
g_return_val_if_fail (info != NULL, FALSE);
- if (!peas_plugin_info_is_active (info))
+ if (!peas_plugin_info_is_loaded (info))
return TRUE;
- g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
+ g_signal_emit (engine, signals[UNLOAD_PLUGIN], 0, info);
- return !peas_plugin_info_is_active (info);
+ return !peas_plugin_info_is_loaded (info);
}
gboolean
@@ -774,7 +769,7 @@ peas_engine_provides_extension (PeasEngine *engine,
g_return_val_if_fail (PEAS_IS_ENGINE (engine), FALSE);
g_return_val_if_fail (info != NULL, FALSE);
- if (!peas_plugin_info_is_active (info))
+ if (!peas_plugin_info_is_loaded (info))
return FALSE;
loader = get_plugin_loader (engine, info);
@@ -796,17 +791,17 @@ peas_engine_get_extension (PeasEngine *engine,
}
/**
- * peas_engine_get_active_plugins:
+ * peas_engine_get_loaded_plugins:
* @engine: A #PeasEngine.
*
- * Returns the list of the names of all the active plugins, or %NULL if there
- * is no active plugin. Please note that the returned array is a newly
- * allocated one: you will need to free it using g_strfreev().
+ * Returns the list of the names of all the loaded plugins, or %NULL if there
+ * is no plugin currently loaded. Please note that the returned array is a
+ * newly allocated one: you will need to free it using g_strfreev().
*
* Returns: A newly-allocated NULL-terminated array of strings, or %NULL.
*/
gchar **
-peas_engine_get_active_plugins (PeasEngine *engine)
+peas_engine_get_loaded_plugins (PeasEngine *engine)
{
GArray *array = g_array_new (TRUE, FALSE, sizeof (gchar *));
GList *pl;
@@ -816,7 +811,7 @@ peas_engine_get_active_plugins (PeasEngine *engine)
PeasPluginInfo *info = (PeasPluginInfo *) pl->data;
gchar *module_name;
- if (peas_plugin_info_is_active (info))
+ if (peas_plugin_info_is_loaded (info))
{
module_name = g_strdup (peas_plugin_info_get_module_name (info));
g_array_append_val (array, module_name);
@@ -838,16 +833,16 @@ string_in_strv (const gchar *needle,
}
/**
- * peas_engine_set_active_plugins:
+ * peas_engine_set_loaded_plugins:
* @engine: A #PeasEngine.
* @plugin_names: A NULL-terminated array of plugin names.
*
- * Sets the list of active plugins for @engine. When this function is called,
- * the #PeasEngine will activate all the plugins whose names are in
- * @plugin_names, and deactivate all other active plugins.
+ * Sets the list of loaded plugins for @engine. When this function is called,
+ * the #PeasEngine will load all the plugins whose names are in @plugin_names,
+ * and ensures all other active plugins are unloaded.
*/
void
-peas_engine_set_active_plugins (PeasEngine *engine,
+peas_engine_set_loaded_plugins (PeasEngine *engine,
const gchar **plugin_names)
{
GList *pl;
@@ -856,21 +851,21 @@ peas_engine_set_active_plugins (PeasEngine *engine,
{
PeasPluginInfo *info = (PeasPluginInfo *) pl->data;
const gchar *module_name;
- gboolean is_active;
- gboolean to_activate;
+ gboolean is_loaded;
+ gboolean to_load;
if (!peas_plugin_info_is_available (info))
continue;
module_name = peas_plugin_info_get_module_name (info);
- is_active = peas_plugin_info_is_active (info);
+ is_loaded = peas_plugin_info_is_loaded (info);
- to_activate = string_in_strv (module_name, plugin_names);
+ to_load = string_in_strv (module_name, plugin_names);
- if (!is_active && to_activate)
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
- else if (is_active && !to_activate)
- g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
+ if (!is_loaded && to_load)
+ g_signal_emit (engine, signals[LOAD_PLUGIN], 0, info);
+ else if (is_loaded && !to_load)
+ g_signal_emit (engine, signals[UNLOAD_PLUGIN], 0, info);
}
}
diff --git a/libpeas/peas-engine.h b/libpeas/peas-engine.h
index 9bb8dfe..440fb09 100644
--- a/libpeas/peas-engine.h
+++ b/libpeas/peas-engine.h
@@ -55,10 +55,10 @@ struct _PeasEngine {
struct _PeasEngineClass {
GObjectClass parent_class;
- void (*activate_plugin) (PeasEngine *engine,
+ void (*load_plugin) (PeasEngine *engine,
PeasPluginInfo *info);
- void (*deactivate_plugin) (PeasEngine *engine,
+ void (*unload_plugin) (PeasEngine *engine,
PeasPluginInfo *info);
};
@@ -72,16 +72,16 @@ void peas_engine_disable_loader (PeasEngine *engine,
const gchar *loader_id);
void peas_engine_rescan_plugins (PeasEngine *engine);
const GList *peas_engine_get_plugin_list (PeasEngine *engine);
-gchar **peas_engine_get_active_plugins (PeasEngine *engine);
-void peas_engine_set_active_plugins (PeasEngine *engine,
+gchar **peas_engine_get_loaded_plugins (PeasEngine *engine);
+void peas_engine_set_loaded_plugins (PeasEngine *engine,
const gchar **plugin_names);
PeasPluginInfo *peas_engine_get_plugin_info (PeasEngine *engine,
const gchar *plugin_name);
-/* plugin load and unloading (overall, for all windows) */
-gboolean peas_engine_activate_plugin (PeasEngine *engine,
+/* plugin loading and unloading */
+gboolean peas_engine_load_plugin (PeasEngine *engine,
PeasPluginInfo *info);
-gboolean peas_engine_deactivate_plugin (PeasEngine *engine,
+gboolean peas_engine_unload_plugin (PeasEngine *engine,
PeasPluginInfo *info);
void peas_engine_garbage_collect (PeasEngine *engine);
diff --git a/libpeas/peas-extension-set.c b/libpeas/peas-extension-set.c
index 3bfcbf5..be76da3 100644
--- a/libpeas/peas-extension-set.c
+++ b/libpeas/peas-extension-set.c
@@ -78,8 +78,8 @@ add_extension (PeasExtensionSet *set,
PeasExtension *exten;
ExtensionItem *item;
- /* Let's just ignore inactive plugins... */
- if (!peas_plugin_info_is_active (info))
+ /* Let's just ignore unloaded plugins... */
+ if (!peas_plugin_info_is_loaded (info))
return;
exten = peas_engine_get_extension (set->priv->engine, info,
@@ -151,11 +151,11 @@ peas_extension_set_set_internal_data (PeasExtensionSet *set,
add_extension (set, (PeasPluginInfo *) l->data);
set->priv->activate_handler_id =
- g_signal_connect_data (engine, "activate-plugin",
+ g_signal_connect_data (engine, "load-plugin",
G_CALLBACK (add_extension), set,
NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
set->priv->deactivate_handler_id =
- g_signal_connect_data (engine, "deactivate-plugin",
+ g_signal_connect_data (engine, "unload-plugin",
G_CALLBACK (remove_extension), set,
NULL, G_CONNECT_SWAPPED);
}
diff --git a/libpeas/peas-plugin-info-priv.h b/libpeas/peas-plugin-info-priv.h
index 96c4bf8..a54c4d7 100644
--- a/libpeas/peas-plugin-info-priv.h
+++ b/libpeas/peas-plugin-info-priv.h
@@ -48,8 +48,8 @@ struct _PeasPluginInfo {
gboolean visible;
GHashTable *keys;
- gint active : 1;
- /* A plugin is unavailable if it is not possible to activate it
+ gint loaded : 1;
+ /* A plugin is unavailable if it is not possible to load it
due to an error loading the plugin module (e.g. for Python plugins
when the interpreter has not been correctly initializated) */
gint available : 1;
diff --git a/libpeas/peas-plugin-info.c b/libpeas/peas-plugin-info.c
index 4c0663b..a221a31 100644
--- a/libpeas/peas-plugin-info.c
+++ b/libpeas/peas-plugin-info.c
@@ -318,19 +318,19 @@ error:
}
/**
- * peas_plugin_info_is_active:
+ * peas_plugin_info_is_loaded:
* @info: A #PeasPluginInfo.
*
- * Check if the plugin is active.
+ * Check if the plugin is loaded.
*
- * Returns: %TRUE if the plugin is active.
+ * Returns: %TRUE if the plugin is loaded.
*/
gboolean
-peas_plugin_info_is_active (PeasPluginInfo *info)
+peas_plugin_info_is_loaded (PeasPluginInfo *info)
{
g_return_val_if_fail (info != NULL, FALSE);
- return info->available && info->active;
+ return info->available && info->loaded;
}
/**
diff --git a/libpeas/peas-plugin-info.h b/libpeas/peas-plugin-info.h
index 7726268..6074bde 100644
--- a/libpeas/peas-plugin-info.h
+++ b/libpeas/peas-plugin-info.h
@@ -39,7 +39,7 @@ typedef struct _PeasPluginInfo PeasPluginInfo;
GType peas_plugin_info_get_type (void) G_GNUC_CONST;
-gboolean peas_plugin_info_is_active (PeasPluginInfo *info);
+gboolean peas_plugin_info_is_loaded (PeasPluginInfo *info);
gboolean peas_plugin_info_is_available (PeasPluginInfo *info);
const gchar *peas_plugin_info_get_module_name (PeasPluginInfo *info);
diff --git a/libpeasui/peas-ui-plugin-manager.c b/libpeasui/peas-ui-plugin-manager.c
index 2b36b9b..7c8a85a 100644
--- a/libpeasui/peas-ui-plugin-manager.c
+++ b/libpeasui/peas-ui-plugin-manager.c
@@ -39,7 +39,7 @@
* @short_description: Management GUI for plugins.
*
* The #PeasUIPluginManager is a widget that can be used to manage plugins,
- * i.e. activate or deactivate them, and see some pieces of information.
+ * i.e. load or unload them, and see some pieces of information.
*
* <inlinegraphic fileref="peas-ui-plugin-manager.png" format="PNG" />
*
@@ -361,7 +361,7 @@ plugin_manager_populate_lists (PeasUIPluginManager *pm)
{
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter,
- ACTIVE_COLUMN, peas_plugin_info_is_active (info),
+ ACTIVE_COLUMN, peas_plugin_info_is_loaded (info),
AVAILABLE_COLUMN, peas_plugin_info_is_available (info),
INFO_COLUMN, info,
-1);
@@ -404,14 +404,14 @@ plugin_manager_set_active (PeasUIPluginManager *pm,
if (active)
{
- /* activate the plugin */
- if (!peas_engine_activate_plugin (pm->priv->engine, info))
+ /* load the plugin */
+ if (!peas_engine_load_plugin (pm->priv->engine, info))
res = FALSE;
}
else
{
- /* deactivate the plugin */
- if (!peas_engine_deactivate_plugin (pm->priv->engine, info))
+ /* unload the plugin */
+ if (!peas_engine_unload_plugin (pm->priv->engine, info))
res = FALSE;
}
@@ -574,7 +574,7 @@ create_tree_popup_menu (PeasUIPluginManager *pm)
item = gtk_check_menu_item_new_with_mnemonic (_("A_ctivate"));
gtk_widget_set_sensitive (item, peas_plugin_info_is_available (info));
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
- peas_plugin_info_is_active (info));
+ peas_plugin_info_is_loaded (info));
g_signal_connect (item, "toggled", G_CALLBACK (enable_plugin_menu_cb), pm);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
@@ -860,7 +860,7 @@ plugin_toggled_cb (PeasEngine *engine,
}
gtk_list_store_set (GTK_LIST_STORE (model), &iter, ACTIVE_COLUMN,
- peas_plugin_info_is_active (info), -1);
+ peas_plugin_info_is_loaded (info), -1);
}
static void
@@ -923,10 +923,10 @@ peas_ui_plugin_manager_constructed (GObject *object)
/* populate the treeview */
g_signal_connect_after (pm->priv->engine,
- "activate-plugin",
+ "load-plugin",
G_CALLBACK (plugin_toggled_cb), pm);
g_signal_connect_after (pm->priv->engine,
- "deactivate-plugin",
+ "unload-plugin",
G_CALLBACK (plugin_toggled_cb), pm);
if (peas_engine_get_plugin_list (pm->priv->engine) != NULL)
diff --git a/peas-demo/peas-demo.c b/peas-demo/peas-demo.c
index c0064f3..e5dd801 100644
--- a/peas-demo/peas-demo.c
+++ b/peas-demo/peas-demo.c
@@ -18,7 +18,7 @@ activate_plugin (GtkButton *button,
g_debug ("%s %s", G_STRFUNC, plugin_name);
info = peas_engine_get_plugin_info (engine, plugin_name);
g_return_if_fail (info != NULL);
- peas_engine_activate_plugin (engine, info);
+ peas_engine_load_plugin (engine, info);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]