comparison pidgin/gtklog.c @ 21343:2ae1233bd6b2

merge of '2af6143b8106e9e17b15eacee5bd408d8b7fc91a' and '9d6b27d8f2e6f67edbf460949a3d074185eaa47e'
author Richard Laager <rlaager@wiktel.com>
date Fri, 16 Nov 2007 22:59:30 +0000
parents 6c4de0d24eff
children 80af064d311c
comparison
equal deleted inserted replaced
21339:a051b177661e 21343:2ae1233bd6b2
521 521
522 logs = logs->next; 522 logs = logs->next;
523 } 523 }
524 } 524 }
525 525
526 static PidginLogViewer *display_log_viewer(GtkWindow *parent, struct log_viewer_hash_t *ht, GList *logs, 526 static PidginLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *logs,
527 const char *title, GtkWidget *icon, int log_size) 527 const char *title, GtkWidget *icon, int log_size)
528 { 528 {
529 PidginLogViewer *lv; 529 PidginLogViewer *lv;
530 GtkWidget *title_box; 530 GtkWidget *title_box;
531 char *text; 531 char *text;
567 567
568 if (ht != NULL) 568 if (ht != NULL)
569 g_hash_table_insert(log_viewers, ht, lv); 569 g_hash_table_insert(log_viewers, ht, lv);
570 570
571 /* Window ***********/ 571 /* Window ***********/
572 lv->window = gtk_dialog_new_with_buttons(title, parent, 0, 572 lv->window = gtk_dialog_new_with_buttons(title, NULL, 0,
573 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); 573 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
574 #ifdef _WIN32 574 #ifdef _WIN32
575 /* Steal the "HELP" response and use it to trigger browsing to the logs folder */ 575 /* Steal the "HELP" response and use it to trigger browsing to the logs folder */
576 gtk_dialog_add_button(GTK_DIALOG(lv->window), _("_Browse logs folder"), GTK_RESPONSE_HELP); 576 gtk_dialog_add_button(GTK_DIALOG(lv->window), _("_Browse logs folder"), GTK_RESPONSE_HELP);
577 #endif 577 #endif
674 674
675 return lv; 675 return lv;
676 } 676 }
677 677
678 void pidgin_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account) { 678 void pidgin_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account) {
679 pidgin_log_show_with_parent(NULL, type, screenname, account);
680 }
681
682 void pidgin_log_show_with_parent(GtkWindow *parent, PurpleLogType type, const char *screenname, PurpleAccount *account) {
683 struct log_viewer_hash_t *ht; 679 struct log_viewer_hash_t *ht;
684 PidginLogViewer *lv = NULL; 680 PidginLogViewer *lv = NULL;
685 const char *name = screenname; 681 const char *name = screenname;
686 char *title; 682 char *title;
687 GdkPixbuf *prpl_icon; 683 GdkPixbuf *prpl_icon;
722 title = g_strdup_printf(_("Conversations with %s"), name); 718 title = g_strdup_printf(_("Conversations with %s"), name);
723 } 719 }
724 720
725 prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM); 721 prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM);
726 722
727 display_log_viewer(parent, ht, purple_log_get_logs(type, screenname, account), 723 display_log_viewer(ht, purple_log_get_logs(type, screenname, account),
728 title, gtk_image_new_from_pixbuf(prpl_icon), 724 title, gtk_image_new_from_pixbuf(prpl_icon),
729 purple_log_get_total_size(type, screenname, account)); 725 purple_log_get_total_size(type, screenname, account));
730 726
731 if (prpl_icon) 727 if (prpl_icon)
732 g_object_unref(prpl_icon); 728 g_object_unref(prpl_icon);
733 g_free(title); 729 g_free(title);
734 } 730 }
735 731
736 void pidgin_log_show_contact(PurpleContact *contact) { 732 void pidgin_log_show_contact(PurpleContact *contact) {
737 pidgin_log_show_contact_with_parent(NULL, contact);
738 }
739
740 void pidgin_log_show_contact_with_parent(GtkWindow *parent, PurpleContact *contact) {
741 struct log_viewer_hash_t *ht = g_new0(struct log_viewer_hash_t, 1); 733 struct log_viewer_hash_t *ht = g_new0(struct log_viewer_hash_t, 1);
742 PurpleBlistNode *child; 734 PurpleBlistNode *child;
743 PidginLogViewer *lv = NULL; 735 PidginLogViewer *lv = NULL;
744 GList *logs = NULL; 736 GList *logs = NULL;
745 GdkPixbuf *pixbuf; 737 GdkPixbuf *pixbuf;
789 if (name == NULL) 781 if (name == NULL)
790 name = ""; 782 name = "";
791 } 783 }
792 784
793 title = g_strdup_printf(_("Conversations with %s"), name); 785 title = g_strdup_printf(_("Conversations with %s"), name);
794 display_log_viewer(parent, ht, logs, title, image, total_log_size); 786 display_log_viewer(ht, logs, title, image, total_log_size);
795 g_free(title); 787 g_free(title);
796 } 788 }
797 789
798 void pidgin_syslog_show(void) 790 void pidgin_syslog_show()
799 {
800 pidgin_syslog_show_with_parent(NULL);
801 }
802
803 void pidgin_syslog_show_with_parent(GtkWindow *parent)
804 { 791 {
805 GList *accounts = NULL; 792 GList *accounts = NULL;
806 GList *logs = NULL; 793 GList *logs = NULL;
807 794
808 if (syslog_viewer != NULL) { 795 if (syslog_viewer != NULL) {
818 805
819 logs = g_list_concat(purple_log_get_system_logs(account), logs); 806 logs = g_list_concat(purple_log_get_system_logs(account), logs);
820 } 807 }
821 logs = g_list_sort(logs, purple_log_compare); 808 logs = g_list_sort(logs, purple_log_compare);
822 809
823 syslog_viewer = display_log_viewer(parent, NULL, logs, _("System Log"), NULL, 0); 810 syslog_viewer = display_log_viewer(NULL, logs, _("System Log"), NULL, 0);
824 } 811 }
825 812
826 /**************************************************************************** 813 /****************************************************************************
827 * GTK+ LOG SUBSYSTEM ******************************************************* 814 * GTK+ LOG SUBSYSTEM *******************************************************
828 ****************************************************************************/ 815 ****************************************************************************/