/soc/2013/ankitkv/gobjectification: 46c2822b7c58: Added the "ext...
Ankit Vani
a at nevitus.org
Sun Jan 12 09:55:45 EST 2014
Changeset: 46c2822b7c582bc301749779c1a14542cd3c8a97
Author: Ankit Vani <a at nevitus.org>
Date: 2014-01-12 19:28 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/46c2822b7c58
Description:
Added the "extra-cb" property for plugins.
Plugins can use this callback to return a string with extra information about itself.
diffstat:
ChangeLog.API | 1 +
libpurple/plugins.c | 28 ++++++++++++++++++++++++++++
libpurple/plugins.h | 23 +++++++++++++++++++----
pidgin/gtkdialogs.c | 12 +++++++++++-
4 files changed, 59 insertions(+), 5 deletions(-)
diffs (193 lines):
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -90,6 +90,7 @@ version 3.0.0 (??/??/????):
* purple_plugin_info_get_category
* purple_plugin_info_get_dependencies
* purple_plugin_info_get_error
+ * purple_plugin_info_get_extra_cb
* purple_plugin_info_get_flags
* purple_plugin_info_get_icon
* purple_plugin_info_get_license_id
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -45,6 +45,9 @@ struct _PurplePluginInfoPrivate {
/** Callback that returns a list of actions the plugin can perform */
PurplePluginActionsCb actions_cb;
+ /** Callback that returns extra information about a plugin */
+ PurplePluginExtraCb extra_cb;
+
/** Callback that returns a preferences frame for a plugin */
PurplePluginPrefFrameCb pref_frame_cb;
@@ -61,6 +64,7 @@ enum
PROP_0,
PROP_UI_REQUIREMENT,
PROP_ACTIONS_CB,
+ PROP_EXTRA_CB,
PROP_PREF_FRAME_CB,
PROP_PREF_REQUEST_CB,
PROP_FLAGS,
@@ -378,6 +382,9 @@ purple_plugin_info_set_property(GObject
case PROP_ACTIONS_CB:
priv->actions_cb = g_value_get_pointer(value);
break;
+ case PROP_EXTRA_CB:
+ priv->extra_cb = g_value_get_pointer(value);
+ break;
case PROP_PREF_FRAME_CB:
priv->pref_frame_cb = g_value_get_pointer(value);
break;
@@ -405,6 +412,10 @@ purple_plugin_info_get_property(GObject
g_value_set_pointer(value,
purple_plugin_info_get_actions_cb(info));
break;
+ case PROP_EXTRA_CB:
+ g_value_set_pointer(value,
+ purple_plugin_info_get_extra_cb(info));
+ break;
case PROP_PREF_FRAME_CB:
g_value_set_pointer(value,
purple_plugin_info_get_pref_frame_cb(info));
@@ -502,6 +513,13 @@ static void purple_plugin_info_class_ini
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property(obj_class, PROP_EXTRA_CB,
+ g_param_spec_pointer("extra-cb",
+ "Extra info callback",
+ "Callback that returns extra info about the plugin",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property(obj_class, PROP_PREF_FRAME_CB,
g_param_spec_pointer("pref-frame-cb",
"Preferences frame callback",
@@ -763,6 +781,16 @@ purple_plugin_info_get_actions_cb(const
return priv->actions_cb;
}
+PurplePluginExtraCb
+purple_plugin_info_get_extra_cb(const PurplePluginInfo *info)
+{
+ PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+
+ g_return_val_if_fail(priv != NULL, NULL);
+
+ return priv->extra_cb;
+}
+
PurplePluginPrefFrameCb
purple_plugin_info_get_pref_frame_cb(const PurplePluginInfo *info)
{
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -97,6 +97,7 @@ typedef struct _PurplePluginAction Purpl
typedef void (*PurplePluginActionCb)(PurplePluginAction *);
typedef GList *(*PurplePluginActionsCb)(PurplePlugin *);
+typedef gchar *(*PurplePluginExtraCb)(PurplePlugin *);
typedef PurplePluginPrefFrame *(*PurplePluginPrefFrameCb)(PurplePlugin *);
typedef gpointer (*PurplePluginPrefRequestCb)(PurplePlugin *);
@@ -524,10 +525,13 @@ GType purple_plugin_info_get_type(void);
* "abi-version" (guint32) The ABI version required by the plugin. \n
* "actions-cb" (PurplePluginActionsCb) Callback that returns a list of
* actions the plugin can perform. \n
+ * "extra-cb" (PurplePluginExtraCb) Callback that returns a newly
+ * allocated string denoting extra information
+ * about a plugin. \n
* "pref-frame-cb" (PurplePluginPrefFrameCb) Callback that returns a
- * preferences frame for the plugin.
+ * preferences frame for the plugin. \n
* "pref-request-cb" (PurplePluginPrefRequestCb) Callback that returns a
- * preferences request handle for the plugin.
+ * preferences request handle for the plugin. \n
* "flags" (PurplePluginInfoFlags) The flags for a plugin. \n
*
* @param first_property The first property name
@@ -676,13 +680,24 @@ guint32 purple_plugin_info_get_abi_versi
*
* @param info The plugin info to get the callback from.
*
- * @constreturn The callback that returns a list of #PurplePluginAction
- * instances corresponding to the actions a plugin can perform.
+ * @return The callback that returns a list of #PurplePluginAction
+ * instances corresponding to the actions a plugin can perform.
*/
PurplePluginActionsCb
purple_plugin_info_get_actions_cb(const PurplePluginInfo *info);
/**
+ * Returns a callback that gives extra information about a plugin. You must
+ * free the string returned by this callback.
+ *
+ * @param info The plugin info to get extra information from.
+ *
+ * @return The callback that returns extra information about a plugin.
+ */
+PurplePluginExtraCb
+purple_plugin_info_get_extra_cb(const PurplePluginInfo *info);
+
+/**
* Returns the callback that retrieves the preferences frame for a plugin, set
* via the "pref-frame-cb" property of the plugin info.
*
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -835,8 +835,9 @@ void pidgin_dialogs_plugins_info(void)
GList *plugins, *l = NULL;
PurplePlugin *plugin = NULL;
PurplePluginInfo *info;
+ PurplePluginExtraCb extra_cb;
char *title = g_strdup_printf(_("%s Plugin Information"), PIDGIN_NAME);
- char *pname = NULL, *authors, *pauthors;
+ char *pname = NULL, *authors, *pauthors, *pextra;
const char *pver, *plicense, *pwebsite, *pid;
gboolean ploaded, ploadable;
const char * const *authorlist;
@@ -851,6 +852,7 @@ void pidgin_dialogs_plugins_info(void)
for(l = plugins; l; l = l->next) {
plugin = PURPLE_PLUGIN(l->data);
info = purple_plugin_get_info(plugin);
+ extra_cb = purple_plugin_info_get_extra_cb(info);
pname = g_markup_escape_text(purple_plugin_info_get_name(info), -1);
authorlist = purple_plugin_info_get_authors(info);
@@ -872,6 +874,11 @@ void pidgin_dialogs_plugins_info(void)
ploadable = !purple_plugin_info_get_error(info);
ploaded = purple_plugin_is_loaded(plugin);
+ if (ploaded && extra_cb)
+ pextra = extra_cb(plugin);
+ else
+ pextra = NULL;
+
g_string_append_printf(str,
"<dt>%s</dt><dd>"
"<b>%s:</b> %s<br/>"
@@ -879,6 +886,7 @@ void pidgin_dialogs_plugins_info(void)
"<b>License:</b> %s<br/>"
"<b>Website:</b> %s<br/>"
"<b>ID String:</b> %s<br/>"
+ "<b>Extra:</b> %s<br/>"
"<b>Loadable:</b> %s<br/>"
"<b>Loaded:</b> %s"
"</dd><br/>",
@@ -889,10 +897,12 @@ void pidgin_dialogs_plugins_info(void)
plicense ? plicense : "",
pwebsite ? pwebsite : "",
pid,
+ pextra ? pextra : "",
ploadable ? "Yes" : "<span style=\"color: #FF0000;\"><b>No</b></span>",
ploaded ? "Yes" : "No");
g_free(pname);
+ g_free(pextra);
g_free(pauthors);
g_free(authors);
}
More information about the Commits
mailing list