changeset 20163:1971e13bb5f6

Merge the plugin pack's showoffline plugin's functionality to pidgin proper as suggested by Sean.
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 19 Sep 2007 01:00:04 +0000
parents 181bcc9a2888
children 7d9391b94b1c
files pidgin/gtkblist.c
diffstat 1 files changed, 36 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkblist.c	Tue Sep 18 23:33:31 2007 +0000
+++ b/pidgin/gtkblist.c	Wed Sep 19 01:00:04 2007 +0000
@@ -662,6 +662,26 @@
 	}
 }
 
+static void gtk_blist_menu_showoffline_cb(GtkWidget *w, PurpleBlistNode *node)
+{
+    if (PURPLE_BLIST_NODE_IS_BUDDY(node))
+    {
+        purple_blist_node_set_bool(node, "show_offline",
+                                 !purple_blist_node_get_bool(node, "show_offline"));
+    }
+    else if (PURPLE_BLIST_NODE_IS_CONTACT(node))
+    {
+        PurpleBlistNode *bnode;
+        gboolean setting = !purple_blist_node_get_bool(node, "show_offline");
+
+        purple_blist_node_set_bool(node, "show_offline", setting);
+        for (bnode = node->child; bnode != NULL; bnode = bnode->next) {
+            purple_blist_node_set_bool(bnode, "show_offline", setting);
+        }
+    }
+	pidgin_blist_update(purple_get_blist(), node);
+}
+
 static void gtk_blist_show_systemlog_cb()
 {
 	pidgin_syslog_show();
@@ -1288,13 +1308,17 @@
 pidgin_blist_make_buddy_menu(GtkWidget *menu, PurpleBuddy *buddy, gboolean sub) {
 	PurplePluginProtocolInfo *prpl_info;
 	PurpleContact *contact;
+	PurpleBlistNode *node;
 	gboolean contact_expanded = FALSE;
+	gboolean show_offline = FALSE;
 
 	g_return_if_fail(menu);
 	g_return_if_fail(buddy);
 
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl);
 
+	node = (PurpleBlistNode*)buddy;
+
 	contact = purple_buddy_get_contact(buddy);
 	if (contact) {
 		contact_expanded = ((struct _pidgin_blist_node *)(((PurpleBlistNode*)contact)->ui_data))->contact_expanded;
@@ -1320,7 +1344,7 @@
 	pidgin_new_item_from_stock(menu, _("Add Buddy _Pounce"), NULL,
 			G_CALLBACK(gtk_blist_menu_bp_cb), buddy, 0, 0, NULL);
 
-	if (((PurpleBlistNode*)buddy)->parent && ((PurpleBlistNode*)buddy)->parent->child->next && 
+	if (node->parent && node->parent->child->next && 
 	      !sub && !contact_expanded) {
 		pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
 				G_CALLBACK(gtk_blist_menu_showlog_cb),
@@ -1330,18 +1354,22 @@
 				G_CALLBACK(gtk_blist_menu_showlog_cb), buddy, 0, 0, NULL);
 	}
 
-
-	pidgin_append_blist_node_proto_menu(menu, buddy->account->gc,
-										  (PurpleBlistNode *)buddy);
-	pidgin_append_blist_node_extended_menu(menu, (PurpleBlistNode *)buddy);
+	if (!(purple_blist_node_get_flags(node) & PURPLE_BLIST_NODE_FLAG_NO_SAVE)) {
+		show_offline = purple_blist_node_get_bool(node, "show_offline");
+		pidgin_new_item_from_stock(menu, show_offline ? _("Hide when offline") : _("Show when offline"),
+				NULL, G_CALLBACK(gtk_blist_menu_showoffline_cb), node, 0, 0, NULL);
+	}
+
+	pidgin_append_blist_node_proto_menu(menu, buddy->account->gc, node);
+	pidgin_append_blist_node_extended_menu(menu, node);
 
 	if (!contact_expanded)
 		pidgin_append_blist_node_move_to_menu(menu, (PurpleBlistNode *)contact);
 
-	if (((PurpleBlistNode*)buddy)->parent && ((PurpleBlistNode*)buddy)->parent->child->next && 
+	if (node->parent && node->parent->child->next && 
               !sub && !contact_expanded) {
 		pidgin_separator(menu);
-		pidgin_append_blist_node_privacy_menu(menu, (PurpleBlistNode *)buddy);
+		pidgin_append_blist_node_privacy_menu(menu, node);
 		pidgin_new_item_from_stock(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
 				G_CALLBACK(gtk_blist_menu_alias_cb),
 				contact, 0, 0, NULL);
@@ -1350,7 +1378,7 @@
 				contact, 0, 0, NULL);
 	} else if (!sub || contact_expanded) {
 		pidgin_separator(menu);
-		pidgin_append_blist_node_privacy_menu(menu, (PurpleBlistNode *)buddy);
+		pidgin_append_blist_node_privacy_menu(menu, node);
 		pidgin_new_item_from_stock(menu, _("_Alias..."), PIDGIN_STOCK_ALIAS,
 				G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL);
 		pidgin_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE,