/soc/2013/ankitkv/gobjectification: 2d36e433e617: Added properti...

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


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

Description:

Added properties "finch_preferences_frame" to FinchPluginInfo, "pidgin_config_frame" to PidginPluginInfo

diffstat:

 finch/gntplugin.c   |  53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 libpurple/plugins.c |  16 ++--------------
 libpurple/plugins.h |   9 ---------
 pidgin/gtkplugin.c  |  53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 108 insertions(+), 23 deletions(-)

diffs (207 lines):

diff --git a/finch/gntplugin.c b/finch/gntplugin.c
--- a/finch/gntplugin.c
+++ b/finch/gntplugin.c
@@ -50,6 +50,13 @@ typedef struct
 	FinchPluginFrame get_pref_frame;
 } FinchPluginInfoPrivate;
 
+enum
+{
+	PROP_0,
+	PROP_FINCH_PREFERENCES_FRAME,
+	PROP_LAST
+};
+
 static struct
 {
 	GntWidget *tree;
@@ -62,10 +69,56 @@ static GHashTable *confwins;
 
 static GntWidget *process_pref_frame(PurplePluginPrefFrame *frame);
 
+/* Set method for GObject properties */
+static void
+finch_plugin_info_set_property(GObject *obj, guint param_id, const GValue *value,
+		GParamSpec *pspec)
+{
+	FinchPluginInfoPrivate *priv = FINCH_PLUGIN_INFO_GET_PRIVATE(obj);
+
+	switch (param_id) {
+		case PROP_FINCH_PREFERENCES_FRAME:
+			priv->get_pref_frame = g_value_get_pointer(value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
+/* Get method for GObject properties */
+static void
+finch_plugin_info_get_property(GObject *obj, guint param_id, GValue *value,
+		GParamSpec *pspec)
+{
+	FinchPluginInfoPrivate *priv = FINCH_PLUGIN_INFO_GET_PRIVATE(obj);
+
+	switch (param_id) {
+		case PROP_FINCH_PREFERENCES_FRAME:
+			g_value_set_pointer(value, priv->get_pref_frame);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
 /* Class initializer function */
 static void finch_plugin_info_class_init(FinchPluginInfoClass *klass)
 {
+	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+
 	g_type_class_add_private(klass, sizeof(FinchPluginInfoPrivate));
+
+	/* Setup properties */
+	obj_class->get_property = finch_plugin_info_get_property;
+	obj_class->set_property = finch_plugin_info_set_property;
+
+	g_object_class_install_property(obj_class, PROP_FINCH_PREFERENCES_FRAME,
+		g_param_spec_pointer("finch_preferences_frame",
+		                     "Finch preferences frame callback",
+		                     "Callback that returns a GNT preferences frame",
+		                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 GType
diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -306,8 +306,7 @@ purple_plugin_info_set_property(GObject 
 			priv->ui_requirement = g_strdup(g_value_get_string(value));
 			break;
 		case PROP_PREFERENCES_FRAME:
-			purple_plugin_info_set_pref_frame_callback(info,
-					g_value_get_pointer(value));
+			priv->get_pref_frame = g_value_get_pointer(value);
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -432,7 +431,7 @@ static void purple_plugin_info_class_ini
 		g_param_spec_pointer(PROP_PREFERENCES_FRAME_S,
 		                     "Preferences frame callback",
 		                     "The callback that returns the preferences frame",
-		                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+		                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 /**************************************************************************
@@ -633,17 +632,6 @@ purple_plugin_info_get_dependencies(cons
 #endif
 }
 
-void
-purple_plugin_info_set_pref_frame_callback(PurplePluginInfo *info,
-		PurplePluginPrefFrameCallback callback)
-{
-	PurplePluginInfoPrivate *priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
-
-	g_return_if_fail(priv != NULL);
-
-	priv->get_pref_frame = callback;
-}
-
 PurplePluginPrefFrameCallback
 purple_plugin_info_get_pref_frame_callback(const PurplePluginInfo *info)
 {
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -420,15 +420,6 @@ guint32 purple_plugin_info_get_abi_versi
 GSList *purple_plugin_info_get_dependencies(const PurplePluginInfo *info);
 
 /**
- * Sets a callback to be invoked to retrieve the preferences frame for a plugin.
- *
- * @param info The plugin info to set the callback for.
- * @param callback    The callback that returns the preferences frame.
- */
-void purple_plugin_info_set_pref_frame_callback(PurplePluginInfo *info,
-		PurplePluginPrefFrameCallback callback);
-
-/**
  * Returns the callback that retrieves the preferences frame for a plugin.
  *
  * @param info The plugin info to get the callback from.
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -47,6 +47,13 @@ typedef struct
 	PidginPluginConfigFrame get_config_frame;
 } PidginPluginInfoPrivate;
 
+enum
+{
+	PROP_0,
+	PROP_PIDGIN_CONFIG_FRAME,
+	PROP_LAST
+};
+
 static void plugin_toggled_stage_two(PurplePlugin *plug, GtkTreeModel *model,
                                   GtkTreeIter *iter, gboolean unload);
 
@@ -64,10 +71,56 @@ static GtkLabel *plugin_filename = NULL;
 static GtkWidget *pref_button = NULL;
 static GHashTable *plugin_pref_dialogs = NULL;
 
+/* Set method for GObject properties */
+static void
+pidgin_plugin_info_set_property(GObject *obj, guint param_id, const GValue *value,
+		GParamSpec *pspec)
+{
+	PidginPluginInfoPrivate *priv = PIDGIN_PLUGIN_INFO_GET_PRIVATE(obj);
+
+	switch (param_id) {
+		case PROP_PIDGIN_CONFIG_FRAME:
+			priv->get_config_frame = g_value_get_pointer(value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
+/* Get method for GObject properties */
+static void
+pidgin_plugin_info_get_property(GObject *obj, guint param_id, GValue *value,
+		GParamSpec *pspec)
+{
+	PidginPluginInfoPrivate *priv = PIDGIN_PLUGIN_INFO_GET_PRIVATE(obj);
+
+	switch (param_id) {
+		case PROP_PIDGIN_CONFIG_FRAME:
+			g_value_set_pointer(value, priv->get_config_frame);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
 /* Class initializer function */
 static void pidgin_plugin_info_class_init(PidginPluginInfoClass *klass)
 {
+	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+
 	g_type_class_add_private(klass, sizeof(PidginPluginInfoPrivate));
+
+	/* Setup properties */
+	obj_class->get_property = pidgin_plugin_info_get_property;
+	obj_class->set_property = pidgin_plugin_info_set_property;
+
+	g_object_class_install_property(obj_class, PROP_PIDGIN_CONFIG_FRAME,
+		g_param_spec_pointer("pidgin_config_frame",
+		                     "Pidgin configuration frame callback",
+		                     "Callback that returns a GTK configuration frame",
+		                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 GType



More information about the Commits mailing list