Mercurial > pidgin.yaz
annotate src/gtkblist.c @ 12127:944c97d11bb1
[gaim-migrate @ 14427]
SF Patch #1358278 from charkins
"There was likely a collision between the patch which
added the account-(en|dis)abled signals and a patch
which added cleaned up the signal documentation. The
lines for these signals are missing from the top of
account-signals.dox and ChangeLog.API. This patch adds
them in."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 18 Nov 2005 12:22:20 +0000 |
parents | 9c123e27e2f6 |
children | 8254bb99f929 |
rev | line source |
---|---|
5228 | 1 /* |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
2 * @file gtkblist.c GTK+ BuddyList API |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
3 * @ingroup gtkui |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
4 * |
5228 | 5 * gaim |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
5228 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
7620 | 28 |
29 #include "account.h" | |
9015 | 30 #include "connection.h" |
7620 | 31 #include "core.h" |
32 #include "debug.h" | |
33 #include "notify.h" | |
34 #include "prpl.h" | |
35 #include "prefs.h" | |
8986 | 36 #include "plugin.h" |
7620 | 37 #include "request.h" |
38 #include "signals.h" | |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10288
diff
changeset
|
39 #include "gtkstock.h" |
7620 | 40 #include "util.h" |
41 | |
42 #include "gtkaccount.h" | |
43 #include "gtkblist.h" | |
44 #include "gtkconv.h" | |
45 #include "gtkdebug.h" | |
9709 | 46 #include "gtkdialogs.h" |
7620 | 47 #include "gtkft.h" |
48 #include "gtklog.h" | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
49 #include "gtkmenutray.h" |
7620 | 50 #include "gtkpounce.h" |
11740 | 51 #include "gtkplugin.h" |
7620 | 52 #include "gtkprefs.h" |
53 #include "gtkprivacy.h" | |
8113 | 54 #include "gtkroomlist.h" |
10643 | 55 #include "gtkstatusbox.h" |
7620 | 56 #include "gtkutils.h" |
57 | |
5228 | 58 #include <gdk/gdkkeysyms.h> |
59 #include <gtk/gtk.h> | |
7620 | 60 #include <gdk/gdk.h> |
61 | |
62 typedef struct | |
63 { | |
64 GaimAccount *account; | |
65 | |
66 GtkWidget *window; | |
67 GtkWidget *combo; | |
68 GtkWidget *entry; | |
69 GtkWidget *entry_for_alias; | |
70 GtkWidget *account_box; | |
71 | |
72 } GaimGtkAddBuddyData; | |
73 | |
74 typedef struct | |
75 { | |
9811 | 76 GaimAccount *account; |
9812 | 77 gchar *default_chat_name; |
9811 | 78 |
79 GtkWidget *window; | |
7620 | 80 GtkWidget *account_menu; |
81 GtkWidget *alias_entry; | |
82 GtkWidget *group_combo; | |
83 GtkWidget *entries_box; | |
84 GtkSizeGroup *sg; | |
85 | |
86 GList *entries; | |
87 | |
88 } GaimGtkAddChatData; | |
89 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
90 typedef struct |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
91 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
92 GaimAccount *account; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
93 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
94 GtkWidget *window; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
95 GtkWidget *account_menu; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
96 GtkWidget *entries_box; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
97 GtkSizeGroup *sg; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
98 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
99 GList *entries; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
100 } GaimGtkJoinChatData; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
101 |
7620 | 102 |
9949 | 103 static GtkWidget *protomenu = NULL; |
5228 | 104 |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
105 static guint visibility_manager_count = 0; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
106 static gboolean gtk_blist_obscured = FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
107 |
11796 | 108 static GList *gaim_gtk_blist_sort_methods = NULL; |
5422 | 109 static struct gaim_gtk_blist_sort_method *current_sort_method = NULL; |
7620 | 110 static GtkTreeIter sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); |
111 | |
112 /* The functions we use for sorting aren't available in gtk 2.0.x, and | |
113 * segfault in 2.2.0. 2.2.1 is known to work, so I'll require that */ | |
114 #if GTK_CHECK_VERSION(2,2,1) | |
115 static GtkTreeIter sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); | |
116 static GtkTreeIter sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); | |
117 static GtkTreeIter sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur); | |
118 #endif | |
119 static GaimGtkBuddyList *gtkblist = NULL; | |
5228 | 120 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
121 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node); |
5228 | 122 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); |
7620 | 123 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node); |
5234 | 124 static char *gaim_get_tooltip_text(GaimBlistNode *node); |
5228 | 125 static char *item_factory_translate_func (const char *path, gpointer func_data); |
5273 | 126 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter); |
7620 | 127 static void redo_buddy_list(GaimBuddyList *list, gboolean remove); |
128 static void gaim_gtk_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node); | |
129 | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
130 static void gaim_gtk_blist_tooltip_destroy(); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
131 |
5256 | 132 struct _gaim_gtk_blist_node { |
133 GtkTreeRowReference *row; | |
7620 | 134 gboolean contact_expanded; |
11910 | 135 gboolean recent_signonoff; |
136 gint recent_signonoff_timer; | |
5256 | 137 }; |
138 | |
10968
e0d5038fbb7e
[gaim-migrate @ 12789]
Christopher O'Brien <siege@pidgin.im>
parents:
10924
diff
changeset
|
139 |
10118 | 140 static char dim_grey_string[8] = ""; |
10144 | 141 static char *dim_grey() |
10118 | 142 { |
143 if (!gtkblist) | |
144 return "dim grey"; | |
145 if (!dim_grey_string[0]) { | |
146 GtkStyle *style = gtk_widget_get_style(gtkblist->treeview); | |
147 snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x", | |
148 style->text_aa[GTK_STATE_NORMAL].red >> 8, | |
149 style->text_aa[GTK_STATE_NORMAL].green >> 8, | |
150 style->text_aa[GTK_STATE_NORMAL].blue >> 8); | |
151 } | |
152 return dim_grey_string; | |
153 } | |
10144 | 154 |
5228 | 155 /*************************************************** |
156 * Callbacks * | |
157 ***************************************************/ | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
158 static gboolean gtk_blist_visibility_cb(GtkWidget *w, GdkEventVisibility *event, gpointer data) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
159 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
160 if (event->state == GDK_VISIBILITY_FULLY_OBSCURED) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
161 gtk_blist_obscured = TRUE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
162 else |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
163 gtk_blist_obscured = FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
164 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
165 /* continue to handle event normally */ |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
166 return FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
167 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
168 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
169 static gboolean gtk_blist_window_state_cb(GtkWidget *w, GdkEventWindowState *event, gpointer data) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
170 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
171 if(event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
172 if(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
173 gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", FALSE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
174 else |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
175 gaim_prefs_set_bool("/gaim/gtk/blist/list_visible", TRUE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
176 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
177 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
178 return FALSE; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
179 } |
5228 | 180 |
181 static gboolean gtk_blist_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) | |
182 { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
183 if(visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
184 gaim_blist_set_visible(FALSE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
185 else |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
186 gaim_core_quit(); |
5228 | 187 |
188 /* we handle everything, event should not propogate further */ | |
189 return TRUE; | |
190 } | |
191 | |
192 static gboolean gtk_blist_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) | |
193 { | |
194 /* unfortunately GdkEventConfigure ignores the window gravity, but * | |
195 * the only way we have of setting the position doesn't. we have to * | |
7620 | 196 * call get_position because it does pay attention to the gravity. * |
197 * this is inefficient and I agree it sucks, but it's more likely * | |
198 * to work correctly. - Robot101 */ | |
5228 | 199 gint x, y; |
200 | |
201 /* check for visibility because when we aren't visible, this will * | |
202 * give us bogus (0,0) coordinates. - xOr */ | |
7620 | 203 if (GTK_WIDGET_VISIBLE(w)) |
5228 | 204 gtk_window_get_position(GTK_WINDOW(w), &x, &y); |
7620 | 205 else |
206 return FALSE; /* carry on normally */ | |
207 | |
208 /* don't save if nothing changed */ | |
209 if (x == gaim_prefs_get_int("/gaim/gtk/blist/x") && | |
210 y == gaim_prefs_get_int("/gaim/gtk/blist/y") && | |
211 event->width == gaim_prefs_get_int("/gaim/gtk/blist/width") && | |
212 event->height == gaim_prefs_get_int("/gaim/gtk/blist/height")) { | |
213 | |
214 return FALSE; /* carry on normally */ | |
5228 | 215 } |
216 | |
7620 | 217 /* don't save off-screen positioning */ |
218 if (x + event->width < 0 || | |
9811 | 219 y + event->height < 0 || |
220 x > gdk_screen_width() || | |
221 y > gdk_screen_height()) { | |
7620 | 222 |
223 return FALSE; /* carry on normally */ | |
224 } | |
225 | |
226 /* store the position */ | |
227 gaim_prefs_set_int("/gaim/gtk/blist/x", x); | |
228 gaim_prefs_set_int("/gaim/gtk/blist/y", y); | |
229 gaim_prefs_set_int("/gaim/gtk/blist/width", event->width); | |
230 gaim_prefs_set_int("/gaim/gtk/blist/height", event->height); | |
231 | |
5228 | 232 /* continue to handle event normally */ |
233 return FALSE; | |
234 } | |
235 | |
7620 | 236 static void gtk_blist_menu_info_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 237 { |
238 serv_get_info(b->account->gc, b->name); | |
239 } | |
240 | |
7620 | 241 static void gtk_blist_menu_im_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 242 { |
9728 | 243 gaim_gtkdialogs_im_with_user(b->account, b->name); |
5228 | 244 } |
245 | |
9466 | 246 static void gtk_blist_menu_send_file_cb(GtkWidget *w, GaimBuddy *b) |
247 { | |
248 serv_send_file(b->account->gc, b->name, NULL); | |
249 } | |
250 | |
12024 | 251 static void gtk_blist_menu_voice_chat_cb(GtkWidget *w, GaimBuddy *b) |
252 { | |
253 serv_voice_chat(b->account->gc, b->name); | |
254 } | |
255 | |
7620 | 256 static void gtk_blist_menu_autojoin_cb(GtkWidget *w, GaimChat *chat) |
257 { | |
7693 | 258 gaim_blist_node_set_bool((GaimBlistNode*)chat, "gtk-autojoin", |
259 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))); | |
7620 | 260 } |
261 | |
262 static void gtk_blist_menu_join_cb(GtkWidget *w, GaimChat *chat) | |
5228 | 263 { |
5234 | 264 serv_join_chat(chat->account->gc, chat->components); |
265 } | |
266 | |
11016 | 267 static void gtk_blist_renderer_edited_cb(GtkCellRendererText *text_rend, char *arg1, |
268 char *arg2, gpointer nada) | |
269 { | |
270 GtkTreeIter iter; | |
271 GtkTreePath *path; | |
272 GValue val = {0,}; | |
273 GaimBlistNode *node; | |
274 | |
275 path = gtk_tree_path_new_from_string (arg1); | |
276 gtk_tree_model_get_iter (GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
277 gtk_tree_path_free (path); | |
278 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
279 node = g_value_get_pointer(&val); | |
280 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), TRUE); | |
281 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", FALSE, NULL); | |
282 switch (node->type){ | |
283 case GAIM_BLIST_CONTACT_NODE: | |
284 gaim_blist_alias_buddy(gaim_contact_get_priority_buddy((GaimContact*)node), arg2); | |
285 break; | |
286 case GAIM_BLIST_BUDDY_NODE: | |
287 gaim_blist_alias_buddy((GaimBuddy*)node, arg2); | |
288 break; | |
289 case GAIM_BLIST_GROUP_NODE: | |
290 gaim_blist_rename_group((GaimGroup*)node, arg2); | |
291 break; | |
292 case GAIM_BLIST_CHAT_NODE: | |
293 gaim_blist_alias_chat((GaimChat*)node, arg2); | |
294 break; | |
295 default: | |
296 break; | |
297 } | |
298 } | |
299 | |
5234 | 300 static void gtk_blist_menu_alias_cb(GtkWidget *w, GaimBlistNode *node) |
301 { | |
11016 | 302 GtkTreeIter iter; |
303 GtkTreePath *path; | |
11258 | 304 const char *text = NULL; |
11494 | 305 |
11258 | 306 if (!(get_iter_from_node(node, &iter))) { |
11016 | 307 /* This is either a bug, or the buddy is in a collapsed contact */ |
308 node = node->parent; | |
309 if (!get_iter_from_node(node, &iter)) | |
310 /* Now it's definitely a bug */ | |
311 return; | |
312 } | |
11258 | 313 |
314 switch (node->type) { | |
315 case GAIM_BLIST_BUDDY_NODE: | |
316 text = gaim_buddy_get_alias((GaimBuddy *)node); | |
317 break; | |
318 case GAIM_BLIST_CONTACT_NODE: | |
319 text = gaim_buddy_get_alias(gaim_contact_get_priority_buddy((GaimContact *)node)); | |
320 break; | |
321 case GAIM_BLIST_GROUP_NODE: | |
322 text = ((GaimGroup *)node)->name; | |
323 break; | |
324 case GAIM_BLIST_CHAT_NODE: | |
325 text = gaim_chat_get_name((GaimChat *)node); | |
326 break; | |
327 default: | |
328 g_return_if_reached(); | |
329 } | |
330 | |
331 gtk_tree_store_set(gtkblist->treemodel, &iter, NAME_COLUMN, text, -1); | |
332 | |
11016 | 333 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); |
334 g_object_set(G_OBJECT(gtkblist->text_rend), "editable", TRUE, NULL); | |
335 gtk_tree_view_set_enable_search (GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
336 gtk_widget_grab_focus(gtkblist->treeview); | |
337 gtk_tree_view_set_cursor(GTK_TREE_VIEW(gtkblist->treeview), path, gtkblist->text_column, TRUE); | |
338 gtk_tree_path_free(path); | |
5228 | 339 } |
340 | |
7620 | 341 static void gtk_blist_menu_bp_cb(GtkWidget *w, GaimBuddy *b) |
5228 | 342 { |
7620 | 343 gaim_gtkpounce_dialog_show(b->account, b->name, NULL); |
5228 | 344 } |
345 | |
9917 | 346 static void gtk_blist_menu_showlog_cb(GtkWidget *w, GaimBlistNode *node) |
5228 | 347 { |
9917 | 348 GaimLogType type; |
349 GaimAccount *account; | |
350 char *name = NULL; | |
10663 | 351 |
9917 | 352 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
353 GaimBuddy *b = (GaimBuddy*) node; | |
354 type = GAIM_LOG_IM; | |
355 name = g_strdup(b->name); | |
356 account = b->account; | |
357 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { | |
358 GaimChat *c = (GaimChat*) node; | |
359 GaimPluginProtocolInfo *prpl_info = NULL; | |
360 type = GAIM_LOG_CHAT; | |
361 account = c->account; | |
362 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(account))); | |
363 if (prpl_info && prpl_info->get_chat_name) { | |
364 name = prpl_info->get_chat_name(c->components); | |
365 } | |
10663 | 366 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
367 gaim_gtk_log_show_contact((GaimContact *)node); | |
368 return; | |
9917 | 369 } else |
370 return; | |
371 | |
372 if (name && account) { | |
373 gaim_gtk_log_show(type, name, account); | |
374 g_free(name); | |
375 } | |
7620 | 376 } |
377 | |
5228 | 378 static void gtk_blist_show_systemlog_cb() |
379 { | |
8573 | 380 gaim_gtk_syslog_show(); |
5228 | 381 } |
382 | |
383 static void gtk_blist_show_onlinehelp_cb() | |
384 { | |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10229
diff
changeset
|
385 gaim_notify_uri(NULL, GAIM_WEBSITE "documentation.php"); |
5228 | 386 } |
387 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
388 static void |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
389 do_join_chat(GaimGtkJoinChatData *data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
390 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
391 if (data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
392 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
393 GHashTable *components = |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
394 g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
395 GList *tmp; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
396 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
397 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
398 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
399 if (g_object_get_data(tmp->data, "is_spin")) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
400 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
401 g_hash_table_replace(components, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
402 g_strdup(g_object_get_data(tmp->data, "identifier")), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
403 g_strdup_printf("%d", |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
404 gtk_spin_button_get_value_as_int(tmp->data))); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
405 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
406 else |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
407 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
408 g_hash_table_replace(components, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
409 g_strdup(g_object_get_data(tmp->data, "identifier")), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
410 g_strdup(gtk_entry_get_text(tmp->data))); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
411 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
412 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
413 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
414 serv_join_chat(gaim_account_get_connection(data->account), components); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
415 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
416 g_hash_table_destroy(components); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
417 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
418 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
419 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
420 static void |
8940 | 421 do_joinchat(GtkWidget *dialog, int id, GaimGtkJoinChatData *info) |
422 { | |
423 switch(id) | |
424 { | |
425 case GTK_RESPONSE_OK: | |
426 do_join_chat(info); | |
427 | |
428 break; | |
429 } | |
430 | |
431 gtk_widget_destroy(GTK_WIDGET(dialog)); | |
432 g_list_free(info->entries); | |
433 g_free(info); | |
434 } | |
435 | |
10475 | 436 /* |
437 * Check the values of all the text entry boxes. If any required input | |
438 * strings are empty then don't allow the user to click on "OK." | |
439 */ | |
440 static void | |
441 joinchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
442 { | |
443 GaimGtkJoinChatData *data; | |
444 GList *tmp; | |
445 const char *text; | |
446 gboolean required; | |
447 gboolean sensitive = TRUE; | |
448 | |
449 data = user_data; | |
450 | |
451 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
452 { | |
453 if (!g_object_get_data(tmp->data, "is_spin")) | |
454 { | |
455 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
456 text = gtk_entry_get_text(tmp->data); | |
457 if (required && (*text == '\0')) | |
458 sensitive = FALSE; | |
459 } | |
460 } | |
461 | |
462 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
463 } | |
464 | |
8940 | 465 static void |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
466 rebuild_joinchat_entries(GaimGtkJoinChatData *data) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
467 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
468 GaimConnection *gc; |
9959 | 469 GList *list = NULL, *tmp = NULL; |
9770 | 470 GHashTable *defaults = NULL; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
471 struct proto_chat_entry *pce; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
472 gboolean focus = TRUE; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
473 |
10127 | 474 g_return_if_fail(data->account != NULL); |
475 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
476 gc = gaim_account_get_connection(data->account); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
477 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
478 while (GTK_BOX(data->entries_box)->children) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
479 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
480 gtk_container_remove(GTK_CONTAINER(data->entries_box), |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
481 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
482 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
483 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
484 if (data->entries != NULL) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
485 g_list_free(data->entries); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
486 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
487 data->entries = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
488 |
9987 | 489 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
9959 | 490 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
491 |
9770 | 492 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
493 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, NULL); | |
494 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
495 for (tmp = list; tmp; tmp = tmp->next) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
496 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
497 GtkWidget *label; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
498 GtkWidget *rowbox; |
10475 | 499 GtkWidget *input; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
500 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
501 pce = tmp->data; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
502 |
11243 | 503 rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
504 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
505 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
506 label = gtk_label_new_with_mnemonic(pce->label); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
507 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
508 gtk_size_group_add_widget(data->sg, label); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
509 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
510 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
511 if (pce->is_int) |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
512 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
513 GtkObject *adjust; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
514 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
515 1, 10, 10); |
10475 | 516 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
517 gtk_widget_set_size_request(input, 50, -1); | |
518 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
519 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
520 else |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
521 { |
9770 | 522 char *value; |
10475 | 523 input = gtk_entry_new(); |
524 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9770 | 525 value = g_hash_table_lookup(defaults, pce->identifier); |
526 if (value != NULL) | |
10475 | 527 gtk_entry_set_text(GTK_ENTRY(input), value); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
528 if (pce->secret) |
11986 | 529 { |
10475 | 530 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 531 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
532 } | |
10475 | 533 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
534 g_signal_connect(G_OBJECT(input), "changed", | |
535 G_CALLBACK(joinchat_set_sensitive_if_input_cb), data); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
536 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
537 |
10475 | 538 /* Do the following for any type of input widget */ |
539 if (focus) | |
540 { | |
541 gtk_widget_grab_focus(input); | |
542 focus = FALSE; | |
543 } | |
544 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
545 gaim_set_accessible_label(input, label); | |
546 g_object_set_data(G_OBJECT(input), "identifier", pce->identifier); | |
547 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); | |
548 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
549 data->entries = g_list_append(data->entries, input); | |
550 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
551 g_free(pce); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
552 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
553 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
554 g_list_free(list); |
10475 | 555 g_hash_table_destroy(defaults); |
556 | |
557 /* Set whether the "OK" button should be clickable initially */ | |
558 joinchat_set_sensitive_if_input_cb(NULL, data); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
559 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
560 gtk_widget_show_all(data->entries_box); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
561 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
562 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
563 static void |
8940 | 564 joinchat_select_account_cb(GObject *w, GaimAccount *account, |
10475 | 565 GaimGtkJoinChatData *data) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
566 { |
9460 | 567 if (strcmp(gaim_account_get_protocol_id(data->account), |
10475 | 568 gaim_account_get_protocol_id(account)) == 0) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
569 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
570 data->account = account; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
571 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
572 else |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
573 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
574 data->account = account; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
575 rebuild_joinchat_entries(data); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
576 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
577 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
578 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
579 static gboolean |
9987 | 580 chat_account_filter_func(GaimAccount *account) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
581 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
582 GaimConnection *gc = gaim_account_get_connection(account); |
8940 | 583 GaimPluginProtocolInfo *prpl_info = NULL; |
584 | |
585 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
586 | |
587 return (prpl_info->chat_info != NULL); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
588 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
589 |
8940 | 590 gboolean |
591 gaim_gtk_blist_joinchat_is_showable() | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
592 { |
8940 | 593 GList *c; |
594 GaimConnection *gc; | |
595 | |
596 for (c = gaim_connections_get_all(); c != NULL; c = c->next) { | |
597 gc = c->data; | |
598 | |
9987 | 599 if (chat_account_filter_func(gaim_connection_get_account(gc))) |
8940 | 600 return TRUE; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
601 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
602 |
8940 | 603 return FALSE; |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
604 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
605 |
8305
57bdd25752c1
[gaim-migrate @ 9029]
Christian Hammond <chipx86@chipx86.com>
parents:
8303
diff
changeset
|
606 void |
8940 | 607 gaim_gtk_blist_joinchat_show(void) |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
608 { |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
609 GtkWidget *hbox, *vbox; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
610 GtkWidget *rowbox; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
611 GtkWidget *label; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
612 GaimGtkBuddyList *gtkblist; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
613 GtkWidget *img = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
614 GaimGtkJoinChatData *data = NULL; |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
615 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
616 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
617 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
618 GTK_ICON_SIZE_DIALOG); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
619 data = g_new0(GaimGtkJoinChatData, 1); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
620 |
8975 | 621 data->window = gtk_dialog_new_with_buttons(_("Join a Chat"), |
622 NULL, GTK_DIALOG_NO_SEPARATOR, | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
623 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
8308 | 624 GAIM_STOCK_CHAT, GTK_RESPONSE_OK, NULL); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
625 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); |
11243 | 626 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
627 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 628 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
629 gtk_container_set_border_width( |
11243 | 630 GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); |
8975 | 631 gtk_window_set_role(GTK_WINDOW(data->window), "join_chat"); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
632 |
11243 | 633 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
634 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
635 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
636 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
637 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
638 vbox = gtk_vbox_new(FALSE, 5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
639 gtk_container_set_border_width(GTK_CONTAINER(vbox), 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
640 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
641 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
642 label = gtk_label_new(_("Please enter the appropriate information " |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
643 "about the chat you would like to join.\n")); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
644 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
645 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
646 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
647 |
11243 | 648 rowbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
649 gtk_box_pack_start(GTK_BOX(vbox), rowbox, TRUE, TRUE, 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
650 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
651 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
652 |
8940 | 653 label = gtk_label_new_with_mnemonic(_("_Account:")); |
654 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
655 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
656 gtk_size_group_add_widget(data->sg, label); | |
657 | |
658 data->account_menu = gaim_gtk_account_option_menu_new(NULL, FALSE, | |
659 G_CALLBACK(joinchat_select_account_cb), | |
9987 | 660 chat_account_filter_func, data); |
8940 | 661 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
662 gtk_label_set_mnemonic_widget(GTK_LABEL(label), | |
663 GTK_WIDGET(data->account_menu)); | |
664 gaim_set_accessible_label (data->account_menu, label); | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
665 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
666 data->entries_box = gtk_vbox_new(FALSE, 5); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
667 gtk_container_add(GTK_CONTAINER(vbox), data->entries_box); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
668 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
669 |
8940 | 670 data->account = gaim_gtk_account_option_menu_get_selected(data->account_menu); |
671 | |
8303
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
672 rebuild_joinchat_entries(data); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
673 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
674 g_signal_connect(G_OBJECT(data->window), "response", |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
675 G_CALLBACK(do_joinchat), data); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
676 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
677 g_object_unref(data->sg); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
678 |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
679 gtk_widget_show_all(data->window); |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
680 } |
4eb4b2a6c604
[gaim-migrate @ 9027]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
681 |
5228 | 682 static void gtk_blist_row_expanded_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) { |
683 GaimBlistNode *node; | |
684 GValue val = {0,}; | |
685 | |
686 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val); | |
687 | |
688 node = g_value_get_pointer(&val); | |
689 | |
690 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7693 | 691 gaim_blist_node_set_bool(node, "collapsed", FALSE); |
5228 | 692 } |
693 } | |
694 | |
695 static void gtk_blist_row_collapsed_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) { | |
696 GaimBlistNode *node; | |
697 GValue val = {0,}; | |
698 | |
699 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val); | |
700 | |
701 node = g_value_get_pointer(&val); | |
702 | |
703 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7693 | 704 gaim_blist_node_set_bool(node, "collapsed", TRUE); |
7620 | 705 } else if(GAIM_BLIST_NODE_IS_CONTACT(node)) { |
706 gaim_gtk_blist_collapse_contact_cb(NULL, node); | |
5228 | 707 } |
708 } | |
709 | |
710 static void gtk_blist_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) { | |
711 GaimBlistNode *node; | |
712 GtkTreeIter iter; | |
713 GValue val = { 0, }; | |
714 | |
715 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
716 | |
717 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
718 node = g_value_get_pointer(&val); | |
719 | |
7620 | 720 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { |
721 GaimBuddy *buddy; | |
722 | |
723 if(GAIM_BLIST_NODE_IS_CONTACT(node)) | |
724 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
725 else | |
726 buddy = (GaimBuddy*)node; | |
727 | |
9728 | 728 gaim_gtkdialogs_im_with_user(buddy->account, buddy->name); |
5234 | 729 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
7620 | 730 serv_join_chat(((GaimChat *)node)->account->gc, ((GaimChat *)node)->components); |
5228 | 731 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
732 if (gtk_tree_view_row_expanded(tv, path)) | |
733 gtk_tree_view_collapse_row(tv, path); | |
734 else | |
735 gtk_tree_view_expand_row(tv,path,FALSE); | |
736 } | |
737 } | |
738 | |
5234 | 739 static void gaim_gtk_blist_add_chat_cb() |
740 { | |
741 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
742 GtkTreeIter iter; | |
743 GaimBlistNode *node; | |
744 | |
745 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){ | |
746 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
7620 | 747 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
9754 | 748 gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent->parent, NULL, NULL); |
7620 | 749 if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node)) |
9754 | 750 gaim_blist_request_add_chat(NULL, (GaimGroup*)node->parent, NULL, NULL); |
5234 | 751 else if (GAIM_BLIST_NODE_IS_GROUP(node)) |
9754 | 752 gaim_blist_request_add_chat(NULL, (GaimGroup*)node, NULL, NULL); |
5234 | 753 } |
754 else { | |
9754 | 755 gaim_blist_request_add_chat(NULL, NULL, NULL, NULL); |
5234 | 756 } |
757 } | |
758 | |
5228 | 759 static void gaim_gtk_blist_add_buddy_cb() |
760 { | |
761 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
762 GtkTreeIter iter; | |
763 GaimBlistNode *node; | |
764 | |
765 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){ | |
766 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
7620 | 767 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
768 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node->parent->parent)->name, | |
769 NULL); | |
770 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) | |
771 || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
772 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node->parent)->name, NULL); | |
773 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
774 gaim_blist_request_add_buddy(NULL, NULL, ((GaimGroup*)node)->name, NULL); | |
775 } | |
5228 | 776 } |
777 else { | |
7620 | 778 gaim_blist_request_add_buddy(NULL, NULL, NULL, NULL); |
779 } | |
780 } | |
781 | |
782 static void | |
783 gaim_gtk_blist_remove_cb (GtkWidget *w, GaimBlistNode *node) | |
784 { | |
785 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
9730 | 786 gaim_gtkdialogs_remove_buddy((GaimBuddy*)node); |
7620 | 787 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
9730 | 788 gaim_gtkdialogs_remove_chat((GaimChat*)node); |
7620 | 789 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
9730 | 790 gaim_gtkdialogs_remove_group((GaimGroup*)node); |
7620 | 791 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { |
9730 | 792 gaim_gtkdialogs_remove_contact((GaimContact*)node); |
5228 | 793 } |
794 } | |
795 | |
796 static void | |
7620 | 797 gaim_gtk_blist_expand_contact_cb(GtkWidget *w, GaimBlistNode *node) |
5228 | 798 { |
7620 | 799 struct _gaim_gtk_blist_node *gtknode; |
9632 | 800 GtkTreeIter iter, parent; |
7620 | 801 GaimBlistNode *bnode; |
10325 | 802 GtkTreePath *path; |
7620 | 803 |
804 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) | |
805 return; | |
806 | |
807 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
808 | |
809 gtknode->contact_expanded = TRUE; | |
810 | |
811 for(bnode = node->child; bnode; bnode = bnode->next) { | |
812 gaim_gtk_blist_update(NULL, bnode); | |
813 } | |
10353 | 814 |
9632 | 815 /* This ensures that the bottom buddy is visible, i.e. not scrolled off the alignment */ |
816 get_iter_from_node(node, &parent); | |
10353 | 817 gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(gtkblist->treemodel), &iter, &parent, |
9811 | 818 gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtkblist->treemodel), &parent) -1); |
9632 | 819 path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); |
820 /* Let the treeview draw so it knows where to scroll */ | |
821 while (gtk_events_pending()) | |
822 gtk_main_iteration(); | |
10353 | 823 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(gtkblist->treeview), path, NULL, FALSE, 0, 0); |
824 | |
9632 | 825 |
7620 | 826 gaim_gtk_blist_update(NULL, node); |
9632 | 827 gtk_tree_path_free(path); |
7620 | 828 } |
829 | |
830 static void | |
831 gaim_gtk_blist_collapse_contact_cb(GtkWidget *w, GaimBlistNode *node) | |
832 { | |
833 GaimBlistNode *bnode; | |
834 struct _gaim_gtk_blist_node *gtknode; | |
835 | |
836 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) | |
837 return; | |
838 | |
839 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
840 | |
841 gtknode->contact_expanded = FALSE; | |
842 | |
843 for(bnode = node->child; bnode; bnode = bnode->next) { | |
844 gaim_gtk_blist_update(NULL, bnode); | |
5228 | 845 } |
846 } | |
847 | |
9030 | 848 |
849 static void | |
850 blist_node_menu_cb(GtkMenuItem *item, GaimBlistNode *node) | |
851 { | |
11638 | 852 void (*callback)(GaimBlistNode *, gpointer); |
853 gpointer data; | |
854 callback = g_object_get_data(G_OBJECT(item), "gaimcallback"); | |
855 data = g_object_get_data(G_OBJECT(item), "gaimcallbackdata"); | |
856 if (callback) | |
857 callback(node, data); | |
9030 | 858 } |
859 | |
860 | |
861 static void | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
862 append_blist_node_action(GtkWidget *menu, GaimBlistNodeAction *act, |
9030 | 863 GaimBlistNode *node, gboolean *dup_separator) |
5228 | 864 { |
9030 | 865 if(act == NULL) { |
866 if(! *dup_separator) { | |
867 gaim_separator(menu); | |
868 *dup_separator = TRUE; | |
869 } | |
870 } else { | |
871 GtkWidget *menuitem; | |
872 | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
873 if (act->children == NULL) { |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
874 *dup_separator = FALSE; |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
875 |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
876 menuitem = gtk_menu_item_new_with_mnemonic(act->label); |
11038
aedd557f46dd
[gaim-migrate @ 12935]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
877 if (act->callback != NULL) { |
aedd557f46dd
[gaim-migrate @ 12935]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
878 g_object_set_data(G_OBJECT(menuitem), "gaimcallback", |
11638 | 879 act->callback); |
880 g_object_set_data(G_OBJECT(menuitem), "gaimcallbackdata", | |
881 act->data); | |
11038
aedd557f46dd
[gaim-migrate @ 12935]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
882 g_signal_connect(G_OBJECT(menuitem), "activate", |
aedd557f46dd
[gaim-migrate @ 12935]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
883 G_CALLBACK(blist_node_menu_cb), node); |
aedd557f46dd
[gaim-migrate @ 12935]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
884 } else { |
aedd557f46dd
[gaim-migrate @ 12935]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
885 gtk_widget_set_sensitive(menuitem, FALSE); |
aedd557f46dd
[gaim-migrate @ 12935]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
886 } |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
887 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
888 } else { |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
889 GtkWidget *submenu = NULL; |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
890 GList *l = NULL; |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
891 |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
892 menuitem = gtk_menu_item_new_with_mnemonic(act->label); |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
893 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
894 |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
895 submenu = gtk_menu_new(); |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
896 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
897 |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
898 for (l = act->children; l; l = l->next) { |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
899 GaimBlistNodeAction *act = (GaimBlistNodeAction *) l->data; |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
900 |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
901 append_blist_node_action(submenu, act, node, dup_separator); |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
902 } |
11638 | 903 g_list_free(act->children); |
904 act->children = NULL; | |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
905 } |
11638 | 906 g_free(act); |
9030 | 907 } |
5228 | 908 } |
909 | |
9030 | 910 |
9051 | 911 void |
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
912 gaim_gtk_append_blist_node_proto_menu(GtkWidget *menu, GaimConnection *gc, |
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10643
diff
changeset
|
913 GaimBlistNode *node) |
9030 | 914 { |
915 GList *l, *ll; | |
916 gboolean dup_separator = FALSE; | |
917 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
918 | |
919 if(!prpl_info || !prpl_info->blist_node_menu) | |
920 return; | |
921 | |
922 for(l = ll = prpl_info->blist_node_menu(node); l; l = l->next) { | |
923 GaimBlistNodeAction *act = (GaimBlistNodeAction *) l->data; | |
924 append_blist_node_action(menu, act, node, &dup_separator); | |
925 } | |
926 g_list_free(ll); | |
927 } | |
928 | |
929 | |
9051 | 930 void |
931 gaim_gtk_append_blist_node_extended_menu (GtkWidget *menu, GaimBlistNode *node) | |
9030 | 932 { |
933 GList *l, *ll; | |
934 gboolean dup_separator = FALSE; | |
935 | |
936 for(l = ll = gaim_blist_node_get_extended_menu(node); l; l = l->next) { | |
937 GaimBlistNodeAction *act = (GaimBlistNodeAction *) l->data; | |
938 append_blist_node_action(menu, act, node, &dup_separator); | |
939 } | |
940 g_list_free(ll); | |
941 } | |
942 | |
943 | |
9774 | 944 void |
10484 | 945 gaim_gtk_blist_make_buddy_menu(GtkWidget *menu, GaimBuddy *buddy, gboolean sub) { |
9774 | 946 GaimPluginProtocolInfo *prpl_info; |
10663 | 947 GaimContact *contact; |
948 gboolean contact_expanded = FALSE; | |
9774 | 949 |
950 g_return_if_fail(menu); | |
951 g_return_if_fail(buddy); | |
952 | |
953 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl); | |
954 | |
10663 | 955 contact = gaim_buddy_get_contact(buddy); |
956 if (contact) { | |
957 contact_expanded = ((struct _gaim_gtk_blist_node *)(((GaimBlistNode*)contact)->ui_data))->contact_expanded; | |
958 } | |
959 | |
7620 | 960 if (prpl_info && prpl_info->get_info) { |
8137 | 961 gaim_new_item_from_stock(menu, _("Get _Info"), GAIM_STOCK_INFO, |
9774 | 962 G_CALLBACK(gtk_blist_menu_info_cb), buddy, 0, 0, NULL); |
7620 | 963 } |
8137 | 964 gaim_new_item_from_stock(menu, _("I_M"), GAIM_STOCK_IM, |
9774 | 965 G_CALLBACK(gtk_blist_menu_im_cb), buddy, 0, 0, NULL); |
9466 | 966 if (prpl_info && prpl_info->send_file) { |
9774 | 967 if (!prpl_info->can_receive_file || |
968 prpl_info->can_receive_file(buddy->account->gc, buddy->name)) | |
969 { | |
970 gaim_new_item_from_stock(menu, _("_Send File"), | |
971 GAIM_STOCK_FILE_TRANSFER, | |
972 G_CALLBACK(gtk_blist_menu_send_file_cb), | |
973 buddy, 0, 0, NULL); | |
9466 | 974 } |
975 } | |
12024 | 976 |
977 if (prpl_info && prpl_info->media_prpl_ops && prpl_info->media_prpl_ops->call) { | |
978 gaim_new_item_from_stock(menu, _("Start _Voice Chat"), | |
979 GAIM_STOCK_VOICE_CHAT, | |
980 G_CALLBACK(gtk_blist_menu_voice_chat_cb), | |
981 buddy, 0, 0, NULL); | |
982 } | |
983 | |
7620 | 984 gaim_new_item_from_stock(menu, _("Add Buddy _Pounce"), NULL, |
9774 | 985 G_CALLBACK(gtk_blist_menu_bp_cb), buddy, 0, 0, NULL); |
10663 | 986 |
987 if(((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { | |
988 gaim_new_item_from_stock(menu, _("View _Log"), NULL, | |
989 G_CALLBACK(gtk_blist_menu_showlog_cb), | |
990 contact, 0, 0, NULL); | |
991 } else if (!sub) { | |
992 gaim_new_item_from_stock(menu, _("View _Log"), NULL, | |
993 G_CALLBACK(gtk_blist_menu_showlog_cb), buddy, 0, 0, NULL); | |
994 } | |
9774 | 995 |
996 gaim_gtk_append_blist_node_proto_menu(menu, buddy->account->gc, | |
997 (GaimBlistNode *)buddy); | |
998 gaim_gtk_append_blist_node_extended_menu(menu, (GaimBlistNode *)buddy); | |
7620 | 999 |
1000 gaim_separator(menu); | |
9030 | 1001 |
10663 | 1002 if(((GaimBlistNode*)buddy)->parent->child->next && !sub && !contact_expanded) { |
9925 | 1003 gaim_new_item_from_stock(menu, _("_Alias Buddy..."), GAIM_STOCK_ALIAS, |
1004 G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL); | |
1005 gaim_new_item_from_stock(menu, _("_Remove Buddy"), GTK_STOCK_REMOVE, | |
1006 G_CALLBACK(gaim_gtk_blist_remove_cb), buddy, 0, 0, NULL); | |
1007 gaim_new_item_from_stock(menu, _("Alias Contact..."), GAIM_STOCK_ALIAS, | |
1008 G_CALLBACK(gtk_blist_menu_alias_cb), | |
10663 | 1009 contact, 0, 0, NULL); |
9925 | 1010 gaim_new_item_from_stock(menu, _("Remove Contact"), GTK_STOCK_REMOVE, |
1011 G_CALLBACK(gaim_gtk_blist_remove_cb), | |
10663 | 1012 contact, 0, 0, NULL); |
9925 | 1013 } else { |
1014 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, | |
1015 G_CALLBACK(gtk_blist_menu_alias_cb), buddy, 0, 0, NULL); | |
1016 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, | |
1017 G_CALLBACK(gaim_gtk_blist_remove_cb), buddy, | |
1018 0, 0, NULL); | |
1019 } | |
7620 | 1020 } |
1021 | |
9774 | 1022 static gboolean |
1023 gtk_blist_key_press_cb(GtkWidget *tv, GdkEventKey *event, gpointer data) { | |
7620 | 1024 GaimBlistNode *node; |
1025 GValue val = { 0, }; | |
1026 GtkTreeIter iter; | |
1027 GtkTreeSelection *sel; | |
1028 | |
1029 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1030 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1031 return FALSE; | |
1032 | |
1033 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
1034 NODE_COLUMN, &val); | |
1035 node = g_value_get_pointer(&val); | |
1036 | |
1037 if(event->state & GDK_CONTROL_MASK && | |
1038 (event->keyval == 'o' || event->keyval == 'O')) { | |
1039 GaimBuddy *buddy; | |
1040 | |
1041 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1042 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1043 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1044 buddy = (GaimBuddy*)node; | |
1045 } else { | |
1046 return FALSE; | |
1047 } | |
1048 if(buddy) | |
1049 serv_get_info(buddy->account->gc, buddy->name); | |
1050 } | |
1051 | |
1052 return FALSE; | |
1053 } | |
1054 | |
9013 | 1055 |
8143 | 1056 static GtkWidget * |
8952 | 1057 create_group_menu (GaimBlistNode *node, GaimGroup *g) |
8143 | 1058 { |
1059 GtkWidget *menu; | |
11988 | 1060 GtkWidget *item; |
8143 | 1061 |
1062 menu = gtk_menu_new(); | |
1063 gaim_new_item_from_stock(menu, _("Add a _Buddy"), GTK_STOCK_ADD, | |
1064 G_CALLBACK(gaim_gtk_blist_add_buddy_cb), node, 0, 0, NULL); | |
11988 | 1065 item = gaim_new_item_from_stock(menu, _("Add a C_hat"), GTK_STOCK_ADD, |
8143 | 1066 G_CALLBACK(gaim_gtk_blist_add_chat_cb), node, 0, 0, NULL); |
11988 | 1067 gtk_widget_set_sensitive(item, gaim_gtk_blist_joinchat_is_showable()); |
8143 | 1068 gaim_new_item_from_stock(menu, _("_Delete Group"), GTK_STOCK_REMOVE, |
1069 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
1070 gaim_new_item_from_stock(menu, _("_Rename"), NULL, | |
11016 | 1071 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
8952 | 1072 |
9051 | 1073 gaim_gtk_append_blist_node_extended_menu(menu, node); |
8952 | 1074 |
8143 | 1075 return menu; |
1076 } | |
1077 | |
8586 | 1078 |
8143 | 1079 static GtkWidget * |
9774 | 1080 create_chat_menu(GaimBlistNode *node, GaimChat *c) { |
8143 | 1081 GtkWidget *menu; |
9030 | 1082 gboolean autojoin; |
8143 | 1083 |
1084 menu = gtk_menu_new(); | |
9030 | 1085 autojoin = (gaim_blist_node_get_bool(node, "gtk-autojoin") || |
1086 (gaim_blist_node_get_string(node, "gtk-autojoin") != NULL)); | |
1087 | |
8143 | 1088 gaim_new_item_from_stock(menu, _("_Join"), GAIM_STOCK_CHAT, |
9030 | 1089 G_CALLBACK(gtk_blist_menu_join_cb), node, 0, 0, NULL); |
8143 | 1090 gaim_new_check_item(menu, _("Auto-Join"), |
9030 | 1091 G_CALLBACK(gtk_blist_menu_autojoin_cb), node, autojoin); |
9917 | 1092 gaim_new_item_from_stock(menu, _("View _Log"), NULL, |
1093 G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL); | |
9030 | 1094 |
9051 | 1095 gaim_gtk_append_blist_node_proto_menu(menu, c->account->gc, node); |
1096 gaim_gtk_append_blist_node_extended_menu(menu, node); | |
8586 | 1097 |
1098 gaim_separator(menu); | |
9030 | 1099 |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8259
diff
changeset
|
1100 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
8143 | 1101 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
1102 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, | |
1103 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
8586 | 1104 |
8143 | 1105 return menu; |
1106 } | |
1107 | |
1108 static GtkWidget * | |
1109 create_contact_menu (GaimBlistNode *node) | |
1110 { | |
1111 GtkWidget *menu; | |
1112 | |
1113 menu = gtk_menu_new(); | |
10663 | 1114 |
1115 gaim_new_item_from_stock(menu, _("View _Log"), NULL, | |
1116 G_CALLBACK(gtk_blist_menu_showlog_cb), | |
1117 node, 0, 0, NULL); | |
1118 | |
1119 gaim_separator(menu); | |
1120 | |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8259
diff
changeset
|
1121 gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS, |
8143 | 1122 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL); |
10663 | 1123 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, |
1124 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL); | |
1125 | |
1126 gaim_separator(menu); | |
1127 | |
8143 | 1128 gaim_new_item_from_stock(menu, _("_Collapse"), GTK_STOCK_ZOOM_OUT, |
1129 G_CALLBACK(gaim_gtk_blist_collapse_contact_cb), | |
1130 node, 0, 0, NULL); | |
9051 | 1131 |
1132 gaim_gtk_append_blist_node_extended_menu(menu, node); | |
1133 | |
8143 | 1134 return menu; |
1135 } | |
1136 | |
1137 static GtkWidget * | |
9774 | 1138 create_buddy_menu(GaimBlistNode *node, GaimBuddy *b) { |
8143 | 1139 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
1140 GtkWidget *menu; | |
1141 GtkWidget *menuitem; | |
1142 gboolean show_offline = gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies"); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
1143 |
8143 | 1144 menu = gtk_menu_new(); |
10484 | 1145 gaim_gtk_blist_make_buddy_menu(menu, b, FALSE); |
8143 | 1146 |
1147 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1148 gaim_separator(menu); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
1149 |
8143 | 1150 if(gtknode->contact_expanded) { |
1151 gaim_new_item_from_stock(menu, _("_Collapse"), | |
1152 GTK_STOCK_ZOOM_OUT, | |
1153 G_CALLBACK(gaim_gtk_blist_collapse_contact_cb), | |
1154 node, 0, 0, NULL); | |
1155 } else { | |
1156 gaim_new_item_from_stock(menu, _("_Expand"), | |
1157 GTK_STOCK_ZOOM_IN, | |
1158 G_CALLBACK(gaim_gtk_blist_expand_contact_cb), node, | |
1159 0, 0, NULL); | |
1160 } | |
1161 if(node->child->next) { | |
1162 GaimBlistNode *bnode; | |
1163 | |
1164 for(bnode = node->child; bnode; bnode = bnode->next) { | |
1165 GaimBuddy *buddy = (GaimBuddy*)bnode; | |
9340 | 1166 GdkPixbuf *buf; |
8143 | 1167 GtkWidget *submenu; |
1168 GtkWidget *image; | |
1169 | |
1170 if(buddy == b) | |
1171 continue; | |
1172 if(!buddy->account->gc) | |
1173 continue; | |
1174 if(!show_offline && !GAIM_BUDDY_IS_ONLINE(buddy)) | |
1175 continue; | |
1176 | |
1177 menuitem = gtk_image_menu_item_new_with_label(buddy->name); | |
9340 | 1178 buf = gaim_gtk_blist_get_status_icon(bnode, |
1179 GAIM_STATUS_ICON_SMALL); | |
1180 image = gtk_image_new_from_pixbuf(buf); | |
1181 g_object_unref(G_OBJECT(buf)); | |
8143 | 1182 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), |
9811 | 1183 image); |
8143 | 1184 gtk_widget_show(image); |
1185 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
1186 gtk_widget_show(menuitem); | |
1187 | |
1188 submenu = gtk_menu_new(); | |
1189 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
1190 gtk_widget_show(submenu); | |
1191 | |
10484 | 1192 gaim_gtk_blist_make_buddy_menu(submenu, buddy, TRUE); |
8143 | 1193 } |
1194 } | |
1195 } | |
1196 return menu; | |
1197 } | |
1198 | |
1199 static gboolean | |
1200 gaim_gtk_blist_show_context_menu(GaimBlistNode *node, | |
1201 GtkMenuPositionFunc func, | |
1202 GtkWidget *tv, | |
1203 guint button, | |
1204 guint32 time) | |
1205 { | |
1206 struct _gaim_gtk_blist_node *gtknode; | |
1207 GtkWidget *menu = NULL; | |
1208 gboolean handled = FALSE; | |
1209 | |
1210 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
1211 | |
1212 /* Create a menu based on the thing we right-clicked on */ | |
1213 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
8952 | 1214 GaimGroup *g = (GaimGroup *)node; |
9774 | 1215 |
8952 | 1216 menu = create_group_menu(node, g); |
8143 | 1217 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) { |
8586 | 1218 GaimChat *c = (GaimChat *)node; |
9774 | 1219 |
1220 menu = create_chat_menu(node, c); | |
8143 | 1221 } else if ((GAIM_BLIST_NODE_IS_CONTACT(node)) && (gtknode->contact_expanded)) { |
1222 menu = create_contact_menu(node); | |
1223 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1224 GaimBuddy *b; | |
1225 | |
1226 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1227 b = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1228 else | |
1229 b = (GaimBuddy *)node; | |
1230 | |
9774 | 1231 menu = create_buddy_menu(node, b); |
8143 | 1232 } |
1233 | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1234 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1235 /* Unhook the tooltip-timeout since we don't want a tooltip |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1236 * to appear and obscure the context menu we are about to show |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1237 This is a workaround for GTK+ bug 107320. */ |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1238 if (gtkblist->timeout) { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1239 g_source_remove(gtkblist->timeout); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1240 gtkblist->timeout = 0; |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1241 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1242 #endif |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1243 |
8143 | 1244 /* Now display the menu */ |
1245 if (menu != NULL) { | |
1246 gtk_widget_show_all(menu); | |
1247 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, func, tv, button, time); | |
1248 handled = TRUE; | |
1249 } | |
1250 | |
1251 return handled; | |
1252 } | |
1253 | |
1254 static gboolean gtk_blist_button_press_cb(GtkWidget *tv, GdkEventButton *event, gpointer user_data) | |
5228 | 1255 { |
1256 GtkTreePath *path; | |
1257 GaimBlistNode *node; | |
1258 GValue val = { 0, }; | |
1259 GtkTreeIter iter; | |
1260 GtkTreeSelection *sel; | |
1261 GaimPlugin *prpl = NULL; | |
1262 GaimPluginProtocolInfo *prpl_info = NULL; | |
7620 | 1263 struct _gaim_gtk_blist_node *gtknode; |
1264 gboolean handled = FALSE; | |
5228 | 1265 |
1266 /* Here we figure out which node was clicked */ | |
1267 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL)) | |
1268 return FALSE; | |
1269 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
8143 | 1270 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); |
5228 | 1271 node = g_value_get_pointer(&val); |
7620 | 1272 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
1273 | |
8143 | 1274 /* Right click draws a context menu */ |
1275 if ((event->button == 3) && (event->type == GDK_BUTTON_PRESS)) { | |
1276 handled = gaim_gtk_blist_show_context_menu(node, NULL, tv, 3, event->time); | |
1277 | |
1278 /* CTRL+middle click expands or collapse a contact */ | |
1279 } else if ((event->button == 2) && (event->type == GDK_BUTTON_PRESS) && | |
1280 (event->state & GDK_CONTROL_MASK) && (GAIM_BLIST_NODE_IS_CONTACT(node))) { | |
1281 if (gtknode->contact_expanded) | |
7620 | 1282 gaim_gtk_blist_collapse_contact_cb(NULL, node); |
1283 else | |
1284 gaim_gtk_blist_expand_contact_cb(NULL, node); | |
1285 handled = TRUE; | |
8143 | 1286 |
1287 /* Double middle click gets info */ | |
1288 } else if ((event->button == 2) && (event->type == GDK_2BUTTON_PRESS) && | |
1289 ((GAIM_BLIST_NODE_IS_CONTACT(node)) || (GAIM_BLIST_NODE_IS_BUDDY(node)))) { | |
7620 | 1290 GaimBuddy *b; |
1291 if(GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1292 b = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1293 else | |
1294 b = (GaimBuddy *)node; | |
1295 | |
7956 | 1296 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5228 | 1297 if (prpl != NULL) |
1298 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
1299 | |
8143 | 1300 if (prpl && prpl_info->get_info) |
1301 serv_get_info(b->account->gc, b->name); | |
1302 handled = TRUE; | |
5228 | 1303 } |
1304 | |
8143 | 1305 #if (1) |
1306 /* | |
10814
364a2ef907ae
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10780
diff
changeset
|
1307 * This code only exists because GTK+ doesn't work. If we return |
8143 | 1308 * FALSE here, as would be normal the event propoagates down and |
1309 * somehow gets interpreted as the start of a drag event. | |
1310 * | |
1311 * Um, isn't it _normal_ to return TRUE here? Since the event | |
1312 * was handled? --Mark | |
1313 */ | |
7620 | 1314 if(handled) { |
1315 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1316 gtk_tree_selection_select_path(sel, path); | |
1317 gtk_tree_path_free(path); | |
1318 return TRUE; | |
1319 } | |
5228 | 1320 #endif |
7753 | 1321 gtk_tree_path_free(path); |
8143 | 1322 |
7620 | 1323 return FALSE; |
5228 | 1324 } |
1325 | |
8143 | 1326 static gboolean |
1327 gaim_gtk_blist_popup_menu_cb(GtkWidget *tv, void *user_data) | |
1328 { | |
1329 GaimBlistNode *node; | |
1330 GValue val = { 0, }; | |
1331 GtkTreeIter iter; | |
1332 GtkTreeSelection *sel; | |
1333 gboolean handled = FALSE; | |
1334 | |
1335 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
1336 if (!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1337 return FALSE; | |
1338 | |
1339 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), | |
1340 &iter, NODE_COLUMN, &val); | |
1341 node = g_value_get_pointer(&val); | |
1342 | |
1343 /* Shift+F10 draws a context menu */ | |
1344 handled = gaim_gtk_blist_show_context_menu(node, gaim_gtk_treeview_popup_menu_position_func, tv, 0, GDK_CURRENT_TIME); | |
1345 | |
1346 return handled; | |
1347 } | |
1348 | |
11796 | 1349 static void gaim_gtk_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item) |
1350 { | |
1351 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons", | |
1352 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
1353 } | |
1354 | |
5228 | 1355 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item) |
1356 { | |
7620 | 1357 gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups", |
1358 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); | |
5228 | 1359 } |
1360 | |
1361 static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action, | |
1362 GtkWidget *checkitem) { | |
1363 if(gtkblist->window->window) { | |
1364 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); | |
1365 gdk_window_set_cursor(gtkblist->window->window, cursor); | |
1366 while (gtk_events_pending()) | |
1367 gtk_main_iteration(); | |
1368 gdk_cursor_unref(cursor); | |
1369 } | |
1370 | |
7620 | 1371 gaim_prefs_set_bool("/gaim/gtk/blist/show_offline_buddies", |
1372 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem))); | |
5228 | 1373 |
1374 if(gtkblist->window->window) { | |
1375 GdkCursor *cursor = gdk_cursor_new(GDK_LEFT_PTR); | |
1376 gdk_window_set_cursor(gtkblist->window->window, cursor); | |
1377 gdk_cursor_unref(cursor); | |
1378 } | |
1379 } | |
1380 | |
10074 | 1381 static void gaim_gtk_blist_mute_sounds_cb(gpointer data, guint action, GtkWidget *item) |
1382 { | |
1383 gaim_prefs_set_bool("/gaim/gtk/sound/mute", GTK_CHECK_MENU_ITEM(item)->active); | |
1384 } | |
1385 | |
1386 static void gaim_gtk_blist_mute_pref_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
1387 { | |
1388 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(gtkblist->ift, | |
1389 N_("/Tools/Mute Sounds"))), (gboolean)GPOINTER_TO_INT(value)); | |
1390 } | |
1391 | |
1392 static void gaim_gtk_blist_sound_method_pref_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
1393 { | |
1394 gboolean sensitive = TRUE; | |
1395 | |
1396 if(!strcmp(value, "none")) | |
1397 sensitive = FALSE; | |
1398 | |
1399 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), sensitive); | |
1400 } | |
1401 | |
8089 | 1402 static void |
1403 add_buddies_from_vcard(const char *prpl_id, GaimGroup *group, GList *list, | |
1404 const char *alias) | |
1405 { | |
1406 GList *l; | |
1407 GaimAccount *account = NULL; | |
1408 GaimConnection *gc; | |
1409 | |
1410 if (list == NULL) | |
1411 return; | |
1412 | |
1413 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
1414 { | |
1415 gc = (GaimConnection *)l->data; | |
1416 account = gaim_connection_get_account(gc); | |
1417 | |
1418 if (!strcmp(gaim_account_get_protocol_id(account), prpl_id)) | |
1419 break; | |
1420 | |
1421 account = NULL; | |
1422 } | |
1423 | |
1424 if (account != NULL) | |
1425 { | |
1426 for (l = list; l != NULL; l = l->next) | |
1427 { | |
1428 gaim_blist_request_add_buddy(account, l->data, | |
1429 (group ? group->name : NULL), | |
1430 alias); | |
1431 } | |
1432 } | |
1433 | |
1434 g_list_foreach(list, (GFunc)g_free, NULL); | |
1435 g_list_free(list); | |
1436 } | |
1437 | |
1438 static gboolean | |
1439 parse_vcard(const char *vcard, GaimGroup *group) | |
1440 { | |
1441 char *temp_vcard; | |
1442 char *s, *c; | |
1443 char *alias = NULL; | |
1444 GList *aims = NULL; | |
1445 GList *icqs = NULL; | |
1446 GList *yahoos = NULL; | |
1447 GList *msns = NULL; | |
1448 GList *jabbers = NULL; | |
1449 | |
1450 s = temp_vcard = g_strdup(vcard); | |
1451 | |
1452 while (*s != '\0' && strncmp(s, "END:vCard", strlen("END:vCard"))) | |
1453 { | |
1454 char *field, *value; | |
1455 | |
1456 field = s; | |
1457 | |
1458 /* Grab the field */ | |
1459 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ':') | |
1460 s++; | |
1461 | |
1462 if (*s == '\r') s++; | |
1463 if (*s == '\n') | |
1464 { | |
1465 s++; | |
1466 continue; | |
1467 } | |
1468 | |
1469 if (*s != '\0') *s++ = '\0'; | |
1470 | |
1471 if ((c = strchr(field, ';')) != NULL) | |
1472 *c = '\0'; | |
1473 | |
1474 /* Proceed to the end of the line */ | |
1475 value = s; | |
1476 | |
1477 while (*s != '\r' && *s != '\n' && *s != '\0') | |
1478 s++; | |
1479 | |
1480 if (*s == '\r') *s++ = '\0'; | |
1481 if (*s == '\n') *s++ = '\0'; | |
1482 | |
1483 /* We only want to worry about a few fields here. */ | |
1484 if (!strcmp(field, "FN")) | |
1485 alias = g_strdup(value); | |
1486 else if (!strcmp(field, "X-AIM") || !strcmp(field, "X-ICQ") || | |
1487 !strcmp(field, "X-YAHOO") || !strcmp(field, "X-MSN") || | |
1488 !strcmp(field, "X-JABBER")) | |
1489 { | |
1490 char **values = g_strsplit(value, ":", 0); | |
1491 char **im; | |
1492 | |
1493 for (im = values; *im != NULL; im++) | |
1494 { | |
1495 if (!strcmp(field, "X-AIM")) | |
1496 aims = g_list_append(aims, g_strdup(*im)); | |
1497 else if (!strcmp(field, "X-ICQ")) | |
1498 icqs = g_list_append(icqs, g_strdup(*im)); | |
1499 else if (!strcmp(field, "X-YAHOO")) | |
1500 yahoos = g_list_append(yahoos, g_strdup(*im)); | |
1501 else if (!strcmp(field, "X-MSN")) | |
1502 msns = g_list_append(msns, g_strdup(*im)); | |
1503 else if (!strcmp(field, "X-JABBER")) | |
1504 jabbers = g_list_append(jabbers, g_strdup(*im)); | |
1505 } | |
1506 | |
1507 g_strfreev(values); | |
1508 } | |
1509 } | |
1510 | |
1511 g_free(temp_vcard); | |
1512 | |
1513 if (aims == NULL && icqs == NULL && yahoos == NULL && | |
1514 msns == NULL && jabbers == NULL) | |
1515 { | |
1516 if (alias != NULL) | |
1517 g_free(alias); | |
1518 | |
1519 return FALSE; | |
1520 } | |
1521 | |
1522 add_buddies_from_vcard("prpl-oscar", group, aims, alias); | |
1523 add_buddies_from_vcard("prpl-oscar", group, icqs, alias); | |
1524 add_buddies_from_vcard("prpl-yahoo", group, yahoos, alias); | |
1525 add_buddies_from_vcard("prpl-msn", group, msns, alias); | |
1526 add_buddies_from_vcard("prpl-jabber", group, jabbers, alias); | |
1527 | |
1528 if (alias != NULL) | |
1529 g_free(alias); | |
1530 | |
1531 return TRUE; | |
1532 } | |
1533 | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1534 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1535 static void gaim_gtk_blist_drag_begin(GtkWidget *widget, |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1536 GdkDragContext *drag_context, gpointer user_data) |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1537 { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1538 gaim_gtk_blist_tooltip_destroy(); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1539 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1540 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1541 /* Unhook the tooltip-timeout since we don't want a tooltip |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1542 * to appear and obscure the dragging operation. |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1543 * This is a workaround for GTK+ bug 107320. */ |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1544 if (gtkblist->timeout) { |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1545 g_source_remove(gtkblist->timeout); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1546 gtkblist->timeout = 0; |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1547 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1548 } |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1549 #endif |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1550 |
9811 | 1551 static void gaim_gtk_blist_drag_data_get_cb(GtkWidget *widget, |
1552 GdkDragContext *dc, | |
1553 GtkSelectionData *data, | |
1554 guint info, | |
1555 guint time, | |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1556 gpointer null) |
5228 | 1557 { |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
1558 |
8089 | 1559 if (data->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
1560 { | |
5228 | 1561 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); |
1562 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref); | |
1563 GtkTreeIter iter; | |
1564 GaimBlistNode *node = NULL; | |
1565 GValue val = {0}; | |
5273 | 1566 if(!sourcerow) |
1567 return; | |
5228 | 1568 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow); |
1569 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
1570 node = g_value_get_pointer(&val); | |
1571 gtk_selection_data_set (data, | |
1572 gdk_atom_intern ("GAIM_BLIST_NODE", FALSE), | |
1573 8, /* bits */ | |
1574 (void*)&node, | |
1575 sizeof (node)); | |
5273 | 1576 |
5228 | 1577 gtk_tree_path_free(sourcerow); |
1578 } | |
8089 | 1579 else if (data->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
1580 { | |
7706 | 1581 GtkTreeRowReference *ref; |
1582 GtkTreePath *sourcerow; | |
1583 GtkTreeIter iter; | |
1584 GaimBlistNode *node = NULL; | |
1585 GaimBuddy *buddy; | |
1586 GaimConnection *gc; | |
1587 GValue val = {0}; | |
1588 GString *str; | |
1589 const char *protocol; | |
1590 char *mime_str; | |
1591 | |
1592 ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); | |
1593 sourcerow = gtk_tree_row_reference_get_path(ref); | |
1594 | |
1595 if (!sourcerow) | |
1596 return; | |
1597 | |
1598 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
1599 sourcerow); | |
1600 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
1601 NODE_COLUMN, &val); | |
1602 | |
1603 node = g_value_get_pointer(&val); | |
1604 | |
1605 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1606 { | |
1607 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
1608 } | |
1609 else if (!GAIM_BLIST_NODE_IS_BUDDY(node)) | |
1610 { | |
1611 gtk_tree_path_free(sourcerow); | |
1612 return; | |
1613 } | |
1614 else | |
1615 { | |
1616 buddy = (GaimBuddy *)node; | |
1617 } | |
1618 | |
1619 gc = gaim_account_get_connection(buddy->account); | |
1620 | |
1621 if (gc == NULL) | |
1622 { | |
1623 gtk_tree_path_free(sourcerow); | |
1624 return; | |
1625 } | |
1626 | |
1627 protocol = | |
1628 GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->list_icon(buddy->account, | |
1629 buddy); | |
1630 | |
1631 str = g_string_new(NULL); | |
1632 g_string_printf(str, | |
1633 "MIME-Version: 1.0\r\n" | |
1634 "Content-Type: application/x-im-contact\r\n" | |
1635 "X-IM-Protocol: %s\r\n" | |
1636 "X-IM-Username: %s\r\n", | |
1637 protocol, | |
1638 buddy->name); | |
1639 | |
1640 if (buddy->alias != NULL) | |
1641 { | |
1642 g_string_append_printf(str, | |
1643 "X-IM-Alias: %s\r\n", | |
1644 buddy->alias); | |
1645 } | |
1646 | |
1647 str = g_string_append(str, "\r\n"); | |
1648 | |
1649 mime_str = g_string_free(str, FALSE); | |
1650 | |
1651 gtk_selection_data_set(data, | |
1652 gdk_atom_intern("application/x-im-contact", FALSE), | |
1653 8, /* bits */ | |
11137 | 1654 (const guchar *)mime_str, |
7706 | 1655 strlen(mime_str) + 1); |
1656 | |
1657 g_free(mime_str); | |
1658 gtk_tree_path_free(sourcerow); | |
1659 } | |
5228 | 1660 } |
1661 | |
1662 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | |
1663 GtkSelectionData *sd, guint info, guint t) | |
7620 | 1664 { |
5228 | 1665 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE) && sd->data) { |
1666 GaimBlistNode *n = NULL; | |
1667 GtkTreePath *path = NULL; | |
1668 GtkTreeViewDropPosition position; | |
1669 memcpy(&n, sd->data, sizeof(n)); | |
1670 if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) { | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
1671 /* if we're here, I think it means the drop is ok */ |
7642 | 1672 GtkTreeIter iter; |
5228 | 1673 GaimBlistNode *node; |
1674 GValue val = {0}; | |
7620 | 1675 struct _gaim_gtk_blist_node *gtknode; |
1676 | |
1677 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), | |
1678 &iter, path); | |
1679 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), | |
1680 &iter, NODE_COLUMN, &val); | |
5228 | 1681 node = g_value_get_pointer(&val); |
7620 | 1682 gtknode = node->ui_data; |
1683 | |
1684 if (GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
1685 GaimContact *c = (GaimContact*)n; | |
1686 if (GAIM_BLIST_NODE_IS_CONTACT(node) && gtknode->contact_expanded) { | |
1687 gaim_blist_merge_contact(c, node); | |
1688 } else if (GAIM_BLIST_NODE_IS_CONTACT(node) || | |
5234 | 1689 GAIM_BLIST_NODE_IS_CHAT(node)) { |
5228 | 1690 switch(position) { |
1691 case GTK_TREE_VIEW_DROP_AFTER: | |
1692 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
7620 | 1693 gaim_blist_add_contact(c, (GaimGroup*)node->parent, |
1694 node); | |
1695 break; | |
1696 case GTK_TREE_VIEW_DROP_BEFORE: | |
1697 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1698 gaim_blist_add_contact(c, (GaimGroup*)node->parent, | |
1699 node->prev); | |
1700 break; | |
1701 } | |
1702 } else if(GAIM_BLIST_NODE_IS_GROUP(node)) { | |
1703 gaim_blist_add_contact(c, (GaimGroup*)node, NULL); | |
1704 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1705 gaim_blist_merge_contact(c, node); | |
1706 } | |
1707 } else if (GAIM_BLIST_NODE_IS_BUDDY(n)) { | |
1708 GaimBuddy *b = (GaimBuddy*)n; | |
1709 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1710 switch(position) { | |
1711 case GTK_TREE_VIEW_DROP_AFTER: | |
1712 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1713 gaim_blist_add_buddy(b, (GaimContact*)node->parent, | |
1714 (GaimGroup*)node->parent->parent, node); | |
5228 | 1715 break; |
1716 case GTK_TREE_VIEW_DROP_BEFORE: | |
1717 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
7620 | 1718 gaim_blist_add_buddy(b, (GaimContact*)node->parent, |
1719 (GaimGroup*)node->parent->parent, | |
1720 node->prev); | |
5228 | 1721 break; |
1722 } | |
7620 | 1723 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { |
1724 gaim_blist_add_buddy(b, NULL, (GaimGroup*)node->parent, | |
1725 NULL); | |
5228 | 1726 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
7620 | 1727 gaim_blist_add_buddy(b, NULL, (GaimGroup*)node, NULL); |
1728 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1729 if(gtknode->contact_expanded) { | |
1730 switch(position) { | |
1731 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1732 case GTK_TREE_VIEW_DROP_AFTER: | |
1733 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1734 gaim_blist_add_buddy(b, (GaimContact*)node, | |
1735 (GaimGroup*)node->parent, NULL); | |
1736 break; | |
1737 case GTK_TREE_VIEW_DROP_BEFORE: | |
1738 gaim_blist_add_buddy(b, NULL, | |
1739 (GaimGroup*)node->parent, node->prev); | |
1740 break; | |
1741 } | |
1742 } else { | |
1743 switch(position) { | |
1744 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1745 case GTK_TREE_VIEW_DROP_AFTER: | |
1746 gaim_blist_add_buddy(b, NULL, | |
1747 (GaimGroup*)node->parent, NULL); | |
1748 break; | |
1749 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1750 case GTK_TREE_VIEW_DROP_BEFORE: | |
1751 gaim_blist_add_buddy(b, NULL, | |
1752 (GaimGroup*)node->parent, node->prev); | |
1753 break; | |
1754 } | |
1755 } | |
5228 | 1756 } |
5234 | 1757 } else if (GAIM_BLIST_NODE_IS_CHAT(n)) { |
7620 | 1758 GaimChat *chat = (GaimChat *)n; |
1759 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1760 switch(position) { | |
1761 case GTK_TREE_VIEW_DROP_AFTER: | |
1762 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1763 gaim_blist_add_chat(chat, | |
1764 (GaimGroup*)node->parent->parent, node); | |
1765 break; | |
1766 case GTK_TREE_VIEW_DROP_BEFORE: | |
1767 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1768 gaim_blist_add_chat(chat, | |
1769 (GaimGroup*)node->parent->parent, | |
1770 node->prev); | |
1771 break; | |
1772 } | |
1773 } else if(GAIM_BLIST_NODE_IS_CONTACT(node) || | |
5234 | 1774 GAIM_BLIST_NODE_IS_CHAT(node)) { |
1775 switch(position) { | |
1776 case GTK_TREE_VIEW_DROP_AFTER: | |
1777 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
7620 | 1778 gaim_blist_add_chat(chat, (GaimGroup*)node->parent, node); |
5234 | 1779 break; |
1780 case GTK_TREE_VIEW_DROP_BEFORE: | |
1781 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
7620 | 1782 gaim_blist_add_chat(chat, (GaimGroup*)node->parent, node->prev); |
5234 | 1783 break; |
1784 } | |
1785 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
7620 | 1786 gaim_blist_add_chat(chat, (GaimGroup*)node, NULL); |
5234 | 1787 } |
5228 | 1788 } else if (GAIM_BLIST_NODE_IS_GROUP(n)) { |
7620 | 1789 GaimGroup *g = (GaimGroup*)n; |
5228 | 1790 if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
1791 switch (position) { | |
1792 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
1793 case GTK_TREE_VIEW_DROP_AFTER: | |
1794 gaim_blist_add_group(g, node); | |
1795 break; | |
1796 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
1797 case GTK_TREE_VIEW_DROP_BEFORE: | |
1798 gaim_blist_add_group(g, node->prev); | |
1799 break; | |
1800 } | |
7620 | 1801 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
1802 gaim_blist_add_group(g, node->parent->parent); | |
1803 } else if(GAIM_BLIST_NODE_IS_CONTACT(node) || | |
5234 | 1804 GAIM_BLIST_NODE_IS_CHAT(node)) { |
5228 | 1805 gaim_blist_add_group(g, node->parent); |
1806 } | |
1807 } | |
1808 | |
1809 gtk_tree_path_free(path); | |
7620 | 1810 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
5228 | 1811 } |
1812 } | |
7706 | 1813 else if (sd->target == gdk_atom_intern("application/x-im-contact", |
1814 FALSE) && sd->data) | |
1815 { | |
1816 GaimGroup *group = NULL; | |
1817 GtkTreePath *path = NULL; | |
1818 GtkTreeViewDropPosition position; | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7706
diff
changeset
|
1819 GaimAccount *account; |
7706 | 1820 char *protocol = NULL; |
1821 char *username = NULL; | |
1822 char *alias = NULL; | |
1823 | |
1824 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), | |
1825 x, y, &path, &position)) | |
1826 { | |
1827 GtkTreeIter iter; | |
1828 GaimBlistNode *node; | |
1829 GValue val = {0}; | |
1830 | |
1831 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), | |
1832 &iter, path); | |
1833 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), | |
1834 &iter, NODE_COLUMN, &val); | |
1835 node = g_value_get_pointer(&val); | |
1836 | |
1837 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
1838 { | |
1839 group = (GaimGroup *)node->parent->parent; | |
1840 } | |
1841 else if (GAIM_BLIST_NODE_IS_CHAT(node) || | |
1842 GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1843 { | |
1844 group = (GaimGroup *)node->parent; | |
1845 } | |
1846 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | |
1847 { | |
1848 group = (GaimGroup *)node; | |
1849 } | |
1850 } | |
1851 | |
11137 | 1852 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7706
diff
changeset
|
1853 &protocol, &username, &alias)) |
7706 | 1854 { |
1855 if (account == NULL) | |
1856 { | |
1857 gaim_notify_error(NULL, NULL, | |
1858 _("You are not currently signed on with an account that " | |
1859 "can add that buddy."), NULL); | |
1860 } | |
1861 else | |
1862 { | |
1863 gaim_blist_request_add_buddy(account, username, | |
1864 (group ? group->name : NULL), | |
1865 alias); | |
1866 } | |
1867 } | |
1868 | |
1869 if (username != NULL) g_free(username); | |
1870 if (protocol != NULL) g_free(protocol); | |
1871 if (alias != NULL) g_free(alias); | |
1872 | |
1873 if (path != NULL) | |
1874 gtk_tree_path_free(path); | |
1875 | |
1876 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
1877 } | |
8089 | 1878 else if (sd->target == gdk_atom_intern("text/x-vcard", FALSE) && sd->data) |
1879 { | |
1880 gboolean result; | |
1881 GaimGroup *group = NULL; | |
1882 GtkTreePath *path = NULL; | |
1883 GtkTreeViewDropPosition position; | |
1884 | |
1885 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), | |
1886 x, y, &path, &position)) | |
1887 { | |
1888 GtkTreeIter iter; | |
1889 GaimBlistNode *node; | |
1890 GValue val = {0}; | |
1891 | |
1892 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), | |
1893 &iter, path); | |
1894 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), | |
1895 &iter, NODE_COLUMN, &val); | |
1896 node = g_value_get_pointer(&val); | |
1897 | |
1898 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
1899 { | |
1900 group = (GaimGroup *)node->parent->parent; | |
1901 } | |
1902 else if (GAIM_BLIST_NODE_IS_CHAT(node) || | |
1903 GAIM_BLIST_NODE_IS_CONTACT(node)) | |
1904 { | |
1905 group = (GaimGroup *)node->parent; | |
1906 } | |
1907 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | |
1908 { | |
1909 group = (GaimGroup *)node; | |
1910 } | |
1911 } | |
1912 | |
11137 | 1913 result = parse_vcard((const gchar *)sd->data, group); |
8089 | 1914 |
1915 gtk_drag_finish(dc, result, (dc->action == GDK_ACTION_MOVE), t); | |
9525 | 1916 } else if (sd->target == gdk_atom_intern("text/uri-list", FALSE) && sd->data) { |
9495 | 1917 GtkTreePath *path = NULL; |
1918 GtkTreeViewDropPosition position; | |
1919 | |
1920 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), | |
9811 | 1921 x, y, &path, &position)) |
9495 | 1922 { |
1923 GtkTreeIter iter; | |
1924 GaimBlistNode *node; | |
1925 GValue val = {0}; | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
1926 |
9495 | 1927 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), |
1928 &iter, path); | |
1929 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), | |
1930 &iter, NODE_COLUMN, &val); | |
1931 node = g_value_get_pointer(&val); | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
1932 |
9495 | 1933 if (GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CONTACT(node)) { |
1934 GaimBuddy *b = GAIM_BLIST_NODE_IS_BUDDY(node) ? (GaimBuddy*)node : gaim_contact_get_priority_buddy((GaimContact*)node); | |
10229 | 1935 gaim_dnd_file_manage(sd, b->account, b->name); |
1936 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
1937 } else { | |
1938 gtk_drag_finish(dc, FALSE, FALSE, t); | |
9495 | 1939 } |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
1940 } |
8089 | 1941 } |
5228 | 1942 } |
1943 | |
10482 | 1944 static GdkPixbuf *gaim_gtk_blist_get_buddy_icon(GaimBlistNode *node, |
1945 gboolean scaled, gboolean greyed) | |
1946 { | |
10483 | 1947 GdkPixbuf *buf, *ret = NULL; |
10482 | 1948 GdkPixbufLoader *loader; |
1949 GaimBuddyIcon *icon; | |
11137 | 1950 const guchar *data; |
1951 gsize len; | |
10482 | 1952 GaimBuddy *buddy = (GaimBuddy *)node; |
1953 | |
1954 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
1955 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
1956 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
1957 buddy = (GaimBuddy*)node; | |
1958 } else { | |
1959 return NULL; | |
1960 } | |
1961 | |
1962 #if 0 | |
1963 if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) | |
1964 return NULL; | |
1965 #endif | |
1966 | |
1967 if (!(icon = gaim_buddy_get_icon(buddy))) | |
1968 if (!(icon = gaim_buddy_icons_find(buddy->account, buddy->name))) /* Not sure I like this...*/ | |
1969 return NULL; | |
1970 | |
1971 loader = gdk_pixbuf_loader_new(); | |
1972 data = gaim_buddy_icon_get_data(icon, &len); | |
1973 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
1974 buf = gdk_pixbuf_loader_get_pixbuf(loader); | |
1975 if (buf) | |
1976 g_object_ref(G_OBJECT(buf)); | |
1977 gdk_pixbuf_loader_close(loader, NULL); | |
1978 g_object_unref(G_OBJECT(loader)); | |
1979 | |
1980 if (buf) { | |
10544 | 1981 GaimAccount *account = gaim_buddy_get_account(buddy); |
1982 GaimPluginProtocolInfo *prpl_info = NULL; | |
1983 int orig_width, orig_height; | |
1984 int scale_width, scale_height; | |
1985 | |
1986 if(account && account->gc) | |
1987 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
1988 | |
10482 | 1989 if (greyed) { |
1990 GaimPresence *presence = gaim_buddy_get_presence(buddy); | |
1991 if (!GAIM_BUDDY_IS_ONLINE(buddy)) | |
1992 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.0, FALSE); | |
1993 if (gaim_presence_is_idle(presence)) | |
1994 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.25, FALSE); | |
1995 } | |
1996 | |
10544 | 1997 /* i'd use the gaim_gtk_buddy_icon_get_scale_size() thing, |
1998 * but it won't tell me the original size, which I need for scaling | |
1999 * purposes */ | |
2000 scale_width = orig_width = gdk_pixbuf_get_width(buf); | |
2001 scale_height = orig_height = gdk_pixbuf_get_height(buf); | |
2002 | |
2003 gaim_buddy_icon_get_scale_size(prpl_info ? &prpl_info->icon_spec : NULL, &scale_width, &scale_height); | |
2004 | |
10482 | 2005 if (scaled) { |
10544 | 2006 if(scale_height > scale_width) { |
2007 scale_width = 30.0 * (double)scale_width / (double)scale_height; | |
2008 scale_height = 30; | |
2009 } else { | |
2010 scale_height = 30.0 * (double)scale_height / (double)scale_width; | |
2011 scale_width = 30; | |
2012 } | |
2013 | |
2014 ret = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 30, 30); | |
2015 gdk_pixbuf_fill(ret, 0x00000000); | |
2016 gdk_pixbuf_scale(buf, ret, (30-scale_width)/2, (30-scale_height)/2, scale_width, scale_height, (30-scale_width)/2, (30-scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR); | |
10483 | 2017 } else { |
2018 ret = gdk_pixbuf_scale_simple(buf,scale_width,scale_height, GDK_INTERP_BILINEAR); | |
2019 } | |
10544 | 2020 g_object_unref(G_OBJECT(buf)); |
10482 | 2021 } |
2022 | |
10483 | 2023 return ret; |
10482 | 2024 } |
2025 | |
11890 | 2026 struct tooltip_data { |
2027 PangoLayout *layout; | |
2028 GdkPixbuf *status_icon; | |
2029 GdkPixbuf *avatar; | |
11892 | 2030 int avatar_width; |
2031 int width; | |
2032 int height; | |
11890 | 2033 }; |
2034 | |
2035 static struct tooltip_data * create_tip_for_node(GaimBlistNode *node) | |
2036 { | |
2037 struct tooltip_data *td = g_new0(struct tooltip_data, 1); | |
2038 char *tooltip_text = gaim_get_tooltip_text(node); | |
2039 | |
2040 td->status_icon = gaim_gtk_blist_get_status_icon(node, GAIM_STATUS_ICON_LARGE); | |
2041 td->avatar = gaim_gtk_blist_get_buddy_icon(node, FALSE, FALSE); | |
2042 | |
2043 td->layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); | |
2044 pango_layout_set_markup(td->layout, tooltip_text, strlen(tooltip_text)); | |
2045 pango_layout_set_wrap(td->layout, PANGO_WRAP_WORD); | |
2046 pango_layout_set_width(td->layout, 300000); | |
11983 | 2047 |
11892 | 2048 pango_layout_get_size (td->layout, &td->width, &td->height); |
2049 td->width = PANGO_PIXELS(td->width) + 38 + 8; | |
2050 td->height = MAX(PANGO_PIXELS(td->height) + 8, 38); | |
2051 | |
2052 if(td->avatar) { | |
2053 td->avatar_width = gdk_pixbuf_get_width(td->avatar); | |
2054 td->width += td->avatar_width + 8; | |
2055 td->height = MAX(td->height, gdk_pixbuf_get_height(td->avatar) + 8); | |
2056 } | |
11890 | 2057 |
2058 return td; | |
2059 } | |
2060 | |
5234 | 2061 static void gaim_gtk_blist_paint_tip(GtkWidget *widget, GdkEventExpose *event, GaimBlistNode *node) |
5228 | 2062 { |
2063 GtkStyle *style; | |
11892 | 2064 int current_height, max_width; |
11890 | 2065 GList *l; |
2066 | |
2067 if(gtkblist->tooltipdata == NULL) | |
7620 | 2068 return; |
2069 | |
11890 | 2070 style = gtkblist->tipwindow->style; |
2071 gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, | |
2072 NULL, gtkblist->tipwindow, "tooltip", 0, 0, -1, -1); | |
2073 | |
11892 | 2074 max_width = 0; |
2075 for(l = gtkblist->tooltipdata; l; l = l->next) | |
2076 { | |
2077 struct tooltip_data *td = l->data; | |
2078 max_width = MAX(max_width, td->width); | |
2079 } | |
2080 | |
11890 | 2081 current_height = 0; |
2082 for(l = gtkblist->tooltipdata; l; l = l->next) | |
10482 | 2083 { |
11890 | 2084 struct tooltip_data *td = l->data; |
5228 | 2085 |
2086 #if GTK_CHECK_VERSION(2,2,0) | |
11890 | 2087 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, |
2088 0, 0, 4, current_height + 4, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); | |
2089 if(td->avatar) | |
2090 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, | |
11892 | 2091 td->avatar, 0, 0, max_width - (td->avatar_width + 4), current_height + 4, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); |
5228 | 2092 #else |
11890 | 2093 gdk_pixbuf_render_to_drawable(td->status_icon, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 4, current_height + 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
2094 if(td->avatar) | |
2095 gdk_pixbuf_render_to_drawable(td->avatar, | |
11983 | 2096 GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, |
11892 | 2097 max_width - (td->avatar_width + 4), |
11890 | 2098 current_height + 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
5228 | 2099 #endif |
2100 | |
11890 | 2101 gtk_paint_layout (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE, |
2102 NULL, gtkblist->tipwindow, "tooltip", 38 + 4, current_height + 4, td->layout); | |
2103 | |
11895 | 2104 current_height += td->height; |
2105 | |
11894 | 2106 if(l->next) |
11895 | 2107 gtk_paint_hline(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, NULL, NULL, NULL, 4, max_width - 4, current_height-2); |
11890 | 2108 } |
5228 | 2109 } |
2110 | |
8254 | 2111 static void gaim_gtk_blist_tooltip_destroy() |
2112 { | |
11890 | 2113 while(gtkblist->tooltipdata) { |
2114 struct tooltip_data *td = gtkblist->tooltipdata->data; | |
2115 | |
2116 if(td->avatar) | |
2117 g_object_unref(td->avatar); | |
2118 if(td->status_icon) | |
2119 g_object_unref(td->status_icon); | |
2120 g_object_unref(td->layout); | |
2121 g_free(td); | |
2122 gtkblist->tooltipdata = g_list_delete_link(gtkblist->tooltipdata, gtkblist->tooltipdata); | |
2123 } | |
11636 | 2124 |
8254 | 2125 if (gtkblist->tipwindow == NULL) |
2126 return; | |
2127 | |
2128 gtk_widget_destroy(gtkblist->tipwindow); | |
2129 gtkblist->tipwindow = NULL; | |
2130 } | |
2131 | |
10354 | 2132 static gboolean gaim_gtk_blist_expand_timeout(GtkWidget *tv) |
2133 { | |
2134 GtkTreePath *path; | |
2135 GtkTreeIter iter; | |
2136 GaimBlistNode *node; | |
2137 GValue val = {0}; | |
2138 struct _gaim_gtk_blist_node *gtknode; | |
2139 | |
2140 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y, &path, NULL, NULL, NULL)) | |
2141 return FALSE; | |
2142 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
2143 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
2144 node = g_value_get_pointer(&val); | |
2145 | |
10504 | 2146 if(!GAIM_BLIST_NODE_IS_CONTACT(node)) { |
2147 gtk_tree_path_free(path); | |
10354 | 2148 return FALSE; |
10504 | 2149 } |
10354 | 2150 |
2151 gtknode = node->ui_data; | |
2152 | |
2153 if (!gtknode->contact_expanded) { | |
2154 GtkTreeIter i; | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
2155 |
10354 | 2156 gaim_gtk_blist_expand_contact_cb(NULL, node); |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
2157 |
10354 | 2158 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->contact_rect); |
2159 gdk_drawable_get_size(GDK_DRAWABLE(tv->window), &(gtkblist->contact_rect.width), NULL); | |
2160 gtkblist->mouseover_contact = node; | |
2161 gtk_tree_path_down (path); | |
2162 while (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &i, path)) { | |
2163 GdkRectangle rect; | |
2164 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &rect); | |
2165 gtkblist->contact_rect.height += rect.height; | |
2166 gtk_tree_path_next(path); | |
2167 } | |
2168 } | |
2169 gtk_tree_path_free(path); | |
2170 return FALSE; | |
2171 } | |
2172 | |
11890 | 2173 static gboolean buddy_is_displayable(GaimBuddy *buddy) |
2174 { | |
11910 | 2175 struct _gaim_gtk_blist_node *gtknode; |
2176 | |
2177 if(!buddy) | |
2178 return FALSE; | |
2179 | |
2180 gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
2181 | |
2182 return (gaim_account_is_connected(buddy->account) && | |
11890 | 2183 (gaim_presence_is_online(buddy->presence) || |
11910 | 2184 (gtknode && gtknode->recent_signonoff) || |
2185 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies") || | |
2186 gaim_blist_node_get_bool((GaimBlistNode*)buddy, "show_offline"))); | |
11890 | 2187 } |
2188 | |
5228 | 2189 static gboolean gaim_gtk_blist_tooltip_timeout(GtkWidget *tv) |
2190 { | |
2191 GtkTreePath *path; | |
2192 GtkTreeIter iter; | |
2193 GaimBlistNode *node; | |
2194 GValue val = {0}; | |
9869 | 2195 int scr_w, scr_h, w, h, x, y; |
2196 #if GTK_CHECK_VERSION(2,2,0) | |
2197 int mon_num; | |
2198 GdkScreen *screen = NULL; | |
2199 #endif | |
7636 | 2200 gboolean tooltip_top = FALSE; |
2201 struct _gaim_gtk_blist_node *gtknode; | |
9773 | 2202 GdkRectangle mon_size; |
5228 | 2203 |
11636 | 2204 /* |
2205 * Attempt to free the previous tooltip. I have a feeling | |
2206 * this is never needed... but just in case. | |
2207 */ | |
2208 gaim_gtk_blist_tooltip_destroy(); | |
2209 | |
7636 | 2210 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->tip_rect.x, gtkblist->tip_rect.y, &path, NULL, NULL, NULL)) |
5228 | 2211 return FALSE; |
2212 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
2213 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
2214 node = g_value_get_pointer(&val); | |
7620 | 2215 |
10504 | 2216 gtk_tree_path_free(path); |
2217 | |
11890 | 2218 gtkblist->tipwindow = gtk_window_new(GTK_WINDOW_POPUP); |
2219 | |
2220 if(GAIM_BLIST_NODE_IS_CHAT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
2221 struct tooltip_data *td = create_tip_for_node(node); | |
2222 gtkblist->tooltipdata = g_list_append(gtkblist->tooltipdata, td); | |
11892 | 2223 w = td->width; |
2224 h = td->height; | |
11890 | 2225 } else if(GAIM_BLIST_NODE_IS_CONTACT(node)) { |
2226 GaimBlistNode *child; | |
11988 | 2227 GaimBuddy *b = gaim_contact_get_priority_buddy((GaimContact *)node); |
11890 | 2228 w = h = 0; |
2229 for(child = node->child; child; child = child->next) | |
2230 { | |
2231 if(GAIM_BLIST_NODE_IS_BUDDY(child) && buddy_is_displayable((GaimBuddy*)child)) { | |
2232 struct tooltip_data *td = create_tip_for_node(child); | |
11988 | 2233 if (b == (GaimBuddy *)child) { |
2234 gtkblist->tooltipdata = g_list_prepend(gtkblist->tooltipdata, td); | |
2235 } else { | |
2236 gtkblist->tooltipdata = g_list_append(gtkblist->tooltipdata, td); | |
2237 } | |
11892 | 2238 w = MAX(w, td->width); |
2239 h += td->height; | |
11890 | 2240 } |
2241 } | |
2242 } else { | |
2243 gtk_widget_destroy(gtkblist->tipwindow); | |
11892 | 2244 gtkblist->tipwindow = NULL; |
5234 | 2245 return FALSE; |
11890 | 2246 } |
2247 | |
2248 if (gtkblist->tooltipdata == NULL) { | |
2249 gtk_widget_destroy(gtkblist->tipwindow); | |
11892 | 2250 gtkblist->tipwindow = NULL; |
11890 | 2251 return FALSE; |
2252 } | |
5228 | 2253 |
7636 | 2254 gtknode = node->ui_data; |
2255 | |
5234 | 2256 gtk_widget_set_app_paintable(gtkblist->tipwindow, TRUE); |
2257 gtk_window_set_resizable(GTK_WINDOW(gtkblist->tipwindow), FALSE); | |
2258 gtk_widget_set_name(gtkblist->tipwindow, "gtk-tooltips"); | |
2259 g_signal_connect(G_OBJECT(gtkblist->tipwindow), "expose_event", | |
11890 | 2260 G_CALLBACK(gaim_gtk_blist_paint_tip), NULL); |
5234 | 2261 gtk_widget_ensure_style (gtkblist->tipwindow); |
7837 | 2262 |
9773 | 2263 |
9869 | 2264 #if GTK_CHECK_VERSION(2,2,0) |
9773 | 2265 gdk_display_get_pointer(gdk_display_get_default(), &screen, &x, &y, NULL); |
2266 mon_num = gdk_screen_get_monitor_at_point(screen, x, y); | |
2267 gdk_screen_get_monitor_geometry(screen, mon_num, &mon_size); | |
2268 | |
2269 scr_w = mon_size.width + mon_size.x; | |
2270 scr_h = mon_size.height + mon_size.y; | |
9869 | 2271 #else |
2272 scr_w = gdk_screen_width(); | |
2273 scr_h = gdk_screen_height(); | |
2274 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
2275 mon_size.x = 0; | |
2276 mon_size.y = 0; | |
2277 #endif | |
9773 | 2278 |
9869 | 2279 #if GTK_CHECK_VERSION(2,2,0) |
10046 | 2280 if (w > mon_size.width) |
9773 | 2281 w = mon_size.width - 10; |
2282 | |
10046 | 2283 if (h > mon_size.height) |
9773 | 2284 h = mon_size.height - 10; |
9869 | 2285 #endif |
9773 | 2286 |
5234 | 2287 if (GTK_WIDGET_NO_WINDOW(gtkblist->window)) |
2288 y+=gtkblist->window->allocation.y; | |
2289 | |
2290 x -= ((w >> 1) + 4); | |
5228 | 2291 |
7636 | 2292 if ((y + h + 4) > scr_h || tooltip_top) |
7620 | 2293 y = y - h - 5; |
5234 | 2294 else |
2295 y = y + 6; | |
7620 | 2296 |
9773 | 2297 if (y < mon_size.y) |
2298 y = mon_size.y; | |
2299 | |
2300 if (y != mon_size.y) { | |
7719 | 2301 if ((x + w) > scr_w) |
2302 x -= (x + w + 5) - scr_w; | |
9773 | 2303 else if (x < mon_size.x) |
2304 x = mon_size.x; | |
7719 | 2305 } else { |
2306 x -= (w / 2 + 10); | |
9773 | 2307 if (x < mon_size.x) |
2308 x = mon_size.x; | |
7719 | 2309 } |
2310 | |
5234 | 2311 gtk_widget_set_size_request(gtkblist->tipwindow, w, h); |
2312 gtk_window_move(GTK_WINDOW(gtkblist->tipwindow), x, y); | |
2313 gtk_widget_show(gtkblist->tipwindow); | |
5228 | 2314 |
2315 return FALSE; | |
2316 } | |
2317 | |
10354 | 2318 static gboolean gaim_gtk_blist_drag_motion_cb(GtkWidget *tv, GdkDragContext *drag_context, |
2319 gint x, gint y, guint time, gpointer user_data) | |
2320 { | |
2321 GtkTreePath *path; | |
2322 int delay; | |
2323 | |
2324 delay = 500; | |
2325 | |
2326 if (gtkblist->drag_timeout) { | |
2327 if ((y > gtkblist->tip_rect.y) && ((y - gtkblist->tip_rect.height) < gtkblist->tip_rect.y)) | |
2328 return FALSE; | |
2329 /* We've left the cell. Remove the timeout and create a new one below */ | |
2330 g_source_remove(gtkblist->drag_timeout); | |
2331 } | |
2332 | |
2333 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), x, y, &path, NULL, NULL, NULL); | |
2334 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->tip_rect); | |
2335 | |
2336 if (path) | |
2337 gtk_tree_path_free(path); | |
2338 gtkblist->drag_timeout = g_timeout_add(delay, (GSourceFunc)gaim_gtk_blist_expand_timeout, tv); | |
2339 | |
2340 if (gtkblist->mouseover_contact) { | |
2341 if ((y < gtkblist->contact_rect.y) || ((y - gtkblist->contact_rect.height) > gtkblist->contact_rect.y)) { | |
2342 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
2343 gtkblist->mouseover_contact = NULL; | |
2344 } | |
2345 } | |
2346 | |
2347 return FALSE; | |
2348 } | |
2349 | |
5228 | 2350 static gboolean gaim_gtk_blist_motion_cb (GtkWidget *tv, GdkEventMotion *event, gpointer null) |
2351 { | |
2352 GtkTreePath *path; | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2353 int delay; |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2354 |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2355 delay = gaim_prefs_get_int("/gaim/gtk/blist/tooltip_delay"); |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2356 |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2357 if (delay == 0) |
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2358 return FALSE; |
8083 | 2359 |
5228 | 2360 if (gtkblist->timeout) { |
7636 | 2361 if ((event->y > gtkblist->tip_rect.y) && ((event->y - gtkblist->tip_rect.height) < gtkblist->tip_rect.y)) |
5228 | 2362 return FALSE; |
2363 /* We've left the cell. Remove the timeout and create a new one below */ | |
8254 | 2364 gaim_gtk_blist_tooltip_destroy(); |
5228 | 2365 g_source_remove(gtkblist->timeout); |
2366 } | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2367 |
5228 | 2368 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL); |
7636 | 2369 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->tip_rect); |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2370 |
5228 | 2371 if (path) |
2372 gtk_tree_path_free(path); | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2373 gtkblist->timeout = g_timeout_add(delay, (GSourceFunc)gaim_gtk_blist_tooltip_timeout, tv); |
7636 | 2374 |
2375 if (gtkblist->mouseover_contact) { | |
2376 if ((event->y < gtkblist->contact_rect.y) || ((event->y - gtkblist->contact_rect.height) > gtkblist->contact_rect.y)) { | |
2377 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
2378 gtkblist->mouseover_contact = NULL; | |
2379 } | |
2380 } | |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2381 |
5228 | 2382 return FALSE; |
2383 } | |
2384 | |
2385 static void gaim_gtk_blist_leave_cb (GtkWidget *w, GdkEventCrossing *e, gpointer n) | |
2386 { | |
8083 | 2387 |
5228 | 2388 if (gtkblist->timeout) { |
2389 g_source_remove(gtkblist->timeout); | |
2390 gtkblist->timeout = 0; | |
2391 } | |
10382
9f28196ed769
[gaim-migrate @ 11608]
Luke Schierer <lschiere@pidgin.im>
parents:
10357
diff
changeset
|
2392 |
10354 | 2393 if (gtkblist->drag_timeout) { |
2394 g_source_remove(gtkblist->drag_timeout); | |
2395 gtkblist->drag_timeout = 0; | |
2396 } | |
2397 | |
8254 | 2398 gaim_gtk_blist_tooltip_destroy(); |
7720 | 2399 |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2400 if (gtkblist->mouseover_contact && |
9811 | 2401 !((e->x > gtkblist->contact_rect.x) && (e->x < (gtkblist->contact_rect.x + gtkblist->contact_rect.width)) && |
2402 (e->y > gtkblist->contact_rect.y) && (e->y < (gtkblist->contact_rect.y + gtkblist->contact_rect.height)))) { | |
2403 gaim_gtk_blist_collapse_contact_cb(NULL, gtkblist->mouseover_contact); | |
7636 | 2404 gtkblist->mouseover_contact = NULL; |
2405 } | |
5228 | 2406 } |
2407 | |
2408 static void | |
2409 toggle_debug(void) | |
2410 { | |
7620 | 2411 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", |
2412 !gaim_prefs_get_bool("/gaim/gtk/debug/enabled")); | |
5228 | 2413 } |
2414 | |
2415 | |
2416 /*************************************************** | |
2417 * Crap * | |
2418 ***************************************************/ | |
2419 static GtkItemFactoryEntry blist_menu[] = | |
2420 { | |
2421 /* Buddies menu */ | |
2422 { N_("/_Buddies"), NULL, NULL, 0, "<Branch>" }, | |
9714 | 2423 { N_("/Buddies/New Instant _Message..."), "<CTL>M", gaim_gtkdialogs_im, 0, "<StockItem>", GAIM_STOCK_IM }, |
8940 | 2424 { N_("/Buddies/Join a _Chat..."), "<CTL>C", gaim_gtk_blist_joinchat_show, 0, "<StockItem>", GAIM_STOCK_CHAT }, |
9714 | 2425 { N_("/Buddies/Get User _Info..."), "<CTL>I", gaim_gtkdialogs_info, 0, "<StockItem>", GAIM_STOCK_INFO }, |
2426 { N_("/Buddies/View User _Log..."), "<CTL>L", gaim_gtkdialogs_log, 0, NULL }, | |
5228 | 2427 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>" }, |
11025 | 2428 { N_("/Buddies/Show _Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"}, |
2429 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>"}, | |
11796 | 2430 { N_("/Buddies/Show Buddy _Details"), NULL, gaim_gtk_blist_buddy_details_cb, 1, "<CheckItem>"}, |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
2431 { N_("/Buddies/Sort Buddies"), NULL, NULL, 0, "<Branch>" }, |
11796 | 2432 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>" }, |
7853 | 2433 { N_("/Buddies/_Add Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, |
2434 { N_("/Buddies/Add C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD }, | |
2435 { N_("/Buddies/Add _Group..."), NULL, gaim_blist_request_add_group, 0, "<StockItem>", GTK_STOCK_ADD }, | |
11796 | 2436 { "/Buddies/sep3", NULL, NULL, 0, "<Separator>" }, |
7620 | 2437 { N_("/Buddies/_Quit"), "<CTL>Q", gaim_core_quit, 0, "<StockItem>", GTK_STOCK_QUIT }, |
5228 | 2438 |
8470
9949b752d1ab
[gaim-migrate @ 9203]
Christian Hammond <chipx86@chipx86.com>
parents:
8444
diff
changeset
|
2439 /* Tools */ |
5228 | 2440 { N_("/_Tools"), NULL, NULL, 0, "<Branch>" }, |
2441 { N_("/Tools/Buddy _Pounce"), NULL, NULL, 0, "<Branch>" }, | |
8845 | 2442 { N_("/Tools/Account Ac_tions"), NULL, NULL, 0, "<Branch>" }, |
5228 | 2443 { "/Tools/sep1", NULL, NULL, 0, "<Separator>" }, |
7620 | 2444 { N_("/Tools/A_ccounts"), "<CTL>A", gaim_gtk_accounts_window_show, 0, "<StockItem>", GAIM_STOCK_ACCOUNTS }, |
10325 | 2445 { N_("/Tools/Pr_eferences"), "<CTL>P", gaim_gtk_prefs_show, 0, "<StockItem>", GTK_STOCK_PREFERENCES }, |
12113 | 2446 { N_("/Tools/Plu_gins"), "<CTL>U", gaim_gtk_plugin_dialog_show, 0, NULL }, |
10694 | 2447 { N_("/Tools/Pr_ivacy"), NULL, gaim_gtk_privacy_dialog_show, 0, "<StockItem>", GTK_STOCK_DIALOG_ERROR }, |
10019
8cc6f0bfa215
[gaim-migrate @ 10943]
Luke Schierer <lschiere@pidgin.im>
parents:
10018
diff
changeset
|
2448 { N_("/Tools/_File Transfers"), "<CTL>T", gaim_show_xfer_dialog, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, |
10694 | 2449 { N_("/Tools/R_oom List"), NULL, gaim_gtk_roomlist_dialog_show, 0, "<StockItem>", GTK_STOCK_INDEX }, |
10325 | 2450 { "/Tools/sep2", NULL, NULL, 0, "<Separator>" }, |
10074 | 2451 { N_("/Tools/Mute _Sounds"), "<CTL>S", gaim_gtk_blist_mute_sounds_cb, 0, "<CheckItem>"}, |
7620 | 2452 { N_("/Tools/View System _Log"), NULL, gtk_blist_show_systemlog_cb, 0, NULL }, |
5228 | 2453 |
2454 /* Help */ | |
2455 { N_("/_Help"), NULL, NULL, 0, "<Branch>" }, | |
2456 { N_("/Help/Online _Help"), "F1", gtk_blist_show_onlinehelp_cb, 0, "<StockItem>", GTK_STOCK_HELP }, | |
7620 | 2457 { N_("/Help/_Debug Window"), NULL, toggle_debug, 0, NULL }, |
9753 | 2458 { N_("/Help/_About"), NULL, gaim_gtkdialogs_about, 0, "<StockItem>", GAIM_STOCK_ABOUT }, |
5228 | 2459 }; |
2460 | |
2461 /********************************************************* | |
2462 * Private Utility functions * | |
2463 *********************************************************/ | |
2464 | |
5234 | 2465 static char *gaim_get_tooltip_text(GaimBlistNode *node) |
5228 | 2466 { |
10475 | 2467 GString *str = g_string_new(""); |
5237 | 2468 GaimPlugin *prpl; |
2469 GaimPluginProtocolInfo *prpl_info = NULL; | |
10475 | 2470 char *tmp; |
2471 | |
2472 if (GAIM_BLIST_NODE_IS_CHAT(node)) | |
2473 { | |
2474 GaimChat *chat; | |
2475 GList *cur; | |
5274 | 2476 struct proto_chat_entry *pce; |
10475 | 2477 char *name, *value; |
2478 | |
2479 chat = (GaimChat *)node; | |
7956 | 2480 prpl = gaim_find_prpl(gaim_account_get_protocol_id(chat->account)); |
5274 | 2481 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
2482 | |
10475 | 2483 tmp = g_markup_escape_text(gaim_chat_get_name(chat), -1); |
2484 g_string_append_printf(str, "<span size='larger' weight='bold'>%s</span>", tmp); | |
2485 g_free(tmp); | |
2486 | |
2487 if (g_list_length(gaim_connections_get_all()) > 1) | |
2488 { | |
2489 tmp = g_markup_escape_text(chat->account->username, -1); | |
2490 g_string_append_printf(str, _("\n<b>Account:</b> %s"), tmp); | |
2491 g_free(tmp); | |
2492 } | |
2493 | |
9959 | 2494 if (prpl_info->chat_info != NULL) |
10475 | 2495 cur = prpl_info->chat_info(chat->account->gc); |
2496 else | |
2497 cur = NULL; | |
2498 | |
2499 while (cur != NULL) | |
2500 { | |
2501 pce = cur->data; | |
2502 | |
2503 if (!pce->secret && (!pce->required && | |
2504 g_hash_table_lookup(chat->components, pce->identifier) == NULL)) | |
2505 { | |
2506 tmp = gaim_text_strip_mnemonic(pce->label); | |
2507 name = g_markup_escape_text(tmp, -1); | |
2508 g_free(tmp); | |
2509 value = g_markup_escape_text(g_hash_table_lookup( | |
2510 chat->components, pce->identifier), -1); | |
10924
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2511 g_string_append_printf(str, "\n<b>%s</b> %s", |
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2512 name ? name : "", |
7a82d86ab44a
[gaim-migrate @ 12695]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10918
diff
changeset
|
2513 value ? value : ""); |
10475 | 2514 g_free(name); |
8020 | 2515 g_free(value); |
2516 } | |
10475 | 2517 |
5274 | 2518 g_free(pce); |
10475 | 2519 cur = g_list_remove(cur, pce); |
5274 | 2520 } |
10475 | 2521 } |
2522 else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) | |
2523 { | |
2524 GaimContact *c; | |
7620 | 2525 GaimBuddy *b; |
9944 | 2526 GaimPresence *presence; |
10475 | 2527 char *tmp; |
9944 | 2528 gboolean idle; |
10567 | 2529 time_t idle_secs, signon; |
10475 | 2530 |
2531 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
2532 { | |
2533 c = (GaimContact *)node; | |
2534 b = gaim_contact_get_priority_buddy(c); | |
2535 } | |
2536 else | |
2537 { | |
7620 | 2538 b = (GaimBuddy *)node; |
10475 | 2539 c = gaim_buddy_get_contact(b); |
7620 | 2540 } |
2541 | |
7956 | 2542 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5234 | 2543 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
2544 | |
10475 | 2545 presence = gaim_buddy_get_presence(b); |
2546 | |
2547 /* Buddy Name */ | |
2548 tmp = g_markup_escape_text(gaim_buddy_get_name(b), -1); | |
2549 g_string_append_printf(str, "<span size='larger' weight='bold'>%s</span>", tmp); | |
2550 g_free(tmp); | |
2551 | |
2552 /* Account */ | |
2553 if (g_list_length(gaim_connections_get_all()) > 1) | |
2554 { | |
2555 tmp = g_markup_escape_text(gaim_account_get_username( | |
2556 gaim_buddy_get_account(b)), -1); | |
2557 g_string_append_printf(str, _("\n<b>Account:</b> %s"), tmp); | |
2558 g_free(tmp); | |
2559 } | |
2560 | |
2561 /* Contact Alias */ | |
2562 if (GAIM_BLIST_NODE_IS_CONTACT(node) && | |
10499 | 2563 (c->alias != NULL)) |
10475 | 2564 { |
10499 | 2565 tmp = g_markup_escape_text(c->alias, -1); |
10475 | 2566 g_string_append_printf(str, _("\n<b>Contact Alias:</b> %s"), tmp); |
2567 g_free(tmp); | |
2568 } | |
2569 | |
2570 /* Alias */ | |
2571 if ((b->alias != NULL) && (b->alias[0] != '\0')) | |
2572 { | |
2573 tmp = g_markup_escape_text(b->alias, -1); | |
2574 g_string_append_printf(str, _("\n<b>Alias:</b> %s"), tmp); | |
2575 g_free(tmp); | |
2576 } | |
2577 | |
2578 /* Nickname/Server Alias */ | |
2579 if (b->server_alias != NULL) | |
2580 { | |
2581 tmp = g_markup_escape_text(b->server_alias, -1); | |
2582 g_string_append_printf(str, _("\n<b>Nickname:</b> %s"), tmp); | |
2583 g_free(tmp); | |
2584 } | |
2585 | |
2586 /* Logged In */ | |
10567 | 2587 signon = gaim_presence_get_login_time(presence); |
10992
2bda44d66641
[gaim-migrate @ 12830]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10968
diff
changeset
|
2588 if (GAIM_BUDDY_IS_ONLINE(b) && signon > 0) |
10475 | 2589 { |
10567 | 2590 tmp = gaim_str_seconds_to_string(time(NULL) - signon); |
10475 | 2591 g_string_append_printf(str, _("\n<b>Logged In:</b> %s"), tmp); |
2592 g_free(tmp); | |
2593 } | |
2594 | |
2595 /* Idle */ | |
2596 idle = gaim_presence_is_idle(presence); | |
2597 if (idle) | |
2598 { | |
2599 idle_secs = gaim_presence_get_idle_time(presence); | |
2600 if (idle_secs > 0) | |
2601 { | |
2602 tmp = gaim_str_seconds_to_string(time(NULL) - idle_secs); | |
2603 g_string_append_printf(str, _("\n<b>Idle:</b> %s"), tmp); | |
2604 g_free(tmp); | |
2605 } | |
2606 } | |
2607 | |
2608 /* Last Seen */ | |
11910 | 2609 if (!GAIM_BUDDY_IS_ONLINE(b)) |
10475 | 2610 { |
11023 | 2611 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode *)c)->ui_data; |
2612 GaimBlistNode *bnode; | |
2613 int lastseen = 0; | |
2614 | |
2615 if (!gtknode->contact_expanded || GAIM_BLIST_NODE_IS_CONTACT(node)) | |
2616 { | |
11437
1c20849fc716
[gaim-migrate @ 13674]
Richard Laager <rlaager@wiktel.com>
parents:
11436
diff
changeset
|
2617 /* We're either looking at a buddy for a collapsed contact or |
11438
5451fe2d89c0
[gaim-migrate @ 13675]
Richard Laager <rlaager@wiktel.com>
parents:
11437
diff
changeset
|
2618 * an expanded contact itself so we show the most recent |
11023 | 2619 * (largest) last_seen time for any of the buddies under |
2620 * the contact. */ | |
2621 for (bnode = ((GaimBlistNode *)c)->child ; bnode != NULL ; bnode = bnode->next) | |
2622 { | |
2623 int value = gaim_blist_node_get_int(bnode, "last_seen"); | |
2624 if (value > lastseen) | |
2625 lastseen = value; | |
2626 } | |
2627 } | |
2628 else | |
2629 { | |
2630 /* We're dealing with a buddy under an expanded contact, | |
2631 * so we show the last_seen time for the buddy. */ | |
2632 lastseen = gaim_blist_node_get_int(&b->node, "last_seen"); | |
2633 } | |
2634 | |
10475 | 2635 if (lastseen > 0) |
2636 { | |
2637 tmp = gaim_str_seconds_to_string(time(NULL) - lastseen); | |
2638 g_string_append_printf(str, _("\n<b>Last Seen:</b> %s ago"), tmp); | |
2639 g_free(tmp); | |
5234 | 2640 } |
2641 } | |
2642 | |
10475 | 2643 |
2644 /* Offline? */ | |
2645 if (!GAIM_BUDDY_IS_ONLINE(b)) { | |
2646 g_string_append_printf(str, _("\n<b>Status:</b> Offline")); | |
2647 } | |
10992
2bda44d66641
[gaim-migrate @ 12830]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10968
diff
changeset
|
2648 |
2bda44d66641
[gaim-migrate @ 12830]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10968
diff
changeset
|
2649 if (prpl_info && prpl_info->tooltip_text) |
10475 | 2650 { |
2651 /* Additional text from the PRPL */ | |
2652 const char *end; | |
2653 tmp = prpl_info->tooltip_text(b); | |
2654 | |
2655 if (tmp && !g_utf8_validate(tmp, -1, &end)) | |
2656 { | |
2657 char *new = g_strndup(tmp, g_utf8_pointer_to_offset(tmp, end)); | |
2658 g_free(tmp); | |
2659 tmp = new; | |
2660 } | |
2661 | |
11634 | 2662 if (tmp != NULL) |
2663 g_string_append(str, tmp); | |
10476 | 2664 g_free(tmp); |
10475 | 2665 } |
2666 | |
2667 /* These are Easter Eggs. Patches to remove them will be rejected. */ | |
2668 if (!g_ascii_strcasecmp(b->name, "robflynn")) | |
2669 g_string_append(str, _("\n<b>Description:</b> Spooky")); | |
2670 if (!g_ascii_strcasecmp(b->name, "seanegn")) | |
2671 g_string_append(str, _("\n<b>Status:</b> Awesome")); | |
2672 if (!g_ascii_strcasecmp(b->name, "chipx86")) | |
2673 g_string_append(str, _("\n<b>Status:</b> Rockin'")); | |
5234 | 2674 } |
10475 | 2675 |
8824 | 2676 gaim_signal_emit(gaim_gtk_blist_get_handle(), |
10477 | 2677 "drawing-tooltip", node, str); |
10475 | 2678 |
2679 return g_string_free(str, FALSE); | |
5228 | 2680 } |
2681 | |
7620 | 2682 struct _emblem_data { |
9954 | 2683 const char *filename; |
7620 | 2684 int x; |
2685 int y; | |
2686 }; | |
2687 | |
9944 | 2688 GdkPixbuf * |
2689 gaim_gtk_blist_get_status_icon(GaimBlistNode *node, GaimStatusIconSize size) | |
5228 | 2690 { |
7620 | 2691 GdkPixbuf *scale, *status = NULL; |
2692 int i, scalesize = 30; | |
2693 char *filename; | |
5228 | 2694 const char *protoname = NULL; |
7620 | 2695 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
11910 | 2696 struct _gaim_gtk_blist_node *gtkbuddynode = NULL; |
7620 | 2697 struct _emblem_data emblems[4] = {{NULL, 15, 15}, {NULL, 0, 15}, |
2698 {NULL, 0, 0}, {NULL, 15, 0}}; | |
9944 | 2699 GaimPresence *presence = NULL; |
7620 | 2700 GaimBuddy *buddy = NULL; |
2701 GaimChat *chat = NULL; | |
2702 | |
2703 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
11910 | 2704 if(!gtknode->contact_expanded) { |
7620 | 2705 buddy = gaim_contact_get_priority_buddy((GaimContact*)node); |
11910 | 2706 gtkbuddynode = ((GaimBlistNode*)buddy)->ui_data; |
2707 } | |
7620 | 2708 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
2709 buddy = (GaimBuddy*)node; | |
11910 | 2710 gtkbuddynode = node->ui_data; |
7620 | 2711 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { |
2712 chat = (GaimChat*)node; | |
2713 } else { | |
5228 | 2714 return NULL; |
5234 | 2715 } |
2716 | |
7620 | 2717 if(buddy || chat) { |
2718 GaimAccount *account; | |
2719 GaimPlugin *prpl; | |
2720 GaimPluginProtocolInfo *prpl_info; | |
2721 | |
2722 if(buddy) | |
2723 account = buddy->account; | |
2724 else | |
2725 account = chat->account; | |
2726 | |
7956 | 2727 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
7620 | 2728 if(!prpl) |
2729 return NULL; | |
2730 | |
2731 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
2732 | |
2733 if(prpl_info && prpl_info->list_icon) { | |
2734 protoname = prpl_info->list_icon(account, buddy); | |
2735 } | |
2736 if(prpl_info && prpl_info->list_emblems && buddy) { | |
11924 | 2737 if(gtknode && !gtknode->recent_signonoff) |
7620 | 2738 prpl_info->list_emblems(buddy, &emblems[0].filename, |
2739 &emblems[1].filename, &emblems[2].filename, | |
2740 &emblems[3].filename); | |
2741 } | |
5234 | 2742 } |
5228 | 2743 |
7620 | 2744 if(size == GAIM_STATUS_ICON_SMALL) { |
5228 | 2745 scalesize = 15; |
7620 | 2746 /* So that only the se icon will composite */ |
2747 emblems[1].filename = emblems[2].filename = emblems[3].filename = NULL; | |
5228 | 2748 } |
2749 | |
11917 | 2750 if(buddy && GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { |
7620 | 2751 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL); |
11917 | 2752 } else if(buddy && !GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) { |
7620 | 2753 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "logout.png", NULL); |
2754 } else if(buddy || chat) { | |
5228 | 2755 char *image = g_strdup_printf("%s.png", protoname); |
2756 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2757 g_free(image); | |
7620 | 2758 } else { |
2759 /* gaim dude */ | |
2760 filename = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL); | |
5228 | 2761 } |
7620 | 2762 |
2763 status = gdk_pixbuf_new_from_file(filename, NULL); | |
2764 g_free(filename); | |
2765 | |
2766 if(!status) | |
2767 return NULL; | |
2768 | |
2769 scale = gdk_pixbuf_scale_simple(status, scalesize, scalesize, | |
2770 GDK_INTERP_BILINEAR); | |
2771 g_object_unref(status); | |
2772 | |
2773 for(i=0; i<4; i++) { | |
2774 if(emblems[i].filename) { | |
2775 GdkPixbuf *emblem; | |
2776 char *image = g_strdup_printf("%s.png", emblems[i].filename); | |
2777 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2778 g_free(image); | |
2779 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
2780 g_free(filename); | |
2781 if(emblem) { | |
2782 if(i == 0 && size == GAIM_STATUS_ICON_SMALL) { | |
2783 gdk_pixbuf_composite(emblem, | |
2784 scale, 5, 5, | |
2785 10, 10, | |
2786 5, 5, | |
2787 .6, .6, | |
2788 GDK_INTERP_BILINEAR, | |
2789 255); | |
2790 } else { | |
2791 gdk_pixbuf_composite(emblem, | |
2792 scale, emblems[i].x, emblems[i].y, | |
2793 15, 15, | |
2794 emblems[i].x, emblems[i].y, | |
2795 1, 1, | |
2796 GDK_INTERP_BILINEAR, | |
2797 255); | |
2798 } | |
2799 g_object_unref(emblem); | |
2800 } | |
5228 | 2801 } |
2802 } | |
7620 | 2803 |
2804 if(buddy) { | |
9944 | 2805 presence = gaim_buddy_get_presence(buddy); |
2806 | |
2807 if (!GAIM_BUDDY_IS_ONLINE(buddy)) | |
7620 | 2808 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); |
10118 | 2809 else if (gaim_presence_is_idle(presence)) |
9944 | 2810 { |
7620 | 2811 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.25, FALSE); |
9944 | 2812 } |
11111
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2813 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2814 if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2815 { |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2816 GdkPixbuf *emblem; |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2817 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "blocked.png", NULL); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2818 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2819 emblem = gdk_pixbuf_new_from_file(filename, NULL); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2820 g_free(filename); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2821 |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2822 if (emblem) |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2823 { |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2824 gdk_pixbuf_composite(emblem, scale, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2825 0, 0, scalesize, scalesize, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2826 0, 0, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2827 (double)scalesize / gdk_pixbuf_get_width(emblem), |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2828 (double)scalesize / gdk_pixbuf_get_height(emblem), |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2829 GDK_INTERP_BILINEAR, |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2830 224); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2831 g_object_unref(emblem); |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2832 } |
f03dce7ea408
[gaim-migrate @ 13163]
Richard Laager <rlaager@wiktel.com>
parents:
11059
diff
changeset
|
2833 } |
5228 | 2834 } |
7620 | 2835 |
5228 | 2836 return scale; |
2837 } | |
2838 | |
7620 | 2839 static gchar *gaim_gtk_blist_get_name_markup(GaimBuddy *b, gboolean selected) |
5228 | 2840 { |
7620 | 2841 const char *name; |
2842 char *esc, *text = NULL; | |
5228 | 2843 GaimPlugin *prpl; |
2844 GaimPluginProtocolInfo *prpl_info = NULL; | |
7620 | 2845 GaimContact *contact; |
9944 | 2846 GaimPresence *presence; |
7620 | 2847 struct _gaim_gtk_blist_node *gtkcontactnode = NULL; |
11257 | 2848 char *idletime = NULL, *statustext = NULL; |
5228 | 2849 time_t t; |
7620 | 2850 /* XXX Clean up this crap */ |
2851 | |
2852 contact = (GaimContact*)((GaimBlistNode*)b)->parent; | |
2853 if(contact) | |
2854 gtkcontactnode = ((GaimBlistNode*)contact)->ui_data; | |
2855 | |
2856 if(gtkcontactnode && !gtkcontactnode->contact_expanded && contact->alias) | |
2857 name = contact->alias; | |
2858 else | |
9620 | 2859 name = gaim_buddy_get_alias(b); |
7620 | 2860 esc = g_markup_escape_text(name, strlen(name)); |
2861 | |
7956 | 2862 prpl = gaim_find_prpl(gaim_account_get_protocol_id(b->account)); |
5228 | 2863 |
2864 if (prpl != NULL) | |
2865 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); | |
2866 | |
9944 | 2867 presence = gaim_buddy_get_presence(b); |
2868 | |
7620 | 2869 if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) { |
9944 | 2870 |
10118 | 2871 if ((gaim_presence_is_idle(presence) || !GAIM_BUDDY_IS_ONLINE(b)) && !selected) |
9944 | 2872 { |
10118 | 2873 text = g_strdup_printf("<span color='%s'>%s</span>", |
2874 dim_grey(), esc); | |
5228 | 2875 g_free(esc); |
2876 return text; | |
7620 | 2877 } |
9944 | 2878 else |
5228 | 2879 return esc; |
2880 } | |
2881 | |
8122
36674144c510
[gaim-migrate @ 8826]
Christian Hammond <chipx86@chipx86.com>
parents:
8113
diff
changeset
|
2882 if (prpl_info && prpl_info->status_text && b->account->gc) { |
5228 | 2883 char *tmp = prpl_info->status_text(b); |
2884 const char *end; | |
2885 | |
2886 if(tmp && !g_utf8_validate(tmp, -1, &end)) { | |
2887 char *new = g_strndup(tmp, | |
2888 g_utf8_pointer_to_offset(tmp, end)); | |
2889 g_free(tmp); | |
2890 tmp = new; | |
2891 } | |
2892 | |
10288 | 2893 #if !GTK_CHECK_VERSION(2,6,0) |
5228 | 2894 if(tmp) { |
2895 char buf[32]; | |
2896 char *c = tmp; | |
2897 int length = 0, vis=0; | |
2898 gboolean inside = FALSE; | |
2899 g_strdelimit(tmp, "\n", ' '); | |
11920 | 2900 gaim_str_strip_char(tmp, '\r'); |
5228 | 2901 |
2902 while(*c && vis < 20) { | |
2903 if(*c == '&') | |
2904 inside = TRUE; | |
2905 else if(*c == ';') | |
2906 inside = FALSE; | |
2907 if(!inside) | |
2908 vis++; | |
7620 | 2909 c = g_utf8_next_char(c); /* this is fun */ |
5228 | 2910 } |
2911 | |
7620 | 2912 length = c - tmp; |
2913 | |
5228 | 2914 if(vis == 20) |
2915 g_snprintf(buf, sizeof(buf), "%%.%ds...", length); | |
2916 else | |
2917 g_snprintf(buf, sizeof(buf), "%%s "); | |
2918 | |
2919 statustext = g_strdup_printf(buf, tmp); | |
2920 | |
2921 g_free(tmp); | |
2922 } | |
10288 | 2923 #else |
2924 statustext = tmp; | |
2925 #endif | |
5228 | 2926 } |
2927 | |
10351 | 2928 if (gaim_presence_is_idle(presence)) { |
9944 | 2929 time_t idle_secs = gaim_presence_get_idle_time(presence); |
2930 | |
10351 | 2931 if (idle_secs > 0) { |
9944 | 2932 int ihrs, imin; |
2933 | |
2934 time(&t); | |
2935 ihrs = (t - idle_secs) / 3600; | |
2936 imin = ((t - idle_secs) / 60) % 60; | |
2937 | |
2938 if (ihrs) | |
11134
f78e7e982cf4
[gaim-migrate @ 13195]
Richard Laager <rlaager@wiktel.com>
parents:
11111
diff
changeset
|
2939 idletime = g_strdup_printf(_("Idle (%dh %02dm) "), ihrs, imin); |
9944 | 2940 else |
2941 idletime = g_strdup_printf(_("Idle (%dm) "), imin); | |
2942 } | |
5228 | 2943 else |
9944 | 2944 idletime = g_strdup(_("Idle ")); |
5228 | 2945 } |
2946 | |
2947 if(!GAIM_BUDDY_IS_ONLINE(b) && !statustext) | |
7620 | 2948 statustext = g_strdup(_("Offline ")); |
2949 | |
10118 | 2950 if (gaim_presence_is_idle(presence) && !selected) { |
2951 text = g_strdup_printf("<span color='%s'>%s</span>\n" | |
11257 | 2952 "<span color='%s' size='smaller'>%s%s%s</span>", |
10118 | 2953 dim_grey(), esc, dim_grey(), |
5228 | 2954 statustext != NULL ? statustext : "", |
11134
f78e7e982cf4
[gaim-migrate @ 13195]
Richard Laager <rlaager@wiktel.com>
parents:
11111
diff
changeset
|
2955 (idletime != NULL && statustext != NULL) ? " - " : "", |
11257 | 2956 idletime != NULL ? idletime : ""); |
2957 } else if (statustext == NULL && idletime == NULL && GAIM_BUDDY_IS_ONLINE(b)) { | |
5228 | 2958 text = g_strdup(esc); |
2959 } else { | |
10118 | 2960 if (selected) |
2961 text = g_strdup_printf("%s\n" | |
11257 | 2962 "<span size='smaller'>%s%s%s</span>", esc, |
10118 | 2963 statustext != NULL ? statustext : "", |
11134
f78e7e982cf4
[gaim-migrate @ 13195]
Richard Laager <rlaager@wiktel.com>
parents:
11111
diff
changeset
|
2964 (idletime != NULL && statustext != NULL) ? " - " : "", |
11257 | 2965 idletime != NULL ? idletime : ""); |
10118 | 2966 else |
2967 text = g_strdup_printf("%s\n" | |
11257 | 2968 "<span color='%s' size='smaller'>%s%s%s</span>", esc, |
10144 | 2969 dim_grey(), |
10118 | 2970 statustext != NULL ? statustext : "", |
11134
f78e7e982cf4
[gaim-migrate @ 13195]
Richard Laager <rlaager@wiktel.com>
parents:
11111
diff
changeset
|
2971 (idletime != NULL && statustext != NULL) ? " - " : "", |
11257 | 2972 idletime != NULL ? idletime : ""); |
5228 | 2973 } |
2974 if (idletime) | |
2975 g_free(idletime); | |
2976 if (statustext) | |
2977 g_free(statustext); | |
2978 if (esc) | |
2979 g_free(esc); | |
2980 | |
2981 return text; | |
2982 } | |
2983 | |
2984 static void gaim_gtk_blist_restore_position() | |
2985 { | |
7620 | 2986 int blist_x, blist_y, blist_width, blist_height; |
2987 | |
2988 blist_width = gaim_prefs_get_int("/gaim/gtk/blist/width"); | |
2989 | |
2990 /* if the window exists, is hidden, we're saving positions, and the | |
2991 * position is sane... */ | |
2992 if (gtkblist && gtkblist->window && | |
2993 !GTK_WIDGET_VISIBLE(gtkblist->window) && blist_width != 0) { | |
2994 | |
2995 blist_x = gaim_prefs_get_int("/gaim/gtk/blist/x"); | |
2996 blist_y = gaim_prefs_get_int("/gaim/gtk/blist/y"); | |
2997 blist_height = gaim_prefs_get_int("/gaim/gtk/blist/height"); | |
2998 | |
5228 | 2999 /* ...check position is on screen... */ |
7620 | 3000 if (blist_x >= gdk_screen_width()) |
3001 blist_x = gdk_screen_width() - 100; | |
3002 else if (blist_x + blist_width < 0) | |
3003 blist_x = 100; | |
3004 | |
3005 if (blist_y >= gdk_screen_height()) | |
3006 blist_y = gdk_screen_height() - 100; | |
3007 else if (blist_y + blist_height < 0) | |
3008 blist_y = 100; | |
3009 | |
5228 | 3010 /* ...and move it back. */ |
7620 | 3011 gtk_window_move(GTK_WINDOW(gtkblist->window), blist_x, blist_y); |
3012 gtk_window_resize(GTK_WINDOW(gtkblist->window), blist_width, blist_height); | |
5228 | 3013 } |
3014 } | |
3015 | |
7620 | 3016 static gboolean gaim_gtk_blist_refresh_timer(GaimBuddyList *list) |
5228 | 3017 { |
7620 | 3018 GaimBlistNode *gnode, *cnode; |
3019 | |
3020 for(gnode = list->root; gnode; gnode = gnode->next) { | |
3021 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5234 | 3022 continue; |
7620 | 3023 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3024 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | |
9944 | 3025 GaimBuddy *buddy; |
3026 | |
3027 buddy = gaim_contact_get_priority_buddy((GaimContact*)cnode); | |
10012 | 3028 |
3029 if (buddy && | |
3030 gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) | |
9944 | 3031 gaim_gtk_blist_update(list, cnode); |
7620 | 3032 } |
5228 | 3033 } |
3034 } | |
3035 | |
3036 /* keep on going */ | |
3037 return TRUE; | |
3038 } | |
3039 | |
7620 | 3040 static void gaim_gtk_blist_hide_node(GaimBuddyList *list, GaimBlistNode *node) |
5260 | 3041 { |
3042 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3043 GtkTreeIter iter; | |
3044 | |
3045 if (!gtknode || !gtknode->row || !gtkblist) | |
3046 return; | |
3047 | |
3048 if(gtkblist->selected_node == node) | |
3049 gtkblist->selected_node = NULL; | |
3050 | |
3051 if (get_iter_from_node(node, &iter)) { | |
3052 gtk_tree_store_remove(gtkblist->treemodel, &iter); | |
7620 | 3053 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) |
3054 || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5260 | 3055 gaim_gtk_blist_update(list, node->parent); |
3056 } | |
3057 } | |
3058 gtk_tree_row_reference_free(gtknode->row); | |
3059 gtknode->row = NULL; | |
3060 } | |
3061 | |
10352 | 3062 static const char *require_connection[] = |
7620 | 3063 { |
10352 | 3064 N_("/Buddies/New Instant Message..."), |
3065 N_("/Buddies/Join a Chat..."), | |
3066 N_("/Buddies/Get User Info..."), | |
3067 N_("/Buddies/Add Buddy..."), | |
3068 N_("/Buddies/Add Chat..."), | |
3069 N_("/Buddies/Add Group..."), | |
3070 }; | |
3071 | |
10357 | 3072 static const int require_connection_size = sizeof(require_connection) |
3073 / sizeof(*require_connection); | |
10352 | 3074 |
3075 /** | |
3076 * Rebuild dynamic menus and make menu items sensitive/insensitive | |
3077 * where appropriate. | |
3078 */ | |
3079 static void | |
3080 update_menu_bar(GaimGtkBuddyList *gtkblist) | |
3081 { | |
8937 | 3082 GtkWidget *widget; |
10352 | 3083 gboolean sensitive; |
3084 int i; | |
3085 | |
3086 g_return_if_fail(gtkblist != NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3087 |
7620 | 3088 gaim_gtk_blist_update_protocol_actions(); |
8235 | 3089 gaim_gtkpounce_menu_build(gtkblist->bpmenu); |
8937 | 3090 |
10352 | 3091 sensitive = (gaim_connections_get_all() != NULL); |
3092 | |
10357 | 3093 for (i = 0; i < require_connection_size; i++) |
10352 | 3094 { |
3095 widget = gtk_item_factory_get_widget(gtkblist->ift, require_connection[i]); | |
3096 gtk_widget_set_sensitive(widget, sensitive); | |
3097 } | |
3098 | |
8940 | 3099 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Join a Chat...")); |
3100 gtk_widget_set_sensitive(widget, gaim_gtk_blist_joinchat_is_showable()); | |
3101 | |
11988 | 3102 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Add Chat...")); |
3103 gtk_widget_set_sensitive(widget, gaim_gtk_blist_joinchat_is_showable()); | |
3104 | |
8937 | 3105 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Room List")); |
8939 | 3106 gtk_widget_set_sensitive(widget, gaim_gtk_roomlist_is_showable()); |
8938 | 3107 |
3108 widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Privacy")); | |
3109 gtk_widget_set_sensitive(widget, gaim_gtk_privacy_is_showable()); | |
7620 | 3110 } |
3111 | |
10352 | 3112 static void |
3113 sign_on_off_cb(GaimConnection *gc, GaimBuddyList *blist) | |
3114 { | |
3115 GaimGtkBuddyList *gtkblist = GAIM_GTK_BLIST(blist); | |
3116 | |
3117 update_menu_bar(gtkblist); | |
3118 } | |
8986 | 3119 |
3120 static void | |
3121 plugin_changed_cb(GaimPlugin *p, gpointer *data) | |
3122 { | |
3123 gaim_gtk_blist_update_plugin_actions(); | |
3124 } | |
3125 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3126 static gboolean |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3127 menutray_press_cb(GtkWidget *widget, GdkEventButton *event) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3128 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3129 gaim_gtkconv_present_conversation(gaim_gtk_conversations_get_first_unseen( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3130 GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3131 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3132 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3133 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3134 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3135 conversation_updated_cb(GaimConversation *conv, GaimConvUpdateType type, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3136 GaimGtkBuddyList *gtkblist) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3137 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3138 GtkWidget *img = NULL; |
12117 | 3139 GString *tooltip_text = NULL; |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3140 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3141 if(gtkblist->menutrayicon) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3142 gtk_widget_destroy(gtkblist->menutrayicon); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3143 gtkblist->menutrayicon = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3144 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3145 |
12117 | 3146 if(gaim_gtk_conversations_get_first_unseen(GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT)) { |
3147 GList *convs = gaim_get_ims(); | |
3148 tooltip_text = g_string_new(""); | |
3149 while(convs) { | |
3150 conv = convs->data; | |
3151 if(GAIM_IS_GTK_CONVERSATION(conv)) { | |
3152 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3153 if(gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) { | |
3154 g_string_append_printf(tooltip_text, | |
3155 _("Unread messages from %s\n"), gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
3156 } | |
3157 } | |
3158 convs = convs->next; | |
3159 } | |
3160 /* get rid of the last newline */ | |
3161 tooltip_text = g_string_truncate(tooltip_text, tooltip_text->len -1); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3162 img = gtk_image_new_from_stock(GAIM_STOCK_PENDING, GTK_ICON_SIZE_MENU); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3163 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3164 gtkblist->menutrayicon = gtk_event_box_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3165 gtk_container_add(GTK_CONTAINER(gtkblist->menutrayicon), img); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3166 gtk_widget_show(img); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3167 gtk_widget_show(gtkblist->menutrayicon); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3168 g_signal_connect(G_OBJECT(gtkblist->menutrayicon), "button-press-event", G_CALLBACK(menutray_press_cb), NULL); |
12117 | 3169 |
3170 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkblist->menutray), gtkblist->menutrayicon, g_string_free(tooltip_text, FALSE)); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3171 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3172 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3173 |
5228 | 3174 /********************************************************************************** |
3175 * Public API Functions * | |
3176 **********************************************************************************/ | |
9774 | 3177 |
7620 | 3178 static void gaim_gtk_blist_new_list(GaimBuddyList *blist) |
5228 | 3179 { |
7620 | 3180 GaimGtkBuddyList *gtkblist; |
3181 | |
3182 gtkblist = g_new0(GaimGtkBuddyList, 1); | |
3183 blist->ui_data = gtkblist; | |
5228 | 3184 } |
3185 | |
5256 | 3186 static void gaim_gtk_blist_new_node(GaimBlistNode *node) |
3187 { | |
3188 node->ui_data = g_new0(struct _gaim_gtk_blist_node, 1); | |
3189 } | |
3190 | |
11018 | 3191 gboolean gaim_gtk_blist_node_is_contact_expanded(GaimBlistNode *node) |
3192 { | |
3193 if GAIM_BLIST_NODE_IS_BUDDY(node) | |
3194 node = node->parent; | |
3195 | |
3196 g_return_val_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node), FALSE); | |
3197 | |
3198 return ((struct _gaim_gtk_blist_node *)node->ui_data)->contact_expanded; | |
3199 } | |
3200 | |
5228 | 3201 void gaim_gtk_blist_update_columns() |
3202 { | |
3203 if(!gtkblist) | |
3204 return; | |
3205 | |
7620 | 3206 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")) { |
5228 | 3207 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, TRUE); |
3208 gtk_tree_view_column_set_visible(gtkblist->idle_column, FALSE); | |
3209 } else { | |
10351 | 3210 gtk_tree_view_column_set_visible(gtkblist->idle_column, TRUE); |
5228 | 3211 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, FALSE); |
3212 } | |
3213 } | |
3214 | |
10433 | 3215 enum { |
3216 DRAG_BUDDY, | |
3217 DRAG_ROW, | |
3218 DRAG_VCARD, | |
3219 DRAG_TEXT, | |
3220 DRAG_URI, | |
3221 NUM_TARGETS | |
3222 }; | |
5228 | 3223 |
3224 static char * | |
3225 item_factory_translate_func (const char *path, gpointer func_data) | |
3226 { | |
7620 | 3227 return _((char *)path); |
5228 | 3228 } |
3229 | |
5422 | 3230 void gaim_gtk_blist_setup_sort_methods() |
3231 { | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
3232 gaim_gtk_blist_sort_method_reg("none", _("Manually"), sort_method_none); |
7620 | 3233 #if GTK_CHECK_VERSION(2,2,1) |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
3234 gaim_gtk_blist_sort_method_reg("alphabetical", _("Alphabetically"), sort_method_alphabetical); |
7620 | 3235 gaim_gtk_blist_sort_method_reg("status", _("By status"), sort_method_status); |
3236 gaim_gtk_blist_sort_method_reg("log_size", _("By log size"), sort_method_log); | |
3237 #endif | |
3238 gaim_gtk_blist_sort_method_set(gaim_prefs_get_string("/gaim/gtk/blist/sort_type")); | |
3239 } | |
3240 | |
10433 | 3241 static void _prefs_change_redo_list() |
3242 { | |
7620 | 3243 redo_buddy_list(gaim_get_blist(), TRUE); |
3244 } | |
3245 | |
3246 static void _prefs_change_sort_method(const char *pref_name, GaimPrefType type, | |
10433 | 3247 gpointer val, gpointer data) |
3248 { | |
7620 | 3249 if(!strcmp(pref_name, "/gaim/gtk/blist/sort_type")) |
3250 gaim_gtk_blist_sort_method_set(val); | |
3251 } | |
3252 | |
10433 | 3253 /* |
3254 * "This is so dead sexy." | |
3255 * "Two thumbs up." | |
3256 * "Best movie of the year." | |
3257 * | |
3258 * This is the function that handles CTRL+F searching in the buddy list. | |
3259 * It finds the top-most buddy/group/chat/whatever containing the | |
3260 * entered string. | |
3261 * | |
3262 * It's somewhat ineffecient, because we strip all the HTML from the | |
3263 * "name" column of the buddy list (because the GtkTreeModel does not | |
3264 * contain the screen name in a non-markedup format). But the alternative | |
3265 * is to add an extra column to the GtkTreeModel. And this function is | |
3266 * used rarely, so it shouldn't matter TOO much. | |
3267 */ | |
3268 static gboolean | |
3269 _search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) | |
3270 { | |
10435 | 3271 gboolean result; |
10433 | 3272 gchar *enteredstring; |
10439 | 3273 gchar *withmarkup; |
10433 | 3274 gchar *nomarkup; |
11490 | 3275 gchar *normalized; |
10435 | 3276 |
3277 gtk_tree_model_get(model, iter, column, &withmarkup, -1); | |
10433 | 3278 |
11490 | 3279 enteredstring = g_utf8_casefold(gaim_normalize(NULL, key), -1); |
10433 | 3280 nomarkup = gaim_markup_strip_html(withmarkup); |
11490 | 3281 normalized = g_utf8_casefold(gaim_normalize(NULL, nomarkup), -1); |
10433 | 3282 |
3283 result = (g_strstr_len(normalized, strlen(normalized), enteredstring) == NULL); | |
3284 | |
10439 | 3285 g_free(withmarkup); |
10433 | 3286 g_free(enteredstring); |
3287 g_free(nomarkup); | |
11490 | 3288 g_free(normalized); |
10433 | 3289 |
3290 return result; | |
3291 } | |
3292 | |
12070 | 3293 static void account_enabled(GaimAccount *account, GaimGtkBuddyList *gtkblist) |
3294 { | |
3295 GtkWidget *box; | |
3296 | |
3297 if (!gtkblist) | |
3298 return; | |
3299 | |
3300 box = gtk_gaim_status_box_new_with_account(account); | |
3301 gtkblist->statusboxes = g_list_append(gtkblist->statusboxes, box); | |
3302 gtk_box_pack_start(GTK_BOX(gtkblist->statusboxbox), box, FALSE, TRUE, 0); | |
3303 gtk_widget_show(box); | |
3304 } | |
3305 | |
3306 static void account_disabled(GaimAccount *account, GaimGtkBuddyList *gtkblist) | |
3307 { | |
3308 GList *iter; | |
3309 | |
3310 if (!gtkblist) | |
3311 return; | |
3312 | |
3313 for (iter = gtkblist->statusboxes; iter; iter = iter->next) | |
3314 { | |
3315 GtkWidget *box = iter->data; | |
3316 GaimAccount *ac = NULL; | |
3317 | |
3318 g_object_get(G_OBJECT(box), "account", &ac, NULL); | |
3319 if (ac == account) | |
3320 { | |
3321 gtkblist->statusboxes = g_list_remove_link(gtkblist->statusboxes, iter); | |
3322 gtk_widget_destroy(box); | |
3323 break; | |
3324 } | |
3325 } | |
3326 } | |
3327 | |
12124
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3328 static gboolean |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3329 pane_position_cb(GtkPaned *paned, GParamSpec *param_spec, gpointer data) |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3330 { |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3331 if (!strcmp(g_param_spec_get_name(param_spec), "position")) { |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3332 gaim_prefs_set_int("/gaim/gtk/blist/pane", |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3333 gtk_paned_get_position(paned)); |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3334 } |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3335 |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3336 return FALSE; |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3337 } |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3338 |
7620 | 3339 static void gaim_gtk_blist_show(GaimBuddyList *list) |
5228 | 3340 { |
10087 | 3341 void *handle; |
5228 | 3342 GtkCellRenderer *rend; |
3343 GtkTreeViewColumn *column; | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3344 GtkWidget *menu; |
5228 | 3345 GtkWidget *sw; |
11983 | 3346 GtkWidget *vpane; |
5228 | 3347 GtkAccelGroup *accel_group; |
3348 GtkTreeSelection *selection; | |
9556 | 3349 GtkTargetEntry dte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
8089 | 3350 {"application/x-im-contact", 0, DRAG_BUDDY}, |
9495 | 3351 {"text/x-vcard", 0, DRAG_VCARD }, |
9525 | 3352 {"text/uri-list", 0, DRAG_URI}, |
3353 {"text/plain", 0, DRAG_TEXT}}; | |
9556 | 3354 GtkTargetEntry ste[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
3355 {"application/x-im-contact", 0, DRAG_BUDDY}, | |
3356 {"text/x-vcard", 0, DRAG_VCARD }}; | |
5228 | 3357 if (gtkblist && gtkblist->window) { |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3358 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3359 return; |
3360 } | |
3361 | |
3362 gtkblist = GAIM_GTK_BLIST(list); | |
3363 | |
3364 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3365 gtk_window_set_role(GTK_WINDOW(gtkblist->window), "buddy_list"); | |
9746 | 3366 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List")); |
5228 | 3367 |
3368 gtkblist->vbox = gtk_vbox_new(FALSE, 0); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3369 gtk_widget_show(gtkblist->vbox); |
5228 | 3370 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox); |
3371 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3372 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); |
5228 | 3373 g_signal_connect(G_OBJECT(gtkblist->window), "configure_event", G_CALLBACK(gtk_blist_configure_cb), NULL); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3374 g_signal_connect(G_OBJECT(gtkblist->window), "visibility_notify_event", G_CALLBACK(gtk_blist_visibility_cb), NULL); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3375 g_signal_connect(G_OBJECT(gtkblist->window), "window_state_event", G_CALLBACK(gtk_blist_window_state_cb), NULL); |
5228 | 3376 gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK); |
3377 | |
3378 /******************************* Menu bar *************************************/ | |
3379 accel_group = gtk_accel_group_new(); | |
3380 gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group); | |
3381 g_object_unref(accel_group); | |
5427 | 3382 gtkblist->ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", accel_group); |
9811 | 3383 gtk_item_factory_set_translate_func(gtkblist->ift, |
3384 item_factory_translate_func, | |
3385 NULL, NULL); | |
5427 | 3386 gtk_item_factory_create_items(gtkblist->ift, sizeof(blist_menu) / sizeof(*blist_menu), |
9811 | 3387 blist_menu, NULL); |
7620 | 3388 gaim_gtk_load_accels(); |
3389 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
3390 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3391 menu = gtk_item_factory_get_widget(gtkblist->ift, "<GaimMain>"); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3392 gtkblist->menutray = gaim_gtk_menu_tray_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3393 gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtkblist->menutray); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3394 gtk_widget_show(gtkblist->menutray); |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3395 gtk_widget_show(menu); |
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3396 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), menu, FALSE, FALSE, 0); |
5228 | 3397 |
5427 | 3398 gtkblist->bpmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Buddy Pounce")); |
8844 | 3399 protomenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Account Actions")); |
10352 | 3400 |
11983 | 3401 /****************************** GtkVPaned ************************************/ |
3402 vpane = gtk_vpaned_new(); | |
3403 gtk_widget_show(vpane); | |
3404 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), vpane, TRUE, TRUE, 0); | |
12124
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3405 gtk_paned_set_position(GTK_PANED(vpane), |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3406 gaim_prefs_get_int("/gaim/gtk/blist/pane")); |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3407 g_signal_connect(G_OBJECT(vpane), "notify", |
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
3408 G_CALLBACK(pane_position_cb), NULL); |
11983 | 3409 |
5228 | 3410 /****************************** GtkTreeView **********************************/ |
3411 sw = gtk_scrolled_window_new(NULL,NULL); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3412 gtk_widget_show(sw); |
5228 | 3413 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3414 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
3415 | |
7620 | 3416 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, |
11494 | 3417 GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, |
11257 | 3418 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); |
5228 | 3419 |
3420 gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel)); | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3421 gtk_widget_show(gtkblist->treeview); |
9176 | 3422 gtk_widget_set_name(gtkblist->treeview, "gaim_gtkblist_treeview"); |
5228 | 3423 |
3424 /* Set up selection stuff */ | |
3425 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
3426 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL); | |
3427 | |
3428 /* Set up dnd */ | |
7650 | 3429 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3430 GDK_BUTTON1_MASK, ste, 3, |
3431 GDK_ACTION_COPY); | |
7650 | 3432 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), |
9811 | 3433 dte, 5, |
3434 GDK_ACTION_COPY | GDK_ACTION_MOVE); | |
7636 | 3435 |
10544 | 3436 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); |
5228 | 3437 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL); |
11059
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3438 #ifdef _WIN32 |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3439 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-begin", G_CALLBACK(gaim_gtk_blist_drag_begin), NULL); |
c86d423df757
[gaim-migrate @ 13012]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11038
diff
changeset
|
3440 #endif |
10433 | 3441 |
10354 | 3442 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-motion", G_CALLBACK(gaim_gtk_blist_drag_motion_cb), NULL); |
5228 | 3443 |
3444 /* Tooltips */ | |
3445 g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL); | |
3446 g_signal_connect(G_OBJECT(gtkblist->treeview), "leave-notify-event", G_CALLBACK(gaim_gtk_blist_leave_cb), NULL); | |
3447 | |
3448 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
3449 | |
11016 | 3450 gtkblist->text_column = column = gtk_tree_view_column_new (); |
5228 | 3451 |
3452 rend = gtk_cell_renderer_pixbuf_new(); | |
9811 | 3453 gtk_tree_view_column_pack_start(column, rend, FALSE); |
3454 gtk_tree_view_column_set_attributes(column, rend, | |
3455 "pixbuf", STATUS_ICON_COLUMN, | |
3456 "visible", STATUS_ICON_VISIBLE_COLUMN, | |
3457 NULL); | |
5228 | 3458 g_object_set(rend, "xalign", 0.0, "ypad", 0, NULL); |
3459 | |
11016 | 3460 gtkblist->text_rend = rend = gtk_cell_renderer_text_new(); |
5228 | 3461 gtk_tree_view_column_pack_start (column, rend, TRUE); |
9811 | 3462 gtk_tree_view_column_set_attributes(column, rend, |
3463 "markup", NAME_COLUMN, | |
3464 NULL); | |
11016 | 3465 g_signal_connect(G_OBJECT(rend), "edited", G_CALLBACK(gtk_blist_renderer_edited_cb), NULL); |
5228 | 3466 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); |
10285 | 3467 #if GTK_CHECK_VERSION(2,6,0) |
3468 gtk_tree_view_column_set_expand (column, TRUE); | |
10501 | 3469 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
10285 | 3470 #endif |
5228 | 3471 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); |
3472 | |
3473 rend = gtk_cell_renderer_text_new(); | |
10351 | 3474 gtkblist->idle_column = gtk_tree_view_column_new_with_attributes("Idle", rend, "markup", IDLE_COLUMN, NULL); |
3475 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->idle_column); | |
5228 | 3476 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
3477 | |
3478 rend = gtk_cell_renderer_pixbuf_new(); | |
3479 gtkblist->buddy_icon_column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL); | |
3480 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); | |
3481 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->buddy_icon_column); | |
3482 | |
3483 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL); | |
3484 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-expanded", G_CALLBACK(gtk_blist_row_expanded_cb), NULL); | |
3485 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-collapsed", G_CALLBACK(gtk_blist_row_collapsed_cb), NULL); | |
3486 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL); | |
7620 | 3487 g_signal_connect(G_OBJECT(gtkblist->treeview), "key-press-event", G_CALLBACK(gtk_blist_key_press_cb), NULL); |
8143 | 3488 g_signal_connect(G_OBJECT(gtkblist->treeview), "popup-menu", G_CALLBACK(gaim_gtk_blist_popup_menu_cb), NULL); |
5228 | 3489 |
5419 | 3490 /* Enable CTRL+F searching */ |
3491 gtk_tree_view_set_search_column(GTK_TREE_VIEW(gtkblist->treeview), NAME_COLUMN); | |
10433 | 3492 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(gtkblist->treeview), _search_func, NULL, NULL); |
5419 | 3493 |
11983 | 3494 gtk_paned_pack1(GTK_PANED(vpane), sw, TRUE, FALSE); |
5228 | 3495 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); |
3496 gaim_gtk_blist_update_columns(); | |
3497 | |
11732 | 3498 /* TODO: functionize this */ |
3499 { | |
3500 GList *accounts, *l; | |
11983 | 3501 GtkWidget *sw2 = gtk_scrolled_window_new(NULL, NULL); |
3502 | |
11732 | 3503 /* Set up some per account status boxes */ |
3504 gtkblist->statusboxbox = gtk_vbox_new(FALSE, 0); | |
3505 gtkblist->statusboxes = NULL; | |
11983 | 3506 |
11732 | 3507 for (l = accounts = gaim_accounts_get_all_active(); l; l = l->next) { |
3508 GtkWidget *statusbox = gtk_gaim_status_box_new_with_account(l->data); | |
3509 gtkblist->statusboxes = g_list_append(gtkblist->statusboxes, statusbox); | |
3510 gtk_box_pack_start(GTK_BOX(gtkblist->statusboxbox), statusbox, FALSE, TRUE, 0); | |
3511 gtk_widget_show(statusbox); | |
3512 } | |
3513 g_list_free(accounts); | |
11983 | 3514 |
11732 | 3515 gtk_widget_show(gtkblist->statusboxbox); |
11983 | 3516 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), gtkblist->statusboxbox); |
3517 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
3518 gtk_widget_show(sw2); | |
3519 gtk_paned_pack2(GTK_PANED(vpane), sw2, FALSE, TRUE); | |
11732 | 3520 |
3521 gtkblist->statusbox = gtk_gaim_status_box_new(); | |
3522 | |
3523 gtk_widget_show(gtkblist->statusbox); | |
3524 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); | |
3525 | |
3526 } | |
10178
96a850ab30c8
[gaim-migrate @ 11293]
Christian Hammond <chipx86@chipx86.com>
parents:
10144
diff
changeset
|
3527 |
5228 | 3528 /* set the Show Offline Buddies option. must be done |
3529 * after the treeview or faceprint gets mad. -Robot101 | |
3530 */ | |
5427 | 3531 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Offline Buddies"))), |
7620 | 3532 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")); |
5427 | 3533 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Empty Groups"))), |
7620 | 3534 gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups")); |
10074 | 3535 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Tools/Mute Sounds"))), |
3536 gaim_prefs_get_bool("/gaim/gtk/sound/mute")); | |
11796 | 3537 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (gtkblist->ift, N_("/Buddies/Show Buddy Details"))), |
11920 | 3538 gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons")); |
10074 | 3539 if(!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none")) |
11494 | 3540 gtk_widget_set_sensitive(gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Mute Sounds")), FALSE); |
5228 | 3541 |
10353 | 3542 /* Update some dynamic things */ |
3543 update_menu_bar(gtkblist); | |
3544 gaim_gtk_blist_update_plugin_actions(); | |
11796 | 3545 gaim_gtk_blist_update_sort_methods(); |
10353 | 3546 |
5228 | 3547 /* OK... let's show this bad boy. */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3548 gaim_gtk_blist_refresh(list); |
12119
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3549 gaim_gtk_blist_restore_position(); |
312efb43c49a
[gaim-migrate @ 14419]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12117
diff
changeset
|
3550 gtk_widget_show_all(GTK_WIDGET(gtkblist->window)); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
3551 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
5228 | 3552 |
3553 /* start the refresh timer */ | |
10351 | 3554 gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, list); |
10353 | 3555 |
10087 | 3556 handle = gaim_gtk_blist_get_handle(); |
3557 | |
7620 | 3558 /* things that affect how buddies are displayed */ |
10087 | 3559 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
3560 _prefs_change_redo_list, NULL); | |
3561 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_empty_groups", | |
3562 _prefs_change_redo_list, NULL); | |
3563 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_offline_buddies", | |
3564 _prefs_change_redo_list, NULL); | |
7620 | 3565 |
3566 /* sorting */ | |
10087 | 3567 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/sort_type", |
3568 _prefs_change_sort_method, NULL); | |
7620 | 3569 |
3570 /* things that affect what columns are displayed */ | |
10087 | 3571 gaim_prefs_connect_callback(handle, "/gaim/gtk/blist/show_buddy_icons", |
3572 gaim_gtk_blist_update_columns, NULL); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3573 |
10074 | 3574 /* menus */ |
10087 | 3575 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/mute", |
3576 gaim_gtk_blist_mute_pref_cb, NULL); | |
3577 gaim_prefs_connect_callback(handle, "/gaim/gtk/sound/method", | |
3578 gaim_gtk_blist_sound_method_pref_cb, NULL); | |
10074 | 3579 |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
3580 /* Setup some gaim signal handlers. */ |
12070 | 3581 gaim_signal_connect(gaim_accounts_get_handle(), "account-disabled", |
3582 gtkblist, GAIM_CALLBACK(account_disabled), gtkblist); | |
3583 gaim_signal_connect(gaim_accounts_get_handle(), "account-enabled", | |
3584 gtkblist, GAIM_CALLBACK(account_enabled), gtkblist); | |
3585 | |
8937 | 3586 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
3587 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
3588 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | |
3589 gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); | |
8815 | 3590 |
8986 | 3591 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-load", |
3592 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3593 gaim_signal_connect(gaim_plugins_get_handle(), "plugin-unload", | |
3594 gtkblist, GAIM_CALLBACK(plugin_changed_cb), NULL); | |
3595 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3596 gaim_signal_connect(gaim_conversations_get_handle(), "conversation-updated", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3597 gtkblist, GAIM_CALLBACK(conversation_updated_cb), |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3598 gtkblist); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12115
diff
changeset
|
3599 |
8815 | 3600 /* emit our created signal */ |
10087 | 3601 gaim_signal_emit(handle, "gtkblist-created", list); |
5228 | 3602 } |
3603 | |
7620 | 3604 static void redo_buddy_list(GaimBuddyList *list, gboolean remove) |
5228 | 3605 { |
12112 | 3606 GaimBlistNode *node = list->root; |
3607 | |
3608 while (node) | |
3609 { | |
3610 if (!GAIM_BLIST_NODE_IS_GROUP(node) && remove) | |
3611 gaim_gtk_blist_hide_node(list, node); | |
3612 | |
3613 gaim_gtk_blist_update(list, node); | |
3614 node = gaim_blist_node_next(node, FALSE); | |
5228 | 3615 } |
3616 } | |
3617 | |
7620 | 3618 void gaim_gtk_blist_refresh(GaimBuddyList *list) |
5422 | 3619 { |
3620 redo_buddy_list(list, FALSE); | |
3621 } | |
3622 | |
5297 | 3623 void |
3624 gaim_gtk_blist_update_refresh_timeout() | |
3625 { | |
7620 | 3626 GaimBuddyList *blist; |
3627 GaimGtkBuddyList *gtkblist; | |
5297 | 3628 |
3629 blist = gaim_get_blist(); | |
3630 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
3631 | |
10351 | 3632 gtkblist->refresh_timer = g_timeout_add(30000,(GSourceFunc)gaim_gtk_blist_refresh_timer, blist); |
5297 | 3633 } |
3634 | |
5256 | 3635 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) { |
3636 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3637 GtkTreePath *path; | |
5228 | 3638 |
5263 | 3639 if (!gtknode) { |
3640 return FALSE; | |
3641 } | |
3642 | |
3643 if (!gtkblist) { | |
10006 | 3644 gaim_debug_error("gtkblist", "get_iter_from_node was called, but we don't seem to have a blist\n"); |
5263 | 3645 return FALSE; |
3646 } | |
3647 | |
3648 if (!gtknode->row) | |
5228 | 3649 return FALSE; |
11494 | 3650 |
5228 | 3651 |
5256 | 3652 if ((path = gtk_tree_row_reference_get_path(gtknode->row)) == NULL) |
5228 | 3653 return FALSE; |
11016 | 3654 |
5256 | 3655 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), iter, path)) { |
3656 gtk_tree_path_free(path); | |
3657 return FALSE; | |
3658 } | |
3659 gtk_tree_path_free(path); | |
3660 return TRUE; | |
5228 | 3661 } |
3662 | |
7620 | 3663 static void gaim_gtk_blist_remove(GaimBuddyList *list, GaimBlistNode *node) |
5228 | 3664 { |
11910 | 3665 struct _gaim_gtk_blist_node *gtknode = node->ui_data; |
3666 | |
10222 | 3667 gaim_request_close_with_handle(node); |
3668 | |
5260 | 3669 gaim_gtk_blist_hide_node(list, node); |
5228 | 3670 |
7620 | 3671 if(node->parent) |
3672 gaim_gtk_blist_update(list, node->parent); | |
3673 | |
10504 | 3674 /* There's something I don't understand here - Ethan */ |
3675 /* Ethan said that back in 2003, but this g_free has been left commented | |
3676 * out ever since. I can't find any reason at all why this is bad and | |
3677 * valgrind found several reasons why it's good. If this causes problems | |
3678 * comment it out again. Stu */ | |
10510 | 3679 /* Of course it still causes problems - this breaks dragging buddies into |
10515 | 3680 * contacts, the dragged buddy mysteriously 'disappears'. Stu. */ |
3681 /* I think it's fixed now. Stu. */ | |
11910 | 3682 |
11915 | 3683 if(gtknode) { |
3684 if(gtknode->recent_signonoff_timer > 0) | |
3685 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
3686 | |
3687 g_free(node->ui_data); | |
3688 node->ui_data = NULL; | |
3689 } | |
5228 | 3690 } |
3691 | |
3692 static gboolean do_selection_changed(GaimBlistNode *new_selection) | |
3693 { | |
5254 | 3694 GaimBlistNode *old_selection = NULL; |
5228 | 3695 |
5254 | 3696 /* test for gtkblist because crazy timeout means we can be called after the blist is gone */ |
3697 if (gtkblist && new_selection != gtkblist->selected_node) { | |
3698 old_selection = gtkblist->selected_node; | |
5228 | 3699 gtkblist->selected_node = new_selection; |
3700 if(new_selection) | |
3701 gaim_gtk_blist_update(NULL, new_selection); | |
3702 if(old_selection) | |
3703 gaim_gtk_blist_update(NULL, old_selection); | |
3704 } | |
3705 | |
3706 return FALSE; | |
3707 } | |
3708 | |
3709 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data) | |
3710 { | |
3711 GaimBlistNode *new_selection = NULL; | |
3712 GtkTreeIter iter; | |
3713 | |
3714 if(gtk_tree_selection_get_selected(selection, NULL, &iter)){ | |
3715 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
3716 NODE_COLUMN, &new_selection, -1); | |
3717 } | |
5254 | 3718 |
5228 | 3719 /* we set this up as a timeout, otherwise the blist flickers */ |
3720 g_timeout_add(0, (GSourceFunc)do_selection_changed, new_selection); | |
3721 } | |
3722 | |
8252 | 3723 static gboolean insert_node(GaimBuddyList *list, GaimBlistNode *node, GtkTreeIter *iter) |
7620 | 3724 { |
3725 GtkTreeIter parent_iter, cur, *curptr = NULL; | |
3726 struct _gaim_gtk_blist_node *gtknode = node->ui_data; | |
5256 | 3727 GtkTreePath *newpath; |
7620 | 3728 |
10515 | 3729 if(!iter) |
8252 | 3730 return FALSE; |
7620 | 3731 |
3732 if(node->parent && !get_iter_from_node(node->parent, &parent_iter)) | |
8252 | 3733 return FALSE; |
7620 | 3734 |
3735 if(get_iter_from_node(node, &cur)) | |
3736 curptr = &cur; | |
3737 | |
3738 if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_CHAT(node)) { | |
3739 *iter = current_sort_method->func(node, list, parent_iter, curptr); | |
3740 } else { | |
3741 *iter = sort_method_none(node, list, parent_iter, curptr); | |
5228 | 3742 } |
3743 | |
10515 | 3744 if(gtknode != NULL) { |
3745 gtk_tree_row_reference_free(gtknode->row); | |
3746 } else { | |
3747 gaim_gtk_blist_new_node(node); | |
3748 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; | |
3749 } | |
3750 | |
7620 | 3751 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), |
3752 iter); | |
3753 gtknode->row = | |
3754 gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), | |
3755 newpath); | |
11494 | 3756 |
5256 | 3757 gtk_tree_path_free(newpath); |
3758 | |
5228 | 3759 gtk_tree_store_set(gtkblist->treemodel, iter, |
3760 NODE_COLUMN, node, | |
3761 -1); | |
7620 | 3762 |
3763 if(node->parent) { | |
3764 GtkTreePath *expand = NULL; | |
3765 struct _gaim_gtk_blist_node *gtkparentnode = node->parent->ui_data; | |
3766 | |
3767 if(GAIM_BLIST_NODE_IS_GROUP(node->parent)) { | |
7693 | 3768 if(!gaim_blist_node_get_bool(node->parent, "collapsed")) |
7620 | 3769 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); |
3770 } else if(GAIM_BLIST_NODE_IS_CONTACT(node->parent) && | |
3771 gtkparentnode->contact_expanded) { | |
3772 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent_iter); | |
3773 } | |
3774 if(expand) { | |
7693 | 3775 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), expand, FALSE); |
7620 | 3776 gtk_tree_path_free(expand); |
3777 } | |
3778 } | |
3779 | |
8252 | 3780 return TRUE; |
5228 | 3781 } |
3782 | |
7620 | 3783 static void gaim_gtk_blist_update_group(GaimBuddyList *list, GaimBlistNode *node) |
3784 { | |
3785 GaimGroup *group; | |
8203 | 3786 int count; |
7620 | 3787 |
3788 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node)); | |
3789 | |
3790 group = (GaimGroup*)node; | |
3791 | |
8203 | 3792 if(gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) |
3793 count = gaim_blist_get_group_size(group, FALSE); | |
3794 else | |
3795 count = gaim_blist_get_group_online_count(group); | |
3796 if(gaim_prefs_get_bool("/gaim/gtk/blist/show_empty_groups") || count > 0) { | |
7620 | 3797 char *mark, *esc; |
3798 GtkTreeIter iter; | |
3799 | |
8252 | 3800 if(!insert_node(list, node, &iter)) |
3801 return; | |
7620 | 3802 |
3803 esc = g_markup_escape_text(group->name, -1); | |
8945 | 3804 mark = g_strdup_printf("<span weight='bold'>%s</span> (%d/%d)", |
3805 esc, gaim_blist_get_group_online_count(group), | |
3806 gaim_blist_get_group_size(group, FALSE)); | |
7620 | 3807 g_free(esc); |
3808 | |
3809 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
3810 STATUS_ICON_COLUMN, NULL, | |
3811 STATUS_ICON_VISIBLE_COLUMN, FALSE, | |
3812 NAME_COLUMN, mark, | |
3813 NODE_COLUMN, node, | |
3814 -1); | |
3815 g_free(mark); | |
3816 } else { | |
3817 gaim_gtk_blist_hide_node(list, node); | |
3818 } | |
3819 } | |
3820 | |
3821 static void buddy_node(GaimBuddy *buddy, GtkTreeIter *iter, GaimBlistNode *node) | |
5228 | 3822 { |
9944 | 3823 GaimPresence *presence; |
7620 | 3824 GdkPixbuf *status, *avatar; |
3825 char *mark; | |
11257 | 3826 char *idle = NULL; |
7620 | 3827 gboolean selected = (gtkblist->selected_node == node); |
3828 | |
9944 | 3829 presence = gaim_buddy_get_presence(buddy); |
3830 | |
7620 | 3831 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)buddy, |
3832 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") | |
3833 ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
3834 | |
10482 | 3835 avatar = gaim_gtk_blist_get_buddy_icon((GaimBlistNode *)buddy, TRUE, TRUE); |
7620 | 3836 mark = gaim_gtk_blist_get_name_markup(buddy, selected); |
3837 | |
9944 | 3838 if (gaim_presence_is_idle(presence)) |
3839 { | |
3840 time_t idle_secs = gaim_presence_get_idle_time(presence); | |
3841 | |
3842 if (idle_secs > 0) | |
3843 { | |
3844 time_t t; | |
3845 int ihrs, imin; | |
3846 time(&t); | |
3847 ihrs = (t - idle_secs) / 3600; | |
3848 imin = ((t - idle_secs) / 60) % 60; | |
3849 | |
3850 if (ihrs > 0) | |
3851 idle = g_strdup_printf("(%d:%02d)", ihrs, imin); | |
3852 else | |
3853 idle = g_strdup_printf("(%d)", imin); | |
3854 } | |
7620 | 3855 } |
3856 | |
10118 | 3857 if (gaim_presence_is_idle(presence)) |
9944 | 3858 { |
3859 if (idle && !selected) { | |
10118 | 3860 char *i2 = g_strdup_printf("<span color='%s'>%s</span>", |
3861 dim_grey(), idle); | |
7620 | 3862 g_free(idle); |
3863 idle = i2; | |
5228 | 3864 } |
7620 | 3865 } |
3866 | |
3867 gtk_tree_store_set(gtkblist->treemodel, iter, | |
3868 STATUS_ICON_COLUMN, status, | |
3869 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
3870 NAME_COLUMN, mark, | |
3871 IDLE_COLUMN, idle, | |
3872 BUDDY_ICON_COLUMN, avatar, | |
3873 -1); | |
3874 | |
3875 g_free(mark); | |
3876 if(idle) | |
3877 g_free(idle); | |
3878 if(status) | |
3879 g_object_unref(status); | |
3880 if(avatar) | |
3881 g_object_unref(avatar); | |
3882 } | |
3883 | |
11890 | 3884 |
7620 | 3885 static void gaim_gtk_blist_update_contact(GaimBuddyList *list, GaimBlistNode *node) |
3886 { | |
3887 GaimContact *contact; | |
3888 GaimBuddy *buddy; | |
3889 struct _gaim_gtk_blist_node *gtknode; | |
3890 | |
3891 g_return_if_fail(GAIM_BLIST_NODE_IS_CONTACT(node)); | |
3892 | |
3893 /* First things first, update the group */ | |
3894 gaim_gtk_blist_update_group(list, node->parent); | |
3895 | |
3896 contact = (GaimContact*)node; | |
3897 buddy = gaim_contact_get_priority_buddy(contact); | |
3898 | |
11890 | 3899 if (buddy_is_displayable(buddy)) |
10006 | 3900 { |
7620 | 3901 GtkTreeIter iter; |
3902 | |
8252 | 3903 if(!insert_node(list, node, &iter)) |
3904 return; | |
7620 | 3905 |
10515 | 3906 gtknode = (struct _gaim_gtk_blist_node *)node->ui_data; |
3907 | |
7620 | 3908 if(gtknode->contact_expanded) { |
3909 GdkPixbuf *status; | |
5228 | 3910 char *mark; |
3911 | |
7620 | 3912 status = gaim_gtk_blist_get_status_icon(node, |
3913 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? | |
3914 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
3915 | |
3916 mark = g_markup_escape_text(gaim_contact_get_alias(contact), -1); | |
3917 | |
5228 | 3918 gtk_tree_store_set(gtkblist->treemodel, &iter, |
7620 | 3919 STATUS_ICON_COLUMN, status, |
3920 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
5228 | 3921 NAME_COLUMN, mark, |
7620 | 3922 IDLE_COLUMN, NULL, |
3923 BUDDY_ICON_COLUMN, NULL, | |
5228 | 3924 -1); |
3925 g_free(mark); | |
7620 | 3926 if(status) |
3927 g_object_unref(status); | |
3928 } else { | |
3929 buddy_node(buddy, &iter, node); | |
5228 | 3930 } |
7620 | 3931 } else { |
3932 gaim_gtk_blist_hide_node(list, node); | |
5228 | 3933 } |
7620 | 3934 } |
3935 | |
3936 static void gaim_gtk_blist_update_buddy(GaimBuddyList *list, GaimBlistNode *node) | |
3937 { | |
3938 GaimContact *contact; | |
3939 GaimBuddy *buddy; | |
3940 struct _gaim_gtk_blist_node *gtkparentnode; | |
3941 | |
3942 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3943 | |
3944 buddy = (GaimBuddy*)node; | |
3945 contact = (GaimContact*)node->parent; | |
3946 | |
11624 | 3947 if (contact == NULL) |
3948 return; | |
3949 | |
7620 | 3950 /* First things first, update the contact */ |
3951 gaim_gtk_blist_update_contact(list, node->parent); | |
3952 | |
10918 | 3953 gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; |
3954 | |
10006 | 3955 if (gtkparentnode->contact_expanded && |
3956 (gaim_presence_is_online(buddy->presence) || | |
11910 | 3957 (0 /* XXX: if we just signed off, need to show logout.png */) || |
7620 | 3958 (gaim_account_is_connected(buddy->account) && |
10006 | 3959 gaim_prefs_get_bool("/gaim/gtk/blist/show_offline_buddies")) || |
3960 gaim_blist_node_get_bool(node->parent, "show_offline"))) | |
3961 { | |
7620 | 3962 GtkTreeIter iter; |
3963 | |
10006 | 3964 if (!insert_node(list, node, &iter)) |
8252 | 3965 return; |
3966 | |
7620 | 3967 buddy_node(buddy, &iter, node); |
3968 | |
3969 } else { | |
3970 gaim_gtk_blist_hide_node(list, node); | |
3971 } | |
3972 | |
3973 } | |
3974 | |
3975 static void gaim_gtk_blist_update_chat(GaimBuddyList *list, GaimBlistNode *node) | |
3976 { | |
3977 GaimChat *chat; | |
3978 | |
3979 g_return_if_fail(GAIM_BLIST_NODE_IS_CHAT(node)); | |
3980 | |
3981 /* First things first, update the group */ | |
3982 gaim_gtk_blist_update_group(list, node->parent); | |
3983 | |
3984 chat = (GaimChat*)node; | |
3985 | |
3986 if(gaim_account_is_connected(chat->account)) { | |
3987 GtkTreeIter iter; | |
5234 | 3988 GdkPixbuf *status; |
7620 | 3989 char *mark; |
3990 | |
8252 | 3991 if(!insert_node(list, node, &iter)) |
3992 return; | |
5234 | 3993 |
3994 status = gaim_gtk_blist_get_status_icon(node, | |
7620 | 3995 (gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons") ? |
3996 GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL)); | |
3997 | |
3998 mark = g_markup_escape_text(gaim_chat_get_name(chat), -1); | |
5234 | 3999 |
4000 gtk_tree_store_set(gtkblist->treemodel, &iter, | |
7620 | 4001 STATUS_ICON_COLUMN, status, |
4002 STATUS_ICON_VISIBLE_COLUMN, TRUE, | |
4003 NAME_COLUMN, mark, | |
4004 -1); | |
5228 | 4005 |
4006 g_free(mark); | |
7620 | 4007 if(status) |
5228 | 4008 g_object_unref(status); |
7620 | 4009 } else { |
5260 | 4010 gaim_gtk_blist_hide_node(list, node); |
5228 | 4011 } |
7620 | 4012 } |
4013 | |
4014 static void gaim_gtk_blist_update(GaimBuddyList *list, GaimBlistNode *node) | |
4015 { | |
4016 if(!gtkblist) | |
4017 return; | |
4018 | |
4019 switch(node->type) { | |
4020 case GAIM_BLIST_GROUP_NODE: | |
4021 gaim_gtk_blist_update_group(list, node); | |
4022 break; | |
4023 case GAIM_BLIST_CONTACT_NODE: | |
4024 gaim_gtk_blist_update_contact(list, node); | |
4025 break; | |
4026 case GAIM_BLIST_BUDDY_NODE: | |
4027 gaim_gtk_blist_update_buddy(list, node); | |
4028 break; | |
4029 case GAIM_BLIST_CHAT_NODE: | |
4030 gaim_gtk_blist_update_chat(list, node); | |
4031 break; | |
4032 case GAIM_BLIST_OTHER_NODE: | |
4033 return; | |
4034 } | |
5234 | 4035 |
5228 | 4036 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
4037 } | |
4038 | |
7620 | 4039 |
4040 static void gaim_gtk_blist_destroy(GaimBuddyList *list) | |
5228 | 4041 { |
4042 if (!gtkblist) | |
4043 return; | |
4044 | |
8937 | 4045 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", |
4046 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
4047 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", | |
4048 gtkblist, GAIM_CALLBACK(sign_on_off_cb)); | |
8259
4f9f68ab8770
[gaim-migrate @ 8982]
Christian Hammond <chipx86@chipx86.com>
parents:
8254
diff
changeset
|
4049 |
5228 | 4050 gtk_widget_destroy(gtkblist->window); |
7620 | 4051 |
8254 | 4052 gaim_gtk_blist_tooltip_destroy(); |
7620 | 4053 |
5228 | 4054 if (gtkblist->refresh_timer) |
4055 g_source_remove(gtkblist->refresh_timer); | |
4056 if (gtkblist->timeout) | |
4057 g_source_remove(gtkblist->timeout); | |
10354 | 4058 if (gtkblist->drag_timeout) |
4059 g_source_remove(gtkblist->drag_timeout); | |
5228 | 4060 |
4061 gtkblist->refresh_timer = 0; | |
4062 gtkblist->timeout = 0; | |
10354 | 4063 gtkblist->drag_timeout = 0; |
5228 | 4064 gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL; |
4065 gtkblist->treemodel = NULL; | |
4066 gtkblist->idle_column = NULL; | |
11257 | 4067 gtkblist->buddy_icon_column = NULL; |
5427 | 4068 g_object_unref(G_OBJECT(gtkblist->ift)); |
5228 | 4069 protomenu = NULL; |
4070 gtkblist = NULL; | |
7620 | 4071 |
10087 | 4072 gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); |
5228 | 4073 } |
4074 | |
7620 | 4075 static void gaim_gtk_blist_set_visible(GaimBuddyList *list, gboolean show) |
5228 | 4076 { |
4077 if (!(gtkblist && gtkblist->window)) | |
4078 return; | |
10325 | 4079 |
5228 | 4080 if (show) { |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4081 if(!GAIM_WINDOW_ICONIFIED(gtkblist->window) && !GTK_WIDGET_VISIBLE(gtkblist->window)) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4082 gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-unhiding", gtkblist); |
5228 | 4083 gaim_gtk_blist_restore_position(); |
4084 gtk_window_present(GTK_WINDOW(gtkblist->window)); | |
4085 } else { | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4086 if(visibility_manager_count) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4087 gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-hiding", gtkblist); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4088 gtk_widget_hide(gtkblist->window); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4089 } else { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4090 gtk_window_iconify(GTK_WINDOW(gtkblist->window)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4091 } |
5228 | 4092 } |
4093 } | |
4094 | |
7620 | 4095 static GList * |
4096 groups_tree(void) | |
4097 { | |
4098 GList *tmp = NULL; | |
4099 char *tmp2; | |
4100 GaimGroup *g; | |
4101 GaimBlistNode *gnode; | |
4102 | |
4103 if (gaim_get_blist()->root == NULL) | |
4104 { | |
4105 tmp2 = g_strdup(_("Buddies")); | |
4106 tmp = g_list_append(tmp, tmp2); | |
4107 } | |
4108 else | |
4109 { | |
4110 for (gnode = gaim_get_blist()->root; | |
4111 gnode != NULL; | |
4112 gnode = gnode->next) | |
4113 { | |
4114 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4115 { | |
4116 g = (GaimGroup *)gnode; | |
4117 tmp2 = g->name; | |
4118 tmp = g_list_append(tmp, tmp2); | |
4119 } | |
4120 } | |
4121 } | |
4122 | |
4123 return tmp; | |
4124 } | |
4125 | |
4126 static void | |
4127 add_buddy_select_account_cb(GObject *w, GaimAccount *account, | |
4128 GaimGtkAddBuddyData *data) | |
4129 { | |
4130 /* Save our account */ | |
4131 data->account = account; | |
4132 } | |
4133 | |
4134 static void | |
4135 destroy_add_buddy_dialog_cb(GtkWidget *win, GaimGtkAddBuddyData *data) | |
4136 { | |
4137 g_free(data); | |
4138 } | |
4139 | |
4140 static void | |
4141 add_buddy_cb(GtkWidget *w, int resp, GaimGtkAddBuddyData *data) | |
4142 { | |
4143 const char *grp, *who, *whoalias; | |
4144 GaimConversation *c; | |
4145 GaimBuddy *b; | |
4146 GaimGroup *g; | |
4147 | |
4148 if (resp == GTK_RESPONSE_OK) | |
4149 { | |
4150 who = gtk_entry_get_text(GTK_ENTRY(data->entry)); | |
4151 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry)); | |
4152 whoalias = gtk_entry_get_text(GTK_ENTRY(data->entry_for_alias)); | |
9658 | 4153 if (*whoalias == '\0') |
4154 whoalias = NULL; | |
7620 | 4155 |
4156 if ((g = gaim_find_group(grp)) == NULL) | |
4157 { | |
4158 g = gaim_group_new(grp); | |
4159 gaim_blist_add_group(g, NULL); | |
4160 } | |
4161 | |
4162 b = gaim_buddy_new(data->account, who, whoalias); | |
4163 gaim_blist_add_buddy(b, NULL, g, NULL); | |
11643 | 4164 gaim_account_add_buddy(data->account, b); |
7620 | 4165 |
7887 | 4166 /* |
9285 | 4167 * XXX |
11643 | 4168 * It really seems like it would be better if the call to |
4169 * gaim_account_add_buddy() and gaim_conversation_update() were done in | |
4170 * blist.c, possibly in the gaim_blist_add_buddy() function. Maybe | |
4171 * gaim_account_add_buddy() should be renamed to | |
4172 * gaim_blist_add_new_buddy() or something, and have it call | |
7887 | 4173 * gaim_blist_add_buddy() after it creates it. --Mark |
9285 | 4174 * |
4175 * No that's not good. blist.c should only deal with adding nodes to the | |
11643 | 4176 * local list. We need a new, non-gtk file that calls both |
4177 * gaim_account_add_buddy and gaim_blist_add_buddy(). | |
4178 * Or something. --Mark | |
7887 | 4179 */ |
4180 | |
11338 | 4181 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, data->account); |
7620 | 4182 if (c != NULL) { |
4183 gaim_buddy_icon_update(gaim_conv_im_get_icon(GAIM_CONV_IM(c))); | |
4184 gaim_conversation_update(c, GAIM_CONV_UPDATE_ADD); | |
4185 } | |
4186 } | |
4187 | |
4188 gtk_widget_destroy(data->window); | |
4189 } | |
4190 | |
4191 static void | |
4192 gaim_gtk_blist_request_add_buddy(GaimAccount *account, const char *username, | |
4193 const char *group, const char *alias) | |
4194 { | |
4195 GtkWidget *table; | |
4196 GtkWidget *label; | |
4197 GtkWidget *hbox; | |
4198 GtkWidget *vbox; | |
4199 GtkWidget *img; | |
4200 GaimGtkBuddyList *gtkblist; | |
4201 GaimGtkAddBuddyData *data = g_new0(GaimGtkAddBuddyData, 1); | |
4202 | |
4203 data->account = | |
4204 (account != NULL | |
4205 ? account | |
4206 : gaim_connection_get_account(gaim_connections_get_all()->data)); | |
4207 | |
4208 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4209 GTK_ICON_SIZE_DIALOG); | |
4210 | |
4211 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); | |
4212 | |
4213 data->window = gtk_dialog_new_with_buttons(_("Add Buddy"), | |
8975 | 4214 NULL, GTK_DIALOG_NO_SEPARATOR, |
7620 | 4215 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
4216 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4217 NULL); | |
4218 | |
4219 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4220 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
7620 | 4221 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4222 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4223 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4224 gtk_window_set_role(GTK_WINDOW(data->window), "add_buddy"); |
8975 | 4225 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4226 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4227 |
11243 | 4228 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4229 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4230 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4231 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4232 | |
4233 vbox = gtk_vbox_new(FALSE, 0); | |
4234 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4235 | |
4236 label = gtk_label_new( | |
4237 _("Please enter the screen name of the person you would like " | |
4238 "to add to your buddy list. You may optionally enter an alias, " | |
4239 "or nickname, for the buddy. The alias will be displayed in " | |
4240 "place of the screen name whenever possible.\n")); | |
4241 | |
4242 gtk_widget_set_size_request(GTK_WIDGET(label), 400, -1); | |
4243 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4244 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4245 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4246 | |
11243 | 4247 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7620 | 4248 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
4249 | |
4250 g_signal_connect(G_OBJECT(data->window), "destroy", | |
4251 G_CALLBACK(destroy_add_buddy_dialog_cb), data); | |
4252 | |
4253 table = gtk_table_new(4, 2, FALSE); | |
4254 gtk_table_set_row_spacings(GTK_TABLE(table), 5); | |
4255 gtk_table_set_col_spacings(GTK_TABLE(table), 5); | |
4256 gtk_container_set_border_width(GTK_CONTAINER(table), 0); | |
4257 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
4258 | |
4259 label = gtk_label_new(_("Screen Name:")); | |
4260 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4261 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
4262 | |
4263 data->entry = gtk_entry_new(); | |
4264 gtk_table_attach_defaults(GTK_TABLE(table), data->entry, 1, 2, 0, 1); | |
4265 gtk_widget_grab_focus(data->entry); | |
4266 | |
4267 if (username != NULL) | |
4268 gtk_entry_set_text(GTK_ENTRY(data->entry), username); | |
4269 | |
4270 gtk_entry_set_activates_default (GTK_ENTRY(data->entry), TRUE); | |
8137 | 4271 gaim_set_accessible_label (data->entry, label); |
7620 | 4272 |
4273 label = gtk_label_new(_("Alias:")); | |
4274 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4275 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
4276 | |
4277 data->entry_for_alias = gtk_entry_new(); | |
4278 gtk_table_attach_defaults(GTK_TABLE(table), | |
4279 data->entry_for_alias, 1, 2, 1, 2); | |
4280 | |
4281 if (alias != NULL) | |
4282 gtk_entry_set_text(GTK_ENTRY(data->entry_for_alias), alias); | |
4283 | |
10734
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4284 if (username != NULL) |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4285 gtk_widget_grab_focus(GTK_WIDGET(data->entry_for_alias)); |
8b2c81d9b271
[gaim-migrate @ 12336]
Luke Schierer <lschiere@pidgin.im>
parents:
10694
diff
changeset
|
4286 |
7620 | 4287 gtk_entry_set_activates_default (GTK_ENTRY(data->entry_for_alias), TRUE); |
8137 | 4288 gaim_set_accessible_label (data->entry_for_alias, label); |
7620 | 4289 |
4290 label = gtk_label_new(_("Group:")); | |
4291 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4292 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
4293 | |
4294 data->combo = gtk_combo_new(); | |
4295 gtk_combo_set_popdown_strings(GTK_COMBO(data->combo), groups_tree()); | |
4296 gtk_table_attach_defaults(GTK_TABLE(table), data->combo, 1, 2, 2, 3); | |
8137 | 4297 gaim_set_accessible_label (data->combo, label); |
7620 | 4298 |
4299 /* Set up stuff for the account box */ | |
4300 label = gtk_label_new(_("Account:")); | |
4301 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4302 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
4303 | |
4304 data->account_box = gaim_gtk_account_option_menu_new(account, FALSE, | |
4305 G_CALLBACK(add_buddy_select_account_cb), NULL, data); | |
4306 | |
4307 gtk_table_attach_defaults(GTK_TABLE(table), data->account_box, 1, 2, 3, 4); | |
8137 | 4308 gaim_set_accessible_label (data->account_box, label); |
7620 | 4309 /* End of account box */ |
4310 | |
4311 g_signal_connect(G_OBJECT(data->window), "response", | |
4312 G_CALLBACK(add_buddy_cb), data); | |
4313 | |
4314 gtk_widget_show_all(data->window); | |
4315 | |
4316 if (group != NULL) | |
4317 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->combo)->entry), group); | |
4318 } | |
4319 | |
4320 static void | |
4321 add_chat_cb(GtkWidget *w, GaimGtkAddChatData *data) | |
4322 { | |
4323 GHashTable *components; | |
4324 GList *tmp; | |
4325 GaimChat *chat; | |
4326 GaimGroup *group; | |
4327 const char *group_name; | |
9918 | 4328 char *chat_name = NULL; |
4329 GaimConversation *conv = NULL; | |
10475 | 4330 const char *value; |
7620 | 4331 |
4332 components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
4333 g_free, g_free); | |
4334 | |
4335 for (tmp = data->entries; tmp; tmp = tmp->next) | |
4336 { | |
4337 if (g_object_get_data(tmp->data, "is_spin")) | |
4338 { | |
4339 g_hash_table_replace(components, | |
4340 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4341 g_strdup_printf("%d", | |
4342 gtk_spin_button_get_value_as_int(tmp->data))); | |
4343 } | |
4344 else | |
4345 { | |
10475 | 4346 value = gtk_entry_get_text(tmp->data); |
4347 if (*value != '\0') | |
4348 g_hash_table_replace(components, | |
4349 g_strdup(g_object_get_data(tmp->data, "identifier")), | |
4350 g_strdup(value)); | |
7620 | 4351 } |
4352 } | |
4353 | |
4354 chat = gaim_chat_new(data->account, | |
4355 gtk_entry_get_text(GTK_ENTRY(data->alias_entry)), | |
4356 components); | |
4357 | |
4358 group_name = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry)); | |
4359 | |
4360 if ((group = gaim_find_group(group_name)) == NULL) | |
4361 { | |
4362 group = gaim_group_new(group_name); | |
4363 gaim_blist_add_group(group, NULL); | |
4364 } | |
4365 | |
4366 if (chat != NULL) | |
4367 { | |
4368 gaim_blist_add_chat(chat, group, NULL); | |
9918 | 4369 |
4370 if (GAIM_PLUGIN_PROTOCOL_INFO(data->account->gc->prpl)->get_chat_name != NULL) | |
4371 chat_name = GAIM_PLUGIN_PROTOCOL_INFO( | |
4372 data->account->gc->prpl)->get_chat_name(chat->components); | |
10246 | 4373 |
9918 | 4374 if (chat_name != NULL) { |
11338 | 4375 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, |
10246 | 4376 chat_name, |
4377 data->account); | |
9918 | 4378 g_free(chat_name); |
4379 } | |
4380 | |
4381 if (conv != NULL) | |
4382 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ADD); | |
7620 | 4383 } |
4384 | |
4385 gtk_widget_destroy(data->window); | |
9812 | 4386 g_free(data->default_chat_name); |
7620 | 4387 g_list_free(data->entries); |
4388 g_free(data); | |
4389 } | |
4390 | |
4391 static void | |
4392 add_chat_resp_cb(GtkWidget *w, int resp, GaimGtkAddChatData *data) | |
4393 { | |
4394 if (resp == GTK_RESPONSE_OK) | |
4395 { | |
4396 add_chat_cb(NULL, data); | |
4397 } | |
4398 else | |
4399 { | |
4400 gtk_widget_destroy(data->window); | |
9812 | 4401 g_free(data->default_chat_name); |
7620 | 4402 g_list_free(data->entries); |
4403 g_free(data); | |
4404 } | |
4405 } | |
4406 | |
10475 | 4407 /* |
4408 * Check the values of all the text entry boxes. If any required input | |
4409 * strings are empty then don't allow the user to click on "OK." | |
4410 */ | |
4411 static void | |
4412 addchat_set_sensitive_if_input_cb(GtkWidget *entry, gpointer user_data) | |
4413 { | |
4414 GaimGtkAddChatData *data; | |
4415 GList *tmp; | |
4416 const char *text; | |
4417 gboolean required; | |
4418 gboolean sensitive = TRUE; | |
4419 | |
4420 data = user_data; | |
4421 | |
4422 for (tmp = data->entries; tmp != NULL; tmp = tmp->next) | |
4423 { | |
4424 if (!g_object_get_data(tmp->data, "is_spin")) | |
4425 { | |
4426 required = GPOINTER_TO_INT(g_object_get_data(tmp->data, "required")); | |
4427 text = gtk_entry_get_text(tmp->data); | |
4428 if (required && (*text == '\0')) | |
4429 sensitive = FALSE; | |
4430 } | |
4431 } | |
4432 | |
4433 gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_OK, sensitive); | |
4434 } | |
4435 | |
7620 | 4436 static void |
4437 rebuild_addchat_entries(GaimGtkAddChatData *data) | |
4438 { | |
4439 GaimConnection *gc; | |
9959 | 4440 GList *list = NULL, *tmp = NULL; |
9754 | 4441 GHashTable *defaults = NULL; |
7620 | 4442 struct proto_chat_entry *pce; |
4443 gboolean focus = TRUE; | |
4444 | |
10127 | 4445 g_return_if_fail(data->account != NULL); |
4446 | |
7620 | 4447 gc = gaim_account_get_connection(data->account); |
4448 | |
4449 while (GTK_BOX(data->entries_box)->children) | |
4450 { | |
4451 gtk_container_remove(GTK_CONTAINER(data->entries_box), | |
10475 | 4452 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
7620 | 4453 } |
4454 | |
4455 if (data->entries != NULL) | |
4456 g_list_free(data->entries); | |
4457 | |
4458 data->entries = NULL; | |
4459 | |
9959 | 4460 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
4461 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | |
7620 | 4462 |
9754 | 4463 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
10475 | 4464 defaults = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, data->default_chat_name); |
9754 | 4465 |
7620 | 4466 for (tmp = list; tmp; tmp = tmp->next) |
4467 { | |
4468 GtkWidget *label; | |
4469 GtkWidget *rowbox; | |
10475 | 4470 GtkWidget *input; |
7620 | 4471 |
4472 pce = tmp->data; | |
4473 | |
4474 rowbox = gtk_hbox_new(FALSE, 5); | |
4475 gtk_box_pack_start(GTK_BOX(data->entries_box), rowbox, FALSE, FALSE, 0); | |
4476 | |
7889 | 4477 label = gtk_label_new_with_mnemonic(pce->label); |
7620 | 4478 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4479 gtk_size_group_add_widget(data->sg, label); | |
4480 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4481 | |
4482 if (pce->is_int) | |
4483 { | |
4484 GtkObject *adjust; | |
4485 adjust = gtk_adjustment_new(pce->min, pce->min, pce->max, | |
4486 1, 10, 10); | |
10475 | 4487 input = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1, 0); |
4488 gtk_widget_set_size_request(input, 50, -1); | |
4489 gtk_box_pack_end(GTK_BOX(rowbox), input, FALSE, FALSE, 0); | |
7620 | 4490 } |
4491 else | |
4492 { | |
9754 | 4493 char *value; |
10475 | 4494 input = gtk_entry_new(); |
4495 gtk_entry_set_activates_default(GTK_ENTRY(input), TRUE); | |
9754 | 4496 value = g_hash_table_lookup(defaults, pce->identifier); |
4497 if (value != NULL) | |
10475 | 4498 gtk_entry_set_text(GTK_ENTRY(input), value); |
7620 | 4499 if (pce->secret) |
11986 | 4500 { |
10475 | 4501 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE); |
11986 | 4502 gtk_entry_set_invisible_char(GTK_ENTRY(input), GAIM_INVISIBLE_CHAR); |
4503 } | |
10475 | 4504 gtk_box_pack_end(GTK_BOX(rowbox), input, TRUE, TRUE, 0); |
4505 g_signal_connect(G_OBJECT(input), "changed", | |
4506 G_CALLBACK(addchat_set_sensitive_if_input_cb), data); | |
7620 | 4507 } |
4508 | |
10475 | 4509 /* Do the following for any type of input widget */ |
4510 if (focus) | |
4511 { | |
4512 gtk_widget_grab_focus(input); | |
4513 focus = FALSE; | |
4514 } | |
4515 gtk_label_set_mnemonic_widget(GTK_LABEL(label), input); | |
4516 gaim_set_accessible_label(input, label); | |
4517 g_object_set_data(G_OBJECT(input), "identifier", pce->identifier); | |
4518 g_object_set_data(G_OBJECT(input), "is_spin", GINT_TO_POINTER(pce->is_int)); | |
4519 g_object_set_data(G_OBJECT(input), "required", GINT_TO_POINTER(pce->required)); | |
4520 data->entries = g_list_append(data->entries, input); | |
4521 | |
7620 | 4522 g_free(pce); |
4523 } | |
4524 | |
4525 g_list_free(list); | |
9754 | 4526 g_hash_table_destroy(defaults); |
7620 | 4527 |
10475 | 4528 /* Set whether the "OK" button should be clickable initially */ |
4529 addchat_set_sensitive_if_input_cb(NULL, data); | |
4530 | |
7620 | 4531 gtk_widget_show_all(data->entries_box); |
4532 } | |
4533 | |
4534 static void | |
10475 | 4535 addchat_select_account_cb(GObject *w, GaimAccount *account, |
7620 | 4536 GaimGtkAddChatData *data) |
4537 { | |
9460 | 4538 if (strcmp(gaim_account_get_protocol_id(data->account), |
4539 gaim_account_get_protocol_id(account)) == 0) | |
7620 | 4540 { |
4541 data->account = account; | |
4542 } | |
4543 else | |
4544 { | |
4545 data->account = account; | |
4546 rebuild_addchat_entries(data); | |
4547 } | |
4548 } | |
4549 | |
4550 void | |
7859 | 4551 gaim_gtk_blist_request_add_chat(GaimAccount *account, GaimGroup *group, |
9754 | 4552 const char *alias, const char *name) |
7620 | 4553 { |
4554 GaimGtkAddChatData *data; | |
8975 | 4555 GaimGtkBuddyList *gtkblist; |
4556 GList *l; | |
4557 GaimConnection *gc; | |
7620 | 4558 GtkWidget *label; |
4559 GtkWidget *rowbox; | |
4560 GtkWidget *hbox; | |
4561 GtkWidget *vbox; | |
4562 GtkWidget *img; | |
4563 | |
9812 | 4564 if (account != NULL) { |
4565 gc = gaim_account_get_connection(account); | |
4566 | |
4567 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat == NULL) { | |
4568 gaim_notify_error(gc, NULL, _("This protocol does not support chat rooms."), NULL); | |
4569 return; | |
4570 } | |
4571 } else { | |
4572 /* Find an account with chat capabilities */ | |
4573 for (l = gaim_connections_get_all(); l != NULL; l = l->next) { | |
4574 gc = (GaimConnection *)l->data; | |
4575 | |
4576 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat != NULL) { | |
4577 account = gaim_connection_get_account(gc); | |
4578 break; | |
4579 } | |
4580 } | |
4581 | |
4582 if (account == NULL) { | |
4583 gaim_notify_error(NULL, NULL, | |
4584 _("You are not currently signed on with any " | |
4585 "protocols that have the ability to chat."), NULL); | |
4586 return; | |
4587 } | |
4588 } | |
4589 | |
7620 | 4590 data = g_new0(GaimGtkAddChatData, 1); |
9812 | 4591 data->account = account; |
4592 data->default_chat_name = g_strdup(name); | |
7620 | 4593 |
4594 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
4595 GTK_ICON_SIZE_DIALOG); | |
4596 | |
8975 | 4597 gtkblist = GAIM_GTK_BLIST(gaim_get_blist()); |
4598 | |
7620 | 4599 data->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4600 | |
8975 | 4601 data->window = gtk_dialog_new_with_buttons(_("Add Chat"), |
4602 NULL, GTK_DIALOG_NO_SEPARATOR, | |
4603 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
4604 GTK_STOCK_ADD, GTK_RESPONSE_OK, | |
4605 NULL); | |
4606 | |
4607 gtk_dialog_set_default_response(GTK_DIALOG(data->window), GTK_RESPONSE_OK); | |
11243 | 4608 gtk_container_set_border_width(GTK_CONTAINER(data->window), GAIM_HIG_BOX_SPACE); |
8975 | 4609 gtk_window_set_resizable(GTK_WINDOW(data->window), FALSE); |
11243 | 4610 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BORDER); |
4611 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), GAIM_HIG_BOX_SPACE); | |
7620 | 4612 gtk_window_set_role(GTK_WINDOW(data->window), "add_chat"); |
8975 | 4613 gtk_window_set_type_hint(GTK_WINDOW(data->window), |
9811 | 4614 GDK_WINDOW_TYPE_HINT_DIALOG); |
7620 | 4615 |
11243 | 4616 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
7620 | 4617 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(data->window)->vbox), hbox); |
4618 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
4619 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
4620 | |
4621 vbox = gtk_vbox_new(FALSE, 5); | |
4622 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
4623 | |
4624 label = gtk_label_new( | |
4625 _("Please enter an alias, and the appropriate information " | |
4626 "about the chat you would like to add to your buddy list.\n")); | |
4627 gtk_widget_set_size_request(label, 400, -1); | |
4628 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
4629 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
4630 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
4631 | |
4632 rowbox = gtk_hbox_new(FALSE, 5); | |
4633 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4634 | |
4635 label = gtk_label_new(_("Account:")); | |
4636 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4637 gtk_size_group_add_widget(data->sg, label); | |
4638 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4639 | |
4640 data->account_menu = gaim_gtk_account_option_menu_new(account, FALSE, | |
10475 | 4641 G_CALLBACK(addchat_select_account_cb), |
9987 | 4642 chat_account_filter_func, data); |
7620 | 4643 gtk_box_pack_start(GTK_BOX(rowbox), data->account_menu, TRUE, TRUE, 0); |
8137 | 4644 gaim_set_accessible_label (data->account_menu, label); |
7620 | 4645 |
4646 data->entries_box = gtk_vbox_new(FALSE, 5); | |
9811 | 4647 gtk_container_set_border_width(GTK_CONTAINER(data->entries_box), 0); |
7620 | 4648 gtk_box_pack_start(GTK_BOX(vbox), data->entries_box, TRUE, TRUE, 0); |
4649 | |
4650 rebuild_addchat_entries(data); | |
4651 | |
4652 rowbox = gtk_hbox_new(FALSE, 5); | |
4653 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4654 | |
4655 label = gtk_label_new(_("Alias:")); | |
4656 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
4657 gtk_size_group_add_widget(data->sg, label); | |
4658 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4659 | |
4660 data->alias_entry = gtk_entry_new(); | |
7859 | 4661 if (alias != NULL) |
4662 gtk_entry_set_text(GTK_ENTRY(data->alias_entry), alias); | |
7620 | 4663 gtk_box_pack_end(GTK_BOX(rowbox), data->alias_entry, TRUE, TRUE, 0); |
10311 | 4664 gtk_entry_set_activates_default(GTK_ENTRY(data->alias_entry), TRUE); |
8137 | 4665 gaim_set_accessible_label (data->alias_entry, label); |
7620 | 4666 |
4667 rowbox = gtk_hbox_new(FALSE, 5); | |
4668 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); | |
4669 | |
9811 | 4670 label = gtk_label_new(_("Group:")); |
7620 | 4671 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
4672 gtk_size_group_add_widget(data->sg, label); | |
4673 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 0); | |
4674 | |
9811 | 4675 data->group_combo = gtk_combo_new(); |
4676 gtk_combo_set_popdown_strings(GTK_COMBO(data->group_combo), groups_tree()); | |
7620 | 4677 gtk_box_pack_end(GTK_BOX(rowbox), data->group_combo, TRUE, TRUE, 0); |
4678 | |
4679 if (group) | |
4680 { | |
4681 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(data->group_combo)->entry), | |
4682 group->name); | |
4683 } | |
8137 | 4684 gaim_set_accessible_label (data->group_combo, label); |
7620 | 4685 |
4686 g_signal_connect(G_OBJECT(data->window), "response", | |
4687 G_CALLBACK(add_chat_resp_cb), data); | |
4688 | |
4689 gtk_widget_show_all(data->window); | |
4690 } | |
4691 | |
4692 static void | |
4693 add_group_cb(GaimConnection *gc, const char *group_name) | |
4694 { | |
9285 | 4695 GaimGroup *group; |
4696 | |
4697 group = gaim_group_new(group_name); | |
4698 gaim_blist_add_group(group, NULL); | |
7620 | 4699 } |
4700 | |
4701 void | |
4702 gaim_gtk_blist_request_add_group(void) | |
4703 { | |
7853 | 4704 gaim_request_input(NULL, _("Add Group"), NULL, |
7620 | 4705 _("Please enter the name of the group to be added."), |
8697 | 4706 NULL, FALSE, FALSE, NULL, |
7620 | 4707 _("Add"), G_CALLBACK(add_group_cb), |
4708 _("Cancel"), NULL, NULL); | |
4709 } | |
4710 | |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4711 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4712 gaim_gtk_blist_toggle_visibility() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4713 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4714 if (gtkblist && gtkblist->window) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4715 if (GTK_WIDGET_VISIBLE(gtkblist->window)) { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4716 gaim_blist_set_visible(GAIM_WINDOW_ICONIFIED(gtkblist->window) || gtk_blist_obscured); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4717 } else { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4718 gaim_blist_set_visible(TRUE); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4719 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4720 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4721 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4722 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4723 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4724 gaim_gtk_blist_visibility_manager_add() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4725 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4726 visibility_manager_count++; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4727 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4728 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4729 void |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4730 gaim_gtk_blist_visibility_manager_remove() |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4731 { |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4732 if (visibility_manager_count) |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4733 visibility_manager_count--; |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4734 if (!visibility_manager_count) |
12115
e9790eb93216
[gaim-migrate @ 14415]
Luke Schierer <lschiere@pidgin.im>
parents:
12113
diff
changeset
|
4735 gaim_blist_set_visible(gaim_prefs_get_bool("/gaim/gtk/blist/list_visible")); |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4736 } |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4737 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4738 |
7620 | 4739 static GaimBlistUiOps blist_ui_ops = |
5228 | 4740 { |
4741 gaim_gtk_blist_new_list, | |
5256 | 4742 gaim_gtk_blist_new_node, |
5228 | 4743 gaim_gtk_blist_show, |
4744 gaim_gtk_blist_update, | |
4745 gaim_gtk_blist_remove, | |
4746 gaim_gtk_blist_destroy, | |
7620 | 4747 gaim_gtk_blist_set_visible, |
4748 gaim_gtk_blist_request_add_buddy, | |
4749 gaim_gtk_blist_request_add_chat, | |
10012 | 4750 gaim_gtk_blist_request_add_group |
5228 | 4751 }; |
4752 | |
4753 | |
7620 | 4754 GaimBlistUiOps * |
4755 gaim_gtk_blist_get_ui_ops(void) | |
5228 | 4756 { |
4757 return &blist_ui_ops; | |
4758 } | |
4759 | |
10643 | 4760 GaimGtkBuddyList *gaim_gtk_blist_get_default_gtk_blist() |
4761 { | |
4762 return gtkblist; | |
4763 } | |
4764 | |
7620 | 4765 static void account_signon_cb(GaimConnection *gc, gpointer z) |
4766 { | |
4767 GaimAccount *account = gaim_connection_get_account(gc); | |
4768 GaimBlistNode *gnode, *cnode; | |
4769 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) | |
4770 { | |
4771 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4772 continue; | |
4773 for(cnode = gnode->child; cnode; cnode = cnode->next) | |
4774 { | |
4775 GaimChat *chat; | |
4776 | |
4777 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
4778 continue; | |
4779 | |
4780 chat = (GaimChat *)cnode; | |
4781 | |
4782 if(chat->account != account) | |
4783 continue; | |
4784 | |
8197 | 4785 if(gaim_blist_node_get_bool((GaimBlistNode*)chat, "gtk-autojoin") || |
8198 | 4786 (gaim_blist_node_get_string((GaimBlistNode*)chat, |
4787 "gtk-autojoin") != NULL)) | |
7620 | 4788 serv_join_chat(gc, chat->components); |
4789 } | |
4790 } | |
4791 } | |
4792 | |
8815 | 4793 void * |
4794 gaim_gtk_blist_get_handle() { | |
4795 static int handle; | |
4796 | |
4797 return &handle; | |
4798 } | |
4799 | |
11910 | 4800 static gboolean buddy_signonoff_timeout_cb(GaimBuddy *buddy) |
4801 { | |
4802 struct _gaim_gtk_blist_node *gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
4803 GaimConversation *conv; | |
4804 | |
4805 gtknode->recent_signonoff = FALSE; | |
4806 gtknode->recent_signonoff_timer = 0; | |
4807 | |
4808 gaim_gtk_blist_update(NULL, (GaimBlistNode*)buddy); | |
4809 | |
4810 if((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account))) { | |
4811 if(GAIM_BUDDY_IS_ONLINE(buddy)) { | |
4812 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
4813 } else { | |
4814 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_OFFLINE); | |
4815 } | |
4816 } | |
4817 | |
4818 return FALSE; | |
4819 } | |
4820 | |
4821 static void buddy_signonoff_cb(GaimBuddy *buddy) | |
4822 { | |
11915 | 4823 struct _gaim_gtk_blist_node *gtknode; |
4824 | |
4825 if(!((GaimBlistNode*)buddy)->ui_data) { | |
4826 gaim_gtk_blist_new_node((GaimBlistNode*)buddy); | |
4827 } | |
4828 | |
4829 gtknode = ((GaimBlistNode*)buddy)->ui_data; | |
11910 | 4830 |
4831 gtknode->recent_signonoff = TRUE; | |
4832 | |
4833 if(gtknode->recent_signonoff_timer > 0) | |
4834 gaim_timeout_remove(gtknode->recent_signonoff_timer); | |
4835 gtknode->recent_signonoff_timer = gaim_timeout_add(10000, | |
4836 (GSourceFunc)buddy_signonoff_timeout_cb, buddy); | |
4837 } | |
4838 | |
7620 | 4839 void gaim_gtk_blist_init(void) |
4840 { | |
8815 | 4841 void *gtk_blist_handle = gaim_gtk_blist_get_handle(); |
7620 | 4842 |
4843 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
8815 | 4844 gtk_blist_handle, GAIM_CALLBACK(account_signon_cb), |
7620 | 4845 NULL); |
7731 | 4846 |
4847 /* Initialize prefs */ | |
8819 | 4848 gaim_prefs_add_none("/gaim/gtk/blist"); |
4849 gaim_prefs_add_bool("/gaim/gtk/blist/show_buddy_icons", TRUE); | |
4850 gaim_prefs_add_bool("/gaim/gtk/blist/show_empty_groups", FALSE); | |
4851 gaim_prefs_add_bool("/gaim/gtk/blist/show_offline_buddies", FALSE); | |
10282 | 4852 gaim_prefs_add_bool("/gaim/gtk/blist/list_visible", TRUE); |
9711 | 4853 gaim_prefs_add_string("/gaim/gtk/blist/sort_type", "alphabetical"); |
8819 | 4854 gaim_prefs_add_int("/gaim/gtk/blist/x", 0); |
4855 gaim_prefs_add_int("/gaim/gtk/blist/y", 0); | |
9778 | 4856 gaim_prefs_add_int("/gaim/gtk/blist/width", 309); /* Golden ratio, baby */ |
4857 gaim_prefs_add_int("/gaim/gtk/blist/height", 500); /* Golden ratio, baby */ | |
12124
9c123e27e2f6
[gaim-migrate @ 14424]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12119
diff
changeset
|
4858 gaim_prefs_add_int("/gaim/gtk/blist/pane", 300); |
8819 | 4859 gaim_prefs_add_int("/gaim/gtk/blist/tooltip_delay", 500); |
7731 | 4860 |
8815 | 4861 /* Register our signals */ |
12016
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4862 gaim_signal_register(gtk_blist_handle, "gtkblist-hiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4863 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4864 gaim_value_new(GAIM_TYPE_POINTER)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4865 |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4866 gaim_signal_register(gtk_blist_handle, "gtkblist-unhiding", |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4867 gaim_marshal_VOID__POINTER, NULL, 1, |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4868 gaim_value_new(GAIM_TYPE_SUBTYPE)); |
24c7fb94d3a3
[gaim-migrate @ 14309]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11988
diff
changeset
|
4869 |
8815 | 4870 gaim_signal_register(gtk_blist_handle, "gtkblist-created", |
9811 | 4871 gaim_marshal_VOID__POINTER, NULL, 1, |
4872 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
4873 GAIM_SUBTYPE_BLIST)); | |
8819 | 4874 |
4875 gaim_signal_register(gtk_blist_handle, "drawing-tooltip", | |
9811 | 4876 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
4877 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_BLIST_NODE), | |
10477 | 4878 gaim_value_new_outgoing(GAIM_TYPE_BOXED, "GString *")); |
11910 | 4879 |
4880 | |
4881 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
4882 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gtk_blist_handle, GAIM_CALLBACK(buddy_signonoff_cb), NULL); | |
7620 | 4883 } |
4884 | |
8815 | 4885 void |
4886 gaim_gtk_blist_uninit(void) { | |
4887 gaim_signals_unregister_by_instance(gaim_gtk_blist_get_handle()); | |
4888 } | |
5228 | 4889 |
4890 /********************************************************************* | |
9811 | 4891 * Buddy List sorting functions * |
5422 | 4892 *********************************************************************/ |
4893 | |
11796 | 4894 GList *gaim_gtk_blist_get_sort_methods() |
4895 { | |
4896 return gaim_gtk_blist_sort_methods; | |
4897 } | |
4898 | |
7620 | 4899 void gaim_gtk_blist_sort_method_reg(const char *id, const char *name, gaim_gtk_blist_sort_function func) |
5422 | 4900 { |
4901 struct gaim_gtk_blist_sort_method *method = g_new0(struct gaim_gtk_blist_sort_method, 1); | |
7620 | 4902 method->id = g_strdup(id); |
5422 | 4903 method->name = g_strdup(name); |
9775 | 4904 method->func = func; |
11796 | 4905 gaim_gtk_blist_sort_methods = g_list_append(gaim_gtk_blist_sort_methods, method); |
4906 gaim_gtk_blist_update_sort_methods(); | |
5422 | 4907 } |
4908 | |
7620 | 4909 void gaim_gtk_blist_sort_method_unreg(const char *id){ |
11796 | 4910 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 4911 |
4912 while(l) { | |
4913 struct gaim_gtk_blist_sort_method *method = l->data; | |
4914 if(!strcmp(method->id, id)) { | |
11796 | 4915 gaim_gtk_blist_sort_methods = g_list_delete_link(gaim_gtk_blist_sort_methods, l); |
7620 | 4916 g_free(method->id); |
4917 g_free(method->name); | |
4918 g_free(method); | |
4919 break; | |
4920 } | |
4921 } | |
11796 | 4922 gaim_gtk_blist_update_sort_methods(); |
5422 | 4923 } |
4924 | |
7620 | 4925 void gaim_gtk_blist_sort_method_set(const char *id){ |
11796 | 4926 GList *l = gaim_gtk_blist_sort_methods; |
7620 | 4927 |
4928 if(!id) | |
4929 id = "none"; | |
4930 | |
4931 while (l && strcmp(((struct gaim_gtk_blist_sort_method*)l->data)->id, id)) | |
5422 | 4932 l = l->next; |
7620 | 4933 |
5422 | 4934 if (l) { |
4935 current_sort_method = l->data; | |
4936 } else if (!current_sort_method) { | |
7620 | 4937 gaim_gtk_blist_sort_method_set("none"); |
5422 | 4938 return; |
4939 } | |
4940 redo_buddy_list(gaim_get_blist(), TRUE); | |
4941 | |
4942 } | |
4943 | |
4944 /****************************************** | |
4945 ** Sort Methods | |
4946 ******************************************/ | |
4947 | |
7620 | 4948 static GtkTreeIter sort_method_none(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter parent_iter, GtkTreeIter *cur) |
5422 | 4949 { |
7620 | 4950 GtkTreeIter iter; |
4951 GaimBlistNode *sibling = node->prev; | |
4952 GtkTreeIter sibling_iter; | |
4953 | |
4954 if(cur) | |
5422 | 4955 return *cur; |
7620 | 4956 |
4957 while (sibling && !get_iter_from_node(sibling, &sibling_iter)) { | |
4958 sibling = sibling->prev; | |
5422 | 4959 } |
7620 | 4960 |
4961 gtk_tree_store_insert_after(gtkblist->treemodel, &iter, | |
4962 node->parent ? &parent_iter : NULL, | |
4963 sibling ? &sibling_iter : NULL); | |
4964 | |
5422 | 4965 return iter; |
4966 } | |
4967 | |
7620 | 4968 #if GTK_CHECK_VERSION(2,2,1) |
4969 | |
4970 static GtkTreeIter sort_method_alphabetical(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur) | |
5422 | 4971 { |
4972 GtkTreeIter more_z, iter; | |
4973 GaimBlistNode *n; | |
4974 GValue val = {0,}; | |
7620 | 4975 |
4976 const char *my_name; | |
4977 | |
4978 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
4979 my_name = gaim_contact_get_alias((GaimContact*)node); | |
4980 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
4981 my_name = gaim_chat_get_name((GaimChat*)node); | |
4982 } else { | |
4983 return sort_method_none(node, blist, groupiter, cur); | |
4984 } | |
4985 | |
5422 | 4986 |
4987 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, &groupiter)) { | |
4988 gtk_tree_store_insert(gtkblist->treemodel, &iter, &groupiter, 0); | |
7620 | 4989 return iter; |
4990 } | |
4991 | |
4992 do { | |
4993 const char *this_name; | |
4994 int cmp; | |
4995 | |
4996 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); | |
4997 n = g_value_get_pointer(&val); | |
4998 | |
4999 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5000 this_name = gaim_contact_get_alias((GaimContact*)n); | |
5001 } else if(GAIM_BLIST_NODE_IS_CHAT(n)) { | |
5002 this_name = gaim_chat_get_name((GaimChat*)n); | |
5003 } else { | |
5004 this_name = NULL; | |
5005 } | |
5006 | |
5007 cmp = gaim_utf8_strcasecmp(my_name, this_name); | |
5008 | |
5009 if(this_name && (cmp < 0 || (cmp == 0 && node < n))) { | |
5010 if(cur) { | |
5011 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); | |
5012 return *cur; | |
5013 } else { | |
5014 gtk_tree_store_insert_before(gtkblist->treemodel, &iter, | |
5015 &groupiter, &more_z); | |
5016 return iter; | |
5017 } | |
5018 } | |
5019 g_value_unset(&val); | |
5020 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
5021 | |
5022 if(cur) { | |
5023 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); | |
5024 return *cur; | |
5025 } else { | |
5026 gtk_tree_store_append(gtkblist->treemodel, &iter, &groupiter); | |
5027 return iter; | |
5028 } | |
5029 } | |
5030 | |
5031 static GtkTreeIter sort_method_status(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur) | |
5032 { | |
5033 GtkTreeIter more_z, iter; | |
5034 GaimBlistNode *n; | |
5035 GValue val = {0,}; | |
5036 | |
5037 GaimBuddy *my_buddy, *this_buddy; | |
5038 | |
5039 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5040 my_buddy = gaim_contact_get_priority_buddy((GaimContact*)node); | |
5041 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5042 if(cur) | |
5043 return *cur; | |
5044 | |
5045 gtk_tree_store_append(gtkblist->treemodel, &iter, &groupiter); | |
5046 return iter; | |
5047 } else { | |
5048 return sort_method_none(node, blist, groupiter, cur); | |
5049 } | |
5050 | |
5051 | |
5052 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, &groupiter)) { | |
5053 gtk_tree_store_insert(gtkblist->treemodel, &iter, &groupiter, 0); | |
5422 | 5054 return iter; |
5055 } | |
5056 | |
5057 do { | |
9944 | 5058 gint name_cmp; |
5059 gint presence_cmp; | |
7620 | 5060 |
5422 | 5061 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5062 n = g_value_get_pointer(&val); | |
7620 | 5063 |
5064 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5065 this_buddy = gaim_contact_get_priority_buddy((GaimContact*)n); | |
5066 } else { | |
5067 this_buddy = NULL; | |
5068 } | |
5069 | |
9944 | 5070 name_cmp = gaim_utf8_strcasecmp( |
5071 (my_buddy | |
5072 ? gaim_contact_get_alias(gaim_buddy_get_contact(my_buddy)) | |
5073 : NULL), | |
5074 (this_buddy | |
5075 ? gaim_contact_get_alias(gaim_buddy_get_contact(this_buddy)) | |
5076 : NULL)); | |
5077 | |
5078 presence_cmp = gaim_presence_compare( | |
5079 gaim_buddy_get_presence(my_buddy), | |
5080 gaim_buddy_get_presence(this_buddy)); | |
5081 | |
5082 if (this_buddy == NULL || | |
10860 | 5083 (presence_cmp < 0 || |
9944 | 5084 (presence_cmp == 0 && |
5085 (name_cmp < 0 || (name_cmp == 0 && node < n))))) | |
5086 { | |
5087 if (cur != NULL) | |
5088 { | |
7620 | 5089 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); |
5090 return *cur; | |
9944 | 5091 } |
5092 else | |
5093 { | |
7620 | 5094 gtk_tree_store_insert_before(gtkblist->treemodel, &iter, |
9944 | 5095 &groupiter, &more_z); |
7620 | 5096 return iter; |
5097 } | |
5422 | 5098 } |
9944 | 5099 |
5422 | 5100 g_value_unset(&val); |
9944 | 5101 } |
5102 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), | |
5103 &more_z)); | |
7620 | 5104 |
5105 if(cur) { | |
5106 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); | |
5107 return *cur; | |
5108 } else { | |
5109 gtk_tree_store_append(gtkblist->treemodel, &iter, &groupiter); | |
5110 return iter; | |
5111 } | |
5422 | 5112 } |
5113 | |
7620 | 5114 static GtkTreeIter sort_method_log(GaimBlistNode *node, GaimBuddyList *blist, GtkTreeIter groupiter, GtkTreeIter *cur) |
5422 | 5115 { |
5116 GtkTreeIter more_z, iter; | |
7620 | 5117 GaimBlistNode *n = NULL, *n2; |
5422 | 5118 GValue val = {0,}; |
7620 | 5119 |
5120 int log_size = 0, this_log_size = 0; | |
5121 const char *buddy_name, *this_buddy_name; | |
5122 | |
5123 if(cur && (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter) == 1)) | |
5124 return *cur; | |
5125 | |
5126 if(GAIM_BLIST_NODE_IS_CONTACT(node)) { | |
5127 for (n = node->child; n; n = n->next) | |
8898 | 5128 log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n))->name, ((GaimBuddy*)(n))->account); |
7620 | 5129 buddy_name = gaim_contact_get_alias((GaimContact*)node); |
5130 } else if(GAIM_BLIST_NODE_IS_CHAT(node)) { | |
5131 /* we don't have a reliable way of getting the log filename | |
5132 * from the chat info in the blist, yet */ | |
5133 if(cur) | |
5134 return *cur; | |
5135 | |
5136 gtk_tree_store_append(gtkblist->treemodel, &iter, &groupiter); | |
5137 return iter; | |
5138 } else { | |
5139 return sort_method_none(node, blist, groupiter, cur); | |
5140 } | |
5141 | |
5142 | |
5422 | 5143 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &more_z, &groupiter)) { |
5144 gtk_tree_store_insert(gtkblist->treemodel, &iter, &groupiter, 0); | |
5145 return iter; | |
5146 } | |
5147 | |
5148 do { | |
7620 | 5149 int cmp; |
5150 | |
5422 | 5151 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &more_z, NODE_COLUMN, &val); |
5152 n = g_value_get_pointer(&val); | |
7620 | 5153 this_log_size = 0; |
5154 | |
5155 if(GAIM_BLIST_NODE_IS_CONTACT(n)) { | |
5156 for (n2 = n->child; n2; n2 = n2->next) | |
8898 | 5157 this_log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy*)(n2))->name, ((GaimBuddy*)(n2))->account); |
7620 | 5158 this_buddy_name = gaim_contact_get_alias((GaimContact*)n); |
5159 } else { | |
5160 this_buddy_name = NULL; | |
5422 | 5161 } |
7620 | 5162 |
5163 cmp = gaim_utf8_strcasecmp(buddy_name, this_buddy_name); | |
5164 | |
5165 if (!GAIM_BLIST_NODE_IS_CONTACT(n) || log_size > this_log_size || | |
5166 ((log_size == this_log_size) && | |
5167 (cmp < 0 || (cmp == 0 && node < n)))) { | |
5168 if(cur) { | |
5169 gtk_tree_store_move_before(gtkblist->treemodel, cur, &more_z); | |
5170 return *cur; | |
5171 } else { | |
5172 gtk_tree_store_insert_before(gtkblist->treemodel, &iter, | |
5173 &groupiter, &more_z); | |
5174 return iter; | |
5175 } | |
5422 | 5176 } |
5177 g_value_unset(&val); | |
5178 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(gtkblist->treemodel), &more_z)); | |
7620 | 5179 |
5180 if(cur) { | |
5181 gtk_tree_store_move_before(gtkblist->treemodel, cur, NULL); | |
5182 return *cur; | |
5183 } else { | |
5184 gtk_tree_store_append(gtkblist->treemodel, &iter, &groupiter); | |
5185 return iter; | |
5186 } | |
5187 } | |
5188 | |
5189 #endif | |
5190 | |
5191 static void | |
9015 | 5192 plugin_act(GtkObject *obk, GaimPluginAction *pam) |
7620 | 5193 { |
10352 | 5194 if (pam->callback) |
5195 pam->callback(pam); | |
5422 | 5196 } |
7620 | 5197 |
11742 | 5198 static GList *plugin_menu_items = NULL; |
5199 static int plugin_menu_index = 8; | |
5200 | |
8986 | 5201 static void |
9015 | 5202 build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin, gpointer context) |
8986 | 5203 { |
9015 | 5204 GtkWidget *menuitem = NULL; |
5205 GaimPluginAction *action = NULL; | |
5206 GList *l, *ll; | |
5207 | |
5208 for (l = ll = GAIM_PLUGIN_ACTIONS(plugin, context); l; l = l->next) { | |
5209 if (l->data) { | |
5210 action = (GaimPluginAction *) l->data; | |
5211 action->plugin = plugin; | |
5212 action->context = context; | |
5213 | |
5214 menuitem = gtk_menu_item_new_with_label(action->label); | |
11745 | 5215 if (context) { |
5216 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
5217 } else { | |
5218 plugin_menu_items = g_list_append(plugin_menu_items, menuitem); | |
5219 plugin_menu_index++; | |
5220 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, plugin_menu_index); | |
5221 } | |
9015 | 5222 g_signal_connect(G_OBJECT(menuitem), "activate", |
5223 G_CALLBACK(plugin_act), action); | |
5224 g_object_set_data(G_OBJECT(menuitem), "plugin_action", action); | |
5225 gtk_widget_show(menuitem); | |
5226 } | |
5227 else | |
5228 gaim_separator(menu); | |
5229 } | |
5230 | |
5231 g_list_free(ll); | |
8986 | 5232 } |
5233 | |
5234 | |
7620 | 5235 void |
5236 gaim_gtk_blist_update_protocol_actions(void) | |
5237 { | |
9015 | 5238 GtkWidget *menuitem, *submenu; |
7620 | 5239 GList *l; |
5240 GaimConnection *gc = NULL; | |
9015 | 5241 GaimPlugin *plugin = NULL; |
7620 | 5242 int count = 0; |
9015 | 5243 |
9019 | 5244 if (protomenu == NULL) |
7620 | 5245 return; |
5246 | |
9019 | 5247 /* Clear the old Account Actions menu */ |
9015 | 5248 for (l = gtk_container_get_children(GTK_CONTAINER(protomenu)); l; l = l->next) { |
5249 GaimPluginAction *action; | |
9987 | 5250 |
7620 | 5251 menuitem = l->data; |
9015 | 5252 action = (GaimPluginAction *) g_object_get_data(G_OBJECT(menuitem), |
5253 "plugin_action"); | |
5254 g_free(action); | |
7620 | 5255 |
5256 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem)); | |
5257 } | |
5258 | |
9019 | 5259 /* Count the number of accounts with actions */ |
9015 | 5260 for (l = gaim_connections_get_all(); l; l = l->next) { |
5261 gc = l->data; | |
5262 plugin = gc->prpl; | |
5263 | |
9019 | 5264 if (GAIM_CONNECTION_IS_CONNECTED(gc) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) |
5265 count++; | |
5266 | |
9015 | 5267 /* no need to count past 2, so don't */ |
9019 | 5268 if (count > 1) |
9015 | 5269 break; |
7620 | 5270 } |
5271 | |
9015 | 5272 if (count == 0) { |
5273 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | |
7620 | 5274 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); |
9015 | 5275 gtk_widget_set_sensitive(menuitem, FALSE); |
7620 | 5276 gtk_widget_show(menuitem); |
5277 } | |
9019 | 5278 |
5279 else if (count == 1) { | |
5280 /* Find the one account that has actions */ | |
5281 for (l = gaim_connections_get_all(); l; l = l->next) { | |
5282 gc = l->data; | |
5283 plugin = gc->prpl; | |
5284 | |
5285 if (GAIM_CONNECTION_IS_CONNECTED(gc) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5286 break; | |
5287 } | |
5288 | |
9015 | 5289 build_plugin_actions(protomenu, plugin, gc); |
7620 | 5290 } |
9019 | 5291 |
7620 | 5292 else { |
9015 | 5293 for (l = gaim_connections_get_all(); l; l = l->next) { |
7620 | 5294 GaimAccount *account; |
5295 GdkPixbuf *pixbuf, *scale; | |
5296 GtkWidget *image; | |
9015 | 5297 char *buf; |
5298 | |
5299 gc = l->data; | |
5300 plugin = gc->prpl; | |
5301 | |
9019 | 5302 if (!GAIM_CONNECTION_IS_CONNECTED(gc) || !GAIM_PLUGIN_HAS_ACTIONS(plugin)) |
7620 | 5303 continue; |
5304 | |
5305 account = gaim_connection_get_account(gc); | |
9015 | 5306 buf = g_strconcat(gaim_account_get_username(account), " (", |
5307 plugin->info->name, ")", NULL); | |
7620 | 5308 menuitem = gtk_image_menu_item_new_with_label(buf); |
9015 | 5309 g_free(buf); |
5310 | |
10884 | 5311 pixbuf = gaim_gtk_create_prpl_icon(account); |
9019 | 5312 if (pixbuf) { |
7620 | 5313 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
5314 GDK_INTERP_BILINEAR); | |
5315 image = gtk_image_new_from_pixbuf(scale); | |
5316 g_object_unref(G_OBJECT(pixbuf)); | |
5317 g_object_unref(G_OBJECT(scale)); | |
5318 gtk_widget_show(image); | |
9015 | 5319 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); |
7620 | 5320 } |
5321 | |
5322 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); | |
5323 gtk_widget_show(menuitem); | |
5324 | |
5325 submenu = gtk_menu_new(); | |
5326 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
5327 gtk_widget_show(submenu); | |
5328 | |
9015 | 5329 build_plugin_actions(submenu, plugin, gc); |
7620 | 5330 } |
5331 } | |
5332 } | |
8986 | 5333 |
5334 void | |
5335 gaim_gtk_blist_update_plugin_actions(void) | |
5336 { | |
11742 | 5337 GtkWidget *menuitem; |
9015 | 5338 GaimPlugin *plugin = NULL; |
8986 | 5339 GList *l; |
5340 int count = 0; | |
5341 | |
11742 | 5342 GtkWidget *pluginmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools")); |
5343 | |
9019 | 5344 if (pluginmenu == NULL) |
8986 | 5345 return; |
5346 | |
9019 | 5347 /* Clear the old Account Actions menu */ |
11742 | 5348 for (l = plugin_menu_items; l; l = l->next) { |
9015 | 5349 GaimPluginAction *action; |
11742 | 5350 plugin_menu_index--; |
8986 | 5351 menuitem = l->data; |
9015 | 5352 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); |
5353 g_free(action); | |
8986 | 5354 |
5355 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(menuitem)); | |
5356 } | |
11742 | 5357 g_list_free(plugin_menu_items); |
5358 plugin_menu_items = NULL; | |
8986 | 5359 |
9019 | 5360 /* Count the number of plugins with actions */ |
9015 | 5361 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
5362 plugin = (GaimPlugin *) l->data; | |
5363 | |
9019 | 5364 if (!GAIM_IS_PROTOCOL_PLUGIN(plugin) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) |
5365 count++; | |
5366 | |
5367 /* no need to count past 2, so don't */ | |
5368 if (count > 1) | |
9015 | 5369 break; |
8986 | 5370 } |
5371 | |
11742 | 5372 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
11923 | 5373 |
11742 | 5374 plugin = (GaimPlugin *) l->data; |
11923 | 5375 |
11742 | 5376 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
5377 continue; | |
5378 | |
5379 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5380 continue; | |
9019 | 5381 |
9015 | 5382 build_plugin_actions(pluginmenu, plugin, NULL); |
8986 | 5383 } |
5384 } | |
11796 | 5385 |
5386 void sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id) | |
5387 { | |
5388 if (gtk_check_menu_item_get_active(checkmenuitem)) | |
11923 | 5389 { |
11796 | 5390 gaim_gtk_blist_sort_method_set(id); |
11923 | 5391 gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); |
5392 } | |
11796 | 5393 } |
5394 | |
5395 void | |
5396 gaim_gtk_blist_update_sort_methods(void) | |
5397 { | |
5398 GtkWidget *menuitem = NULL, *activeitem = NULL; | |
5399 GaimGtkBlistSortMethod *method = NULL; | |
5400 GList *l; | |
5401 GSList *sl = NULL; | |
5402 GtkWidget *sortmenu; | |
11797 | 5403 const char *m = gaim_prefs_get_string("/gaim/gtk/blist/sort_type"); |
11796 | 5404 |
5405 if (gtkblist == NULL) | |
5406 return; | |
5407 | |
11798
01c3eec6ea3c
[gaim-migrate @ 14089]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11797
diff
changeset
|
5408 sortmenu = gtk_item_factory_get_widget(gtkblist->ift, N_("/Buddies/Sort Buddies")); |
11796 | 5409 |
5410 if (sortmenu == NULL) | |
5411 return; | |
5412 | |
5413 /* Clear the old menu */ | |
5414 for (l = gtk_container_get_children(GTK_CONTAINER(sortmenu)); l; l = l->next) { | |
5415 menuitem = l->data; | |
5416 gtk_widget_destroy(GTK_WIDGET(menuitem)); | |
5417 } | |
11923 | 5418 |
11796 | 5419 for (l = gaim_gtk_blist_sort_methods; l; l = l->next) { |
5420 method = (GaimGtkBlistSortMethod *) l->data; | |
5421 menuitem = gtk_radio_menu_item_new_with_label(sl, _(method->name)); | |
5422 if (!strcmp(m, method->id)) | |
5423 activeitem = menuitem; | |
5424 sl = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); | |
5425 gtk_menu_shell_append(GTK_MENU_SHELL(sortmenu), menuitem); | |
5426 g_signal_connect(G_OBJECT(menuitem), "toggled", | |
5427 G_CALLBACK(sortmethod_act), method->id); | |
11923 | 5428 gtk_widget_show(menuitem); |
11796 | 5429 } |
5430 if (activeitem) | |
5431 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(activeitem), TRUE); | |
5432 | |
5433 } |