Debian Codegraph @

systray/src/gtk3/na-tray.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2002 Red Hat, Inc.
3 * Copyright (C) 2003-2006 Vincent Untz
4 * Copyright (C) 2007 Christian Persch
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22 #include <string.h>
23
24 #include <gtk/gtk.h>
25
26 #include "na-tray-manager.h"
27 #include "fixedtip.h"
28
29 #include "na-tray.h"
30
31 #define ICON_SPACING 3
32 #define MIN_BOX_SIZE 24
33
34 typedef struct
35 {
36 NaTrayManager *tray_manager;
37 GSList *all_trays;
38 GHashTable *icon_table;
39 GHashTable *tip_table;
40 } TraysScreen;
41
42 struct _NaTrayPrivate
43 {
44 GdkScreen *screen;
45 TraysScreen *trays_screen;
46
47 GtkWidget *box;
48 GtkWidget *frame;
49
50 guint idle_redraw_id;
51
52 GtkOrientation orientation;
53 };
54
55 typedef struct
56 {
57 char *text;
58 glong id;
59 glong timeout;
60 } IconTipBuffer;
61
62 typedef struct
63 {
64 NaTray *tray; /* tray containing the tray icon */
65 GtkWidget *icon; /* tray icon sending the message */
66 GtkWidget *fixedtip;
67 guint source_id;
68 glong id; /* id of the current message */
69 GSList *buffer; /* buffered messages */
70 } IconTip;
71
72 enum
73 {
74 PROP_0,
75 PROP_ORIENTATION,
76 PROP_SCREEN
77 };
78
79 static gboolean initialized = FALSE;
80 static TraysScreen *trays_screens = NULL;
81
82 static void icon_tip_show_next (IconTip *icontip);
83
84 /* NaTray */
85
86 G_DEFINE_TYPE (NaTray, na_tray, GTK_TYPE_BIN)
87
88 static NaTray *
89 get_tray (TraysScreen *trays_screen)
90 {
91 if (trays_screen->all_trays == NULL)
92 return NULL;
93
94 return trays_screen->all_trays->data;
95 }
96
97 const char *ordered_roles[] = {
98 "keyboard",
99 "volume",
100 "bluetooth",
101 "network",
102 "battery",
103 NULL
104 };
105
106 const char *wmclass_roles[] = {
107 "Bluetooth-applet", "bluetooth",
108 "Gnome-volume-control-applet", "volume",
109 "Nm-applet", "network",
110 "Gnome-power-manager", "battery",
111 "keyboard", "keyboard",
112 NULL,
113 };
114
115 static const char *
116 find_role (const char *wmclass)
117 {
118 int i;
119
120 for (i = 0; wmclass_roles[i]; i += 2)
121 {
122 if (strcmp (wmclass, wmclass_roles[i]) == 0)
123 return wmclass_roles[i + 1];
124 }
125
126 return NULL;
127 }
128
129 static int
130 find_role_position (const char *role)
131 {
132 int i;
133
134 for (i = 0; ordered_roles[i]; i++)
135 {
136 if (strcmp (role, ordered_roles[i]) == 0)
137 break;
138 }
139
140 return i + 1;
141 }
142
143 static int
144 find_icon_position (NaTray *tray,
145 GtkWidget *icon)
146 {
147 NaTrayPrivate *priv;
148 int position;
149 char *class_a;
150 const char *role;
151 int role_position;
152 GList *l, *children;
153
154 /* We insert the icons with a known roles in a specific order (the one
155 * defined by ordered_roles), and all other icons at the beginning of the box
156 * (left in LTR). */
157
158 priv = tray->priv;
159 position = 0;
160
161 class_a = NULL;
162 na_tray_child_get_wm_class (NA_TRAY_CHILD (icon), NULL, &class_a);
163 if (!class_a)
164 return position;
165
166 role = find_role (class_a);
167 g_free (class_a);
168 if (!role)
169 return position;
170
171 role_position = find_role_position (role);
172 g_object_set_data (G_OBJECT (icon), "role-position", GINT_TO_POINTER (role_position));
173
174 children = gtk_container_get_children (GTK_CONTAINER (priv->box));
175 for (l = g_list_last (children); l; l = l->prev)
176 {
177 GtkWidget *child = l->data;
178 int rp;
179
180 rp = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (child), "role-position"));
181 if (rp == 0 || rp < role_position)
182 {
183 position = g_list_index (children, child) + 1;
184 break;
185 }
186 }
187 g_list_free (children);
188
189 /* should never happen, but it doesn't hurt to be on the safe side */
190 if (position < 0)
191 position = 0;
192
193 return position;
194 }
195
196 static void
197 tray_added (NaTrayManager *manager,
198 GtkWidget *icon,
199 TraysScreen *trays_screen)
200 {
201 NaTray *tray;
202 NaTrayPrivate *priv;
203 int position;
204
205 tray = get_tray (trays_screen);
206 if (tray == NULL)
207 return;
208
209 priv = tray->priv;
210
211 g_assert (priv->trays_screen == trays_screen);
212
213 g_hash_table_insert (trays_screen->icon_table, icon, tray);
214
215 position = find_icon_position (tray, icon);
216 gtk_box_pack_start (GTK_BOX (priv->box), icon, FALSE, FALSE, 0);
217 gtk_box_reorder_child (GTK_BOX (priv->box), icon, position);
218
219 gtk_widget_show (icon);
220 }
221
222 static void
223 tray_removed (NaTrayManager *manager,
224 GtkWidget *icon,
225 TraysScreen *trays_screen)
226 {
227 NaTray *tray;
228 NaTrayPrivate *priv;
229
230 tray = g_hash_table_lookup (trays_screen->icon_table, icon);
231 if (tray == NULL)
232 return;
233
234 priv = tray->priv;
235
236 g_assert (tray->priv->trays_screen == trays_screen);
237
238 gtk_container_remove (GTK_CONTAINER (priv->box), icon);
239
240 g_hash_table_remove (trays_screen->icon_table, icon);
241 /* this will also destroy the tip associated to this icon */
242 g_hash_table_remove (trays_screen->tip_table, icon);
243 }
244
245 static void
246 icon_tip_buffer_free (gpointer data,
247 gpointer userdata)
248 {
249 IconTipBuffer *buffer;
250
251 buffer = data;
252
253 g_free (buffer->text);
254 buffer->text = NULL;
255
256 g_free (buffer);
257 }
258
259 static void
260 icon_tip_free (gpointer data)
261 {
262 IconTip *icontip;
263
264 if (data == NULL)
265 return;
266
267 icontip = data;
268
269 if (icontip->fixedtip != NULL)
270 gtk_widget_destroy (GTK_WIDGET (icontip->fixedtip));
271 icontip->fixedtip = NULL;
272
273 if (icontip->source_id != 0)
274 g_source_remove (icontip->source_id);
275 icontip->source_id = 0;
276
277 if (icontip->buffer != NULL)
278 {
279 g_slist_foreach (icontip->buffer, icon_tip_buffer_free, NULL);
280 g_slist_free (icontip->buffer);
281 }
282 icontip->buffer = NULL;
283
284 g_free (icontip);
285 }
286
287 static int
288 icon_tip_buffer_compare (gconstpointer a,
289 gconstpointer b)
290 {
291 const IconTipBuffer *buffer_a = a;
292 const IconTipBuffer *buffer_b = b;
293
294 if (buffer_a == NULL || buffer_b == NULL)
295 return !(buffer_a == buffer_b);
296
297 return buffer_a->id - buffer_b->id;
298 }
299
300 static void
301 icon_tip_show_next_clicked (GtkWidget *widget,
302 gpointer data)
303 {
304 icon_tip_show_next ((IconTip *) data);
305 }
306
307 static gboolean
308 icon_tip_show_next_timeout (gpointer data)
309 {
310 IconTip *icontip = (IconTip *) data;
311
312 icon_tip_show_next (icontip);
313
314 return FALSE;
315 }
316
317 static void
318 icon_tip_show_next (IconTip *icontip)
319 {
320 IconTipBuffer *buffer;
321
322 if (icontip->buffer == NULL)
323 {
324 /* this will also destroy the tip window */
325 g_hash_table_remove (icontip->tray->priv->trays_screen->tip_table,
326 icontip->icon);
327 return;
328 }
329
330 if (icontip->source_id != 0)
331 g_source_remove (icontip->source_id);
332 icontip->source_id = 0;
333
334 buffer = icontip->buffer->data;
335 icontip->buffer = g_slist_remove (icontip->buffer, buffer);
336
337 if (icontip->fixedtip == NULL)
338 {
339 icontip->fixedtip = na_fixed_tip_new (icontip->icon,
340 na_tray_get_orientation (icontip->tray));
341
342 g_signal_connect (icontip->fixedtip, "clicked",
343 G_CALLBACK (icon_tip_show_next_clicked), icontip);
344 }
345
346 na_fixed_tip_set_markup (icontip->fixedtip, buffer->text);
347
348 if (!gtk_widget_get_mapped (icontip->fixedtip))
349 gtk_widget_show (icontip->fixedtip);
350
351 icontip->id = buffer->id;
352
353 if (buffer->timeout > 0)
354 icontip->source_id = g_timeout_add_seconds (buffer->timeout,
355 icon_tip_show_next_timeout,
356 icontip);
357
358 icon_tip_buffer_free (buffer, NULL);
359 }
360
361 static void
362 message_sent (NaTrayManager *manager,
363 GtkWidget *icon,
364 const char *text,
365 glong id,
366 glong timeout,
367 TraysScreen *trays_screen)
368 {
369 IconTip *icontip;
370 IconTipBuffer find_buffer;
371 IconTipBuffer *buffer;
372 gboolean show_now;
373
374 icontip = g_hash_table_lookup (trays_screen->tip_table, icon);
375
376 find_buffer.id = id;
377 if (icontip &&
378 (icontip->id == id ||
379 g_slist_find_custom (icontip->buffer, &find_buffer,
380 icon_tip_buffer_compare) != NULL))
381 /* we already have this message, so ignore it */
382 /* FIXME: in an ideal world, we'd remember all the past ids and ignore them
383 * too */
384 return;
385
386 show_now = FALSE;
387
388 if (icontip == NULL)
389 {
390 NaTray *tray;
391
392 tray = g_hash_table_lookup (trays_screen->icon_table, icon);
393 if (tray == NULL)
394 {
395 /* We don't know about the icon sending the message, so ignore it.
396 * But this should never happen since NaTrayManager shouldn't send
397 * us the message if there's no socket for it. */
398 g_critical ("Ignoring a message sent by a tray icon "
399 "we don't know: \"%s\".\n", text);
400 return;
401 }
402
403 icontip = g_new0 (IconTip, 1);
404 icontip->tray = tray;
405 icontip->icon = icon;
406
407 g_hash_table_insert (trays_screen->tip_table, icon, icontip);
408
409 show_now = TRUE;
410 }
411
412 buffer = g_new0 (IconTipBuffer, 1);
413
414 buffer->text = g_strdup (text);
415 buffer->id = id;
416 buffer->timeout = timeout;
417
418 icontip->buffer = g_slist_append (icontip->buffer, buffer);
419
420 if (show_now)
421 icon_tip_show_next (icontip);
422 }
423
424 static void
425 message_cancelled (NaTrayManager *manager,
426 GtkWidget *icon,
427 glong id,
428 TraysScreen *trays_screen)
429 {
430 IconTip *icontip;
431 IconTipBuffer find_buffer;
432 GSList *cancel_buffer_l;
433 IconTipBuffer *cancel_buffer;
434
435 icontip = g_hash_table_lookup (trays_screen->tip_table, icon);
436 if (icontip == NULL)
437 return;
438
439 if (icontip->id == id)
440 {
441 icon_tip_show_next (icontip);
442 return;
443 }
444
445 find_buffer.id = id;
446 cancel_buffer_l = g_slist_find_custom (icontip->buffer, &find_buffer,
447 icon_tip_buffer_compare);
448 if (cancel_buffer_l == NULL)
449 return;
450
451 cancel_buffer = cancel_buffer_l->data;
452 icon_tip_buffer_free (cancel_buffer, NULL);
453
454 icontip->buffer = g_slist_remove_link (icontip->buffer, cancel_buffer_l);
455 g_slist_free_1 (cancel_buffer_l);
456 }
457
458 static void
459 update_orientation_for_messages (gpointer key,
460 gpointer value,
461 gpointer data)
462 {
463 NaTray *tray;
464 IconTip *icontip;
465
466 if (value == NULL)
467 return;
468
469 icontip = value;
470 tray = data;
471 if (icontip->tray != tray)
472 return;
473
474 if (icontip->fixedtip)
475 na_fixed_tip_set_orientation (icontip->fixedtip, tray->priv->orientation);
476 }
477
478 static void
479 update_size_and_orientation (NaTray *tray)
480 {
481 NaTrayPrivate *priv = tray->priv;
482
483 gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->box), priv->orientation);
484
485 /* This only happens when setting the property during object construction */
486 if (!priv->trays_screen)
487 return;
488
489 g_hash_table_foreach (priv->trays_screen->tip_table,
490 update_orientation_for_messages, tray);
491
492 if (get_tray (priv->trays_screen) == tray)
493 na_tray_manager_set_orientation (priv->trays_screen->tray_manager,
494 priv->orientation);
495
496 /* note, you want this larger if the frame has non-NONE relief by default. */
497 switch (priv->orientation)
498 {
499 case GTK_ORIENTATION_VERTICAL:
500 /* Give box a min size so the frame doesn't look dumb */
501 gtk_widget_set_size_request (priv->box, MIN_BOX_SIZE, -1);
502 break;
503 case GTK_ORIENTATION_HORIZONTAL:
504 gtk_widget_set_size_request (priv->box, -1, MIN_BOX_SIZE);
505 break;
506 }
507 }
508
509 /* Children with alpha channels have been set to be composited by calling
510 * gdk_window_set_composited(). We need to paint these children ourselves.
511 */
512 static void
513 na_tray_draw_icon (GtkWidget *widget,
514 gpointer data)
515 {
516 cairo_t *cr = (cairo_t *) data;
517
518 if (na_tray_child_has_alpha (NA_TRAY_CHILD (widget)))
519 {
520 GtkAllocation allocation;
521
522 gtk_widget_get_allocation (widget, &allocation);
523
524 cairo_save (cr);
525 gdk_cairo_set_source_window (cr,
526 gtk_widget_get_window (widget),
527 allocation.x,
528 allocation.y);
529 cairo_rectangle (cr, allocation.x, allocation.y, allocation.width, allocation.height);
530 cairo_clip (cr);
531 cairo_paint (cr);
532 cairo_restore (cr);
533 }
534 }
535
536 static void
537 na_tray_draw_box (GtkWidget *box,
538 cairo_t *cr)
539 {
540 gtk_container_foreach (GTK_CONTAINER (box), na_tray_draw_icon, cr);
541 }
542
543 static void
544 na_tray_init (NaTray *tray)
545 {
546 NaTrayPrivate *priv;
547
548 priv = tray->priv = G_TYPE_INSTANCE_GET_PRIVATE (tray, NA_TYPE_TRAY, NaTrayPrivate);
549
550 priv->screen = NULL;
551 priv->orientation = GTK_ORIENTATION_HORIZONTAL;
552
553 priv->frame = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
554 gtk_container_add (GTK_CONTAINER (tray), priv->frame);
555 gtk_widget_show (priv->frame);
556
557 priv->box = gtk_box_new (priv->orientation, ICON_SPACING);
558 g_signal_connect (priv->box, "draw",
559 G_CALLBACK (na_tray_draw_box), NULL);
560 gtk_container_add (GTK_CONTAINER (priv->frame), priv->box);
561 gtk_widget_show (priv->box);
562 }
563
564 static GObject *
565 na_tray_constructor (GType type,
566 guint n_construct_properties,
567 GObjectConstructParam *construct_params)
568 {
569 GObject *object;
570 NaTray *tray;
571 NaTrayPrivate *priv;
572
573 object = G_OBJECT_CLASS (na_tray_parent_class)->constructor (type,
574 n_construct_properties,
575 construct_params);
576 tray = NA_TRAY (object);
577 priv = tray->priv;
578
579 g_assert (priv->screen != NULL);
580
581 if (!initialized)
582 {
583 trays_screens = g_new0 (TraysScreen, 1);
584 initialized = TRUE;
585 }
586
587 if (trays_screens->tray_manager == NULL)
588 {
589 NaTrayManager *tray_manager;
590
591 tray_manager = na_tray_manager_new ();
592
593 if (na_tray_manager_manage_screen (tray_manager, priv->screen))
594 {
595 trays_screens->tray_manager = tray_manager;
596
597 g_signal_connect (tray_manager, "tray_icon_added",
598 G_CALLBACK (tray_added),
599 trays_screens);
600 g_signal_connect (tray_manager, "tray_icon_removed",
601 G_CALLBACK (tray_removed),
602 trays_screens);
603 g_signal_connect (tray_manager, "message_sent",
604 G_CALLBACK (message_sent),
605 trays_screens);
606 g_signal_connect (tray_manager, "message_cancelled",
607 G_CALLBACK (message_cancelled),
608 trays_screens);
609
610 trays_screens->icon_table = g_hash_table_new (NULL,
611 NULL);
612 trays_screens->tip_table = g_hash_table_new_full (
613 NULL,
614 NULL,
615 NULL,
616 icon_tip_free);
617 }
618 else
619 {
620 g_printerr ("System tray didn't get the system tray manager selection for screen %d\n",
621 gdk_screen_get_number (priv->screen));
622 g_object_unref (tray_manager);
623 }
624 }
625
626 priv->trays_screen = trays_screens;
627 trays_screens->all_trays = g_slist_append (trays_screens->all_trays,
628 tray);
629
630 update_size_and_orientation (tray);
631
632 return object;
633 }
634
635 static void
636 na_tray_dispose (GObject *object)
637 {
638 NaTray *tray = NA_TRAY (object);
639 NaTrayPrivate *priv = tray->priv;
640 TraysScreen *trays_screen = priv->trays_screen;
641
642 if (trays_screen != NULL)
643 {
644 trays_screen->all_trays = g_slist_remove (trays_screen->all_trays, tray);
645
646 if (trays_screen->all_trays == NULL)
647 {
648 /* Make sure we drop the manager selection */
649 g_object_unref (trays_screen->tray_manager);
650 trays_screen->tray_manager = NULL;
651
652 g_hash_table_destroy (trays_screen->icon_table);
653 trays_screen->icon_table = NULL;
654
655 g_hash_table_destroy (trays_screen->tip_table);
656 trays_screen->tip_table = NULL;
657 }
658 else
659 {
660 NaTray *new_tray;
661
662 new_tray = get_tray (trays_screen);
663 if (new_tray != NULL)
664 na_tray_manager_set_orientation (trays_screen->tray_manager,
665 na_tray_get_orientation (new_tray));
666 }
667 }
668
669 priv->trays_screen = NULL;
670
671 if (priv->idle_redraw_id != 0)
672 {
673 g_source_remove (priv->idle_redraw_id);
674 priv->idle_redraw_id = 0;
675 }
676
677 G_OBJECT_CLASS (na_tray_parent_class)->dispose (object);
678 }
679
680 static void
681 na_tray_set_property (GObject *object,
682 guint prop_id,
683 const GValue *value,
684 GParamSpec *pspec)
685 {
686 NaTray *tray = NA_TRAY (object);
687 NaTrayPrivate *priv = tray->priv;
688
689 switch (prop_id)
690 {
691 case PROP_ORIENTATION:
692 na_tray_set_orientation (tray, g_value_get_enum (value));
693 break;
694 case PROP_SCREEN:
695 priv->screen = g_value_get_object (value);
696 break;
697 default:
698 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
699 break;
700 }
701 }
702
703 static void
704 na_tray_get_preferred_width (GtkWidget *widget,
705 gint *minimal_width,
706 gint *natural_width)
707 {
708 gtk_widget_get_preferred_width (gtk_bin_get_child (GTK_BIN (widget)),
709 minimal_width,
710 natural_width);
711 }
712
713 static void
714 na_tray_get_preferred_height (GtkWidget *widget,
715 gint *minimal_height,
716 gint *natural_height)
717 {
718 gtk_widget_get_preferred_height (gtk_bin_get_child (GTK_BIN (widget)),
719 minimal_height,
720 natural_height);
721 }
722
723 static void
724 na_tray_size_allocate (GtkWidget *widget,
725 GtkAllocation *allocation)
726 {
727 gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), allocation);
728 gtk_widget_set_allocation (widget, allocation);
729 }
730
731 static void
732 na_tray_class_init (NaTrayClass *klass)
733 {
734 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
735 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
736
737 gobject_class->constructor = na_tray_constructor;
738 gobject_class->set_property = na_tray_set_property;
739 gobject_class->dispose = na_tray_dispose;
740 widget_class->get_preferred_width = na_tray_get_preferred_width;
741 widget_class->get_preferred_height = na_tray_get_preferred_height;
742 widget_class->size_allocate = na_tray_size_allocate;
743
744 g_object_class_install_property
745 (gobject_class,
746 PROP_ORIENTATION,
747 g_param_spec_enum ("orientation", "orientation", "orientation",
748 GTK_TYPE_ORIENTATION,
749 GTK_ORIENTATION_HORIZONTAL,
750 G_PARAM_WRITABLE |
751 G_PARAM_CONSTRUCT_ONLY |
752 G_PARAM_STATIC_NAME |
753 G_PARAM_STATIC_NICK |
754 G_PARAM_STATIC_BLURB));
755
756 g_object_class_install_property
757 (gobject_class,
758 PROP_SCREEN,
759 g_param_spec_object ("screen", "screen", "screen",
760 GDK_TYPE_SCREEN,
761 G_PARAM_WRITABLE |
762 G_PARAM_CONSTRUCT_ONLY |
763 G_PARAM_STATIC_NAME |
764 G_PARAM_STATIC_NICK |
765 G_PARAM_STATIC_BLURB));
766
767 g_type_class_add_private (gobject_class, sizeof (NaTrayPrivate));
768 }
769
770 NaTray *
771 na_tray_new_for_screen (GdkScreen *screen,
772 GtkOrientation orientation)
773 {
774 return g_object_new (NA_TYPE_TRAY,
775 "screen", screen,
776 "orientation", orientation,
777 NULL);
778 }
779
780 void
781 na_tray_set_orientation (NaTray *tray,
782 GtkOrientation orientation)
783 {
784 NaTrayPrivate *priv = tray->priv;
785
786 if (orientation == priv->orientation)
787 return;
788
789 priv->orientation = orientation;
790
791 update_size_and_orientation (tray);
792 }
793
794 GtkOrientation
795 na_tray_get_orientation (NaTray *tray)
796 {
797 return tray->priv->orientation;
798 }
799
800 static gboolean
801 idle_redraw_cb (NaTray *tray)
802 {
803 NaTrayPrivate *priv = tray->priv;
804
805 gtk_container_foreach (GTK_CONTAINER (priv->box), (GtkCallback)na_tray_child_force_redraw, tray);
806
807 priv->idle_redraw_id = 0;
808
809 return FALSE;
810 }
811
812 void
813 na_tray_set_padding (NaTray *tray,
814 gint padding)
815 {
816 NaTrayPrivate *priv = tray->priv;
817
818 if (get_tray (priv->trays_screen) == tray)
819 na_tray_manager_set_padding (priv->trays_screen->tray_manager, padding);
820 }
821
822 void
823 na_tray_set_icon_size (NaTray *tray,
824 gint size)
825 {
826 NaTrayPrivate *priv = tray->priv;
827
828 if (get_tray (priv->trays_screen) == tray)
829 na_tray_manager_set_icon_size (priv->trays_screen->tray_manager, size);
830 }
831
832 void
833 na_tray_set_colors (NaTray *tray,
834 GdkColor *fg,
835 GdkColor *error,
836 GdkColor *warning,
837 GdkColor *success)
838 {
839 NaTrayPrivate *priv = tray->priv;
840
841 if (get_tray (priv->trays_screen) == tray)
842 na_tray_manager_set_colors (priv->trays_screen->tray_manager, fg, error, warning, success);
843 }
844
845 void
846 na_tray_force_redraw (NaTray *tray)
847 {
848 NaTrayPrivate *priv = tray->priv;
849
850 /* Force the icons to redraw their backgrounds.
851 */
852 if (priv->idle_redraw_id == 0)
853 priv->idle_redraw_id = g_idle_add ((GSourceFunc) idle_redraw_cb, tray);
854 }