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