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