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