pidgin: bc02373b: Add a 'View log' option in the buddylist...

sadrul at pidgin.im sadrul at pidgin.im
Sun May 4 00:15:43 EDT 2008


-----------------------------------------------------------------
Revision: bc02373b5cfe8a046df6344d7b6833cab1003448
Ancestor: b310905bae44ab31bd5b3497fd091c4310f3d227
Author: sadrul at pidgin.im
Date: 2008-05-04T04:15:11
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/bc02373b5cfe8a046df6344d7b6833cab1003448

Modified files:
        finch/gntblist.c

ChangeLog: 

Add a 'View log' option in the buddylist menu.

-------------- next part --------------
============================================================
--- finch/gntblist.c	90bfc00688cbd11a5ded336714a9f0ba0f5bc587
+++ finch/gntblist.c	aae68a3c1e5fb7c9db0585da66c5aa3a69600f75
@@ -2779,6 +2779,68 @@ static void
 }
 
 static void
+view_log_select_cb(gpointer data, PurpleRequestFields *fields)
+{
+	PurpleAccount *account;
+	const char *name;
+	PurpleBuddy *buddy;
+	PurpleContact *contact;
+
+	account = purple_request_fields_get_account(fields, "account");
+	name = purple_request_fields_get_string(fields,  "screenname");
+
+	buddy = purple_find_buddy(account, name);
+	if (buddy) {
+		contact = purple_buddy_get_contact(buddy);
+	} else {
+		contact = NULL;
+	}
+
+	if (contact) {
+		finch_log_show_contact(contact);
+	} else {
+		finch_log_show(PURPLE_LOG_IM, name, account);
+	}
+}
+
+static void
+view_log_cb(GntMenuItem *item, gpointer n)
+{
+	PurpleRequestFields *fields;
+	PurpleRequestFieldGroup *group;
+	PurpleRequestField *field;
+
+	fields = purple_request_fields_new();
+
+	group = purple_request_field_group_new(NULL);
+	purple_request_fields_add_group(fields, group);
+
+	field = purple_request_field_string_new("screenname", _("Name"), NULL, FALSE);
+	purple_request_field_set_type_hint(field, "screenname-all");
+	purple_request_field_set_required(field, TRUE);
+	purple_request_field_group_add_field(group, field);
+
+	field = purple_request_field_account_new("account", _("Account"), NULL);
+	purple_request_field_set_type_hint(field, "account");
+	purple_request_field_set_visible(field,
+		(purple_accounts_get_all() != NULL &&
+		 purple_accounts_get_all()->next != NULL));
+	purple_request_field_set_required(field, TRUE);
+	purple_request_field_group_add_field(group, field);
+	purple_request_field_account_set_show_all(field, TRUE);
+
+	purple_request_fields(purple_get_blist(), _("View Log"),
+						NULL,
+						_("Please enter the username or alias of the person "
+						  "whose log you would like to view."),
+						fields,
+						_("OK"), G_CALLBACK(view_log_select_cb),
+						_("Cancel"), NULL,
+						NULL, NULL, NULL,
+						NULL);
+}
+
+static void
 menu_add_buddy_cb(GntMenuItem *item, gpointer null)
 {
 	purple_blist_request_add_buddy(NULL, NULL, NULL, NULL);
@@ -2838,6 +2900,11 @@ create_menu(void)
 	gnt_menu_add_item(GNT_MENU(sub), item);
 	gnt_menuitem_set_callback(GNT_MENU_ITEM(item), join_chat_select, NULL);
 
+	item = gnt_menuitem_new(_("View Log..."));
+	gnt_menuitem_set_id(GNT_MENU_ITEM(item), "view-log");
+	gnt_menu_add_item(GNT_MENU(sub), item);
+	gnt_menuitem_set_callback(GNT_MENU_ITEM(item), view_log_cb, NULL);
+
 	item = gnt_menuitem_new(_("Show"));
 	gnt_menu_add_item(GNT_MENU(sub), item);
 	subsub = gnt_menu_new(GNT_MENU_POPUP);


More information about the Commits mailing list