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