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