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