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