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