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