Mercurial > pidgin
changeset 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 | 3cdd05b9830a |
children | aa1c97f5e6eb |
files | console/gntblist.c console/gntblist.h console/gntgaim.c console/gntui.c console/libgnt/gnttree.c |
diffstat | 5 files changed, 42 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/console/gntblist.c Fri Jun 23 08:42:07 2006 +0000 +++ b/console/gntblist.c Fri Jun 23 09:38:48 2006 +0000 @@ -16,31 +16,52 @@ { GntWidget *window; GntWidget *tree; + + GaimBuddyList *list; } GGBlist; GGBlist *ggblist; +static void add_buddy(GaimBuddy *buddy, GGBlist *ggblist); +static void add_group(GaimGroup *group, GGBlist *ggblist); + static void new_node(GaimBlistNode *node) { } static void -node_update(GaimBuddyList *list, GaimBlistNode *node) +node_remove(GaimBuddyList *list, GaimBlistNode *node) { + GGBlist *ggblist = list->ui_data; + + if (node->ui_data == NULL) + return; + + gnt_tree_remove(GNT_TREE(ggblist->tree), node); + node->ui_data = NULL; + + /* XXX: Depending on the node, we may want to remove the group/contact node if necessary */ + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + { + GaimGroup *group = gaim_buddy_get_group((GaimBuddy*)node); + if (gaim_blist_get_group_online_count(group) == 0) + node_remove(list, (GaimBlistNode*)group); + } } static void -node_remove(GaimBuddyList *list, GaimBlistNode *node) +node_update(GaimBuddyList *list, GaimBlistNode *node) { + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + { + GaimBuddy *buddy = (GaimBuddy*)node; + } } static void new_list(GaimBuddyList *list) { - if (ggblist == NULL) - gg_blist_init(); - list->ui_data = ggblist; } static GaimBlistUiOps blist_ui_ops = @@ -85,6 +106,7 @@ if (node->ui_data) return; + node->ui_data = GINT_TO_POINTER(TRUE); group = gaim_buddy_get_group(buddy); add_group(group, ggblist); @@ -102,10 +124,10 @@ static void buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist) { - gnt_tree_remove(GNT_TREE(ggblist->tree), buddy); + node_remove(ggblist->list, (GaimBlistNode*)buddy); } -GaimBlistUiOps *gg_get_blist_ui_ops() +GaimBlistUiOps *gg_blist_get_ui_ops() { return &blist_ui_ops; } @@ -118,8 +140,9 @@ void gg_blist_init() { - if (ggblist == NULL) - ggblist = g_new0(GGBlist, 1); + ggblist = g_new0(GGBlist, 1); + + gaim_get_blist()->ui_data = ggblist; ggblist->window = gnt_box_new(FALSE, FALSE); GNT_WIDGET_UNSET_FLAGS(ggblist->window, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); @@ -139,7 +162,7 @@ GAIM_CALLBACK(buddy_signed_off), ggblist); g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); - + /*gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", gg_blist_get_handle(),*/ /*GAIM_CALLBACK(received_im_msg), list);*/ /*gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", gg_blist_get_handle(),*/
--- a/console/gntblist.h Fri Jun 23 08:42:07 2006 +0000 +++ b/console/gntblist.h Fri Jun 23 09:38:48 2006 +0000 @@ -1,5 +1,5 @@ #include "blist.h" -GaimBlistUiOps * gg_get_blist_ui_ops(); +GaimBlistUiOps * gg_blist_get_ui_ops(); void gg_blist_init();
--- a/console/gntgaim.c Fri Jun 23 08:42:07 2006 +0000 +++ b/console/gntgaim.c Fri Jun 23 09:38:48 2006 +0000 @@ -171,8 +171,6 @@ /* Initialize the libgaim stuff */ init_libgaim(); - /* Connect to the signals */ - /* Enable the accounts and restore the status */ gaim_accounts_restore_current_statuses();
--- a/console/gntui.c Fri Jun 23 08:42:07 2006 +0000 +++ b/console/gntui.c Fri Jun 23 09:38:48 2006 +0000 @@ -6,12 +6,11 @@ wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); werase(stdscr); - /*box(stdscr, ACS_VLINE, ACS_HLINE);*/ wrefresh(stdscr); /* Initialize the buddy list */ gg_blist_init(); - gaim_blist_set_ui_ops(gg_get_blist_ui_ops()); + gaim_blist_set_ui_ops(gg_blist_get_ui_ops()); gnt_main(); }
--- a/console/libgnt/gnttree.c Fri Jun 23 08:42:07 2006 +0000 +++ b/console/libgnt/gnttree.c Fri Jun 23 09:38:48 2006 +0000 @@ -13,9 +13,11 @@ char *text; void *data; /* XXX: unused */ + /* XXX: These are also unused */ GntTreeRow *parent; GntTreeRow *child; GntTreeRow *next; + GntTreeRow *prev; }; static GntWidgetClass *parent_class = NULL; @@ -268,7 +270,9 @@ pr = g_hash_table_lookup(tree->hash, bigbro); if (pr) { + if (pr->next) pr->next->prev = row; row->next = pr->next; + row->prev = pr; pr->next = row; row->parent = pr->parent; @@ -281,6 +285,7 @@ pr = g_hash_table_lookup(tree->hash, parent); if (pr) { + if (pr->child) pr->child->prev = row; row->next = pr->child; pr->child = row; row->parent = pr; @@ -291,6 +296,7 @@ if (pr == NULL) { + if (tree->root) tree->root->prev = row; row->next = tree->root; tree->root = row; @@ -316,6 +322,7 @@ return tree->current; } +/* XXX: Should this also remove all the children of the row being removed? */ void gnt_tree_remove(GntTree *tree, gpointer key) { GntTreeRow *row = g_hash_table_lookup(tree->hash, key);