comparison console/gntblist.c @ 14024:7109e6397a31

[gaim-migrate @ 16622] Add commands /accounts, /buddylist, /debugwin and /plugins. It allows the user to close those windows, and pop them back up when necessary -- provided a conversation window is open -- which I am assuming would be the case most of the time. Until there's some better way of accessing these dialogs (eg. menus), this is the only way. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 03 Aug 2006 07:16:35 +0000
parents 13e7ba964993
children 27182f83b79b
comparison
equal deleted inserted replaced
14023:07d645986c79 14024:7109e6397a31
64 static void 64 static void
65 node_remove(GaimBuddyList *list, GaimBlistNode *node) 65 node_remove(GaimBuddyList *list, GaimBlistNode *node)
66 { 66 {
67 GGBlist *ggblist = list->ui_data; 67 GGBlist *ggblist = list->ui_data;
68 68
69 if (node->ui_data == NULL) 69 if (ggblist == NULL || node->ui_data == NULL)
70 return; 70 return;
71 71
72 gnt_tree_remove(GNT_TREE(ggblist->tree), node); 72 gnt_tree_remove(GNT_TREE(ggblist->tree), node);
73 node->ui_data = NULL; 73 node->ui_data = NULL;
74 74
83 } 83 }
84 84
85 static void 85 static void
86 node_update(GaimBuddyList *list, GaimBlistNode *node) 86 node_update(GaimBuddyList *list, GaimBlistNode *node)
87 { 87 {
88 if (list->ui_data == NULL)
89 return;
90
88 if (node->ui_data != NULL) 91 if (node->ui_data != NULL)
89 { 92 {
90 gnt_tree_change_text(GNT_TREE(ggblist->tree), node, 93 gnt_tree_change_text(GNT_TREE(ggblist->tree), node,
91 0, get_display_name(node)); 94 0, get_display_name(node));
92 } 95 }
742 { 745 {
743 gaim_prefs_set_int(PREF_ROOT "/position/x", x); 746 gaim_prefs_set_int(PREF_ROOT "/position/x", x);
744 gaim_prefs_set_int(PREF_ROOT "/position/y", y); 747 gaim_prefs_set_int(PREF_ROOT "/position/y", y);
745 } 748 }
746 749
750 static void
751 reset_blist_window(GntWidget *window, gpointer null)
752 {
753 GaimBlistNode *node;
754 gaim_signals_disconnect_by_handle(gg_blist_get_handle());
755 gaim_get_blist()->ui_data = NULL;
756
757 node = gaim_blist_get_root();
758 while (node)
759 {
760 node->ui_data = NULL;
761 node = gaim_blist_node_next(node, TRUE);
762 }
763
764 remove_peripherals(ggblist);
765 g_free(ggblist);
766 ggblist = NULL;
767 }
768
769 static void
770 populate_buddylist()
771 {
772 GaimBlistNode *node;
773 GaimBuddyList *list;
774
775 list = gaim_get_blist();
776 node = gaim_blist_get_root();
777 while (node)
778 {
779 node_update(list, node);
780 node = gaim_blist_node_next(node, TRUE);
781 }
782 }
783
747 void gg_blist_init() 784 void gg_blist_init()
748 { 785 {
749 gaim_prefs_add_none(PREF_ROOT); 786 gaim_prefs_add_none(PREF_ROOT);
750 gaim_prefs_add_none(PREF_ROOT "/size"); 787 gaim_prefs_add_none(PREF_ROOT "/size");
751 gaim_prefs_add_int(PREF_ROOT "/size/width", 20); 788 gaim_prefs_add_int(PREF_ROOT "/size/width", 20);
752 gaim_prefs_add_int(PREF_ROOT "/size/height", 20); 789 gaim_prefs_add_int(PREF_ROOT "/size/height", 20);
753 gaim_prefs_add_none(PREF_ROOT "/position"); 790 gaim_prefs_add_none(PREF_ROOT "/position");
754 gaim_prefs_add_int(PREF_ROOT "/position/x", 0); 791 gaim_prefs_add_int(PREF_ROOT "/position/x", 0);
755 gaim_prefs_add_int(PREF_ROOT "/position/y", 0); 792 gaim_prefs_add_int(PREF_ROOT "/position/y", 0);
793
794 gg_blist_show();
795
796 return;
797 }
798
799 void gg_blist_show()
800 {
801 if (ggblist)
802 return;
756 803
757 ggblist = g_new0(GGBlist, 1); 804 ggblist = g_new0(GGBlist, 1);
758 805
759 gaim_get_blist()->ui_data = ggblist; 806 gaim_get_blist()->ui_data = ggblist;
760 807
803 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); 850 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
804 g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals), 851 g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals),
805 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); 852 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
806 g_signal_connect(G_OBJECT(ggblist->tree), "size_changed", G_CALLBACK(size_changed_cb), NULL); 853 g_signal_connect(G_OBJECT(ggblist->tree), "size_changed", G_CALLBACK(size_changed_cb), NULL);
807 g_signal_connect(G_OBJECT(ggblist->window), "position_set", G_CALLBACK(save_position_cb), NULL); 854 g_signal_connect(G_OBJECT(ggblist->window), "position_set", G_CALLBACK(save_position_cb), NULL);
808 855 g_signal_connect(G_OBJECT(ggblist->window), "destroy", G_CALLBACK(reset_blist_window), NULL);
856
857 populate_buddylist();
809 } 858 }
810 859
811 void gg_blist_uninit() 860 void gg_blist_uninit()
812 { 861 {
862 if (ggblist == NULL)
863 return;
864
813 gnt_widget_destroy(ggblist->window); 865 gnt_widget_destroy(ggblist->window);
814 g_free(ggblist); 866 g_free(ggblist);
815 ggblist = NULL; 867 ggblist = NULL;
816 } 868 }
817 869