Mercurial > pidgin.yaz
comparison console/gntblist.c @ 13853:bbf0470cb348
[gaim-migrate @ 16312]
Improvement/fixing of GntTree. Do the scrolling and stuff without 'reliably'.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 23 Jun 2006 00:45:45 +0000 |
parents | 0e1e59770cb0 |
children | d341b5ac1a78 |
comparison
equal
deleted
inserted
replaced
13852:d95e5e0e29b9 | 13853:bbf0470cb348 |
---|---|
6 | 6 |
7 #include "gntgaim.h" | 7 #include "gntgaim.h" |
8 #include "gntbox.h" | 8 #include "gntbox.h" |
9 #include "gnttree.h" | 9 #include "gnttree.h" |
10 | 10 |
11 #include "gntblist.h" | |
12 | |
11 #define TAB_SIZE 3 | 13 #define TAB_SIZE 3 |
12 | |
13 /** | |
14 * NOTES: | |
15 * | |
16 * 1. signal-callbacks should check for module_in_focus() before redrawing anything. | |
17 * 2. call module_lost_focus() before opening a new window, and module_gained_focus() when | |
18 * the new window is closed. This is to make sure the signal callbacks don't screw up | |
19 * the display. | |
20 */ | |
21 | |
22 static GaimBlistUiOps blist_ui_ops = | |
23 { | |
24 NULL, | |
25 NULL, | |
26 NULL, | |
27 NULL, /* This doesn't do crap */ | |
28 NULL, | |
29 NULL, | |
30 NULL, | |
31 NULL, | |
32 NULL, | |
33 NULL | |
34 }; | |
35 | 14 |
36 typedef struct | 15 typedef struct |
37 { | 16 { |
38 GntWidget *window; | 17 GntWidget *window; |
39 GntWidget *tree; | 18 GntWidget *tree; |
40 } GGBlist; | 19 } GGBlist; |
41 | 20 |
42 GGBlist *ggblist; | 21 GGBlist *ggblist; |
22 | |
23 static void | |
24 new_node(GaimBlistNode *node) | |
25 { | |
26 } | |
27 | |
28 static void | |
29 node_update(GaimBuddyList *list, GaimBlistNode *node) | |
30 { | |
31 } | |
32 | |
33 static void | |
34 node_remove(GaimBuddyList *list, GaimBlistNode *node) | |
35 { | |
36 } | |
37 | |
38 static void | |
39 new_list(GaimBuddyList *list) | |
40 { | |
41 if (ggblist == NULL) | |
42 gg_blist_init(); | |
43 list->ui_data = ggblist; | |
44 } | |
45 | |
46 static GaimBlistUiOps blist_ui_ops = | |
47 { | |
48 new_list, | |
49 new_node, | |
50 NULL, | |
51 node_update, /* This doesn't do crap */ | |
52 node_remove, | |
53 NULL, | |
54 NULL, | |
55 NULL, | |
56 NULL, | |
57 NULL | |
58 }; | |
43 | 59 |
44 static gpointer | 60 static gpointer |
45 gg_blist_get_handle() | 61 gg_blist_get_handle() |
46 { | 62 { |
47 static int handle; | 63 static int handle; |
59 group->name, NULL, NULL); | 75 group->name, NULL, NULL); |
60 node->ui_data = GINT_TO_POINTER(TRUE); | 76 node->ui_data = GINT_TO_POINTER(TRUE); |
61 } | 77 } |
62 | 78 |
63 static void | 79 static void |
64 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) | 80 add_buddy(GaimBuddy *buddy, GGBlist *ggblist) |
65 { | 81 { |
66 GaimGroup *group = gaim_buddy_get_group(buddy); | |
67 char *text; | 82 char *text; |
83 GaimGroup *group; | |
84 GaimBlistNode *node = (GaimBlistNode *)buddy; | |
85 if (node->ui_data) | |
86 return; | |
68 | 87 |
88 group = gaim_buddy_get_group(buddy); | |
69 add_group(group, ggblist); | 89 add_group(group, ggblist); |
70 | 90 |
71 text = g_strdup_printf("%*s%s", TAB_SIZE, "", gaim_buddy_get_alias(buddy)); | 91 text = g_strdup_printf("%*s%s", TAB_SIZE, "", gaim_buddy_get_alias(buddy)); |
72 gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, text, group, NULL); | 92 gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, text, group, NULL); |
73 g_free(text); | 93 g_free(text); |
94 } | |
95 | |
96 static void | |
97 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) | |
98 { | |
99 add_buddy(buddy, ggblist); | |
74 } | 100 } |
75 | 101 |
76 static void | 102 static void |
77 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist) | 103 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist) |
78 { | 104 { |
90 gnt_widget_set_focus(widget, FALSE); | 116 gnt_widget_set_focus(widget, FALSE); |
91 } | 117 } |
92 | 118 |
93 void gg_blist_init() | 119 void gg_blist_init() |
94 { | 120 { |
95 ggblist = g_new0(GGBlist, 1); | 121 if (ggblist == NULL) |
122 ggblist = g_new0(GGBlist, 1); | |
96 | 123 |
97 ggblist->window = gnt_box_new(FALSE, FALSE); | 124 ggblist->window = gnt_box_new(FALSE, FALSE); |
125 GNT_WIDGET_UNSET_FLAGS(ggblist->window, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); | |
98 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); | 126 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); |
127 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); | |
99 | 128 |
100 ggblist->tree = gnt_tree_new(); | 129 ggblist->tree = gnt_tree_new(); |
101 gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr)); | 130 GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER); |
131 gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr) - 2); | |
102 | 132 |
103 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); | 133 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); |
104 gnt_widget_show(ggblist->window); | 134 gnt_widget_show(ggblist->window); |
105 | 135 |
106 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gg_blist_get_handle(), | 136 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gg_blist_get_handle(), |