125
125
SessionMenuItems.Add (shutdown);
126
126
SessionDockItems.Add (shutdown);
131
130
void BuildMenuEntries ()
134
132
lockscreen = new SessionManagerEntry ("system-lock-screen", Catalog.GetString ("Lock Screen"), () => {
136
Console.WriteLine ("Lock Screen now...");
137
DockServices.System.Execute ("gnome-screensaver-command --lock");
133
system_manager.LockScreen ();
141
136
logout = new SessionManagerEntry ("system-log-out", Catalog.GetString ("Log Out..."), () => {
143
137
ShowConfirmationDialog (Catalog.GetString ("Log Out"),
144
138
Catalog.GetString ("Are you sure you want to close all programs and log out of the computer?"),
145
139
"system-log-out",
146
() => DockServices.System.Execute ("gnome-session-save --logout"));
140
system_manager.LogOut);
150
143
suspend = new SessionManagerEntry ("system-suspend", Catalog.GetString ("Suspend"), () => {
152
Console.WriteLine ("Suspend now...");
153
DockServices.System.Execute ("gnome-screensaver-command --lock");
144
system_manager.LockScreen ();
154
145
system_manager.Suspend ();
158
148
hibernate = new SessionManagerEntry ("system-hibernate", Catalog.GetString ("Hibernate"), () => {
160
Console.WriteLine ("Hibernate now...");
161
DockServices.System.Execute ("gnome-screensaver-command --lock");
149
system_manager.LockScreen ();
162
150
system_manager.Hibernate ();
167
154
restart = new SessionManagerEntry ("system-restart", Catalog.GetString ("Restart..."), () => {
169
155
ShowConfirmationDialog (Catalog.GetString ("Restart"),
170
156
Catalog.GetString ("Are you sure you want to close all programs and restart the computer?"),
171
157
"system-restart",
172
158
() => system_manager.Restart ());
176
161
shutdown = new SessionManagerEntry ("system-shutdown", Catalog.GetString ("Shut Down..."), () => {
178
162
ShowConfirmationDialog (Catalog.GetString ("Shut Down"),
179
163
Catalog.GetString ("Are you sure you want to close all programs and shut down the computer?"),
180
164
"system-shutdown",
181
165
() => system_manager.Stop ());
187
169
void ShowConfirmationDialog (string title, string text, string icon_name, Action action)
189
Console.WriteLine ("Calling {0}", title);
191
171
Gtk.MessageDialog md = new Gtk.MessageDialog (null, 0, Gtk.MessageType.Question, Gtk.ButtonsType.None, text);
193
173
md.Title = title;
199
179
md.AddButton (title, Gtk.ResponseType.Ok);
201
181
md.Response += (o, args) => {
203
if (args.ResponseId == Gtk.ResponseType.Ok) {
204
Console.WriteLine ("{0} now...", title);
182
if (args.ResponseId == Gtk.ResponseType.Ok)
205
183
action.Invoke ();
243
220
if (current_index == 0)
244
221
current_index = SessionDockItems.Count;
245
222
current_index = (current_index - 1) % SessionDockItems.Count;
246
} else if (direction == Gdk.ScrollDirection.Down || direction == Gdk.ScrollDirection.Right) {
247
224
current_index = (current_index + 1) % SessionDockItems.Count;
251
227
HoverText = SessionDockItems[current_index].hover_text;
252
228
Icon = SessionDockItems[current_index].icon;