Mercurial > pidgin.yaz
diff finch/gntblist.c @ 22248:88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
The search box must be focused in order to scroll the log or fire up the pager,
and is labelled such. Feel free to come up with a better widget to attach these
to.
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Sat, 02 Feb 2008 03:51:19 +0000 |
parents | 1f256f63c52c |
children | 9b620ed4fbc4 |
line wrap: on
line diff
--- a/finch/gntblist.c Fri Feb 01 19:35:38 2008 +0000 +++ b/finch/gntblist.c Sat Feb 02 03:51:19 2008 +0000 @@ -27,6 +27,7 @@ #include <account.h> #include <blist.h> +#include <log.h> #include <notify.h> #include <request.h> #include <savedstatuses.h> @@ -43,6 +44,7 @@ #include "gntft.h" #include "gntlabel.h" #include "gntline.h" +#include "gntlog.h" #include "gntmenu.h" #include "gntmenuitem.h" #include "gntmenuitemcheck.h" @@ -1282,6 +1284,43 @@ g_free(prompt); } + +static void showlog_cb(PurpleBlistNode *node) +{ + PurpleLogType type; + PurpleAccount *account; + char *name = NULL; + + if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { + PurpleBuddy *b = (PurpleBuddy*) node; + type = PURPLE_LOG_IM; + name = g_strdup(b->name); + account = b->account; + } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { + PurpleChat *c = (PurpleChat*) node; + PurplePluginProtocolInfo *prpl_info = NULL; + type = PURPLE_LOG_CHAT; + account = c->account; + prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl(purple_account_get_protocol_id(account))); + if (prpl_info && prpl_info->get_chat_name) { + name = prpl_info->get_chat_name(c->components); + } + } else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { + finch_log_show_contact((PurpleContact *)node); + return; + } else { + /* This callback should not have been registered for a node + * that doesn't match the type of one of the blocks above. */ + g_return_if_reached(); + } + + if (name && account) { + finch_log_show(type, name, account); + g_free(name); + } +} + + /* Xeroxed from gtkdialogs.c:purple_gtkdialogs_remove_group_cb*/ static void remove_group(PurpleGroup *group) @@ -1540,6 +1579,10 @@ add_custom_action(GNT_MENU(context), _("Toggle Tag"), PURPLE_CALLBACK(finch_blist_toggle_tag_buddy), node); } + if (!PURPLE_BLIST_NODE_IS_GROUP(node)) { + add_custom_action(GNT_MENU(context), _("View Log"), + PURPLE_CALLBACK(showlog_cb), node); + } } /* Set the position for the popup */