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