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