comparison 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
comparison
equal deleted inserted replaced
22247:5ffb0b5f785f 22248:88796aff14d6
25 */ 25 */
26 #include "finch.h" 26 #include "finch.h"
27 27
28 #include <account.h> 28 #include <account.h>
29 #include <blist.h> 29 #include <blist.h>
30 #include <log.h>
30 #include <notify.h> 31 #include <notify.h>
31 #include <request.h> 32 #include <request.h>
32 #include <savedstatuses.h> 33 #include <savedstatuses.h>
33 #include <server.h> 34 #include <server.h>
34 #include <signal.h> 35 #include <signal.h>
41 #include "gntcombobox.h" 42 #include "gntcombobox.h"
42 #include "gntentry.h" 43 #include "gntentry.h"
43 #include "gntft.h" 44 #include "gntft.h"
44 #include "gntlabel.h" 45 #include "gntlabel.h"
45 #include "gntline.h" 46 #include "gntline.h"
47 #include "gntlog.h"
46 #include "gntmenu.h" 48 #include "gntmenu.h"
47 #include "gntmenuitem.h" 49 #include "gntmenuitem.h"
48 #include "gntmenuitemcheck.h" 50 #include "gntmenuitemcheck.h"
49 #include "gntpounce.h" 51 #include "gntpounce.h"
50 #include "gntstyle.h" 52 #include "gntstyle.h"
1279 NULL, NULL, NULL, 1281 NULL, NULL, NULL,
1280 node); 1282 node);
1281 1283
1282 g_free(prompt); 1284 g_free(prompt);
1283 } 1285 }
1286
1287
1288 static void showlog_cb(PurpleBlistNode *node)
1289 {
1290 PurpleLogType type;
1291 PurpleAccount *account;
1292 char *name = NULL;
1293
1294 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
1295 PurpleBuddy *b = (PurpleBuddy*) node;
1296 type = PURPLE_LOG_IM;
1297 name = g_strdup(b->name);
1298 account = b->account;
1299 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
1300 PurpleChat *c = (PurpleChat*) node;
1301 PurplePluginProtocolInfo *prpl_info = NULL;
1302 type = PURPLE_LOG_CHAT;
1303 account = c->account;
1304 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl(purple_account_get_protocol_id(account)));
1305 if (prpl_info && prpl_info->get_chat_name) {
1306 name = prpl_info->get_chat_name(c->components);
1307 }
1308 } else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
1309 finch_log_show_contact((PurpleContact *)node);
1310 return;
1311 } else {
1312 /* This callback should not have been registered for a node
1313 * that doesn't match the type of one of the blocks above. */
1314 g_return_if_reached();
1315 }
1316
1317 if (name && account) {
1318 finch_log_show(type, name, account);
1319 g_free(name);
1320 }
1321 }
1322
1284 1323
1285 /* Xeroxed from gtkdialogs.c:purple_gtkdialogs_remove_group_cb*/ 1324 /* Xeroxed from gtkdialogs.c:purple_gtkdialogs_remove_group_cb*/
1286 static void 1325 static void
1287 remove_group(PurpleGroup *group) 1326 remove_group(PurpleGroup *group)
1288 { 1327 {
1538 1577
1539 if (PURPLE_BLIST_NODE_IS_BUDDY(node) || PURPLE_BLIST_NODE_IS_CONTACT(node)) { 1578 if (PURPLE_BLIST_NODE_IS_BUDDY(node) || PURPLE_BLIST_NODE_IS_CONTACT(node)) {
1540 add_custom_action(GNT_MENU(context), _("Toggle Tag"), 1579 add_custom_action(GNT_MENU(context), _("Toggle Tag"),
1541 PURPLE_CALLBACK(finch_blist_toggle_tag_buddy), node); 1580 PURPLE_CALLBACK(finch_blist_toggle_tag_buddy), node);
1542 } 1581 }
1582 if (!PURPLE_BLIST_NODE_IS_GROUP(node)) {
1583 add_custom_action(GNT_MENU(context), _("View Log"),
1584 PURPLE_CALLBACK(showlog_cb), node);
1585 }
1543 } 1586 }
1544 1587
1545 /* Set the position for the popup */ 1588 /* Set the position for the popup */
1546 gnt_widget_get_position(GNT_WIDGET(tree), &x, &y); 1589 gnt_widget_get_position(GNT_WIDGET(tree), &x, &y);
1547 gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL); 1590 gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL);