diff options
author | Ankit Vani <a@nevitus.org> | 2013-07-19 13:55:59 +0530 |
---|---|---|
committer | Ankit Vani <a@nevitus.org> | 2013-07-19 13:55:59 +0530 |
commit | ca1d7343289f6cdb5f535b441684fb49eb29af1c (patch) | |
tree | d2d7b44545ea18e598e2d69c367775898bc376a5 | |
parent | 19d762627fc16016912cfbfa89d2a443bfcb4de4 (diff) | |
download | pidgin-ca1d7343289f6cdb5f535b441684fb49eb29af1c.tar.gz |
Started GObjectification of PurpleBuddyIcon.
Removed purple_buddy_icon_ref() and purple_buddy_icon_unref()
-rw-r--r-- | libpurple/buddyicon.c | 39 | ||||
-rw-r--r-- | libpurple/buddyicon.h | 62 |
2 files changed, 41 insertions, 60 deletions
diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c index f91da9eb63..fef853aefb 100644 --- a/libpurple/buddyicon.c +++ b/libpurple/buddyicon.c @@ -33,17 +33,19 @@ #include "imgstore.h" #include "util.h" -/* NOTE: Instances of this struct are allocated without zeroing the memory, so - * NOTE: be sure to update purple_buddy_icon_new() if you add members. */ -struct _PurpleBuddyIcon +#define PURPLE_BUDDY_ICON_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_BUDDY_ICON, PurpleBuddyIconPrivate)) + +/** Private data for buddy icons */ +typedef struct { PurpleAccount *account; /**< The account the user is on. */ PurpleStoredImage *img; /**< The stored image containing the icon data. */ char *username; /**< The username the icon belongs to. */ char *checksum; /**< The protocol checksum. */ - unsigned int ref_count; /**< The buddy icon reference count. */ -}; + +} PurpleBuddyIconPrivate; /** * This is the big grand daddy hash table that contains references to @@ -1131,30 +1133,3 @@ void purple_buddy_icon_get_scale_size(PurpleBuddyIconSpec *spec, int *width, int *width = new_width; *height = new_height; } - -static PurpleBuddyIcon * -purple_buddy_icon_copy(PurpleBuddyIcon *icon) -{ - PurpleBuddyIcon *icon_copy; - - g_return_val_if_fail(icon != NULL, NULL); - - icon_copy = g_new(PurpleBuddyIcon, 1); - *icon_copy = *icon; - - return icon_copy; -} - -GType -purple_buddy_icon_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - type = g_boxed_type_register_static("PurpleBuddyIcon", - (GBoxedCopyFunc)purple_buddy_icon_copy, - (GBoxedFreeFunc)g_free); - } - - return type; -} diff --git a/libpurple/buddyicon.h b/libpurple/buddyicon.h index 5102d150e8..21bccad0b0 100644 --- a/libpurple/buddyicon.h +++ b/libpurple/buddyicon.h @@ -26,14 +26,17 @@ #ifndef _PURPLE_BUDDYICON_H_ #define _PURPLE_BUDDYICON_H_ -#define PURPLE_TYPE_BUDDY_ICON (purple_buddy_icon_get_type()) - -/** An opaque structure representing a buddy icon for a particular user on a - * particular #PurpleAccount. Instances are reference-counted; use - * purple_buddy_icon_ref() and purple_buddy_icon_unref() to take and release - * references. - */ +#define PURPLE_TYPE_BUDDY_ICON (purple_buddy_icon_get_type()) +#define PURPLE_BUDDY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_BUDDY_ICON, PurpleBuddyIcon)) +#define PURPLE_BUDDY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_BUDDY_ICON, PurpleBuddyIconClass)) +#define PURPLE_IS_BUDDY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_BUDDY_ICON)) +#define PURPLE_IS_BUDDY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_BUDDY_ICON)) +#define PURPLE_BUDDY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_BUDDY_ICON, PurpleBuddyIconClass)) + +/** @copydoc _PurpleBuddyIcon */ typedef struct _PurpleBuddyIcon PurpleBuddyIcon; +/** @copydoc _PurpleBuddyIconClass */ +typedef struct _PurpleBuddyIconClass PurpleBuddyIconClass; #include "account.h" #include "buddylist.h" @@ -41,6 +44,29 @@ typedef struct _PurpleBuddyIcon PurpleBuddyIcon; #include "prpl.h" #include "util.h" +/** An object representing a buddy icon for a particular user on a particular + * #PurpleAccount. Use g_object_ref() and g_object_unref() to take and release + * references. + */ +struct _PurpleBuddyIcon +{ + /*< private >*/ + GObject gparent; +}; + +/** + * The base class for all #PurpleBuddyIcon's. + */ +struct _PurpleBuddyIconClass { + /*< private >*/ + GObjectClass parent_class; + + void (*_purple_reserved1)(void); + void (*_purple_reserved2)(void); + void (*_purple_reserved3)(void); + void (*_purple_reserved4)(void); +}; + G_BEGIN_DECLS /**************************************************************************/ @@ -49,9 +75,7 @@ G_BEGIN_DECLS /*@{*/ /** - * Returns the GType for the PurpleBuddyIcon boxed structure. - * TODO Boxing of PurpleBuddyIcon is a temporary solution to having a GType for - * icons. This should rather be a GObject instead of a GBoxed. + * Returns the GType for the PurpleBuddyIcon object. */ GType purple_buddy_icon_get_type(void); @@ -74,24 +98,6 @@ PurpleBuddyIcon *purple_buddy_icon_new(PurpleAccount *account, const char *usern const char *checksum); /** - * Increments the reference count on a buddy icon. - * - * @param icon The buddy icon. - * - * @return @a icon. - */ -PurpleBuddyIcon *purple_buddy_icon_ref(PurpleBuddyIcon *icon); - -/** - * Decrements the reference count on a buddy icon. - * - * If the reference count reaches 0, the icon will be destroyed. - * - * @param icon The buddy icon. - */ -void purple_buddy_icon_unref(PurpleBuddyIcon *icon); - -/** * Updates every instance of this icon. * * @param icon The buddy icon. |