| 33 static void add_group(GaimGroup *group, GGBlist *ggblist); |
33 static void add_group(GaimGroup *group, GGBlist *ggblist); |
| 34 static void add_chat(GaimChat *chat, GGBlist *ggblist); |
34 static void add_chat(GaimChat *chat, GGBlist *ggblist); |
| 35 static void add_node(GaimBlistNode *node, GGBlist *ggblist); |
35 static void add_node(GaimBlistNode *node, GGBlist *ggblist); |
| 36 static void draw_tooltip(GGBlist *ggblist); |
36 static void draw_tooltip(GGBlist *ggblist); |
| 37 static void remove_peripherals(GGBlist *ggblist); |
37 static void remove_peripherals(GGBlist *ggblist); |
| |
38 static const char * get_display_name(GaimBlistNode *node); |
| 38 |
39 |
| 39 static void |
40 static void |
| 40 new_node(GaimBlistNode *node) |
41 new_node(GaimBlistNode *node) |
| 41 { |
42 { |
| 42 } |
43 } |
| 82 } |
83 } |
| 83 |
84 |
| 84 static void |
85 static void |
| 85 node_update(GaimBuddyList *list, GaimBlistNode *node) |
86 node_update(GaimBuddyList *list, GaimBlistNode *node) |
| 86 { |
87 { |
| |
88 if (node->ui_data != NULL) |
| |
89 { |
| |
90 gnt_tree_change_text(GNT_TREE(ggblist->tree), node, |
| |
91 0, get_display_name(node)); |
| |
92 } |
| |
93 |
| 87 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
94 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
| 88 { |
95 { |
| 89 GaimBuddy *buddy = (GaimBuddy*)node; |
96 GaimBuddy *buddy = (GaimBuddy*)node; |
| 90 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy))) |
97 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy))) |
| 91 add_node((GaimBlistNode*)buddy, list->ui_data); |
98 add_node((GaimBlistNode*)buddy, list->ui_data); |
| 131 GaimBlistNode *node = (GaimBlistNode *)group; |
138 GaimBlistNode *node = (GaimBlistNode *)group; |
| 132 if (node->ui_data) |
139 if (node->ui_data) |
| 133 return; |
140 return; |
| 134 gnt_tree_remove(GNT_TREE(ggblist->tree), group); |
141 gnt_tree_remove(GNT_TREE(ggblist->tree), group); |
| 135 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, |
142 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, |
| 136 gnt_tree_create_row(GNT_TREE(ggblist->tree), group->name), NULL, NULL); |
143 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), NULL, NULL); |
| 137 } |
144 } |
| 138 |
145 |
| 139 static const char * |
146 static const char * |
| 140 get_display_name(GaimBlistNode *node) |
147 get_display_name(GaimBlistNode *node) |
| 141 { |
148 { |
| 175 GaimChat *chat = (GaimChat*)node; |
182 GaimChat *chat = (GaimChat*)node; |
| 176 name = gaim_chat_get_name(chat); |
183 name = gaim_chat_get_name(chat); |
| 177 |
184 |
| 178 strncpy(status, "~", sizeof(status) - 1); |
185 strncpy(status, "~", sizeof(status) - 1); |
| 179 } |
186 } |
| |
187 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
| |
188 return ((GaimGroup*)node)->name; |
| 180 |
189 |
| 181 snprintf(text, sizeof(text) - 1, "%s %s", status, name); |
190 snprintf(text, sizeof(text) - 1, "%s %s", status, name); |
| 182 |
191 |
| 183 return text; |
192 return text; |
| 184 } |
193 } |
| 389 |
398 |
| 390 remove_context_menu(ggblist); |
399 remove_context_menu(ggblist); |
| 391 } |
400 } |
| 392 |
401 |
| 393 static void |
402 static void |
| |
403 rename_blist_node(GaimBlistNode *node, const char *newname) |
| |
404 { |
| |
405 const char *name = newname; |
| |
406 if (name && !*name) |
| |
407 name = NULL; |
| |
408 |
| |
409 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
| |
410 gaim_blist_alias_buddy((GaimBuddy*)node, name); |
| |
411 else if (GAIM_BLIST_NODE_IS_CHAT(node)) |
| |
412 gaim_blist_alias_chat((GaimChat*)node, name); |
| |
413 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
| |
414 gaim_blist_rename_group((GaimGroup*)node, name); |
| |
415 else |
| |
416 g_return_if_reached(); |
| |
417 } |
| |
418 |
| |
419 static void |
| 394 gg_blist_rename_node_cb(GaimBlistNode *node, GaimBlistNode *null) |
420 gg_blist_rename_node_cb(GaimBlistNode *node, GaimBlistNode *null) |
| 395 { |
421 { |
| |
422 const char *name = NULL; |
| |
423 char *prompt; |
| |
424 |
| |
425 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
| |
426 name = gaim_buddy_get_contact_alias((GaimBuddy*)node); |
| |
427 else if (GAIM_BLIST_NODE_IS_CHAT(node)) |
| |
428 name = gaim_chat_get_name((GaimChat*)node); |
| |
429 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
| |
430 name = ((GaimGroup*)node)->name; |
| |
431 else |
| |
432 g_return_if_reached(); |
| |
433 |
| |
434 prompt = g_strdup_printf(_("Please enter the new name for %s"), name); |
| |
435 |
| |
436 gaim_request_input(node, _("Rename"), prompt, _("Enter empty string to reset the name."), |
| |
437 name, FALSE, FALSE, NULL, _("Rename"), G_CALLBACK(rename_blist_node), |
| |
438 _("Cancel"), NULL, node); |
| |
439 |
| |
440 g_free(prompt); |
| 396 } |
441 } |
| 397 |
442 |
| 398 /* XXX: This still doesn't do anything, because request doesn't have a ui yet */ |
443 /* XXX: This still doesn't do anything, because request doesn't have a ui yet */ |
| 399 static void |
444 static void |
| 400 gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *null) |
445 gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *null) |