Mercurial > pidgin
comparison console/gntblist.c @ 13857:d341b5ac1a78
[gaim-migrate @ 16316]
Minor tweaks to the buddy-list. The list now updates if some account gets disconnected due to a connection error.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 23 Jun 2006 09:38:48 +0000 |
parents | bbf0470cb348 |
children | aa1c97f5e6eb |
comparison
equal
deleted
inserted
replaced
13856:3cdd05b9830a | 13857:d341b5ac1a78 |
---|---|
14 | 14 |
15 typedef struct | 15 typedef struct |
16 { | 16 { |
17 GntWidget *window; | 17 GntWidget *window; |
18 GntWidget *tree; | 18 GntWidget *tree; |
19 | |
20 GaimBuddyList *list; | |
19 } GGBlist; | 21 } GGBlist; |
20 | 22 |
21 GGBlist *ggblist; | 23 GGBlist *ggblist; |
24 | |
25 static void add_buddy(GaimBuddy *buddy, GGBlist *ggblist); | |
26 static void add_group(GaimGroup *group, GGBlist *ggblist); | |
22 | 27 |
23 static void | 28 static void |
24 new_node(GaimBlistNode *node) | 29 new_node(GaimBlistNode *node) |
25 { | 30 { |
26 } | 31 } |
27 | 32 |
28 static void | 33 static void |
29 node_update(GaimBuddyList *list, GaimBlistNode *node) | 34 node_remove(GaimBuddyList *list, GaimBlistNode *node) |
30 { | 35 { |
36 GGBlist *ggblist = list->ui_data; | |
37 | |
38 if (node->ui_data == NULL) | |
39 return; | |
40 | |
41 gnt_tree_remove(GNT_TREE(ggblist->tree), node); | |
42 node->ui_data = NULL; | |
43 | |
44 /* XXX: Depending on the node, we may want to remove the group/contact node if necessary */ | |
45 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
46 { | |
47 GaimGroup *group = gaim_buddy_get_group((GaimBuddy*)node); | |
48 if (gaim_blist_get_group_online_count(group) == 0) | |
49 node_remove(list, (GaimBlistNode*)group); | |
50 } | |
31 } | 51 } |
32 | 52 |
33 static void | 53 static void |
34 node_remove(GaimBuddyList *list, GaimBlistNode *node) | 54 node_update(GaimBuddyList *list, GaimBlistNode *node) |
35 { | 55 { |
56 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
57 { | |
58 GaimBuddy *buddy = (GaimBuddy*)node; | |
59 } | |
36 } | 60 } |
37 | 61 |
38 static void | 62 static void |
39 new_list(GaimBuddyList *list) | 63 new_list(GaimBuddyList *list) |
40 { | 64 { |
41 if (ggblist == NULL) | |
42 gg_blist_init(); | |
43 list->ui_data = ggblist; | |
44 } | 65 } |
45 | 66 |
46 static GaimBlistUiOps blist_ui_ops = | 67 static GaimBlistUiOps blist_ui_ops = |
47 { | 68 { |
48 new_list, | 69 new_list, |
83 GaimGroup *group; | 104 GaimGroup *group; |
84 GaimBlistNode *node = (GaimBlistNode *)buddy; | 105 GaimBlistNode *node = (GaimBlistNode *)buddy; |
85 if (node->ui_data) | 106 if (node->ui_data) |
86 return; | 107 return; |
87 | 108 |
109 node->ui_data = GINT_TO_POINTER(TRUE); | |
88 group = gaim_buddy_get_group(buddy); | 110 group = gaim_buddy_get_group(buddy); |
89 add_group(group, ggblist); | 111 add_group(group, ggblist); |
90 | 112 |
91 text = g_strdup_printf("%*s%s", TAB_SIZE, "", gaim_buddy_get_alias(buddy)); | 113 text = g_strdup_printf("%*s%s", TAB_SIZE, "", gaim_buddy_get_alias(buddy)); |
92 gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, text, group, NULL); | 114 gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, text, group, NULL); |
100 } | 122 } |
101 | 123 |
102 static void | 124 static void |
103 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist) | 125 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist) |
104 { | 126 { |
105 gnt_tree_remove(GNT_TREE(ggblist->tree), buddy); | 127 node_remove(ggblist->list, (GaimBlistNode*)buddy); |
106 } | 128 } |
107 | 129 |
108 GaimBlistUiOps *gg_get_blist_ui_ops() | 130 GaimBlistUiOps *gg_blist_get_ui_ops() |
109 { | 131 { |
110 return &blist_ui_ops; | 132 return &blist_ui_ops; |
111 } | 133 } |
112 | 134 |
113 static void | 135 static void |
116 gnt_widget_set_focus(widget, FALSE); | 138 gnt_widget_set_focus(widget, FALSE); |
117 } | 139 } |
118 | 140 |
119 void gg_blist_init() | 141 void gg_blist_init() |
120 { | 142 { |
121 if (ggblist == NULL) | 143 ggblist = g_new0(GGBlist, 1); |
122 ggblist = g_new0(GGBlist, 1); | 144 |
145 gaim_get_blist()->ui_data = ggblist; | |
123 | 146 |
124 ggblist->window = gnt_box_new(FALSE, FALSE); | 147 ggblist->window = gnt_box_new(FALSE, FALSE); |
125 GNT_WIDGET_UNSET_FLAGS(ggblist->window, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); | 148 GNT_WIDGET_UNSET_FLAGS(ggblist->window, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); |
126 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); | 149 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); |
127 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); | 150 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); |
137 GAIM_CALLBACK(buddy_signed_on), ggblist); | 160 GAIM_CALLBACK(buddy_signed_on), ggblist); |
138 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gg_blist_get_handle(), | 161 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gg_blist_get_handle(), |
139 GAIM_CALLBACK(buddy_signed_off), ggblist); | 162 GAIM_CALLBACK(buddy_signed_off), ggblist); |
140 | 163 |
141 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); | 164 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); |
142 | 165 |
143 /*gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", gg_blist_get_handle(),*/ | 166 /*gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", gg_blist_get_handle(),*/ |
144 /*GAIM_CALLBACK(received_im_msg), list);*/ | 167 /*GAIM_CALLBACK(received_im_msg), list);*/ |
145 /*gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", gg_blist_get_handle(),*/ | 168 /*gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", gg_blist_get_handle(),*/ |
146 /*GAIM_CALLBACK(sent_im_msg), NULL);*/ | 169 /*GAIM_CALLBACK(sent_im_msg), NULL);*/ |
147 | 170 |