diff options
author | Ankit Vani <a@nevitus.org> | 2013-11-20 05:15:00 +0530 |
---|---|---|
committer | Ankit Vani <a@nevitus.org> | 2013-11-20 05:15:00 +0530 |
commit | fb945af97bf985cf91432bd0ea1f39a490e04ec8 (patch) | |
tree | 7ac1e287cf3ce6cbcd2d3ded4ff6859aee77663d | |
parent | 666132552c54ef2ce39c7f28d3f8e8a9106bf330 (diff) | |
download | pidgin-fb945af97bf985cf91432bd0ea1f39a490e04ec8.tar.gz |
libpurple: started changing g_object_notify to g_object_notify_by_pspec
-rw-r--r-- | libpurple/circularbuffer.c | 49 | ||||
-rw-r--r-- | libpurple/media/codec.c | 52 | ||||
-rw-r--r-- | libpurple/smiley.c | 18 | ||||
-rw-r--r-- | libpurple/theme-loader.c | 23 | ||||
-rw-r--r-- | libpurple/theme.c | 60 |
5 files changed, 118 insertions, 84 deletions
diff --git a/libpurple/circularbuffer.c b/libpurple/circularbuffer.c index 1a3da1c18c..7584fe9e72 100644 --- a/libpurple/circularbuffer.c +++ b/libpurple/circularbuffer.c @@ -22,6 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #include "internal.h" +#include "glibcompat.h" #include "circularbuffer.h" @@ -72,6 +73,7 @@ enum { * Globals *****************************************************************************/ static GObjectClass *parent_class = NULL; +static GParamSpec *properties[PROP_LAST]; /****************************************************************************** * Circular Buffer Implementation @@ -124,8 +126,8 @@ purple_circular_buffer_real_grow(PurpleCircularBuffer *buffer, gsize len) { obj = G_OBJECT(buffer); g_object_freeze_notify(obj); - g_object_notify(obj, "input"); - g_object_notify(obj, "output"); + g_object_notify_by_pspec(obj, properties[PROP_INPUT]); + g_object_notify_by_pspec(obj, properties[PROP_OUTPUT]); g_object_thaw_notify(obj); } @@ -166,8 +168,8 @@ purple_circular_buffer_real_append(PurpleCircularBuffer *buffer, obj = G_OBJECT(buffer); g_object_freeze_notify(obj); - g_object_notify(obj, "buffer-used"); - g_object_notify(obj, "input"); + g_object_notify_by_pspec(obj, properties[PROP_BUFFER_USED]); + g_object_notify_by_pspec(obj, properties[PROP_INPUT]); g_object_thaw_notify(obj); } @@ -208,8 +210,8 @@ purple_circular_buffer_real_mark_read(PurpleCircularBuffer *buffer, obj = G_OBJECT(buffer); g_object_freeze_notify(obj); - g_object_notify(obj, "buffer-used"); - g_object_notify(obj, "output"); + g_object_notify_by_pspec(obj, properties[PROP_BUFFER_USED]); + g_object_notify_by_pspec(obj, properties[PROP_OUTPUT]); g_object_thaw_notify(obj); return TRUE; @@ -227,7 +229,7 @@ purple_circular_buffer_set_grow_size(PurpleCircularBuffer *buffer, priv->growsize = (grow_size != 0) ? grow_size : DEFAULT_BUF_SIZE; - g_object_notify(G_OBJECT(buffer), "grow-size"); + g_object_notify_by_pspec(G_OBJECT(buffer), properties[PROP_GROW_SIZE]); } static const gchar * @@ -321,28 +323,33 @@ purple_circular_buffer_class_init(PurpleCircularBufferClass *klass) { /* using a ulong for the gsize properties since there is no * g_param_spec_size, and the ulong should always work. --gk 3/21/11 */ - g_object_class_install_property(obj_class, PROP_GROW_SIZE, - g_param_spec_ulong("grow-size", "grow-size", + properties[PROP_GROW_SIZE] = g_param_spec_ulong("grow-size", "grow-size", "The grow size of the buffer", 0, G_MAXSIZE, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(obj_class, PROP_GROW_SIZE, + properties[PROP_GROW_SIZE]); - g_object_class_install_property(obj_class, PROP_BUFFER_USED, - g_param_spec_ulong("buffer-used", "buffer-used", + properties[PROP_BUFFER_USED] = g_param_spec_ulong("buffer-used", + "buffer-used", "The amount of the buffer used", 0, G_MAXSIZE, 0, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property(obj_class, PROP_BUFFER_USED, + properties[PROP_BUFFER_USED]); - g_object_class_install_property(obj_class, PROP_INPUT, - g_param_spec_pointer("input", "input", + properties[PROP_INPUT] = g_param_spec_pointer("input", "input", "The input pointer of the buffer", - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property(obj_class, PROP_INPUT, + properties[PROP_INPUT]); - g_object_class_install_property(obj_class, PROP_OUTPUT, - g_param_spec_pointer("output", "output", + properties[PROP_OUTPUT] = g_param_spec_pointer("output", "output", "The output pointer of the buffer", - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property(obj_class, PROP_OUTPUT, + properties[PROP_OUTPUT]); } /****************************************************************************** @@ -473,8 +480,8 @@ purple_circular_buffer_reset(PurpleCircularBuffer *buffer) { obj = G_OBJECT(buffer); g_object_freeze_notify(obj); - g_object_notify(obj, "input"); - g_object_notify(obj, "output"); + g_object_notify_by_pspec(obj, properties[PROP_INPUT]); + g_object_notify_by_pspec(obj, properties[PROP_OUTPUT]); g_object_thaw_notify(obj); } diff --git a/libpurple/media/codec.c b/libpurple/media/codec.c index bbb1414592..7fda97927e 100644 --- a/libpurple/media/codec.c +++ b/libpurple/media/codec.c @@ -24,6 +24,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "internal.h" +#include "glibcompat.h" #include "codec.h" /** @copydoc _PurpleMediaCodecClass */ @@ -65,8 +67,11 @@ enum { PROP_CLOCK_RATE, PROP_CHANNELS, PROP_OPTIONAL_PARAMS, + PROP_LAST }; +static GParamSpec *properties[PROP_LAST]; + static void purple_media_codec_init(PurpleMediaCodec *info) { @@ -171,49 +176,56 @@ purple_media_codec_class_init(PurpleMediaCodecClass *klass) gobject_class->set_property = purple_media_codec_set_property; gobject_class->get_property = purple_media_codec_get_property; - g_object_class_install_property(gobject_class, PROP_ID, - g_param_spec_uint("id", + properties[PROP_ID] = g_param_spec_uint("id", "ID", "The numeric identifier of the codec.", 0, G_MAXUINT, 0, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_ID, + properties[PROP_ID]); - g_object_class_install_property(gobject_class, PROP_ENCODING_NAME, - g_param_spec_string("encoding-name", + properties[PROP_ENCODING_NAME] = g_param_spec_string("encoding-name", "Encoding Name", "The name of the codec.", NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_ENCODING_NAME, + properties[PROP_ENCODING_NAME]); - g_object_class_install_property(gobject_class, PROP_MEDIA_TYPE, - g_param_spec_flags("media-type", + properties[PROP_MEDIA_TYPE] = g_param_spec_flags("media-type", "Media Type", "Whether this is an audio of video codec.", PURPLE_TYPE_MEDIA_SESSION_TYPE, PURPLE_MEDIA_NONE, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); + G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_MEDIA_TYPE, + properties[PROP_MEDIA_TYPE]); - g_object_class_install_property(gobject_class, PROP_CLOCK_RATE, - g_param_spec_uint("clock-rate", + properties[PROP_CLOCK_RATE] = g_param_spec_uint("clock-rate", "Create Callback", "The function called to create this element.", 0, G_MAXUINT, 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_CLOCK_RATE, + properties[PROP_CLOCK_RATE]); - g_object_class_install_property(gobject_class, PROP_CHANNELS, - g_param_spec_uint("channels", + properties[PROP_CHANNELS] = g_param_spec_uint("channels", "Channels", "The number of channels in this codec.", 0, G_MAXUINT, 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property(gobject_class, PROP_OPTIONAL_PARAMS, - g_param_spec_pointer("optional-params", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_CHANNELS, + properties[PROP_CHANNELS]); + + properties[PROP_OPTIONAL_PARAMS] = g_param_spec_pointer("optional-params", "Optional Params", "A list of optional parameters for the codec.", - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property(gobject_class, PROP_OPTIONAL_PARAMS, + properties[PROP_OPTIONAL_PARAMS]); g_type_class_add_private(klass, sizeof(PurpleMediaCodecPrivate)); } @@ -294,7 +306,7 @@ purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec, priv->optional_params = g_list_append( priv->optional_params, new_param); - g_object_notify(G_OBJECT(codec), "optional-params"); + g_object_notify_by_pspec(G_OBJECT(codec), properties[PROP_OPTIONAL_PARAMS]); } void @@ -314,7 +326,7 @@ purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec, g_list_remove(priv->optional_params, param); g_free(param); - g_object_notify(G_OBJECT(codec), "optional-params"); + g_object_notify_by_pspec(G_OBJECT(codec), properties[PROP_OPTIONAL_PARAMS]); } PurpleKeyValuePair * diff --git a/libpurple/smiley.c b/libpurple/smiley.c index 0414fe918c..f740190350 100644 --- a/libpurple/smiley.c +++ b/libpurple/smiley.c @@ -25,6 +25,7 @@ */ #include "internal.h" +#include "glibcompat.h" #include "dbus-maybe.h" #include "debug.h" #include "imgstore.h" @@ -282,7 +283,8 @@ enum { PROP_0, PROP_SHORTCUT, - PROP_IMGSTORE + PROP_IMGSTORE, + PROP_LAST }; enum @@ -293,6 +295,7 @@ enum static guint signals[SIG_LAST]; static GObjectClass *parent_class; +static GParamSpec *properties[PROP_LAST]; static void purple_smiley_init(GTypeInstance *instance, gpointer klass) @@ -393,7 +396,6 @@ static void purple_smiley_class_init(PurpleSmileyClass *klass) { GObjectClass *gobj_class = G_OBJECT_CLASS(klass); - GParamSpec *pspec; parent_class = g_type_class_peek_parent(klass); @@ -405,17 +407,19 @@ purple_smiley_class_init(PurpleSmileyClass *klass) gobj_class->dispose = purple_smiley_dispose; /* Shortcut */ - pspec = g_param_spec_string("shortcut", "Shortcut", + properties[PROP_SHORTCUT] = g_param_spec_string("shortcut", "Shortcut", "The text-shortcut for the smiley", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property(gobj_class, PROP_SHORTCUT, pspec); + g_object_class_install_property(gobj_class, PROP_SHORTCUT, + properties[PROP_SHORTCUT]); /* Stored Image */ - pspec = g_param_spec_pointer("image", "Stored Image", + properties[PROP_IMGSTORE] = g_param_spec_pointer("image", "Stored Image", "Stored Image. (that'll have to do for now)", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property(gobj_class, PROP_IMGSTORE, pspec); + g_object_class_install_property(gobj_class, PROP_IMGSTORE, + properties[PROP_IMGSTORE]); signals[SIG_DESTROY] = g_signal_new("destroy", G_OBJECT_CLASS_TYPE(klass), @@ -764,7 +768,7 @@ purple_smiley_set_shortcut(PurpleSmiley *smiley, const char *shortcut) g_free(priv->shortcut); priv->shortcut = g_strdup(shortcut); - g_object_notify(G_OBJECT(smiley), "shortcut"); + g_object_notify_by_pspec(G_OBJECT(smiley), properties[PROP_SHORTCUT]); purple_smileys_save(); diff --git a/libpurple/theme-loader.c b/libpurple/theme-loader.c index 40917617e0..b189f53af6 100644 --- a/libpurple/theme-loader.c +++ b/libpurple/theme-loader.c @@ -21,6 +21,7 @@ */ #include "internal.h" +#include "glibcompat.h" #include "theme-loader.h" #define PURPLE_THEME_LOADER_GET_PRIVATE(PurpleThemeLoader) \ @@ -36,21 +37,23 @@ typedef struct { } PurpleThemeLoaderPrivate; /****************************************************************************** - * Globals - *****************************************************************************/ - -static GObjectClass *parent_class = NULL; - -/****************************************************************************** * Enums *****************************************************************************/ enum { PROP_ZERO = 0, PROP_TYPE, + PROP_LAST }; /****************************************************************************** + * Globals + *****************************************************************************/ + +static GObjectClass *parent_class = NULL; +static GParamSpec *properties[PROP_LAST]; + +/****************************************************************************** * GObject Stuff * *****************************************************************************/ @@ -116,7 +119,6 @@ static void purple_theme_loader_class_init(PurpleThemeLoaderClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS(klass); - GParamSpec *pspec; parent_class = g_type_class_peek_parent(klass); @@ -127,12 +129,13 @@ purple_theme_loader_class_init(PurpleThemeLoaderClass *klass) obj_class->finalize = purple_theme_loader_finalize; /* 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]); } GType @@ -186,7 +189,7 @@ purple_theme_loader_set_type_string(PurpleThemeLoader *loader, const gchar *type g_free(priv->type); priv->type = g_strdup(type); - g_object_notify(G_OBJECT(loader), "type"); + g_object_notify_by_pspec(G_OBJECT(loader), properties[PROP_TYPE]); } PurpleTheme * diff --git a/libpurple/theme.c b/libpurple/theme.c index 73b981720f..4e59513c28 100644 --- a/libpurple/theme.c +++ b/libpurple/theme.c @@ -21,6 +21,7 @@ */ #include "internal.h" +#include "glibcompat.h" #include "theme.h" #include "util.h" @@ -43,12 +44,6 @@ typedef struct { } PurpleThemePrivate; /****************************************************************************** - * Globals - *****************************************************************************/ - -static GObjectClass *parent_class = NULL; - -/****************************************************************************** * Enums *****************************************************************************/ @@ -59,10 +54,18 @@ enum { 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 @@ static void 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 @@ purple_theme_class_init(PurpleThemeClass *klass) 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 @@ purple_theme_set_name(PurpleTheme *theme, const gchar *name) 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 @@ purple_theme_set_description(PurpleTheme *theme, const gchar *description) 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 @@ purple_theme_set_author(PurpleTheme *theme, const gchar *author) 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 @@ purple_theme_set_type_string(PurpleTheme *theme, const gchar *type) 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 @@ purple_theme_set_dir(PurpleTheme *theme, const gchar *dir) 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 @@ purple_theme_set_image(PurpleTheme *theme, const gchar *img) 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]); } |