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