Mercurial > pidgin
changeset 32157:4d92a431d0a1
Use GObject's instance private data for all the theme GObjects.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 17 Sep 2011 04:51:57 +0000 |
parents | d478be29444a |
children | 17c27a527004 |
files | libpurple/sound-theme.c libpurple/sound-theme.h libpurple/theme-loader.c libpurple/theme-loader.h libpurple/theme.c libpurple/theme.h pidgin/gtkblist-theme.c pidgin/gtkblist-theme.h pidgin/gtkicon-theme.c pidgin/gtkicon-theme.h |
diffstat | 10 files changed, 18 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/sound-theme.c Fri Sep 16 06:10:04 2011 +0000 +++ b/libpurple/sound-theme.c Sat Sep 17 04:51:57 2011 +0000 @@ -24,7 +24,7 @@ #include "sound-theme.h" #define PURPLE_SOUND_THEME_GET_PRIVATE(Gobject) \ - ((PurpleSoundThemePrivate *) ((PURPLE_SOUND_THEME(Gobject))->priv)) + (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PURPLE_TYPE_SOUND_THEME, PurpleSoundThemePrivate)) /****************************************************************************** * Structs @@ -55,8 +55,6 @@ { PurpleSoundThemePrivate *priv; - (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, @@ -82,6 +80,8 @@ parent_class = g_type_class_peek_parent(klass); + g_type_class_add_private(klass, sizeof(PurpleSoundThemePrivate)); + obj_class->finalize = purple_sound_theme_finalize; }
--- a/libpurple/sound-theme.h Fri Sep 16 06:10:04 2011 +0000 +++ b/libpurple/sound-theme.h Sat Sep 17 04:51:57 2011 +0000 @@ -51,7 +51,6 @@ struct _PurpleSoundTheme { PurpleTheme parent; - gpointer priv; }; struct _PurpleSoundThemeClass
--- a/libpurple/theme-loader.c Fri Sep 16 06:10:04 2011 +0000 +++ b/libpurple/theme-loader.c Sat Sep 17 04:51:57 2011 +0000 @@ -24,7 +24,7 @@ #include "theme-loader.h" #define PURPLE_THEME_LOADER_GET_PRIVATE(PurpleThemeLoader) \ - ((PurpleThemeLoaderPrivate *) ((PurpleThemeLoader)->priv)) + (G_TYPE_INSTANCE_GET_PRIVATE((PurpleThemeLoader), PURPLE_TYPE_THEME_LOADER, PurpleThemeLoaderPrivate)) void purple_theme_loader_set_type_string(PurpleThemeLoader *loader, const gchar *type); @@ -86,21 +86,12 @@ } static void -purple_theme_loader_init(GTypeInstance *instance, - gpointer klass) -{ - PurpleThemeLoader *loader = PURPLE_THEME_LOADER(instance); - loader->priv = g_new0(PurpleThemeLoaderPrivate, 1); -} - -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); - g_free(priv); parent_class->finalize(obj); } @@ -113,6 +104,8 @@ parent_class = g_type_class_peek_parent(klass); + g_type_class_add_private(klass, sizeof(PurpleThemeLoaderPrivate)); + 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; @@ -139,7 +132,7 @@ NULL, /* class_data */ sizeof(PurpleThemeLoader), 0, /* n_preallocs */ - purple_theme_loader_init, /* instance_init */ + NULL, /* instance_init */ NULL, /* value table */ }; type = g_type_register_static(G_TYPE_OBJECT,
--- a/libpurple/theme-loader.h Fri Sep 16 06:10:04 2011 +0000 +++ b/libpurple/theme-loader.h Sat Sep 17 04:51:57 2011 +0000 @@ -50,7 +50,6 @@ struct _PurpleThemeLoader { GObject parent; - gpointer priv; }; struct _PurpleThemeLoaderClass
--- a/libpurple/theme.c Fri Sep 16 06:10:04 2011 +0000 +++ b/libpurple/theme.c Sat Sep 17 04:51:57 2011 +0000 @@ -25,7 +25,7 @@ #include "util.h" #define PURPLE_THEME_GET_PRIVATE(PurpleTheme) \ - ((PurpleThemePrivate *) ((PurpleTheme)->priv)) + (G_TYPE_INSTANCE_GET_PRIVATE((PurpleTheme), PURPLE_TYPE_THEME, PurpleThemePrivate)) void purple_theme_set_type_string(PurpleTheme *theme, const gchar *type); @@ -129,14 +129,6 @@ } static void -purple_theme_init(GTypeInstance *instance, - gpointer klass) -{ - PurpleTheme *theme = PURPLE_THEME(instance); - theme->priv = g_new0(PurpleThemePrivate, 1); -} - -static void purple_theme_finalize(GObject *obj) { PurpleTheme *theme = PURPLE_THEME(obj); @@ -160,6 +152,8 @@ parent_class = g_type_class_peek_parent(klass); + g_type_class_add_private(klass, sizeof(PurpleThemePrivate)); + obj_class->get_property = purple_theme_get_property; obj_class->set_property = purple_theme_set_property; obj_class->finalize = purple_theme_finalize; @@ -222,7 +216,7 @@ NULL, /* class_data */ sizeof(PurpleTheme), 0, /* n_preallocs */ - purple_theme_init, /* instance_init */ + NULL, /* instance_init */ NULL, /* value table */ }; type = g_type_register_static (G_TYPE_OBJECT,
--- a/libpurple/theme.h Fri Sep 16 06:10:04 2011 +0000 +++ b/libpurple/theme.h Sat Sep 17 04:51:57 2011 +0000 @@ -49,7 +49,6 @@ struct _PurpleTheme { GObject parent; - gpointer priv; }; struct _PurpleThemeClass
--- a/pidgin/gtkblist-theme.c Fri Sep 16 06:10:04 2011 +0000 +++ b/pidgin/gtkblist-theme.c Sat Sep 17 04:51:57 2011 +0000 @@ -24,7 +24,7 @@ #include "gtkblist-theme.h" #define PIDGIN_BLIST_THEME_GET_PRIVATE(Gobject) \ - ((PidginBlistThemePrivate *) ((PIDGIN_BLIST_THEME(Gobject))->priv)) + (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_BLIST_THEME, PidginBlistThemePrivate)) /****************************************************************************** * Structs @@ -189,13 +189,6 @@ *****************************************************************************/ static void -pidgin_blist_theme_init(GTypeInstance *instance, - gpointer klass) -{ - (PIDGIN_BLIST_THEME(instance))->priv = g_new0(PidginBlistThemePrivate, 1); -} - -static void pidgin_blist_theme_get_property(GObject *obj, guint param_id, GValue *value, GParamSpec *psec) { @@ -349,8 +342,6 @@ pidgin_theme_font_free(priv->message_nick_said); pidgin_theme_font_free(priv->status); - g_free(priv); - parent_class->finalize (obj); } @@ -362,6 +353,8 @@ parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private(klass, sizeof(PidginBlistThemePrivate)); + obj_class->get_property = pidgin_blist_theme_get_property; obj_class->set_property = pidgin_blist_theme_set_property; obj_class->finalize = pidgin_blist_theme_finalize; @@ -484,7 +477,7 @@ NULL, /* class_data */ sizeof(PidginBlistTheme), 0, /* n_preallocs */ - pidgin_blist_theme_init, /* instance_init */ + NULL, /* instance_init */ NULL, /* value table */ }; type = g_type_register_static (PURPLE_TYPE_THEME,
--- a/pidgin/gtkblist-theme.h Fri Sep 16 06:10:04 2011 +0000 +++ b/pidgin/gtkblist-theme.h Sat Sep 17 04:51:57 2011 +0000 @@ -51,7 +51,6 @@ struct _PidginBlistTheme { PurpleTheme parent; - gpointer priv; }; struct _PidginBlistThemeClass
--- a/pidgin/gtkicon-theme.c Fri Sep 16 06:10:04 2011 +0000 +++ b/pidgin/gtkicon-theme.c Sat Sep 17 04:51:57 2011 +0000 @@ -26,7 +26,7 @@ #include <gtk/gtk.h> #define PIDGIN_ICON_THEME_GET_PRIVATE(Gobject) \ - ((PidginIconThemePrivate *) ((PIDGIN_ICON_THEME(Gobject))->priv)) + (G_TYPE_INSTANCE_GET_PRIVATE((Gobject), PIDGIN_TYPE_ICON_THEME, PidginIconThemePrivate)) /****************************************************************************** * Structs @@ -53,8 +53,6 @@ { PidginIconThemePrivate *priv; - (PIDGIN_ICON_THEME(instance))->priv = g_new0(PidginIconThemePrivate, 1); - priv = PIDGIN_ICON_THEME_GET_PRIVATE(instance); priv->icon_files = g_hash_table_new_full(g_str_hash, @@ -69,7 +67,6 @@ priv = PIDGIN_ICON_THEME_GET_PRIVATE(obj); g_hash_table_destroy(priv->icon_files); - g_free(priv); parent_class->finalize(obj); } @@ -82,6 +79,8 @@ parent_class = g_type_class_peek_parent(klass); obj_class->finalize = pidgin_icon_theme_finalize; + + g_type_class_add_private(klass, sizeof(PidginIconThemePrivate)); } GType