Mercurial > pidgin
comparison console/gntblist.c @ 13884:eac18261c6f0
[gaim-migrate @ 16364]
Let's have chats in the buddylist.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 28 Jun 2006 01:46:41 +0000 |
parents | 765bbdf29d04 |
children | 582aaa4e287e |
comparison
equal
deleted
inserted
replaced
13883:ab6376814e73 | 13884:eac18261c6f0 |
---|---|
22 | 22 |
23 GGBlist *ggblist; | 23 GGBlist *ggblist; |
24 | 24 |
25 static void add_buddy(GaimBuddy *buddy, GGBlist *ggblist); | 25 static void add_buddy(GaimBuddy *buddy, GGBlist *ggblist); |
26 static void add_group(GaimGroup *group, GGBlist *ggblist); | 26 static void add_group(GaimGroup *group, GGBlist *ggblist); |
27 static void add_chat(GaimChat *chat, GGBlist *ggblist); | |
27 static void add_node(GaimBlistNode *node, GGBlist *ggblist); | 28 static void add_node(GaimBlistNode *node, GGBlist *ggblist); |
28 static void draw_tooltip(GGBlist *ggblist); | 29 static void draw_tooltip(GGBlist *ggblist); |
29 | 30 |
30 static void | 31 static void |
31 new_node(GaimBlistNode *node) | 32 new_node(GaimBlistNode *node) |
36 { | 37 { |
37 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | 38 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
38 add_buddy((GaimBuddy*)node, ggblist); | 39 add_buddy((GaimBuddy*)node, ggblist); |
39 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | 40 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
40 add_group((GaimGroup*)node, ggblist); | 41 add_group((GaimGroup*)node, ggblist); |
42 else if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
43 add_chat((GaimChat *)node, ggblist); | |
41 draw_tooltip(ggblist); | 44 draw_tooltip(ggblist); |
42 } | 45 } |
43 | 46 |
44 static void | 47 static void |
45 remove_tooltip(GGBlist *ggblist) | 48 remove_tooltip(GGBlist *ggblist) |
78 GaimBuddy *buddy = (GaimBuddy*)node; | 81 GaimBuddy *buddy = (GaimBuddy*)node; |
79 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy))) | 82 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy))) |
80 add_node((GaimBlistNode*)buddy, list->ui_data); | 83 add_node((GaimBlistNode*)buddy, list->ui_data); |
81 else | 84 else |
82 node_remove(gaim_get_blist(), node); | 85 node_remove(gaim_get_blist(), node); |
86 } | |
87 else if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
88 { | |
89 add_chat((GaimChat *)node, list->ui_data); | |
83 } | 90 } |
84 } | 91 } |
85 | 92 |
86 static void | 93 static void |
87 new_list(GaimBuddyList *list) | 94 new_list(GaimBuddyList *list) |
119 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, | 126 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, |
120 group->name, NULL, NULL); | 127 group->name, NULL, NULL); |
121 } | 128 } |
122 | 129 |
123 static const char * | 130 static const char * |
124 get_buddy_display_name(GaimBuddy *buddy) | 131 get_display_name(GaimBlistNode *node) |
125 { | 132 { |
126 static char text[2096]; | 133 static char text[2096]; |
127 char status[8]; | 134 char status[8] = " "; |
128 GaimStatusPrimitive prim; | 135 const char *name = NULL; |
129 GaimPresence *presence; | 136 |
130 GaimStatus *now; | 137 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
131 | 138 { |
132 presence = gaim_buddy_get_presence(buddy); | 139 GaimBuddy *buddy = (GaimBuddy *)node; |
133 now = gaim_presence_get_active_status(presence); | 140 GaimStatusPrimitive prim; |
134 | 141 GaimPresence *presence; |
135 prim = gaim_status_type_get_primitive(gaim_status_get_type(now)); | 142 GaimStatus *now; |
136 | 143 |
137 switch(prim) | 144 |
138 { | 145 presence = gaim_buddy_get_presence(buddy); |
146 now = gaim_presence_get_active_status(presence); | |
147 | |
148 prim = gaim_status_type_get_primitive(gaim_status_get_type(now)); | |
149 | |
150 switch(prim) | |
151 { | |
139 #if 1 | 152 #if 1 |
140 case GAIM_STATUS_OFFLINE: | 153 case GAIM_STATUS_OFFLINE: |
141 strncpy(status, "x", sizeof(status) - 1); | 154 strncpy(status, "x", sizeof(status) - 1); |
142 break; | 155 break; |
143 case GAIM_STATUS_AVAILABLE: | 156 case GAIM_STATUS_AVAILABLE: |
144 strncpy(status, "o", sizeof(status) - 1); | 157 strncpy(status, "o", sizeof(status) - 1); |
145 break; | 158 break; |
146 default: | 159 default: |
147 strncpy(status, ".", sizeof(status) - 1); | 160 strncpy(status, ".", sizeof(status) - 1); |
148 break; | 161 break; |
149 #else | 162 #else |
150 /* XXX: Let's use these some time */ | 163 /* XXX: Let's use these some time */ |
151 case GAIM_STATUS_OFFLINE: | 164 case GAIM_STATUS_OFFLINE: |
152 strncpy(status, "⊗", sizeof(status) - 1); | 165 strncpy(status, "⊗", sizeof(status) - 1); |
153 break; | 166 break; |
154 case GAIM_STATUS_AVAILABLE: | 167 case GAIM_STATUS_AVAILABLE: |
155 /* XXX: Detect idleness */ | 168 /* XXX: Detect idleness */ |
156 strncpy(status, "◯", sizeof(status) - 1); | 169 strncpy(status, "◯", sizeof(status) - 1); |
157 break; | 170 break; |
158 default: | 171 default: |
159 strncpy(status, "⊖", sizeof(status) - 1); | 172 strncpy(status, "⊖", sizeof(status) - 1); |
160 break; | 173 break; |
161 #endif | 174 #endif |
162 } | 175 } |
163 | 176 name = gaim_buddy_get_alias(buddy); |
164 snprintf(text, sizeof(text) - 1, "%s %s", status, gaim_buddy_get_alias(buddy)); | 177 } |
178 else if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
179 { | |
180 GaimChat *chat = (GaimChat*)node; | |
181 name = gaim_chat_get_name(chat); | |
182 } | |
183 | |
184 snprintf(text, sizeof(text) - 1, "%s %s", status, name); | |
165 | 185 |
166 return text; | 186 return text; |
187 } | |
188 | |
189 static void | |
190 add_chat(GaimChat *chat, GGBlist *ggblist) | |
191 { | |
192 GaimGroup *group; | |
193 GaimBlistNode *node = (GaimBlistNode *)chat; | |
194 if (node->ui_data) | |
195 return; | |
196 | |
197 group = gaim_chat_get_group(chat); | |
198 add_node((GaimBlistNode*)group, ggblist); | |
199 | |
200 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, | |
201 get_display_name(node), group, NULL); | |
167 } | 202 } |
168 | 203 |
169 static void | 204 static void |
170 add_buddy(GaimBuddy *buddy, GGBlist *ggblist) | 205 add_buddy(GaimBuddy *buddy, GGBlist *ggblist) |
171 { | 206 { |
176 | 211 |
177 group = gaim_buddy_get_group(buddy); | 212 group = gaim_buddy_get_group(buddy); |
178 add_node((GaimBlistNode*)group, ggblist); | 213 add_node((GaimBlistNode*)group, ggblist); |
179 | 214 |
180 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, | 215 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, |
181 get_buddy_display_name(buddy), group, NULL); | 216 get_display_name(node), group, NULL); |
182 } | 217 } |
183 | 218 |
184 static void | 219 static void |
185 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) | 220 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) |
186 { | 221 { |
266 gaim_blist_get_group_online_count(group), | 301 gaim_blist_get_group_online_count(group), |
267 gaim_blist_get_group_size(group, FALSE)); | 302 gaim_blist_get_group_size(group, FALSE)); |
268 | 303 |
269 title = g_strdup(group->name); | 304 title = g_strdup(group->name); |
270 } | 305 } |
306 else if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
307 { | |
308 GaimChat *chat = (GaimChat *)node; | |
309 GaimAccount *account = chat->account; | |
310 | |
311 g_string_append_printf(str, _("Account: %s"), gaim_account_get_username(account)); | |
312 | |
313 title = g_strdup(gaim_chat_get_name(chat)); | |
314 } | |
271 else | 315 else |
272 { | 316 { |
273 g_string_free(str, TRUE); | 317 g_string_free(str, TRUE); |
274 return; | 318 return; |
275 } | 319 } |
323 } | 367 } |
324 | 368 |
325 static void | 369 static void |
326 buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist) | 370 buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist) |
327 { | 371 { |
328 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, get_buddy_display_name(buddy)); | 372 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, get_display_name((GaimBlistNode*)buddy)); |
329 if (ggblist->tnode == (GaimBlistNode*)buddy) | 373 if (ggblist->tnode == (GaimBlistNode*)buddy) |
330 draw_tooltip(ggblist); | 374 draw_tooltip(ggblist); |
331 } | 375 } |
332 | 376 |
333 void gg_blist_init() | 377 void gg_blist_init() |