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