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