/soc/2013/ankitkv/gobjectification: cefe6df8c6c6: Made PurplePlu...

Ankit Vani a at nevitus.org
Mon Jul 15 10:15:42 EDT 2013


Changeset: cefe6df8c6c6b06db2c85b971d2f96fb0d5d0a46
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-15 19:43 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/cefe6df8c6c6

Description:

Made PurplePlugin a GBoxed

diffstat:

 libpurple/connection.c |  14 +++++++-------
 libpurple/plugin.c     |  23 +++++++++++++++++++++++
 libpurple/plugin.h     |  10 ++++++++++
 3 files changed, 40 insertions(+), 7 deletions(-)

diffs (96 lines):

diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -614,8 +614,8 @@ purple_connection_set_property(GObject *
 
 	switch (param_id) {
 		case PROP_PRPL:
-#warning TODO: change get_pointer to get_object when prpl is a GObject
-			priv->prpl = g_value_get_pointer(value);
+#warning TODO: change get_boxed to get_object when prpl is a GObject
+			priv->prpl = g_value_get_boxed(value);
 			break;
 		case PROP_FLAGS:
 			purple_connection_set_flags(gc, g_value_get_flags(value));
@@ -648,8 +648,8 @@ purple_connection_get_property(GObject *
 
 	switch (param_id) {
 		case PROP_PRPL:
-#warning TODO: change set_pointer to set_object when prpl is a GObject
-			g_value_set_pointer(value, purple_connection_get_prpl(gc));
+#warning TODO: change set_static_boxed to set_object when prpl is a GObject
+			g_value_set_static_boxed(value, purple_connection_get_prpl(gc));
 			break;
 		case PROP_FLAGS:
 			g_value_set_flags(value, purple_connection_get_flags(gc));
@@ -796,10 +796,10 @@ static void purple_connection_class_init
 	obj_class->get_property = purple_connection_get_property;
 	obj_class->set_property = purple_connection_set_property;
 
-#warning TODO: change spec_pointer to spec_object when prpl is a GObject
+#warning TODO: change spec_boxed to spec_object when prpl is a GObject
 	g_object_class_install_property(obj_class, PROP_PRPL,
-			g_param_spec_pointer(PROP_PRPL_S, _("Protocol plugin"),
-				_("The prpl that is using the connection."),
+			g_param_spec_boxed(PROP_PRPL_S, _("Protocol plugin"),
+				_("The prpl that is using the connection."), PURPLE_TYPE_PLUGIN,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
 
diff --git a/libpurple/plugin.c b/libpurple/plugin.c
--- a/libpurple/plugin.c
+++ b/libpurple/plugin.c
@@ -1612,3 +1612,26 @@ purple_plugin_action_free(PurplePluginAc
 	g_free(action->label);
 	g_free(action);
 }
+
+static PurplePlugin *
+purple_plugin_copy(PurplePlugin *plugin)
+{
+	PurplePlugin *plugin_copy = g_new(PurplePlugin, 1);
+	*plugin_copy = *plugin;
+
+	return plugin_copy;
+}
+
+GType
+purple_plugin_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PurplePlugin",
+				(GBoxedCopyFunc)purple_plugin_copy,
+				(GBoxedFreeFunc)g_free);
+	}
+
+	return type;
+}
diff --git a/libpurple/plugin.h b/libpurple/plugin.h
--- a/libpurple/plugin.h
+++ b/libpurple/plugin.h
@@ -33,6 +33,9 @@
 #include <gmodule.h>
 #include "signals.h"
 
+/** Returns the GType for the PurplePlugin boxed structure */
+#define PURPLE_TYPE_PLUGIN  (purple_plugin_get_type())
+
 /** @copydoc _PurplePlugin */
 typedef struct _PurplePlugin           PurplePlugin;
 /** @copydoc _PurplePluginInfo */
@@ -246,6 +249,13 @@ G_BEGIN_DECLS
 /*@{*/
 
 /**
+ * Returns the GType for the PurplePlugin boxed structure.
+ * TODO Boxing of PurplePlugin is a temporary solution to having a GType for
+ *      plugins. This should rather be a GObject instead of a GBoxed.
+ */
+GType purple_plugin_get_type(void);
+
+/**
  * Creates a new plugin structure.
  *
  * @param native Whether or not the plugin is native.



More information about the Commits mailing list