soc.2008.themes: 02cf374d: Fixed some things needed for proper gobf...
ffdragon at soc.pidgin.im
ffdragon at soc.pidgin.im
Mon Jun 16 15:50:59 EDT 2008
-----------------------------------------------------------------
Revision: 02cf374dc9a8652fab64d8ccc2a51d309b7cf102
Ancestor: 383422f1fb5de68d77c6509a220d103faf6b6b1c
Author: ffdragon at soc.pidgin.im
Date: 2008-06-16T19:48:56
Branch: im.pidgin.soc.2008.themes
URL: http://d.pidgin.im/viewmtn/revision/info/02cf374dc9a8652fab64d8ccc2a51d309b7cf102
Modified files:
libpurple/sound-loader.c libpurple/sound-theme.c
libpurple/sound-theme.h libpurple/theme-loader.c
libpurple/theme-loader.h libpurple/theme-manager.c
libpurple/theme-manager.h libpurple/theme.c
ChangeLog:
Fixed some things needed for proper gobfication (init/finalize/etc)
-------------- next part --------------
============================================================
--- libpurple/sound-loader.c 001c8020db062cd7282c3d4f3f066862ac74c911
+++ libpurple/sound-loader.c 7e5730acf1bb24edeed304d9b6c1ff49a4d1d9be
@@ -25,6 +25,12 @@
#include "util.h"
#include "xmlnode.h"
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+
+static PurpleThemeLoaderClass *parent_class = NULL;
+
/*****************************************************************************
* Sound Theme Builder
*****************************************************************************/
@@ -68,7 +74,7 @@ purple_sound_loader_build(const gchar *d
g_return_val_if_fail(root_node != NULL, NULL);
/* Parse the tree */
- theme = purple_sound_theme_new();
+ theme = g_object_new(PURPLE_TYPE_SOUND_THEME, "type", "sound", NULL);
purple_theme_set_name(theme->parent, xmlnode_get_attrib(root_node, THEME_NAME));
purple_theme_set_author(theme->parent, xmlnode_get_attrib(root_node, THEME_AUTHOR));
@@ -103,9 +109,10 @@ purple_sound_theme_loader_class_init (Pu
static void
purple_sound_theme_loader_class_init (PurpleSoundThemeLoaderClass *klass)
{
- PurpleSoundThemeLoaderClass *loader_class = PURPLE_SOUND_THEME_LOADER_CLASS(klass);
+ parent_class = g_type_class_peek_parent (klass);
- loader_class->parent_class._purple_theme_loader_build = purple_sound_loader_build;
+ /* TODO: fix warning */
+ parent_class->purple_theme_loader_build = purple_sound_loader_build;
}
============================================================
--- libpurple/sound-theme.c 1dce694e72ae487b87caa0353a00a877edffba58
+++ libpurple/sound-theme.c 5576ef51c07bcee3d538640f5261142f75498e60
@@ -39,6 +39,8 @@ typedef struct {
* Globals
*****************************************************************************/
+static GObjectClass *parent_class = NULL;
+
/******************************************************************************
* Enums
*****************************************************************************/
@@ -47,6 +49,21 @@ typedef struct {
* GObject Stuff
*****************************************************************************/
+static void
+purple_sound_theme_init(GTypeInstance *instance,
+ gpointer klass)
+{
+ PurpleSoundThemePrivate *priv;
+ GObject *obj = (GObject *)instance;
+
+ priv = PURPLE_SOUND_THEME_GET_PRIVATE(obj);
+
+ priv->sound_files = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_free);
+}
+
static void
purple_sound_theme_finalize (GObject *obj)
{
@@ -55,6 +72,8 @@ purple_sound_theme_finalize (GObject *ob
priv = PURPLE_SOUND_THEME_GET_PRIVATE(obj);
g_hash_table_destroy(priv->sound_files);
+
+ parent_class->finalize (obj);
}
static void
@@ -62,6 +81,8 @@ purple_sound_theme_class_init (PurpleSou
{
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+ parent_class = g_type_class_peek_parent (klass);
+
obj_class->finalize = purple_sound_theme_finalize;
}
@@ -79,7 +100,7 @@ purple_sound_theme_get_type (void)
NULL, /* class_data */
sizeof (PurpleSoundTheme),
0, /* n_preallocs */
- NULL, /* instance_init */
+ purple_sound_theme_init, /* instance_init */
NULL, /* value table */
};
type = g_type_register_static (G_TYPE_OBJECT,
@@ -94,23 +115,6 @@ purple_sound_theme_get_type (void)
* Public API functions
*****************************************************************************/
-PurpleSoundTheme *
-purple_sound_theme_new()
-{
- PurpleSoundTheme *theme;
- PurpleSoundThemePrivate *priv;
-
- theme = g_object_new(PURPLE_TYPE_SOUND_THEME, NULL);
- priv = PURPLE_SOUND_THEME_GET_PRIVATE(theme);
-
- priv->sound_files = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- g_free);
-
- return theme;
-}
-
gchar *
purple_sound_theme_get_file(PurpleSoundTheme *theme,
const gchar *event)
============================================================
--- libpurple/sound-theme.h 4a0256e9bcc84c62ea58b8095d660c3af631e2b6
+++ libpurple/sound-theme.h 7af14da6d4d31f7e639e4df3cf5013e65f0c62d4
@@ -71,13 +71,6 @@ GType purple_sound_theme_get_type(void);
GType purple_sound_theme_get_type(void);
/**
- * Creates a new purple sound theme
- *
- * @returns a new purple sound theme object
- */
-PurpleSoundTheme *purple_sound_theme_new(void);
-
-/**
* Returns a copy of the filename for the sound event
*
* @param event the purple sound event to look up
============================================================
--- libpurple/theme-loader.c 70d56aa850953d60464d2bf616da9d6bf2ed7586
+++ libpurple/theme-loader.c 8621db57b1e87458ca01a6d354acc40a1f2c0301
@@ -26,7 +26,7 @@
#define PURPLE_THEME_LOADER_GET_PRIVATE(PurpleThemeLoader) \
((PurpleThemeLoaderPrivate *) ((PurpleThemeLoader)->priv))
-
+void purple_theme_loader_set_type_string(PurpleThemeLoader *loader, const gchar *type);
/******************************************************************************
* Structs
*****************************************************************************/
@@ -38,6 +38,8 @@ typedef struct {
* Globals
*****************************************************************************/
+static GObjectClass *parent_class = NULL;
+
/******************************************************************************
* Enums
*****************************************************************************/
@@ -68,16 +70,43 @@ static void
}
static void
+purple_theme_loader_set_property(GObject *obj, guint param_id, const GValue *value,
+ GParamSpec *psec)
+{
+ PurpleThemeLoader *loader = PURPLE_THEME_LOADER(obj);
+
+ switch(param_id) {
+ case PROP_TYPE:
+ purple_theme_loader_set_type_string(loader, g_value_get_string(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, psec);
+ break;
+ }
+}
+
+static void
+purple_theme_loader_finalize(GObject *obj)
+{
+ PurpleThemeLoader *loader = PURPLE_THEME_LOADER(obj);
+ PurpleThemeLoaderPrivate *priv = PURPLE_THEME_LOADER_GET_PRIVATE(loader);
+
+ g_free(priv->type);
+
+ parent_class->finalize (obj);
+}
+
+static void
purple_theme_loader_class_init (PurpleThemeLoaderClass *klass)
{
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
GParamSpec *pspec;
- /* 2.4
- * g_type_class_add_private(klass, sizeof(PurpleThemePrivate)); */
-
+ parent_class = g_type_class_peek_parent (klass);
obj_class->get_property = purple_theme_loader_get_property;
+ obj_class->set_property = purple_theme_loader_set_property;
+ obj_class->finalize = purple_theme_loader_finalize;
/* TYPE STRING (read only) */
pspec = g_param_spec_string(PROP_TYPE_S, "Type",
@@ -129,8 +158,23 @@ purple_theme_loader_get_type_string (Pur
return priv->type;
}
+/* < private > */
+void
+purple_theme_loader_set_type_string(PurpleThemeLoader *loader, const gchar *type)
+{
+ PurpleThemeLoaderPrivate *priv;
+
+ g_return_if_fail(PURPLE_IS_THEME_LOADER(loader));
+
+ priv = PURPLE_THEME_LOADER_GET_PRIVATE(loader);
+
+ g_free(priv->type);
+ priv->type = g_strdup (type);
+}
+
PurpleTheme *
purple_theme_loader_build (PurpleThemeLoader *loader, const gchar *dir)
{
- return PURPLE_THEME_LOADER_GET_CLASS(loader)->_purple_theme_loader_build(dir);
+ /* TODO: fix warning */
+ return PURPLE_THEME_LOADER_GET_CLASS(loader)->purple_theme_loader_build(dir);
}
============================================================
--- libpurple/theme-loader.h 256c2766b8404dd8fb6fb7e8156d45fbeb33ff1c
+++ libpurple/theme-loader.h ac79cc3c2466a8aeae322766a53980ee7f342b95
@@ -56,7 +56,7 @@ struct _PurpleThemeLoaderClass
struct _PurpleThemeLoaderClass
{
GObjectClass parent_class;
- PurpleTheme *(*_purple_theme_loader_build)(const gchar);
+ PurpleTheme *(*purple_theme_loader_build)(const gchar);
};
/**************************************************************************/
============================================================
--- libpurple/theme-manager.c 093b3322f71821d8d2cf488f37b44d7d994e86ab
+++ libpurple/theme-manager.c 55e9d6811c6031315cc94536cee6e0c6ee95044e
@@ -30,29 +30,10 @@ static GHashTable *theme_table;
static GHashTable *theme_table;
-
/*****************************************************************************
* GObject Stuff
****************************************************************************/
-static void
-purple_theme_manager_finalize (GObject *obj)
-{
- g_hash_table_destroy(theme_table);
-}
-
-static void
-purple_theme_manager_class_init (PurpleThemeManagerClass *klass)
-{
- /*PurpleThemeManagerClass *theme_manager_class = PURPLE_THEME_MANAGER_CLASS(klass);*/
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
- /* 2.4 g_type_class_add_private(klass, sizeof(PurpleThemeManagerPrivate));*/
-
- obj_class->finalize = purple_theme_manager_finalize;
-
-}
-
GType
purple_theme_manager_get_type (void)
{
@@ -62,7 +43,7 @@ purple_theme_manager_get_type (void)
sizeof (PurpleThemeManagerClass),
NULL, /* base_init */
NULL, /* base_finalize */
- (GClassInitFunc)purple_theme_manager_class_init, /* class_init */
+ NULL, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (PurpleThemeManager),
@@ -116,7 +97,7 @@ static void
}
static void
-purple_theme_manager_build(const gchar *root)
+purple_theme_manager_build_dir(const gchar *root)
{
GDir *rdir;
@@ -166,10 +147,12 @@ purple_theme_manager_init (PurpleThemeLo
va_list args;
PurpleThemeLoader *loader;
+ g_return_if_fail(theme_table != NULL);
+
theme_table = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- g_object_unref);
+ g_str_equal,
+ g_free,
+ g_object_unref);
va_start(args, loader1);
for (loader = loader1; loader != NULL; loader = va_arg(args, PurpleThemeLoader *))
@@ -177,10 +160,28 @@ purple_theme_manager_init (PurpleThemeLo
va_end(args);
/* TODO: add themes properly */
- purple_theme_manager_build(NULL);
+ purple_theme_manager_build_dir(NULL);
}
+void
+purple_theme_manager_refresh()
+{
+ g_hash_table_foreach_remove (theme_table,
+ (GHRFunc) purple_theme_manager_is_theme,
+ NULL);
+
+ /* TODO: this also needs to be fixed the same as new */
+ purple_theme_manager_build_dir(NULL);
+}
+
+void
+purple_theme_manager_uninit ()
+{
+ g_hash_table_destroy(theme_table);
+}
+
+
void
purple_theme_manager_register_type(PurpleThemeLoader *loader)
{
@@ -269,18 +270,6 @@ void
}
void
-purple_theme_manager_refresh()
-{
- g_hash_table_foreach_remove (theme_table,
- (GHRFunc) purple_theme_manager_is_theme,
- NULL);
-
- /* TODO: this also needs to be fixed the same as new */
- purple_theme_manager_build(NULL);
-
-}
-
-void
purple_theme_manager_for_each_theme(PTFunc func)
{
g_return_if_fail(func);
============================================================
--- libpurple/theme-manager.h e19134f3c98b17287b34ae900579640260d12162
+++ libpurple/theme-manager.h 846f834899f35dfb017af9abc2c153dc5ee97dd0
@@ -63,14 +63,24 @@ GType purple_theme_manager_get_type (voi
GType purple_theme_manager_get_type (void);
/**
- * Creates a new ThemeManager object
- * @param the loaders to initalize the manager with and use for first build
- *
- * @returns a new ThemeManager object
+ * Initalizes the manager then add the loaders to the theme manager
+ * and builds with the given loaders
+ * @param the loaders to build with
*/
void purple_theme_manager_init (PurpleThemeLoader *loader1, ...);
/**
+ * Rebuilds all the themes in the theme manager
+ * (removes all current themes but keeps the added loaders)
+ */
+void purple_theme_manager_refresh(void);
+
+/**
+ * Uninitalizes the manager then frees all the themes an loaders it is responsible for
+ */
+void purple_theme_manager_uninit (void);
+
+/**
* Finds the PurpleTheme object stored by the theme manager
*
* @param name the name of the PurpleTheme
@@ -106,11 +116,6 @@ void purple_theme_manager_unregister_typ
void purple_theme_manager_unregister_type(PurpleThemeLoader *loader);
/**
- * Rebuilds all the themes in the theme manaer
- */
-void purple_theme_manager_refresh(void);
-
-/**
* Calles the given function on each purple theme
*
* @param func the PTFunc to be applied to each theme
============================================================
--- libpurple/theme.c ff59f141f11d9b74d4309487fbafe06839318779
+++ libpurple/theme.c 06760718fb8528591a89d785b5b4572301b2c3b4
@@ -26,6 +26,7 @@
#define PURPLE_THEME_GET_PRIVATE(PurpleTheme) \
((PurpleThemePrivate *) ((PurpleTheme)->priv))
+void purple_theme_set_type_string(PurpleTheme *theme, const gchar *type);
/******************************************************************************
* Structs
@@ -43,6 +44,8 @@ typedef struct {
* Globals
*****************************************************************************/
+static GObjectClass *parent_class = NULL;
+
/******************************************************************************
* Enums
*****************************************************************************/
@@ -115,6 +118,9 @@ purple_theme_set_property(GObject *obj,
case PROP_AUTHOR:
purple_theme_set_author(theme, g_value_get_string(value));
break;
+ case PROP_TYPE:
+ purple_theme_set_type_string(theme, g_value_get_string(value));
+ break;
case PROP_DIR:
purple_theme_set_dir(theme, g_value_get_string(value));
break;
@@ -128,16 +134,32 @@ static void
}
static void
+purple_theme_finalize(GObject *obj)
+{
+ PurpleTheme *theme = PURPLE_THEME(obj);
+ PurpleThemePrivate *priv = PURPLE_THEME_GET_PRIVATE(theme);
+
+ g_free(priv->name);
+ g_free(priv->description);
+ g_free(priv->author);
+ g_free(priv->type);
+ g_free(priv->dir);
+ purple_imgstore_unref(priv->img);
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
purple_theme_class_init (PurpleThemeClass *klass)
{
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
GParamSpec *pspec;
- /* 2.4
- * g_type_class_add_private(klass, sizeof(PurpleThemePrivate)); */
+ parent_class = g_type_class_peek_parent(klass);
obj_class->get_property = purple_theme_get_property;
obj_class->set_property = purple_theme_set_property;
+ obj_class->finalize = purple_theme_finalize;
/* NAME */
pspec = g_param_spec_string(PROP_NAME_S, "Name",
@@ -289,6 +311,20 @@ purple_theme_get_type_string(PurpleTheme
return priv->type;
}
+/* < private > */
+void
+purple_theme_set_type_string(PurpleTheme *theme, const gchar *type)
+{
+ PurpleThemePrivate *priv;
+
+ g_return_if_fail(PURPLE_IS_THEME(theme));
+
+ priv = PURPLE_THEME_GET_PRIVATE(theme);
+
+ g_free(priv->type);
+ priv->type = g_strdup (type);
+}
+
gchar *
purple_theme_get_dir(PurpleTheme *theme)
{
More information about the Commits
mailing list