pidgin: bc21e641: Disable the 'send to' menu in converatio...

sadrul at pidgin.im sadrul at pidgin.im
Sat Apr 26 21:50:38 EDT 2008


-----------------------------------------------------------------
Revision: bc21e6410a9d5d30b855410ca24b85bb0ad02f23
Ancestor: 74190d6fbb138e095f84e71b0e0513240531437c
Author: sadrul at pidgin.im
Date: 2008-04-26T17:05:16
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/bc21e6410a9d5d30b855410ca24b85bb0ad02f23

Modified files:
        pidgin/gtkconv.c

ChangeLog: 

Disable the 'send to' menu in converation windows if there's only one
item in the menu. Also, if the same buddy is present multiple times in
the buddylist, show her only once in the 'send to' menu.

-------------- next part --------------
============================================================
--- pidgin/gtkconv.c	951c63c29cd65b0386d5fa5d10117e0b8f927afb
+++ pidgin/gtkconv.c	5b7bdf7430f0a1d18dd3bbf070ea376408e893f9
@@ -3640,6 +3640,20 @@ create_sendto_item(GtkWidget *menu, GtkS
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
 }
 
+static gboolean
+compare_buddy_presence(PurplePresence *p1, PurplePresence *p2)
+{
+	/* This is necessary because multiple PurpleBuddy's don't share the same
+	 * PurplePresence anymore.
+	 */
+	PurpleBuddy *b1 = purple_presence_get_buddy(p1);
+	PurpleBuddy *b2 = purple_presence_get_buddy(p2);
+	if (purple_buddy_get_account(b1) == purple_buddy_get_account(b2) &&
+			strcmp(purple_buddy_get_name(b1), purple_buddy_get_name(b2)) == 0)
+		return FALSE;
+	return TRUE;
+}
+
 static void
 generate_send_to_items(PidginWindow *win)
 {
@@ -3674,8 +3688,7 @@ generate_send_to_items(PidginWindow *win
 
 		if (buds == NULL)
 		{
-			/* The user isn't on the buddy list. */
-			create_sendto_item(menu, sg, &group, NULL, gtkconv->active_conv->account, gtkconv->active_conv->name);
+			/* The user isn't on the buddy list. So we don't create any sendto menu. */
 		}
 		else
 		{
@@ -3699,20 +3712,22 @@ generate_send_to_items(PidginWindow *win
 					{
 						/* Use the PurplePresence to get unique buddies. */
 						PurplePresence *presence = purple_buddy_get_presence(buddy);
-						if (!g_list_find(list, presence))
+						if (!g_list_find_custom(list, presence, (GCompareFunc)compare_buddy_presence))
 							list = g_list_prepend(list, presence);
 					}
 				}
 			}
 
-			/* Loop over the list backwards so we get the items in the right order,
-			 * since we did a g_list_prepend() earlier. */
-			for (iter = g_list_last(list); iter != NULL; iter = iter->prev)
-			{
-				PurplePresence *pre = iter->data;
-				PurpleBuddy *buddy = purple_presence_get_buddy(pre);
-				create_sendto_item(menu, sg, &group, buddy,
+			/* Create the sendto menu only if it has more than one item to show */
+			if (list && list->next) {
+				/* Loop over the list backwards so we get the items in the right order,
+				 * since we did a g_list_prepend() earlier. */
+				for (iter = g_list_last(list); iter != NULL; iter = iter->prev) {
+					PurplePresence *pre = iter->data;
+					PurpleBuddy *buddy = purple_presence_get_buddy(pre);
+					create_sendto_item(menu, sg, &group, buddy,
 							purple_buddy_get_account(buddy), purple_buddy_get_name(buddy));
+				}
 			}
 			g_list_free(list);
 			g_slist_free(buds);


More information about the Commits mailing list