comparison finch/gntconv.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 797230b3e48e
children 40707fbabcbc
comparison
equal deleted inserted replaced
22247:5ffb0b5f785f 22248:88796aff14d6
34 34
35 #include "gntaccount.h" 35 #include "gntaccount.h"
36 #include "gntblist.h" 36 #include "gntblist.h"
37 #include "gntconv.h" 37 #include "gntconv.h"
38 #include "gntdebug.h" 38 #include "gntdebug.h"
39 #include "gntlog.h"
39 #include "gntplugin.h" 40 #include "gntplugin.h"
40 #include "gntprefs.h" 41 #include "gntprefs.h"
41 #include "gntsound.h" 42 #include "gntsound.h"
42 #include "gntstatus.h" 43 #include "gntstatus.h"
43 #include "gntpounce.h" 44 #include "gntpounce.h"
466 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy); 467 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy);
467 finch_conversation_set_active(conv); 468 finch_conversation_set_active(conv);
468 } 469 }
469 470
470 static void 471 static void
472 view_log_cb(GntMenuItem *n, gpointer ggc)
473 {
474 FinchConv *fc;
475 PurpleConversation *conv;
476 PurpleLogType type;
477 const char *name;
478 PurpleAccount *account;
479 GSList *buddies;
480 GSList *cur;
481
482 fc = ggc;
483 conv = fc->active_conv;
484
485 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
486 type = PURPLE_LOG_IM;
487 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
488 type = PURPLE_LOG_CHAT;
489 else
490 return;
491
492 name = purple_conversation_get_name(conv);
493 account = purple_conversation_get_account(conv);
494
495 buddies = purple_find_buddies(account, name);
496 for (cur = buddies; cur != NULL; cur = cur->next) {
497 PurpleBlistNode *node = cur->data;
498 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) {
499 finch_log_show_contact((PurpleContact *)node->parent);
500 g_slist_free(buddies);
501 return;
502 }
503 }
504 g_slist_free(buddies);
505
506 finch_log_show(type, name, account);
507 }
508
509 static void
471 generate_send_to_menu(FinchConv *ggc) 510 generate_send_to_menu(FinchConv *ggc)
472 { 511 {
473 GntWidget *sub, *menu = ggc->menu; 512 GntWidget *sub, *menu = ggc->menu;
474 GntMenuItem *item; 513 GntMenuItem *item;
475 GSList *buds; 514 GSList *buds;
566 gnt_menuitem_set_callback(item, send_file_cb, ggc); 605 gnt_menuitem_set_callback(item, send_file_cb, ggc);
567 } 606 }
568 607
569 generate_send_to_menu(ggc); 608 generate_send_to_menu(ggc);
570 } 609 }
610
611 item = gnt_menuitem_new(_("View Log..."));
612 gnt_menu_add_item(GNT_MENU(sub), item);
613 gnt_menuitem_set_callback(item, view_log_cb, ggc);
571 614
572 item = gnt_menuitem_check_new(_("Enable Logging")); 615 item = gnt_menuitem_check_new(_("Enable Logging"));
573 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), 616 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item),
574 purple_conversation_is_logging(ggc->active_conv)); 617 purple_conversation_is_logging(ggc->active_conv));
575 gnt_menu_add_item(GNT_MENU(sub), item); 618 gnt_menu_add_item(GNT_MENU(sub), item);