/soc/2013/ankitkv/gobjectification: e75794a5a7f0: Added [purple,...

Ankit Vani a at nevitus.org
Sun Aug 4 15:17:29 EDT 2013


Changeset: e75794a5a7f067c7d567b16342d387d1694c5565
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-05 00:27 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/e75794a5a7f0

Description:

Added [purple,pidgin,finch]_plugin_info_new()

diffstat:

 finch/gntplugin.c   |  20 ++++++++++++++++++++
 finch/gntplugin.h   |  20 ++++++++++++++++++++
 libpurple/plugins.c |  36 +++++++++++++++++++++++++++---------
 libpurple/plugins.h |  33 +++++++++++++++++++++++++++++++++
 pidgin/gtkplugin.c  |  20 ++++++++++++++++++++
 pidgin/gtkplugin.h  |  20 ++++++++++++++++++++
 6 files changed, 140 insertions(+), 9 deletions(-)

diffs (245 lines):

diff --git a/finch/gntplugin.c b/finch/gntplugin.c
--- a/finch/gntplugin.c
+++ b/finch/gntplugin.c
@@ -87,6 +87,26 @@ finch_plugin_info_get_type(void)
 	return type;
 }
 
+FinchPluginInfo *
+finch_plugin_info_new(const char *first_property, ...)
+{
+	GObject *info;
+	va_list var_args;
+
+	/* at least ID is required */
+	if (!first_property)
+		return NULL;
+
+	va_start(var_args, first_property);
+	info = g_object_new_valist(FINCH_TYPE_PLUGIN_INFO, first_property,
+	                           var_args);
+	va_end(var_args);
+
+	g_object_set(info, "ui_requirement", FINCH_UI, NULL);
+
+	return FINCH_PLUGIN_INFO(info);
+}
+
 static void
 free_stringlist(GList *list)
 {
diff --git a/finch/gntplugin.h b/finch/gntplugin.h
--- a/finch/gntplugin.h
+++ b/finch/gntplugin.h
@@ -82,6 +82,26 @@ struct _FinchPluginInfoClass {
  */
 GType finch_plugin_info_get_type(void);
 
+/**
+ * Creates a new #FinchPluginInfo instance to be returned from
+ * gplugin_plugin_query() of a finch plugin, using the provided name/value
+ * pairs.
+ *
+ * See purple_plugin_info_new() for a list of available property names.
+ * Additionally, you can provide the property "finch_preferences_frame",
+ * which should be a callback that returns a GntWidget for the plugin's
+ * preferences (see FinchPluginFrame).
+ *
+ * @param first_property  The first property name
+ * @param ...  The value of the first property, followed optionally by more
+ *             name/value pairs, followed by @c NULL
+ *
+ * @return A new #FinchPluginInfo instance.
+ *
+ * @see purple_plugin_info_new()
+ */
+FinchPluginInfo *finch_plugin_info_new(const char *first_property, ...);
+
 /*@}*/
 
 /**********************************************************************
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -51,7 +51,7 @@ enum
 	PROP_0,
 	PROP_CATEGORY,
 	PROP_UI_REQUIREMENT,
-	PROP_PREF_FRAME_CALLBACK,
+	PROP_PREFERENCES_FRAME,
 	PROP_LAST
 };
 
@@ -286,9 +286,9 @@ purple_plugin_get_dependent_plugins(cons
  * GObject code for PurplePluginInfo
  **************************************************************************/
 /* GObject Property names */
-#define PROP_CATEGORY_S             "category"
-#define PROP_UI_REQUIREMENT_S       "ui-requirement"
-#define PROP_PREF_FRAME_CALLBACK_S  "preferences-callback"
+#define PROP_CATEGORY_S           "category"
+#define PROP_UI_REQUIREMENT_S     "ui_requirement"
+#define PROP_PREFERENCES_FRAME_S  "preferences_frame"
 
 /* Set method for GObject properties */
 static void
@@ -305,7 +305,7 @@ purple_plugin_info_set_property(GObject 
 		case PROP_UI_REQUIREMENT:
 			priv->ui_requirement = g_strdup(g_value_get_string(value));
 			break;
-		case PROP_PREF_FRAME_CALLBACK:
+		case PROP_PREFERENCES_FRAME:
 			purple_plugin_info_set_pref_frame_callback(info,
 					g_value_get_pointer(value));
 			break;
@@ -326,7 +326,7 @@ purple_plugin_info_get_property(GObject 
 		case PROP_CATEGORY:
 			g_value_set_string(value, purple_plugin_info_get_category(info));
 			break;
-		case PROP_PREF_FRAME_CALLBACK:
+		case PROP_PREFERENCES_FRAME:
 			g_value_set_pointer(value,
 					purple_plugin_info_get_pref_frame_callback(info));
 			break;
@@ -426,10 +426,10 @@ static void purple_plugin_info_class_ini
 		g_param_spec_string(PROP_UI_REQUIREMENT_S,
 		                    "UI Requirement",
 		                    "ID of UI that is required by this plugin", NULL,
-		                    G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+		                    G_PARAM_WRITABLE));
 
-	g_object_class_install_property(obj_class, PROP_PREF_FRAME_CALLBACK,
-		g_param_spec_pointer(PROP_PREF_FRAME_CALLBACK_S,
+	g_object_class_install_property(obj_class, PROP_PREFERENCES_FRAME,
+		g_param_spec_pointer(PROP_PREFERENCES_FRAME_S,
 		                     "Preferences frame callback",
 		                     "The callback that returns the preferences frame",
 		                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
@@ -462,6 +462,24 @@ purple_plugin_info_get_type(void)
 	return type;
 }
 
+PurplePluginInfo *
+purple_plugin_info_new(const char *first_property, ...)
+{
+	GObject *info;
+	va_list var_args;
+
+	/* at least ID is required */
+	if (!first_property)
+		return NULL;
+
+	va_start(var_args, first_property);
+	info = g_object_new_valist(PURPLE_TYPE_PLUGIN_INFO, first_property,
+	                           var_args);
+	va_end(var_args);
+
+	return PURPLE_PLUGIN_INFO(info);
+}
+
 const gchar *
 purple_plugin_info_get_id(const PurplePluginInfo *info)
 {
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -279,6 +279,39 @@ GSList *purple_plugin_get_dependent_plug
 GType purple_plugin_info_get_type(void);
 
 /**
+ * Creates a new #PurplePluginInfo instance to be returned from
+ * gplugin_plugin_query() of a plugin, using the provided name/value pairs.
+ *
+ * All properties except "id" are optional.
+ *
+ * Valid property names are:                                                 \n
+ * "id"                 (string) The ID of the plugin.                       \n
+ * "name"               (string) The name of the plugin.                     \n
+ * "version"            (string) Version of the plugin.                      \n
+ * "category"           (string) Primary category of the plugin.             \n
+ * "summary"            (string) Summary of the plugin.                      \n
+ * "description"        (string) Description of the plugin                   \n
+ * "author"             (string) Author of the plugin                        \n
+ * "website"            (string) Website of the plugin                       \n
+ * "icon"               (string) Path to a plugin's icon                     \n
+ * "license"            (string) The plugin's license                        \n
+ * "abi_version"        (guint32) The required ABI version for the plugin.   \n
+ * "dependencies"       (GSList) List of plugin IDs required by the plugin.  \n
+ * "preferences_frame"  (PurplePluginPrefFrameCallback) Callback that returns
+ *                      a preferences frame for the plugin.
+ *
+ * @param first_property  The first property name
+ * @param ...  The value of the first property, followed optionally by more
+ *             name/value pairs, followed by @c NULL
+ *
+ * @return A new #PurplePluginInfo instance.
+ *
+ * @see PURPLE_PLUGIN_ABI_VERSION
+ * @see @ref plugin-ids
+ */
+PurplePluginInfo *purple_plugin_info_new(const char *first_property, ...);
+
+/**
  * Returns a plugin's ID.
  *
  * @param info The plugin's info instance.
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -89,6 +89,26 @@ pidgin_plugin_info_get_type(void)
 	return type;
 }
 
+PidginPluginInfo *
+pidgin_plugin_info_new(const char *first_property, ...)
+{
+	GObject *info;
+	va_list var_args;
+
+	/* at least ID is required */
+	if (!first_property)
+		return NULL;
+
+	va_start(var_args, first_property);
+	info = g_object_new_valist(PIDGIN_TYPE_PLUGIN_INFO, first_property,
+	                           var_args);
+	va_end(var_args);
+
+	g_object_set(info, "ui_requirement", PIDGIN_UI, NULL);
+
+	return PIDGIN_PLUGIN_INFO(info);
+}
+
 GtkWidget *
 pidgin_plugin_get_config_frame(PurplePlugin *plugin)
 {
diff --git a/pidgin/gtkplugin.h b/pidgin/gtkplugin.h
--- a/pidgin/gtkplugin.h
+++ b/pidgin/gtkplugin.h
@@ -74,6 +74,26 @@ G_BEGIN_DECLS
 GType pidgin_plugin_info_get_type(void);
 
 /**
+ * Creates a new #PidginPluginInfo instance to be returned from
+ * gplugin_plugin_query() of a pidgin plugin, using the provided name/value
+ * pairs.
+ *
+ * See purple_plugin_info_new() for a list of available property names.
+ * Additionally, you can provide the property "pidgin_config_frame",
+ * which should be a callback that returns a GtkWidget for the plugin's
+ * configuration (see PidginPluginConfigFrame).
+ *
+ * @param first_property  The first property name
+ * @param ...  The value of the first property, followed optionally by more
+ *             name/value pairs, followed by @c NULL
+ *
+ * @return A new #PidginPluginInfo instance.
+ *
+ * @see purple_plugin_info_new()
+ */
+PidginPluginInfo *pidgin_plugin_info_new(const char *first_property, ...);
+
+/**
  * Returns the configuration frame widget for a GTK+ plugin, if one
  * exists.
  *



More information about the Commits mailing list