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