Merge lp:~ted/indicator-session/restart-required-menu into lp:indicator-session/0.1

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/indicator-session/restart-required-menu
Merge into: lp:indicator-session/0.1
Diff against target: 68 lines (+44/-0)
1 file modified
src/session-service.c (+44/-0)
To merge this branch: bzr merge lp:~ted/indicator-session/restart-required-menu
Reviewer Review Type Date Requested Status
David Barth Approve
Review via email: mp+20619@code.launchpad.net

Description of the change

Adds a directory watcher on /var/run so that we can look for the
reboot-required file existing and change the menu item to encourage
people to reboot their computers.

Though, it matches design currently, I kinda want to change "Switch Off"
to "Switch Off is acceptable too" ;)

To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

Don't you need to unref the filedir somewhere?

review: Approve
Revision history for this message
Ted Gould (ted) wrote :

On Thu, 2010-03-04 at 14:33 +0000, David Barth wrote:
> Don't you need to unref the filedir somewhere?

Well, perhaps. The reality is that the only place we'd unref it would
be when the executable exits, so it seemed like unneeded complexity.

Revision history for this message
David Barth (dbarth) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/session-service.c'
2--- src/session-service.c 2010-03-04 02:58:51 +0000
3+++ src/session-service.c 2010-03-04 04:00:35 +0000
4@@ -27,6 +27,7 @@
5 #include <unistd.h>
6
7 #include <glib/gi18n.h>
8+#include <gio/gio.h>
9
10 #include <dbus/dbus-glib.h>
11 #include <dbus/dbus-glib-bindings.h>
12@@ -605,6 +606,47 @@
13 return;
14 }
15
16+/* When the directory changes we need to figure out how our menu
17+ item should look. */
18+static void
19+restart_dir_changed (void)
20+{
21+ gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS);
22+
23+ if (restart_required) {
24+ if (supress_confirmations()) {
25+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required"));
26+ } else {
27+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart Required..."));
28+ }
29+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, "emblem-important");
30+ } else {
31+ if (supress_confirmations()) {
32+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart"));
33+ } else {
34+ dbusmenu_menuitem_property_set(restart_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Restart..."));
35+ }
36+ dbusmenu_menuitem_property_remove(restart_mi, DBUSMENU_MENUITEM_PROP_ICON_NAME);
37+ }
38+
39+ return;
40+}
41+
42+/* Buids a file watcher for the directory so that when it
43+ changes we can check to see if our reboot-required is
44+ there. */
45+static void
46+setup_restart_watch (void)
47+{
48+ GFile * filedir = g_file_new_for_path("/var/run");
49+ GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL);
50+ if (filemon != NULL) {
51+ g_signal_connect(G_OBJECT(filemon), "changed", G_CALLBACK(restart_dir_changed), NULL);
52+ }
53+ restart_dir_changed();
54+ return;
55+}
56+
57 /* Main, is well, main. It brings everything up and throws
58 us into the mainloop of no return. */
59 int
60@@ -642,6 +684,8 @@
61 G_CALLBACK (user_change),
62 root_menuitem);
63
64+ setup_restart_watch();
65+
66 setup_up();
67
68 DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT);

Subscribers

People subscribed via source and target branches