Mercurial > pidgin
annotate src/buddy.c @ 4912:a6e9cd5e853e
[gaim-migrate @ 5246]
Danny Colascione (quotemstr) fixed a segfault when buddies sign on as you do.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sun, 30 Mar 2003 18:45:49 +0000 |
parents | 50b77ae4cacf |
children | d9b6b5ae34e4 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
342
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
23 #include <config.h> |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
342
diff
changeset
|
24 #endif |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
25 #ifdef GAIM_PLUGINS |
3630 | 26 #ifndef _WIN32 |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
27 #include <dlfcn.h> |
3630 | 28 #endif |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
29 #endif /* GAIM_PLUGINS */ |
1 | 30 #include <string.h> |
31 #include <stdio.h> | |
32 #include <stdlib.h> | |
3159 | 33 #include <ctype.h> |
1 | 34 #include <math.h> |
35 #include <time.h> | |
3630 | 36 #include <ctype.h> |
37 | |
38 #ifdef _WIN32 | |
39 #include <gdk/gdkwin32.h> | |
40 #else | |
1233
728a90516211
[gaim-migrate @ 1243]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1230
diff
changeset
|
41 #include <unistd.h> |
3630 | 42 #include <gdk/gdkx.h> |
43 #endif | |
1 | 44 |
1634
d029dc28a61e
[gaim-migrate @ 1644]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1625
diff
changeset
|
45 #include <gdk/gdkkeysyms.h> |
1 | 46 #include <gtk/gtk.h> |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
47 #include "prpl.h" |
4561 | 48 #include "sound.h" |
1 | 49 #include "gaim.h" |
4687 | 50 #include "gtklist.h" |
51 #include "gtkft.h" | |
3630 | 52 |
53 #ifdef _WIN32 | |
54 #include "win32dep.h" | |
55 #endif | |
56 | |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
57 static struct gaim_gtk_buddy_list *gtkblist = NULL; |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
58 |
4840 | 59 /* part of the best damn Docklet code this side of Tahiti */ |
4698 | 60 static gboolean gaim_gtk_blist_obscured = FALSE; |
61 | |
4810 | 62 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data); |
4687 | 63 static void gaim_gtk_blist_update(struct gaim_buddy_list *list, GaimBlistNode *node); |
4724 | 64 static char *gaim_get_tooltip_text(struct buddy *b); |
65 static GdkPixbuf *gaim_gtk_blist_get_status_icon(struct buddy *b, GaimStatusIconSize size); | |
4834 | 66 static char *item_factory_translate_func (const char *path, gpointer func_data); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
67 |
4687 | 68 /*************************************************** |
69 * Callbacks * | |
70 ***************************************************/ | |
3869 | 71 |
4840 | 72 static gboolean gtk_blist_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data) |
4698 | 73 { |
74 if (docklet_count) | |
75 gaim_blist_set_visible(FALSE); | |
76 else | |
77 do_quit(); | |
4840 | 78 |
79 /* we handle everything, event should not propogate further */ | |
80 return TRUE; | |
81 } | |
82 | |
83 static gboolean gtk_blist_save_prefs_cb(gpointer data) | |
84 { | |
85 save_prefs(); | |
86 | |
87 /* only run once */ | |
88 return FALSE; | |
89 } | |
90 | |
91 static gboolean gtk_blist_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) | |
92 { | |
93 /* unfortunately GdkEventConfigure ignores the window gravity, but * | |
94 * the only way we have of setting the position doesn't. we have to * | |
95 * call get_position and get_size because they do pay attention to * | |
96 * the gravity. this is inefficient and I agree it sucks, but it's * | |
97 * more likely to work correctly. - Robot101 */ | |
98 gint x, y; | |
99 | |
100 /* check for visibility because when we aren't visible, this will * | |
101 * give us bogus (0,0) coordinates. - xOr */ | |
102 if (GTK_WIDGET_VISIBLE(w)) { | |
103 gtk_window_get_position(GTK_WINDOW(w), &x, &y); | |
104 | |
105 if (x != blist_pos.x || | |
106 y != blist_pos.y || | |
107 event->width != blist_pos.width || | |
108 event->height != blist_pos.height) { | |
109 blist_pos.x = x; | |
110 blist_pos.y = y; | |
111 blist_pos.width = event->width; | |
112 blist_pos.height = event->height; | |
113 | |
114 if (!g_main_context_find_source_by_user_data(NULL, >k_blist_save_prefs_cb)) { | |
115 g_timeout_add(5000, gtk_blist_save_prefs_cb, >k_blist_save_prefs_cb); | |
116 } | |
117 } | |
118 } | |
119 | |
120 /* continue to handle event normally */ | |
121 return FALSE; | |
122 } | |
123 | |
124 static gboolean gtk_blist_visibility_cb(GtkWidget *w, GdkEventVisibility *event, gpointer data) | |
125 { | |
126 if (event->state == GDK_VISIBILITY_FULLY_OBSCURED) | |
127 gaim_gtk_blist_obscured = TRUE; | |
128 else | |
129 gaim_gtk_blist_obscured = FALSE; | |
130 | |
131 /* continue to handle event normally */ | |
132 return FALSE; | |
4698 | 133 } |
134 | |
4732 | 135 static void gtk_blist_menu_info_cb(GtkWidget *w, struct buddy *b) |
136 { | |
137 serv_get_info(b->account->gc, b->name); | |
138 } | |
139 | |
4697 | 140 static void gtk_blist_menu_im_cb(GtkWidget *w, struct buddy *b) |
141 { | |
142 gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); | |
143 } | |
144 | |
145 static void gtk_blist_menu_alias_cb(GtkWidget *w, struct buddy *b) | |
146 { | |
147 alias_dialog_bud(b); | |
148 } | |
149 | |
150 static void gtk_blist_menu_bp_cb(GtkWidget *w, struct buddy *b) | |
151 { | |
152 show_new_bp(b->name, b->account->gc, b->idle, | |
153 b->uc & UC_UNAVAILABLE, NULL); | |
154 } | |
155 | |
156 static void gtk_blist_menu_showlog_cb(GtkWidget *w, struct buddy *b) | |
157 { | |
158 show_log(b->name); | |
159 } | |
160 | |
161 static void gtk_blist_show_systemlog_cb() | |
162 { | |
163 show_log(NULL); | |
164 } | |
165 | |
4776 | 166 static void gtk_blist_show_onlinehelp_cb() |
167 { | |
168 open_url(NULL, "http://gaim.sourceforge.net/documentation.php"); | |
169 } | |
170 | |
4692 | 171 static void gtk_blist_button_im_cb(GtkWidget *w, GtkTreeView *tv) |
172 { | |
173 GtkTreeIter iter; | |
174 GtkTreeModel *model = gtk_tree_view_get_model(tv); | |
175 GtkTreeSelection *sel = gtk_tree_view_get_selection(tv); | |
176 | |
177 if(gtk_tree_selection_get_selected(sel, &model, &iter)){ | |
178 GaimBlistNode *node; | |
179 | |
180 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
181 if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
182 gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)node)->account, ((struct buddy*)node)->name); | |
183 } | |
4694 | 184 } |
4692 | 185 |
4694 | 186 static void gtk_blist_button_info_cb(GtkWidget *w, GtkTreeView *tv) |
187 { | |
188 GtkTreeIter iter; | |
189 GtkTreeModel *model = gtk_tree_view_get_model(tv); | |
190 GtkTreeSelection *sel = gtk_tree_view_get_selection(tv); | |
4692 | 191 |
4694 | 192 if(gtk_tree_selection_get_selected(sel, &model, &iter)){ |
193 GaimBlistNode *node; | |
194 | |
195 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
196 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
197 serv_get_info(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name); | |
198 return; | |
199 } | |
200 } | |
201 show_info_dialog(); | |
202 } | |
203 | |
204 static void gtk_blist_button_chat_cb(GtkWidget *w, gpointer data) | |
205 { | |
206 /* FIXME: someday, we can check to see if we've selected a chat node */ | |
207 join_chat(); | |
208 } | |
209 | |
210 static void gtk_blist_button_away_cb(GtkWidget *w, gpointer data) | |
211 { | |
212 gtk_menu_popup(GTK_MENU(awaymenu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); | |
4692 | 213 } |
214 | |
4687 | 215 static void gtk_blist_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) { |
216 GaimBlistNode *node; | |
217 GtkTreeIter iter; | |
218 GValue val = { 0, }; | |
3154 | 219 |
4687 | 220 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); |
221 | |
222 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
223 node = g_value_get_pointer(&val); | |
224 | |
225 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
4911 | 226 struct gaim_conversation *conv = |
227 gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)node)->account, ((struct buddy*)node)->name); | |
228 if(conv) { | |
229 gaim_window_raise(gaim_conversation_get_window(conv)); | |
230 gaim_window_switch_conversation( | |
231 gaim_conversation_get_window(conv), | |
232 gaim_conversation_get_index(conv)); | |
233 } | |
4697 | 234 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
235 if (gtk_tree_view_row_expanded(tv, path)) | |
236 gtk_tree_view_collapse_row(tv, path); | |
237 else | |
238 gtk_tree_view_expand_row(tv,path,FALSE); | |
1 | 239 } |
240 } | |
241 | |
4687 | 242 static void gaim_proto_menu_cb(GtkMenuItem *item, struct buddy *b) |
1 | 243 { |
4687 | 244 struct proto_buddy_menu *pbm = g_object_get_data(G_OBJECT(item), "gaimcallback"); |
245 if (pbm->callback) | |
246 pbm->callback(pbm->gc, b->name); | |
1396
df7c3cacac92
[gaim-migrate @ 1406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1392
diff
changeset
|
247 } |
1 | 248 |
4687 | 249 static gboolean gtk_blist_button_press_cb(GtkWidget *tv, GdkEventButton *event, gpointer null) |
1391
d606da211acb
[gaim-migrate @ 1401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
250 { |
4687 | 251 GtkTreePath *path; |
252 GaimBlistNode *node; | |
253 GValue val = { 0, }; | |
254 GtkTreeIter iter; | |
255 GtkWidget *menu, *menuitem; | |
256 GtkWidget *image; | |
4702 | 257 GtkTreeSelection *sel; |
4687 | 258 GList *list; |
259 struct prpl *prpl; | |
1391
d606da211acb
[gaim-migrate @ 1401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
260 |
4687 | 261 if (event->button != 3) |
262 return FALSE; | |
4718 | 263 |
4687 | 264 /* Here we figure out which node was clicked */ |
265 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL)) | |
266 return FALSE; | |
267 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
268 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
269 node = g_value_get_pointer(&val); | |
4718 | 270 |
4721 | 271 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) { |
272 gtk_tree_path_free(path); | |
4687 | 273 return FALSE; |
4721 | 274 } |
4718 | 275 |
4687 | 276 menu = gtk_menu_new(); |
3251 | 277 |
4687 | 278 /* Protocol specific options */ |
279 prpl = find_prpl(((struct buddy*)node)->account->protocol); | |
4732 | 280 |
281 if(prpl && prpl->get_info) { | |
4813 | 282 menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Get Info")); |
4732 | 283 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_info_cb), node); |
284 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
285 } | |
286 | |
4813 | 287 menuitem = gtk_image_menu_item_new_with_mnemonic(_("_IM")); |
4732 | 288 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_im_cb), node); |
289 image = gtk_image_new_from_stock(GAIM_STOCK_IM, GTK_ICON_SIZE_MENU); | |
290 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
291 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
292 | |
4813 | 293 menuitem = gtk_image_menu_item_new_with_mnemonic(_("_Alias")); |
4732 | 294 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_alias_cb), node); |
295 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
296 | |
4813 | 297 menuitem = gtk_image_menu_item_new_with_mnemonic(_("Add Buddy _Pounce")); |
4732 | 298 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_bp_cb), node); |
299 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
300 | |
4813 | 301 menuitem = gtk_image_menu_item_new_with_mnemonic(_("View _Log")); |
4732 | 302 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_showlog_cb), node); |
303 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
304 | |
4687 | 305 if (prpl) { |
306 list = prpl->buddy_menu(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name); | |
307 while (list) { | |
308 struct proto_buddy_menu *pbm = list->data; | |
309 menuitem = gtk_menu_item_new_with_mnemonic(pbm->label); | |
310 g_object_set_data(G_OBJECT(menuitem), "gaimcallback", pbm); | |
311 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gaim_proto_menu_cb), node); | |
312 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
313 list = list->next; | |
3313 | 314 } |
3251 | 315 } |
1 | 316 |
4687 | 317 gtk_widget_show_all(menu); |
318 | |
319 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); | |
1 | 320 |
4702 | 321 #if (1) /* This code only exists because GTK doesn't work. If we return FALSE here, as would be normal |
322 * the event propoagates down and somehow gets interpreted as the start of a drag event. */ | |
323 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
324 gtk_tree_selection_select_path(sel, path); | |
4721 | 325 gtk_tree_path_free(path); |
4702 | 326 return TRUE; |
327 #endif | |
1 | 328 } |
329 | |
4687 | 330 /* This is called 10 seconds after the buddy logs in. It removes the "logged in" icon and replaces it with |
331 * the normal status icon */ | |
1072
81d19577285a
[gaim-migrate @ 1082]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1070
diff
changeset
|
332 |
4687 | 333 static gboolean gaim_reset_present_icon(GaimBlistNode *b) |
334 { | |
335 ((struct buddy*)b)->present = 1; | |
336 gaim_gtk_blist_update(NULL, b); | |
337 return FALSE; | |
577
aa9a8bcddd80
[gaim-migrate @ 587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
544
diff
changeset
|
338 } |
aa9a8bcddd80
[gaim-migrate @ 587]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
544
diff
changeset
|
339 |
4687 | 340 static void gaim_gtk_blist_add_buddy_cb() |
935
5e6ca3dd4d02
[gaim-migrate @ 945]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
921
diff
changeset
|
341 { |
4690 | 342 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); |
4687 | 343 GtkTreeIter iter; |
344 GaimBlistNode *node; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
345 |
4692 | 346 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){ |
347 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1); | |
4691 | 348 if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
349 show_add_buddy(NULL, NULL, ((struct group*)node->parent)->name, NULL); | |
350 else if (GAIM_BLIST_NODE_IS_GROUP(node)) | |
351 show_add_buddy(NULL, NULL, ((struct group*)node)->name, NULL); | |
352 } | |
4697 | 353 else { |
4692 | 354 show_add_buddy(NULL, NULL, NULL, NULL); |
355 } | |
1 | 356 } |
357 | |
4697 | 358 static void gaim_gtk_blist_update_toolbar_icons (GtkWidget *widget, gpointer data) { |
359 if (GTK_IS_IMAGE(widget)) { | |
360 if (blist_options & OPT_BLIST_SHOW_BUTTON_XPM) | |
361 gtk_widget_show(widget); | |
362 else | |
363 gtk_widget_hide(widget); | |
364 } else if (GTK_IS_CONTAINER(widget)) { | |
365 gtk_container_foreach(GTK_CONTAINER(widget), gaim_gtk_blist_update_toolbar_icons, NULL); | |
366 } | |
367 } | |
1 | 368 |
4702 | 369 static void gaim_gtk_blist_drag_data_get_cb (GtkWidget *widget, |
370 GdkDragContext *dc, | |
371 GtkSelectionData *data, | |
372 guint info, | |
373 guint time, | |
374 gpointer *null) | |
375 { | |
4781 | 376 if (data->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) { |
4702 | 377 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); |
378 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref); | |
379 GtkTreeIter iter; | |
380 GaimBlistNode *node = NULL; | |
381 GValue val = {0}; | |
382 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow); | |
383 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
384 node = g_value_get_pointer(&val); | |
4781 | 385 gtk_selection_data_set (data, |
386 gdk_atom_intern ("GAIM_BLIST_NODE", FALSE), | |
387 8, /* bits */ | |
388 (void*)&node, | |
389 sizeof (node)); | |
390 | |
4721 | 391 gtk_tree_path_free(sourcerow); |
4702 | 392 } |
4781 | 393 |
4702 | 394 } |
395 | |
396 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | |
397 GtkSelectionData *sd, guint info, guint t) | |
398 { | |
4781 | 399 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE) && sd->data) { |
400 GaimBlistNode *n = NULL; | |
4702 | 401 GtkTreePath *path = NULL; |
4704 | 402 GtkTreeViewDropPosition position; |
4781 | 403 memcpy(&n, sd->data, sizeof(n)); |
4704 | 404 if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) { |
405 /* if we're here, I think it means the drop is ok */ | |
4770 | 406 GtkTreeIter iter; |
407 GaimBlistNode *node; | |
408 GValue val = {0}; | |
409 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
410 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
411 node = g_value_get_pointer(&val); | |
4781 | 412 |
413 if (GAIM_BLIST_NODE_IS_BUDDY(n)) { | |
414 struct buddy *b = (struct buddy*)n; | |
415 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
4795 | 416 switch(position) { |
417 case GTK_TREE_VIEW_DROP_AFTER: | |
418 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
419 gaim_blist_add_buddy(b, (struct group*)node->parent, node); | |
420 break; | |
421 case GTK_TREE_VIEW_DROP_BEFORE: | |
422 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
423 gaim_blist_add_buddy(b, (struct group*)node->parent, node->prev); | |
424 break; | |
4781 | 425 } |
426 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
427 gaim_blist_add_buddy(b, (struct group*)node, NULL); | |
4795 | 428 } |
4781 | 429 } else if (GAIM_BLIST_NODE_IS_GROUP(n)) { |
430 struct group *g = (struct group*)n; | |
431 if (GAIM_BLIST_NODE_IS_GROUP(node)) { | |
432 switch (position) { | |
433 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: | |
434 case GTK_TREE_VIEW_DROP_AFTER: | |
435 gaim_blist_add_group(g, node); | |
436 break; | |
437 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: | |
438 case GTK_TREE_VIEW_DROP_BEFORE: | |
439 gaim_blist_add_group(g, node->prev); | |
440 break; | |
441 } | |
442 | |
4770 | 443 } |
4781 | 444 |
4777 | 445 } |
4781 | 446 |
4721 | 447 gtk_tree_path_free(path); |
4704 | 448 } |
4702 | 449 } |
450 } | |
451 | |
4724 | 452 static void gaim_gtk_blist_paint_tip(GtkWidget *widget, GdkEventExpose *event, struct buddy *b) |
453 { | |
454 GtkStyle *style; | |
455 GdkPixbuf *pixbuf = gaim_gtk_blist_get_status_icon(b, GAIM_STATUS_ICON_LARGE); | |
456 PangoLayout *layout; | |
457 char *tooltiptext = gaim_get_tooltip_text(b); | |
458 | |
459 layout = gtk_widget_create_pango_layout (gtkblist->tipwindow, NULL); | |
460 pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext)); | |
4732 | 461 pango_layout_set_wrap(layout, PANGO_WRAP_WORD); |
4733 | 462 pango_layout_set_width(layout, 300000); |
4724 | 463 style = gtkblist->tipwindow->style; |
4732 | 464 |
4724 | 465 gtk_paint_flat_box (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, |
466 NULL, gtkblist->tipwindow, "tooltip", 0, 0, -1, -1); | |
4729 | 467 |
468 #if GTK_CHECK_VERSION(2,2,0) | |
4724 | 469 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, pixbuf, |
470 0, 0, 4, 4, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); | |
4729 | 471 #else |
4758 | 472 gdk_pixbuf_render_to_drawable(pixbuf, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 4, 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
4729 | 473 #endif |
4724 | 474 |
475 gtk_paint_layout (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, TRUE, | |
476 NULL, gtkblist->tipwindow, "tooltip", 38, 4, layout); | |
477 | |
478 g_object_unref (pixbuf); | |
479 g_object_unref (layout); | |
480 g_free(tooltiptext); | |
481 return; | |
482 } | |
483 | |
484 static gboolean gaim_gtk_blist_tooltip_timeout(GtkWidget *tv) | |
485 { | |
486 GtkTreePath *path; | |
487 GtkTreeIter iter; | |
488 GaimBlistNode *node; | |
489 GValue val = {0}; | |
490 | |
491 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->rect.x, gtkblist->rect.y, &path, NULL, NULL, NULL)) | |
492 return FALSE; | |
493 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); | |
494 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); | |
495 node = g_value_get_pointer(&val); | |
496 | |
497 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
498 int scr_w,scr_h, w, h, x, y; | |
499 PangoLayout *layout; | |
500 struct buddy *buddy = (struct buddy*)node; | |
501 char *tooltiptext = gaim_get_tooltip_text(buddy); | |
502 gtkblist->tipwindow = gtk_window_new(GTK_WINDOW_POPUP); | |
4907
68e2b07ef8d7
[gaim-migrate @ 5241]
Christian Hammond <chipx86@chipx86.com>
parents:
4883
diff
changeset
|
503 gtkblist->tipwindow->parent = tv; |
4724 | 504 gtk_widget_set_app_paintable(gtkblist->tipwindow, TRUE); |
4729 | 505 gtk_window_set_resizable(GTK_WINDOW(gtkblist->tipwindow), FALSE); |
4724 | 506 gtk_widget_set_name(gtkblist->tipwindow, "gtk-tooltips"); |
4883
3c3bafae42e8
[gaim-migrate @ 5213]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4879
diff
changeset
|
507 gtk_widget_realize(gtkblist->tipwindow); |
4724 | 508 g_signal_connect(G_OBJECT(gtkblist->tipwindow), "expose_event", |
509 G_CALLBACK(gaim_gtk_blist_paint_tip), buddy); | |
510 gtk_widget_ensure_style (gtkblist->tipwindow); | |
511 | |
512 layout = gtk_widget_create_pango_layout (gtkblist->tipwindow, NULL); | |
4733 | 513 pango_layout_set_wrap(layout, PANGO_WRAP_WORD); |
514 pango_layout_set_width(layout, 300000); | |
4724 | 515 pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext)); |
516 scr_w = gdk_screen_width(); | |
517 scr_h = gdk_screen_height(); | |
518 pango_layout_get_size (layout, &w, &h); | |
519 w = PANGO_PIXELS(w) + 8; | |
520 h = PANGO_PIXELS(h) + 8; | |
521 | |
522 /* 38 is the size of a large status icon plus 4 pixels padding on each side. | |
523 I should #define this or something */ | |
524 w = w + 38; | |
525 h = MAX(h, 38); | |
526 | |
527 gdk_window_get_pointer(NULL, &x, &y, NULL); | |
528 if (GTK_WIDGET_NO_WINDOW(gtkblist->window)) | |
529 y+=gtkblist->window->allocation.y; | |
530 | |
531 x -= ((w >> 1) + 4); | |
532 | |
533 if ((x + w) > scr_w) | |
534 x -= (x + w) - scr_w; | |
535 else if (x < 0) | |
536 x = 0; | |
537 | |
538 if ((y + h + 4) > scr_h) | |
539 y = y - h; | |
540 else | |
541 y = y + 6; | |
542 g_object_unref (layout); | |
543 g_free(tooltiptext); | |
544 gtk_widget_set_size_request(gtkblist->tipwindow, w, h); | |
4729 | 545 gtk_window_move(GTK_WINDOW(gtkblist->tipwindow), x, y); |
4724 | 546 gtk_widget_show(gtkblist->tipwindow); |
547 } | |
4729 | 548 |
4724 | 549 gtk_tree_path_free(path); |
550 return FALSE; | |
551 } | |
552 | |
4730 | 553 static gboolean gaim_gtk_blist_motion_cb (GtkWidget *tv, GdkEventMotion *event, gpointer null) |
4724 | 554 { |
555 GtkTreePath *path; | |
556 if (gtkblist->timeout) { | |
557 if ((event->y > gtkblist->rect.y) && ((event->y - gtkblist->rect.height) < gtkblist->rect.y)) | |
4732 | 558 return FALSE; |
4724 | 559 /* We've left the cell. Remove the timeout and create a new one below */ |
560 if (gtkblist->tipwindow) { | |
561 gtk_widget_destroy(gtkblist->tipwindow); | |
562 gtkblist->tipwindow = NULL; | |
563 } | |
564 | |
565 g_source_remove(gtkblist->timeout); | |
566 } | |
567 | |
568 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL); | |
569 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, >kblist->rect); | |
570 if (path) | |
571 gtk_tree_path_free(path); | |
572 gtkblist->timeout = g_timeout_add(500, (GSourceFunc)gaim_gtk_blist_tooltip_timeout, tv); | |
4730 | 573 return FALSE; |
4724 | 574 } |
575 | |
576 static void gaim_gtk_blist_leave_cb (GtkWidget *w, GdkEventCrossing *e, gpointer n) | |
577 { | |
578 if (gtkblist->timeout == 0) | |
579 return; | |
580 if (gtkblist->tipwindow) { | |
581 gtk_widget_destroy(gtkblist->tipwindow); | |
582 gtkblist->tipwindow = NULL; | |
583 } | |
584 g_source_remove(gtkblist->timeout); | |
585 gtkblist->timeout = 0; | |
586 } | |
587 | |
4687 | 588 /*************************************************** |
589 * Crap * | |
590 ***************************************************/ | |
591 static GtkItemFactoryEntry blist_menu[] = | |
1929
d51ea669d84e
[gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1918
diff
changeset
|
592 { |
4687 | 593 /* Buddies menu */ |
594 { N_("/_Buddies"), NULL, NULL, 0, "<Branch>" }, | |
595 { N_("/Buddies/_Add A Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, | |
596 "<StockItem>", GTK_STOCK_ADD }, | |
597 { N_("/Buddies/New _Instant Message..."), "<CTL>I", show_im_dialog, 0, | |
598 "<StockItem>", GAIM_STOCK_IM }, | |
599 { N_("/Buddies/Join a _Chat..."), "<CTL>C", join_chat, 0, | |
600 "<StockItem>", GAIM_STOCK_CHAT }, | |
4834 | 601 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>" }, |
4687 | 602 { N_("/Buddies/Get _User Info..."), "<CTL>J", show_info_dialog, 0, |
603 "<StockItem>", GAIM_STOCK_INFO }, | |
4834 | 604 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>" }, |
4687 | 605 { N_("/Buddies/_Signoff"), "<CTL>D", signoff_all, 0, NULL }, |
606 { N_("/Buddies/_Quit"), "<CTL>Q", do_quit, 0, | |
607 "<StockItem>", GTK_STOCK_QUIT }, | |
1929
d51ea669d84e
[gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1918
diff
changeset
|
608 |
4687 | 609 /* Tools */ |
610 { N_("/_Tools"), NULL, NULL, 0, "<Branch>" }, | |
611 { N_("/Tools/_Away"), NULL, NULL, 0, "<Branch>" }, | |
612 { N_("/Tools/Buddy _Pounce"), NULL, NULL, 0, "<Branch>" }, | |
4834 | 613 { "/Tools/sep1", NULL, NULL, 0, "<Separator>" }, |
4687 | 614 { N_("/Tools/A_ccounts"), "<CTL>A", account_editor, 0, NULL }, |
4694 | 615 { N_("/Tools/Preferences"), "<CTL>P", show_prefs, 0, |
4687 | 616 "<StockItem>", GTK_STOCK_PREFERENCES }, |
4698 | 617 { N_("/Tools/_File Transfers"), NULL, gaim_show_xfer_dialog, 0, |
4687 | 618 "<StockItem>", GTK_STOCK_REVERT_TO_SAVED }, |
4834 | 619 { "/Tools/sep2", NULL, NULL, 0, "<Separator>" }, |
4687 | 620 { N_("/Tools/P_rotocol Actions"), NULL, NULL, 0, "<Branch>" }, |
621 { N_("/Tools/Pr_ivacy"), NULL, show_privacy_options, 0, NULL }, | |
4697 | 622 { N_("/Tools/View System _Log"), NULL, gtk_blist_show_systemlog_cb, 0, NULL }, |
3251 | 623 |
4687 | 624 /* Help */ |
625 { N_("/_Help"), NULL, NULL, 0, "<Branch>" }, | |
4776 | 626 { N_("/Help/Online _Help"), "F1", gtk_blist_show_onlinehelp_cb, 0, |
4687 | 627 "<StockItem>", GTK_STOCK_HELP }, |
4755 | 628 { N_("/Help/_Debug Window"), NULL, toggle_debug, 0, NULL }, |
4687 | 629 { N_("/Help/_About"), NULL, show_about, 0, NULL }, |
630 | |
631 }; | |
1929
d51ea669d84e
[gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1918
diff
changeset
|
632 |
4687 | 633 /********************************************************* |
634 * Private Utility functions * | |
635 *********************************************************/ | |
636 | |
4724 | 637 static char *gaim_get_tooltip_text(struct buddy *b) |
638 { | |
639 char *text = NULL; | |
640 struct prpl* prpl = find_prpl(b->account->protocol); | |
641 char *statustext = NULL; | |
4867 | 642 char *aliastext = NULL, *nicktext = NULL; |
4724 | 643 char *warning = NULL, *idletime = NULL; |
644 | |
645 if (prpl->tooltip_text) { | |
4815 | 646 const char *end; |
4732 | 647 statustext = prpl->tooltip_text(b); |
4815 | 648 |
649 if(statustext && !g_utf8_validate(statustext, -1, &end)) { | |
650 char *new = g_strndup(statustext, | |
651 g_utf8_pointer_to_offset(statustext, end)); | |
652 g_free(statustext); | |
653 statustext = new; | |
654 } | |
4724 | 655 } |
4732 | 656 |
4724 | 657 if (b->idle) { |
658 int ihrs, imin; | |
659 time_t t; | |
660 time(&t); | |
661 ihrs = (t - b->idle) / 3600; | |
662 imin = ((t - b->idle) / 60) % 60; | |
663 if (ihrs) | |
4744 | 664 idletime = g_strdup_printf(_("%dh%02dm"), ihrs, imin); |
4724 | 665 else |
4744 | 666 idletime = g_strdup_printf(_("%dm"), imin); |
4724 | 667 } |
4732 | 668 |
4867 | 669 if(b->alias) |
670 aliastext = g_markup_escape_text(b->alias, -1); | |
671 | |
672 if(b->server_alias) | |
673 nicktext = g_markup_escape_text(b->server_alias, -1); | |
674 | |
4724 | 675 if (b->evil > 0) |
4744 | 676 warning = g_strdup_printf(_("%d%%"), b->evil); |
4732 | 677 |
4724 | 678 text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>" |
4744 | 679 "%s %s" /* Alias */ |
680 "%s %s" /* Nickname */ | |
681 "%s %s" /* Idle */ | |
682 "%s %s" /* Warning */ | |
4741 | 683 "%s%s", /* Status */ |
4724 | 684 b->name, |
4867 | 685 aliastext ? _("\n<b>Alias:</b>") : "", aliastext ? aliastext : "", |
686 nicktext ? _("\n<b>Nickname:</b>") : "", nicktext ? nicktext : "", | |
687 b->idle ? _("\n<b>Idle:</b>") : "", b->idle ? idletime : "", | |
4744 | 688 b->evil ? _("\n<b>Warned:</b>") : "", b->evil ? warning : "", |
4724 | 689 statustext ? "\n" : "", statustext ? statustext : ""); |
4737 | 690 if(warning) |
691 g_free(warning); | |
692 if(idletime) | |
693 g_free(idletime); | |
694 if(statustext) | |
695 g_free(statustext); | |
4867 | 696 if(nicktext) |
697 g_free(nicktext); | |
698 if(aliastext) | |
699 g_free(aliastext); | |
4737 | 700 |
4724 | 701 return text; |
702 | |
703 } | |
704 | |
705 static GdkPixbuf *gaim_gtk_blist_get_status_icon(struct buddy *b, GaimStatusIconSize size) | |
4687 | 706 { |
707 GdkPixbuf *status = NULL; | |
708 GdkPixbuf *scale = NULL; | |
709 GdkPixbuf *emblem = NULL; | |
4737 | 710 gchar *filename = NULL; |
4687 | 711 const char *protoname = NULL; |
1929
d51ea669d84e
[gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1918
diff
changeset
|
712 |
4691 | 713 char *se = NULL, *sw = NULL ,*nw = NULL ,*ne = NULL; |
4737 | 714 |
4687 | 715 int scalesize = 30; |
716 | |
717 struct prpl* prpl = find_prpl(b->account->protocol); | |
718 if (prpl->list_icon) | |
719 protoname = prpl->list_icon(b->account, b); | |
720 if (prpl->list_emblems) | |
721 prpl->list_emblems(b, &se, &sw, &nw, &ne); | |
4737 | 722 |
4724 | 723 if (size == GAIM_STATUS_ICON_SMALL) { |
4687 | 724 scalesize = 15; |
725 sw = nw = ne = NULL; /* So that only the se icon will composite */ | |
1929
d51ea669d84e
[gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1918
diff
changeset
|
726 } |
d51ea669d84e
[gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1918
diff
changeset
|
727 |
4701 | 728 |
4687 | 729 if (b->present == 2) { |
4701 | 730 struct gaim_gtk_blist_node *gtknode; |
4687 | 731 /* If b->present is 2, that means this buddy has just signed on. We use the "login" icon for the |
732 * status, and we set a timeout to change it to a normal icon after 10 seconds. */ | |
733 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL); | |
734 status = gdk_pixbuf_new_from_file(filename,NULL); | |
735 g_free(filename); | |
4701 | 736 |
737 gtknode = GAIM_GTK_BLIST_NODE((GaimBlistNode*)b); | |
4773 | 738 if (gtknode->timer > 0) |
739 g_source_remove(gtknode->timer); | |
4701 | 740 gtknode->timer = g_timeout_add(10000, (GSourceFunc)gaim_reset_present_icon, b); |
741 | |
4737 | 742 /* "Hey, what's all this crap?" you ask. Status icons will be themeable too, and |
4687 | 743 then it will look up protoname from the theme */ |
744 } else { | |
745 char *image = g_strdup_printf("%s.png", protoname); | |
746 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
747 status = gdk_pixbuf_new_from_file(filename,NULL); | |
748 g_free(image); | |
749 g_free(filename); | |
1929
d51ea669d84e
[gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1918
diff
changeset
|
750 |
4687 | 751 } |
4737 | 752 |
4687 | 753 if (!status) |
754 return NULL; | |
4737 | 755 |
4687 | 756 scale = gdk_pixbuf_scale_simple(status, scalesize, scalesize, GDK_INTERP_BILINEAR); |
4737 | 757 |
758 g_object_unref(G_OBJECT(status)); | |
759 | |
4687 | 760 /* Emblems */ |
4737 | 761 |
4687 | 762 /* Each protocol can specify up to four "emblems" to composite over the base icon. "away", "busy", "mobile user" |
763 * are all examples of states represented by emblems. I'm not even really sure I like this yet. */ | |
4737 | 764 |
4687 | 765 /* XXX Clean this crap up, yo. */ |
766 if (se) { | |
767 char *image = g_strdup_printf("%s.png", se); | |
768 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
769 g_free(image); | |
770 emblem = gdk_pixbuf_new_from_file(filename,NULL); | |
771 g_free(filename); | |
772 if (emblem) { | |
4724 | 773 if (size == GAIM_STATUS_ICON_LARGE) |
4687 | 774 gdk_pixbuf_composite (emblem, |
775 scale, 15, 15, | |
776 15, 15, | |
777 15, 15, | |
778 1, 1, | |
779 GDK_INTERP_BILINEAR, | |
780 255); | |
781 else | |
782 gdk_pixbuf_composite (emblem, | |
783 scale, 0, 0, | |
784 15, 15, | |
785 0, 0, | |
786 1, 1, | |
787 GDK_INTERP_BILINEAR, | |
788 255); | |
4737 | 789 g_object_unref(G_OBJECT(emblem)); |
4687 | 790 } |
791 } | |
792 if (sw) { | |
793 char *image = g_strdup_printf("%s.png", sw); | |
794 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
795 g_free(image); | |
796 emblem = gdk_pixbuf_new_from_file(filename,NULL); | |
797 g_free(filename); | |
798 if (emblem) { | |
4737 | 799 gdk_pixbuf_composite (emblem, |
800 scale, 0, 15, | |
801 15, 15, | |
802 0, 15, | |
803 1, 1, | |
804 GDK_INTERP_BILINEAR, | |
805 255); | |
806 g_object_unref(G_OBJECT(emblem)); | |
4687 | 807 } |
808 } | |
809 if (nw) { | |
810 char *image = g_strdup_printf("%s.png", nw); | |
811 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
812 g_free(image); | |
813 emblem = gdk_pixbuf_new_from_file(filename,NULL); | |
814 g_free(filename); | |
815 if (emblem) { | |
816 gdk_pixbuf_composite (emblem, | |
817 scale, 0, 0, | |
818 15, 15, | |
819 0, 0, | |
820 1, 1, | |
821 GDK_INTERP_BILINEAR, | |
822 255); | |
4737 | 823 g_object_unref(G_OBJECT(emblem)); |
4687 | 824 } |
825 } | |
826 if (ne) { | |
827 char *image = g_strdup_printf("%s.png", ne); | |
828 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
829 g_free(image); | |
830 emblem = gdk_pixbuf_new_from_file(filename,NULL); | |
831 g_free(filename); | |
832 if (emblem) { | |
833 gdk_pixbuf_composite (emblem, | |
834 scale, 15, 0, | |
835 15, 15, | |
836 15, 0, | |
837 1, 1, | |
838 GDK_INTERP_BILINEAR, | |
839 255); | |
840 } | |
4737 | 841 } |
4687 | 842 |
4737 | 843 |
4718 | 844 /* Idle grey buddies affects the whole row. This converts the status icon to greyscale. */ |
4699 | 845 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS) |
4687 | 846 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0, FALSE); |
847 return scale; | |
1 | 848 } |
849 | |
4737 | 850 static GdkPixbuf *gaim_gtk_blist_get_buddy_icon(struct buddy *b) |
1 | 851 { |
4687 | 852 /* This just opens a file from ~/.gaim/icons/screenname. This needs to change to be more gooder. */ |
4737 | 853 char *file; |
854 GdkPixbuf *buf, *ret; | |
855 | |
4687 | 856 if (!(blist_options & OPT_BLIST_SHOW_ICONS)) |
857 return NULL; | |
4737 | 858 |
4757 | 859 if ((file = gaim_buddy_get_setting(b, "buddy_icon")) == NULL) |
860 return NULL; | |
861 | |
4737 | 862 buf = gdk_pixbuf_new_from_file(file, NULL); |
863 g_free(file); | |
864 | |
865 | |
4687 | 866 if (buf) { |
4699 | 867 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS) { |
4687 | 868 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0, FALSE); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
869 } |
4737 | 870 ret = gdk_pixbuf_scale_simple(buf,30,30, GDK_INTERP_BILINEAR); |
871 g_object_unref(G_OBJECT(buf)); | |
872 return ret; | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
873 } |
4687 | 874 return NULL; |
2986 | 875 } |
876 | |
4810 | 877 static gchar *gaim_gtk_blist_get_name_markup(struct buddy *b, gboolean selected) |
1 | 878 { |
4687 | 879 char *name = gaim_get_buddy_alias(b); |
880 char *esc = g_markup_escape_text(name, strlen(name)), *text = NULL; | |
4722 | 881 struct prpl* prpl = find_prpl(b->account->protocol); |
882 | |
4687 | 883 /* XXX Clean up this crap */ |
4699 | 884 |
4687 | 885 int ihrs, imin; |
4724 | 886 char *idletime = NULL, *warning = NULL, *statustext = NULL; |
4732 | 887 time_t t; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
888 |
4687 | 889 if (!(blist_options & OPT_BLIST_SHOW_ICONS)) { |
4810 | 890 if (b->idle > 0 && blist_options & OPT_BLIST_GREY_IDLERS && !selected) { |
4718 | 891 text = g_strdup_printf("<span color='dim grey'>%s</span>", |
4699 | 892 esc); |
4687 | 893 g_free(esc); |
894 return text; | |
895 } else { | |
896 return esc; | |
897 } | |
1 | 898 } |
899 | |
4687 | 900 time(&t); |
901 ihrs = (t - b->idle) / 3600; | |
902 imin = ((t - b->idle) / 60) % 60; | |
4699 | 903 |
4722 | 904 if (prpl->status_text) { |
4732 | 905 char *tmp = prpl->status_text(b); |
4815 | 906 const char *end; |
907 | |
908 if(tmp && !g_utf8_validate(tmp, -1, &end)) { | |
909 char *new = g_strndup(tmp, | |
910 g_utf8_pointer_to_offset(tmp, end)); | |
911 g_free(tmp); | |
912 tmp = new; | |
913 } | |
4732 | 914 |
915 if(tmp) { | |
4855 | 916 char buf[32]; |
917 char *c = tmp; | |
918 int length = 0, vis=0; | |
919 gboolean inside = FALSE; | |
4806 | 920 g_strdelimit(tmp, "\n", ' '); |
4852
d1c17e81055e
[gaim-migrate @ 5179]
Christian Hammond <chipx86@chipx86.com>
parents:
4847
diff
changeset
|
921 |
4855 | 922 while(*c && vis < 20) { |
923 if(*c == '&') | |
924 inside = TRUE; | |
4856 | 925 else if(*c == ';') |
926 inside = FALSE; | |
4855 | 927 if(!inside) |
928 vis++; | |
929 length++; | |
930 c++; /* this is fun */ | |
931 } | |
4852
d1c17e81055e
[gaim-migrate @ 5179]
Christian Hammond <chipx86@chipx86.com>
parents:
4847
diff
changeset
|
932 |
4855 | 933 if(vis == 20) |
934 g_snprintf(buf, sizeof(buf), "%%.%ds...", length); | |
935 else | |
936 g_snprintf(buf, sizeof(buf), "%%s "); | |
4852
d1c17e81055e
[gaim-migrate @ 5179]
Christian Hammond <chipx86@chipx86.com>
parents:
4847
diff
changeset
|
937 |
4855 | 938 statustext = g_strdup_printf(buf, tmp); |
4852
d1c17e81055e
[gaim-migrate @ 5179]
Christian Hammond <chipx86@chipx86.com>
parents:
4847
diff
changeset
|
939 |
4732 | 940 g_free(tmp); |
941 } | |
4722 | 942 } |
4732 | 943 |
4687 | 944 if (b->idle) { |
945 if (ihrs) | |
4757 | 946 idletime = g_strdup_printf(_("Idle (%dh%02dm) "), ihrs, imin); |
4687 | 947 else |
4757 | 948 idletime = g_strdup_printf(_("Idle (%dm) "), imin); |
4687 | 949 } |
4757 | 950 |
4687 | 951 if (b->evil > 0) |
4757 | 952 warning = g_strdup_printf(_("Warned (%d%%) "), b->evil); |
953 | |
4810 | 954 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS && !selected) { |
4757 | 955 text = g_strdup_printf("<span color='dim grey'>%s</span>\n<span color='dim grey' size='smaller'>%s%s%s</span>", |
4687 | 956 esc, |
4722 | 957 statustext != NULL ? statustext : "", |
958 idletime != NULL ? idletime : "", | |
959 warning != NULL ? warning : ""); | |
4797 | 960 } else if (statustext == NULL && idletime == NULL && warning == NULL) { |
961 text = g_strdup_printf("%s", esc); | |
962 } else { | |
4810 | 963 text = g_strdup_printf("%s\n<span %s size='smaller'>%s%s%s</span>", esc, |
964 selected ? "" : "color='dim grey'", | |
965 statustext != NULL ? statustext : "", | |
966 idletime != NULL ? idletime : "", | |
967 warning != NULL ? warning : ""); | |
4797 | 968 } |
4722 | 969 if (idletime) |
4687 | 970 g_free(idletime); |
4722 | 971 if (warning) |
4687 | 972 g_free(warning); |
4722 | 973 if (statustext) |
974 g_free(statustext); | |
4737 | 975 if (esc) |
976 g_free(esc); | |
4699 | 977 |
4687 | 978 return text; |
979 } | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
980 |
4840 | 981 static void gaim_gtk_blist_restore_position() |
982 { | |
983 /* if the window exists, is hidden, we're saving positions, and the position is sane... */ | |
984 if(gtkblist && gtkblist->window && | |
985 !GTK_WIDGET_VISIBLE(gtkblist->window) && | |
986 blist_options & OPT_BLIST_SAVED_WINDOWS && | |
987 blist_pos.width != 0) { | |
988 /* ...check position is on screen... */ | |
989 if (blist_pos.x >= gdk_screen_width()) | |
990 blist_pos.x = gdk_screen_width() - 100; | |
991 else if (blist_pos.x < 0) | |
992 blist_pos.x = 100; | |
993 | |
994 if (blist_pos.y >= gdk_screen_height()) | |
995 blist_pos.y = gdk_screen_height() - 100; | |
996 else if (blist_pos.y < 0) | |
997 blist_pos.y = 100; | |
998 | |
999 /* ...and move it back. */ | |
1000 gtk_window_move(GTK_WINDOW(gtkblist->window), blist_pos.x, blist_pos.y); | |
1001 gtk_window_resize(GTK_WINDOW(gtkblist->window), blist_pos.width, blist_pos.height); | |
1002 } | |
1003 } | |
1004 | |
1005 | |
4687 | 1006 /********************************************************************************** |
1007 * Public API Functions * | |
1008 **********************************************************************************/ | |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1009 static void gaim_gtk_blist_new_list(struct gaim_buddy_list *blist) |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1010 { |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1011 blist->ui_data = g_new0(struct gaim_gtk_buddy_list, 1); |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1012 } |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1013 |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1014 static void gaim_gtk_blist_new_node(GaimBlistNode *node) |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1015 { |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1016 node->ui_data = g_new0(struct gaim_gtk_blist_node, 1); |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1017 } |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1018 |
4729 | 1019 void gaim_gtk_blist_update_columns() |
1020 { | |
1021 if (blist_options & OPT_BLIST_SHOW_ICONS) { | |
1022 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, TRUE); | |
1023 gtk_tree_view_column_set_visible(gtkblist->idle_column, FALSE); | |
1024 gtk_tree_view_column_set_visible(gtkblist->warning_column, FALSE); | |
1025 } else { | |
1026 gtk_tree_view_column_set_visible(gtkblist->idle_column, blist_options & OPT_BLIST_SHOW_IDLETIME); | |
1027 gtk_tree_view_column_set_visible(gtkblist->warning_column, blist_options & OPT_BLIST_SHOW_WARN); | |
1028 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, FALSE); | |
1029 } | |
1030 } | |
1031 | |
4702 | 1032 enum {DRAG_BUDDY, DRAG_ROW}; |
1033 | |
4834 | 1034 static char * |
1035 item_factory_translate_func (const char *path, gpointer func_data) | |
1036 { | |
1037 return _(path); | |
1038 } | |
1039 | |
4687 | 1040 static void gaim_gtk_blist_show(struct gaim_buddy_list *list) |
1041 { | |
1042 GtkItemFactory *ift; | |
1043 GtkCellRenderer *rend; | |
1044 GtkTreeViewColumn *column; | |
1045 GtkWidget *sw; | |
1046 GtkWidget *button; | |
4694 | 1047 GtkSizeGroup *sg; |
4810 | 1048 GtkTreeSelection *selection; |
4781 | 1049 GtkTargetEntry gte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, |
4702 | 1050 {"application/x-im-contact", 0, DRAG_BUDDY}}; |
4690 | 1051 |
4745 | 1052 if (gtkblist && gtkblist->window) { |
4687 | 1053 gtk_widget_show(gtkblist->window); |
1054 return; | |
1055 } | |
4690 | 1056 |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1057 gtkblist = GAIM_GTK_BLIST(list); |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1058 |
4687 | 1059 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
4840 | 1060 gtk_window_set_gravity(GTK_WINDOW(gtkblist->window), GDK_GRAVITY_NORTH_WEST); |
1061 gtk_window_set_role(GTK_WINDOW(gtkblist->window), "buddy_list"); | |
4687 | 1062 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List")); |
4879
4f5bd9a2da37
[gaim-migrate @ 5209]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4867
diff
changeset
|
1063 gtk_widget_realize(gtkblist->window); |
4690 | 1064 |
4687 | 1065 gtkblist->vbox = gtk_vbox_new(FALSE, 6); |
1066 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox); | |
1 | 1067 |
4840 | 1068 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL); |
1069 g_signal_connect(G_OBJECT(gtkblist->window), "configure_event", G_CALLBACK(gtk_blist_configure_cb), NULL); | |
1070 g_signal_connect(G_OBJECT(gtkblist->window), "visibility_notify_event", G_CALLBACK(gtk_blist_visibility_cb), NULL); | |
1071 gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK); | |
4698 | 1072 |
4687 | 1073 /******************************* Menu bar *************************************/ |
1074 ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", NULL); | |
4834 | 1075 gtk_item_factory_set_translate_func (ift, |
1076 item_factory_translate_func, | |
1077 NULL, NULL); | |
4687 | 1078 gtk_item_factory_create_items(ift, sizeof(blist_menu) / sizeof(*blist_menu), |
1079 blist_menu, NULL); | |
1080 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtk_item_factory_get_widget(ift, "<GaimMain>"), FALSE, FALSE, 0); | |
1 | 1081 |
4834 | 1082 awaymenu = gtk_item_factory_get_widget(ift, N_("/Tools/Away")); |
4694 | 1083 do_away_menu(); |
1084 | |
4834 | 1085 bpmenu = gtk_item_factory_get_widget(ift, N_("/Tools/Buddy Pounce")); |
4696 | 1086 do_bp_menu(); |
1087 | |
4834 | 1088 protomenu = gtk_item_factory_get_widget(ift, N_("/Tools/Protocol Actions")); |
4696 | 1089 do_proto_menu(); |
1090 | |
4687 | 1091 /****************************** GtkTreeView **********************************/ |
1092 sw = gtk_scrolled_window_new(NULL,NULL); | |
1093 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); | |
1094 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
1095 | |
4847 | 1096 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
4687 | 1097 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER); |
4702 | 1098 |
4687 | 1099 gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel)); |
4704 | 1100 |
4810 | 1101 /* Set up selection stuff */ |
1102 | |
1103 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview)); | |
1104 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL); | |
1105 | |
1106 | |
4702 | 1107 /* Set up dnd */ |
1108 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), GDK_BUTTON1_MASK, gte, | |
1109 2, GDK_ACTION_COPY); | |
4704 | 1110 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), gte, 2, |
4702 | 1111 GDK_ACTION_COPY | GDK_ACTION_MOVE); |
4704 | 1112 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL); |
1113 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL); | |
1114 | |
4724 | 1115 /* Tooltips */ |
1116 g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL); | |
1117 g_signal_connect(G_OBJECT(gtkblist->treeview), "leave-notify-event", G_CALLBACK(gaim_gtk_blist_leave_cb), NULL); | |
4687 | 1118 |
1119 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE); | |
1 | 1120 |
4687 | 1121 rend = gtk_cell_renderer_pixbuf_new(); |
1122 column = gtk_tree_view_column_new_with_attributes("Status", rend, "pixbuf", STATUS_ICON_COLUMN, NULL); | |
1123 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); | |
4796 | 1124 g_object_set(rend, "ypad", 0, NULL); |
4706 | 1125 |
4687 | 1126 rend = gtk_cell_renderer_text_new(); |
1127 column = gtk_tree_view_column_new_with_attributes("Name", rend, "markup", NAME_COLUMN, NULL); | |
1128 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column); | |
4797 | 1129 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); |
4706 | 1130 |
4687 | 1131 rend = gtk_cell_renderer_text_new(); |
4725 | 1132 gtkblist->warning_column = gtk_tree_view_column_new_with_attributes("Warning", rend, "markup", WARNING_COLUMN, NULL); |
1133 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->warning_column); | |
4796 | 1134 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
4687 | 1135 |
1136 rend = gtk_cell_renderer_text_new(); | |
4725 | 1137 gtkblist->idle_column = gtk_tree_view_column_new_with_attributes("Idle", rend, "markup", IDLE_COLUMN, NULL); |
1138 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->idle_column); | |
4796 | 1139 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
1 | 1140 |
4687 | 1141 rend = gtk_cell_renderer_pixbuf_new(); |
4725 | 1142 gtkblist->buddy_icon_column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL); |
4796 | 1143 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL); |
4725 | 1144 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->buddy_icon_column); |
4718 | 1145 |
4687 | 1146 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL); |
1147 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
1148 |
4687 | 1149 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); |
1150 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); | |
4725 | 1151 gaim_gtk_blist_update_columns(); |
4687 | 1152 /**************************** Button Box **************************************/ |
4694 | 1153 |
1154 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4687 | 1155 gtkblist->bbox = gtk_hbox_new(TRUE, 0); |
1156 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->bbox, FALSE, FALSE, 0); | |
1157 button = gaim_pixbuf_button_from_stock(_("IM"), GAIM_STOCK_IM, GAIM_BUTTON_VERTICAL); | |
1158 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0); | |
1159 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4694 | 1160 gtk_size_group_add_widget(sg, button); |
4692 | 1161 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_im_cb), |
4697 | 1162 gtkblist->treeview); |
1163 | |
4687 | 1164 button = gaim_pixbuf_button_from_stock(_("Get Info"), GAIM_STOCK_INFO, GAIM_BUTTON_VERTICAL); |
1165 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0); | |
1166 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4694 | 1167 gtk_size_group_add_widget(sg, button); |
1168 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_info_cb), | |
4697 | 1169 gtkblist->treeview); |
4729 | 1170 |
4687 | 1171 button = gaim_pixbuf_button_from_stock(_("Chat"), GAIM_STOCK_CHAT, GAIM_BUTTON_VERTICAL); |
1172 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0); | |
1173 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4694 | 1174 gtk_size_group_add_widget(sg, button); |
1175 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_chat_cb), NULL); | |
1176 | |
4687 | 1177 button = gaim_pixbuf_button_from_stock(_("Away"), GAIM_STOCK_AWAY, GAIM_BUTTON_VERTICAL); |
1178 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0); | |
1179 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4694 | 1180 gtk_size_group_add_widget(sg, button); |
1181 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_away_cb), NULL); | |
4687 | 1182 |
1183 /* OK... let's show this bad boy. */ | |
1184 gaim_gtk_blist_refresh(list); | |
4840 | 1185 gaim_gtk_blist_restore_position(); |
4687 | 1186 gtk_widget_show_all(gtkblist->window); |
4729 | 1187 |
4697 | 1188 gaim_gtk_blist_update_toolbar(); |
1189 | |
4687 | 1190 } |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
1191 |
4687 | 1192 void gaim_gtk_blist_refresh(struct gaim_buddy_list *list) |
1193 { | |
1194 GaimBlistNode *group = list->root; | |
1195 GaimBlistNode *buddy; | |
4690 | 1196 |
4687 | 1197 while (group) { |
1198 gaim_gtk_blist_update(list, group); | |
1199 buddy = group->child; | |
1200 while (buddy) { | |
4699 | 1201 gaim_gtk_blist_update(list, buddy); |
4687 | 1202 buddy = buddy->next; |
1203 } | |
1204 group = group->next; | |
1205 } | |
1206 } | |
1 | 1207 |
4699 | 1208 static gboolean get_iter_from_node_helper(GaimBlistNode *node, GtkTreeIter *iter, GtkTreeIter *root) { |
4867 | 1209 |
4699 | 1210 do { |
1211 GaimBlistNode *n; | |
1212 GtkTreeIter child; | |
1213 | |
1214 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), root, NODE_COLUMN, &n, -1); | |
1215 if(n == node) { | |
1216 *iter = *root; | |
1217 return TRUE; | |
1218 } | |
1219 | |
1220 if(gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &child, root)) { | |
1221 if(get_iter_from_node_helper(node,iter,&child)) | |
1222 return TRUE; | |
1223 } | |
1224 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), root)); | |
1225 | |
1226 return FALSE; | |
1227 } | |
1228 | |
1229 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) { | |
1230 GtkTreeIter root; | |
1231 | |
1232 if (!gtkblist) | |
1233 return FALSE; | |
1234 | |
1235 if(!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(gtkblist->treemodel), &root)) | |
1236 return FALSE; | |
1237 | |
1238 return get_iter_from_node_helper(node, iter, &root); | |
1239 } | |
1240 | |
4697 | 1241 void gaim_gtk_blist_update_toolbar() { |
1242 if (!gtkblist) | |
1243 return; | |
4699 | 1244 |
4697 | 1245 gtk_container_foreach(GTK_CONTAINER(gtkblist->bbox), gaim_gtk_blist_update_toolbar_icons, NULL); |
4699 | 1246 |
4697 | 1247 if (blist_options & OPT_BLIST_NO_BUTTONS) |
1248 gtk_widget_hide(gtkblist->bbox); | |
1249 else | |
1250 gtk_widget_show_all(gtkblist->bbox); | |
1251 } | |
1252 | |
4701 | 1253 static void gaim_gtk_blist_remove(struct gaim_buddy_list *list, GaimBlistNode *node) |
1254 { | |
1255 struct gaim_gtk_blist_node *gtknode; | |
1256 GtkTreeIter iter; | |
1257 | |
1258 if (!node->ui_data) | |
1259 return; | |
1260 | |
1261 gtknode = (struct gaim_gtk_blist_node *)node->ui_data; | |
1262 | |
1263 if (gtknode->timer > 0) { | |
1264 g_source_remove(gtknode->timer); | |
1265 gtknode->timer = 0; | |
1266 } | |
1267 | |
4912 | 1268 /* For some reason, we're called before we have a buddy list sometimes */ |
1269 if(!gtkblist) | |
1270 return; | |
1271 | |
4831 | 1272 if(gtkblist->selected_node == node) |
1273 gtkblist->selected_node = NULL; | |
1274 | |
4701 | 1275 if (get_iter_from_node(node, &iter)) { |
1276 gtk_tree_store_remove(gtkblist->treemodel, &iter); | |
1277 if(GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_blist_get_group_online_count((struct group *)node->parent) == 0) { | |
1278 GtkTreeIter groupiter; | |
1279 if(get_iter_from_node(node->parent, &groupiter)) | |
1280 gtk_tree_store_remove(gtkblist->treemodel, &groupiter); | |
1281 } | |
1282 } | |
1283 } | |
1284 | |
4810 | 1285 static gboolean do_selection_changed(GaimBlistNode *new_selection) |
1286 { | |
1287 GaimBlistNode *old_selection = gtkblist->selected_node; | |
1288 | |
1289 if(new_selection != gtkblist->selected_node) { | |
1290 gtkblist->selected_node = new_selection; | |
1291 if(new_selection) | |
1292 gaim_gtk_blist_update(NULL, new_selection); | |
1293 if(old_selection) | |
1294 gaim_gtk_blist_update(NULL, old_selection); | |
1295 } | |
1296 | |
1297 return FALSE; | |
1298 } | |
1299 | |
1300 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data) | |
1301 { | |
1302 GaimBlistNode *new_selection = NULL; | |
1303 GtkTreeIter iter; | |
1304 | |
1305 if(gtk_tree_selection_get_selected(selection, NULL, &iter)){ | |
1306 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, | |
1307 NODE_COLUMN, &new_selection, -1); | |
1308 } | |
1309 /* we set this up as a timeout, otherwise the blist flickers */ | |
1310 g_timeout_add(0, (GSourceFunc)do_selection_changed, new_selection); | |
1311 } | |
1312 | |
4701 | 1313 |
4687 | 1314 static void gaim_gtk_blist_update(struct gaim_buddy_list *list, GaimBlistNode *node) |
1315 { | |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1316 struct gaim_gtk_blist_node *gtknode; |
4699 | 1317 GtkTreeIter iter; |
4687 | 1318 gboolean expand = FALSE; |
4699 | 1319 gboolean new_entry = FALSE; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
1320 |
4687 | 1321 if (!gtkblist) |
1322 return; | |
4699 | 1323 |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1324 gtknode = GAIM_GTK_BLIST_NODE(node); |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1325 |
4690 | 1326 |
4699 | 1327 if (!get_iter_from_node(node, &iter)) { /* This is a newly added node */ |
1328 new_entry = TRUE; | |
4687 | 1329 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
1330 if (((struct buddy*)node)->present) { | |
4699 | 1331 GtkTreeIter groupiter; |
1332 GaimBlistNode *oldersibling; | |
1333 GtkTreeIter oldersiblingiter; | |
4690 | 1334 |
4699 | 1335 if(node->parent && !get_iter_from_node(node->parent, &groupiter)) { |
1336 /* This buddy's group has not yet been added. We do that here */ | |
4757 | 1337 GdkPixbuf *groupicon = gtk_widget_render_icon(gtkblist->treeview, |
1338 GTK_STOCK_OPEN, GTK_ICON_SIZE_SMALL_TOOLBAR, NULL); | |
4794 | 1339 char *esc = g_markup_escape_text(((struct group*)node->parent)->name, -1); |
1340 char *mark = g_strdup_printf("<span weight='bold'>%s</span>", esc); | |
1341 g_free(esc); | |
4699 | 1342 oldersibling = node->parent->prev; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
1343 |
4687 | 1344 /* We traverse backwards through the buddy list to find the node in the tree to insert it after */ |
4699 | 1345 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter)) |
1346 oldersibling = oldersibling->prev; | |
4690 | 1347 |
4687 | 1348 /* This is where we create the node and add it. */ |
4699 | 1349 gtk_tree_store_insert_after(gtkblist->treemodel, &groupiter, NULL, oldersibling ? &oldersiblingiter : NULL); |
1350 gtk_tree_store_set(gtkblist->treemodel, &groupiter, | |
4757 | 1351 STATUS_ICON_COLUMN, groupicon, |
4687 | 1352 NAME_COLUMN, mark, |
1353 NODE_COLUMN, node->parent, | |
1354 -1); | |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1355 |
4737 | 1356 g_free(mark); |
4757 | 1357 g_object_unref(G_OBJECT(groupicon)); |
4737 | 1358 |
4687 | 1359 expand = TRUE; |
1360 } | |
4810 | 1361 |
4699 | 1362 oldersibling = node->prev; |
4867 | 1363 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter)) { |
4699 | 1364 oldersibling = oldersibling->prev; |
4867 | 1365 } |
4699 | 1366 |
1367 gtk_tree_store_insert_after(gtkblist->treemodel, &iter, &groupiter, oldersibling ? &oldersiblingiter : NULL); | |
4810 | 1368 |
4767 | 1369 if (blist_options & OPT_BLIST_POPUP) |
1370 gtk_window_present(GTK_WINDOW(gtkblist->window)); | |
4699 | 1371 |
4687 | 1372 if (expand) { /* expand was set to true if this is the first element added to a group. In such case |
1373 * we expand the group node */ | |
4699 | 1374 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter); |
1375 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), path, TRUE); | |
4721 | 1376 gtk_tree_path_free(path); |
4687 | 1377 } |
4699 | 1378 } |
1379 } | |
1380 } | |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1381 |
4687 | 1382 if (GAIM_BLIST_NODE_IS_BUDDY(node) && ((struct buddy*)node)->present) { |
1383 GdkPixbuf *status, *avatar; | |
1384 char *mark; | |
4697 | 1385 char *warning = NULL, *idle = NULL; |
1386 | |
4810 | 1387 gboolean selected = (gtkblist->selected_node == node); |
1388 | |
1389 status = gaim_gtk_blist_get_status_icon((struct buddy*)node, | |
4724 | 1390 blist_options & OPT_BLIST_SHOW_ICONS ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL); |
4687 | 1391 avatar = gaim_gtk_blist_get_buddy_icon((struct buddy*)node); |
4810 | 1392 mark = gaim_gtk_blist_get_name_markup((struct buddy*)node, selected); |
4697 | 1393 |
4725 | 1394 if (((struct buddy*)node)->idle > 0) { |
4697 | 1395 time_t t; |
1396 int ihrs, imin; | |
1397 time(&t); | |
1398 ihrs = (t - ((struct buddy *)node)->idle) / 3600; | |
1399 imin = ((t - ((struct buddy*)node)->idle) / 60) % 60; | |
4718 | 1400 if(ihrs > 0) |
1401 idle = g_strdup_printf("(%d:%02d)", ihrs, imin); | |
1402 else | |
1403 idle = g_strdup_printf("(%d)", imin); | |
4697 | 1404 } |
1405 | |
4725 | 1406 if (((struct buddy*)node)->evil > 0) |
4699 | 1407 warning = g_strdup_printf("%d%%", ((struct buddy*)node)->evil); |
4810 | 1408 |
4697 | 1409 |
4718 | 1410 if((blist_options & OPT_BLIST_GREY_IDLERS) |
1411 && ((struct buddy *)node)->idle) { | |
4810 | 1412 if(warning && !selected) { |
4718 | 1413 char *w2 = g_strdup_printf("<span color='dim grey'>%s</span>", |
1414 warning); | |
1415 g_free(warning); | |
1416 warning = w2; | |
1417 } | |
1418 | |
4810 | 1419 if(idle && !selected) { |
4718 | 1420 char *i2 = g_strdup_printf("<span color='dim grey'>%s</span>", |
1421 idle); | |
1422 g_free(idle); | |
1423 idle = i2; | |
1424 } | |
1425 } | |
1426 | |
1427 | |
4699 | 1428 gtk_tree_store_set(gtkblist->treemodel, &iter, |
4687 | 1429 STATUS_ICON_COLUMN, status, |
1430 NAME_COLUMN, mark, | |
4697 | 1431 WARNING_COLUMN, warning, |
1432 IDLE_COLUMN, idle, | |
4699 | 1433 BUDDY_ICON_COLUMN, avatar, |
4687 | 1434 NODE_COLUMN, node, |
1435 -1); | |
4699 | 1436 |
4687 | 1437 g_free(mark); |
4697 | 1438 if (idle) |
1439 g_free(idle); | |
1440 if (warning) | |
1441 g_free(warning); | |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1442 |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1443 if (status != NULL) |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1444 g_object_unref(status); |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1445 |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1446 if (avatar != NULL) |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1447 g_object_unref(avatar); |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1448 |
4701 | 1449 } else if (GAIM_BLIST_NODE_IS_BUDDY(node) && !new_entry) { |
1450 gaim_gtk_blist_remove(list, node); | |
4767 | 1451 if (blist_options & OPT_BLIST_POPUP) |
1452 gtk_window_present(GTK_WINDOW(gtkblist->window)); | |
4781 | 1453 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
1454 GaimBlistNode *afsad = node->child; | |
1455 while (afsad) { | |
1456 gaim_gtk_blist_update(list, afsad); | |
1457 afsad = afsad->next; | |
1458 } | |
4687 | 1459 } |
4786 | 1460 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview)); |
4687 | 1461 } |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
1462 |
4687 | 1463 static void gaim_gtk_blist_destroy(struct gaim_buddy_list *list) |
1464 { | |
4770 | 1465 if (!gtkblist) |
1466 return; | |
4687 | 1467 gtk_widget_destroy(gtkblist->window); |
4745 | 1468 |
1469 gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL; | |
1470 gtkblist->treemodel = NULL; | |
1471 gtkblist->idle_column = NULL; | |
1472 gtkblist->warning_column = gtkblist->buddy_icon_column = NULL; | |
1473 gtkblist->bbox = gtkblist->tipwindow = NULL; | |
1474 protomenu = NULL; | |
1475 awaymenu = NULL; | |
1476 bpmenu = NULL; | |
1477 | |
1478 gtkblist->timeout = 0; | |
4687 | 1479 } |
1 | 1480 |
4687 | 1481 static void gaim_gtk_blist_set_visible(struct gaim_buddy_list *list, gboolean show) |
1482 { | |
4840 | 1483 if (!(gtkblist && gtkblist->window)) |
1484 return; | |
1485 | |
4698 | 1486 if (show) { |
4840 | 1487 gaim_gtk_blist_restore_position(); |
4699 | 1488 gtk_window_present(GTK_WINDOW(gtkblist->window)); |
4698 | 1489 } else { |
1490 if (!connections || docklet_count) { | |
1491 #ifdef _WIN32 | |
4711
0c1f3e651d3e
[gaim-migrate @ 5022]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4706
diff
changeset
|
1492 wgaim_systray_minimize(gtkblist->window); |
4698 | 1493 #endif |
1494 gtk_widget_hide(gtkblist->window); | |
1495 } else { | |
1496 gtk_window_iconify(GTK_WINDOW(gtkblist->window)); | |
1497 } | |
1498 } | |
1499 } | |
1500 | |
1501 void gaim_gtk_blist_docklet_toggle() { | |
1502 /* Useful for the docklet plugin and also for the win32 tray icon*/ | |
1503 /* This is called when one of those is clicked--it will show/hide the | |
1504 buddy list/login window--depending on which is active */ | |
4840 | 1505 if (connections) { |
1506 if (gtkblist && gtkblist->window) { | |
1507 if (GTK_WIDGET_VISIBLE(gtkblist->window)) { | |
1508 gaim_blist_set_visible(GAIM_WINDOW_ICONIFIED(gtkblist->window) || gaim_gtk_blist_obscured); | |
1509 } else { | |
4698 | 1510 #if _WIN32 |
4840 | 1511 wgaim_systray_maximize(gtkblist->window); |
4698 | 1512 #endif |
4840 | 1513 gaim_blist_set_visible(TRUE); |
1514 } | |
1515 } else { | |
1516 /* we're logging in or something... do nothing */ | |
1517 /* or should I make the blist? */ | |
1518 debug_printf("docklet_toggle called with connections but no blist!\n"); | |
4698 | 1519 } |
4840 | 1520 } else if (mainwindow) { |
1521 if (GTK_WIDGET_VISIBLE(mainwindow)) { | |
4698 | 1522 if (GAIM_WINDOW_ICONIFIED(mainwindow)) { |
1523 gtk_window_present(GTK_WINDOW(mainwindow)); | |
1524 } else { | |
1525 #if _WIN32 | |
1526 wgaim_systray_minimize(mainwindow); | |
1527 #endif | |
1528 gtk_widget_hide(mainwindow); | |
1529 } | |
1530 } else { | |
1531 #if _WIN32 | |
1532 wgaim_systray_maximize(mainwindow); | |
1533 #endif | |
4833 | 1534 show_login(); |
4698 | 1535 } |
4840 | 1536 } else { |
1537 show_login(); | |
4698 | 1538 } |
1539 } | |
1540 | |
1541 void gaim_gtk_blist_docklet_add() | |
1542 { | |
1543 docklet_count++; | |
1544 } | |
1545 | |
1546 void gaim_gtk_blist_docklet_remove() | |
1547 { | |
1548 docklet_count--; | |
1549 if (!docklet_count) { | |
1550 if (connections) { | |
1551 gaim_blist_set_visible(TRUE); | |
4840 | 1552 } else if (mainwindow) { |
1553 gtk_window_present(GTK_WINDOW(mainwindow)); | |
1554 } else { | |
1555 show_login(); | |
4698 | 1556 } |
1557 } | |
4687 | 1558 } |
1 | 1559 |
4687 | 1560 static struct gaim_blist_ui_ops blist_ui_ops = |
1561 { | |
4695
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1562 gaim_gtk_blist_new_list, |
4bdd9a5fd026
[gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents:
4694
diff
changeset
|
1563 gaim_gtk_blist_new_node, |
4687 | 1564 gaim_gtk_blist_show, |
1565 gaim_gtk_blist_update, | |
1566 gaim_gtk_blist_remove, | |
1567 gaim_gtk_blist_destroy, | |
1568 gaim_gtk_blist_set_visible | |
1569 }; | |
1 | 1570 |
1571 | |
4687 | 1572 struct gaim_blist_ui_ops *gaim_get_gtk_blist_ui_ops() |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
1573 { |
4687 | 1574 return &blist_ui_ops; |
1037
1c663beef29d
[gaim-migrate @ 1047]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1036
diff
changeset
|
1575 } |
1c663beef29d
[gaim-migrate @ 1047]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1036
diff
changeset
|
1576 |
3131 | 1577 |
1578 | |
4687 | 1579 /********************************************************************* |
1580 * Public utility functions * | |
1581 *********************************************************************/ | |
1058
4927ce25d8cc
[gaim-migrate @ 1068]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
1582 |
4687 | 1583 GdkPixbuf * |
1584 create_prpl_icon(struct gaim_account *account) | |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4525
diff
changeset
|
1585 { |
4687 | 1586 struct prpl *prpl = find_prpl(account->protocol); |
1587 GdkPixbuf *status = NULL; | |
1588 char *filename = NULL; | |
1589 const char *protoname = prpl->list_icon(account, NULL); | |
1590 /* "Hey, what's all this crap?" you ask. Status icons will be themeable too, and | |
1591 then it will look up protoname from the theme */ | |
1592 if (!strcmp(protoname, "aim")) { | |
1593 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "aim.png", NULL); | |
1594 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1595 g_free(filename); | |
1596 } else if (!strcmp(protoname, "yahoo")) { | |
1597 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "yahoo.png", NULL); | |
1598 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1599 g_free(filename); | |
1600 } else if (!strcmp(protoname, "msn")) { | |
1601 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "msn.png", NULL); | |
1602 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1603 g_free(filename); | |
1604 } else if (!strcmp(protoname, "jabber")) { | |
1605 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "jabber.png", NULL); | |
1606 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1607 g_free(filename); | |
1608 } else if (!strcmp(protoname, "icq")) { | |
1609 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "icq.png", NULL); | |
1610 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1611 g_free(filename); | |
1612 } else if (!strcmp(protoname, "gadu-gadu")) { | |
1613 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "gadugadu.png", NULL); | |
1614 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1615 g_free(filename); | |
1616 } else if (!strcmp(protoname, "napster")) { | |
1617 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "napster.png", NULL); | |
1618 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1619 g_free(filename); | |
1620 } else if (!strcmp(protoname, "irc")) { | |
1621 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "irc.png", NULL); | |
1622 status = gdk_pixbuf_new_from_file(filename,NULL); | |
1623 g_free(filename); | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
945
diff
changeset
|
1624 } |
4687 | 1625 return status; |
1 | 1626 } |
4699 | 1627 |