/soc/2013/ankitkv/gobjectification: bb8dbeba5bed: Changed icon s...

Ankit Vani a at nevitus.org
Thu Aug 29 15:29:06 EDT 2013


Changeset: bb8dbeba5bedbfd042d370b9c66d8d1b050ceeb6
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-30 00:48 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/bb8dbeba5bed

Description:

Changed icon spec member of a protocol to a pointer. Use purple_buddy_icon_spec_new() to create an icon spec instance

diffstat:

 libpurple/protocol.h  |  14 +++++++-------
 libpurple/protocols.c |  24 ++++++++++++++----------
 libpurple/protocols.h |  25 +++++++++++++++++++++++++
 pidgin/gtkblist.c     |   2 +-
 pidgin/gtkutils.c     |   2 +-
 5 files changed, 48 insertions(+), 19 deletions(-)

diffs (148 lines):

diff --git a/libpurple/protocol.h b/libpurple/protocol.h
--- a/libpurple/protocol.h
+++ b/libpurple/protocol.h
@@ -75,15 +75,15 @@ struct _PurpleProtocolClass
 	/*< private >*/
 	GObjectClass parent_class;
 
-	const char *id;                 /**< Protocol ID */
-	const char *name;               /**< Translated name of the protocol */
+	const char *id;                  /**< Protocol ID */
+	const char *name;                /**< Translated name of the protocol */
 
-	PurpleProtocolOptions options;  /**< Protocol options */
+	PurpleProtocolOptions options;   /**< Protocol options */
 
-	GList *user_splits;             /**< A GList of PurpleAccountUserSplit */
-	GList *protocol_options;        /**< A GList of PurpleAccountOption */
+	GList *user_splits;              /**< A GList of PurpleAccountUserSplit */
+	GList *protocol_options;         /**< A GList of PurpleAccountOption */
 
-	PurpleBuddyIconSpec icon_spec;  /**< The icon spec. */
+	PurpleBuddyIconSpec *icon_spec;  /**< The icon spec. */
 
 	PurpleWhiteboardPrplOps *whiteboard_protocol_ops;
 
@@ -619,7 +619,7 @@ GList *purple_protocol_get_protocol_opti
  *
  * @return The icon spec of the protocol.
  */
-PurpleBuddyIconSpec purple_protocol_get_icon_spec(const PurpleProtocol *protocol);
+PurpleBuddyIconSpec *purple_protocol_get_icon_spec(const PurpleProtocol *protocol);
 
 /** TODO
  * Returns the whiteboard ops of a protocol.
diff --git a/libpurple/protocols.c b/libpurple/protocols.c
--- a/libpurple/protocols.c
+++ b/libpurple/protocols.c
@@ -648,9 +648,11 @@ purple_protocol_action_free(PurpleProtoc
 /**************************************************************************
  * Protocols API
  **************************************************************************/
+/* TODO make this PurpleProtocolClass's base finalize */
 static void
 purple_protocol_destroy(PurpleProtocol *protocol)
 {
+	PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_GET_CLASS(protocol);
 	GList *accounts, *l;
 
 	accounts = purple_accounts_get_all_active();
@@ -659,27 +661,29 @@ purple_protocol_destroy(PurpleProtocol *
 		if (purple_account_is_disconnected(account))
 			continue;
 
-		if (purple_strequal(purple_protocol_get_id(protocol), purple_account_get_protocol_id(account)))
+		if (purple_strequal(proto_class->id, purple_account_get_protocol_id(account)))
 			purple_account_disconnect(account);
 	}
 
 	g_list_free(accounts);
 
-	while (purple_protocol_get_user_splits(protocol)) {
-		PurpleAccountUserSplit *split = purple_protocol_get_user_splits(protocol)->data;
+	while (proto_class->user_splits) {
+		PurpleAccountUserSplit *split = proto_class->user_splits->data;
 		purple_account_user_split_destroy(split);
-		purple_protocol_get_user_splits(protocol) = g_list_delete_link(purple_protocol_get_user_splits(protocol),
-				purple_protocol_get_user_splits(protocol));
+		proto_class->user_splits = g_list_delete_link(proto_class->user_splits,
+				proto_class->user_splits);
 	}
 
-	while (purple_protocol_get_protocol_options(protocol)) {
-		PurpleAccountOption *option = purple_protocol_get_protocol_options(protocol)->data;
+	while (proto_class->protocol_options) {
+		PurpleAccountOption *option = proto_class->protocol_options->data;
 		purple_account_option_destroy(option);
-		purple_protocol_get_protocol_options(protocol) =
-				g_list_delete_link(purple_protocol_get_protocol_options(protocol),
-				purple_protocol_get_protocol_options(protocol));
+		proto_class->protocol_options =
+				g_list_delete_link(proto_class->protocol_options,
+				proto_class->protocol_options);
 	}
 
+	purple_buddy_icon_spec_destroy(proto_class->icon_spec);
+
 	purple_request_close_with_handle(protocol);
 	purple_notify_close_with_handle(protocol);
 
diff --git a/libpurple/protocols.h b/libpurple/protocols.h
--- a/libpurple/protocols.h
+++ b/libpurple/protocols.h
@@ -369,6 +369,31 @@ void purple_protocol_action_free(PurpleP
  */
 GType purple_buddy_icon_spec_get_type(void);
 
+/** TODO
+ * Creates a new #PurpleBuddyIconSpec instance.
+ *
+ * @param format        A comma-delimited list of image formats or @c NULL if
+ *                      icons are not supported
+ * @param min_width     Minimum width of an icon
+ * @param min_height    Minimum height of an icon
+ * @param max_width     Maximum width of an icon
+ * @param max_height    Maximum height of an icon
+ * @param max_filesize  Maximum file size in bytes
+ * @param scale_rules   How to stretch this icon
+ *
+ * @return  A new buddy icon spec.
+ */
+PurpleBuddyIconSpec *purple_buddy_icon_spec_new(char *format, int min_width,
+		int min_height, int max_width, int max_height, size_t max_filesize,
+		PurpleIconScaleRules scale_rules);
+
+/** TODO needed?
+ * Destroys a #PurpleBuddyIconSpec instance.
+ *
+ * @param icon_spec  The icon spec to destroy.
+ */
+void purple_buddy_icon_spec_destroy(PurpleBuddyIconSpec *icon_spec);
+
 /*@}*/
 
 /**************************************************************************/
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -2769,7 +2769,7 @@ static GdkPixbuf *pidgin_blist_get_buddy
 	scale_height = orig_height = gdk_pixbuf_get_height(buf);
 
 	if (protocol && purple_protocol_get_icon_spec(protocol).scale_rules & PURPLE_ICON_SCALE_DISPLAY)
-		purple_buddy_icon_get_scale_size(&purple_protocol_get_icon_spec(protocol), &scale_width, &scale_height);
+		purple_buddy_icon_get_scale_size(purple_protocol_get_icon_spec(protocol), &scale_width, &scale_height);
 
 	if (scaled || scale_height > 200 || scale_width > 200) {
 		GdkPixbuf *tmpbuf;
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -2273,7 +2273,7 @@ pidgin_convert_buddy_icon(PurpleProtocol
 	int i;
 	gchar *tmp;
 
-	spec = &purple_protocol_get_icon_spec(protocol);
+	spec = purple_protocol_get_icon_spec(protocol);
 	g_return_val_if_fail(spec->format != NULL, NULL);
 
 	format = gdk_pixbuf_get_file_info(path, &orig_width, &orig_height);



More information about the Commits mailing list