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