9
#include <glade/glade.h>
10
#include <libnotify/notify.h>
12
#include "update-notifier.h"
16
#define GDM_SIGNAL "/usr/bin/gdm-signal"
21
show_notification (TrayApplet *ta)
23
NotifyNotification *n;
26
/* Get the location of the icon. If there's no location, come back
27
* in a few seconds. */
28
gdk_window_get_origin (GTK_WIDGET(ta->tray_icon)->window, &x, &y);
29
if ((x <= 0) || (y <= 0))
32
/* Check whether the icon is still visible, may have gone away */
33
if (!GTK_WIDGET_VISIBLE (ta->tray_icon))
36
/* Create and show the notification */
37
n = notify_notification_new (_("Restart Required"),
38
_("In order to complete the update of "
39
"your system, restarting is strongly "
41
"Click this icon to restart your "
43
GTK_STOCK_DIALOG_WARNING,
45
notify_notification_set_timeout (n, 60000);
46
notify_notification_show (n, NULL);
47
g_object_set_data (G_OBJECT(ta->tray_icon), "notification", n);
53
reboot_check (TrayApplet *ta)
57
/* If the file doesn't exist, we don't need to reboot */
58
if (stat (REBOOT_FILE, &statbuf)) {
59
NotifyNotification *n;
61
gtk_widget_hide (GTK_WIDGET(ta->tray_icon));
63
/* Hide any notification popup */
64
n = g_object_get_data (G_OBJECT(ta->tray_icon), "notification");
66
notify_notification_close (n, NULL);
67
g_object_set_data (G_OBJECT(ta->tray_icon), "notification", NULL);
72
/* Skip the rest if the icon is already visible */
73
if (GTK_WIDGET_VISIBLE(GTK_WIDGET(ta->tray_icon)))
76
gtk_tooltips_set_tip (GTK_TOOLTIPS(ta->tooltip),
77
GTK_WIDGET (ta->eventbox),
78
_("Restart Required"),
79
_("Click this icon to restart your computer."));
81
gtk_widget_show (GTK_WIDGET(ta->tray_icon));
83
/* Check whether the user doesn't like notifications */
84
if (gconf_client_get_bool ((GConfClient*) ta->user_data,
85
GCONF_KEY_NO_UPDATE_NOTIFICATIONS, NULL))
88
/* Show the notification, after a delay so it doesn't look ugly
89
* if we've just logged in */
90
g_timeout_add(5000, show_notification, ta);
99
char *cmd[] = { GDM_SIGNAL, "--reboot", NULL };
101
client = gnome_master_client ();
102
g_return_if_fail (client != NULL);
104
/* Tell gdm to reboot once we exit the session */
105
g_spawn_sync (NULL, cmd, NULL, G_SPAWN_STDOUT_TO_DEV_NULL,
106
NULL, NULL, NULL, NULL, NULL, NULL);
108
/* Tell gnome-session to save and exit the session without asking
110
gnome_client_request_save (client,
119
button_release_cb (GtkWidget *widget,
120
GdkEventButton *event,
123
if ((event->button == 1) && (event->type == GDK_BUTTON_RELEASE)) {
126
dia = glade_xml_get_widget (xml, "dialog_reboot");
127
if (gtk_dialog_run (dia) == GTK_RESPONSE_OK)
130
gtk_widget_hide (dia);
138
reboot_tray_icon_init (TrayApplet *ta)
143
xml = glade_xml_new (GLADEDIR"reboot-dialog.glade", NULL, NULL);
145
widget = glade_xml_get_widget (xml, "image");
146
gtk_image_set_from_file (GTK_IMAGE(widget), "/usr/share/pixmaps/reboot.png");
148
ta->user_data = gconf_client_get_default();
150
g_signal_connect (G_OBJECT(ta->tray_icon),
151
"button-release-event",
152
G_CALLBACK (button_release_cb),
155
/* Check for updates for the first time */