Mercurial > pidgin
annotate finch/gntblist.c @ 21727:1a27ded7f9e3
Fix the fix for incorrect callback types.
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 02 Dec 2007 17:36:50 +0000 |
parents | 52bbf38a1cd2 |
children | e3e64d1e4869 |
rev | line source |
---|---|
15817 | 1 /** |
2 * @file gntblist.c GNT BuddyList API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
16106
diff
changeset
|
3 * @ingroup finch |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
6 /* finch |
15817 | 7 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15843
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 9 * to list here. Please refer to the COPYRIGHT file distributed with this |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19375
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15817 | 25 */ |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18071
diff
changeset
|
26 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18071
diff
changeset
|
27 |
15817 | 28 #include <account.h> |
29 #include <blist.h> | |
30 #include <notify.h> | |
31 #include <request.h> | |
32 #include <savedstatuses.h> | |
33 #include <server.h> | |
34 #include <signal.h> | |
35 #include <status.h> | |
36 #include <util.h> | |
37 #include "debug.h" | |
38 | |
39 #include "gntbox.h" | |
21691
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
40 #include "gntcolors.h" |
15817 | 41 #include "gntcombobox.h" |
42 #include "gntentry.h" | |
43 #include "gntft.h" | |
44 #include "gntlabel.h" | |
45 #include "gntline.h" | |
46 #include "gntmenu.h" | |
47 #include "gntmenuitem.h" | |
48 #include "gntmenuitemcheck.h" | |
49 #include "gntpounce.h" | |
21691
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
50 #include "gntstyle.h" |
15817 | 51 #include "gnttree.h" |
52 #include "gntutils.h" | |
53 #include "gntwindow.h" | |
54 | |
55 #include "gntblist.h" | |
56 #include "gntconv.h" | |
57 #include "gntstatus.h" | |
58 #include <string.h> | |
59 | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16276
diff
changeset
|
60 #define PREF_ROOT "/finch/blist" |
15817 | 61 #define TYPING_TIMEOUT 4000 |
62 | |
63 typedef struct | |
64 { | |
65 GntWidget *window; | |
66 GntWidget *tree; | |
67 | |
68 GntWidget *tooltip; | |
15822 | 69 PurpleBlistNode *tnode; /* Who is the tooltip being displayed for? */ |
15817 | 70 GList *tagged; /* A list of tagged blistnodes */ |
71 | |
72 GntWidget *context; | |
15822 | 73 PurpleBlistNode *cnode; |
15817 | 74 |
75 /* XXX: I am KISSing */ | |
76 GntWidget *status; /* Dropdown with the statuses */ | |
77 GntWidget *statustext; /* Status message */ | |
78 int typing; | |
79 | |
80 GntWidget *menu; | |
81 /* These are the menuitems that get regenerated */ | |
82 GntMenuItem *accounts; | |
83 GntMenuItem *plugins; | |
84 } FinchBlist; | |
85 | |
86 typedef enum | |
87 { | |
88 STATUS_PRIMITIVE = 0, | |
89 STATUS_SAVED_POPULAR, | |
90 STATUS_SAVED_ALL, | |
91 STATUS_SAVED_NEW | |
92 } StatusType; | |
93 | |
94 typedef struct | |
95 { | |
96 StatusType type; | |
97 union | |
98 { | |
15822 | 99 PurpleStatusPrimitive prim; |
100 PurpleSavedStatus *saved; | |
15817 | 101 } u; |
102 } StatusBoxItem; | |
103 | |
18584
91fdd3e4892f
We don't need dynamic things here.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18565
diff
changeset
|
104 static FinchBlist *ggblist; |
15817 | 105 |
15822 | 106 static void add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist); |
107 static void add_contact(PurpleContact *contact, FinchBlist *ggblist); | |
108 static void add_group(PurpleGroup *group, FinchBlist *ggblist); | |
109 static void add_chat(PurpleChat *chat, FinchBlist *ggblist); | |
110 static void add_node(PurpleBlistNode *node, FinchBlist *ggblist); | |
18001
55a90b3fb1a1
Fix for the bug Alver reported:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17987
diff
changeset
|
111 static void node_update(PurpleBuddyList *list, PurpleBlistNode *node); |
15817 | 112 static void draw_tooltip(FinchBlist *ggblist); |
113 static gboolean remove_typing_cb(gpointer null); | |
114 static void remove_peripherals(FinchBlist *ggblist); | |
15822 | 115 static const char * get_display_name(PurpleBlistNode *node); |
116 static void savedstatus_changed(PurpleSavedStatus *now, PurpleSavedStatus *old); | |
117 static void blist_show(PurpleBuddyList *list); | |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
118 static void update_node_display(PurpleBlistNode *buddy, FinchBlist *ggblist); |
15822 | 119 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist); |
16771
d7ad8013b914
Fix this spectacularly braindead code. I must've been on the good stuff when I wrote this. Fixes #364.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16655
diff
changeset
|
120 static void account_signed_on_cb(PurpleConnection *pc, gpointer null); |
17203
0d9fba04fc85
Re-show the add buddy request dialog if something went wrong. It's easy to lose the buddy who just added you otherwise.
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
121 static void finch_request_add_buddy(PurpleAccount *account, const char *username, const char *grp, const char *alias); |
15817 | 122 |
123 /* Sort functions */ | |
16483
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
124 static int blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2); |
15822 | 125 static int blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2); |
126 static int blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2); | |
127 static int blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2); | |
15817 | 128 |
21691
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
129 static int color_available; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
130 static int color_away; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
131 static int color_offline; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
132 static int color_idle; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
133 |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
134 static int |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
135 get_display_color(PurpleBlistNode *node) |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
136 { |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
137 PurpleBuddy *buddy; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
138 int color = 0; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
139 |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
140 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
141 node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
142 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
143 return 0; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
144 |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
145 buddy = (PurpleBuddy*)node; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
146 if (purple_presence_is_idle(purple_buddy_get_presence(buddy))) { |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
147 color = color_idle; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
148 } else if (purple_presence_is_available(purple_buddy_get_presence(buddy))) { |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
149 color = color_available; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
150 } else if (purple_presence_is_online(purple_buddy_get_presence(buddy)) && |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
151 !purple_presence_is_available(purple_buddy_get_presence(buddy))) { |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
152 color = color_away; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
153 } else if (!purple_presence_is_online(purple_buddy_get_presence(buddy))) { |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
154 color = color_offline; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
155 } |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
156 |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
157 return color; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
158 } |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
159 |
15817 | 160 static gboolean |
15822 | 161 is_contact_online(PurpleContact *contact) |
15817 | 162 { |
15822 | 163 PurpleBlistNode *node; |
164 for (node = ((PurpleBlistNode*)contact)->child; node; node = node->next) { | |
165 if (PURPLE_BUDDY_IS_ONLINE((PurpleBuddy*)node)) | |
15817 | 166 return TRUE; |
167 } | |
168 return FALSE; | |
169 } | |
170 | |
171 static gboolean | |
15822 | 172 is_group_online(PurpleGroup *group) |
15817 | 173 { |
15822 | 174 PurpleBlistNode *node; |
175 for (node = ((PurpleBlistNode*)group)->child; node; node = node->next) { | |
18490
095718d51209
Chats aren't shown if their account is offline, so a group of offline chats shouldn't be either
Richard Nelson <wabz@pidgin.im>
parents:
18442
diff
changeset
|
176 if (PURPLE_BLIST_NODE_IS_CHAT(node) && |
095718d51209
Chats aren't shown if their account is offline, so a group of offline chats shouldn't be either
Richard Nelson <wabz@pidgin.im>
parents:
18442
diff
changeset
|
177 purple_account_is_connected(((PurpleChat *)node)->account)) |
15817 | 178 return TRUE; |
15822 | 179 else if (is_contact_online((PurpleContact*)node)) |
15817 | 180 return TRUE; |
181 } | |
182 return FALSE; | |
183 } | |
184 | |
185 static void | |
15822 | 186 new_node(PurpleBlistNode *node) |
15817 | 187 { |
188 } | |
189 | |
15822 | 190 static void add_node(PurpleBlistNode *node, FinchBlist *ggblist) |
15817 | 191 { |
15822 | 192 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
193 add_buddy((PurpleBuddy*)node, ggblist); | |
194 else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) | |
195 add_contact((PurpleContact*)node, ggblist); | |
196 else if (PURPLE_BLIST_NODE_IS_GROUP(node)) | |
197 add_group((PurpleGroup*)node, ggblist); | |
198 else if (PURPLE_BLIST_NODE_IS_CHAT(node)) | |
199 add_chat((PurpleChat *)node, ggblist); | |
15817 | 200 draw_tooltip(ggblist); |
201 } | |
202 | |
203 static void | |
204 remove_tooltip(FinchBlist *ggblist) | |
205 { | |
206 gnt_widget_destroy(ggblist->tooltip); | |
207 ggblist->tooltip = NULL; | |
208 ggblist->tnode = NULL; | |
209 } | |
210 | |
211 static void | |
15822 | 212 node_remove(PurpleBuddyList *list, PurpleBlistNode *node) |
15817 | 213 { |
214 FinchBlist *ggblist = list->ui_data; | |
215 | |
216 if (ggblist == NULL || node->ui_data == NULL) | |
217 return; | |
218 | |
219 gnt_tree_remove(GNT_TREE(ggblist->tree), node); | |
220 node->ui_data = NULL; | |
221 if (ggblist->tagged) | |
222 ggblist->tagged = g_list_remove(ggblist->tagged, node); | |
223 | |
15822 | 224 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
225 PurpleContact *contact = (PurpleContact*)node->parent; | |
226 if ((!purple_prefs_get_bool(PREF_ROOT "/showoffline") && !is_contact_online(contact)) || | |
15817 | 227 contact->currentsize < 1) |
15822 | 228 node_remove(list, (PurpleBlistNode*)contact); |
18001
55a90b3fb1a1
Fix for the bug Alver reported:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17987
diff
changeset
|
229 else |
55a90b3fb1a1
Fix for the bug Alver reported:
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17987
diff
changeset
|
230 node_update(list, (PurpleBlistNode*)contact); |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
231 } else if (!PURPLE_BLIST_NODE_IS_GROUP(node)) { |
15822 | 232 PurpleGroup *group = (PurpleGroup*)node->parent; |
18441
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
233 if ((group->currentsize < 1 && !purple_prefs_get_bool(PREF_ROOT "/emptygroups")) || |
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
234 (!purple_prefs_get_bool(PREF_ROOT "/showoffline") && !is_group_online(group))) |
15817 | 235 node_remove(list, node->parent); |
236 for (node = node->child; node; node = node->next) | |
237 node->ui_data = NULL; | |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
238 } else { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
239 for (node = node->child; node; node = node->next) |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
240 node_remove(list, node); |
15817 | 241 } |
242 | |
243 draw_tooltip(ggblist); | |
244 } | |
245 | |
246 static void | |
15822 | 247 node_update(PurpleBuddyList *list, PurpleBlistNode *node) |
15817 | 248 { |
249 /* It really looks like this should never happen ... but it does. | |
250 This will at least emit a warning to the log when it | |
251 happens, so maybe someone will figure it out. */ | |
252 g_return_if_fail(node != NULL); | |
253 | |
254 if (list->ui_data == NULL) | |
255 return; /* XXX: this is probably the place to auto-join chats */ | |
256 | |
17987
1b6db70bdab2
Fix a crash exposed by nullprpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
257 if (ggblist->window == NULL) |
1b6db70bdab2
Fix a crash exposed by nullprpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
258 return; |
1b6db70bdab2
Fix a crash exposed by nullprpl.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
259 |
15817 | 260 if (node->ui_data != NULL) { |
261 gnt_tree_change_text(GNT_TREE(ggblist->tree), node, | |
262 0, get_display_name(node)); | |
263 gnt_tree_sort_row(GNT_TREE(ggblist->tree), node); | |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
264 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), node, get_display_color(node)); |
15817 | 265 } |
266 | |
15822 | 267 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
268 PurpleBuddy *buddy = (PurpleBuddy*)node; | |
269 if (purple_account_is_connected(buddy->account) && | |
270 (PURPLE_BUDDY_IS_ONLINE(buddy) || purple_prefs_get_bool(PREF_ROOT "/showoffline"))) | |
271 add_node((PurpleBlistNode*)buddy, list->ui_data); | |
15817 | 272 else |
15822 | 273 node_remove(purple_get_blist(), node); |
15817 | 274 |
275 node_update(list, node->parent); | |
15822 | 276 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { |
277 add_chat((PurpleChat *)node, list->ui_data); | |
278 } else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { | |
279 PurpleContact *contact = (PurpleContact*)node; | |
280 if ((!purple_prefs_get_bool(PREF_ROOT "/showoffline") && !is_contact_online(contact)) || | |
15817 | 281 contact->currentsize < 1) |
15822 | 282 node_remove(purple_get_blist(), node); |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
283 else { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
284 if (node->ui_data == NULL) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
285 /* The core seems to expect the UI to add the buddies. */ |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
286 for (node = node->child; node; node = node->next) |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
287 add_node(node, list->ui_data); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
288 } |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
289 } |
15822 | 290 } else if (PURPLE_BLIST_NODE_IS_GROUP(node)) { |
291 PurpleGroup *group = (PurpleGroup*)node; | |
18441
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
292 if (!purple_prefs_get_bool(PREF_ROOT "/emptygroups") && |
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
293 ((!purple_prefs_get_bool(PREF_ROOT "/showoffline") && !is_group_online(group)) || |
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
294 group->currentsize < 1)) |
15817 | 295 node_remove(list, node); |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
296 else |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
297 add_node(node, list->ui_data); |
15817 | 298 } |
299 } | |
300 | |
301 static void | |
15822 | 302 new_list(PurpleBuddyList *list) |
15817 | 303 { |
304 if (ggblist) | |
305 return; | |
306 | |
307 ggblist = g_new0(FinchBlist, 1); | |
308 list->ui_data = ggblist; | |
309 } | |
310 | |
311 static void | |
15822 | 312 add_buddy_cb(void *data, PurpleRequestFields *allfields) |
15817 | 313 { |
15822 | 314 const char *username = purple_request_fields_get_string(allfields, "screenname"); |
315 const char *alias = purple_request_fields_get_string(allfields, "alias"); | |
316 const char *group = purple_request_fields_get_string(allfields, "group"); | |
317 PurpleAccount *account = purple_request_fields_get_account(allfields, "account"); | |
15817 | 318 const char *error = NULL; |
15822 | 319 PurpleGroup *grp; |
320 PurpleBuddy *buddy; | |
15817 | 321 |
322 if (!username) | |
323 error = _("You must provide a screename for the buddy."); | |
324 else if (!group) | |
325 error = _("You must provide a group."); | |
326 else if (!account) | |
327 error = _("You must select an account."); | |
16926
7e4a22162bb6
Show an error message when trying to add a buddy from an offline account.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16925
diff
changeset
|
328 else if (!purple_account_is_connected(account)) |
7e4a22162bb6
Show an error message when trying to add a buddy from an offline account.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16925
diff
changeset
|
329 error = _("The selected account is not online."); |
15817 | 330 |
331 if (error) | |
332 { | |
17203
0d9fba04fc85
Re-show the add buddy request dialog if something went wrong. It's easy to lose the buddy who just added you otherwise.
Richard Nelson <wabz@pidgin.im>
parents:
17091
diff
changeset
|
333 finch_request_add_buddy(account, username, group, alias); |
15822 | 334 purple_notify_error(NULL, _("Error"), _("Error adding buddy"), error); |
15817 | 335 return; |
336 } | |
337 | |
15822 | 338 grp = purple_find_group(group); |
15817 | 339 if (!grp) |
340 { | |
15822 | 341 grp = purple_group_new(group); |
342 purple_blist_add_group(grp, NULL); | |
15817 | 343 } |
344 | |
15822 | 345 buddy = purple_buddy_new(account, username, alias); |
346 purple_blist_add_buddy(buddy, NULL, grp, NULL); | |
347 purple_account_add_buddy(account, buddy); | |
15817 | 348 } |
349 | |
350 static void | |
15822 | 351 finch_request_add_buddy(PurpleAccount *account, const char *username, const char *grp, const char *alias) |
15817 | 352 { |
15822 | 353 PurpleRequestFields *fields = purple_request_fields_new(); |
354 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL); | |
355 PurpleRequestField *field; | |
15817 | 356 |
15822 | 357 purple_request_fields_add_group(fields, group); |
15817 | 358 |
15822 | 359 field = purple_request_field_string_new("screenname", _("Screen Name"), username, FALSE); |
360 purple_request_field_group_add_field(group, field); | |
15817 | 361 |
15822 | 362 field = purple_request_field_string_new("alias", _("Alias"), alias, FALSE); |
363 purple_request_field_group_add_field(group, field); | |
15817 | 364 |
15822 | 365 field = purple_request_field_string_new("group", _("Group"), grp, FALSE); |
366 purple_request_field_group_add_field(group, field); | |
15843
e74c2488448b
Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents:
15822
diff
changeset
|
367 purple_request_field_set_type_hint(field, "group"); |
15817 | 368 |
15822 | 369 field = purple_request_field_account_new("account", _("Account"), NULL); |
370 purple_request_field_account_set_show_all(field, FALSE); | |
15817 | 371 if (account) |
15822 | 372 purple_request_field_account_set_value(field, account); |
373 purple_request_field_group_add_field(group, field); | |
15817 | 374 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
375 purple_request_fields(NULL, _("Add Buddy"), NULL, _("Please enter buddy information."), |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
376 fields, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
377 _("Add"), G_CALLBACK(add_buddy_cb), |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
378 _("Cancel"), NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
379 account, NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
380 NULL); |
15817 | 381 } |
382 | |
383 static void | |
15822 | 384 add_chat_cb(void *data, PurpleRequestFields *allfields) |
15817 | 385 { |
15822 | 386 PurpleAccount *account; |
15817 | 387 const char *alias, *name, *group; |
15822 | 388 PurpleChat *chat; |
389 PurpleGroup *grp; | |
15817 | 390 GHashTable *hash = NULL; |
15822 | 391 PurpleConnection *gc; |
18586
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
392 gboolean autojoin; |
15817 | 393 |
15822 | 394 account = purple_request_fields_get_account(allfields, "account"); |
395 name = purple_request_fields_get_string(allfields, "name"); | |
396 alias = purple_request_fields_get_string(allfields, "alias"); | |
397 group = purple_request_fields_get_string(allfields, "group"); | |
18586
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
398 autojoin = purple_request_fields_get_bool(allfields, "autojoin"); |
15817 | 399 |
15822 | 400 if (!purple_account_is_connected(account) || !name || !*name) |
15817 | 401 return; |
402 | |
403 if (!group || !*group) | |
404 group = _("Chats"); | |
405 | |
15822 | 406 gc = purple_account_get_connection(account); |
15817 | 407 |
15822 | 408 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
409 hash = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, name); | |
15817 | 410 |
15822 | 411 chat = purple_chat_new(account, name, hash); |
15817 | 412 |
413 if (chat != NULL) { | |
15822 | 414 if ((grp = purple_find_group(group)) == NULL) { |
415 grp = purple_group_new(group); | |
416 purple_blist_add_group(grp, NULL); | |
15817 | 417 } |
15822 | 418 purple_blist_add_chat(chat, grp, NULL); |
419 purple_blist_alias_chat(chat, alias); | |
18586
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
420 purple_blist_node_set_bool((PurpleBlistNode*)chat, "gnt-autojoin", autojoin); |
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
421 if (autojoin) |
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
422 serv_join_chat(chat->account->gc, chat->components); |
15817 | 423 } |
424 } | |
425 | |
426 static void | |
15822 | 427 finch_request_add_chat(PurpleAccount *account, PurpleGroup *grp, const char *alias, const char *name) |
15817 | 428 { |
15822 | 429 PurpleRequestFields *fields = purple_request_fields_new(); |
430 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL); | |
431 PurpleRequestField *field; | |
15817 | 432 |
15822 | 433 purple_request_fields_add_group(fields, group); |
15817 | 434 |
15822 | 435 field = purple_request_field_account_new("account", _("Account"), NULL); |
436 purple_request_field_account_set_show_all(field, FALSE); | |
15817 | 437 if (account) |
15822 | 438 purple_request_field_account_set_value(field, account); |
439 purple_request_field_group_add_field(group, field); | |
15817 | 440 |
15822 | 441 field = purple_request_field_string_new("name", _("Name"), name, FALSE); |
442 purple_request_field_group_add_field(group, field); | |
15817 | 443 |
15822 | 444 field = purple_request_field_string_new("alias", _("Alias"), alias, FALSE); |
445 purple_request_field_group_add_field(group, field); | |
15817 | 446 |
15822 | 447 field = purple_request_field_string_new("group", _("Group"), grp ? grp->name : NULL, FALSE); |
448 purple_request_field_group_add_field(group, field); | |
15817 | 449 |
18586
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
450 field = purple_request_field_bool_new("autojoin", _("Auto-join"), FALSE); |
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
451 purple_request_field_group_add_field(group, field); |
4fda1fc6d7cf
Add an 'auto-join' checkbox in the 'Add Chat' dialog, thanks to fmoo's
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18585
diff
changeset
|
452 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
453 purple_request_fields(NULL, _("Add Chat"), NULL, |
15817 | 454 _("You can edit more information from the context menu later."), |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
455 fields, _("Add"), G_CALLBACK(add_chat_cb), _("Cancel"), NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
456 NULL, NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
457 NULL); |
15817 | 458 } |
459 | |
460 static void | |
461 add_group_cb(gpointer null, const char *group) | |
462 { | |
15822 | 463 PurpleGroup *grp; |
15817 | 464 |
465 if (!group || !*group) | |
466 { | |
15822 | 467 purple_notify_error(NULL, _("Error"), _("Error adding group"), |
15817 | 468 _("You must give a name for the group to add.")); |
469 return; | |
470 } | |
471 | |
15822 | 472 grp = purple_find_group(group); |
15817 | 473 if (!grp) |
474 { | |
15822 | 475 grp = purple_group_new(group); |
476 purple_blist_add_group(grp, NULL); | |
15817 | 477 } |
478 else | |
479 { | |
15822 | 480 purple_notify_error(NULL, _("Error"), _("Error adding group"), |
15817 | 481 _("A group with the name already exists.")); |
482 } | |
483 } | |
484 | |
485 static void | |
486 finch_request_add_group() | |
487 { | |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
488 purple_request_input(NULL, _("Add Group"), NULL, _("Enter the name of the group"), |
15817 | 489 NULL, FALSE, FALSE, NULL, |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
490 _("Add"), G_CALLBACK(add_group_cb), _("Cancel"), NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
491 NULL, NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
492 NULL); |
15817 | 493 } |
494 | |
15822 | 495 static PurpleBlistUiOps blist_ui_ops = |
15817 | 496 { |
497 new_list, | |
498 new_node, | |
499 blist_show, | |
500 node_update, | |
501 node_remove, | |
502 NULL, | |
503 NULL, | |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16958
diff
changeset
|
504 finch_request_add_buddy, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16958
diff
changeset
|
505 finch_request_add_chat, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16958
diff
changeset
|
506 finch_request_add_group, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16958
diff
changeset
|
507 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16958
diff
changeset
|
508 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16958
diff
changeset
|
509 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16958
diff
changeset
|
510 NULL |
15817 | 511 }; |
512 | |
513 static gpointer | |
514 finch_blist_get_handle() | |
515 { | |
516 static int handle; | |
517 | |
518 return &handle; | |
519 } | |
520 | |
521 static void | |
15822 | 522 add_group(PurpleGroup *group, FinchBlist *ggblist) |
15817 | 523 { |
15822 | 524 PurpleBlistNode *node = (PurpleBlistNode *)group; |
15817 | 525 if (node->ui_data) |
526 return; | |
527 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, | |
528 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), NULL, NULL); | |
16105
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
529 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), node, |
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
530 !purple_blist_node_get_bool(node, "collapsed")); |
15817 | 531 } |
532 | |
533 static const char * | |
15822 | 534 get_display_name(PurpleBlistNode *node) |
15817 | 535 { |
536 static char text[2096]; | |
537 char status[8] = " "; | |
538 const char *name = NULL; | |
539 | |
15822 | 540 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
541 node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); /* XXX: this can return NULL?! */ | |
15817 | 542 |
543 if (node == NULL) | |
544 return NULL; | |
545 | |
15822 | 546 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
15817 | 547 { |
15822 | 548 PurpleBuddy *buddy = (PurpleBuddy *)node; |
549 PurpleStatusPrimitive prim; | |
550 PurplePresence *presence; | |
551 PurpleStatus *now; | |
15817 | 552 gboolean ascii = gnt_ascii_only(); |
553 | |
15822 | 554 presence = purple_buddy_get_presence(buddy); |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
555 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
556 strncpy(status, ascii ? ":" : "☎", sizeof(status) - 1); |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
557 else { |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
558 now = purple_presence_get_active_status(presence); |
15817 | 559 |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
560 prim = purple_status_type_get_primitive(purple_status_get_type(now)); |
15817 | 561 |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
562 switch(prim) { |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
563 case PURPLE_STATUS_OFFLINE: |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
564 strncpy(status, ascii ? "x" : "⊗", sizeof(status) - 1); |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
565 break; |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
566 case PURPLE_STATUS_AVAILABLE: |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
567 strncpy(status, ascii ? "o" : "â—¯", sizeof(status) - 1); |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
568 break; |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
569 default: |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
570 strncpy(status, ascii ? "." : "⊖", sizeof(status) - 1); |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
571 break; |
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
572 } |
15817 | 573 } |
15822 | 574 name = purple_buddy_get_alias(buddy); |
15817 | 575 } |
15822 | 576 else if (PURPLE_BLIST_NODE_IS_CHAT(node)) |
15817 | 577 { |
15822 | 578 PurpleChat *chat = (PurpleChat*)node; |
579 name = purple_chat_get_name(chat); | |
15817 | 580 |
581 strncpy(status, "~", sizeof(status) - 1); | |
582 } | |
15822 | 583 else if (PURPLE_BLIST_NODE_IS_GROUP(node)) |
584 return ((PurpleGroup*)node)->name; | |
15817 | 585 |
586 snprintf(text, sizeof(text) - 1, "%s %s", status, name); | |
587 | |
588 return text; | |
589 } | |
590 | |
591 static void | |
15822 | 592 add_chat(PurpleChat *chat, FinchBlist *ggblist) |
15817 | 593 { |
15822 | 594 PurpleGroup *group; |
595 PurpleBlistNode *node = (PurpleBlistNode *)chat; | |
15817 | 596 if (node->ui_data) |
597 return; | |
15822 | 598 if (!purple_account_is_connected(chat->account)) |
15817 | 599 return; |
600 | |
15822 | 601 group = purple_chat_get_group(chat); |
602 add_node((PurpleBlistNode*)group, ggblist); | |
15817 | 603 |
604 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, | |
605 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), | |
606 group, NULL); | |
607 } | |
608 | |
609 static void | |
15822 | 610 add_contact(PurpleContact *contact, FinchBlist *ggblist) |
15817 | 611 { |
15822 | 612 PurpleGroup *group; |
613 PurpleBlistNode *node = (PurpleBlistNode*)contact; | |
15817 | 614 const char *name; |
615 | |
616 if (node->ui_data) | |
617 return; | |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
618 |
15817 | 619 name = get_display_name(node); |
620 if (name == NULL) | |
621 return; | |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
622 |
15822 | 623 group = (PurpleGroup*)node->parent; |
624 add_node((PurpleBlistNode*)group, ggblist); | |
15817 | 625 |
626 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact, | |
627 gnt_tree_create_row(GNT_TREE(ggblist->tree), name), | |
628 group, NULL); | |
629 | |
630 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), contact, FALSE); | |
631 } | |
632 | |
633 static void | |
15822 | 634 add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist) |
15817 | 635 { |
15822 | 636 PurpleContact *contact; |
637 PurpleBlistNode *node = (PurpleBlistNode *)buddy; | |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
638 int color = 0; |
15817 | 639 if (node->ui_data) |
640 return; | |
641 | |
18428
1dbd8ce2f11f
Fix a bug where buddies from offline accounts were showing up.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
642 if (!purple_account_is_connected(buddy->account)) |
1dbd8ce2f11f
Fix a bug where buddies from offline accounts were showing up.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
643 return; |
1dbd8ce2f11f
Fix a bug where buddies from offline accounts were showing up.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
644 |
15822 | 645 contact = (PurpleContact*)node->parent; |
15817 | 646 if (!contact) /* When a new buddy is added and show-offline is set */ |
647 return; | |
15822 | 648 add_node((PurpleBlistNode*)contact, ggblist); |
15817 | 649 |
650 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, | |
651 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), | |
652 contact, NULL); | |
21691
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
653 |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
654 color = get_display_color((PurpleBlistNode*)buddy); |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
655 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), buddy, color); |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
656 if (buddy == purple_contact_get_priority_buddy(contact)) |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
657 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), contact, color); |
15817 | 658 } |
659 | |
660 #if 0 | |
661 static void | |
15822 | 662 buddy_signed_on(PurpleBuddy *buddy, FinchBlist *ggblist) |
15817 | 663 { |
15822 | 664 add_node((PurpleBlistNode*)buddy, ggblist); |
15817 | 665 } |
666 | |
667 static void | |
15822 | 668 buddy_signed_off(PurpleBuddy *buddy, FinchBlist *ggblist) |
15817 | 669 { |
15822 | 670 node_remove(purple_get_blist(), (PurpleBlistNode*)buddy); |
15817 | 671 } |
672 #endif | |
673 | |
15822 | 674 PurpleBlistUiOps *finch_blist_get_ui_ops() |
15817 | 675 { |
676 return &blist_ui_ops; | |
677 } | |
678 | |
679 static void | |
680 selection_activate(GntWidget *widget, FinchBlist *ggblist) | |
681 { | |
682 GntTree *tree = GNT_TREE(ggblist->tree); | |
15822 | 683 PurpleBlistNode *node = gnt_tree_get_selection_data(tree); |
15817 | 684 |
685 if (!node) | |
686 return; | |
687 | |
15822 | 688 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
689 node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); | |
15817 | 690 |
15822 | 691 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
15817 | 692 { |
15822 | 693 PurpleBuddy *buddy = (PurpleBuddy *)node; |
18071
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
694 PurpleConversation *conv; |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
695 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
696 purple_buddy_get_name(buddy), |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
697 purple_buddy_get_account(buddy)); |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
698 if (!conv) { |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
699 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
700 purple_buddy_get_account(buddy), |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
701 purple_buddy_get_name(buddy)); |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
702 } else { |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
703 FinchConv *ggconv = conv->ui_data; |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
704 gnt_window_present(ggconv->window); |
bb9cd8dfc61c
present existing conversation window if one exists
Richard Nelson <wabz@pidgin.im>
parents:
18069
diff
changeset
|
705 } |
15817 | 706 finch_conversation_set_active(conv); |
707 } | |
15822 | 708 else if (PURPLE_BLIST_NODE_IS_CHAT(node)) |
15817 | 709 { |
15822 | 710 PurpleChat *chat = (PurpleChat*)node; |
15817 | 711 serv_join_chat(chat->account->gc, chat->components); |
712 } | |
713 } | |
714 | |
715 static void | |
716 context_menu_callback(GntMenuItem *item, gpointer data) | |
717 { | |
15822 | 718 PurpleMenuAction *action = data; |
719 PurpleBlistNode *node = ggblist->cnode; | |
15817 | 720 if (action) { |
15822 | 721 void (*callback)(PurpleBlistNode *, gpointer); |
722 callback = (void (*)(PurpleBlistNode *, gpointer))action->callback; | |
15817 | 723 if (callback) |
18512
0cb139b20d65
I can pretty much swear this worked at some point. I am not sure when this
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18490
diff
changeset
|
724 callback(node, action->data); |
15817 | 725 else |
726 return; | |
727 } | |
728 } | |
729 | |
730 static void | |
15822 | 731 gnt_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer parent) |
15817 | 732 { |
733 GList *list; | |
734 GntMenuItem *item; | |
735 | |
736 if (action == NULL) | |
737 return; | |
738 | |
739 item = gnt_menuitem_new(action->label); | |
740 if (action->callback) | |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
741 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), context_menu_callback, action); |
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
742 gnt_menu_add_item(menu, GNT_MENU_ITEM(item)); |
15817 | 743 |
744 if (action->children) { | |
745 GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP); | |
746 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
747 for (list = action->children; list; list = list->next) | |
748 gnt_append_menu_action(GNT_MENU(sub), list->data, action); | |
749 } | |
750 } | |
751 | |
752 static void | |
15822 | 753 append_proto_menu(GntMenu *menu, PurpleConnection *gc, PurpleBlistNode *node) |
15817 | 754 { |
755 GList *list; | |
15822 | 756 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
15817 | 757 |
758 if(!prpl_info || !prpl_info->blist_node_menu) | |
759 return; | |
760 | |
761 for(list = prpl_info->blist_node_menu(node); list; | |
762 list = g_list_delete_link(list, list)) | |
763 { | |
15822 | 764 PurpleMenuAction *act = (PurpleMenuAction *) list->data; |
15817 | 765 act->data = node; |
766 gnt_append_menu_action(menu, act, NULL); | |
767 } | |
768 } | |
769 | |
770 static void | |
15822 | 771 add_custom_action(GntMenu *menu, const char *label, PurpleCallback callback, |
15817 | 772 gpointer data) |
773 { | |
15822 | 774 PurpleMenuAction *action = purple_menu_action_new(label, callback, data, NULL); |
15817 | 775 gnt_append_menu_action(menu, action, NULL); |
776 g_signal_connect_swapped(G_OBJECT(menu), "destroy", | |
15822 | 777 G_CALLBACK(purple_menu_action_free), action); |
15817 | 778 } |
779 | |
780 static void | |
15822 | 781 chat_components_edit_ok(PurpleChat *chat, PurpleRequestFields *allfields) |
15817 | 782 { |
783 GList *groups, *fields; | |
784 | |
15822 | 785 for (groups = purple_request_fields_get_groups(allfields); groups; groups = groups->next) { |
786 fields = purple_request_field_group_get_fields(groups->data); | |
15817 | 787 for (; fields; fields = fields->next) { |
15822 | 788 PurpleRequestField *field = fields->data; |
15817 | 789 const char *id; |
790 char *val; | |
791 | |
15822 | 792 id = purple_request_field_get_id(field); |
793 if (purple_request_field_get_type(field) == PURPLE_REQUEST_FIELD_INTEGER) | |
794 val = g_strdup_printf("%d", purple_request_field_int_get_value(field)); | |
15817 | 795 else |
15822 | 796 val = g_strdup(purple_request_field_string_get_value(field)); |
15817 | 797 |
798 g_hash_table_replace(chat->components, g_strdup(id), val); /* val should not be free'd */ | |
799 } | |
800 } | |
801 } | |
802 | |
803 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
804 chat_components_edit(PurpleBlistNode *selected, PurpleChat *chat) |
15817 | 805 { |
15822 | 806 PurpleRequestFields *fields = purple_request_fields_new(); |
807 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL); | |
808 PurpleRequestField *field; | |
15817 | 809 GList *parts, *iter; |
810 struct proto_chat_entry *pce; | |
811 | |
15822 | 812 purple_request_fields_add_group(fields, group); |
15817 | 813 |
15822 | 814 parts = PURPLE_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc); |
15817 | 815 |
816 for (iter = parts; iter; iter = iter->next) { | |
817 pce = iter->data; | |
818 if (pce->is_int) { | |
819 int val; | |
820 const char *str = g_hash_table_lookup(chat->components, pce->identifier); | |
821 if (!str || sscanf(str, "%d", &val) != 1) | |
822 val = pce->min; | |
15822 | 823 field = purple_request_field_int_new(pce->identifier, pce->label, val); |
15817 | 824 } else { |
15822 | 825 field = purple_request_field_string_new(pce->identifier, pce->label, |
15817 | 826 g_hash_table_lookup(chat->components, pce->identifier), FALSE); |
827 } | |
828 | |
15822 | 829 purple_request_field_group_add_field(group, field); |
15817 | 830 g_free(pce); |
831 } | |
832 | |
833 g_list_free(parts); | |
834 | |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
835 purple_request_fields(NULL, _("Edit Chat"), NULL, _("Please Update the necessary fields."), |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
836 fields, _("Edit"), G_CALLBACK(chat_components_edit_ok), _("Cancel"), NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
837 NULL, NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
838 chat); |
15817 | 839 } |
840 | |
841 static void | |
842 autojoin_toggled(GntMenuItem *item, gpointer data) | |
843 { | |
15822 | 844 PurpleMenuAction *action = data; |
845 purple_blist_node_set_bool(action->data, "gnt-autojoin", | |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
846 gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item))); |
15817 | 847 } |
848 | |
849 static void | |
15822 | 850 create_chat_menu(GntMenu *menu, PurpleChat *chat) |
15817 | 851 { |
15822 | 852 PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL); |
15817 | 853 GntMenuItem *check = gnt_menuitem_check_new(action->label); |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
854 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check), |
15822 | 855 purple_blist_node_get_bool((PurpleBlistNode*)chat, "gnt-autojoin")); |
15817 | 856 gnt_menu_add_item(menu, check); |
857 gnt_menuitem_set_callback(check, autojoin_toggled, action); | |
858 g_signal_connect_swapped(G_OBJECT(menu), "destroy", | |
15822 | 859 G_CALLBACK(purple_menu_action_free), action); |
15817 | 860 |
15822 | 861 add_custom_action(menu, _("Edit Settings"), (PurpleCallback)chat_components_edit, chat); |
15817 | 862 } |
863 | |
864 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
865 finch_add_buddy(PurpleBlistNode *selected, PurpleGroup *grp) |
15817 | 866 { |
15822 | 867 purple_blist_request_add_buddy(NULL, NULL, grp ? grp->name : NULL, NULL); |
15817 | 868 } |
869 | |
870 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
871 finch_add_group(PurpleBlistNode *selected, PurpleGroup *grp) |
15817 | 872 { |
15822 | 873 purple_blist_request_add_group(); |
15817 | 874 } |
875 | |
876 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
877 finch_add_chat(PurpleBlistNode *selected, PurpleGroup *grp) |
15817 | 878 { |
15822 | 879 purple_blist_request_add_chat(NULL, grp, NULL, NULL); |
15817 | 880 } |
881 | |
882 static void | |
15822 | 883 create_group_menu(GntMenu *menu, PurpleGroup *group) |
15817 | 884 { |
885 add_custom_action(menu, _("Add Buddy"), | |
15822 | 886 PURPLE_CALLBACK(finch_add_buddy), group); |
15817 | 887 add_custom_action(menu, _("Add Chat"), |
15822 | 888 PURPLE_CALLBACK(finch_add_chat), group); |
15817 | 889 add_custom_action(menu, _("Add Group"), |
15822 | 890 PURPLE_CALLBACK(finch_add_group), group); |
15817 | 891 } |
892 | |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17756
diff
changeset
|
893 gpointer finch_retrieve_user_info(PurpleConnection *conn, const char *name) |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
894 { |
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
895 PurpleNotifyUserInfo *info = purple_notify_user_info_new(); |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17756
diff
changeset
|
896 gpointer uihandle; |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
897 purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving...")); |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17756
diff
changeset
|
898 uihandle = purple_notify_userinfo(conn, name, info, NULL, NULL); |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
899 purple_notify_user_info_destroy(info); |
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
900 |
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
901 serv_get_info(conn, name); |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17756
diff
changeset
|
902 return uihandle; |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
903 } |
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
904 |
15817 | 905 static void |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
906 finch_blist_get_buddy_info_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) |
15817 | 907 { |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17203
diff
changeset
|
908 finch_retrieve_user_info(buddy->account->gc, purple_buddy_get_name(buddy)); |
15817 | 909 } |
910 | |
911 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
912 finch_blist_menu_send_file_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) |
15817 | 913 { |
914 serv_send_file(buddy->account->gc, buddy->name, NULL); | |
915 } | |
916 | |
917 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
918 finch_blist_pounce_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node) |
15817 | 919 { |
15822 | 920 PurpleBuddy *b; |
921 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) | |
922 b = purple_contact_get_priority_buddy((PurpleContact *)node); | |
15817 | 923 else |
15822 | 924 b = (PurpleBuddy *)node; |
15817 | 925 finch_pounce_editor_show(b->account, b->name, NULL); |
926 } | |
927 | |
928 | |
929 static void | |
15822 | 930 create_buddy_menu(GntMenu *menu, PurpleBuddy *buddy) |
15817 | 931 { |
15822 | 932 PurplePluginProtocolInfo *prpl_info; |
15817 | 933 |
15822 | 934 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl); |
15817 | 935 if (prpl_info && prpl_info->get_info) |
936 { | |
937 add_custom_action(menu, _("Get Info"), | |
15822 | 938 PURPLE_CALLBACK(finch_blist_get_buddy_info_cb), buddy); |
15817 | 939 } |
940 | |
941 add_custom_action(menu, _("Add Buddy Pounce"), | |
15822 | 942 PURPLE_CALLBACK(finch_blist_pounce_node_cb), buddy); |
15817 | 943 |
944 if (prpl_info && prpl_info->send_file) | |
945 { | |
946 if (!prpl_info->can_receive_file || | |
947 prpl_info->can_receive_file(buddy->account->gc, buddy->name)) | |
948 add_custom_action(menu, _("Send File"), | |
15822 | 949 PURPLE_CALLBACK(finch_blist_menu_send_file_cb), buddy); |
15817 | 950 } |
951 #if 0 | |
952 add_custom_action(tree, _("View Log"), | |
15822 | 953 PURPLE_CALLBACK(finch_blist_view_log_cb)), buddy); |
15817 | 954 #endif |
955 | |
956 /* Protocol actions */ | |
957 append_proto_menu(menu, | |
15822 | 958 purple_account_get_connection(purple_buddy_get_account(buddy)), |
959 (PurpleBlistNode*)buddy); | |
15817 | 960 } |
961 | |
962 static void | |
15822 | 963 append_extended_menu(GntMenu *menu, PurpleBlistNode *node) |
15817 | 964 { |
965 GList *iter; | |
966 | |
15822 | 967 for (iter = purple_blist_node_get_extended_menu(node); |
15817 | 968 iter; iter = g_list_delete_link(iter, iter)) |
969 { | |
970 gnt_append_menu_action(menu, iter->data, NULL); | |
971 } | |
972 } | |
973 | |
15822 | 974 /* Xerox'd from gtkdialogs.c:purple_gtkdialogs_remove_contact_cb */ |
15817 | 975 static void |
15822 | 976 remove_contact(PurpleContact *contact) |
15817 | 977 { |
15822 | 978 PurpleBlistNode *bnode, *cnode; |
979 PurpleGroup *group; | |
15817 | 980 |
15822 | 981 cnode = (PurpleBlistNode *)contact; |
982 group = (PurpleGroup*)cnode->parent; | |
15817 | 983 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
15822 | 984 PurpleBuddy *buddy = (PurpleBuddy*)bnode; |
985 if (purple_account_is_connected(buddy->account)) | |
986 purple_account_remove_buddy(buddy->account, buddy, group); | |
15817 | 987 } |
15822 | 988 purple_blist_remove_contact(contact); |
15817 | 989 } |
990 | |
991 static void | |
15822 | 992 rename_blist_node(PurpleBlistNode *node, const char *newname) |
15817 | 993 { |
994 const char *name = newname; | |
995 if (name && !*name) | |
996 name = NULL; | |
997 | |
15822 | 998 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
999 PurpleContact *contact = (PurpleContact*)node; | |
1000 PurpleBuddy *buddy = purple_contact_get_priority_buddy(contact); | |
1001 purple_blist_alias_contact(contact, name); | |
1002 purple_blist_alias_buddy(buddy, name); | |
15817 | 1003 serv_alias_buddy(buddy); |
15822 | 1004 } else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
1005 purple_blist_alias_buddy((PurpleBuddy*)node, name); | |
1006 serv_alias_buddy((PurpleBuddy*)node); | |
1007 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) | |
1008 purple_blist_alias_chat((PurpleChat*)node, name); | |
1009 else if (PURPLE_BLIST_NODE_IS_GROUP(node) && (name != NULL)) | |
1010 purple_blist_rename_group((PurpleGroup*)node, name); | |
15817 | 1011 else |
1012 g_return_if_reached(); | |
1013 } | |
1014 | |
1015 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
1016 finch_blist_rename_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node) |
15817 | 1017 { |
1018 const char *name = NULL; | |
1019 char *prompt; | |
16276
31dad9806e9d
Use 'alias' instead of 'rename' for non-group nodes. Thankfully, this does not introduce new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
1020 const char *text; |
15817 | 1021 |
15822 | 1022 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
1023 name = purple_contact_get_alias((PurpleContact*)node); | |
1024 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) | |
1025 name = purple_buddy_get_contact_alias((PurpleBuddy*)node); | |
1026 else if (PURPLE_BLIST_NODE_IS_CHAT(node)) | |
1027 name = purple_chat_get_name((PurpleChat*)node); | |
1028 else if (PURPLE_BLIST_NODE_IS_GROUP(node)) | |
1029 name = ((PurpleGroup*)node)->name; | |
15817 | 1030 else |
1031 g_return_if_reached(); | |
1032 | |
1033 prompt = g_strdup_printf(_("Please enter the new name for %s"), name); | |
1034 | |
16958
1a336cfc410e
Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16926
diff
changeset
|
1035 text = PURPLE_BLIST_NODE_IS_GROUP(node) ? _("Rename") : _("Set Alias"); |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
1036 purple_request_input(node, text, prompt, _("Enter empty string to reset the name."), |
16276
31dad9806e9d
Use 'alias' instead of 'rename' for non-group nodes. Thankfully, this does not introduce new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
1037 name, FALSE, FALSE, NULL, text, G_CALLBACK(rename_blist_node), |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1038 _("Cancel"), NULL, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1039 NULL, NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
1040 node); |
15817 | 1041 |
1042 g_free(prompt); | |
1043 } | |
1044 | |
15822 | 1045 /* Xeroxed from gtkdialogs.c:purple_gtkdialogs_remove_group_cb*/ |
15817 | 1046 static void |
15822 | 1047 remove_group(PurpleGroup *group) |
15817 | 1048 { |
15822 | 1049 PurpleBlistNode *cnode, *bnode; |
15817 | 1050 |
15822 | 1051 cnode = ((PurpleBlistNode*)group)->child; |
15817 | 1052 |
1053 while (cnode) { | |
15822 | 1054 if (PURPLE_BLIST_NODE_IS_CONTACT(cnode)) { |
15817 | 1055 bnode = cnode->child; |
1056 cnode = cnode->next; | |
1057 while (bnode) { | |
15822 | 1058 PurpleBuddy *buddy; |
1059 if (PURPLE_BLIST_NODE_IS_BUDDY(bnode)) { | |
1060 buddy = (PurpleBuddy*)bnode; | |
15817 | 1061 bnode = bnode->next; |
15822 | 1062 if (purple_account_is_connected(buddy->account)) { |
1063 purple_account_remove_buddy(buddy->account, buddy, group); | |
1064 purple_blist_remove_buddy(buddy); | |
15817 | 1065 } |
1066 } else { | |
1067 bnode = bnode->next; | |
1068 } | |
1069 } | |
15822 | 1070 } else if (PURPLE_BLIST_NODE_IS_CHAT(cnode)) { |
1071 PurpleChat *chat = (PurpleChat *)cnode; | |
15817 | 1072 cnode = cnode->next; |
15822 | 1073 if (purple_account_is_connected(chat->account)) |
1074 purple_blist_remove_chat(chat); | |
15817 | 1075 } else { |
1076 cnode = cnode->next; | |
1077 } | |
1078 } | |
1079 | |
15822 | 1080 purple_blist_remove_group(group); |
15817 | 1081 } |
1082 | |
1083 static void | |
15822 | 1084 finch_blist_remove_node(PurpleBlistNode *node) |
15817 | 1085 { |
15822 | 1086 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
1087 remove_contact((PurpleContact*)node); | |
1088 } else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { | |
1089 PurpleBuddy *buddy = (PurpleBuddy*)node; | |
1090 PurpleGroup *group = purple_buddy_get_group(buddy); | |
1091 purple_account_remove_buddy(purple_buddy_get_account(buddy), buddy, group); | |
1092 purple_blist_remove_buddy(buddy); | |
1093 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { | |
1094 purple_blist_remove_chat((PurpleChat*)node); | |
1095 } else if (PURPLE_BLIST_NODE_IS_GROUP(node)) { | |
1096 remove_group((PurpleGroup*)node); | |
15817 | 1097 } |
1098 } | |
1099 | |
1100 static void | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
1101 finch_blist_remove_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node) |
15817 | 1102 { |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1103 PurpleAccount *account = NULL; |
15817 | 1104 char *primary; |
1105 const char *name, *sec = NULL; | |
1106 | |
1107 /* XXX: could be a contact */ | |
15822 | 1108 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
1109 PurpleContact *c = (PurpleContact*)node; | |
1110 name = purple_contact_get_alias(c); | |
15817 | 1111 if (c->totalsize > 1) |
1112 sec = _("Removing this contact will also remove all the buddies in the contact"); | |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1113 } else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
15822 | 1114 name = purple_buddy_get_name((PurpleBuddy*)node); |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1115 account = purple_buddy_get_account((PurpleBuddy*)node); |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1116 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { |
15822 | 1117 name = purple_chat_get_name((PurpleChat*)node); |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1118 } else if (PURPLE_BLIST_NODE_IS_GROUP(node)) { |
15822 | 1119 name = ((PurpleGroup*)node)->name; |
15817 | 1120 sec = _("Removing this group will also remove all the buddies in the group"); |
1121 } | |
1122 else | |
1123 return; | |
1124 | |
1125 primary = g_strdup_printf(_("Are you sure you want to remove %s?"), name); | |
1126 | |
1127 /* XXX: anything to do with the returned ui-handle? */ | |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
1128 purple_request_action(node, _("Confirm Remove"), |
15817 | 1129 primary, sec, |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1130 1, |
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
1131 account, name, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
1132 node, 2, |
15817 | 1133 _("Remove"), finch_blist_remove_node, |
1134 _("Cancel"), NULL); | |
1135 g_free(primary); | |
1136 } | |
1137 | |
1138 static void | |
15822 | 1139 finch_blist_toggle_tag_buddy(PurpleBlistNode *node) |
15817 | 1140 { |
1141 GList *iter; | |
1142 if (node == NULL) | |
1143 return; | |
1144 if (ggblist->tagged && (iter = g_list_find(ggblist->tagged, node)) != NULL) { | |
1145 ggblist->tagged = g_list_delete_link(ggblist->tagged, iter); | |
1146 } else { | |
1147 ggblist->tagged = g_list_prepend(ggblist->tagged, node); | |
1148 } | |
15822 | 1149 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
1150 node = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); | |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1151 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1152 update_buddy_display((PurpleBuddy*)node, ggblist); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1153 else |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1154 update_node_display(node, ggblist); |
15817 | 1155 } |
1156 | |
1157 static void | |
15822 | 1158 finch_blist_place_tagged(PurpleBlistNode *target) |
15817 | 1159 { |
15822 | 1160 PurpleGroup *tg = NULL; |
1161 PurpleContact *tc = NULL; | |
15817 | 1162 |
1163 if (target == NULL) | |
1164 return; | |
1165 | |
15822 | 1166 if (PURPLE_BLIST_NODE_IS_GROUP(target)) |
1167 tg = (PurpleGroup*)target; | |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1168 else if (PURPLE_BLIST_NODE_IS_BUDDY(target)) { |
15822 | 1169 tc = (PurpleContact*)target->parent; |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1170 tg = (PurpleGroup*)target->parent->parent; |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1171 } else { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1172 if (PURPLE_BLIST_NODE_IS_CONTACT(target)) |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1173 tc = (PurpleContact*)target; |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1174 tg = (PurpleGroup*)target->parent; |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1175 } |
15817 | 1176 |
1177 if (ggblist->tagged) { | |
1178 GList *list = ggblist->tagged; | |
1179 ggblist->tagged = NULL; | |
1180 while (list) { | |
15822 | 1181 PurpleBlistNode *node = list->data; |
15817 | 1182 list = g_list_delete_link(list, list); |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1183 |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1184 if (PURPLE_BLIST_NODE_IS_GROUP(node)) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1185 update_node_display(node, ggblist); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1186 /* Add the group after the current group */ |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1187 purple_blist_add_group((PurpleGroup*)node, (PurpleBlistNode*)tg); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1188 } else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1189 update_buddy_display(purple_contact_get_priority_buddy((PurpleContact*)node), ggblist); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1190 if ((PurpleBlistNode*)tg == target) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1191 /* The target is a group, just add the contact to the group. */ |
15822 | 1192 purple_blist_add_contact((PurpleContact*)node, tg, NULL); |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1193 } else if (tc) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1194 /* The target is either a buddy, or a contact. Merge with that contact. */ |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1195 purple_blist_merge_contact((PurpleContact*)node, (PurpleBlistNode*)tc); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1196 } else { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1197 /* The target is a chat. Add the contact to the group after this chat. */ |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1198 purple_blist_add_contact((PurpleContact*)node, NULL, target); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1199 } |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1200 } else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1201 update_buddy_display((PurpleBuddy*)node, ggblist); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1202 if ((PurpleBlistNode*)tg == target) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1203 /* The target is a group. Add this buddy in a new contact under this group. */ |
15822 | 1204 purple_blist_add_buddy((PurpleBuddy*)node, NULL, tg, NULL); |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1205 } else if (PURPLE_BLIST_NODE_IS_CONTACT(target)) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1206 /* Add to the contact. */ |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1207 purple_blist_add_buddy((PurpleBuddy*)node, tc, NULL, NULL); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1208 } else if (PURPLE_BLIST_NODE_IS_BUDDY(target)) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1209 /* Add to the contact after the selected buddy. */ |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1210 purple_blist_add_buddy((PurpleBuddy*)node, NULL, NULL, target); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1211 } else if (PURPLE_BLIST_NODE_IS_CHAT(target)) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1212 /* Add to the selected chat's group. */ |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1213 purple_blist_add_buddy((PurpleBuddy*)node, NULL, tg, NULL); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1214 } |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1215 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1216 update_node_display(node, ggblist); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1217 if ((PurpleBlistNode*)tg == target) |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1218 purple_blist_add_chat((PurpleChat*)node, tg, NULL); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1219 else |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1220 purple_blist_add_chat((PurpleChat*)node, NULL, target); |
15817 | 1221 } |
1222 } | |
1223 } | |
1224 } | |
1225 | |
1226 static void | |
1227 context_menu_destroyed(GntWidget *widget, FinchBlist *ggblist) | |
1228 { | |
1229 ggblist->context = NULL; | |
1230 } | |
1231 | |
1232 static void | |
1233 draw_context_menu(FinchBlist *ggblist) | |
1234 { | |
15822 | 1235 PurpleBlistNode *node = NULL; |
15817 | 1236 GntWidget *context = NULL; |
1237 GntTree *tree = NULL; | |
1238 int x, y, top, width; | |
1239 char *title = NULL; | |
1240 | |
16813
e79555933fc6
Do not build the context menu if one is already being shown.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16781
diff
changeset
|
1241 if (ggblist->context) |
e79555933fc6
Do not build the context menu if one is already being shown.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16781
diff
changeset
|
1242 return; |
e79555933fc6
Do not build the context menu if one is already being shown.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16781
diff
changeset
|
1243 |
15817 | 1244 tree = GNT_TREE(ggblist->tree); |
1245 | |
1246 node = gnt_tree_get_selection_data(tree); | |
1247 | |
1248 if (ggblist->tooltip) | |
1249 remove_tooltip(ggblist); | |
1250 | |
1251 ggblist->cnode = node; | |
1252 | |
1253 ggblist->context = context = gnt_menu_new(GNT_MENU_POPUP); | |
1254 g_signal_connect(G_OBJECT(context), "destroy", G_CALLBACK(context_menu_destroyed), ggblist); | |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
1255 g_signal_connect(G_OBJECT(context), "hide", G_CALLBACK(gnt_widget_destroy), NULL); |
15817 | 1256 |
1257 if (!node) { | |
1258 create_group_menu(GNT_MENU(context), NULL); | |
1259 title = g_strdup(_("Buddy List")); | |
15822 | 1260 } else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
18565
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
1261 ggblist->cnode = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)node); |
980d6e1b2d21
Fix a crash Eric found. These parameters were in reverse order.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18535
diff
changeset
|
1262 create_buddy_menu(GNT_MENU(context), (PurpleBuddy*)ggblist->cnode); |
15822 | 1263 title = g_strdup(purple_contact_get_alias((PurpleContact*)node)); |
1264 } else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { | |
1265 PurpleBuddy *buddy = (PurpleBuddy *)node; | |
15817 | 1266 create_buddy_menu(GNT_MENU(context), buddy); |
15822 | 1267 title = g_strdup(purple_buddy_get_name(buddy)); |
1268 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { | |
1269 PurpleChat *chat = (PurpleChat*)node; | |
15817 | 1270 create_chat_menu(GNT_MENU(context), chat); |
15822 | 1271 title = g_strdup(purple_chat_get_name(chat)); |
1272 } else if (PURPLE_BLIST_NODE_IS_GROUP(node)) { | |
1273 PurpleGroup *group = (PurpleGroup *)node; | |
15817 | 1274 create_group_menu(GNT_MENU(context), group); |
1275 title = g_strdup(group->name); | |
1276 } | |
1277 | |
1278 append_extended_menu(GNT_MENU(context), node); | |
1279 | |
1280 /* These are common for everything */ | |
1281 if (node) { | |
16276
31dad9806e9d
Use 'alias' instead of 'rename' for non-group nodes. Thankfully, this does not introduce new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
1282 add_custom_action(GNT_MENU(context), |
31dad9806e9d
Use 'alias' instead of 'rename' for non-group nodes. Thankfully, this does not introduce new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
1283 PURPLE_BLIST_NODE_IS_GROUP(node) ? _("Rename") : _("Alias"), |
15822 | 1284 PURPLE_CALLBACK(finch_blist_rename_node_cb), node); |
15817 | 1285 add_custom_action(GNT_MENU(context), _("Remove"), |
15822 | 1286 PURPLE_CALLBACK(finch_blist_remove_node_cb), node); |
15817 | 1287 |
15822 | 1288 if (ggblist->tagged && (PURPLE_BLIST_NODE_IS_CONTACT(node) |
1289 || PURPLE_BLIST_NODE_IS_GROUP(node))) { | |
15817 | 1290 add_custom_action(GNT_MENU(context), _("Place tagged"), |
15822 | 1291 PURPLE_CALLBACK(finch_blist_place_tagged), node); |
15817 | 1292 } |
1293 | |
15822 | 1294 if (PURPLE_BLIST_NODE_IS_BUDDY(node) || PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
15817 | 1295 add_custom_action(GNT_MENU(context), _("Toggle Tag"), |
15822 | 1296 PURPLE_CALLBACK(finch_blist_toggle_tag_buddy), node); |
15817 | 1297 } |
1298 } | |
1299 | |
1300 /* Set the position for the popup */ | |
1301 gnt_widget_get_position(GNT_WIDGET(tree), &x, &y); | |
1302 gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL); | |
1303 top = gnt_tree_get_selection_visible_line(tree); | |
1304 | |
1305 x += width; | |
1306 y += top - 1; | |
1307 | |
1308 gnt_widget_set_position(context, x, y); | |
1309 gnt_screen_menu_show(GNT_MENU(context)); | |
1310 g_free(title); | |
1311 } | |
1312 | |
1313 static void | |
18332
1862a23b1751
Show better tooltips for contacts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18316
diff
changeset
|
1314 tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full) |
15817 | 1315 { |
15822 | 1316 PurplePlugin *prpl; |
1317 PurplePluginProtocolInfo *prpl_info; | |
1318 PurpleAccount *account; | |
1319 PurpleNotifyUserInfo *user_info; | |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
1320 PurplePresence *presence; |
15822 | 1321 const char *alias = purple_buddy_get_alias(buddy); |
15817 | 1322 char *tmp, *strip; |
1323 | |
15822 | 1324 user_info = purple_notify_user_info_new(); |
15817 | 1325 |
15822 | 1326 account = purple_buddy_get_account(buddy); |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
1327 presence = purple_buddy_get_presence(buddy); |
15817 | 1328 |
19305
f0b25c6fa806
Fix #2607. (Finch tooltip HTML display)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18635
diff
changeset
|
1329 if (!full || g_utf8_collate(purple_buddy_get_name(buddy), alias)) { |
f0b25c6fa806
Fix #2607. (Finch tooltip HTML display)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18635
diff
changeset
|
1330 char *esc = g_markup_escape_text(alias, -1); |
f0b25c6fa806
Fix #2607. (Finch tooltip HTML display)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18635
diff
changeset
|
1331 purple_notify_user_info_add_pair(user_info, _("Nickname"), esc); |
f0b25c6fa806
Fix #2607. (Finch tooltip HTML display)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18635
diff
changeset
|
1332 g_free(esc); |
f0b25c6fa806
Fix #2607. (Finch tooltip HTML display)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18635
diff
changeset
|
1333 } |
15817 | 1334 |
1335 tmp = g_strdup_printf("%s (%s)", | |
15822 | 1336 purple_account_get_username(account), |
1337 purple_account_get_protocol_name(account)); | |
1338 purple_notify_user_info_add_pair(user_info, _("Account"), tmp); | |
15817 | 1339 g_free(tmp); |
1340 | |
15822 | 1341 prpl = purple_find_prpl(purple_account_get_protocol_id(account)); |
1342 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); | |
15817 | 1343 if (prpl_info && prpl_info->tooltip_text) { |
18332
1862a23b1751
Show better tooltips for contacts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18316
diff
changeset
|
1344 prpl_info->tooltip_text(buddy, user_info, full); |
15817 | 1345 } |
1346 | |
16424
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16276
diff
changeset
|
1347 if (purple_prefs_get_bool("/finch/blist/idletime")) { |
15822 | 1348 PurplePresence *pre = purple_buddy_get_presence(buddy); |
1349 if (purple_presence_is_idle(pre)) { | |
1350 time_t idle = purple_presence_get_idle_time(pre); | |
15817 | 1351 if (idle > 0) { |
15822 | 1352 char *st = purple_str_seconds_to_string(time(NULL) - idle); |
1353 purple_notify_user_info_add_pair(user_info, _("Idle"), st); | |
15817 | 1354 g_free(st); |
1355 } | |
1356 } | |
1357 } | |
1358 | |
15822 | 1359 tmp = purple_notify_user_info_get_text_with_newline(user_info, "<BR>"); |
1360 purple_notify_user_info_destroy(user_info); | |
15817 | 1361 |
15822 | 1362 strip = purple_markup_strip_html(tmp); |
15817 | 1363 g_string_append(str, strip); |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
1364 |
18635
5551e5ec1ce0
Insert a newline in the tooltip.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18586
diff
changeset
|
1365 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) { |
5551e5ec1ce0
Insert a newline in the tooltip.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18586
diff
changeset
|
1366 g_string_append(str, "\n"); |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
1367 g_string_append(str, _("On Mobile")); |
18635
5551e5ec1ce0
Insert a newline in the tooltip.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18586
diff
changeset
|
1368 } |
18437
ecb223f9f75b
Show a pimping cool unicode status emblem for buddies on mobile (thanks, elb).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18428
diff
changeset
|
1369 |
15817 | 1370 g_free(strip); |
1371 g_free(tmp); | |
1372 } | |
1373 | |
1374 static GString* | |
1375 make_sure_text_fits(GString *string) | |
1376 { | |
1377 int maxw = getmaxx(stdscr) - 3; | |
1378 char *str = gnt_util_onscreen_fit_string(string->str, maxw); | |
1379 string = g_string_assign(string, str); | |
1380 g_free(str); | |
1381 return string; | |
1382 } | |
1383 | |
1384 static gboolean | |
1385 draw_tooltip_real(FinchBlist *ggblist) | |
1386 { | |
15822 | 1387 PurpleBlistNode *node; |
15817 | 1388 int x, y, top, width, w, h; |
1389 GString *str; | |
1390 GntTree *tree; | |
1391 GntWidget *widget, *box, *tv; | |
1392 char *title = NULL; | |
1393 int lastseen = 0; | |
1394 | |
1395 widget = ggblist->tree; | |
1396 tree = GNT_TREE(widget); | |
1397 | |
1398 if (!gnt_widget_has_focus(ggblist->tree) || | |
1399 (ggblist->context && !GNT_WIDGET_IS_FLAG_SET(ggblist->context, GNT_WIDGET_INVISIBLE))) | |
1400 return FALSE; | |
1401 | |
1402 if (ggblist->tooltip) | |
1403 { | |
1404 /* XXX: Once we can properly redraw on expose events, this can be removed at the end | |
1405 * to avoid the blinking*/ | |
1406 remove_tooltip(ggblist); | |
1407 } | |
1408 | |
1409 node = gnt_tree_get_selection_data(tree); | |
1410 if (!node) | |
1411 return FALSE; | |
1412 | |
1413 str = g_string_new(""); | |
1414 | |
15822 | 1415 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) { |
1416 PurpleBuddy *pr = purple_contact_get_priority_buddy((PurpleContact*)node); | |
1417 gboolean offline = !PURPLE_BUDDY_IS_ONLINE(pr); | |
1418 gboolean showoffline = purple_prefs_get_bool(PREF_ROOT "/showoffline"); | |
1419 const char *name = purple_buddy_get_name(pr); | |
15817 | 1420 |
1421 title = g_strdup(name); | |
18332
1862a23b1751
Show better tooltips for contacts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18316
diff
changeset
|
1422 tooltip_for_buddy(pr, str, TRUE); |
15817 | 1423 for (node = node->child; node; node = node->next) { |
15822 | 1424 PurpleBuddy *buddy = (PurpleBuddy*)node; |
15817 | 1425 if (offline) { |
15822 | 1426 int value = purple_blist_node_get_int(node, "last_seen"); |
15817 | 1427 if (value > lastseen) |
1428 lastseen = value; | |
1429 } | |
15822 | 1430 if (node == (PurpleBlistNode*)pr) |
15817 | 1431 continue; |
15822 | 1432 if (!purple_account_is_connected(buddy->account)) |
15817 | 1433 continue; |
15822 | 1434 if (!showoffline && !PURPLE_BUDDY_IS_ONLINE(buddy)) |
15817 | 1435 continue; |
1436 str = g_string_append(str, "\n----------\n"); | |
18332
1862a23b1751
Show better tooltips for contacts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18316
diff
changeset
|
1437 tooltip_for_buddy(buddy, str, FALSE); |
15817 | 1438 } |
15822 | 1439 } else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
1440 PurpleBuddy *buddy = (PurpleBuddy *)node; | |
18332
1862a23b1751
Show better tooltips for contacts.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18316
diff
changeset
|
1441 tooltip_for_buddy(buddy, str, TRUE); |
15822 | 1442 title = g_strdup(purple_buddy_get_name(buddy)); |
1443 if (!PURPLE_BUDDY_IS_ONLINE((PurpleBuddy*)node)) | |
1444 lastseen = purple_blist_node_get_int(node, "last_seen"); | |
1445 } else if (PURPLE_BLIST_NODE_IS_GROUP(node)) { | |
1446 PurpleGroup *group = (PurpleGroup *)node; | |
15817 | 1447 |
1448 g_string_append_printf(str, _("Online: %d\nTotal: %d"), | |
15822 | 1449 purple_blist_get_group_online_count(group), |
1450 purple_blist_get_group_size(group, FALSE)); | |
15817 | 1451 |
1452 title = g_strdup(group->name); | |
15822 | 1453 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { |
1454 PurpleChat *chat = (PurpleChat *)node; | |
1455 PurpleAccount *account = chat->account; | |
15817 | 1456 |
1457 g_string_append_printf(str, _("Account: %s (%s)"), | |
15822 | 1458 purple_account_get_username(account), |
1459 purple_account_get_protocol_name(account)); | |
15817 | 1460 |
15822 | 1461 title = g_strdup(purple_chat_get_name(chat)); |
15817 | 1462 } else { |
1463 g_string_free(str, TRUE); | |
1464 return FALSE; | |
1465 } | |
1466 | |
1467 if (lastseen > 0) { | |
15822 | 1468 char *tmp = purple_str_seconds_to_string(time(NULL) - lastseen); |
15817 | 1469 g_string_append_printf(str, _("\nLast Seen: %s ago"), tmp); |
1470 g_free(tmp); | |
1471 } | |
1472 | |
1473 gnt_widget_get_position(widget, &x, &y); | |
1474 gnt_widget_get_size(widget, &width, NULL); | |
1475 top = gnt_tree_get_selection_visible_line(tree); | |
1476 | |
1477 x += width; | |
1478 y += top - 1; | |
1479 | |
1480 box = gnt_box_new(FALSE, FALSE); | |
1481 gnt_box_set_toplevel(GNT_BOX(box), TRUE); | |
1482 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW); | |
1483 gnt_box_set_title(GNT_BOX(box), title); | |
1484 | |
1485 str = make_sure_text_fits(str); | |
1486 gnt_util_get_text_bound(str->str, &w, &h); | |
18316
70325b0c5792
Use the new flags to make the tooltip look better.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
1487 h = MAX(1, h); |
15817 | 1488 tv = gnt_text_view_new(); |
1489 gnt_widget_set_size(tv, w + 1, h); | |
18316
70325b0c5792
Use the new flags to make the tooltip look better.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
1490 gnt_text_view_set_flag(GNT_TEXT_VIEW(tv), GNT_TEXT_VIEW_NO_SCROLL); |
15817 | 1491 gnt_box_add_widget(GNT_BOX(box), tv); |
1492 | |
1493 gnt_widget_set_position(box, x, y); | |
1494 GNT_WIDGET_UNSET_FLAGS(box, GNT_WIDGET_CAN_TAKE_FOCUS); | |
1495 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); | |
1496 gnt_widget_draw(box); | |
1497 | |
1498 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(tv), str->str, GNT_TEXT_FLAG_NORMAL); | |
1499 gnt_text_view_scroll(GNT_TEXT_VIEW(tv), 0); | |
1500 | |
1501 g_free(title); | |
1502 g_string_free(str, TRUE); | |
1503 ggblist->tooltip = box; | |
1504 ggblist->tnode = node; | |
1505 | |
1506 gnt_widget_set_name(ggblist->tooltip, "tooltip"); | |
1507 return FALSE; | |
1508 } | |
1509 | |
1510 static void | |
1511 draw_tooltip(FinchBlist *ggblist) | |
1512 { | |
1513 /* When an account has signed off, it removes one buddy at a time. | |
1514 * Drawing the tooltip after removing each buddy is expensive. On | |
1515 * top of that, if the selected buddy belongs to the disconnected | |
1516 * account, then retreiving the tooltip for that causes crash. So | |
1517 * let's make sure we wait for all the buddies to be removed first.*/ | |
1518 int id = g_timeout_add(0, (GSourceFunc)draw_tooltip_real, ggblist); | |
1519 g_object_set_data_full(G_OBJECT(ggblist->window), "draw_tooltip_calback", | |
1520 GINT_TO_POINTER(id), (GDestroyNotify)g_source_remove); | |
1521 } | |
1522 | |
1523 static void | |
1524 selection_changed(GntWidget *widget, gpointer old, gpointer current, FinchBlist *ggblist) | |
1525 { | |
16781
d0f9b2b217cf
Fix context menu unusualness in the buddylist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16771
diff
changeset
|
1526 remove_peripherals(ggblist); |
15817 | 1527 draw_tooltip(ggblist); |
1528 } | |
1529 | |
1530 static gboolean | |
1531 context_menu(GntWidget *widget, FinchBlist *ggblist) | |
1532 { | |
1533 draw_context_menu(ggblist); | |
1534 return TRUE; | |
1535 } | |
1536 | |
1537 static gboolean | |
1538 key_pressed(GntWidget *widget, const char *text, FinchBlist *ggblist) | |
1539 { | |
1540 if (text[0] == 27 && text[1] == 0) { | |
1541 /* Escape was pressed */ | |
21305
0208beabfa33
Cancel the typeahead search when escape is pressed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21244
diff
changeset
|
1542 if (gnt_tree_is_searching(GNT_TREE(ggblist->tree))) |
0208beabfa33
Cancel the typeahead search when escape is pressed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21244
diff
changeset
|
1543 gnt_bindable_perform_action_named(GNT_BINDABLE(ggblist->tree), "end-search", NULL); |
15817 | 1544 remove_peripherals(ggblist); |
1545 } else if (strcmp(text, GNT_KEY_CTRL_O) == 0) { | |
15822 | 1546 purple_prefs_set_bool(PREF_ROOT "/showoffline", |
1547 !purple_prefs_get_bool(PREF_ROOT "/showoffline")); | |
20625
54ff514fdd04
Pressing INSERT in the buddy list brings up the 'Add Buddy' dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20561
diff
changeset
|
1548 } else if (strcmp(text, GNT_KEY_INS) == 0) { |
54ff514fdd04
Pressing INSERT in the buddy list brings up the 'Add Buddy' dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20561
diff
changeset
|
1549 purple_blist_request_add_buddy(NULL, NULL, NULL, NULL); |
18535
fad459189cc5
New feature: successful compilation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18512
diff
changeset
|
1550 } else if (!gnt_tree_is_searching(GNT_TREE(ggblist->tree))) { |
15817 | 1551 if (strcmp(text, "t") == 0) { |
1552 finch_blist_toggle_tag_buddy(gnt_tree_get_selection_data(GNT_TREE(ggblist->tree))); | |
1553 gnt_bindable_perform_action_named(GNT_BINDABLE(ggblist->tree), "move-down"); | |
1554 } else if (strcmp(text, "a") == 0) { | |
1555 finch_blist_place_tagged(gnt_tree_get_selection_data(GNT_TREE(ggblist->tree))); | |
1556 } else | |
1557 return FALSE; | |
1558 } else | |
1559 return FALSE; | |
1560 | |
1561 return TRUE; | |
1562 } | |
1563 | |
1564 static void | |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1565 update_node_display(PurpleBlistNode *node, FinchBlist *ggblist) |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1566 { |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1567 GntTextFormatFlags flag = 0; |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1568 if (ggblist->tagged && g_list_find(ggblist->tagged, node)) |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1569 flag |= GNT_TEXT_FLAG_BOLD; |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1570 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), node, flag); |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1571 } |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1572 |
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1573 static void |
15822 | 1574 update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist) |
15817 | 1575 { |
15822 | 1576 PurpleContact *contact; |
15817 | 1577 GntTextFormatFlags bflag = 0, cflag = 0; |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
1578 int color = 0; |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
1579 |
15822 | 1580 contact = purple_buddy_get_contact(buddy); |
15817 | 1581 |
15822 | 1582 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((PurpleBlistNode*)buddy)); |
1583 gnt_tree_change_text(GNT_TREE(ggblist->tree), contact, 0, get_display_name((PurpleBlistNode*)contact)); | |
15817 | 1584 |
1585 if (ggblist->tagged && g_list_find(ggblist->tagged, buddy)) | |
1586 bflag |= GNT_TEXT_FLAG_BOLD; | |
1587 if (ggblist->tagged && g_list_find(ggblist->tagged, contact)) | |
1588 cflag |= GNT_TEXT_FLAG_BOLD; | |
1589 | |
15822 | 1590 if (ggblist->tnode == (PurpleBlistNode*)buddy) |
15817 | 1591 draw_tooltip(ggblist); |
1592 | |
21695
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
1593 color = get_display_color((PurpleBlistNode*)buddy); |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
1594 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), buddy, color); |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
1595 if (buddy == purple_contact_get_priority_buddy(contact)) |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
1596 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), contact, color); |
52bbf38a1cd2
Refactor the code a little bit.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21694
diff
changeset
|
1597 |
21691
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1598 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, bflag); |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1599 if (buddy == purple_contact_get_priority_buddy(contact)) |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1600 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, cflag); |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1601 |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1602 if (buddy != purple_contact_get_priority_buddy(contact)) |
16567
7b692d5dd704
This makes it possible to rearrange chats and groups using the tag+attach system. Thanks a bunch to wabz for testing this. Fixes #379.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16483
diff
changeset
|
1603 update_buddy_display(purple_contact_get_priority_buddy(contact), ggblist); |
15817 | 1604 } |
1605 | |
1606 static void | |
15822 | 1607 buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old, PurpleStatus *now, FinchBlist *ggblist) |
15817 | 1608 { |
1609 update_buddy_display(buddy, ggblist); | |
1610 } | |
1611 | |
1612 static void | |
15822 | 1613 buddy_idle_changed(PurpleBuddy *buddy, int old, int new, FinchBlist *ggblist) |
15817 | 1614 { |
1615 update_buddy_display(buddy, ggblist); | |
1616 } | |
1617 | |
1618 static void | |
1619 remove_peripherals(FinchBlist *ggblist) | |
1620 { | |
1621 if (ggblist->tooltip) | |
1622 remove_tooltip(ggblist); | |
1623 else if (ggblist->context) | |
1624 gnt_widget_destroy(ggblist->context); | |
1625 } | |
1626 | |
1627 static void | |
1628 size_changed_cb(GntWidget *w, int wi, int h) | |
1629 { | |
1630 int width, height; | |
1631 gnt_widget_get_size(w, &width, &height); | |
15822 | 1632 purple_prefs_set_int(PREF_ROOT "/size/width", width); |
1633 purple_prefs_set_int(PREF_ROOT "/size/height", height); | |
15817 | 1634 } |
1635 | |
1636 static void | |
1637 save_position_cb(GntWidget *w, int x, int y) | |
1638 { | |
15822 | 1639 purple_prefs_set_int(PREF_ROOT "/position/x", x); |
1640 purple_prefs_set_int(PREF_ROOT "/position/y", y); | |
15817 | 1641 } |
1642 | |
1643 static void | |
1644 reset_blist_window(GntWidget *window, gpointer null) | |
1645 { | |
15822 | 1646 PurpleBlistNode *node; |
1647 purple_signals_disconnect_by_handle(finch_blist_get_handle()); | |
1648 purple_get_blist()->ui_data = NULL; | |
15817 | 1649 |
15822 | 1650 node = purple_blist_get_root(); |
15817 | 1651 while (node) { |
1652 node->ui_data = NULL; | |
15822 | 1653 node = purple_blist_node_next(node, TRUE); |
15817 | 1654 } |
1655 | |
1656 if (ggblist->typing) | |
1657 g_source_remove(ggblist->typing); | |
1658 remove_peripherals(ggblist); | |
1659 if (ggblist->tagged) | |
1660 g_list_free(ggblist->tagged); | |
1661 g_free(ggblist); | |
1662 ggblist = NULL; | |
1663 } | |
1664 | |
1665 static void | |
1666 populate_buddylist() | |
1667 { | |
15822 | 1668 PurpleBlistNode *node; |
1669 PurpleBuddyList *list; | |
15817 | 1670 |
15822 | 1671 if (strcmp(purple_prefs_get_string(PREF_ROOT "/sort_type"), "text") == 0) { |
15817 | 1672 gnt_tree_set_compare_func(GNT_TREE(ggblist->tree), |
1673 (GCompareFunc)blist_node_compare_text); | |
15822 | 1674 } else if (strcmp(purple_prefs_get_string(PREF_ROOT "/sort_type"), "status") == 0) { |
15817 | 1675 gnt_tree_set_compare_func(GNT_TREE(ggblist->tree), |
1676 (GCompareFunc)blist_node_compare_status); | |
15822 | 1677 } else if (strcmp(purple_prefs_get_string(PREF_ROOT "/sort_type"), "log") == 0) { |
15817 | 1678 gnt_tree_set_compare_func(GNT_TREE(ggblist->tree), |
1679 (GCompareFunc)blist_node_compare_log); | |
1680 } | |
1681 | |
15822 | 1682 list = purple_get_blist(); |
1683 node = purple_blist_get_root(); | |
15817 | 1684 while (node) |
1685 { | |
1686 node_update(list, node); | |
15822 | 1687 node = purple_blist_node_next(node, FALSE); |
15817 | 1688 } |
1689 } | |
1690 | |
1691 static void | |
1692 destroy_status_list(GList *list) | |
1693 { | |
1694 g_list_foreach(list, (GFunc)g_free, NULL); | |
1695 g_list_free(list); | |
1696 } | |
1697 | |
1698 static void | |
1699 populate_status_dropdown() | |
1700 { | |
1701 int i; | |
1702 GList *iter; | |
1703 GList *items = NULL; | |
1704 StatusBoxItem *item = NULL; | |
1705 | |
1706 /* First the primitives */ | |
15822 | 1707 PurpleStatusPrimitive prims[] = {PURPLE_STATUS_AVAILABLE, PURPLE_STATUS_AWAY, |
1708 PURPLE_STATUS_INVISIBLE, PURPLE_STATUS_OFFLINE, PURPLE_STATUS_UNSET}; | |
15817 | 1709 |
1710 gnt_combo_box_remove_all(GNT_COMBO_BOX(ggblist->status)); | |
1711 | |
15822 | 1712 for (i = 0; prims[i] != PURPLE_STATUS_UNSET; i++) |
15817 | 1713 { |
1714 item = g_new0(StatusBoxItem, 1); | |
1715 item->type = STATUS_PRIMITIVE; | |
1716 item->u.prim = prims[i]; | |
1717 items = g_list_prepend(items, item); | |
1718 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, | |
15822 | 1719 purple_primitive_get_name_from_type(prims[i])); |
15817 | 1720 } |
1721 | |
1722 /* Now the popular statuses */ | |
18585
823946ddd527
Memory leak fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18584
diff
changeset
|
1723 for (iter = purple_savedstatuses_get_popular(6); iter; iter = g_list_delete_link(iter, iter)) |
15817 | 1724 { |
1725 item = g_new0(StatusBoxItem, 1); | |
1726 item->type = STATUS_SAVED_POPULAR; | |
1727 item->u.saved = iter->data; | |
1728 items = g_list_prepend(items, item); | |
1729 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, | |
15822 | 1730 purple_savedstatus_get_title(iter->data)); |
15817 | 1731 } |
1732 | |
1733 /* New savedstatus */ | |
1734 item = g_new0(StatusBoxItem, 1); | |
1735 item->type = STATUS_SAVED_NEW; | |
1736 items = g_list_prepend(items, item); | |
1737 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, | |
1738 _("New...")); | |
1739 | |
1740 /* More savedstatuses */ | |
1741 item = g_new0(StatusBoxItem, 1); | |
1742 item->type = STATUS_SAVED_ALL; | |
1743 items = g_list_prepend(items, item); | |
1744 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item, | |
1745 _("Saved...")); | |
1746 | |
1747 /* The keys for the combobox are created here, and never used | |
1748 * anywhere else. So make sure the keys are freed when the widget | |
1749 * is destroyed. */ | |
1750 g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses", | |
1751 items, (GDestroyNotify)destroy_status_list); | |
1752 } | |
1753 | |
1754 static void | |
15822 | 1755 redraw_blist(const char *name, PurplePrefType type, gconstpointer val, gpointer data) |
15817 | 1756 { |
15822 | 1757 PurpleBlistNode *node, *sel; |
15817 | 1758 if (ggblist == NULL || ggblist->window == NULL) |
1759 return; | |
1760 | |
1761 sel = gnt_tree_get_selection_data(GNT_TREE(ggblist->tree)); | |
1762 gnt_tree_remove_all(GNT_TREE(ggblist->tree)); | |
15822 | 1763 node = purple_blist_get_root(); |
1764 for (; node; node = purple_blist_node_next(node, TRUE)) | |
15817 | 1765 node->ui_data = NULL; |
1766 populate_buddylist(); | |
1767 gnt_tree_set_selected(GNT_TREE(ggblist->tree), sel); | |
1768 draw_tooltip(ggblist); | |
1769 } | |
1770 | |
21691
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1771 static int |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1772 get_color(char *key) |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1773 { |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1774 #if GLIB_CHECK_VERSION(2,6,0) |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1775 int fg = 0, bg = 0; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1776 gsize n; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1777 char **vals; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1778 vals = gnt_style_get_string_list(NULL, key, &n); |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1779 if (vals && n == 2) { |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1780 fg = gnt_colors_get_color(vals[0]); |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1781 bg = gnt_colors_get_color(vals[1]); |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1782 return gnt_color_add_pair(fg, bg); |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1783 } |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1784 return 0; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1785 #else |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1786 return 0; |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1787 #endif |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1788 } |
3ed9b027479d
Add support for colour in gnttreerows, and colourise the blist. Fixes #1490
Richard Nelson <wabz@pidgin.im>
parents:
21560
diff
changeset
|
1789 |
15817 | 1790 void finch_blist_init() |
1791 { | |
21694
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1792 color_available = get_color("color-available"); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1793 if (!color_available) |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1794 color_available = gnt_color_add_pair(COLOR_GREEN, -1); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1795 color_away = get_color("color-away"); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1796 if (!color_away) |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1797 color_away = gnt_color_add_pair(COLOR_BLUE, -1); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1798 color_idle = get_color("color-idle"); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1799 if (!color_idle) |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1800 color_idle = gnt_color_add_pair(COLOR_CYAN, -1); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1801 color_offline = get_color("color-offline"); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1802 if (!color_offline) |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1803 color_offline = gnt_color_add_pair(COLOR_RED, -1); |
2de3a2de5f13
Update the changelogs. Correct the man page. Allow 'default' to mean the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21691
diff
changeset
|
1804 |
15822 | 1805 purple_prefs_add_none(PREF_ROOT); |
1806 purple_prefs_add_none(PREF_ROOT "/size"); | |
1807 purple_prefs_add_int(PREF_ROOT "/size/width", 20); | |
1808 purple_prefs_add_int(PREF_ROOT "/size/height", 17); | |
1809 purple_prefs_add_none(PREF_ROOT "/position"); | |
1810 purple_prefs_add_int(PREF_ROOT "/position/x", 0); | |
1811 purple_prefs_add_int(PREF_ROOT "/position/y", 0); | |
1812 purple_prefs_add_bool(PREF_ROOT "/idletime", TRUE); | |
1813 purple_prefs_add_bool(PREF_ROOT "/showoffline", FALSE); | |
18441
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
1814 purple_prefs_add_bool(PREF_ROOT "/emptygroups", FALSE); |
15822 | 1815 purple_prefs_add_string(PREF_ROOT "/sort_type", "text"); |
15817 | 1816 |
15822 | 1817 purple_prefs_connect_callback(finch_blist_get_handle(), |
18441
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
1818 PREF_ROOT "/emptygroups", redraw_blist, NULL); |
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
1819 purple_prefs_connect_callback(finch_blist_get_handle(), |
15817 | 1820 PREF_ROOT "/showoffline", redraw_blist, NULL); |
15822 | 1821 purple_prefs_connect_callback(finch_blist_get_handle(), |
15817 | 1822 PREF_ROOT "/sort_type", redraw_blist, NULL); |
1823 | |
15822 | 1824 purple_signal_connect(purple_connections_get_handle(), "signed-on", purple_blist_get_handle(), |
15817 | 1825 G_CALLBACK(account_signed_on_cb), NULL); |
1826 return; | |
1827 } | |
1828 | |
1829 static gboolean | |
1830 remove_typing_cb(gpointer null) | |
1831 { | |
15822 | 1832 PurpleSavedStatus *current; |
15817 | 1833 const char *message, *newmessage; |
15822 | 1834 PurpleStatusPrimitive prim, newprim; |
15817 | 1835 StatusBoxItem *item; |
1836 | |
15822 | 1837 current = purple_savedstatus_get_current(); |
1838 message = purple_savedstatus_get_message(current); | |
1839 prim = purple_savedstatus_get_type(current); | |
15817 | 1840 |
1841 newmessage = gnt_entry_get_text(GNT_ENTRY(ggblist->statustext)); | |
1842 item = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(ggblist->status)); | |
16655
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1843 |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1844 switch (item->type) { |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1845 case STATUS_PRIMITIVE: |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1846 newprim = item->u.prim; |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1847 break; |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1848 case STATUS_SAVED_POPULAR: |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1849 newprim = purple_savedstatus_get_type(item->u.saved); |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1850 break; |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1851 default: |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1852 goto end; /* 'New' or 'Saved' is selected, but this should never happen. */ |
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1853 } |
15817 | 1854 |
1855 if (newprim != prim || ((message && !newmessage) || | |
1856 (!message && newmessage) || | |
1857 (message && newmessage && g_utf8_collate(message, newmessage) != 0))) | |
1858 { | |
15822 | 1859 PurpleSavedStatus *status = purple_savedstatus_find_transient_by_type_and_message(newprim, newmessage); |
15817 | 1860 /* Holy Crap! That's a LAWNG function name */ |
1861 if (status == NULL) | |
1862 { | |
15822 | 1863 status = purple_savedstatus_new(NULL, newprim); |
1864 purple_savedstatus_set_message(status, newmessage); | |
15817 | 1865 } |
1866 | |
15822 | 1867 purple_savedstatus_activate(status); |
15817 | 1868 } |
1869 | |
1870 gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree); | |
16655
1c9835f8b29c
A rare crash fix for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16567
diff
changeset
|
1871 end: |
15817 | 1872 if (ggblist->typing) |
1873 g_source_remove(ggblist->typing); | |
1874 ggblist->typing = 0; | |
1875 return FALSE; | |
1876 } | |
1877 | |
1878 static void | |
1879 status_selection_changed(GntComboBox *box, StatusBoxItem *old, StatusBoxItem *now, gpointer null) | |
1880 { | |
1881 gnt_entry_set_text(GNT_ENTRY(ggblist->statustext), NULL); | |
1882 if (now->type == STATUS_SAVED_POPULAR) | |
1883 { | |
1884 /* Set the status immediately */ | |
15822 | 1885 purple_savedstatus_activate(now->u.saved); |
15817 | 1886 } |
1887 else if (now->type == STATUS_PRIMITIVE) | |
1888 { | |
1889 /* Move the focus to the entry box */ | |
1890 /* XXX: Make sure the selected status can have a message */ | |
1891 gnt_box_move_focus(GNT_BOX(ggblist->window), 1); | |
1892 ggblist->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, NULL); | |
1893 } | |
1894 else if (now->type == STATUS_SAVED_ALL) | |
1895 { | |
1896 /* Restore the selection to reflect current status. */ | |
15822 | 1897 savedstatus_changed(purple_savedstatus_get_current(), NULL); |
15817 | 1898 gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree); |
1899 finch_savedstatus_show_all(); | |
1900 } | |
1901 else if (now->type == STATUS_SAVED_NEW) | |
1902 { | |
15822 | 1903 savedstatus_changed(purple_savedstatus_get_current(), NULL); |
15817 | 1904 gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree); |
1905 finch_savedstatus_edit(NULL); | |
1906 } | |
1907 else | |
1908 g_return_if_reached(); | |
1909 } | |
1910 | |
1911 static gboolean | |
1912 status_text_changed(GntEntry *entry, const char *text, gpointer null) | |
1913 { | |
1914 if ((text[0] == 27 || (text[0] == '\t' && text[1] == '\0')) && ggblist->typing == 0) | |
1915 return FALSE; | |
1916 | |
1917 if (ggblist->typing) | |
1918 g_source_remove(ggblist->typing); | |
1919 ggblist->typing = 0; | |
1920 | |
1921 if (text[0] == '\r' && text[1] == 0) | |
1922 { | |
1923 /* Set the status only after you press 'Enter' */ | |
1924 remove_typing_cb(NULL); | |
1925 return TRUE; | |
1926 } | |
1927 | |
1928 ggblist->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, NULL); | |
1929 return FALSE; | |
1930 } | |
1931 | |
1932 static void | |
15822 | 1933 savedstatus_changed(PurpleSavedStatus *now, PurpleSavedStatus *old) |
15817 | 1934 { |
1935 GList *list; | |
15822 | 1936 PurpleStatusPrimitive prim; |
15817 | 1937 const char *message; |
1938 gboolean found = FALSE, saved = TRUE; | |
1939 | |
1940 if (!ggblist) | |
1941 return; | |
1942 | |
1943 /* Block the signals we don't want to emit */ | |
1944 g_signal_handlers_block_matched(ggblist->status, G_SIGNAL_MATCH_FUNC, | |
1945 0, 0, NULL, status_selection_changed, NULL); | |
1946 g_signal_handlers_block_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC, | |
1947 0, 0, NULL, status_text_changed, NULL); | |
1948 | |
15822 | 1949 prim = purple_savedstatus_get_type(now); |
1950 message = purple_savedstatus_get_message(now); | |
15817 | 1951 |
1952 /* Rebuild the status dropdown */ | |
1953 populate_status_dropdown(); | |
1954 | |
1955 while (!found) { | |
1956 list = g_object_get_data(G_OBJECT(ggblist->status), "list of statuses"); | |
1957 for (; list; list = list->next) | |
1958 { | |
1959 StatusBoxItem *item = list->data; | |
1960 if ((saved && item->type != STATUS_PRIMITIVE && item->u.saved == now) || | |
1961 (!saved && item->type == STATUS_PRIMITIVE && item->u.prim == prim)) | |
1962 { | |
15822 | 1963 char *mess = purple_unescape_html(message); |
15817 | 1964 gnt_combo_box_set_selected(GNT_COMBO_BOX(ggblist->status), item); |
1965 gnt_entry_set_text(GNT_ENTRY(ggblist->statustext), mess); | |
1966 gnt_widget_draw(ggblist->status); | |
1967 g_free(mess); | |
1968 found = TRUE; | |
1969 break; | |
1970 } | |
1971 } | |
1972 if (!saved) | |
1973 break; | |
1974 saved = FALSE; | |
1975 } | |
1976 | |
1977 g_signal_handlers_unblock_matched(ggblist->status, G_SIGNAL_MATCH_FUNC, | |
1978 0, 0, NULL, status_selection_changed, NULL); | |
1979 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC, | |
1980 0, 0, NULL, status_text_changed, NULL); | |
1981 } | |
1982 | |
1983 static int | |
16483
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1984 blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2) |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1985 { |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1986 while ((n1 = n1->prev) != NULL) |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1987 if (n1 == n2) |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1988 return 1; |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1989 return -1; |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1990 } |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1991 |
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
1992 static int |
15822 | 1993 blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2) |
15817 | 1994 { |
1995 const char *s1, *s2; | |
1996 char *us1, *us2; | |
1997 int ret; | |
17240
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
1998 |
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
1999 if (n1->type != n2->type) |
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
2000 return blist_node_compare_position(n1, n2); |
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
2001 |
15817 | 2002 switch (n1->type) |
2003 { | |
15822 | 2004 case PURPLE_BLIST_CHAT_NODE: |
2005 s1 = purple_chat_get_name((PurpleChat*)n1); | |
2006 s2 = purple_chat_get_name((PurpleChat*)n2); | |
15817 | 2007 break; |
15822 | 2008 case PURPLE_BLIST_BUDDY_NODE: |
2009 return purple_presence_compare(purple_buddy_get_presence((PurpleBuddy*)n1), | |
2010 purple_buddy_get_presence((PurpleBuddy*)n2)); | |
15817 | 2011 break; |
15822 | 2012 case PURPLE_BLIST_CONTACT_NODE: |
2013 s1 = purple_contact_get_alias((PurpleContact*)n1); | |
2014 s2 = purple_contact_get_alias((PurpleContact*)n2); | |
15817 | 2015 break; |
2016 default: | |
16483
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
2017 return blist_node_compare_position(n1, n2); |
15817 | 2018 } |
2019 | |
2020 us1 = g_utf8_strup(s1, -1); | |
2021 us2 = g_utf8_strup(s2, -1); | |
2022 ret = g_utf8_collate(us1, us2); | |
2023 g_free(us1); | |
2024 g_free(us2); | |
2025 | |
2026 return ret; | |
2027 } | |
2028 | |
2029 static int | |
15822 | 2030 blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2) |
15817 | 2031 { |
2032 int ret; | |
2033 | |
17240
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
2034 if (n1->type != n2->type) |
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
2035 return blist_node_compare_position(n1, n2); |
15817 | 2036 |
2037 switch (n1->type) { | |
15822 | 2038 case PURPLE_BLIST_CONTACT_NODE: |
2039 n1 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n1); | |
2040 n2 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n2); | |
15817 | 2041 /* now compare the presence of the priority buddies */ |
15822 | 2042 case PURPLE_BLIST_BUDDY_NODE: |
2043 ret = purple_presence_compare(purple_buddy_get_presence((PurpleBuddy*)n1), | |
2044 purple_buddy_get_presence((PurpleBuddy*)n2)); | |
15817 | 2045 if (ret != 0) |
2046 return ret; | |
2047 break; | |
2048 default: | |
16483
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
2049 return blist_node_compare_position(n1, n2); |
15817 | 2050 break; |
2051 } | |
2052 | |
2053 /* Sort alphabetically if presence is not comparable */ | |
2054 ret = blist_node_compare_text(n1, n2); | |
2055 | |
2056 return ret; | |
2057 } | |
2058 | |
2059 static int | |
15822 | 2060 get_contact_log_size(PurpleBlistNode *c) |
15817 | 2061 { |
2062 int log = 0; | |
15822 | 2063 PurpleBlistNode *node; |
15817 | 2064 |
2065 for (node = c->child; node; node = node->next) { | |
15822 | 2066 PurpleBuddy *b = (PurpleBuddy*)node; |
2067 log += purple_log_get_total_size(PURPLE_LOG_IM, b->name, b->account); | |
15817 | 2068 } |
2069 | |
2070 return log; | |
2071 } | |
2072 | |
2073 static int | |
15822 | 2074 blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2) |
15817 | 2075 { |
2076 int ret; | |
15822 | 2077 PurpleBuddy *b1, *b2; |
15817 | 2078 |
17240
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
2079 if (n1->type != n2->type) |
29b3dc9cc8c5
It's valid for different types to be compared. In that case, use existing positions.
Richard Nelson <wabz@pidgin.im>
parents:
17203
diff
changeset
|
2080 return blist_node_compare_position(n1, n2); |
15817 | 2081 |
2082 switch (n1->type) { | |
15822 | 2083 case PURPLE_BLIST_BUDDY_NODE: |
2084 b1 = (PurpleBuddy*)n1; | |
2085 b2 = (PurpleBuddy*)n2; | |
2086 ret = purple_log_get_total_size(PURPLE_LOG_IM, b2->name, b2->account) - | |
2087 purple_log_get_total_size(PURPLE_LOG_IM, b1->name, b1->account); | |
15817 | 2088 if (ret != 0) |
2089 return ret; | |
2090 break; | |
15822 | 2091 case PURPLE_BLIST_CONTACT_NODE: |
15817 | 2092 ret = get_contact_log_size(n2) - get_contact_log_size(n1); |
2093 if (ret != 0) | |
2094 return ret; | |
2095 break; | |
2096 default: | |
16483
0b97b224a829
Never change the orders of chats or the groups.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16439
diff
changeset
|
2097 return blist_node_compare_position(n1, n2); |
15817 | 2098 } |
2099 ret = blist_node_compare_text(n1, n2); | |
2100 return ret; | |
2101 } | |
2102 | |
2103 static gboolean | |
2104 blist_clicked(GntTree *tree, GntMouseEvent event, int x, int y, gpointer ggblist) | |
2105 { | |
2106 if (event == GNT_RIGHT_MOUSE_DOWN) { | |
2107 draw_context_menu(ggblist); | |
2108 } | |
2109 return FALSE; | |
2110 } | |
2111 | |
2112 static void | |
2113 plugin_action(GntMenuItem *item, gpointer data) | |
2114 { | |
15822 | 2115 PurplePluginAction *action = data; |
15817 | 2116 if (action && action->callback) |
2117 action->callback(action); | |
2118 } | |
2119 | |
2120 static void | |
15822 | 2121 build_plugin_actions(GntMenuItem *item, PurplePlugin *plugin, gpointer context) |
15817 | 2122 { |
2123 GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP); | |
2124 GList *actions; | |
2125 GntMenuItem *menuitem; | |
2126 | |
2127 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
15822 | 2128 for (actions = PURPLE_PLUGIN_ACTIONS(plugin, context); actions; |
15817 | 2129 actions = g_list_delete_link(actions, actions)) { |
2130 if (actions->data) { | |
15822 | 2131 PurplePluginAction *action = actions->data; |
15817 | 2132 action->plugin = plugin; |
2133 action->context = context; | |
2134 menuitem = gnt_menuitem_new(action->label); | |
2135 gnt_menu_add_item(GNT_MENU(sub), menuitem); | |
2136 | |
2137 gnt_menuitem_set_callback(menuitem, plugin_action, action); | |
2138 g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", | |
15822 | 2139 action, (GDestroyNotify)purple_plugin_action_free); |
15817 | 2140 } |
2141 } | |
2142 } | |
2143 | |
2144 static void | |
2145 reconstruct_plugins_menu() | |
2146 { | |
2147 GntWidget *sub; | |
2148 GntMenuItem *plg; | |
2149 GList *iter; | |
2150 | |
2151 if (!ggblist) | |
2152 return; | |
2153 | |
2154 if (ggblist->plugins == NULL) | |
2155 ggblist->plugins = gnt_menuitem_new(_("Plugins")); | |
2156 | |
2157 plg = ggblist->plugins; | |
2158 sub = gnt_menu_new(GNT_MENU_POPUP); | |
2159 gnt_menuitem_set_submenu(plg, GNT_MENU(sub)); | |
2160 | |
15822 | 2161 for (iter = purple_plugins_get_loaded(); iter; iter = iter->next) { |
2162 PurplePlugin *plugin = iter->data; | |
15817 | 2163 GntMenuItem *item; |
15822 | 2164 if (PURPLE_IS_PROTOCOL_PLUGIN(plugin)) |
15817 | 2165 continue; |
2166 | |
15822 | 2167 if (!PURPLE_PLUGIN_HAS_ACTIONS(plugin)) |
15817 | 2168 continue; |
2169 | |
2170 item = gnt_menuitem_new(_(plugin->info->name)); | |
2171 gnt_menu_add_item(GNT_MENU(sub), item); | |
2172 build_plugin_actions(item, plugin, NULL); | |
2173 } | |
2174 } | |
2175 | |
2176 static void | |
2177 reconstruct_accounts_menu() | |
2178 { | |
2179 GntWidget *sub; | |
2180 GntMenuItem *acc, *item; | |
2181 GList *iter; | |
2182 | |
2183 if (!ggblist) | |
2184 return; | |
2185 | |
2186 if (ggblist->accounts == NULL) | |
2187 ggblist->accounts = gnt_menuitem_new(_("Accounts")); | |
2188 | |
2189 acc = ggblist->accounts; | |
2190 sub = gnt_menu_new(GNT_MENU_POPUP); | |
2191 gnt_menuitem_set_submenu(acc, GNT_MENU(sub)); | |
2192 | |
15822 | 2193 for (iter = purple_accounts_get_all_active(); iter; |
15817 | 2194 iter = g_list_delete_link(iter, iter)) { |
15822 | 2195 PurpleAccount *account = iter->data; |
2196 PurpleConnection *gc = purple_account_get_connection(account); | |
2197 PurplePlugin *prpl; | |
15817 | 2198 |
15822 | 2199 if (!gc || !PURPLE_CONNECTION_IS_CONNECTED(gc)) |
15817 | 2200 continue; |
2201 prpl = gc->prpl; | |
2202 | |
15822 | 2203 if (PURPLE_PLUGIN_HAS_ACTIONS(prpl)) { |
2204 item = gnt_menuitem_new(purple_account_get_username(account)); | |
15817 | 2205 gnt_menu_add_item(GNT_MENU(sub), item); |
2206 build_plugin_actions(item, prpl, gc); | |
2207 } | |
2208 } | |
2209 } | |
2210 | |
19375
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2211 static gboolean |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2212 auto_join_chats(gpointer data) |
15817 | 2213 { |
15822 | 2214 PurpleBlistNode *node; |
19375
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2215 PurpleConnection *pc = data; |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2216 PurpleAccount *account = purple_connection_get_account(pc); |
15817 | 2217 |
15822 | 2218 for (node = purple_blist_get_root(); node; |
2219 node = purple_blist_node_next(node, FALSE)) { | |
2220 if (PURPLE_BLIST_NODE_IS_CHAT(node)) { | |
2221 PurpleChat *chat = (PurpleChat*)node; | |
19375
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2222 if (chat->account == account && |
16771
d7ad8013b914
Fix this spectacularly braindead code. I must've been on the good stuff when I wrote this. Fixes #364.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16655
diff
changeset
|
2223 purple_blist_node_get_bool(node, "gnt-autojoin")) |
15822 | 2224 serv_join_chat(purple_account_get_connection(chat->account), chat->components); |
15817 | 2225 } |
2226 } | |
19375
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2227 return FALSE; |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2228 } |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2229 |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2230 static void |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2231 account_signed_on_cb(PurpleConnection *gc, gpointer null) |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2232 { |
f520bf6dd4bc
I think this fixes the auto-rejoin-after-auto-reconnect bug in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19305
diff
changeset
|
2233 g_idle_add(auto_join_chats, gc); |
15817 | 2234 } |
18442
6d8aed4adcd6
Minor changes to remove a couple of lines of duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18441
diff
changeset
|
2235 |
6d8aed4adcd6
Minor changes to remove a couple of lines of duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18441
diff
changeset
|
2236 static void toggle_pref_cb(GntMenuItem *item, gpointer n) |
18441
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
2237 { |
18442
6d8aed4adcd6
Minor changes to remove a couple of lines of duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18441
diff
changeset
|
2238 purple_prefs_set_bool(n, !purple_prefs_get_bool(n)); |
15817 | 2239 } |
2240 | |
2241 static void sort_blist_change_cb(GntMenuItem *item, gpointer n) | |
2242 { | |
15822 | 2243 purple_prefs_set_string(PREF_ROOT "/sort_type", n); |
15817 | 2244 } |
2245 | |
18428
1dbd8ce2f11f
Fix a bug where buddies from offline accounts were showing up.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
2246 /* send_im_select* -- Xerox */ |
15817 | 2247 static void |
15822 | 2248 send_im_select_cb(gpointer data, PurpleRequestFields *fields) |
15817 | 2249 { |
15822 | 2250 PurpleAccount *account; |
15817 | 2251 const char *username; |
2252 | |
15822 | 2253 account = purple_request_fields_get_account(fields, "account"); |
2254 username = purple_request_fields_get_string(fields, "screenname"); | |
15817 | 2255 |
15822 | 2256 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, username); |
15817 | 2257 } |
2258 | |
2259 static void | |
2260 send_im_select(GntMenuItem *item, gpointer n) | |
2261 { | |
15822 | 2262 PurpleRequestFields *fields; |
2263 PurpleRequestFieldGroup *group; | |
2264 PurpleRequestField *field; | |
15817 | 2265 |
15822 | 2266 fields = purple_request_fields_new(); |
15817 | 2267 |
15822 | 2268 group = purple_request_field_group_new(NULL); |
2269 purple_request_fields_add_group(fields, group); | |
15817 | 2270 |
20739
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2271 field = purple_request_field_string_new("screenname", _("Name"), NULL, FALSE); |
15822 | 2272 purple_request_field_set_type_hint(field, "screenname"); |
2273 purple_request_field_set_required(field, TRUE); | |
2274 purple_request_field_group_add_field(group, field); | |
15817 | 2275 |
20739
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2276 field = purple_request_field_account_new("account", _("Account"), NULL); |
15822 | 2277 purple_request_field_set_type_hint(field, "account"); |
2278 purple_request_field_set_visible(field, | |
2279 (purple_connections_get_all() != NULL && | |
2280 purple_connections_get_all()->next != NULL)); | |
2281 purple_request_field_set_required(field, TRUE); | |
2282 purple_request_field_group_add_field(group, field); | |
15817 | 2283 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
2284 purple_request_fields(purple_get_blist(), _("New Instant Message"), |
15817 | 2285 NULL, |
2286 _("Please enter the screen name or alias of the person " | |
2287 "you would like to IM."), | |
2288 fields, | |
2289 _("OK"), G_CALLBACK(send_im_select_cb), | |
2290 _("Cancel"), NULL, | |
16439
08db93bbd798
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents:
16424
diff
changeset
|
2291 NULL, NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
2292 NULL); |
15817 | 2293 } |
2294 | |
2295 static void | |
20739
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2296 join_chat_select_cb(gpointer data, PurpleRequestFields *fields) |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2297 { |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2298 PurpleAccount *account; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2299 const char *name; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2300 PurpleConnection *gc; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2301 PurpleChat *chat; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2302 GHashTable *hash = NULL; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2303 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2304 account = purple_request_fields_get_account(fields, "account"); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2305 name = purple_request_fields_get_string(fields, "chat"); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2306 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2307 if (!purple_account_is_connected(account)) |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2308 return; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2309 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2310 gc = purple_account_get_connection(account); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2311 purple_conversation_new(PURPLE_CONV_TYPE_CHAT, account, name); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2312 chat = purple_blist_find_chat(account, name); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2313 if (chat == NULL) { |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2314 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2315 hash = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, name); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2316 } else { |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2317 hash = chat->components; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2318 } |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2319 serv_join_chat(gc, hash); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2320 if (chat == NULL && hash != NULL) |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2321 g_hash_table_destroy(hash); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2322 } |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2323 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2324 static void |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2325 join_chat_select(GntMenuItem *item, gpointer n) |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2326 { |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2327 PurpleRequestFields *fields; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2328 PurpleRequestFieldGroup *group; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2329 PurpleRequestField *field; |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2330 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2331 fields = purple_request_fields_new(); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2332 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2333 group = purple_request_field_group_new(NULL); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2334 purple_request_fields_add_group(fields, group); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2335 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2336 field = purple_request_field_string_new("chat", _("Channel"), NULL, FALSE); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2337 purple_request_field_set_required(field, TRUE); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2338 purple_request_field_group_add_field(group, field); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2339 |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2340 field = purple_request_field_account_new("account", _("Account"), NULL); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2341 purple_request_field_set_type_hint(field, "account"); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2342 purple_request_field_set_visible(field, |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2343 (purple_connections_get_all() != NULL && |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2344 purple_connections_get_all()->next != NULL)); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2345 purple_request_field_set_required(field, TRUE); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2346 purple_request_field_group_add_field(group, field); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2347 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
2348 purple_request_fields(purple_get_blist(), _("Join a Chat"), |
20739
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2349 NULL, |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2350 _("Please enter the name of the chat you want to join."), |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2351 fields, |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2352 _("Join"), G_CALLBACK(join_chat_select_cb), |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2353 _("Cancel"), NULL, |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2354 NULL, NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
2355 NULL); |
15817 | 2356 } |
2357 | |
2358 static void | |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2359 menu_add_buddy_cb(GntMenuItem *item, gpointer null) |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2360 { |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2361 purple_blist_request_add_buddy(NULL, NULL, NULL, NULL); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2362 } |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2363 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2364 static void |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2365 menu_add_chat_cb(GntMenuItem *item, gpointer null) |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2366 { |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2367 purple_blist_request_add_chat(NULL, NULL, NULL, NULL); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2368 } |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2369 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2370 static void |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2371 menu_add_group_cb(GntMenuItem *item, gpointer null) |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2372 { |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2373 purple_blist_request_add_group(); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2374 } |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2375 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2376 static void |
15817 | 2377 create_menu() |
2378 { | |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2379 GntWidget *menu, *sub, *subsub; |
15817 | 2380 GntMenuItem *item; |
2381 GntWindow *window; | |
2382 | |
2383 if (!ggblist) | |
2384 return; | |
2385 | |
2386 window = GNT_WINDOW(ggblist->window); | |
2387 ggblist->menu = menu = gnt_menu_new(GNT_MENU_TOPLEVEL); | |
2388 gnt_window_set_menu(window, GNT_MENU(menu)); | |
2389 | |
2390 item = gnt_menuitem_new(_("Options")); | |
2391 gnt_menu_add_item(GNT_MENU(menu), item); | |
2392 | |
2393 sub = gnt_menu_new(GNT_MENU_POPUP); | |
2394 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
2395 | |
2396 item = gnt_menuitem_new(_("Send IM...")); | |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2397 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "send-im"); |
15817 | 2398 gnt_menu_add_item(GNT_MENU(sub), item); |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
2399 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), send_im_select, NULL); |
15817 | 2400 |
20739
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2401 item = gnt_menuitem_new(_("Join Chat...")); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2402 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "join-chat"); |
20739
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2403 gnt_menu_add_item(GNT_MENU(sub), item); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2404 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), join_chat_select, NULL); |
3f9520e09805
Add a 'Join Chat...' item in the buddylist menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20625
diff
changeset
|
2405 |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2406 item = gnt_menuitem_new(_("Show")); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2407 gnt_menu_add_item(GNT_MENU(sub), item); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2408 subsub = gnt_menu_new(GNT_MENU_POPUP); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2409 gnt_menuitem_set_submenu(item, GNT_MENU(subsub)); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2410 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2411 item = gnt_menuitem_check_new(_("Empty groups")); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2412 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "show-empty-groups"); |
18441
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
2413 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), |
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
2414 purple_prefs_get_bool(PREF_ROOT "/emptygroups")); |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2415 gnt_menu_add_item(GNT_MENU(subsub), item); |
18442
6d8aed4adcd6
Minor changes to remove a couple of lines of duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18441
diff
changeset
|
2416 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), toggle_pref_cb, PREF_ROOT "/emptygroups"); |
18441
24ecab0d40b3
Plucked revision from im.pidgin.soc.2007.finchfeat to allow showing empty
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18437
diff
changeset
|
2417 |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2418 item = gnt_menuitem_check_new(_("Offline buddies")); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2419 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "show-offline-buddies"); |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
2420 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), |
15822 | 2421 purple_prefs_get_bool(PREF_ROOT "/showoffline")); |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2422 gnt_menu_add_item(GNT_MENU(subsub), item); |
18442
6d8aed4adcd6
Minor changes to remove a couple of lines of duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18441
diff
changeset
|
2423 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), toggle_pref_cb, PREF_ROOT "/showoffline"); |
15817 | 2424 |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2425 item = gnt_menuitem_new(_("Sort")); |
15817 | 2426 gnt_menu_add_item(GNT_MENU(sub), item); |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2427 subsub = gnt_menu_new(GNT_MENU_POPUP); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2428 gnt_menuitem_set_submenu(item, GNT_MENU(subsub)); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2429 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2430 item = gnt_menuitem_new(_("By Status")); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2431 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "sort-status"); |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2432 gnt_menu_add_item(GNT_MENU(subsub), item); |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
2433 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), sort_blist_change_cb, "status"); |
15817 | 2434 |
20597
591267f6f1d5
propagate from branch 'im.pidgin.pidgin' (head 025faf23aaac403798451974c320c4de6df470d5)
Gabriel Schulhof <nix@go-nix.ca>
diff
changeset
|
2435 item = gnt_menuitem_new(_("Alphabetically")); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2436 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "sort-alpha"); |
20597
591267f6f1d5
propagate from branch 'im.pidgin.pidgin' (head 025faf23aaac403798451974c320c4de6df470d5)
Gabriel Schulhof <nix@go-nix.ca>
diff
changeset
|
2437 gnt_menu_add_item(GNT_MENU(subsub), item); |
15928
f00f2e283ffb
Some define changes. This helps in generating the python bindings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
2438 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), sort_blist_change_cb, "text"); |
15817 | 2439 |
20604
6c6fd163a992
Restoring gntblist.c:create_menu
Gabriel Schulhof <nix@go-nix.ca>
parents:
20603
diff
changeset
|
2440 item = gnt_menuitem_new(_("By Log Size")); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2441 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "sort-log"); |
20604
6c6fd163a992
Restoring gntblist.c:create_menu
Gabriel Schulhof <nix@go-nix.ca>
parents:
20603
diff
changeset
|
2442 gnt_menu_add_item(GNT_MENU(subsub), item); |
6c6fd163a992
Restoring gntblist.c:create_menu
Gabriel Schulhof <nix@go-nix.ca>
parents:
20603
diff
changeset
|
2443 gnt_menuitem_set_callback(GNT_MENU_ITEM(item), sort_blist_change_cb, "log"); |
6c6fd163a992
Restoring gntblist.c:create_menu
Gabriel Schulhof <nix@go-nix.ca>
parents:
20603
diff
changeset
|
2444 |
6c6fd163a992
Restoring gntblist.c:create_menu
Gabriel Schulhof <nix@go-nix.ca>
parents:
20603
diff
changeset
|
2445 item = gnt_menuitem_new(_("Add")); |
15817 | 2446 gnt_menu_add_item(GNT_MENU(sub), item); |
20604
6c6fd163a992
Restoring gntblist.c:create_menu
Gabriel Schulhof <nix@go-nix.ca>
parents:
20603
diff
changeset
|
2447 |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2448 subsub = gnt_menu_new(GNT_MENU_POPUP); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2449 gnt_menuitem_set_submenu(item, GNT_MENU(subsub)); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2450 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2451 item = gnt_menuitem_new("Buddy"); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2452 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "add-buddy"); |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2453 gnt_menu_add_item(GNT_MENU(subsub), item); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2454 gnt_menuitem_set_callback(item, menu_add_buddy_cb, NULL); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2455 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2456 item = gnt_menuitem_new("Chat"); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2457 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "add-chat"); |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2458 gnt_menu_add_item(GNT_MENU(subsub), item); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2459 gnt_menuitem_set_callback(item, menu_add_chat_cb, NULL); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2460 |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2461 item = gnt_menuitem_new("Group"); |
21214
05bb2853f350
Add IDs to the menuitems in the buddylist menu so they can have acceletor keys.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20739
diff
changeset
|
2462 gnt_menuitem_set_id(GNT_MENU_ITEM(item), "add-group"); |
20561
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2463 gnt_menu_add_item(GNT_MENU(subsub), item); |
c7b2c6ae3bea
Re-arrange the menu. Add 'Add buddy/chat/group' in the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
2464 gnt_menuitem_set_callback(item, menu_add_group_cb, NULL); |
15817 | 2465 |
2466 reconstruct_accounts_menu(); | |
2467 gnt_menu_add_item(GNT_MENU(menu), ggblist->accounts); | |
2468 | |
2469 reconstruct_plugins_menu(); | |
2470 gnt_menu_add_item(GNT_MENU(menu), ggblist->plugins); | |
2471 } | |
2472 | |
2473 void finch_blist_show() | |
2474 { | |
15822 | 2475 blist_show(purple_get_blist()); |
15817 | 2476 } |
2477 | |
2478 static void | |
16105
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
2479 group_collapsed(GntWidget *widget, PurpleBlistNode *node, gboolean collapsed, gpointer null) |
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
2480 { |
16106 | 2481 if (PURPLE_BLIST_NODE_IS_GROUP(node)) |
2482 purple_blist_node_set_bool(node, "collapsed", collapsed); | |
16105
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
2483 } |
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
2484 |
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
2485 static void |
15822 | 2486 blist_show(PurpleBuddyList *list) |
15817 | 2487 { |
2488 if (ggblist == NULL) | |
2489 new_list(list); | |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18332
diff
changeset
|
2490 else if (ggblist->window) { |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18332
diff
changeset
|
2491 gnt_window_present(ggblist->window); |
15817 | 2492 return; |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18332
diff
changeset
|
2493 } |
15817 | 2494 |
2495 ggblist->window = gnt_vwindow_new(FALSE); | |
2496 gnt_widget_set_name(ggblist->window, "buddylist"); | |
2497 gnt_box_set_toplevel(GNT_BOX(ggblist->window), TRUE); | |
2498 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List")); | |
2499 gnt_box_set_pad(GNT_BOX(ggblist->window), 0); | |
2500 | |
2501 ggblist->tree = gnt_tree_new(); | |
2502 | |
2503 GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER); | |
15822 | 2504 gnt_widget_set_size(ggblist->tree, purple_prefs_get_int(PREF_ROOT "/size/width"), |
2505 purple_prefs_get_int(PREF_ROOT "/size/height")); | |
2506 gnt_widget_set_position(ggblist->window, purple_prefs_get_int(PREF_ROOT "/position/x"), | |
2507 purple_prefs_get_int(PREF_ROOT "/position/y")); | |
15817 | 2508 |
2509 gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0, | |
15822 | 2510 purple_prefs_get_int(PREF_ROOT "/size/width") - 1); |
15817 | 2511 |
2512 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree); | |
2513 | |
2514 ggblist->status = gnt_combo_box_new(); | |
2515 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->status); | |
2516 ggblist->statustext = gnt_entry_new(NULL); | |
2517 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->statustext); | |
2518 | |
2519 gnt_widget_show(ggblist->window); | |
2520 | |
15822 | 2521 purple_signal_connect(purple_connections_get_handle(), "signed-on", finch_blist_get_handle(), |
2522 PURPLE_CALLBACK(reconstruct_accounts_menu), NULL); | |
2523 purple_signal_connect(purple_connections_get_handle(), "signed-off", finch_blist_get_handle(), | |
2524 PURPLE_CALLBACK(reconstruct_accounts_menu), NULL); | |
2525 purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed", finch_blist_get_handle(), | |
2526 PURPLE_CALLBACK(buddy_status_changed), ggblist); | |
2527 purple_signal_connect(purple_blist_get_handle(), "buddy-idle-changed", finch_blist_get_handle(), | |
2528 PURPLE_CALLBACK(buddy_idle_changed), ggblist); | |
15817 | 2529 |
15822 | 2530 purple_signal_connect(purple_plugins_get_handle(), "plugin-load", finch_blist_get_handle(), |
2531 PURPLE_CALLBACK(reconstruct_plugins_menu), NULL); | |
2532 purple_signal_connect(purple_plugins_get_handle(), "plugin-unload", finch_blist_get_handle(), | |
2533 PURPLE_CALLBACK(reconstruct_plugins_menu), NULL); | |
15817 | 2534 |
2535 #if 0 | |
15822 | 2536 purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", finch_blist_get_handle(), |
2537 PURPLE_CALLBACK(buddy_signed_on), ggblist); | |
2538 purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", finch_blist_get_handle(), | |
2539 PURPLE_CALLBACK(buddy_signed_off), ggblist); | |
15817 | 2540 |
2541 /* These I plan to use to indicate unread-messages etc. */ | |
15822 | 2542 purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", finch_blist_get_handle(), |
2543 PURPLE_CALLBACK(received_im_msg), list); | |
2544 purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", finch_blist_get_handle(), | |
2545 PURPLE_CALLBACK(sent_im_msg), NULL); | |
15817 | 2546 |
15822 | 2547 purple_signal_connect(purple_conversations_get_handle(), "received-chat-msg", finch_blist_get_handle(), |
2548 PURPLE_CALLBACK(received_chat_msg), list); | |
15817 | 2549 #endif |
2550 | |
2551 g_signal_connect(G_OBJECT(ggblist->tree), "selection_changed", G_CALLBACK(selection_changed), ggblist); | |
2552 g_signal_connect(G_OBJECT(ggblist->tree), "key_pressed", G_CALLBACK(key_pressed), ggblist); | |
2553 g_signal_connect(G_OBJECT(ggblist->tree), "context-menu", G_CALLBACK(context_menu), ggblist); | |
16105
1983ecd15174
Remember the collapsed state of groups in the blist
Richard Nelson <wabz@pidgin.im>
parents:
15928
diff
changeset
|
2554 g_signal_connect(G_OBJECT(ggblist->tree), "collapse-toggled", G_CALLBACK(group_collapsed), NULL); |
15817 | 2555 g_signal_connect_after(G_OBJECT(ggblist->tree), "clicked", G_CALLBACK(blist_clicked), ggblist); |
2556 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist); | |
2557 g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip), | |
2558 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); | |
2559 g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals), | |
2560 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); | |
17707
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16655
diff
changeset
|
2561 g_signal_connect_data(G_OBJECT(ggblist->window), "workspace-hidden", G_CALLBACK(remove_peripherals), |
3c3fc1432a01
Let windows know when the workspace they are in is being hidden/shown
Richard Nelson <wabz@pidgin.im>
parents:
16655
diff
changeset
|
2562 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED); |
15817 | 2563 g_signal_connect(G_OBJECT(ggblist->tree), "size_changed", G_CALLBACK(size_changed_cb), NULL); |
2564 g_signal_connect(G_OBJECT(ggblist->window), "position_set", G_CALLBACK(save_position_cb), NULL); | |
2565 g_signal_connect(G_OBJECT(ggblist->window), "destroy", G_CALLBACK(reset_blist_window), NULL); | |
2566 | |
2567 /* Status signals */ | |
15822 | 2568 purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-changed", finch_blist_get_handle(), |
2569 PURPLE_CALLBACK(savedstatus_changed), NULL); | |
15817 | 2570 g_signal_connect(G_OBJECT(ggblist->status), "selection_changed", |
2571 G_CALLBACK(status_selection_changed), NULL); | |
2572 g_signal_connect(G_OBJECT(ggblist->statustext), "key_pressed", | |
2573 G_CALLBACK(status_text_changed), NULL); | |
2574 | |
2575 create_menu(); | |
2576 | |
2577 populate_buddylist(); | |
2578 | |
15822 | 2579 savedstatus_changed(purple_savedstatus_get_current(), NULL); |
15817 | 2580 } |
2581 | |
2582 void finch_blist_uninit() | |
2583 { | |
2584 if (ggblist == NULL) | |
2585 return; | |
2586 | |
2587 gnt_widget_destroy(ggblist->window); | |
2588 g_free(ggblist); | |
2589 ggblist = NULL; | |
2590 } | |
2591 | |
2592 gboolean finch_blist_get_position(int *x, int *y) | |
2593 { | |
2594 if (!ggblist || !ggblist->window) | |
2595 return FALSE; | |
2596 gnt_widget_get_position(ggblist->window, x, y); | |
2597 return TRUE; | |
2598 } | |
2599 | |
2600 void finch_blist_set_position(int x, int y) | |
2601 { | |
2602 gnt_widget_set_position(ggblist->window, x, y); | |
2603 } | |
2604 | |
2605 gboolean finch_blist_get_size(int *width, int *height) | |
2606 { | |
2607 if (!ggblist || !ggblist->window) | |
2608 return FALSE; | |
2609 gnt_widget_get_size(ggblist->window, width, height); | |
2610 return TRUE; | |
2611 } | |
2612 | |
2613 void finch_blist_set_size(int width, int height) | |
2614 { | |
2615 gnt_widget_set_size(ggblist->window, width, height); | |
2616 } |