~noskcaj/ubuntu/saucy/xfce4-power-manager/1.2.0-2ubuntu1

« back to all changes in this revision

Viewing changes to src/xfpm-tray-icon.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2010-12-09 18:28:34 UTC
  • mfrom: (2.3.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20101209182834-efb7dinmf9ssp3es
Tags: 1.0.1-0ubuntu1
Upload to natty (pkg-xfce svn r4665), no Ubuntu changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * * Copyright (C) 2008-2009 Ali <aliov@xfce.org>
3
 
 *
4
 
 * Licensed under the GNU General Public License Version 2
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#ifdef HAVE_CONFIG_H
22
 
#include <config.h>
23
 
#endif
24
 
 
25
 
#include <stdio.h>
26
 
#include <stdlib.h>
27
 
#include <string.h>
28
 
 
29
 
#include <glib.h>
30
 
#include <gtk/gtk.h>
31
 
 
32
 
#include <libxfce4util/libxfce4util.h>
33
 
#include <libxfcegui4/libxfcegui4.h>
34
 
 
35
 
#include "libxfpm/xfpm-common.h"
36
 
#include "libxfpm/xfpm-string.h"
37
 
#include "libxfpm/xfpm-notify.h"
38
 
#include "libxfpm/xfpm-icons.h"
39
 
 
40
 
#include "xfpm-tray-icon.h"
41
 
#include "xfpm-shutdown.h"
42
 
#include "xfpm-dbus-monitor.h"
43
 
#include "xfpm-inhibit.h"
44
 
#include "xfpm-screen-saver.h"
45
 
#include "xfpm-xfconf.h"
46
 
#include "xfpm-config.h"
47
 
 
48
 
static void xfpm_tray_icon_finalize   (GObject *object);
49
 
 
50
 
#define XFPM_TRAY_ICON_GET_PRIVATE(o) \
51
 
(G_TYPE_INSTANCE_GET_PRIVATE((o), XFPM_TYPE_TRAY_ICON, XfpmTrayIconPrivate))
52
 
 
53
 
struct XfpmTrayIconPrivate
54
 
{
55
 
    XfpmShutdown    *shutdown;
56
 
    XfpmXfconf      *conf;
57
 
    XfpmNotify      *notify;
58
 
    XfpmInhibit     *inhibit;
59
 
    XfpmScreenSaver *srv;
60
 
    XfpmDBusMonitor *monitor;
61
 
    
62
 
    GtkStatusIcon   *icon;
63
 
    GQuark           icon_quark;
64
 
    gboolean         info_menu;
65
 
    gboolean         inhibited;
66
 
    gboolean         data_available;
67
 
    
68
 
    gulong           sig;
69
 
    gulong           sig_1;
70
 
};
71
 
 
72
 
enum
73
 
{
74
 
    SHOW_INFORMATION,
75
 
    LAST_SIGNAL
76
 
};
77
 
 
78
 
static guint signals[LAST_SIGNAL] = { 0 };
79
 
 
80
 
G_DEFINE_TYPE(XfpmTrayIcon, xfpm_tray_icon, G_TYPE_OBJECT)
81
 
 
82
 
static gboolean
83
 
xfpm_tray_icon_size_changed_cb (GtkStatusIcon *icon, gint size, XfpmTrayIcon *tray)
84
 
{
85
 
    GdkPixbuf *pix;
86
 
    
87
 
    g_return_val_if_fail (size > 0, FALSE);
88
 
    
89
 
    g_debug ("Size Changed %d icon=%s", size, g_quark_to_string (tray->priv->icon_quark));
90
 
    
91
 
    if ( size > 128 )
92
 
        return FALSE;
93
 
 
94
 
    if ( tray->priv->icon_quark == 0 )
95
 
        return FALSE;
96
 
    
97
 
    pix = xfce_themed_icon_load (g_quark_to_string (tray->priv->icon_quark), size);
98
 
    
99
 
    if ( pix )
100
 
    {
101
 
        gtk_status_icon_set_from_pixbuf (GTK_STATUS_ICON(tray->priv->icon), pix);
102
 
        g_object_unref (pix);
103
 
        return TRUE;
104
 
    }
105
 
    return FALSE;
106
 
}
107
 
 
108
 
static void
109
 
xfpm_tray_info (GtkWidget *w, XfpmTrayIcon *tray)
110
 
{
111
 
    g_signal_emit (G_OBJECT (tray), signals[SHOW_INFORMATION], 0);
112
 
}
113
 
 
114
 
static gboolean
115
 
xfpm_tray_icon_do_suspend (XfpmTrayIcon *tray)
116
 
{
117
 
    GError *error = NULL;
118
 
 
119
 
    xfpm_suspend (tray->priv->shutdown, &error);
120
 
 
121
 
    if (error)
122
 
    {
123
 
        g_warning ("%s", error->message);
124
 
        xfpm_notify_show_notification (tray->priv->notify, 
125
 
                                      _("Xfce power manager"), 
126
 
                                       error->message, 
127
 
                                       xfpm_tray_icon_get_icon_name (tray),
128
 
                                       10000,
129
 
                                       FALSE,
130
 
                                       XFPM_NOTIFY_CRITICAL,
131
 
                                       tray->priv->icon);
132
 
        g_error_free (error);
133
 
    }
134
 
    return FALSE;
135
 
}
136
 
 
137
 
static gboolean
138
 
xfpm_tray_icon_do_hibernate (XfpmTrayIcon *tray)
139
 
{
140
 
    GError *error = NULL;
141
 
 
142
 
    xfpm_hibernate (tray->priv->shutdown, &error);
143
 
    
144
 
    if (error)
145
 
    {
146
 
        g_warning ("%s", error->message);
147
 
        xfpm_notify_show_notification (tray->priv->notify, 
148
 
                                      _("Xfce power manager"), 
149
 
                                       error->message, 
150
 
                                       xfpm_tray_icon_get_icon_name (tray),
151
 
                                       10000,
152
 
                                       FALSE,
153
 
                                       XFPM_NOTIFY_CRITICAL,
154
 
                                       tray->priv->icon);
155
 
        g_error_free (error);
156
 
    }
157
 
    return FALSE;
158
 
}
159
 
 
160
 
static void
161
 
xfpm_tray_icon_hibernate_cb (GtkWidget *w, XfpmTrayIcon *tray)
162
 
{
163
 
    const gchar *message;
164
 
    gboolean lock_screen;
165
 
    gboolean ret;
166
 
 
167
 
    g_object_get (G_OBJECT (tray->priv->conf),
168
 
                  LOCK_SCREEN_ON_SLEEP, &lock_screen,
169
 
                  NULL);
170
 
    
171
 
    message = tray->priv->inhibited ? 
172
 
             _("An application is currently disabling the automatic sleep,"
173
 
              " doing this action now may damage the working state of this application,"
174
 
              " are you sure you want to hibernate the system?") :
175
 
              _("Are you sure you want to proceed?") ;
176
 
    
177
 
    ret = 
178
 
        xfce_confirm (message,
179
 
                      GTK_STOCK_YES,
180
 
                      _("Hibernate"));
181
 
    
182
 
    if ( ret ) 
183
 
    {
184
 
        xfpm_shutdown_add_callback (tray->priv->shutdown, 
185
 
                                    (GSourceFunc) xfpm_tray_icon_do_hibernate, 
186
 
                                    lock_screen,
187
 
                                    tray);
188
 
    }
189
 
}
190
 
 
191
 
static void
192
 
xfpm_tray_icon_suspend_cb (GtkWidget *w, XfpmTrayIcon *tray)
193
 
{
194
 
    const gchar *message;
195
 
    gboolean lock_screen;
196
 
    gboolean ret;
197
 
    
198
 
    g_object_get (G_OBJECT (tray->priv->conf),
199
 
                  LOCK_SCREEN_ON_SLEEP, &lock_screen,
200
 
                  NULL);
201
 
    
202
 
    message = tray->priv->inhibited ? 
203
 
             _("An application is currently disabling the automatic sleep,"
204
 
              " doing this action now may damage the working state of this application,"
205
 
              " are you sure you want to suspend the system?") :
206
 
              _("Are you sure you want to proceed?") ;
207
 
    
208
 
    ret = 
209
 
        xfce_confirm  (message,
210
 
                       GTK_STOCK_YES,
211
 
                       _("Suspend"));
212
 
    
213
 
    if ( ret ) 
214
 
    {
215
 
        xfpm_shutdown_add_callback (tray->priv->shutdown, 
216
 
                                    (GSourceFunc) xfpm_tray_icon_do_suspend, 
217
 
                                    lock_screen,
218
 
                                    tray);
219
 
    }
220
 
}
221
 
 
222
 
static void
223
 
xfpm_tray_icon_exit_activated_cb (GtkWidget *w, gpointer data)
224
 
{
225
 
    gboolean ret;
226
 
    
227
 
    ret = xfce_confirm (_("Quit the Xfce power manager"),
228
 
                        GTK_STOCK_YES,
229
 
                        _("Quit"));
230
 
    if ( ret )
231
 
    {
232
 
        xfpm_quit ();
233
 
    }
234
 
}
235
 
 
236
 
static void
237
 
xfpm_tray_icon_menu_selection_done (GtkMenuShell *menu, gpointer data)
238
 
{
239
 
    gtk_widget_destroy (GTK_WIDGET (menu));
240
 
}
241
 
 
242
 
static void
243
 
xfpm_tray_icon_inhibit_active_cb (GtkWidget *mi, XfpmTrayIcon *tray)
244
 
{
245
 
    gboolean active;
246
 
    active = xfpm_screen_saver_get_inhibit (tray->priv->srv);
247
 
    
248
 
    active == FALSE ? xfpm_screen_saver_inhibit   (tray->priv->srv) :
249
 
                      xfpm_screen_saver_uninhibit (tray->priv->srv);
250
 
}
251
 
 
252
 
static void
253
 
xfpm_tray_icon_popup_menu_cb (GtkStatusIcon *icon, guint button, 
254
 
                              guint activate_time, XfpmTrayIcon *tray)
255
 
{
256
 
    GtkWidget *menu, *mi, *img;
257
 
    gboolean can_suspend = FALSE;
258
 
    gboolean can_hibernate = FALSE ;
259
 
    gboolean caller = FALSE;
260
 
 
261
 
    gboolean saver_inhibited;
262
 
 
263
 
    menu = gtk_menu_new();
264
 
 
265
 
    g_object_get (G_OBJECT (tray->priv->shutdown),
266
 
                  "caller-privilege", &caller,
267
 
                  "can-suspend", &can_suspend,
268
 
                  "can-hibernate", &can_hibernate,
269
 
                  NULL);
270
 
    
271
 
    // Hibernate menu option
272
 
    mi = gtk_image_menu_item_new_with_label (_("Hibernate"));
273
 
    img = gtk_image_new_from_icon_name (XFPM_HIBERNATE_ICON, GTK_ICON_SIZE_MENU);
274
 
    gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(mi), img);
275
 
    gtk_widget_set_sensitive (mi,FALSE);
276
 
    
277
 
    if ( caller && can_hibernate && tray->priv->data_available )
278
 
    {
279
 
        gtk_widget_set_sensitive (mi, TRUE);
280
 
        g_signal_connect (G_OBJECT (mi), "activate",
281
 
                          G_CALLBACK (xfpm_tray_icon_hibernate_cb), tray);
282
 
    }
283
 
    gtk_widget_show(mi);
284
 
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
285
 
    
286
 
    // Suspend menu option
287
 
    mi = gtk_image_menu_item_new_with_label(_("Suspend"));
288
 
    img = gtk_image_new_from_icon_name (XFPM_SUSPEND_ICON, GTK_ICON_SIZE_MENU);
289
 
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi),img);
290
 
    
291
 
    gtk_widget_set_sensitive(mi,FALSE);
292
 
    if ( caller && can_suspend && tray->priv->data_available )
293
 
    {
294
 
        gtk_widget_set_sensitive (mi,TRUE);
295
 
        g_signal_connect (mi, "activate",
296
 
                          G_CALLBACK (xfpm_tray_icon_suspend_cb), tray);
297
 
    }
298
 
    gtk_widget_show(mi);
299
 
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
300
 
 
301
 
    saver_inhibited = xfpm_screen_saver_get_inhibit (tray->priv->srv);
302
 
    mi = gtk_check_menu_item_new_with_label (_("Monitor power control"));
303
 
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), !saver_inhibited);
304
 
    gtk_widget_set_tooltip_text (mi, _("Disable or enable monitor power control, "\
305
 
                                       "for example you could disable the screen power "\
306
 
                                       "control to avoid screen blanking when watching a movie."));
307
 
    
308
 
    g_signal_connect (G_OBJECT (mi), "activate",
309
 
                      G_CALLBACK (xfpm_tray_icon_inhibit_active_cb), tray);
310
 
    gtk_widget_set_sensitive (mi, TRUE);
311
 
    gtk_widget_show(mi);
312
 
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
313
 
    
314
 
    if ( tray->priv->info_menu )
315
 
    {
316
 
        mi = gtk_separator_menu_item_new();
317
 
        gtk_widget_show(mi);
318
 
        gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
319
 
    
320
 
        // Battery informations
321
 
    
322
 
        mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_INFO, NULL);
323
 
        
324
 
        gtk_widget_set_sensitive(mi,FALSE);
325
 
        gtk_widget_set_sensitive (mi,TRUE);
326
 
        
327
 
        g_signal_connect(mi,"activate",
328
 
                         G_CALLBACK(xfpm_tray_info), tray);
329
 
                         
330
 
        gtk_widget_show(mi);
331
 
        gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
332
 
    
333
 
    
334
 
        // Separator
335
 
        mi = gtk_separator_menu_item_new();
336
 
        gtk_widget_show(mi);
337
 
        gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
338
 
    }
339
 
        
340
 
    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP,NULL);
341
 
    gtk_widget_set_sensitive(mi,TRUE);
342
 
    gtk_widget_show(mi);
343
 
    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_help),NULL);
344
 
        
345
 
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
346
 
    
347
 
    
348
 
    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT,NULL);
349
 
    gtk_widget_set_sensitive(mi,TRUE);
350
 
    gtk_widget_show(mi);
351
 
    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_about), _("Xfce Power Manager"));
352
 
    
353
 
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
354
 
    
355
 
    mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES,NULL);
356
 
    gtk_widget_set_sensitive(mi,TRUE);
357
 
    gtk_widget_show(mi);
358
 
    g_signal_connect(mi,"activate",G_CALLBACK(xfpm_preferences),NULL);
359
 
    
360
 
    gtk_menu_shell_append(GTK_MENU_SHELL(menu),mi);
361
 
 
362
 
    mi = gtk_separator_menu_item_new ();
363
 
    gtk_widget_show (mi);
364
 
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
365
 
 
366
 
    mi = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
367
 
    gtk_widget_set_sensitive (mi, TRUE);
368
 
    gtk_widget_show (mi);
369
 
    g_signal_connect (mi, "activate", G_CALLBACK (xfpm_tray_icon_exit_activated_cb), NULL);
370
 
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
371
 
 
372
 
    g_signal_connect (menu, "selection-done",
373
 
                      G_CALLBACK (xfpm_tray_icon_menu_selection_done), NULL);
374
 
 
375
 
    // Popup the menu
376
 
    gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
377
 
                   gtk_status_icon_position_menu, 
378
 
                   icon, button, activate_time);
379
 
}
380
 
 
381
 
static void
382
 
xfpm_tray_icon_inhibit_changed_cb (XfpmInhibit *inhibit, gboolean inhibited, XfpmTrayIcon *tray)
383
 
{
384
 
    tray->priv->inhibited = inhibited;
385
 
}
386
 
 
387
 
static void
388
 
xfpm_tray_icon_hal_connection_changed_cb (XfpmDBusMonitor *monitor, gboolean connected, XfpmTrayIcon *tray)
389
 
{
390
 
    if ( connected == FALSE )
391
 
        xfpm_tray_icon_set_tooltip (tray, _("No data available"));
392
 
        
393
 
    /*
394
 
     * We set this variable after since xfpm_tray_icon_set_tooltip will return 
395
 
     * if data_available is set to FALSE
396
 
     */
397
 
    tray->priv->data_available = connected;
398
 
}
399
 
 
400
 
static void
401
 
xfpm_tray_icon_activated_cb (XfpmTrayIcon *tray)
402
 
{
403
 
    xfpm_preferences ();
404
 
}
405
 
 
406
 
static void
407
 
xfpm_tray_icon_class_init(XfpmTrayIconClass *klass)
408
 
{
409
 
    GObjectClass *object_class = G_OBJECT_CLASS(klass);
410
 
 
411
 
    signals[SHOW_INFORMATION] =
412
 
            g_signal_new("show-information",
413
 
                         XFPM_TYPE_TRAY_ICON,
414
 
                         G_SIGNAL_RUN_LAST,
415
 
                         G_STRUCT_OFFSET(XfpmTrayIconClass, show_info),
416
 
                         NULL, NULL,
417
 
                         g_cclosure_marshal_VOID__VOID,
418
 
                         G_TYPE_NONE, 0, G_TYPE_NONE);
419
 
 
420
 
    object_class->finalize = xfpm_tray_icon_finalize;
421
 
 
422
 
    g_type_class_add_private(klass,sizeof(XfpmTrayIconPrivate));
423
 
}
424
 
 
425
 
static void
426
 
xfpm_tray_icon_init(XfpmTrayIcon *tray)
427
 
{
428
 
    tray->priv = XFPM_TRAY_ICON_GET_PRIVATE(tray);
429
 
    
430
 
    tray->priv->icon  = gtk_status_icon_new();
431
 
    tray->priv->shutdown = xfpm_shutdown_new ();
432
 
    tray->priv->conf  = xfpm_xfconf_new ();
433
 
    tray->priv->notify = xfpm_notify_new ();
434
 
    tray->priv->inhibited = FALSE;
435
 
    tray->priv->inhibit = xfpm_inhibit_new ();
436
 
    tray->priv->srv     = xfpm_screen_saver_new ();
437
 
    tray->priv->monitor = xfpm_dbus_monitor_new ();
438
 
    
439
 
    tray->priv->info_menu = TRUE;
440
 
    tray->priv->icon_quark = 0;
441
 
    
442
 
    g_signal_connect (tray->priv->icon, "size-changed",
443
 
                      G_CALLBACK (xfpm_tray_icon_size_changed_cb), tray);
444
 
                      
445
 
    g_signal_connect (tray->priv->icon, "popup-menu",
446
 
                      G_CALLBACK (xfpm_tray_icon_popup_menu_cb), tray);
447
 
                      
448
 
    g_signal_connect_swapped (tray->priv->icon, "activate",
449
 
                              G_CALLBACK (xfpm_tray_icon_activated_cb), tray);
450
 
                              
451
 
    tray->priv->sig = g_signal_connect (tray->priv->inhibit, "has-inhibit-changed",
452
 
                                        G_CALLBACK (xfpm_tray_icon_inhibit_changed_cb), tray);
453
 
                                        
454
 
    tray->priv->sig_1 = g_signal_connect (tray->priv->monitor, "hal-connection-changed",
455
 
                                         G_CALLBACK (xfpm_tray_icon_hal_connection_changed_cb), tray);
456
 
                                         
457
 
    tray->priv->data_available = xfpm_dbus_monitor_hal_connected (tray->priv->monitor);
458
 
}
459
 
 
460
 
static void
461
 
xfpm_tray_icon_finalize(GObject *object)
462
 
{
463
 
    XfpmTrayIcon *tray;
464
 
 
465
 
    tray = XFPM_TRAY_ICON(object);
466
 
    
467
 
    if ( g_signal_handler_is_connected (tray->priv->inhibit, tray->priv->sig ) )
468
 
        g_signal_handler_disconnect (G_OBJECT (tray->priv->inhibit), tray->priv->sig);
469
 
    
470
 
    if ( g_signal_handler_is_connected (tray->priv->monitor, tray->priv->sig_1) )
471
 
        g_signal_handler_disconnect (G_OBJECT (tray->priv->monitor), tray->priv->sig_1);
472
 
        
473
 
    g_object_unref (tray->priv->monitor);
474
 
    
475
 
    g_object_unref (tray->priv->icon);
476
 
        
477
 
    g_object_unref (tray->priv->shutdown);
478
 
    
479
 
    g_object_unref (tray->priv->conf);
480
 
    
481
 
    g_object_unref (tray->priv->notify);
482
 
    
483
 
    g_object_unref (tray->priv->inhibit);
484
 
    
485
 
    g_object_unref (tray->priv->srv);
486
 
 
487
 
    G_OBJECT_CLASS(xfpm_tray_icon_parent_class)->finalize(object);
488
 
}
489
 
 
490
 
XfpmTrayIcon *
491
 
xfpm_tray_icon_new(void)
492
 
{
493
 
    XfpmTrayIcon *tray = NULL;
494
 
    tray = g_object_new (XFPM_TYPE_TRAY_ICON, NULL);
495
 
    return tray;
496
 
}
497
 
 
498
 
void xfpm_tray_icon_set_show_info_menu (XfpmTrayIcon *icon, gboolean value)
499
 
{
500
 
    g_return_if_fail (XFPM_IS_TRAY_ICON (icon));
501
 
    icon->priv->info_menu = value;
502
 
}
503
 
 
504
 
void xfpm_tray_icon_set_icon (XfpmTrayIcon *icon, const gchar *icon_name)
505
 
{
506
 
    g_return_if_fail(XFPM_IS_TRAY_ICON(icon));
507
 
    
508
 
    icon->priv->icon_quark = g_quark_from_string(icon_name);
509
 
    
510
 
    xfpm_tray_icon_size_changed_cb (icon->priv->icon,
511
 
                                    gtk_status_icon_get_size(icon->priv->icon),
512
 
                                    icon);
513
 
}
514
 
 
515
 
void xfpm_tray_icon_set_tooltip (XfpmTrayIcon *icon, const gchar *tooltip)
516
 
{
517
 
    g_return_if_fail (XFPM_IS_TRAY_ICON (icon));
518
 
    /*
519
 
     * Hal is disconnected we have the tooltips set to "no data available"
520
 
     */
521
 
    g_return_if_fail (icon->priv->data_available);
522
 
 
523
 
#if GTK_CHECK_VERSION (2, 16, 0)
524
 
    gtk_status_icon_set_tooltip_text (GTK_STATUS_ICON(icon->priv->icon), tooltip);
525
 
#else
526
 
    gtk_status_icon_set_tooltip (GTK_STATUS_ICON(icon->priv->icon), tooltip);
527
 
#endif
528
 
}
529
 
 
530
 
void xfpm_tray_icon_set_visible (XfpmTrayIcon *icon, gboolean visible)
531
 
{
532
 
    g_return_if_fail(XFPM_IS_TRAY_ICON(icon));
533
 
    
534
 
    gtk_status_icon_set_visible(GTK_STATUS_ICON(icon->priv->icon), visible);
535
 
}
536
 
 
537
 
gboolean xfpm_tray_icon_get_visible (XfpmTrayIcon *icon)
538
 
{
539
 
    g_return_val_if_fail (XFPM_IS_TRAY_ICON(icon), FALSE);
540
 
    
541
 
    return gtk_status_icon_get_visible (GTK_STATUS_ICON(icon->priv->icon));
542
 
}
543
 
 
544
 
GtkStatusIcon *xfpm_tray_icon_get_tray_icon (XfpmTrayIcon *icon)
545
 
{
546
 
    g_return_val_if_fail(XFPM_IS_TRAY_ICON(icon), NULL);
547
 
    
548
 
    return icon->priv->icon;
549
 
}
550
 
 
551
 
const gchar *xfpm_tray_icon_get_icon_name   (XfpmTrayIcon *icon)
552
 
{
553
 
    g_return_val_if_fail(XFPM_IS_TRAY_ICON(icon), NULL);
554
 
    
555
 
    if ( icon->priv->icon_quark == 0 ) return NULL;
556
 
    
557
 
    return  g_quark_to_string (icon->priv->icon_quark);
558
 
}