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