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