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