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