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