/soc/2013/ankitkv/gobjectification: 8d86658a3b68: Added 'plugin'...

Ankit Vani a at nevitus.org
Wed Jul 31 12:37:06 EDT 2013


Changeset: 8d86658a3b68ab8f5afb0b069272e2b940ed61a9
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-31 22:03 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/8d86658a3b68

Description:

Added 'plugin' field to PurplePluginAction. Added purple_plugin_info_get_actions().

diffstat:

 libpurple/plugins.c |  18 ++++++++++++++----
 libpurple/plugins.h |  24 +++++++++++++++---------
 2 files changed, 29 insertions(+), 13 deletions(-)

diffs (115 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -223,8 +223,18 @@ purple_plugin_info_get_type(void)
 	return type;
 }
 
+GList *
+purple_plugin_info_get_actions(PurplePluginInfo *plugin_info)
+{
+	PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(plugin_info);
+
+	g_return_val_if_fail(priv != NULL, NULL);
+
+	return priv->actions;
+}
+
 /**************************************************************************
- * PluginAction API
+ * Plugin actions API
  **************************************************************************/
 static void
 purple_plugin_action_free(PurplePluginAction *action)
@@ -232,6 +242,7 @@ purple_plugin_action_free(PurplePluginAc
 	g_return_if_fail(action != NULL);
 
 	g_free(action->label);
+	g_object_unref(action->plugin);
 	g_free(action);
 }
 
@@ -246,6 +257,7 @@ purple_plugin_action_copy(PurplePluginAc
 
 	action_copy->label    = g_strdup(action->label);
 	action_copy->callback = action->callback;
+	action_copy->plugin   = g_object_ref(action->plugin);
 
 	return action_copy;
 }
@@ -264,9 +276,6 @@ purple_plugin_action_get_type(void)
 	return type;
 }
 
-/**************************************************************************
- * Actions API
- **************************************************************************/
 void
 purple_plugin_actions_add(GPluginPlugin *plugin, const char* label,
                           PurplePluginActionCallback callback)
@@ -285,6 +294,7 @@ purple_plugin_actions_add(GPluginPlugin 
 
 	action->label    = g_strdup(label);
 	action->callback = callback;
+	action->plugin   = g_object_ref(plugin);
 
 	priv->actions = g_list_append(priv->actions, action);
 
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -45,7 +45,7 @@ typedef struct _PurplePluginInfoClass Pu
 /** @copydoc _PurplePluginAction */
 typedef struct _PurplePluginAction PurplePluginAction;
 
-typedef void (*PurplePluginActionCallback)(GPluginPlugin *);
+typedef void (*PurplePluginActionCallback)(PurplePluginAction *);
 
 #include "pluginpref.h"
 
@@ -79,6 +79,7 @@ struct _PurplePluginInfoClass {
 struct _PurplePluginAction {
 	char *label;
 	PurplePluginActionCallback callback;
+	GPluginPlugin *plugin;
 };
 
 G_BEGIN_DECLS
@@ -131,10 +132,22 @@ gboolean purple_plugin_is_loaded(const G
  */
 GType purple_plugin_info_get_type(void);
 
+/**
+ * Returns a list of actions that a plugin can perform.
+ *
+ * @param plugin_info The plugin info to get the actions from.
+ *
+ * @return A list of #PurplePluginAction instances corresponding to the actions
+ *         a plugin can perform.
+ *
+ * @see purple_plugin_actions_add()
+ */
+GList *purple_plugin_info_get_actions(PurplePluginInfo *plugin_info);
+
 /*@}*/
 
 /**************************************************************************/
-/** @name PluginAction API                                                */
+/** @name Plugin actions API                                              */
 /**************************************************************************/
 /*@{*/
 
@@ -143,13 +156,6 @@ GType purple_plugin_info_get_type(void);
  */
 GType purple_plugin_action_get_type(void);
 
-/*@}*/
-
-/**************************************************************************/
-/** @name Actions API                                                     */
-/**************************************************************************/
-/*@{*/
-
 /**
  * Adds a new action to a plugin.
  *



More information about the Commits mailing list