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