]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-status-icon.c
Completely reworked ContactList API. Fixes bug #471611, bug #467280, bug #459540...
[empathy.git] / libempathy-gtk / empathy-status-icon.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2007 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  * 
20  * Authors: Xavier Claessens <xclaesse@gmail.com>
21  */
22
23 #include <config.h>
24
25 #include <string.h>
26
27 #include <gtk/gtk.h>
28 #include <glade/glade.h>
29 #include <glib/gi18n.h>
30
31 #include <libmissioncontrol/mission-control.h>
32
33 #include <libempathy/empathy-contact-list.h>
34 #include <libempathy/empathy-contact-manager.h>
35 #include <libempathy/empathy-contact.h>
36 #include <libempathy/empathy-tp-chat.h>
37 #include <libempathy/empathy-debug.h>
38 #include <libempathy/empathy-utils.h>
39 #include <libempathy/empathy-conf.h>
40 #include <libempathy/empathy-idle.h>
41 #include <libempathy/empathy-filter.h>
42
43 #include "empathy-status-icon.h"
44 #include "empathy-contact-dialogs.h"
45 #include "empathy-presence-chooser.h"
46 #include "empathy-preferences.h"
47 #include "empathy-ui-utils.h"
48 #include "empathy-accounts-dialog.h"
49 #include "empathy-images.h"
50
51
52 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
53                        EMPATHY_TYPE_STATUS_ICON, EmpathyStatusIconPriv))
54
55 #define DEBUG_DOMAIN "StatusIcon"
56
57 /* Number of ms to wait when blinking */
58 #define BLINK_TIMEOUT 500
59
60 typedef struct _StatusIconEvent StatusIconEvent;
61
62 struct _EmpathyStatusIconPriv {
63         GtkStatusIcon         *icon;
64         EmpathyContactManager *manager;
65         EmpathyFilter         *text_filter;
66         EmpathyIdle           *idle;
67         MissionControl        *mc;
68         GList                 *events;
69         gboolean               showing_event_icon;
70         StatusIconEvent       *flash_state_event;
71         guint                  blink_timeout;
72
73         GtkWindow             *window;
74         GtkWidget             *popup_menu;
75         GtkWidget             *show_window_item;
76         GtkWidget             *message_item;
77         GtkWidget             *status_item;
78 };
79
80 typedef void (*EventActivatedFunc) (StatusIconEvent *event);
81
82 struct _StatusIconEvent {
83         gchar              *icon_name;
84         gchar              *message;
85         EventActivatedFunc  func;
86         gpointer            user_data;
87 };
88
89
90 static void       empathy_status_icon_class_init  (EmpathyStatusIconClass *klass);
91 static void       empathy_status_icon_init        (EmpathyStatusIcon      *icon);
92 static void       status_icon_finalize            (GObject                *object);
93 static void       status_icon_filter_new_channel  (EmpathyFilter          *filter,
94                                                    TpConn                 *tp_conn,
95                                                    TpChan                 *tp_chan,
96                                                    EmpathyStatusIcon      *icon);
97 static void       status_icon_message_received_cb (EmpathyTpChat          *tp_chat,
98                                                    EmpathyMessage         *message,
99                                                    EmpathyStatusIcon      *icon);
100 static void       status_icon_idle_notify_cb      (EmpathyStatusIcon      *icon);
101 static void       status_icon_update_tooltip      (EmpathyStatusIcon      *icon);
102 static void       status_icon_set_from_state      (EmpathyStatusIcon      *icon);
103 static void       status_icon_toggle_visibility   (EmpathyStatusIcon      *icon);
104 static void       status_icon_activate_cb         (GtkStatusIcon          *status_icon,
105                                                    EmpathyStatusIcon      *icon);
106 static gboolean   status_icon_delete_event_cb     (GtkWidget              *widget,
107                                                    GdkEvent               *event,
108                                                    EmpathyStatusIcon      *icon);
109 static void       status_icon_popup_menu_cb       (GtkStatusIcon          *status_icon,
110                                                    guint                   button,
111                                                    guint                   activate_time,
112                                                    EmpathyStatusIcon      *icon);
113 static void       status_icon_create_menu         (EmpathyStatusIcon      *icon);
114 static void       status_icon_new_message_cb      (GtkWidget              *widget,
115                                                    EmpathyStatusIcon      *icon);
116 static void       status_icon_quit_cb             (GtkWidget              *window,
117                                                    EmpathyStatusIcon      *icon);
118 static void       status_icon_show_hide_window_cb (GtkWidget              *widget,
119                                                    EmpathyStatusIcon      *icon);
120 static void       status_icon_pendings_changed_cb (EmpathyContactManager  *manager,
121                                                    EmpathyContact         *contact,
122                                                    EmpathyContact         *actor,
123                                                    guint                   reason,
124                                                    gchar                  *message,
125                                                    gboolean                is_pending,
126                                                    EmpathyStatusIcon      *icon);
127 static void       status_icon_event_subscribe_cb  (StatusIconEvent        *event);
128 static void       status_icon_event_flash_state_cb (StatusIconEvent       *event);
129 static void       status_icon_event_msg_cb        (StatusIconEvent        *event);
130 static StatusIconEvent * status_icon_event_new    (EmpathyStatusIcon      *icon,
131                                                    const gchar            *icon_name,
132                                                    const gchar            *message);
133 static void       status_icon_event_remove        (EmpathyStatusIcon      *icon,
134                                                    StatusIconEvent        *event);
135 static gboolean   status_icon_event_timeout_cb    (EmpathyStatusIcon      *icon);
136 static void       status_icon_event_free          (StatusIconEvent        *event);
137
138 G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
139
140 static void
141 empathy_status_icon_class_init (EmpathyStatusIconClass *klass)
142 {
143         GObjectClass *object_class = G_OBJECT_CLASS (klass);
144
145         object_class->finalize = status_icon_finalize;
146
147         g_type_class_add_private (object_class, sizeof (EmpathyStatusIconPriv));
148 }
149
150 static void
151 empathy_status_icon_init (EmpathyStatusIcon *icon)
152 {
153         EmpathyStatusIconPriv *priv;
154         GList                 *pendings, *l;
155
156         priv = GET_PRIV (icon);
157
158         priv->icon = gtk_status_icon_new ();
159         priv->idle = empathy_idle_new ();
160         priv->manager = empathy_contact_manager_new ();
161         priv->mc = empathy_mission_control_new ();
162         priv->text_filter = empathy_filter_new ("org.gnome.Empathy.Chat",
163                                                 "/org/freedesktop/Telepathy/Filter",
164                                                 TP_IFACE_CHANNEL_TYPE_TEXT,
165                                                 MC_FILTER_PRIORITY_DIALOG,
166                                                 MC_FILTER_FLAG_INCOMING);
167
168         status_icon_create_menu (icon);
169         status_icon_idle_notify_cb (icon);
170
171         g_signal_connect (priv->text_filter, "new-channel",
172                           G_CALLBACK (status_icon_filter_new_channel),
173                           icon);
174         g_signal_connect_swapped (priv->idle, "notify",
175                                   G_CALLBACK (status_icon_idle_notify_cb),
176                                   icon);
177         g_signal_connect (priv->icon, "activate",
178                           G_CALLBACK (status_icon_activate_cb),
179                           icon);
180         g_signal_connect (priv->icon, "popup-menu",
181                           G_CALLBACK (status_icon_popup_menu_cb),
182                           icon);
183         g_signal_connect (priv->manager, "pendings-changed",
184                           G_CALLBACK (status_icon_pendings_changed_cb),
185                           icon);
186
187         pendings = empathy_contact_list_get_pendings (EMPATHY_CONTACT_LIST (priv->manager));
188         for (l = pendings; l; l = l->next) {
189                 EmpathyPendingInfo *info;
190
191                 info = l->data;
192                 status_icon_pendings_changed_cb (priv->manager,
193                                                  info->member,
194                                                  info->actor,
195                                                  0,
196                                                  info->message,
197                                                  TRUE,
198                                                  icon);
199                 empathy_pending_info_free (info);
200         }
201         g_list_free (pendings);
202 }
203
204 static void
205 status_icon_finalize (GObject *object)
206 {
207         EmpathyStatusIconPriv *priv;
208
209         priv = GET_PRIV (object);
210
211         g_list_foreach (priv->events, (GFunc) status_icon_event_free, NULL);
212         g_list_free (priv->events);
213
214         if (priv->blink_timeout) {
215                 g_source_remove (priv->blink_timeout);
216         }
217
218         g_object_unref (priv->icon);
219         g_object_unref (priv->window);
220         g_object_unref (priv->idle);
221         g_object_unref (priv->manager);
222         g_object_unref (priv->mc);
223 }
224
225 EmpathyStatusIcon *
226 empathy_status_icon_new (GtkWindow *window)
227 {
228         EmpathyStatusIconPriv *priv;
229         EmpathyStatusIcon     *icon;
230         gboolean               should_hide;
231         gboolean               visible;
232
233         g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
234
235         icon = g_object_new (EMPATHY_TYPE_STATUS_ICON, NULL);
236         priv = GET_PRIV (icon);
237
238         priv->window = g_object_ref (window);
239
240         g_signal_connect (priv->window, "delete-event",
241                           G_CALLBACK (status_icon_delete_event_cb),
242                           icon);
243
244         empathy_conf_get_bool (empathy_conf_get (),
245                               EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
246                               &should_hide);
247         visible = empathy_window_get_is_visible (window);
248
249         if ((!should_hide && !visible) || (should_hide && visible)) {
250                 status_icon_toggle_visibility (icon);
251         }
252
253         return icon;
254 }
255
256 static void
257 status_icon_filter_new_channel (EmpathyFilter     *filter,
258                                 TpConn            *tp_conn,
259                                 TpChan            *tp_chan,
260                                 EmpathyStatusIcon *icon)
261 {
262         EmpathyStatusIconPriv *priv;
263         McAccount             *account;
264         EmpathyTpChat         *tp_chat;
265         GList                 *messages;
266
267         priv = GET_PRIV (icon);
268
269         account = mission_control_get_account_for_connection (priv->mc, tp_conn, NULL);
270
271         empathy_debug (DEBUG_DOMAIN, "New text channel to be filtered for contact %s",
272                        empathy_inspect_channel (account, tp_chan));
273
274         tp_chat = empathy_tp_chat_new (account, tp_chan);
275         g_object_set_data (G_OBJECT (tp_chat), "filter", filter);
276         g_object_unref (account);
277
278         messages = empathy_tp_chat_get_pendings (tp_chat);
279         if (!messages) {
280                 empathy_debug (DEBUG_DOMAIN, "No pending msg, waiting...");
281                 g_signal_connect (tp_chat, "message-received",
282                                   G_CALLBACK (status_icon_message_received_cb),
283                                   icon);
284                 return;
285         }
286
287         status_icon_message_received_cb (tp_chat, messages->data, icon);
288
289         g_list_foreach (messages, (GFunc) g_object_unref, NULL);
290         g_list_free (messages);
291 }
292
293 static void
294 status_icon_message_received_cb (EmpathyTpChat     *tp_chat,
295                                  EmpathyMessage    *message,
296                                  EmpathyStatusIcon *icon)
297 {
298         EmpathyContact  *sender;
299         gchar           *msg;
300         StatusIconEvent *event;
301
302         empathy_debug (DEBUG_DOMAIN, "Message received, add event");
303
304         g_signal_handlers_disconnect_by_func (tp_chat,
305                                               status_icon_message_received_cb,
306                                               icon);
307
308         sender = empathy_message_get_sender (message);
309         msg = g_strdup_printf (_("New message from %s:\n%s"),
310                                empathy_contact_get_name (sender),
311                                empathy_message_get_body (message));
312
313         event = status_icon_event_new (icon, EMPATHY_IMAGE_NEW_MESSAGE, msg);
314         event->func = status_icon_event_msg_cb;
315         event->user_data = tp_chat;
316 }
317
318 static void
319 status_icon_idle_notify_cb (EmpathyStatusIcon *icon)
320 {
321         EmpathyStatusIconPriv *priv;
322         McPresence             flash_state;
323
324         priv = GET_PRIV (icon);
325
326         flash_state = empathy_idle_get_flash_state (priv->idle);
327         if (flash_state != MC_PRESENCE_UNSET) {
328                 const gchar *icon_name;
329
330                 icon_name = empathy_icon_name_for_presence_state (flash_state);
331                 if (!priv->flash_state_event) {
332                         /* We are now flashing */
333                         priv->flash_state_event = status_icon_event_new (icon, icon_name, NULL);
334                         priv->flash_state_event->user_data = icon;
335                         priv->flash_state_event->func = status_icon_event_flash_state_cb;
336                 } else {
337                         /* We are still flashing but with another state */
338                         g_free (priv->flash_state_event->icon_name);
339                         priv->flash_state_event->icon_name = g_strdup (icon_name);
340                 }
341         }
342         else if (priv->flash_state_event) {
343                 /* We are no more flashing */
344                 status_icon_event_remove (icon, priv->flash_state_event);
345                 priv->flash_state_event = NULL;
346         }
347
348         if (!priv->showing_event_icon) {
349                 status_icon_set_from_state (icon);
350         }
351
352         status_icon_update_tooltip (icon);
353 }
354
355 static void
356 status_icon_update_tooltip (EmpathyStatusIcon *icon)
357 {
358         EmpathyStatusIconPriv *priv;
359         const gchar           *tooltip = NULL;
360
361         priv = GET_PRIV (icon);
362
363         if (priv->events) {
364                 StatusIconEvent *event;
365
366                 event = priv->events->data;
367                 tooltip = event->message;
368         }
369
370         if (!tooltip) {
371                 tooltip = empathy_idle_get_status (priv->idle);
372         }
373
374         gtk_status_icon_set_tooltip (priv->icon, tooltip);      
375 }
376
377 static void
378 status_icon_set_from_state (EmpathyStatusIcon *icon)
379 {
380         EmpathyStatusIconPriv *priv;
381         McPresence             state;
382         const gchar           *icon_name;
383
384         priv = GET_PRIV (icon);
385
386         state = empathy_idle_get_state (priv->idle);
387         icon_name = empathy_icon_name_for_presence_state (state);
388         gtk_status_icon_set_from_icon_name (priv->icon, icon_name);
389 }
390
391 static void
392 status_icon_toggle_visibility (EmpathyStatusIcon *icon)
393 {
394         EmpathyStatusIconPriv *priv;
395         gboolean               visible;
396
397         priv = GET_PRIV (icon);
398
399         visible = gtk_window_has_toplevel_focus (GTK_WINDOW (priv->window));
400
401         if (visible) {
402                 empathy_window_iconify (priv->window, priv->icon);
403                 empathy_conf_set_bool (empathy_conf_get (),
404                                       EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, TRUE);
405         } else {
406                 GList *accounts;
407
408                 empathy_window_present (GTK_WINDOW (priv->window), TRUE);
409                 empathy_conf_set_bool (empathy_conf_get (),
410                                       EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, FALSE);
411         
412                 /* Show the accounts dialog if there is no enabled accounts */
413                 accounts = mc_accounts_list_by_enabled (TRUE);
414                 if (accounts) {
415                         mc_accounts_list_free (accounts);
416                 } else {
417                         empathy_debug (DEBUG_DOMAIN,
418                                       "No enabled account, Showing account dialog");
419                         empathy_accounts_dialog_show (GTK_WINDOW (priv->window));
420                 }
421         }
422 }
423
424 static void
425 status_icon_activate_cb (GtkStatusIcon     *status_icon,
426                          EmpathyStatusIcon *icon)
427 {
428         EmpathyStatusIconPriv *priv;
429
430         priv = GET_PRIV (icon);
431
432         empathy_debug (DEBUG_DOMAIN, "Activated: %s",
433                        priv->events ? "event" : "toggle");
434
435         if (priv->events) {
436                 status_icon_event_remove (icon, priv->events->data);
437         } else {
438                 status_icon_toggle_visibility (icon);
439         }
440 }
441
442 static gboolean
443 status_icon_delete_event_cb (GtkWidget         *widget,
444                              GdkEvent          *event,
445                              EmpathyStatusIcon *icon)
446 {
447         status_icon_toggle_visibility (icon);
448
449         return TRUE;
450 }
451
452 static void
453 status_icon_popup_menu_cb (GtkStatusIcon     *status_icon,
454                            guint              button,
455                            guint              activate_time,
456                            EmpathyStatusIcon *icon)
457 {
458         EmpathyStatusIconPriv *priv;
459         GtkWidget             *submenu;
460         gboolean               show;
461
462         priv = GET_PRIV (icon);
463
464         show = empathy_window_get_is_visible (GTK_WINDOW (priv->window));
465
466         g_signal_handlers_block_by_func (priv->show_window_item,
467                                          status_icon_show_hide_window_cb,
468                                          icon);
469         gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (priv->show_window_item),
470                                         show);
471         g_signal_handlers_unblock_by_func (priv->show_window_item,
472                                            status_icon_show_hide_window_cb,
473                                            icon);
474
475         submenu = empathy_presence_chooser_create_menu ();
476         gtk_menu_item_set_submenu (GTK_MENU_ITEM (priv->status_item),
477                                    submenu);
478
479         gtk_menu_popup (GTK_MENU (priv->popup_menu),
480                         NULL, NULL,
481                         gtk_status_icon_position_menu,
482                         priv->icon,
483                         button,
484                         activate_time);
485 }
486
487 static void
488 status_icon_create_menu (EmpathyStatusIcon *icon)
489 {
490         EmpathyStatusIconPriv *priv;
491         GladeXML              *glade;
492
493         priv = GET_PRIV (icon);
494
495         glade = empathy_glade_get_file ("empathy-status-icon.glade",
496                                        "tray_menu",
497                                        NULL,
498                                        "tray_menu", &priv->popup_menu,
499                                        "tray_show_list", &priv->show_window_item,
500                                        "tray_new_message", &priv->message_item,
501                                        "tray_status", &priv->status_item,
502                                        NULL);
503
504         empathy_glade_connect (glade,
505                               icon,
506                               "tray_new_message", "activate", status_icon_new_message_cb,
507                               "tray_quit", "activate", status_icon_quit_cb,
508                               NULL);
509
510         g_signal_connect (priv->show_window_item, "toggled",
511                           G_CALLBACK (status_icon_show_hide_window_cb),
512                           icon);
513
514         g_object_unref (glade);
515 }
516
517 static void
518 status_icon_new_message_cb (GtkWidget         *widget,
519                             EmpathyStatusIcon *icon)
520 {
521         EmpathyStatusIconPriv *priv;
522
523         priv = GET_PRIV (icon);
524
525         //empathy_new_message_dialog_show (GTK_WINDOW (priv->window));
526 }
527
528 static void
529 status_icon_quit_cb (GtkWidget         *window,
530                      EmpathyStatusIcon *icon)
531 {
532         gtk_main_quit ();
533 }
534
535 static void
536 status_icon_show_hide_window_cb (GtkWidget         *widget,
537                                  EmpathyStatusIcon *icon)
538 {
539         status_icon_toggle_visibility (icon);
540 }
541
542 static void
543 status_icon_pendings_changed_cb (EmpathyContactManager *manager,
544                                  EmpathyContact        *contact,
545                                  EmpathyContact        *actor,
546                                  guint                  reason,
547                                  gchar                 *message,
548                                  gboolean               is_pending,
549                                  EmpathyStatusIcon     *icon)
550 {
551         EmpathyStatusIconPriv *priv;
552         StatusIconEvent       *event;
553         gchar                 *str;
554         GList                 *l;
555
556         priv = GET_PRIV (icon);
557
558         if (!is_pending) {
559                 /* FIXME: We should remove the event */
560                 return;
561         }
562
563         for (l = priv->events; l; l = l->next) {
564                 if (empathy_contact_equal (contact, ((StatusIconEvent*)l->data)->user_data)) {
565                         return;
566                 }
567         }
568
569         str = g_strdup_printf (_("Subscription requested for %s\n"
570                                  "Message: %s"),
571                                empathy_contact_get_name (contact),
572                                message);
573
574         event = status_icon_event_new (icon, GTK_STOCK_DIALOG_QUESTION, str);
575         event->user_data = g_object_ref (contact);
576         event->func = status_icon_event_subscribe_cb;
577
578         g_free (str);
579 }
580
581 static void
582 status_icon_event_subscribe_cb (StatusIconEvent *event)
583 {
584         EmpathyContact *contact;
585
586         contact = EMPATHY_CONTACT (event->user_data);
587
588         empathy_subscription_dialog_show (contact, NULL);
589
590         g_object_unref (contact);
591 }
592
593 static void
594 status_icon_event_flash_state_cb (StatusIconEvent *event)
595 {
596         EmpathyStatusIconPriv *priv;
597
598         priv = GET_PRIV (event->user_data);
599
600         empathy_idle_set_flash_state (priv->idle, MC_PRESENCE_UNSET);
601 }
602
603 static void
604 status_icon_event_msg_cb (StatusIconEvent *event)
605 {
606         EmpathyFilter *filter;
607         EmpathyTpChat *tp_chat;
608
609         empathy_debug (DEBUG_DOMAIN, "Dispatching text channel");
610
611         tp_chat = event->user_data;
612         filter = g_object_get_data (G_OBJECT (tp_chat), "filter");
613         empathy_filter_process (filter,
614                                 empathy_tp_chat_get_channel (tp_chat),
615                                 TRUE);
616         g_object_unref (tp_chat);
617 }
618
619 static StatusIconEvent *
620 status_icon_event_new (EmpathyStatusIcon *icon,
621                        const gchar       *icon_name,
622                        const gchar       *message)
623 {
624         EmpathyStatusIconPriv *priv;
625         StatusIconEvent       *event;
626
627         priv = GET_PRIV (icon);
628
629         event = g_slice_new0 (StatusIconEvent);
630         event->icon_name = g_strdup (icon_name);        
631         event->message = g_strdup (message);
632
633         priv->events = g_list_append (priv->events, event);
634         if (!priv->blink_timeout) {
635                 priv->showing_event_icon = FALSE;
636                 priv->blink_timeout = g_timeout_add (BLINK_TIMEOUT,
637                                                      (GSourceFunc) status_icon_event_timeout_cb,
638                                                      icon);
639                 status_icon_event_timeout_cb (icon);
640         }
641
642         return event;
643 }
644
645 static void
646 status_icon_event_remove (EmpathyStatusIcon *icon,
647                           StatusIconEvent   *event)
648 {
649         EmpathyStatusIconPriv *priv;
650
651         priv = GET_PRIV (icon);
652
653         if (event->func) {
654                 event->func (event);
655         }
656         priv->events = g_list_remove (priv->events, event);
657         status_icon_event_free (event);
658         priv->showing_event_icon = FALSE;
659         status_icon_update_tooltip (icon);
660         status_icon_set_from_state (icon);
661
662         if (priv->events) {
663                 return;
664         }
665
666         if (priv->blink_timeout) {
667                 g_source_remove (priv->blink_timeout);
668                 priv->blink_timeout = 0;
669         }
670 }
671
672 static gboolean
673 status_icon_event_timeout_cb (EmpathyStatusIcon *icon)
674 {
675         EmpathyStatusIconPriv *priv;
676
677         priv = GET_PRIV (icon);
678
679         priv->showing_event_icon = !priv->showing_event_icon;
680
681         if (!priv->showing_event_icon) {
682                 status_icon_set_from_state (icon);
683         } else {
684                 StatusIconEvent *event;
685
686                 event = priv->events->data;
687                 gtk_status_icon_set_from_icon_name (priv->icon, event->icon_name);
688         }
689         status_icon_update_tooltip (icon);
690
691         return TRUE;
692 }
693
694 static void
695 status_icon_event_free (StatusIconEvent *event)
696 {
697         g_free (event->icon_name);
698         g_free (event->message);
699         g_slice_free (StatusIconEvent, event);
700 }
701