annotate console/gntblist.c @ 13990:ff4ee4ac4408

[gaim-migrate @ 16563] Reverted [16528] as per gaim-devel discussion committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Mon, 24 Jul 2006 16:19:16 +0000
parents 0a0d2a1fd2bc
children 7573bd40a190
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13877
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
1 #include <account.h>
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
2 #include <blist.h>
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
3 #include <request.h>
13877
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
4 #include <server.h>
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include <signal.h>
13877
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
6 #include <util.h>
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 #include "gntgaim.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 #include "gntbox.h"
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
10 #include "gntlabel.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 #include "gnttree.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
13 #include "gntblist.h"
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
14 #include <string.h>
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 typedef struct
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 GntWidget *window;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 GntWidget *tree;
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
20
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
21 GntWidget *tooltip;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
22 GaimBlistNode *tnode; /* Who is the tooltip being displayed for? */
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
23
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
24 GntWidget *context;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
25 GaimBlistNode *cnode;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 } GGBlist;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 GGBlist *ggblist;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
30 static void add_buddy(GaimBuddy *buddy, GGBlist *ggblist);
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
31 static void add_group(GaimGroup *group, GGBlist *ggblist);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
32 static void add_chat(GaimChat *chat, GGBlist *ggblist);
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
33 static void add_node(GaimBlistNode *node, GGBlist *ggblist);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
34 static void draw_tooltip(GGBlist *ggblist);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
35 static void remove_peripherals(GGBlist *ggblist);
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
36
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
37 static void
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
38 new_node(GaimBlistNode *node)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
39 {
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
40 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
41
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
42 static void add_node(GaimBlistNode *node, GGBlist *ggblist)
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
43 {
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
44 if (GAIM_BLIST_NODE_IS_BUDDY(node))
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
45 add_buddy((GaimBuddy*)node, ggblist);
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
46 else if (GAIM_BLIST_NODE_IS_GROUP(node))
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
47 add_group((GaimGroup*)node, ggblist);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
48 else if (GAIM_BLIST_NODE_IS_CHAT(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
49 add_chat((GaimChat *)node, ggblist);
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
50 draw_tooltip(ggblist);
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
51 }
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
52
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
53 static void
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
54 remove_tooltip(GGBlist *ggblist)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
55 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
56 gnt_widget_destroy(ggblist->tooltip);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
57 ggblist->tooltip = NULL;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
58 ggblist->tnode = NULL;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
59 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
60
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
61 static void
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
62 node_remove(GaimBuddyList *list, GaimBlistNode *node)
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
63 {
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
64 GGBlist *ggblist = list->ui_data;
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
65
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
66 if (node->ui_data == NULL)
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
67 return;
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
68
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
69 gnt_tree_remove(GNT_TREE(ggblist->tree), node);
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
70 node->ui_data = NULL;
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
71
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
72 /* XXX: Depending on the node, we may want to remove the group/contact node if necessary */
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
73 if (GAIM_BLIST_NODE_IS_BUDDY(node))
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
74 {
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
75 GaimGroup *group = gaim_buddy_get_group((GaimBuddy*)node);
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
76 if (gaim_blist_get_group_online_count(group) == 0)
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
77 node_remove(list, (GaimBlistNode*)group);
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
78 }
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
79 draw_tooltip(ggblist);
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
80 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
81
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
82 static void
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
83 node_update(GaimBuddyList *list, GaimBlistNode *node)
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
84 {
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
85 if (GAIM_BLIST_NODE_IS_BUDDY(node))
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
86 {
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
87 GaimBuddy *buddy = (GaimBuddy*)node;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
88 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy)))
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
89 add_node((GaimBlistNode*)buddy, list->ui_data);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
90 else
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
91 node_remove(gaim_get_blist(), node);
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
92 }
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
93 else if (GAIM_BLIST_NODE_IS_CHAT(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
94 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
95 add_chat((GaimChat *)node, list->ui_data);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
96 }
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
97 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
98
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
99 static void
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
100 new_list(GaimBuddyList *list)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
101 {
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
102 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
103
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
104 static GaimBlistUiOps blist_ui_ops =
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
105 {
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
106 new_list,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
107 new_node,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
108 NULL,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
109 node_update, /* This doesn't do crap */
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
110 node_remove,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
111 NULL,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
112 NULL,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
113 NULL,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
114 NULL,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
115 NULL
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
116 };
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
117
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 static gpointer
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 gg_blist_get_handle()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 static int handle;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 return &handle;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 add_group(GaimGroup *group, GGBlist *ggblist)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 GaimBlistNode *node = (GaimBlistNode *)group;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 if (node->ui_data)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 return;
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
132 gnt_tree_remove(GNT_TREE(ggblist->tree), group);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
133 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group,
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
134 gnt_tree_create_row(GNT_TREE(ggblist->tree), group->name), NULL, NULL);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
137 static const char *
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
138 get_display_name(GaimBlistNode *node)
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
139 {
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
140 static char text[2096];
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
141 char status[8] = " ";
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
142 const char *name = NULL;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
143
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
144 if (GAIM_BLIST_NODE_IS_BUDDY(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
145 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
146 GaimBuddy *buddy = (GaimBuddy *)node;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
147 GaimStatusPrimitive prim;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
148 GaimPresence *presence;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
149 GaimStatus *now;
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
150 gboolean ascii = gnt_ascii_only();
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
151
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
152 presence = gaim_buddy_get_presence(buddy);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
153 now = gaim_presence_get_active_status(presence);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
154
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
155 prim = gaim_status_type_get_primitive(gaim_status_get_type(now));
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
156
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
157 switch(prim)
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
158 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
159 case GAIM_STATUS_OFFLINE:
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
160 strncpy(status, ascii ? "x" : "⊗", sizeof(status) - 1);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
161 break;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
162 case GAIM_STATUS_AVAILABLE:
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
163 strncpy(status, ascii ? "o" : "â—¯", sizeof(status) - 1);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
164 break;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
165 default:
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
166 strncpy(status, ascii ? "." : "⊖", sizeof(status) - 1);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
167 break;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
168 }
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
169 name = gaim_buddy_get_alias(buddy);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
170 }
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
171 else if (GAIM_BLIST_NODE_IS_CHAT(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
172 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
173 GaimChat *chat = (GaimChat*)node;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
174 name = gaim_chat_get_name(chat);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13884
diff changeset
175
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13884
diff changeset
176 strncpy(status, "~", sizeof(status) - 1);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
177 }
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
178
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
179 snprintf(text, sizeof(text) - 1, "%s %s", status, name);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
180
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
181 return text;
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
182 }
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
183
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 static void
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
185 add_chat(GaimChat *chat, GGBlist *ggblist)
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
186 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
187 GaimGroup *group;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
188 GaimBlistNode *node = (GaimBlistNode *)chat;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
189 if (node->ui_data)
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
190 return;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
191
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
192 group = gaim_chat_get_group(chat);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
193 add_node((GaimBlistNode*)group, ggblist);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
194
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
195 gnt_tree_remove(GNT_TREE(ggblist->tree), chat);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
196 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat,
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
197 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
198 group, NULL);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
199 }
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
200
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
201 static void
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
202 add_buddy(GaimBuddy *buddy, GGBlist *ggblist)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 {
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
204 GaimGroup *group;
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
205 GaimBlistNode *node = (GaimBlistNode *)buddy;
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
206 if (node->ui_data)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
207 return;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
209 group = gaim_buddy_get_group(buddy);
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
210 add_node((GaimBlistNode*)group, ggblist);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
212 gnt_tree_remove(GNT_TREE(ggblist->tree), buddy);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
213 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy,
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
214 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
215 group, NULL);
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
216 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy)))
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
217 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM);
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
218 else
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
219 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
222 #if 0
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 static void
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
224 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
225 {
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
226 add_node((GaimBlistNode*)buddy, ggblist);
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
227 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
228
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
229 static void
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 {
13861
55fb5cd9bac9 [gaim-migrate @ 16322]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
232 node_remove(gaim_get_blist(), (GaimBlistNode*)buddy);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 }
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
234 #endif
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
236 GaimBlistUiOps *gg_blist_get_ui_ops()
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 return &blist_ui_ops;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 selection_activate(GntWidget *widget, GGBlist *ggblist)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 {
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
244 GntTree *tree = GNT_TREE(ggblist->tree);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
245 GaimBlistNode *node = gnt_tree_get_selection_data(tree);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
246
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
247 if (!node)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
248 return;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
249
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
250 if (GAIM_BLIST_NODE_IS_BUDDY(node))
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
251 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
252 GaimBuddy *buddy = (GaimBuddy *)node;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
253 gaim_conversation_new(GAIM_CONV_TYPE_IM,
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
254 gaim_buddy_get_account(buddy),
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
255 gaim_buddy_get_name(buddy));
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
256 }
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
257 else if (GAIM_BLIST_NODE_IS_CHAT(node))
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
258 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
259 GaimChat *chat = (GaimChat*)node;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
260 serv_join_chat(chat->account->gc, chat->components);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
261 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
264 static void
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
265 remove_context_menu(GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
266 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
267 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
268 gnt_widget_destroy(ggblist->context->parent);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
269 ggblist->context = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
270 ggblist->cnode = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
271 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
272
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
273 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
274 gnt_append_menu_action(GntTree *tree, GaimMenuAction *action, gpointer parent)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
275 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
276 GList *list;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
277
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
278 gnt_tree_add_row_after(tree, action,
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
279 gnt_tree_create_row(tree, action->label), parent, NULL);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
280 for (list = action->children; list; list = list->next)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
281 gnt_append_menu_action(tree, list->data, action);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
282 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
283
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
284 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
285 append_proto_menu(GntTree *tree, GaimConnection *gc, GaimBlistNode *node)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
286 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
287 GList *list;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
288 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
289
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
290 if(!prpl_info || !prpl_info->blist_node_menu)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
291 return;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
292
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
293 for(list = prpl_info->blist_node_menu(node); list;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
294 list = g_list_delete_link(list, list))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
295 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
296 GaimMenuAction *act = (GaimMenuAction *) list->data;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
297 gnt_append_menu_action(tree, act, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
298 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
299 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
300
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
301 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
302 add_custom_action(GntTree *tree, const char *label, GaimCallback callback,
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
303 gpointer data)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
304 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
305 GaimMenuAction *action = gaim_menu_action_new(label, callback, data, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
306 gnt_append_menu_action(tree, action, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
307 g_signal_connect_swapped(G_OBJECT(tree), "destroy",
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
308 G_CALLBACK(gaim_menu_action_free), action);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
309 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
310
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
311 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
312 create_chat_menu(GntTree *tree, GaimChat *chat)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
313 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
314 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
315
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
316 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
317 create_group_menu(GntTree *tree, GaimGroup *group)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
318 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
319 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
320
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
321 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
322 gg_blist_get_buddy_info_cb(GaimBuddy *buddy, GaimBlistNode *null)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
323 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
324 serv_get_info(buddy->account->gc, gaim_buddy_get_name(buddy));
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
325 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
326
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
327 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
328 create_buddy_menu(GntTree *tree, GaimBuddy *buddy)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
329 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
330 GaimPluginProtocolInfo *prpl_info;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
331
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
332 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
333 if (prpl_info && prpl_info->get_info)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
334 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
335 add_custom_action(tree, _("Get Info"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
336 GAIM_CALLBACK(gg_blist_get_buddy_info_cb), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
337 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
338
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
339 #if 0
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
340 add_custom_action(tree, _("Add Buddy Pounce"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
341 GAIM_CALLBACK(gg_blist_add_buddy_pounce_cb)), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
342
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
343 if (prpl_info && prpl_info->send_file)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
344 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
345 if (!prpl_info->can_receive_file ||
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
346 prpl_info->can_receive_file(buddy->account->gc, buddy->name))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
347 add_custom_action(tree, _("Send File"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
348 GAIM_CALLBACK(gg_blist_show_file_cb)), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
349 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
350
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
351 add_custom_action(tree, _("View Log"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
352 GAIM_CALLBACK(gg_blist_view_log_cb)), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
353 #endif
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
354
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
355 /* Protocol actions */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
356 append_proto_menu(tree,
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
357 gaim_account_get_connection(gaim_buddy_get_account(buddy)),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
358 (GaimBlistNode*)buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
359 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
360
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
361 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
362 append_extended_menu(GntTree *tree, GaimBlistNode *node)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
363 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
364 GList *iter;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
365
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
366 for (iter = gaim_blist_node_get_extended_menu(node);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
367 iter; iter = g_list_delete_link(iter, iter))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
368 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
369 gnt_append_menu_action(tree, iter->data, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
370 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
371 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
372
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
373 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
374 context_menu_callback(GntTree *tree, GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
375 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
376 GaimMenuAction *action = gnt_tree_get_selection_data(tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
377 GaimBlistNode *node = ggblist->cnode;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
378
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
379 if (action)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
380 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
381 void (*callback)(GaimBlistNode *, gpointer);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
382 callback = (void (*)(GaimBlistNode *, gpointer))action->callback;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
383 callback(node, action->data);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
384 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
385
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
386 remove_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
387 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
388
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
389 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
390 gg_blist_rename_node_cb(GaimBlistNode *node, GaimBlistNode *null)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
391 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
392 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
393
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
394 /* XXX: This still doesn't do anything, because request doesn't have a ui yet */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
395 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
396 gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *null)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
397 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
398 void (*callback)(gpointer);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
399
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
400 if (GAIM_BLIST_NODE_IS_BUDDY(node))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
401 callback = (void(*)(gpointer))gaim_blist_remove_buddy;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
402 else if (GAIM_BLIST_NODE_IS_CHAT(node))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
403 callback = (void(*)(gpointer))gaim_blist_remove_chat;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
404 else if (GAIM_BLIST_NODE_IS_GROUP(node))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
405 callback = (void(*)(gpointer))gaim_blist_remove_group;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
406
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
407 /* XXX: anything to do with the returned ui-handle? */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
408 gaim_request_action(node, _("Confirm Remove"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
409 _("Are you sure you want to remove ..."), NULL, /* XXX: tidy up */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
410 1, node, 2,
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
411 _("Remove"), callback,
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
412 _("No"), NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
413
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
414 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
415
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
416 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
417 draw_context_menu(GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
418 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
419 GaimBlistNode *node = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
420 GntWidget *context = NULL, *window = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
421 GntTree *tree = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
422 int x, y, top, width;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
423 char *title = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
424
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
425 tree = GNT_TREE(ggblist->tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
426
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
427 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
428 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
429 remove_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
430 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
431
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
432 node = gnt_tree_get_selection_data(tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
433
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
434 if (node == NULL)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
435 return;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
436 if (ggblist->tooltip)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
437 remove_tooltip(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
438
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
439 ggblist->cnode = node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
440 ggblist->context = context = gnt_tree_new();
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
441 GNT_WIDGET_SET_FLAGS(context, GNT_WIDGET_NO_BORDER);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
442 gnt_widget_set_name(context, "context menu");
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
443 g_signal_connect(G_OBJECT(context), "activate", G_CALLBACK(context_menu_callback), ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
444
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
445 if (GAIM_BLIST_NODE_IS_BUDDY(node))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
446 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
447 GaimBuddy *buddy = (GaimBuddy *)node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
448 create_buddy_menu(GNT_TREE(context), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
449 title = g_strdup(gaim_buddy_get_name(buddy));
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
450 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
451 else if (GAIM_BLIST_NODE_IS_CHAT(node))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
452 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
453 GaimChat *chat = (GaimChat*)node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
454 create_chat_menu(GNT_TREE(context), chat);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
455 title = g_strdup(gaim_chat_get_name(chat));
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
456 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
457 else if (GAIM_BLIST_NODE_IS_GROUP(node))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
458 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
459 GaimGroup *group = (GaimGroup *)node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
460 create_group_menu(GNT_TREE(context), group);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
461 title = g_strdup(group->name);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
462 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
463
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
464 append_extended_menu(GNT_TREE(context), node);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
465
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
466 /* These are common for everything */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
467 add_custom_action(GNT_TREE(context), _("Rename"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
468 GAIM_CALLBACK(gg_blist_rename_node_cb), node);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
469 add_custom_action(GNT_TREE(context), _("Remove"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
470 GAIM_CALLBACK(gg_blist_remove_node_cb), node);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
471
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
472 window = gnt_vbox_new(FALSE);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
473 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
474 gnt_box_set_title(GNT_BOX(window), title);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
475
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
476 gnt_box_add_widget(GNT_BOX(window), context);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
477
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
478 /* Set the position for the popup */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
479 gnt_widget_get_position(GNT_WIDGET(tree), &x, &y);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
480 gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
481 top = gnt_tree_get_selection_visible_line(tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
482
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
483 x += width;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
484 y += top - 1;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
485
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
486 gnt_widget_set_position(window, x, y);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
487 gnt_widget_draw(window);
13959
2ae35c0cf616 [gaim-migrate @ 16511]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13958
diff changeset
488 g_free(title);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
489 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
490
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
491 static void
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
492 draw_tooltip(GGBlist *ggblist)
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
493 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
494 GaimBlistNode *node;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
495 int x, y, top, width;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
496 GString *str;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
497 GaimPlugin *prpl;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
498 GaimPluginProtocolInfo *prpl_info;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
499 GaimAccount *account;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
500 GntTree *tree;
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
501 GntWidget *widget, *box;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
502 char *title = NULL;
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
503
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
504 widget = ggblist->tree;
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
505 tree = GNT_TREE(widget);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
506
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
507 if (!gnt_widget_has_focus(ggblist->tree))
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
508 return;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
509
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
510 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
511 return;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
512
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
513 if (ggblist->tooltip)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
514 {
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
515 /* XXX: Once we can properly redraw on expose events, this can be removed at the end
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
516 * to avoid the blinking*/
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
517 remove_tooltip(ggblist);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
518 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
519
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
520 node = gnt_tree_get_selection_data(tree);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
521 if (!node)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
522 return;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
523
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
524 str = g_string_new("");
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
525
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
526 if (GAIM_BLIST_NODE_IS_BUDDY(node))
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
527 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
528 GaimBuddy *buddy = (GaimBuddy *)node;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
529 account = gaim_buddy_get_account(buddy);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
530
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
531 g_string_append_printf(str, _("Account: %s (%s)"),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
532 gaim_account_get_username(account),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
533 gaim_account_get_protocol_name(account));
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
534
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
535 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
536 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
537 if (prpl_info && prpl_info->tooltip_text)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
538 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
539 GString *tip = g_string_new("");
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
540 char *strip, *br;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
541 prpl_info->tooltip_text(buddy, tip, TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
542
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
543 br = gaim_strreplace(tip->str, "\n", "<br>");
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
544 strip = gaim_markup_strip_html(br);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
545 g_string_append(str, strip);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
546 g_string_free(tip, TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
547 g_free(strip);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
548 g_free(br);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
549 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
550
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
551 title = g_strdup(gaim_buddy_get_name(buddy));
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
552 }
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
553 else if (GAIM_BLIST_NODE_IS_GROUP(node))
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
554 {
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
555 GaimGroup *group = (GaimGroup *)node;
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
556
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
557 g_string_append_printf(str, _("Online: %d\nTotal: %d"),
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
558 gaim_blist_get_group_online_count(group),
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
559 gaim_blist_get_group_size(group, FALSE));
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
560
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
561 title = g_strdup(group->name);
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
562 }
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
563 else if (GAIM_BLIST_NODE_IS_CHAT(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
564 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
565 GaimChat *chat = (GaimChat *)node;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
566 GaimAccount *account = chat->account;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
567
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
568 g_string_append_printf(str, _("Account: %s (%s)"),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
569 gaim_account_get_username(account),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
570 gaim_account_get_protocol_name(account));
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
571
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
572 title = g_strdup(gaim_chat_get_name(chat));
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
573 }
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
574 else
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
575 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
576 g_string_free(str, TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
577 return;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
578 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
579
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
580 gnt_widget_get_position(widget, &x, &y);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
581 gnt_widget_get_size(widget, &width, NULL);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
582 top = gnt_tree_get_selection_visible_line(tree);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
583
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
584 x += width;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
585 y += top - 1;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
586
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
587 box = gnt_box_new(FALSE, FALSE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
588 gnt_box_set_toplevel(GNT_BOX(box), TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
589 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
590 gnt_box_set_title(GNT_BOX(box), title);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
591
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
592 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(str->str));
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
593
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
594 gnt_widget_set_position(box, x, y);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
595 GNT_WIDGET_UNSET_FLAGS(box, GNT_WIDGET_CAN_TAKE_FOCUS);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
596 gnt_widget_draw(box);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
597
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
598 g_free(title);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
599 g_string_free(str, TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
600 ggblist->tooltip = box;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
601 ggblist->tnode = node;
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
602
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
603 gnt_widget_set_name(ggblist->tooltip, "tooltip");
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
604 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
605
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
606 static void
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
607 selection_changed(GntWidget *widget, gpointer old, gpointer current, GGBlist *ggblist)
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
608 {
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
609 draw_tooltip(ggblist);
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
610 }
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
611
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
612 static gboolean
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
613 key_pressed(GntWidget *widget, const char *text, GGBlist *ggblist)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
614 {
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
615 gboolean stop = FALSE, ret = FALSE;
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
616 if (text[0] == 27 && text[1] == 0)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
617 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
618 /* Escape was pressed */
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
619 remove_peripherals(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
620 stop = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
621 ret = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
622 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
623
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
624 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
625 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
626 ret = gnt_widget_key_pressed(ggblist->context, text);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
627 stop = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
628 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
629
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
630 if (text[0] == 27)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
631 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
632 if (strcmp(text + 1, GNT_KEY_POPUP) == 0)
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
633 {
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
634 draw_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
635 stop = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
636 ret = TRUE;
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
637 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
638 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13884
diff changeset
639
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
640 if (stop)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
641 g_signal_stop_emission_by_name(G_OBJECT(widget), "key_pressed");
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
642
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
643 return ret;
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
644 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
645
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
646 static void
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
647 update_buddy_display(GaimBuddy *buddy, GGBlist *ggblist)
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
648 {
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
649 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((GaimBlistNode*)buddy));
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
650 if (ggblist->tnode == (GaimBlistNode*)buddy)
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
651 draw_tooltip(ggblist);
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
652
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
653 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy)))
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
654 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM);
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
655 else
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
656 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0);
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
657 }
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
658
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
659 static void
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
660 buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist)
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
661 {
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
662 update_buddy_display(buddy, ggblist);
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
663 }
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
664
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
665 static void
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
666 buddy_idle_changed(GaimBuddy *buddy, int old, int new, GGBlist *ggblist)
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
667 {
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
668 update_buddy_display(buddy, ggblist);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
669 }
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
670
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
671 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
672 remove_peripherals(GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
673 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
674 if (ggblist->tooltip)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
675 remove_tooltip(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
676 else if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
677 remove_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
678 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
679
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
680 void gg_blist_init()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
681 {
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
682 ggblist = g_new0(GGBlist, 1);
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
683
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
684 gaim_get_blist()->ui_data = ggblist;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
685
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
686 ggblist->window = gnt_box_new(FALSE, FALSE);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
687 gnt_widget_set_name(ggblist->window, "buddylist");
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
688 gnt_box_set_toplevel(GNT_BOX(ggblist->window), TRUE);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
689 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List"));
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
690 gnt_box_set_pad(GNT_BOX(ggblist->window), 0);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
691
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
692 ggblist->tree = gnt_tree_new();
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
693 GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER);
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
694 gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0, 25);
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
695 gnt_widget_set_size(ggblist->tree, 0, getmaxy(stdscr) - 4);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
696
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
697 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
698 gnt_widget_show(ggblist->window);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
699
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
700 gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", gg_blist_get_handle(),
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
701 GAIM_CALLBACK(buddy_status_changed), ggblist);
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
702 gaim_signal_connect(gaim_blist_get_handle(), "buddy-idle-changed", gg_blist_get_handle(),
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
703 GAIM_CALLBACK(buddy_idle_changed), ggblist);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
704
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
705 #if 0
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
706 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gg_blist_get_handle(),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
707 GAIM_CALLBACK(buddy_signed_on), ggblist);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
708 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gg_blist_get_handle(),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
709 GAIM_CALLBACK(buddy_signed_off), ggblist);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
710
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
711 /* These I plan to use to indicate unread-messages etc. */
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
712 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", gg_blist_get_handle(),
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
713 GAIM_CALLBACK(received_im_msg), list);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
714 gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", gg_blist_get_handle(),
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
715 GAIM_CALLBACK(sent_im_msg), NULL);
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
716
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
717 gaim_signal_connect(gaim_conversations_get_handle(), "received-chat-msg", gg_blist_get_handle(),
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
718 GAIM_CALLBACK(received_chat_msg), list);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
719 #endif
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
720
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
721 g_signal_connect(G_OBJECT(ggblist->tree), "selection_changed", G_CALLBACK(selection_changed), ggblist);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
722 g_signal_connect(G_OBJECT(ggblist->tree), "key_pressed", G_CALLBACK(key_pressed), ggblist);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
723 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
724 g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip),
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
725 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
726 g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals),
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
727 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
728 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
729
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
730 void gg_blist_uninit()
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
731 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
732 gnt_widget_destroy(ggblist->window);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
733 g_free(ggblist);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
734 ggblist = NULL;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
735 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
736
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
737 void gg_blist_get_position(int *x, int *y)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
738 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
739 gnt_widget_get_position(ggblist->window, x, y);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
740 }
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
741
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
742 void gg_blist_set_position(int x, int y)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
743 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
744 gnt_widget_set_position(ggblist->window, x, y);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
745 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
746
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
747 void gg_blist_get_size(int *width, int *height)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
748 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
749 gnt_widget_get_size(ggblist->window, width, height);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
750 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
751
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
752 void gg_blist_set_size(int width, int height)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
753 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
754 gnt_widget_set_size(ggblist->window, width, height);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
755 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
756