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