Mercurial > pidgin
comparison console/gntblist.c @ 13850:0e1e59770cb0
[gaim-migrate @ 16308]
This is my first commit here. So don't yell at me if things get borked.
Also, I haven't looked at the auto-thingies yet. So don't puke at the
Makefiles.
Files in console/libgnt/ are for the 'Gaim/GObjectified Ncurses Toolkit'
library. Files in console/ uses libgaim and libgnt. Currently, only the
buddylist-ui is 'functional', ie. the buddy-list updates when someone
logs on or logs off. It still needs a lot of work.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Thu, 22 Jun 2006 08:33:54 +0000 |
parents | |
children | bbf0470cb348 |
comparison
equal
deleted
inserted
replaced
13849:8d1c55309e3c | 13850:0e1e59770cb0 |
---|---|
1 #include <gaim/account.h> | |
2 #include <gaim/blist.h> | |
3 #include <signal.h> | |
4 #include <gaim/util.h> | |
5 #include <gaim/server.h> | |
6 | |
7 #include "gntgaim.h" | |
8 #include "gntbox.h" | |
9 #include "gnttree.h" | |
10 | |
11 #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 | |
36 typedef struct | |
37 { | |
38 GntWidget *window; | |
39 GntWidget *tree; | |
40 } GGBlist; | |
41 | |
42 GGBlist *ggblist; | |
43 | |
44 static gpointer | |
45 gg_blist_get_handle() | |
46 { | |
47 static int handle; | |
48 | |
49 return &handle; | |
50 } | |
51 | |
52 static void | |
53 add_group(GaimGroup *group, GGBlist *ggblist) | |
54 { | |
55 GaimBlistNode *node = (GaimBlistNode *)group; | |
56 if (node->ui_data) | |
57 return; | |
58 gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, | |
59 group->name, NULL, NULL); | |
60 node->ui_data = GINT_TO_POINTER(TRUE); | |
61 } | |
62 | |
63 static void | |
64 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist) | |
65 { | |
66 GaimGroup *group = gaim_buddy_get_group(buddy); | |
67 char *text; | |
68 | |
69 add_group(group, ggblist); | |
70 | |
71 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); | |
73 g_free(text); | |
74 } | |
75 | |
76 static void | |
77 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist) | |
78 { | |
79 gnt_tree_remove(GNT_TREE(ggblist->tree), buddy); | |
80 } | |
81 | |
82 GaimBlistUiOps *gg_get_blist_ui_ops() | |
83 { | |
84 return &blist_ui_ops; | |
85 } | |
86 | |
87 static void | |
88 selection_activate(GntWidget *widget, GGBlist *ggblist) | |
89 { | |
90 gnt_widget_set_focus(widget, FALSE); | |
91 } | |
92 | |
93 void gg_blist_init() | |
94 { | |
95 ggblist = g_new0(GGBlist, 1); | |
96 | |
97 ggblist->window = gnt_box_new(FALSE, FALSE); | |
98 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); | |
99 | |
100 ggblist->tree = gnt_tree_new(); | |
101 gnt_widget_set_size(ggblist->tree, 25, getmaxy(stdscr)); | |
102 | |
103 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); | |
104 gnt_widget_show(ggblist->window); | |
105 | |
106 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gg_blist_get_handle(), | |
107 GAIM_CALLBACK(buddy_signed_on), ggblist); | |
108 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gg_blist_get_handle(), | |
109 GAIM_CALLBACK(buddy_signed_off), ggblist); | |
110 | |
111 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); | |
112 | |
113 /*gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", gg_blist_get_handle(),*/ | |
114 /*GAIM_CALLBACK(received_im_msg), list);*/ | |
115 /*gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", gg_blist_get_handle(),*/ | |
116 /*GAIM_CALLBACK(sent_im_msg), NULL);*/ | |
117 | |
118 /*gaim_signal_connect(gaim_conversations_get_handle(), "received-chat-msg", gg_blist_get_handle(),*/ | |
119 /*GAIM_CALLBACK(received_chat_msg), list);*/ | |
120 } | |
121 |