| 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) |
| 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 { |
| 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 } |