aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-03 21:50:37 -0600
committerTed Gould <ted@gould.cx>2010-03-03 21:50:37 -0600
commitbe3f65e45fb928f6afe189fe41ab7a25243d1d90 (patch)
tree4c1cc634062e4ea45a98248b7ccb11410795dd5e /src
parent1af7a048d62b8616d3182a8bb48fe33e7b54d93d (diff)
downloadayatana-indicator-session-be3f65e45fb928f6afe189fe41ab7a25243d1d90.tar.gz
ayatana-indicator-session-be3f65e45fb928f6afe189fe41ab7a25243d1d90.tar.bz2
ayatana-indicator-session-be3f65e45fb928f6afe189fe41ab7a25243d1d90.zip
Adds a file watcher to see if we should change the menuitem to warn that a restart is recommended.
Diffstat (limited to 'src')
-rw-r--r--src/session-service.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/session-service.c b/src/session-service.c
index eb1966e..62ee0a7 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -27,6 +27,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <unistd.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
@@ -605,6 +606,42 @@ service_shutdown (IndicatorService * service, gpointer user_data)
return;
}
+static void
+restart_dir_changed (void)
+{
+ gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS);
+
+ if (restart_required) {
+ if (supress_confirmations()) {
+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required"));
+ } else {
+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required..."));
+ }
+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, "emblem-important");
+ } else {
+ if (supress_confirmations()) {
+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart"));
+ } else {
+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart..."));
+ }
+ dbusmenu_menuitem_property_remove(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME);
+ }
+
+ return;
+}
+
+static void
+setup_restart_watch (void)
+{
+ GFile * filedir = g_file_new_for_path("/var/run");
+ GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL);
+ if (filemon != NULL) {
+ g_signal_connect(G_OBJECT(filemon), "changed", G_CALLBACK(restart_dir_changed), NULL);
+ }
+ restart_dir_changed();
+ return;
+}
+
/* Main, is well, main. It brings everything up and throws
us into the mainloop of no return. */
int
@@ -642,6 +679,8 @@ main (int argc, char ** argv)
G_CALLBACK (user_change),
root_menuitem);
+ setup_restart_watch();
+
setup_up();
DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT);