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