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