annotate src/gtkblist.c @ 5381:aa1cf48f76eb

[gaim-migrate @ 5757] Correct me if I'm wrong, but I don't think we want to call list_emblems if the user is offline? committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 15 May 2003 19:29:07 +0000
parents c4e7a079cc04
children 965c339fd74c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /*
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * gaim
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * (at your option) any later version.
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * GNU General Public License for more details.
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include <config.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #ifdef GAIM_PLUGINS
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #ifndef _WIN32
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #include <dlfcn.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 #endif /* GAIM_PLUGINS */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 #include <string.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 #include <stdio.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 #include <stdlib.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #include <ctype.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 #include <math.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 #include <time.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 #include <ctype.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 #ifdef _WIN32
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 #include <gdk/gdkwin32.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 #else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 #include <unistd.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 #include <gdk/gdkx.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 #include <gdk/gdkkeysyms.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 #include <gtk/gtk.h>
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 #include "prpl.h"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 #include "sound.h"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 #include "gaim.h"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 #include "gtkblist.h"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 #include "gtkpounce.h"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 #include "gtkft.h"
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
53 #include "gtkdebug.h"
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 #ifdef _WIN32
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 #include "win32dep.h"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 static struct gaim_gtk_buddy_list *gtkblist = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 /* part of the best damn Docklet code this side of Tahiti */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 static gboolean gaim_gtk_blist_obscured = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 static void gaim_gtk_blist_update(struct gaim_buddy_list *list, GaimBlistNode *node);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
66 static char *gaim_get_tooltip_text(GaimBlistNode *node);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 static char *item_factory_translate_func (const char *path, gpointer func_data);
5273
2e1238f4b4e3 [gaim-migrate @ 5645]
Nathan Walp <nwalp@pidgin.im>
parents: 5263
diff changeset
68 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
70 struct _gaim_gtk_blist_node {
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
71 GtkTreeRowReference *row;
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
72 };
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
73
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 /***************************************************
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 * Callbacks *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 ***************************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 static gboolean gtk_blist_delete_cb(GtkWidget *w, GdkEventAny *event, gpointer data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 if (docklet_count)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 gaim_blist_set_visible(FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 do_quit();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 /* we handle everything, event should not propogate further */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 return TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 static gboolean gtk_blist_save_prefs_cb(gpointer data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 save_prefs();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 /* only run once */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 static gboolean gtk_blist_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 /* unfortunately GdkEventConfigure ignores the window gravity, but *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 * the only way we have of setting the position doesn't. we have to *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 * call get_position and get_size because they do pay attention to *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 * the gravity. this is inefficient and I agree it sucks, but it's *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 * more likely to work correctly. - Robot101 */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 gint x, y;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 /* check for visibility because when we aren't visible, this will *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 * give us bogus (0,0) coordinates. - xOr */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 if (GTK_WIDGET_VISIBLE(w)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 gtk_window_get_position(GTK_WINDOW(w), &x, &y);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 if (x != blist_pos.x ||
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 y != blist_pos.y ||
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 event->width != blist_pos.width ||
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 event->height != blist_pos.height) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 blist_pos.x = x;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 blist_pos.y = y;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 blist_pos.width = event->width;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 blist_pos.height = event->height;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 if (!g_main_context_find_source_by_user_data(NULL, &gtk_blist_save_prefs_cb)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 g_timeout_add(5000, gtk_blist_save_prefs_cb, &gtk_blist_save_prefs_cb);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 /* continue to handle event normally */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 static gboolean gtk_blist_visibility_cb(GtkWidget *w, GdkEventVisibility *event, gpointer data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 if (event->state == GDK_VISIBILITY_FULLY_OBSCURED)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 gaim_gtk_blist_obscured = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 gaim_gtk_blist_obscured = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 /* continue to handle event normally */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 static void gtk_blist_menu_info_cb(GtkWidget *w, struct buddy *b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 serv_get_info(b->account->gc, b->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 static void gtk_blist_menu_im_cb(GtkWidget *w, struct buddy *b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
148 gaim_conversation_new(GAIM_CONV_IM, b->account, b->name);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
151 static void gtk_blist_menu_join_cb(GtkWidget *w, struct chat *chat)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
153 serv_join_chat(chat->account->gc, chat->components);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
154 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
155
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
156 static void gtk_blist_menu_alias_cb(GtkWidget *w, GaimBlistNode *node)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
157 {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
158 if(GAIM_BLIST_NODE_IS_BUDDY(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
159 alias_dialog_bud((struct buddy*)node);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
160 else if(GAIM_BLIST_NODE_IS_CHAT(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
161 alias_dialog_chat((struct chat*)node);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 static void gtk_blist_menu_bp_cb(GtkWidget *w, struct buddy *b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 gaim_gtkpounce_dialog_show(b, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 static void gtk_blist_menu_showlog_cb(GtkWidget *w, struct buddy *b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
171 show_log(b->name);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 static void gtk_blist_show_systemlog_cb()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
176 show_log(NULL);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 static void gtk_blist_show_onlinehelp_cb()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
181 open_url(NULL, WEBSITE "documentation.php");
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 static void gtk_blist_button_im_cb(GtkWidget *w, GtkTreeView *tv)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 GtkTreeModel *model = gtk_tree_view_get_model(tv);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 GtkTreeSelection *sel = gtk_tree_view_get_selection(tv);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 if(gtk_tree_selection_get_selected(sel, &model, &iter)){
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)node)->account, ((struct buddy*)node)->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 show_im_dialog();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 static void gtk_blist_button_info_cb(GtkWidget *w, GtkTreeView *tv)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 GtkTreeModel *model = gtk_tree_view_get_model(tv);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 GtkTreeSelection *sel = gtk_tree_view_get_selection(tv);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 if(gtk_tree_selection_get_selected(sel, &model, &iter)){
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 serv_get_info(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 show_info_dialog();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
220 static void gtk_blist_button_chat_cb(GtkWidget *w, GtkTreeView *tv)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
222 GtkTreeIter iter;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
223 GtkTreeModel *model = gtk_tree_view_get_model(tv);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
224 GtkTreeSelection *sel = gtk_tree_view_get_selection(tv);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
225
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
226 if(gtk_tree_selection_get_selected(sel, &model, &iter)){
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
227 GaimBlistNode *node;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
228
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
229 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
230 if (GAIM_BLIST_NODE_IS_CHAT(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
231 serv_join_chat(((struct chat *)node)->account->gc, ((struct chat*)node)->components);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
232 return;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
233 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
234 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 join_chat();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 static void gtk_blist_button_away_cb(GtkWidget *w, gpointer data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 gtk_menu_popup(GTK_MENU(awaymenu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 static void gtk_blist_row_expanded_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 GValue val = {0,};
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 node = g_value_get_pointer(&val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 gaim_group_set_setting((struct group *)node, "collapsed", NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 gaim_blist_save();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 static void gtk_blist_row_collapsed_cb(GtkTreeView *tv, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 GValue val = {0,};
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 gtk_tree_model_get_value(GTK_TREE_MODEL(gtkblist->treemodel), iter, NODE_COLUMN, &val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 node = g_value_get_pointer(&val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 gaim_group_set_setting((struct group *)node, "collapsed", "true");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 gaim_blist_save();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 static void gtk_blist_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 GValue val = { 0, };
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 node = g_value_get_pointer(&val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 struct gaim_conversation *conv =
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)node)->account, ((struct buddy*)node)->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 if(conv) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 gaim_window_raise(gaim_conversation_get_window(conv));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 gaim_window_switch_conversation(
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 gaim_conversation_get_window(conv),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 gaim_conversation_get_index(conv));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
290 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
291 serv_join_chat(((struct chat *)node)->account->gc, ((struct chat*)node)->components);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 if (gtk_tree_view_row_expanded(tv, path))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 gtk_tree_view_collapse_row(tv, path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 gtk_tree_view_expand_row(tv,path,FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
300 static void gaim_gtk_blist_add_chat_cb()
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
301 {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
302 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
303 GtkTreeIter iter;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
304 GaimBlistNode *node;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
305
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
306 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
307 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
308 if (GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
309 show_add_chat(NULL, (struct group*)node->parent);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
310 else if (GAIM_BLIST_NODE_IS_GROUP(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
311 show_add_chat(NULL, (struct group*)node);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
312 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
313 else {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
314 show_add_chat(NULL, NULL);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
315 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
316 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
317
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 static void gaim_gtk_blist_add_buddy_cb()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
326 if (GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node))
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 show_add_buddy(NULL, NULL, ((struct group*)node->parent)->name, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 else if (GAIM_BLIST_NODE_IS_GROUP(node))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 show_add_buddy(NULL, NULL, ((struct group*)node)->name, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 show_add_buddy(NULL, NULL, NULL, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 static void
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 gaim_gtk_blist_remove_cb (GtkWidget *w, GaimBlistNode *node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 struct buddy *b = (struct buddy*)node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 show_confirm_del(b->account->gc, b->name);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
342 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
343 struct chat *chat = (struct chat*)node;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
344 show_confirm_del_chat(chat);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 struct group *g = (struct group*)node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 show_confirm_del_group(g);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 static void gaim_proto_menu_cb(GtkMenuItem *item, struct buddy *b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 struct proto_buddy_menu *pbm = g_object_get_data(G_OBJECT(item), "gaimcallback");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 if (pbm->callback)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 pbm->callback(pbm->gc, b->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 static gboolean gtk_blist_button_press_cb(GtkWidget *tv, GdkEventButton *event, gpointer null)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360 GtkTreePath *path;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 GValue val = { 0, };
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 GtkWidget *menu, *menuitem;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 GtkTreeSelection *sel;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 GList *list;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367 GaimPlugin *prpl = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 GaimPluginProtocolInfo *prpl_info = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 if (event->button != 3)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 /* Here we figure out which node was clicked */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 node = g_value_get_pointer(&val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 menu = gtk_menu_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 if (GAIM_BLIST_NODE_IS_GROUP(node)) {
5366
23898d72679c [gaim-migrate @ 5742]
Luke Schierer <lschiere@pidgin.im>
parents: 5341
diff changeset
382 gaim_new_item_from_stock(menu, _("Add a _Buddy"), GTK_STOCK_ADD, G_CALLBACK(gaim_gtk_blist_add_buddy_cb), node, 0, 0, NULL);
5307
8ecf4de21db8 [gaim-migrate @ 5679]
Luke Schierer <lschiere@pidgin.im>
parents: 5297
diff changeset
383 gaim_new_item_from_stock(menu, _("Add a C_hat"), GTK_STOCK_ADD, G_CALLBACK(gaim_gtk_blist_add_chat_cb), node, 0, 0, NULL);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 gaim_new_item_from_stock(menu, _("_Delete Group"), GTK_STOCK_REMOVE, G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 gaim_new_item_from_stock(menu, _("_Rename"), NULL, G_CALLBACK(show_rename_group), node, 0, 0, NULL);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
386 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
387 gaim_new_item_from_stock(menu, _("_Join"), GAIM_STOCK_CHAT, G_CALLBACK(gtk_blist_menu_join_cb), node, 0, 0, NULL);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
388 gaim_new_item_from_stock(menu, _("_Alias"), GAIM_STOCK_EDIT, G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
389 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 /* Protocol specific options */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 prpl = gaim_find_prpl(((struct buddy*)node)->account->protocol);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 if (prpl != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 if (prpl && prpl_info->get_info)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 gaim_new_item_from_stock(menu, _("_Get Info"), GAIM_STOCK_INFO, G_CALLBACK(gtk_blist_menu_info_cb), node, 0, 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
399
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 gaim_new_item_from_stock(menu, _("_IM"), GAIM_STOCK_IM, G_CALLBACK(gtk_blist_menu_im_cb), node, 0, 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
401 gaim_new_item_from_stock(menu, _("Add Buddy _Pounce"), NULL, G_CALLBACK(gtk_blist_menu_bp_cb), node, 0, 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 gaim_new_item_from_stock(menu, _("View _Log"), NULL, G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403
5290
1f9e349b4e09 [gaim-migrate @ 5662]
Nathan Walp <nwalp@pidgin.im>
parents: 5288
diff changeset
404 if (prpl && prpl_info->buddy_menu) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 list = prpl_info->buddy_menu(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 while (list) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407 struct proto_buddy_menu *pbm = list->data;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 menuitem = gtk_menu_item_new_with_mnemonic(pbm->label);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 g_object_set_data(G_OBJECT(menuitem), "gaimcallback", pbm);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gaim_proto_menu_cb), node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412 list = list->next;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 gaim_event_broadcast (event_draw_menu, menu, ((struct buddy *) node)->name);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418 gaim_separator(menu);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 gaim_new_item_from_stock(menu, _("_Alias"), GAIM_STOCK_EDIT, G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420 gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE, G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 gtk_widget_show_all(menu);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 #if (1) /* This code only exists because GTK doesn't work. If we return FALSE here, as would be normal
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428 * the event propoagates down and somehow gets interpreted as the start of a drag event. */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 gtk_tree_selection_select_path(sel, path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 gtk_tree_path_free(path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 return TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 blist_options &= ~OPT_BLIST_NO_MT_GRP;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441 blist_options |= OPT_BLIST_NO_MT_GRP;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 save_prefs();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443 gaim_gtk_blist_refresh(gaim_get_blist());
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 GtkWidget *checkitem) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448 if(gtkblist->window->window) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
449 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 gdk_window_set_cursor(gtkblist->window->window, cursor);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451 while (gtk_events_pending())
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 gtk_main_iteration();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 gdk_cursor_unref(cursor);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem)))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 blist_options |= OPT_BLIST_SHOW_OFFLINE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 blist_options &= ~OPT_BLIST_SHOW_OFFLINE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 save_prefs();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 if(gtkblist->window->window) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 GdkCursor *cursor = gdk_cursor_new(GDK_LEFT_PTR);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464 gdk_window_set_cursor(gtkblist->window->window, cursor);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 gdk_cursor_unref(cursor);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
466 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468 gaim_gtk_blist_refresh(gaim_get_blist());
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
469 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
471 static void gaim_gtk_blist_drag_data_get_cb (GtkWidget *widget,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472 GdkDragContext *dc,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
473 GtkSelectionData *data,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
474 guint info,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
475 guint time,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
476 gpointer *null)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
477 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
478 if (data->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
479 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
481 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 GaimBlistNode *node = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
483 GValue val = {0};
5273
2e1238f4b4e3 [gaim-migrate @ 5645]
Nathan Walp <nwalp@pidgin.im>
parents: 5263
diff changeset
484 if(!sourcerow)
2e1238f4b4e3 [gaim-migrate @ 5645]
Nathan Walp <nwalp@pidgin.im>
parents: 5263
diff changeset
485 return;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
486 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488 node = g_value_get_pointer(&val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
489 gtk_selection_data_set (data,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 gdk_atom_intern ("GAIM_BLIST_NODE", FALSE),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491 8, /* bits */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 (void*)&node,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 sizeof (node));
5273
2e1238f4b4e3 [gaim-migrate @ 5645]
Nathan Walp <nwalp@pidgin.im>
parents: 5263
diff changeset
494
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495 gtk_tree_path_free(sourcerow);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
496 }
5273
2e1238f4b4e3 [gaim-migrate @ 5645]
Nathan Walp <nwalp@pidgin.im>
parents: 5263
diff changeset
497
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
498 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 GtkSelectionData *sd, guint info, guint t)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE) && sd->data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 GaimBlistNode *n = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 GtkTreePath *path = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 GtkTreeViewDropPosition position;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507 memcpy(&n, sd->data, sizeof(n));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508 if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 /* if we're here, I think it means the drop is ok */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512 GValue val = {0};
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
513 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515 node = g_value_get_pointer(&val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517 if (GAIM_BLIST_NODE_IS_BUDDY(n)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
518 struct buddy *b = (struct buddy*)n;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
519 if (GAIM_BLIST_NODE_IS_BUDDY(node) ||
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
520 GAIM_BLIST_NODE_IS_CHAT(node)) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521 switch(position) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522 case GTK_TREE_VIEW_DROP_AFTER:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
523 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524 gaim_blist_add_buddy(b, (struct group*)node->parent, node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
525 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
526 case GTK_TREE_VIEW_DROP_BEFORE:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
527 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
528 gaim_blist_add_buddy(b, (struct group*)node->parent, node->prev);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
529 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
530 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
531 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
532 gaim_blist_add_buddy(b, (struct group*)node, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
533 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
534 } else if (GAIM_BLIST_NODE_IS_CHAT(n)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
535 struct chat *chat = (struct chat*)n;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
536 if (GAIM_BLIST_NODE_IS_BUDDY(node) ||
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
537 GAIM_BLIST_NODE_IS_CHAT(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
538 switch(position) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
539 case GTK_TREE_VIEW_DROP_AFTER:
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
540 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
541 gaim_blist_add_chat(chat, (struct group*)node->parent, node);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
542 break;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
543 case GTK_TREE_VIEW_DROP_BEFORE:
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
544 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
545 gaim_blist_add_chat(chat, (struct group*)node->parent, node->prev);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
546 break;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
547 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
548 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
549 gaim_blist_add_chat(chat, (struct group*)node, NULL);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
550 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
551 } else if (GAIM_BLIST_NODE_IS_GROUP(n)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
552 struct group *g = (struct group*)n;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
553 if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
554 switch (position) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
555 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
556 case GTK_TREE_VIEW_DROP_AFTER:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
557 gaim_blist_add_group(g, node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
558 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
559 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
560 case GTK_TREE_VIEW_DROP_BEFORE:
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
561 gaim_blist_add_group(g, node->prev);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
562 break;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
563 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
564
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
565 } else if(GAIM_BLIST_NODE_IS_BUDDY(node) ||
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
566 GAIM_BLIST_NODE_IS_CHAT(node)) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
567 gaim_blist_add_group(g, node->parent);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
568 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
569
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
570 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
571
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
572 gtk_tree_path_free(path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
573 gaim_blist_save();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
574 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
577
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
578 static void gaim_gtk_blist_paint_tip(GtkWidget *widget, GdkEventExpose *event, GaimBlistNode *node)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
579 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
580 GtkStyle *style;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
581 GdkPixbuf *pixbuf = gaim_gtk_blist_get_status_icon(node, GAIM_STATUS_ICON_LARGE);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
582 PangoLayout *layout;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
583 char *tooltiptext = gaim_get_tooltip_text(node);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
584
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
585 layout = gtk_widget_create_pango_layout (gtkblist->tipwindow, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
586 pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
587 pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
588 pango_layout_set_width(layout, 300000);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
589 style = gtkblist->tipwindow->style;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
590
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
591 gtk_paint_flat_box (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
592 NULL, gtkblist->tipwindow, "tooltip", 0, 0, -1, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
593
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
594 #if GTK_CHECK_VERSION(2,2,0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
595 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, pixbuf,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
596 0, 0, 4, 4, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
597 #else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
598 gdk_pixbuf_render_to_drawable(pixbuf, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 4, 4, -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
600
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
601 gtk_paint_layout (style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, TRUE,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
602 NULL, gtkblist->tipwindow, "tooltip", 38, 4, layout);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
603
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
604 g_object_unref (pixbuf);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
605 g_object_unref (layout);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
606 g_free(tooltiptext);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
607 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
608 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
609
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
610 static gboolean gaim_gtk_blist_tooltip_timeout(GtkWidget *tv)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
611 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
612 GtkTreePath *path;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
613 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
614 GaimBlistNode *node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
615 GValue val = {0};
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
616 int scr_w,scr_h, w, h, x, y;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
617 PangoLayout *layout;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
618 char *tooltiptext = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
619
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), gtkblist->rect.x, gtkblist->rect.y, &path, NULL, NULL, NULL))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
621 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
622 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
623 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
624 node = g_value_get_pointer(&val);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
625 if(!GAIM_BLIST_NODE_IS_BUDDY(node) && !GAIM_BLIST_NODE_IS_CHAT(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
626 return FALSE;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
627
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
628 tooltiptext = gaim_get_tooltip_text(node);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
629 gtkblist->tipwindow = gtk_window_new(GTK_WINDOW_POPUP);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
630 gtkblist->tipwindow->parent = tv;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
631 gtk_widget_set_app_paintable(gtkblist->tipwindow, TRUE);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
632 gtk_window_set_resizable(GTK_WINDOW(gtkblist->tipwindow), FALSE);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
633 gtk_widget_set_name(gtkblist->tipwindow, "gtk-tooltips");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
634 g_signal_connect(G_OBJECT(gtkblist->tipwindow), "expose_event",
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
635 G_CALLBACK(gaim_gtk_blist_paint_tip), node);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
636 gtk_widget_ensure_style (gtkblist->tipwindow);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
637
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
638 layout = gtk_widget_create_pango_layout (gtkblist->tipwindow, NULL);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
639 pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
640 pango_layout_set_width(layout, 300000);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
641 pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
642 scr_w = gdk_screen_width();
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
643 scr_h = gdk_screen_height();
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
644 pango_layout_get_size (layout, &w, &h);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
645 w = PANGO_PIXELS(w) + 8;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
646 h = PANGO_PIXELS(h) + 8;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
647
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
648 /* 38 is the size of a large status icon plus 4 pixels padding on each side.
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
649 * I should #define this or something */
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
650 w = w + 38;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
651 h = MAX(h, 38);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
652
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
653 gdk_window_get_pointer(NULL, &x, &y, NULL);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
654 if (GTK_WIDGET_NO_WINDOW(gtkblist->window))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
655 y+=gtkblist->window->allocation.y;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
656
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
657 x -= ((w >> 1) + 4);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
658
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
659 if ((x + w) > scr_w)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
660 x -= (x + w) - scr_w;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
661 else if (x < 0)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
662 x = 0;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
663
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
664 if ((y + h + 4) > scr_h)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
665 y = y - h;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
666 else
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
667 y = y + 6;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
668 g_object_unref (layout);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
669 g_free(tooltiptext);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
670 gtk_widget_set_size_request(gtkblist->tipwindow, w, h);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
671 gtk_window_move(GTK_WINDOW(gtkblist->tipwindow), x, y);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
672 gtk_widget_show(gtkblist->tipwindow);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
673
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
674 gtk_tree_path_free(path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
675 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
676 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
677
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
678 static gboolean gaim_gtk_blist_motion_cb (GtkWidget *tv, GdkEventMotion *event, gpointer null)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
679 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
680 GtkTreePath *path;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
681 if (gtkblist->timeout) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
682 if ((event->y > gtkblist->rect.y) && ((event->y - gtkblist->rect.height) < gtkblist->rect.y))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
683 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
684 /* We've left the cell. Remove the timeout and create a new one below */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
685 if (gtkblist->tipwindow) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
686 gtk_widget_destroy(gtkblist->tipwindow);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
687 gtkblist->tipwindow = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
688 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
689
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
690 g_source_remove(gtkblist->timeout);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
691 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
692
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
693 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
694 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &gtkblist->rect);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
695 if (path)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
696 gtk_tree_path_free(path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
697 gtkblist->timeout = g_timeout_add(500, (GSourceFunc)gaim_gtk_blist_tooltip_timeout, tv);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
698 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
699 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
700
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
701 static void gaim_gtk_blist_leave_cb (GtkWidget *w, GdkEventCrossing *e, gpointer n)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
702 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
703 if (gtkblist->timeout) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
704 g_source_remove(gtkblist->timeout);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
705 gtkblist->timeout = 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
706 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
707 if (gtkblist->tipwindow) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
708 gtk_widget_destroy(gtkblist->tipwindow);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
709 gtkblist->tipwindow = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
710 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
711 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
712
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
713 static void
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
714 toggle_debug(void)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
715 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
716 misc_options ^= OPT_MISC_DEBUG;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
717
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
718 if ((misc_options & OPT_MISC_DEBUG))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
719 gaim_gtk_debug_window_show();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
720 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
721 gaim_gtk_debug_window_hide();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
722
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
723 save_prefs();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
724 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
725
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
726
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
727 /***************************************************
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
728 * Crap *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
729 ***************************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
730 static GtkItemFactoryEntry blist_menu[] =
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
731 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
732 /* Buddies menu */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
733 { N_("/_Buddies"), NULL, NULL, 0, "<Branch>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
734 { N_("/Buddies/New _Instant Message..."), "<CTL>I", show_im_dialog, 0, "<StockItem>", GAIM_STOCK_IM },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
735 { N_("/Buddies/Join a _Chat..."), "<CTL>C", join_chat, 0, "<StockItem>", GAIM_STOCK_CHAT },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
736 { N_("/Buddies/Get _User Info..."), "<CTL>J", show_info_dialog, 0, "<StockItem>", GAIM_STOCK_INFO },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
737 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
738 { N_("/Buddies/_Show Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"},
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
739 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>"},
5307
8ecf4de21db8 [gaim-migrate @ 5679]
Luke Schierer <lschiere@pidgin.im>
parents: 5297
diff changeset
740 { N_("/Buddies/_Add a Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD },
8ecf4de21db8 [gaim-migrate @ 5679]
Luke Schierer <lschiere@pidgin.im>
parents: 5297
diff changeset
741 { N_("/Buddies/Add a C_hat..."), NULL, gaim_gtk_blist_add_chat_cb, 0, "<StockItem>", GTK_STOCK_ADD },
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
742 { N_("/Buddies/Add a _Group..."), NULL, show_add_group, 0, NULL},
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
743 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
744 { N_("/Buddies/_Signoff"), "<CTL>D", signoff_all, 0, "<StockItem>", GAIM_STOCK_SIGN_OFF },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
745 { N_("/Buddies/_Quit"), "<CTL>Q", do_quit, 0, "<StockItem>", GTK_STOCK_QUIT },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
746
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
747 /* Tools */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
748 { N_("/_Tools"), NULL, NULL, 0, "<Branch>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
749 { N_("/Tools/_Away"), NULL, NULL, 0, "<Branch>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
750 { N_("/Tools/Buddy _Pounce"), NULL, NULL, 0, "<Branch>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
751 { N_("/Tools/P_rotocol Actions"), NULL, NULL, 0, "<Branch>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
752 { "/Tools/sep1", NULL, NULL, 0, "<Separator>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
753 { N_("/Tools/A_ccounts..."), "<CTL>A", account_editor, 0, "<StockItem>", GAIM_STOCK_ACCOUNTS },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
754 { N_("/Tools/_File Transfers..."), NULL, gaim_show_xfer_dialog, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
755 { N_("/Tools/Preferences..."), "<CTL>P", show_prefs, 0, "<StockItem>", GTK_STOCK_PREFERENCES },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
756 { N_("/Tools/Pr_ivacy..."), NULL, show_privacy_options, 0, "<StockItem>", GAIM_STOCK_PRIVACY },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
757 { "/Tools/sep2", NULL, NULL, 0, "<Separator>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
758 { N_("/Tools/View System _Log..."), NULL, gtk_blist_show_systemlog_cb, 0, NULL },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
759
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
760 /* Help */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
761 { N_("/_Help"), NULL, NULL, 0, "<Branch>" },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
762 { N_("/Help/Online _Help"), "F1", gtk_blist_show_onlinehelp_cb, 0, "<StockItem>", GTK_STOCK_HELP },
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
763 { N_("/Help/_Debug Window..."), NULL, toggle_debug, 0, NULL },
5307
8ecf4de21db8 [gaim-migrate @ 5679]
Luke Schierer <lschiere@pidgin.im>
parents: 5297
diff changeset
764 { N_("/Help/_About..."), "<CTL>F1", show_about, 0, "<StockItem>", GAIM_STOCK_ABOUT },
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
765 };
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
766
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
767 /*********************************************************
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
768 * Private Utility functions *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
769 *********************************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
770
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
771 static char *gaim_get_tooltip_text(GaimBlistNode *node)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
772 {
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
773 GaimPlugin *prpl;
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
774 GaimPluginProtocolInfo *prpl_info = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
775 char *text = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
776
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
777 if(GAIM_BLIST_NODE_IS_CHAT(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
778 struct chat *chat = (struct chat *)node;
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
779 char *name = NULL;
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
780 struct proto_chat_entry *pce;
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
781 GList *parts, *tmp;
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
782 GString *parts_text = g_string_new("");
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
783
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
784 prpl = gaim_find_prpl(chat->account->protocol);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
785 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
786
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
787 parts = prpl_info->chat_info(chat->account->gc);
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
788
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
789 if(chat->alias) {
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
790 name = g_markup_escape_text(chat->alias, -1);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
791 } else {
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
792 pce = parts->data;
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
793 name = g_markup_escape_text(g_hash_table_lookup(chat->components,
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
794 pce->identifier), -1);
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
795 }
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
796 if(g_slist_length(connections) > 1) {
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
797 char *account = g_markup_escape_text(chat->account->username, -1);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
798 g_string_append_printf(parts_text, _("\n<b>Account:</b> %s"),
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
799 account);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
800 g_free(account);
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
801 }
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
802 for(tmp = parts; tmp; tmp = tmp->next) {
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
803 char *label, *value;
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
804 pce = tmp->data;
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
805
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
806 label = g_markup_escape_text(pce->label, -1);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
807
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
808 value = g_markup_escape_text(g_hash_table_lookup(chat->components,
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
809 pce->identifier), -1);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
810
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
811 g_string_append_printf(parts_text, "\n<b>%s</b> %s", label, value);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
812 g_free(label);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
813 g_free(value);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
814 g_free(pce);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
815 }
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
816 g_list_free(parts);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
817
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
818 text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>%s",
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
819 name, parts_text->str);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
820 g_string_free(parts_text, TRUE);
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
821 g_free(name);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
822 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
823 struct buddy *b = (struct buddy *)node;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
824 char *statustext = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
825 char *aliastext = NULL, *nicktext = NULL;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
826 char *warning = NULL, *idletime = NULL;
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
827 char *accounttext = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
828
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
829 prpl = gaim_find_prpl(b->account->protocol);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
830 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
831
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
832 if (prpl_info->tooltip_text) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
833 const char *end;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
834 statustext = prpl_info->tooltip_text(b);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
835
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
836 if(statustext && !g_utf8_validate(statustext, -1, &end)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
837 char *new = g_strndup(statustext,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
838 g_utf8_pointer_to_offset(statustext, end));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
839 g_free(statustext);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
840 statustext = new;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
841 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
842 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
843
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
844 if (!statustext && !GAIM_BUDDY_IS_ONLINE(b))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
845 statustext = g_strdup(_("<b>Status:</b> Offline"));
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
846
5341
ccec8893c1be [gaim-migrate @ 5717]
Mark Doliner <mark@kingant.net>
parents: 5340
diff changeset
847 if (b->idle > 0)
ccec8893c1be [gaim-migrate @ 5717]
Mark Doliner <mark@kingant.net>
parents: 5340
diff changeset
848 idletime = sec_to_text(time(NULL) - b->idle);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
849
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
850 if(b->alias && b->alias[0])
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
851 aliastext = g_markup_escape_text(b->alias, -1);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
852
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
853 if(b->server_alias)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
854 nicktext = g_markup_escape_text(b->server_alias, -1);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
855
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
856 if (b->evil > 0)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
857 warning = g_strdup_printf(_("%d%%"), b->evil);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
858
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
859 if(g_slist_length(connections) > 1)
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
860 accounttext = g_markup_escape_text(b->account->username, -1);
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
861
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
862 text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>"
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
863 "%s %s" /* Account */
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
864 "%s %s" /* Alias */
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
865 "%s %s" /* Nickname */
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
866 "%s %s" /* Idle */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
867 "%s %s" /* Warning */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
868 "%s%s" /* Status */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
869 "%s",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
870 b->name,
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
871 accounttext ? _("\n<b>Account:</b>") : "", accounttext ? accounttext : "",
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
872 aliastext ? _("\n<b>Alias:</b>") : "", aliastext ? aliastext : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
873 nicktext ? _("\n<b>Nickname:</b>") : "", nicktext ? nicktext : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
874 idletime ? _("\n<b>Idle:</b>") : "", idletime ? idletime : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
875 b->evil ? _("\n<b>Warned:</b>") : "", b->evil ? warning : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
876 statustext ? "\n" : "", statustext ? statustext : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
877 !g_ascii_strcasecmp(b->name, "robflynn") ? _("\n<b>Description:</b> Spooky") : "");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
878
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
879 if(warning)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
880 g_free(warning);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
881 if(idletime)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
882 g_free(idletime);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
883 if(statustext)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
884 g_free(statustext);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
885 if(nicktext)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
886 g_free(nicktext);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
887 if(aliastext)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
888 g_free(aliastext);
5274
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
889 if(accounttext)
ad299f62b9b6 [gaim-migrate @ 5646]
Nathan Walp <nwalp@pidgin.im>
parents: 5273
diff changeset
890 g_free(accounttext);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
891 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
892
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
893 return text;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
894 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
895
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
896 GdkPixbuf *gaim_gtk_blist_get_status_icon(GaimBlistNode *node, GaimStatusIconSize size)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
897 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
898 GdkPixbuf *status = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
899 GdkPixbuf *scale = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
900 GdkPixbuf *emblem = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
901 gchar *filename = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
902 const char *protoname = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
903
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
904 char *se = NULL, *sw = NULL ,*nw = NULL ,*ne = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
905
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
906 int scalesize = 30;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
907
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
908 GaimPlugin *prpl = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
909 GaimPluginProtocolInfo *prpl_info = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
910
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
911 if(GAIM_BLIST_NODE_IS_BUDDY(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
912 prpl = gaim_find_prpl(((struct buddy *)node)->account->protocol);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
913 else if(GAIM_BLIST_NODE_IS_CHAT(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
914 prpl = gaim_find_prpl(((struct chat *)node)->account->protocol);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
915
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
916 if (!prpl)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
917 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
918
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
919 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
920
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
921 if (prpl_info->list_icon) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
922 if(GAIM_BLIST_NODE_IS_BUDDY(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
923 protoname = prpl_info->list_icon(((struct buddy*)node)->account,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
924 (struct buddy *)node);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
925 else if(GAIM_BLIST_NODE_IS_CHAT(node))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
926 protoname = prpl_info->list_icon(((struct chat*)node)->account, NULL);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
927 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
928
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
929 if (GAIM_BLIST_NODE_IS_BUDDY(node) &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
930 ((struct buddy *)node)->present != GAIM_BUDDY_SIGNING_OFF &&
5381
aa1cf48f76eb [gaim-migrate @ 5757]
Christian Hammond <chipx86@chipx86.com>
parents: 5368
diff changeset
931 ((struct buddy *)node)->present != GAIM_BUDDY_OFFLINE &&
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
932 prpl_info->list_emblems) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
933 prpl_info->list_emblems((struct buddy*)node, &se, &sw, &nw, &ne);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
934 }
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
935
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
936 if (size == GAIM_STATUS_ICON_SMALL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
937 scalesize = 15;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
938 sw = nw = ne = NULL; /* So that only the se icon will composite */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
939 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
940
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
941
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
942 if (GAIM_BLIST_NODE_IS_BUDDY(node) &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
943 ((struct buddy*)node)->present == GAIM_BUDDY_SIGNING_ON) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
944 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
945 status = gdk_pixbuf_new_from_file(filename,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
946 g_free(filename);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
947 } else if (GAIM_BLIST_NODE_IS_BUDDY(node) &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
948 ((struct buddy *)node)->present == GAIM_BUDDY_SIGNING_OFF) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
949 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "logout.png", NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
950 status = gdk_pixbuf_new_from_file(filename,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
951 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
952
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
953 /* "Hey, what's all this crap?" you ask. Status icons will be themeable too, and
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
954 then it will look up protoname from the theme */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
955 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
956 char *image = g_strdup_printf("%s.png", protoname);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
957 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
958 status = gdk_pixbuf_new_from_file(filename,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
959 g_free(image);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
960 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
961
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
962 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
963
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
964 if (!status)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
965 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
966
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
967 scale = gdk_pixbuf_scale_simple(status, scalesize, scalesize, GDK_INTERP_BILINEAR);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
968
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
969 g_object_unref(G_OBJECT(status));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
970
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
971 /* Emblems */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
972
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
973 /* Each protocol can specify up to four "emblems" to composite over the base icon. "away", "busy", "mobile user"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
974 * are all examples of states represented by emblems. I'm not even really sure I like this yet. */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
975
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
976 /* XXX Clean this crap up, yo. */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
977 if (se) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
978 char *image = g_strdup_printf("%s.png", se);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
979 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
980 g_free(image);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
981 emblem = gdk_pixbuf_new_from_file(filename,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
982 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
983 if (emblem) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
984 if (size == GAIM_STATUS_ICON_LARGE)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
985 gdk_pixbuf_composite (emblem,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
986 scale, 15, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
987 15, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
988 15, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
989 1, 1,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
990 GDK_INTERP_BILINEAR,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
991 255);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
992 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
993 gdk_pixbuf_composite (emblem,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
994 scale, 5, 5,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
995 10, 10,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
996 5, 5,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
997 .6, .6,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
998 GDK_INTERP_BILINEAR,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
999 255);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1000 g_object_unref(G_OBJECT(emblem));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1001 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1002 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1003 if (sw) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1004 char *image = g_strdup_printf("%s.png", sw);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1005 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1006 g_free(image);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1007 emblem = gdk_pixbuf_new_from_file(filename,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1008 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1009 if (emblem) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1010 gdk_pixbuf_composite (emblem,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1011 scale, 0, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1012 15, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1013 0, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1014 1, 1,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1015 GDK_INTERP_BILINEAR,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1016 255);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1017 g_object_unref(G_OBJECT(emblem));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1018 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1019 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1020 if (nw) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1021 char *image = g_strdup_printf("%s.png", nw);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1022 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1023 g_free(image);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1024 emblem = gdk_pixbuf_new_from_file(filename,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1025 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1026 if (emblem) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1027 gdk_pixbuf_composite (emblem,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1028 scale, 0, 0,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1029 15, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1030 0, 0,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1031 1, 1,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1032 GDK_INTERP_BILINEAR,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1033 255);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1034 g_object_unref(G_OBJECT(emblem));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1035 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1036 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1037 if (ne) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1038 char *image = g_strdup_printf("%s.png", ne);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1039 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1040 g_free(image);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1041 emblem = gdk_pixbuf_new_from_file(filename,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1042 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1043 if (emblem) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1044 gdk_pixbuf_composite (emblem,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1045 scale, 15, 0,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1046 15, 15,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1047 15, 0,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1048 1, 1,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1049 GDK_INTERP_BILINEAR,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1050 255);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1051 g_object_unref(G_OBJECT(emblem));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1052 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1053 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1054
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1055
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1056 /* Idle grey buddies affects the whole row. This converts the status icon to greyscale. */
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1057 if (GAIM_BLIST_NODE_IS_BUDDY(node) &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1058 ((struct buddy *)node)->present == GAIM_BUDDY_OFFLINE)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1059 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1060 else if (GAIM_BLIST_NODE_IS_BUDDY(node) &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1061 ((struct buddy *)node)->idle &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1062 blist_options & OPT_BLIST_GREY_IDLERS)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1063 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.25, FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1064 return scale;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1065 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1066
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1067 static GdkPixbuf *gaim_gtk_blist_get_buddy_icon(struct buddy *b)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1068 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1069 /* This just opens a file from ~/.gaim/icons/screenname. This needs to change to be more gooder. */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1070 char *file;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1071 GdkPixbuf *buf, *ret;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1072
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1073 if (!(blist_options & OPT_BLIST_SHOW_ICONS))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1074 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1075
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1076 if ((file = gaim_buddy_get_setting(b, "buddy_icon")) == NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1077 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1078
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1079 buf = gdk_pixbuf_new_from_file(file, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1080 g_free(file);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1081
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1082
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1083 if (buf) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1084 if (!GAIM_BUDDY_IS_ONLINE(b))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1085 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.0, FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1086 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1087 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0.25, FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1088
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1089 ret = gdk_pixbuf_scale_simple(buf,30,30, GDK_INTERP_BILINEAR);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1090 g_object_unref(G_OBJECT(buf));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1091 return ret;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1092 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1093 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1094 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1095
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1096 static gchar *gaim_gtk_blist_get_name_markup(struct buddy *b, gboolean selected)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1097 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1098 char *name = gaim_get_buddy_alias(b);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1099 char *esc = g_markup_escape_text(name, strlen(name)), *text = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1100 GaimPlugin *prpl;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1101 GaimPluginProtocolInfo *prpl_info = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1102 /* XXX Clean up this crap */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1103
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1104 int ihrs, imin;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1105 char *idletime = NULL, *warning = NULL, *statustext = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1106 time_t t;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1107
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1108 prpl = gaim_find_prpl(b->account->protocol);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1109
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1110 if (prpl != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1111 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1112
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1113 if (!(blist_options & OPT_BLIST_SHOW_ICONS)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1114 if ((b->idle && blist_options & OPT_BLIST_GREY_IDLERS && !selected) || !GAIM_BUDDY_IS_ONLINE(b)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1115 text = g_strdup_printf("<span color='dim grey'>%s</span>",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1116 esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1117 g_free(esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1118 return text;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1119 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1120 return esc;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1121 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1122 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1123
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1124 time(&t);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1125 ihrs = (t - b->idle) / 3600;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1126 imin = ((t - b->idle) / 60) % 60;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1127
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1128 if (prpl && prpl_info->status_text) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1129 char *tmp = prpl_info->status_text(b);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1130 const char *end;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1131
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1132 if(tmp && !g_utf8_validate(tmp, -1, &end)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1133 char *new = g_strndup(tmp,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1134 g_utf8_pointer_to_offset(tmp, end));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1135 g_free(tmp);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1136 tmp = new;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1137 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1138
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1139 if(tmp) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1140 char buf[32];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1141 char *c = tmp;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1142 int length = 0, vis=0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1143 gboolean inside = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1144 g_strdelimit(tmp, "\n", ' ');
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1145
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1146 while(*c && vis < 20) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1147 if(*c == '&')
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1148 inside = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1149 else if(*c == ';')
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1150 inside = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1151 if(!inside)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1152 vis++;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1153 length++;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1154 c++; /* this is fun */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1155 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1156
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1157 if(vis == 20)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1158 g_snprintf(buf, sizeof(buf), "%%.%ds...", length);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1159 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1160 g_snprintf(buf, sizeof(buf), "%%s ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1161
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1162 statustext = g_strdup_printf(buf, tmp);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1163
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1164 g_free(tmp);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1165 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1166 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1167
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1168 if (b->idle > 0) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1169 if (ihrs)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1170 idletime = g_strdup_printf(_("Idle (%dh%02dm) "), ihrs, imin);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1171 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1172 idletime = g_strdup_printf(_("Idle (%dm) "), imin);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1173 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1174
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1175 if (b->evil > 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1176 warning = g_strdup_printf(_("Warned (%d%%) "), b->evil);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1177
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1178 if(!GAIM_BUDDY_IS_ONLINE(b) && !statustext)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1179 statustext = g_strdup("Offline ");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1180
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1181 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS && !selected) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1182 text = g_strdup_printf("<span color='dim grey'>%s</span>\n"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1183 "<span color='dim grey' size='smaller'>%s%s%s</span>",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1184 esc,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1185 statustext != NULL ? statustext : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1186 idletime != NULL ? idletime : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1187 warning != NULL ? warning : "");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1188 } else if (statustext == NULL && idletime == NULL && warning == NULL && GAIM_BUDDY_IS_ONLINE(b)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1189 text = g_strdup(esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1190 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1191 text = g_strdup_printf("%s\n"
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1192 "<span %s size='smaller'>%s%s%s</span>", esc,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1193 selected ? "" : "color='dim grey'",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1194 statustext != NULL ? statustext : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1195 idletime != NULL ? idletime : "",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1196 warning != NULL ? warning : "");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1197 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1198 if (idletime)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1199 g_free(idletime);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1200 if (warning)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1201 g_free(warning);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1202 if (statustext)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1203 g_free(statustext);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1204 if (esc)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1205 g_free(esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1206
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1207 return text;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1208 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1209
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1210 static void gaim_gtk_blist_restore_position()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1211 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1212 /* if the window exists, is hidden, we're saving positions, and the position is sane... */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1213 if(gtkblist && gtkblist->window &&
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1214 !GTK_WIDGET_VISIBLE(gtkblist->window) &&
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1215 blist_pos.width != 0) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1216 /* ...check position is on screen... */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1217 if (blist_pos.x >= gdk_screen_width())
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1218 blist_pos.x = gdk_screen_width() - 100;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1219 else if (blist_pos.x < 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1220 blist_pos.x = 100;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1221
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1222 if (blist_pos.y >= gdk_screen_height())
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1223 blist_pos.y = gdk_screen_height() - 100;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1224 else if (blist_pos.y < 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1225 blist_pos.y = 100;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1226
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1227 /* ...and move it back. */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1228 gtk_window_move(GTK_WINDOW(gtkblist->window), blist_pos.x, blist_pos.y);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1229 gtk_window_resize(GTK_WINDOW(gtkblist->window), blist_pos.width, blist_pos.height);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1230 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1231 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1232
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1233 static gboolean gaim_gtk_blist_refresh_timer(struct gaim_buddy_list *list)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1234 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1235 GaimBlistNode *group, *buddy;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1236
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1237 for(group = list->root; group; group = group->next) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1238 if(!GAIM_BLIST_NODE_IS_GROUP(group))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1239 continue;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1240 for(buddy = group->child; buddy; buddy = buddy->next) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1241 if(!GAIM_BLIST_NODE_IS_BUDDY(buddy))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1242 continue;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1243 if (((struct buddy *)buddy)->idle)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1244 gaim_gtk_blist_update(list, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1245 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1246 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1247
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1248 /* keep on going */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1249 return TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1250 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1251
5260
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1252 static void gaim_gtk_blist_hide_node(struct gaim_buddy_list *list, GaimBlistNode *node)
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1253 {
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1254 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data;
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1255 GtkTreeIter iter;
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1256
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1257 if (!gtknode || !gtknode->row || !gtkblist)
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1258 return;
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1259
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1260 if(gtkblist->selected_node == node)
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1261 gtkblist->selected_node = NULL;
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1262
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1263 if (get_iter_from_node(node, &iter)) {
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1264 gtk_tree_store_remove(gtkblist->treemodel, &iter);
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1265 if(GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node)) {
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1266 gaim_gtk_blist_update(list, node->parent);
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1267 }
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1268 }
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1269 gtk_tree_row_reference_free(gtknode->row);
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1270 gtknode->row = NULL;
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1271 }
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1272
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1273
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1274 /**********************************************************************************
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1275 * Public API Functions *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1276 **********************************************************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1277 static void gaim_gtk_blist_new_list(struct gaim_buddy_list *blist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1278 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1279 blist->ui_data = g_new0(struct gaim_gtk_buddy_list, 1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1280 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1281
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1282 static void gaim_gtk_blist_new_node(GaimBlistNode *node)
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1283 {
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1284 node->ui_data = g_new0(struct _gaim_gtk_blist_node, 1);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1285 }
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1286
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1287 void gaim_gtk_blist_update_columns()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1288 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1289 if(!gtkblist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1290 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1291
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1292 if (blist_options & OPT_BLIST_SHOW_ICONS) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1293 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, TRUE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1294 gtk_tree_view_column_set_visible(gtkblist->idle_column, FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1295 gtk_tree_view_column_set_visible(gtkblist->warning_column, FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1296 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1297 gtk_tree_view_column_set_visible(gtkblist->idle_column, blist_options & OPT_BLIST_SHOW_IDLETIME);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1298 gtk_tree_view_column_set_visible(gtkblist->warning_column, blist_options & OPT_BLIST_SHOW_WARN);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1299 gtk_tree_view_column_set_visible(gtkblist->buddy_icon_column, FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1300 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1301 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1302
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1303 enum {DRAG_BUDDY, DRAG_ROW};
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1304
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1305 static char *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1306 item_factory_translate_func (const char *path, gpointer func_data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1307 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1308 return _(path);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1309 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1310
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1311 static void gaim_gtk_blist_show(struct gaim_buddy_list *list)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1312 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1313 GtkItemFactory *ift;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1314 GtkCellRenderer *rend;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1315 GtkTreeViewColumn *column;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1316 GtkWidget *sw;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1317 GtkWidget *button;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1318 GtkSizeGroup *sg;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1319 GtkAccelGroup *accel_group;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1320 GtkTreeSelection *selection;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1321 GtkTargetEntry gte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW},
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1322 {"application/x-im-contact", 0, DRAG_BUDDY}};
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1323
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1324 if (gtkblist && gtkblist->window) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1325 gtk_widget_show(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1326 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1327 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1328
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1329 gtkblist = GAIM_GTK_BLIST(list);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1330
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1331 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1332 gtk_window_set_role(GTK_WINDOW(gtkblist->window), "buddy_list");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1333 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1334
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1335 GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1336
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1337 gtkblist->vbox = gtk_vbox_new(FALSE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1338 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1339
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1340 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gtk_blist_delete_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1341 g_signal_connect(G_OBJECT(gtkblist->window), "configure_event", G_CALLBACK(gtk_blist_configure_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1342 g_signal_connect(G_OBJECT(gtkblist->window), "visibility_notify_event", G_CALLBACK(gtk_blist_visibility_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1343 gtk_widget_add_events(gtkblist->window, GDK_VISIBILITY_NOTIFY_MASK);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1344
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1345 /******************************* Menu bar *************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1346 accel_group = gtk_accel_group_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1347 gtk_window_add_accel_group(GTK_WINDOW (gtkblist->window), accel_group);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1348 g_object_unref(accel_group);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1349 ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", accel_group);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1350 gtk_item_factory_set_translate_func (ift,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1351 item_factory_translate_func,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1352 NULL, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1353 gtk_item_factory_create_items(ift, sizeof(blist_menu) / sizeof(*blist_menu),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1354 blist_menu, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1355 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtk_item_factory_get_widget(ift, "<GaimMain>"), FALSE, FALSE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1356
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1357 awaymenu = gtk_item_factory_get_widget(ift, N_("/Tools/Away"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1358 do_away_menu();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1359
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1360 gtkblist->bpmenu = gtk_item_factory_get_widget(ift, N_("/Tools/Buddy Pounce"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1361 gaim_gtkpounce_menu_build(gtkblist->bpmenu);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1362
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1363 protomenu = gtk_item_factory_get_widget(ift, N_("/Tools/Protocol Actions"));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1364 do_proto_menu();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1365
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1366 /****************************** GtkTreeView **********************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1367 sw = gtk_scrolled_window_new(NULL,NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1368 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1369 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1370
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1371 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, G_TYPE_STRING,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1372 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1373
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1374 gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1375 gtk_widget_set_size_request(gtkblist->treeview, -1, 200);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1376
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1377 /* Set up selection stuff */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1378
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1379 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1380 g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(gaim_gtk_blist_selection_changed), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1381
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1382
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1383 /* Set up dnd */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1384 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), GDK_BUTTON1_MASK, gte,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1385 2, GDK_ACTION_COPY);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1386 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), gte, 2,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1387 GDK_ACTION_COPY | GDK_ACTION_MOVE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1388 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", G_CALLBACK(gaim_gtk_blist_drag_data_rcv_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1389 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", G_CALLBACK(gaim_gtk_blist_drag_data_get_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1390
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1391 /* Tooltips */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1392 g_signal_connect(G_OBJECT(gtkblist->treeview), "motion-notify-event", G_CALLBACK(gaim_gtk_blist_motion_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1393 g_signal_connect(G_OBJECT(gtkblist->treeview), "leave-notify-event", G_CALLBACK(gaim_gtk_blist_leave_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1394
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1395 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1396
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1397 column = gtk_tree_view_column_new ();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1398
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1399 rend = gtk_cell_renderer_pixbuf_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1400 gtk_tree_view_column_pack_start (column, rend, FALSE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1401 gtk_tree_view_column_set_attributes (column, rend,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1402 "pixbuf", STATUS_ICON_COLUMN,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1403 "visible", STATUS_ICON_VISIBLE_COLUMN,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1404 NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1405 g_object_set(rend, "xalign", 0.0, "ypad", 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1406
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1407 rend = gtk_cell_renderer_text_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1408 gtk_tree_view_column_pack_start (column, rend, TRUE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1409 gtk_tree_view_column_set_attributes (column, rend,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1410 "markup", NAME_COLUMN,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1411 NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1412 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1413
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1414 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1415
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1416 rend = gtk_cell_renderer_text_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1417 gtkblist->warning_column = gtk_tree_view_column_new_with_attributes("Warning", rend, "markup", WARNING_COLUMN, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1418 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->warning_column);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1419 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1420
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1421 rend = gtk_cell_renderer_text_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1422 gtkblist->idle_column = gtk_tree_view_column_new_with_attributes("Idle", rend, "markup", IDLE_COLUMN, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1423 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->idle_column);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1424 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1425
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1426 rend = gtk_cell_renderer_pixbuf_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1427 gtkblist->buddy_icon_column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1428 g_object_set(rend, "xalign", 1.0, "ypad", 0, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1429 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), gtkblist->buddy_icon_column);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1430
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1431 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1432 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-expanded", G_CALLBACK(gtk_blist_row_expanded_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1433 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-collapsed", G_CALLBACK(gtk_blist_row_collapsed_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1434 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1435
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1436 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1437 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1438 gaim_gtk_blist_update_columns();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1439
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1440 /* set the Show Offline Buddies option. must be done
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1441 * after the treeview or faceprint gets mad. -Robot101
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1442 */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1443 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (ift, N_("/Buddies/Show Offline Buddies"))),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1444 blist_options & OPT_BLIST_SHOW_OFFLINE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1445 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (ift, N_("/Buddies/Show Empty Groups"))),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1446 !(blist_options & OPT_BLIST_NO_MT_GRP));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1447
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1448 /* OK... let's show this bad boy. */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1449 gaim_gtk_blist_refresh(list);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1450 gaim_gtk_blist_restore_position();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1451 gtk_widget_show_all(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1452
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1453 /**************************** Button Box **************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1454 /* add this afterwards so it doesn't force up the width of the window */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1455
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1456 gtkblist->tooltips = gtk_tooltips_new();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1457
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1458 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1459 gtkblist->bbox = gtk_hbox_new(TRUE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1460 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->bbox, FALSE, FALSE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1461 gtk_widget_show(gtkblist->bbox);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1462
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1463 button = gaim_pixbuf_button_from_stock(_("IM"), GAIM_STOCK_IM, GAIM_BUTTON_VERTICAL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1464 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1465 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1466 gtk_size_group_add_widget(sg, button);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1467 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_im_cb),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1468 gtkblist->treeview);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1469 gtk_tooltips_set_tip(GTK_TOOLTIPS(gtkblist->tooltips), button, _("Send a message to the selected buddy"), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1470 gtk_widget_show(button);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1471
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1472 button = gaim_pixbuf_button_from_stock(_("Get Info"), GAIM_STOCK_INFO, GAIM_BUTTON_VERTICAL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1473 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1474 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1475 gtk_size_group_add_widget(sg, button);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1476 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_info_cb),
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1477 gtkblist->treeview);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1478 gtk_tooltips_set_tip(GTK_TOOLTIPS(gtkblist->tooltips), button, _("Get information on the selected buddy"), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1479 gtk_widget_show(button);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1480
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1481 button = gaim_pixbuf_button_from_stock(_("Chat"), GAIM_STOCK_CHAT, GAIM_BUTTON_VERTICAL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1482 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1483 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1484 gtk_size_group_add_widget(sg, button);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1485 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_chat_cb), gtkblist->treeview);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1486 gtk_tooltips_set_tip(GTK_TOOLTIPS(gtkblist->tooltips), button, _("Join a chat room"), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1487 gtk_widget_show(button);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1488
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1489 button = gaim_pixbuf_button_from_stock(_("Away"), GAIM_STOCK_ICON_AWAY, GAIM_BUTTON_VERTICAL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1490 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1491 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1492 gtk_size_group_add_widget(sg, button);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1493 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_away_cb), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1494 gtk_tooltips_set_tip(GTK_TOOLTIPS(gtkblist->tooltips), button, _("Set an away message"), NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1495 gtk_widget_show(button);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1496
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1497 /* this will show the right image/label widgets for us */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1498 gaim_gtk_blist_update_toolbar();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1499
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1500 /* start the refresh timer */
5297
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1501 if (blist_options & (OPT_BLIST_SHOW_IDLETIME | OPT_BLIST_SHOW_ICONS))
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1502 gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, list);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1503 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1504
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1505 void gaim_gtk_blist_refresh(struct gaim_buddy_list *list)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1506 {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1507 GaimBlistNode *group, *buddy;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1508
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1509 for(group = list->root; group; group = group->next) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1510 if(!GAIM_BLIST_NODE_IS_GROUP(group))
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1511 continue;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1512 gaim_gtk_blist_update(list, group);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1513 for(buddy = group->child; buddy; buddy = buddy->next) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1514 gaim_gtk_blist_update(list, buddy);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1515 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1516 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1517 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1518
5297
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1519 void
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1520 gaim_gtk_blist_update_refresh_timeout()
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1521 {
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1522 struct gaim_buddy_list *blist;
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1523 struct gaim_gtk_buddy_list *gtkblist;
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1524
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1525 blist = gaim_get_blist();
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1526 gtkblist = GAIM_GTK_BLIST(gaim_get_blist());
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1527
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1528 if (blist_options & (OPT_BLIST_SHOW_IDLETIME | OPT_BLIST_SHOW_ICONS)) {
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1529 gtkblist->refresh_timer = g_timeout_add(30000, (GSourceFunc)gaim_gtk_blist_refresh_timer, blist);
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1530 } else {
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1531 g_source_remove(gtkblist->refresh_timer);
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1532 gtkblist->refresh_timer = 0;
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1533 }
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1534 }
d4c9c5491812 [gaim-migrate @ 5669]
Luke Schierer <lschiere@pidgin.im>
parents: 5296
diff changeset
1535
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1536 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) {
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1537 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data;
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1538 GtkTreePath *path;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1539
5263
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1540 if (!gtknode) {
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1541 gaim_debug(GAIM_DEBUG_ERROR, "gtkblist", "buddy %s has no ui_data\n", ((struct buddy *)node)->name);
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1542 return FALSE;
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1543 }
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1544
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1545 if (!gtkblist) {
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1546 gaim_debug(GAIM_DEBUG_ERROR, "gtkblist", "get_iter_from_node was called, but we don't seem to have a blist\n");
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1547 return FALSE;
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1548 }
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1549
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1550 if (!gtknode->row)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1551 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1552
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1553 if ((path = gtk_tree_row_reference_get_path(gtknode->row)) == NULL)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1554 return FALSE;
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1555 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), iter, path)) {
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1556 gtk_tree_path_free(path);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1557 return FALSE;
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1558 }
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1559 gtk_tree_path_free(path);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1560 return TRUE;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1561 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1562
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1563 /*
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1564 * These state assignments suck. I'm sorry. They're for historical reasons.
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1565 * Roll on new prefs. -Robot101
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1566 *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1567 * NO_BUTTON_TEXT && SHOW_BUTTON_XPM - image
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1568 * !NO_BUTTON_TEXT && !SHOW_BUTTON_XPM - text
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1569 * !NO_BUTTON_TEXT && SHOW_BUTTON_XPM - text & images
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1570 * NO_BUTTON_TEXT && !SHOW_BUTTON_XPM - none
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1571 */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1572
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1573 static void gaim_gtk_blist_update_toolbar_icons (GtkWidget *widget, gpointer data) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1574 if (GTK_IS_IMAGE(widget)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1575 if (blist_options & OPT_BLIST_SHOW_BUTTON_XPM)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1576 gtk_widget_show(widget);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1577 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1578 gtk_widget_hide(widget);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1579 } else if (GTK_IS_LABEL(widget)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1580 if (blist_options & OPT_BLIST_NO_BUTTON_TEXT)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1581 gtk_widget_hide(widget);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1582 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1583 gtk_widget_show(widget);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1584 } else if (GTK_IS_CONTAINER(widget)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1585 gtk_container_foreach(GTK_CONTAINER(widget), gaim_gtk_blist_update_toolbar_icons, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1586 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1587 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1588
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1589 void gaim_gtk_blist_update_toolbar() {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1590 if (!gtkblist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1591 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1592
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1593 if (blist_options & OPT_BLIST_NO_BUTTON_TEXT && !(blist_options & OPT_BLIST_SHOW_BUTTON_XPM))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1594 gtk_widget_hide(gtkblist->bbox);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1595 else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1596 gtk_container_foreach(GTK_CONTAINER(gtkblist->bbox), gaim_gtk_blist_update_toolbar_icons, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1597 gtk_widget_show(gtkblist->bbox);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1598 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1599 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1600
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1601 static void gaim_gtk_blist_remove(struct gaim_buddy_list *list, GaimBlistNode *node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1602 {
5260
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1603 gaim_gtk_blist_hide_node(list, node);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1604
5263
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1605 /* There's something I don't understand here */
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1606 /* g_free(node->ui_data);
b476a30ef4e3 [gaim-migrate @ 5635]
Luke Schierer <lschiere@pidgin.im>
parents: 5260
diff changeset
1607 node->ui_data = NULL; */
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1608 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1609
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1610 static gboolean do_selection_changed(GaimBlistNode *new_selection)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1611 {
5254
d1e1ca490894 [gaim-migrate @ 5626]
Luke Schierer <lschiere@pidgin.im>
parents: 5241
diff changeset
1612 GaimBlistNode *old_selection = NULL;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1613
5254
d1e1ca490894 [gaim-migrate @ 5626]
Luke Schierer <lschiere@pidgin.im>
parents: 5241
diff changeset
1614 /* test for gtkblist because crazy timeout means we can be called after the blist is gone */
d1e1ca490894 [gaim-migrate @ 5626]
Luke Schierer <lschiere@pidgin.im>
parents: 5241
diff changeset
1615 if (gtkblist && new_selection != gtkblist->selected_node) {
d1e1ca490894 [gaim-migrate @ 5626]
Luke Schierer <lschiere@pidgin.im>
parents: 5241
diff changeset
1616 old_selection = gtkblist->selected_node;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1617 gtkblist->selected_node = new_selection;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1618 if(new_selection)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1619 gaim_gtk_blist_update(NULL, new_selection);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1620 if(old_selection)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1621 gaim_gtk_blist_update(NULL, old_selection);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1622 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1623
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1624 return FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1625 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1626
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1627 static void gaim_gtk_blist_selection_changed(GtkTreeSelection *selection, gpointer data)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1628 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1629 GaimBlistNode *new_selection = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1630 GtkTreeIter iter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1631
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1632 if(gtk_tree_selection_get_selected(selection, NULL, &iter)){
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1633 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1634 NODE_COLUMN, &new_selection, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1635 }
5254
d1e1ca490894 [gaim-migrate @ 5626]
Luke Schierer <lschiere@pidgin.im>
parents: 5241
diff changeset
1636
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1637 /* we set this up as a timeout, otherwise the blist flickers */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1638 g_timeout_add(0, (GSourceFunc)do_selection_changed, new_selection);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1639 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1640
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1641 static void make_a_group(GaimBlistNode *node, GtkTreeIter *iter) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1642 GaimBlistNode *sibling;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1643 GtkTreeIter siblingiter;
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1644 GtkTreePath *newpath;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1645 struct group *group = (struct group *)node;
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1646 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1647 char *esc = g_markup_escape_text(group->name, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1648 char *mark;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1649
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1650 if(blist_options & OPT_BLIST_SHOW_GRPNUM)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1651 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));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1652 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1653 mark = g_strdup_printf("<span weight='bold'>%s</span>", esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1654
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1655 g_free(esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1656
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1657 sibling = node->prev;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1658 while (sibling && !get_iter_from_node(sibling, &siblingiter)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1659 sibling = sibling->prev;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1660 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1661
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1662 gtk_tree_store_insert_after(gtkblist->treemodel, iter, NULL,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1663 sibling ? &siblingiter : NULL);
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1664 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), iter);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1665 gtknode->row = gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), newpath);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1666 gtk_tree_path_free(newpath);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1667
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1668 gtk_tree_store_set(gtkblist->treemodel, iter,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1669 STATUS_ICON_COLUMN, NULL,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1670 STATUS_ICON_VISIBLE_COLUMN, FALSE,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1671 NAME_COLUMN, mark,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1672 NODE_COLUMN, node,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1673 -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1674 g_free(mark);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1675 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1676
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1677
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1678 static void gaim_gtk_blist_update(struct gaim_buddy_list *list, GaimBlistNode *node)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1679 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1680 GtkTreeIter iter;
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1681 GtkTreePath *expand = NULL, *newpath = NULL;
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1682 struct _gaim_gtk_blist_node *gtknode = (struct _gaim_gtk_blist_node *)node->ui_data;
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1683 gboolean new_entry = FALSE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1684
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1685 if (!gtkblist || !gtknode)
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1686 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1687
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1688 if (!get_iter_from_node(node, &iter)) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1689 new_entry = TRUE;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1690 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1691 if (((struct buddy*)node)->present != GAIM_BUDDY_OFFLINE || ((blist_options & OPT_BLIST_SHOW_OFFLINE) && ((struct buddy*)node)->account->gc)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1692 GtkTreeIter groupiter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1693 GaimBlistNode *oldersibling;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1694 GtkTreeIter oldersiblingiter;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1695 char *collapsed = gaim_group_get_setting((struct group *)node->parent, "collapsed");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1696
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1697 if(node->parent &&
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1698 !get_iter_from_node(node->parent, &groupiter)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1699 /* This buddy's group has not yet been added.
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1700 * We do that here */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1701 make_a_group(node->parent, &groupiter);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1702 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1703 if(!collapsed)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1704 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1705 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1706 g_free(collapsed);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1707
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1708 oldersibling = node->prev;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1709 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1710 oldersibling = oldersibling->prev;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1711 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1712
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1713 gtk_tree_store_insert_after(gtkblist->treemodel, &iter, &groupiter, oldersibling ? &oldersiblingiter : NULL);
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1714 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1715 gtknode->row = gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), newpath);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1716 gtk_tree_path_free(newpath);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1717
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1718 if (blist_options & OPT_BLIST_POPUP) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1719 gtk_widget_show(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1720 gtk_window_deiconify(GTK_WINDOW(gtkblist->window));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1721 gdk_window_raise(gtkblist->window->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1722 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1723
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1724 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1725 } else if (GAIM_BLIST_NODE_IS_CHAT(node) &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1726 ((struct chat *)node)->account->gc) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1727 GtkTreeIter groupiter;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1728 GaimBlistNode *oldersibling;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1729 GtkTreeIter oldersiblingiter;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1730 char *collapsed = gaim_group_get_setting((struct group *)node->parent, "collapsed");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1731
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1732 if(node->parent &&
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1733 !get_iter_from_node(node->parent, &groupiter)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1734 /* This buddy's group has not yet been added.
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1735 * We do that here */
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1736 make_a_group(node->parent, &groupiter);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1737 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1738 if(!collapsed)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1739 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1740 else
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1741 g_free(collapsed);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1742
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1743 oldersibling = node->prev;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1744 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter)) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1745 oldersibling = oldersibling->prev;
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1746 }
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1747
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1748 gtk_tree_store_insert_after(gtkblist->treemodel, &iter, &groupiter, oldersibling ? &oldersiblingiter : NULL);
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1749 newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1750 gtknode->row = gtk_tree_row_reference_new(GTK_TREE_MODEL(gtkblist->treemodel), newpath);
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
1751 gtk_tree_path_free(newpath);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1752
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1753 } else if (GAIM_BLIST_NODE_IS_GROUP(node) &&
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1754 ((blist_options & OPT_BLIST_SHOW_OFFLINE) ||
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1755 !(blist_options & OPT_BLIST_NO_MT_GRP))) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1756 make_a_group(node, &iter);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1757 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1758 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1759 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1760 if((blist_options & OPT_BLIST_NO_MT_GRP) && !(blist_options & OPT_BLIST_SHOW_OFFLINE) && !gaim_blist_get_group_online_count((struct group *)node)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1761 gtk_tree_store_remove(gtkblist->treemodel, &iter);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1762 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1763 struct group *group = (struct group *)node;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1764 char *esc = g_markup_escape_text(group->name, -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1765 char *mark;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1766
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1767 if(blist_options & OPT_BLIST_SHOW_GRPNUM)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1768 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));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1769 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1770 mark = g_strdup_printf("<span weight='bold'>%s</span>", esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1771
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1772 g_free(esc);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1773 gtk_tree_store_set(gtkblist->treemodel, &iter,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1774 NAME_COLUMN, mark,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1775 -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1776 g_free(mark);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1777 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1778 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1779
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1780 if (GAIM_BLIST_NODE_IS_CHAT(node) && ((struct chat*)node)->account->gc) {
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1781 GdkPixbuf *status;
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1782 struct chat *chat = (struct chat *)node;
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1783 char *name;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1784
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1785 status = gaim_gtk_blist_get_status_icon(node,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1786 blist_options & OPT_BLIST_SHOW_ICONS ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL);
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1787 if(chat->alias) {
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1788 name = g_markup_escape_text(chat->alias, -1);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1789 } else {
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1790 struct proto_chat_entry *pce;
5241
a3bb756635be [gaim-migrate @ 5612]
Nathan Walp <nwalp@pidgin.im>
parents: 5237
diff changeset
1791 GList *parts, *tmp;
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1792
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1793 parts = GAIM_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1794 pce = parts->data;
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1795 name = g_markup_escape_text(g_hash_table_lookup(chat->components,
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1796 pce->identifier), -1);
5241
a3bb756635be [gaim-migrate @ 5612]
Nathan Walp <nwalp@pidgin.im>
parents: 5237
diff changeset
1797 for(tmp = parts; tmp; tmp = tmp->next)
a3bb756635be [gaim-migrate @ 5612]
Nathan Walp <nwalp@pidgin.im>
parents: 5237
diff changeset
1798 g_free(tmp->data);
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1799 g_list_free(parts);
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1800 }
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1801
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1802
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1803 gtk_tree_store_set(gtkblist->treemodel, &iter,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1804 STATUS_ICON_COLUMN, status,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1805 STATUS_ICON_VISIBLE_COLUMN, TRUE,
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1806 NAME_COLUMN, name,
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1807 NODE_COLUMN, node,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1808 -1);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1809
5237
757d680f923d [gaim-migrate @ 5607]
Nathan Walp <nwalp@pidgin.im>
parents: 5234
diff changeset
1810 g_free(name);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1811 if (status != NULL)
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1812 g_object_unref(status);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1813 } else if(GAIM_BLIST_NODE_IS_CHAT(node) && !((struct chat *)node)->account->gc) {
5260
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1814 gaim_gtk_blist_hide_node(list, node);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1815 } else 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))) {
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1816 GdkPixbuf *status, *avatar;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1817 char *mark;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1818 char *warning = NULL, *idle = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1819
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1820 gboolean selected = (gtkblist->selected_node == node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1821
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1822 status = gaim_gtk_blist_get_status_icon(node,
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1823 blist_options & OPT_BLIST_SHOW_ICONS ? GAIM_STATUS_ICON_LARGE : GAIM_STATUS_ICON_SMALL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1824 avatar = gaim_gtk_blist_get_buddy_icon((struct buddy*)node);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1825 mark = gaim_gtk_blist_get_name_markup((struct buddy*)node, selected);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1826
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1827 if (((struct buddy*)node)->idle > 0) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1828 time_t t;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1829 int ihrs, imin;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1830 time(&t);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1831 ihrs = (t - ((struct buddy *)node)->idle) / 3600;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1832 imin = ((t - ((struct buddy*)node)->idle) / 60) % 60;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1833 if(ihrs > 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1834 idle = g_strdup_printf("(%d:%02d)", ihrs, imin);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1835 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1836 idle = g_strdup_printf("(%d)", imin);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1837 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1838
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1839 if (((struct buddy*)node)->evil > 0)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1840 warning = g_strdup_printf("%d%%", ((struct buddy*)node)->evil);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1841
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1842
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1843 if((blist_options & OPT_BLIST_GREY_IDLERS)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1844 && ((struct buddy *)node)->idle) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1845 if(warning && !selected) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1846 char *w2 = g_strdup_printf("<span color='dim grey'>%s</span>",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1847 warning);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1848 g_free(warning);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1849 warning = w2;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1850 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1851
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1852 if(idle && !selected) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1853 char *i2 = g_strdup_printf("<span color='dim grey'>%s</span>",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1854 idle);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1855 g_free(idle);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1856 idle = i2;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1857 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1858 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1859
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1860 gtk_tree_store_set(gtkblist->treemodel, &iter,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1861 STATUS_ICON_COLUMN, status,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1862 STATUS_ICON_VISIBLE_COLUMN, TRUE,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1863 NAME_COLUMN, mark,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1864 WARNING_COLUMN, warning,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1865 IDLE_COLUMN, idle,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1866 BUDDY_ICON_COLUMN, avatar,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1867 NODE_COLUMN, node,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1868 -1);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1869
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1870 if (blist_options & OPT_BLIST_POPUP &&
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1871 ((struct buddy *)node)->present == GAIM_BUDDY_SIGNING_OFF) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1872 gtk_widget_show(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1873 gtk_window_deiconify(GTK_WINDOW(gtkblist->window));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1874 gdk_window_raise(gtkblist->window->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1875 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1876
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1877 g_free(mark);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1878 if (idle)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1879 g_free(idle);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1880 if (warning)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1881 g_free(warning);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1882
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1883 if (status != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1884 g_object_unref(status);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1885
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1886 if (avatar != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1887 g_object_unref(avatar);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1888
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1889 } else if (GAIM_BLIST_NODE_IS_BUDDY(node) && !new_entry) {
5260
5331d5f11089 [gaim-migrate @ 5632]
Luke Schierer <lschiere@pidgin.im>
parents: 5256
diff changeset
1890 gaim_gtk_blist_hide_node(list, node);
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1891 }
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1892
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1893 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(gtkblist->treeview));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1894
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1895
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1896 if(expand) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1897 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), expand, TRUE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1898 gtk_tree_path_free(expand);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1899 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1900
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5228
diff changeset
1901 if(GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node))
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1902 gaim_gtk_blist_update(list, node->parent);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1903 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1904
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1905 static void gaim_gtk_blist_destroy(struct gaim_buddy_list *list)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1906 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1907 if (!gtkblist)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1908 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1909
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1910 gtk_widget_destroy(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1911 gtk_object_sink(GTK_OBJECT(gtkblist->tooltips));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1912
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1913 if (gtkblist->refresh_timer)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1914 g_source_remove(gtkblist->refresh_timer);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1915 if (gtkblist->timeout)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1916 g_source_remove(gtkblist->timeout);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1917
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1918 gtkblist->refresh_timer = 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1919 gtkblist->timeout = 0;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1920 gtkblist->window = gtkblist->vbox = gtkblist->treeview = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1921 gtkblist->treemodel = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1922 gtkblist->idle_column = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1923 gtkblist->warning_column = gtkblist->buddy_icon_column = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1924 gtkblist->bbox = gtkblist->tipwindow = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1925 protomenu = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1926 awaymenu = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1927 gtkblist = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1928 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1929
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1930 static void gaim_gtk_blist_set_visible(struct gaim_buddy_list *list, gboolean show)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1931 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1932 if (!(gtkblist && gtkblist->window))
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1933 return;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1934
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1935 if (show) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1936 gaim_gtk_blist_restore_position();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1937 gtk_window_present(GTK_WINDOW(gtkblist->window));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1938 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1939 if (!connections || docklet_count) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1940 #ifdef _WIN32
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1941 wgaim_systray_minimize(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1942 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1943 gtk_widget_hide(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1944 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1945 gtk_window_iconify(GTK_WINDOW(gtkblist->window));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1946 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1947 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1948 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1949
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1950 void gaim_gtk_blist_docklet_toggle() {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1951 /* Useful for the docklet plugin and also for the win32 tray icon*/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1952 /* This is called when one of those is clicked--it will show/hide the
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1953 buddy list/login window--depending on which is active */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1954 if (connections) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1955 if (gtkblist && gtkblist->window) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1956 if (GTK_WIDGET_VISIBLE(gtkblist->window)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1957 gaim_blist_set_visible(GAIM_WINDOW_ICONIFIED(gtkblist->window) || gaim_gtk_blist_obscured);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1958 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1959 #if _WIN32
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1960 wgaim_systray_maximize(gtkblist->window);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1961 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1962 gaim_blist_set_visible(TRUE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1963 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1964 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1965 /* we're logging in or something... do nothing */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1966 /* or should I make the blist? */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1967 gaim_debug(GAIM_DEBUG_WARNING, "blist",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1968 "docklet_toggle called with connections "
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1969 "but no blist!\n");
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1970 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1971 } else if (mainwindow) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1972 if (GTK_WIDGET_VISIBLE(mainwindow)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1973 if (GAIM_WINDOW_ICONIFIED(mainwindow)) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1974 gtk_window_present(GTK_WINDOW(mainwindow));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1975 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1976 #if _WIN32
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1977 wgaim_systray_minimize(mainwindow);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1978 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1979 gtk_widget_hide(mainwindow);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1980 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1981 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1982 #if _WIN32
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1983 wgaim_systray_maximize(mainwindow);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1984 #endif
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1985 show_login();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1986 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1987 } else {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1988 show_login();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1989 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1990 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1991
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1992 void gaim_gtk_blist_docklet_add()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1993 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1994 docklet_count++;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1995 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1996
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1997 void gaim_gtk_blist_docklet_remove()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1998 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1999 docklet_count--;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2000 if (!docklet_count) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2001 if (connections)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2002 gaim_blist_set_visible(TRUE);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2003 else if (mainwindow)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2004 gtk_window_present(GTK_WINDOW(mainwindow));
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2005 else
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2006 show_login();
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2007 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2008 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2009
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2010 static struct gaim_blist_ui_ops blist_ui_ops =
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2011 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2012 gaim_gtk_blist_new_list,
5256
1d1c45d9b7fc [gaim-migrate @ 5628]
Luke Schierer <lschiere@pidgin.im>
parents: 5254
diff changeset
2013 gaim_gtk_blist_new_node,
5228
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2014 gaim_gtk_blist_show,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2015 gaim_gtk_blist_update,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2016 gaim_gtk_blist_remove,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2017 gaim_gtk_blist_destroy,
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2018 gaim_gtk_blist_set_visible
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2019 };
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2020
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2021
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2022 struct gaim_blist_ui_ops *gaim_get_gtk_blist_ui_ops()
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2023 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2024 return &blist_ui_ops;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2025 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2026
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2027
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2028
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2029 /*********************************************************************
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2030 * Public utility functions *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2031 *********************************************************************/
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2032
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2033 GdkPixbuf *
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2034 create_prpl_icon(struct gaim_account *account)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2035 {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2036 GaimPlugin *prpl;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2037 GaimPluginProtocolInfo *prpl_info = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2038 GdkPixbuf *status = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2039 char *filename = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2040 const char *protoname = NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2041 char buf[256];
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2042
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2043 prpl = gaim_find_prpl(account->protocol);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2044
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2045 if (prpl != NULL) {
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2046 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2047
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2048 if (prpl_info->list_icon != NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2049 protoname = prpl_info->list_icon(account, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2050 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2051
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2052 if (protoname == NULL)
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2053 return NULL;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2054
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2055 /*
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2056 * Status icons will be themeable too, and then it will look up
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2057 * protoname from the theme
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2058 */
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2059 g_snprintf(buf, sizeof(buf), "%s.png", protoname);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2060
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2061 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2062 "default", buf, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2063 status = gdk_pixbuf_new_from_file(filename, NULL);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2064 g_free(filename);
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2065
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2066 return status;
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2067 }
1a53330dfd34 [gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2068