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