cpw.rekkanoryo.icqxstatus: 9b4a51d7: Deprecate purple_request_field_list_add(...

rlaager at pidgin.im rlaager at pidgin.im
Sun Nov 16 14:21:03 EST 2008


-----------------------------------------------------------------
Revision: 9b4a51d71523cc54c0697fb13954429569c9449d
Ancestor: b6e77fc455d1a8fb1f2a091c843015a7f157a38e
Author: rlaager at pidgin.im
Date: 2008-11-16T10:10:17
Branch: im.pidgin.cpw.rekkanoryo.icqxstatus
URL: http://d.pidgin.im/viewmtn/revision/info/9b4a51d71523cc54c0697fb13954429569c9449d

Modified files:
        libpurple/request.c libpurple/request.h

ChangeLog: 

Deprecate purple_request_field_list_add() in favor of the new
purple_request_field_list_add_icon() which now works whether or not icons
are being provided.

-------------- next part --------------
============================================================
--- libpurple/request.c	0de4709239063a21296f96ff945b8ddf2233149b
+++ libpurple/request.c	c40ef881a2fd3c66102a312c1b7a5090471279f0
@@ -823,14 +823,7 @@ purple_request_field_list_add(PurpleRequ
 purple_request_field_list_add(PurpleRequestField *field, const char *item,
 							void *data)
 {
-	g_return_if_fail(field != NULL);
-	g_return_if_fail(item  != NULL);
-	g_return_if_fail(data  != NULL);
-	g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST);
-
-	field->u.list.items = g_list_append(field->u.list.items, g_strdup(item));
-
-	g_hash_table_insert(field->u.list.item_data, g_strdup(item), data);
+	purple_request_field_list_add_icon(field, item, NULL, data);
 }
 
 void
@@ -840,12 +833,30 @@ purple_request_field_list_add_icon(Purpl
 	g_return_if_fail(field != NULL);
 	g_return_if_fail(item  != NULL);
 	g_return_if_fail(data  != NULL);
-	g_return_if_fail(icon_path != NULL);
 	g_return_if_fail(field->type == PURPLE_REQUEST_FIELD_LIST);
 
-	field->u.list.items = g_list_append(field->u.list.items, g_strdup(item));
-	field->u.list.icons = g_list_append(field->u.list.icons, g_strdup(icon_path));
+	if (icon_path)
+	{
+		if (field->u.list.icons == NULL)
+		{
+			GList *l;
+			for (l = field->u.list.items ; l != NULL ; l = l->next)
+			{
+				/* Order doesn't matter, because we're just
+				 * filing in blank items.  So, we use
+				 * g_list_prepend() because it's faster. */
+				field->u.list.icons = g_list_prepend(field->u.list.icons, NULL);
+			}
+		}
+		field->u.list.icons = g_list_append(field->u.list.icons, g_strdup(icon_path));
+	}
+	else if (field->u.list.icons)
+	{
+		/* Keep this even with the items list. */
+		field->u.list.icons = g_list_append(field->u.list.icons, NULL);
+	}
 
+	field->u.list.items = g_list_append(field->u.list.items, g_strdup(item));
 	g_hash_table_insert(field->u.list.item_data, g_strdup(item), data);
 }
 
============================================================
--- libpurple/request.h	68aad8c881d4d2be4cec4ce2d52e71dea3bed89b
+++ libpurple/request.h	4f551cffdd23a7f2d038a5d30219ddcb20969e7d
@@ -146,8 +146,8 @@ typedef struct
 		struct
 		{
 			GList *items;
+			GList *icons;
 			GHashTable *item_data;
-			GList *icons;
 			GList *selected;
 			GHashTable *selected_table;
 
@@ -914,6 +914,8 @@ void *purple_request_field_list_get_data
  * @param field The list field.
  * @param item  The list item.
  * @param data  The associated data.
+ *
+ * @deprecated Use purple_request_field_list_add_icon() instead.
  */
 void purple_request_field_list_add(PurpleRequestField *field,
 								 const char *item, void *data);
@@ -990,9 +992,12 @@ GList *purple_request_field_list_get_ite
 /**
  * Returns a list of icons in a list field.
  *
+ * The icons will correspond with the items, in order.
+ *
  * @param field The field.
  *
- * @constreturn The list of icons.
+ * @constreturn The list of icons or @c NULL (i.e. the empty GList) if no
+ *              items have icons.
  */
 GList *purple_request_field_list_get_icons(const PurpleRequestField *field);
 


More information about the Commits mailing list