libpurple/theme.c

branch
soc.2013.gobjectification
changeset 35078
9e2aff0b8476
parent 35065
2fe1b3f20c3c
child 35085
abab0adfa0ec
--- a/libpurple/theme.c	Wed Nov 20 04:48:53 2013 +0530
+++ b/libpurple/theme.c	Wed Nov 20 05:15:00 2013 +0530
@@ -21,6 +21,7 @@
  */
 
 #include "internal.h"
+#include "glibcompat.h"
 #include "theme.h"
 #include "util.h"
 
@@ -43,12 +44,6 @@
 } PurpleThemePrivate;
 
 /******************************************************************************
- * Globals
- *****************************************************************************/
-
-static GObjectClass *parent_class = NULL;
-
-/******************************************************************************
  * Enums
  *****************************************************************************/
 
@@ -59,10 +54,18 @@
 	PROP_AUTHOR,
 	PROP_TYPE,
 	PROP_DIR,
-	PROP_IMAGE
+	PROP_IMAGE,
+	PROP_LAST
 };
 
 /******************************************************************************
+ * Globals
+ *****************************************************************************/
+
+static GObjectClass *parent_class = NULL;
+static GParamSpec *properties[PROP_LAST];
+
+/******************************************************************************
  * GObject Stuff
  *****************************************************************************/
 
@@ -148,7 +151,6 @@
 purple_theme_class_init(PurpleThemeClass *klass)
 {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-	GParamSpec *pspec;
 
 	parent_class = g_type_class_peek_parent(klass);
 
@@ -159,47 +161,53 @@
 	obj_class->finalize = purple_theme_finalize;
 
 	/* NAME */
-	pspec = g_param_spec_string("name", "Name",
+	properties[PROP_NAME] = g_param_spec_string("name", "Name",
 			"The name of the theme",
 			NULL,
 			G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
-	g_object_class_install_property(obj_class, PROP_NAME, pspec);
+	g_object_class_install_property(obj_class, PROP_NAME,
+			properties[PROP_NAME]);
 
 	/* DESCRIPTION */
-	pspec = g_param_spec_string("description", "Description",
+	properties[PROP_DESCRIPTION] = g_param_spec_string("description",
+			"Description",
 			"The description of the theme",
 			NULL,
 			G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
-	g_object_class_install_property(obj_class, PROP_DESCRIPTION, pspec);
+	g_object_class_install_property(obj_class, PROP_DESCRIPTION,
+			properties[PROP_DESCRIPTION]);
 
 	/* AUTHOR */
-	pspec = g_param_spec_string("author", "Author",
+	properties[PROP_AUTHOR] = g_param_spec_string("author", "Author",
 			"The author of the theme",
 			NULL,
 			G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
-	g_object_class_install_property(obj_class, PROP_AUTHOR, pspec);
+	g_object_class_install_property(obj_class, PROP_AUTHOR,
+			properties[PROP_AUTHOR]);
 
 	/* TYPE STRING (read only) */
-	pspec = g_param_spec_string("type", "Type",
+	properties[PROP_TYPE] = g_param_spec_string("type", "Type",
 			"The string representing the type of the theme",
 			NULL,
 			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
 			G_PARAM_STATIC_STRINGS);
-	g_object_class_install_property(obj_class, PROP_TYPE, pspec);
+	g_object_class_install_property(obj_class, PROP_TYPE,
+			properties[PROP_TYPE]);
 
 	/* DIRECTORY */
-	pspec = g_param_spec_string("directory", "Directory",
+	properties[PROP_DIR] = g_param_spec_string("directory", "Directory",
 			"The directory that contains the theme and all its files",
 			NULL,
 			G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
-	g_object_class_install_property(obj_class, PROP_DIR, pspec);
+	g_object_class_install_property(obj_class, PROP_DIR, properties[PROP_DIR]);
 
 	/* PREVIEW IMAGE */
-	pspec = g_param_spec_string("image", "Image",
+	properties[PROP_IMAGE] = g_param_spec_string("image", "Image",
 			"A preview image of the theme",
 			NULL,
 			G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-	g_object_class_install_property(obj_class, PROP_IMAGE, pspec);
+	g_object_class_install_property(obj_class, PROP_IMAGE,
+			properties[PROP_IMAGE]);
 }
 
 
@@ -269,7 +277,7 @@
 	g_free(priv->name);
 	priv->name = theme_clean_text(name);
 
-	g_object_notify(G_OBJECT(theme), "name");
+	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_NAME]);
 }
 
 const gchar *
@@ -295,7 +303,7 @@
 	g_free(priv->description);
 	priv->description = theme_clean_text(description);
 
-	g_object_notify(G_OBJECT(theme), "description");
+	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_DESCRIPTION]);
 }
 
 const gchar *
@@ -321,7 +329,7 @@
 	g_free(priv->author);
 	priv->author = theme_clean_text(author);
 
-	g_object_notify(G_OBJECT(theme), "author");
+	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_AUTHOR]);
 }
 
 const gchar *
@@ -348,7 +356,7 @@
 	g_free(priv->type);
 	priv->type = g_strdup(type);
 
-	g_object_notify(G_OBJECT(theme), "type");
+	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_TYPE]);
 }
 
 const gchar *
@@ -374,7 +382,7 @@
 	g_free(priv->dir);
 	priv->dir = g_strdup(dir);
 
-	g_object_notify(G_OBJECT(theme), "directory");
+	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_DIR]);
 }
 
 const gchar *
@@ -412,5 +420,5 @@
 	g_free(priv->img);
 	priv->img = g_strdup(img);
 
-	g_object_notify(G_OBJECT(theme), "image");
+	g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_IMAGE]);
 }

mercurial