changeset 23466:5a02912e0bac

more gobject fixed
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Sun, 22 Jun 2008 03:07:07 +0000
parents d60c3d1c6966
children 655a37bc0eb0
files libpurple/core.c libpurple/sound-loader.c libpurple/sound-theme.c libpurple/theme-loader.c libpurple/theme-manager.c libpurple/theme.c
diffstat 6 files changed, 33 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/core.c	Sat Jun 21 23:42:57 2008 +0000
+++ b/libpurple/core.c	Sun Jun 22 03:07:07 2008 +0000
@@ -149,7 +149,7 @@
 	/* Accounts use status, buddy icons and connection signals, so
 	 * initialize these before accounts
 	 */
-	purple_theme_manager_init(g_object_new(PURPLE_TYPE_SOUND_THEME_LOADER, NULL), NULL);
+	purple_theme_manager_init(g_object_new(PURPLE_TYPE_SOUND_THEME_LOADER, "type", "sound", NULL), NULL);
 	purple_status_init();
 	purple_buddy_icons_init();
 	purple_connections_init();
--- a/libpurple/sound-loader.c	Sat Jun 21 23:42:57 2008 +0000
+++ b/libpurple/sound-loader.c	Sun Jun 22 03:07:07 2008 +0000
@@ -29,9 +29,6 @@
 /******************************************************************************
  * Globals
  *****************************************************************************/
-
-static PurpleThemeLoaderClass *parent_class = NULL;
-
 /*****************************************************************************
  * Sound Theme Builder                                                      
  *****************************************************************************/
@@ -126,7 +123,7 @@
       NULL,    /* instance_init */
       NULL,   /* value table */
     };
-    type = g_type_register_static (G_TYPE_OBJECT,
+    type = g_type_register_static (PURPLE_TYPE_THEME_LOADER,
                                    "PurpleSoundThemeLoader",
                                    &info, 0);
   }
--- a/libpurple/sound-theme.c	Sat Jun 21 23:42:57 2008 +0000
+++ b/libpurple/sound-theme.c	Sun Jun 22 03:07:07 2008 +0000
@@ -54,9 +54,10 @@
 			gpointer klass)
 {
 	PurpleSoundThemePrivate *priv;
-	GObject *obj = (GObject *)instance;
 
-	priv = PURPLE_SOUND_THEME_GET_PRIVATE(obj);
+	(PURPLE_SOUND_THEME(instance))->priv = g_new0(PurpleSoundThemePrivate, 1);
+
+	priv = PURPLE_SOUND_THEME_GET_PRIVATE(instance);
 
 	priv->sound_files = g_hash_table_new_full (g_str_hash,
 						   g_str_equal,
--- a/libpurple/theme-loader.c	Sat Jun 21 23:42:57 2008 +0000
+++ b/libpurple/theme-loader.c	Sun Jun 22 03:07:07 2008 +0000
@@ -85,6 +85,13 @@
 }
 
 static void
+purple_theme_loader_init(GTypeInstance *instance,
+			gpointer klass)
+{
+	(PURPLE_THEME_LOADER(instance))->priv = g_new0(PurpleThemeLoaderPrivate, 1);
+}
+
+static void
 purple_theme_loader_finalize(GObject *obj)
 {
 	PurpleThemeLoader *loader = PURPLE_THEME_LOADER(obj);	
@@ -130,11 +137,11 @@
       NULL,   /* class_data */
       sizeof (PurpleThemeLoader),
       0,      /* n_preallocs */
-      NULL,    /* instance_init */
+      purple_theme_loader_init,    /* instance_init */
       NULL,   /* value table */
     };
     type = g_type_register_static (G_TYPE_OBJECT,
-                                   "PurpleThemeLoaderType",
+                                   "PurpleThemeLoader",
                                    &info, G_TYPE_FLAG_ABSTRACT);
   }
   return type;
--- a/libpurple/theme-manager.c	Sat Jun 21 23:42:57 2008 +0000
+++ b/libpurple/theme-manager.c	Sun Jun 22 03:07:07 2008 +0000
@@ -65,9 +65,9 @@
 static gchar *
 purple_theme_manager_make_key(const gchar *name, const gchar *type)
 {
-	g_return_val_if_fail(name, NULL);	
+	g_return_val_if_fail(name, NULL);
 	g_return_val_if_fail(type, NULL);		
-	return g_strconcat(type, '/', name, NULL);
+	return g_strconcat(type, "/", name, NULL);
 }
 
 /* returns TRUE if theme is of type "user_data" */ 
@@ -76,7 +76,7 @@
                   gpointer value,
                   gchar *user_data)
 {
-	return g_str_has_prefix (key, g_strconcat(user_data, '/', NULL));
+	return g_str_has_prefix (key, g_strconcat(user_data, "/", NULL));
 }
 
 static gboolean
@@ -244,7 +244,7 @@
 	g_return_if_fail(key);
 	
 	/* if something is already there do nothing */
-	if (! g_hash_table_lookup (theme_table, key)) 
+	if (g_hash_table_lookup (theme_table, key) == NULL) 
 		g_hash_table_insert(theme_table, key, theme);
 	
 	g_free(key);	
--- a/libpurple/theme.c	Sat Jun 21 23:42:57 2008 +0000
+++ b/libpurple/theme.c	Sun Jun 22 03:07:07 2008 +0000
@@ -49,12 +49,6 @@
 /******************************************************************************
  * Enums
  *****************************************************************************/
-#define PROP_NAME_S "name"
-#define PROP_DESCRIPION_S "description"
-#define PROP_AUTHOR_S "author"
-#define PROP_TYPE_S "type"
-#define PROP_DIR_S "dir"
-#define PROP_IMAGE_S "image"
 
 enum {
 	PROP_ZERO = 0,
@@ -66,7 +60,6 @@
 	PROP_IMAGE
 };
 
-
 /******************************************************************************
  * GObject Stuff                                                              *
  *****************************************************************************/
@@ -134,6 +127,13 @@
 }
 
 static void
+purple_theme_init(GTypeInstance *instance,
+			gpointer klass)
+{
+	(PURPLE_THEME(instance))->priv = g_new0(PurpleThemePrivate, 1);
+}
+
+static void
 purple_theme_finalize(GObject *obj)
 {
 	PurpleTheme *theme = PURPLE_THEME(obj);	
@@ -162,37 +162,37 @@
 	obj_class->finalize = purple_theme_finalize;
 	
 	/* NAME */
-	pspec = g_param_spec_string(PROP_NAME_S, "Name",
+	pspec = g_param_spec_string("name", "Name",
 				    "The name of the theme",
 				    NULL,
 				    G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 	g_object_class_install_property(obj_class, PROP_NAME, pspec);
 	/* DESCRIPION */
-	pspec = g_param_spec_string(PROP_DESCRIPION_S, "Description",
+	pspec = g_param_spec_string("description", "Description",
 				    "The description of the theme",
 				    NULL,
 				    G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 	g_object_class_install_property(obj_class, PROP_DESCRIPION, pspec);
 	/* AUTHOR */
-	pspec = g_param_spec_string(PROP_AUTHOR_S, "Author",
+	pspec = g_param_spec_string("author", "Author",
 				    "The author of the theme",
 				    NULL,
 				    G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 	g_object_class_install_property(obj_class, PROP_AUTHOR, pspec);
 	/* TYPE STRING (read only) */
-	pspec = g_param_spec_string(PROP_TYPE_S, "Type",
+	pspec = g_param_spec_string("type", "Type",
 				    "The string represtenting the type of the theme",
 				    NULL,
-				    G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY);
+				    G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 	g_object_class_install_property(obj_class, PROP_TYPE, pspec);
 	/* DIRECTORY */
-	pspec = g_param_spec_string(PROP_DIR_S, "Directory",
+	pspec = g_param_spec_string("directory", "Directory",
 				    "The directory that contains the theme and all its files",
 				    NULL,
 				    G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
 	g_object_class_install_property(obj_class, PROP_DIR, pspec);
 	/* PREVIEW IMAGE */
-	pspec = g_param_spec_pointer(PROP_IMAGE_S, "Image",
+	pspec = g_param_spec_pointer("image", "Image",
 				    "A preview image of the theme",
 				    G_PARAM_READWRITE);
 	g_object_class_install_property(obj_class, PROP_IMAGE, pspec);
@@ -213,7 +213,7 @@
       NULL,   /* class_data */
       sizeof (PurpleTheme),
       0,      /* n_preallocs */
-      NULL,    /* instance_init */
+      purple_theme_init,    /* instance_init */
       NULL,   /* value table */
     };
     type = g_type_register_static (G_TYPE_OBJECT,