aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-04 08:52:35 -0600
committerTed Gould <ted@gould.cx>2010-03-04 08:52:35 -0600
commit2eba4c72ba16f6390d6d68ba7de5bdecd91effc6 (patch)
treedf8d84c139d8a4f6190d240073a530af05a193ea /src
parent6f21e3c8b251a6323a8e56127d998ea77ba5b18e (diff)
parentd018794d6717df1f4dfcb1f26258d6cd2820d8bd (diff)
downloadayatana-indicator-session-2eba4c72ba16f6390d6d68ba7de5bdecd91effc6.tar.gz
ayatana-indicator-session-2eba4c72ba16f6390d6d68ba7de5bdecd91effc6.tar.bz2
ayatana-indicator-session-2eba4c72ba16f6390d6d68ba7de5bdecd91effc6.zip
Setting the icon and changing the text on the restart menu if one is required by update.
Diffstat (limited to 'src')
-rw-r--r--src/session-service.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/session-service.c b/src/session-service.c
index 88a79fe..a6c3fc3 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,47 @@ service_shutdown (IndicatorService * service, gpointer user_data)
return;
}
+/* When the directory changes we need to figure out how our menu
+ item should look. */
+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;
+}
+
+/* Buids a file watcher for the directory so that when it
+ changes we can check to see if our reboot-required is
+ there. */
+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 +684,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);