~psybers/docky/indicator-scaling

« back to all changes in this revision

Viewing changes to StandardPlugins/SessionManager/src/SessionManagerItem.cs

  • Committer: Robert Dyer
  • Date: 2010-03-31 04:18:07 UTC
  • Revision ID: psybers@gmail.com-20100331041807-u0w79c8f22lez0am
clean session docklet code

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
                                SessionMenuItems.Add (shutdown);
126
126
                                SessionDockItems.Add (shutdown);
127
127
                        }
128
 
                        
129
128
                }
130
129
                
131
130
                void BuildMenuEntries () 
132
131
                {
133
 
                        
134
132
                        lockscreen = new SessionManagerEntry ("system-lock-screen", Catalog.GetString ("Lock Screen"), () => { 
135
 
                                
136
 
                                Console.WriteLine ("Lock Screen now...");
137
 
                                DockServices.System.Execute ("gnome-screensaver-command --lock");
138
 
                                
 
133
                                system_manager.LockScreen ();
139
134
                        });
140
135
                        
141
136
                        logout = new SessionManagerEntry ("system-log-out", Catalog.GetString ("Log Out..."), () => { 
142
 
                                
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"));
147
 
                                
 
140
                                                        system_manager.LogOut);
148
141
                        });
149
142
 
150
143
                        suspend = new SessionManagerEntry ("system-suspend", Catalog.GetString ("Suspend"), () => { 
151
 
                                
152
 
                                Console.WriteLine ("Suspend now...");
153
 
                                DockServices.System.Execute ("gnome-screensaver-command --lock");
 
144
                                system_manager.LockScreen ();
154
145
                                system_manager.Suspend (); 
155
 
                                
156
146
                        });
157
147
                        
158
148
                        hibernate = new SessionManagerEntry ("system-hibernate", Catalog.GetString ("Hibernate"), () => { 
159
 
                                
160
 
                                Console.WriteLine ("Hibernate now...");
161
 
                                DockServices.System.Execute ("gnome-screensaver-command --lock");
 
149
                                system_manager.LockScreen ();
162
150
                                system_manager.Hibernate (); 
163
 
                                
164
151
                        });
165
152
                        
166
153
 
167
154
                        restart = new SessionManagerEntry ("system-restart", Catalog.GetString ("Restart..."), () => { 
168
 
                
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 ());
173
 
                
174
159
                        });
175
160
                        
176
161
                        shutdown = new SessionManagerEntry ("system-shutdown", Catalog.GetString ("Shut Down..."), () => { 
177
 
                
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 ());
182
 
                
183
166
                        });
184
 
                        
185
167
                }
186
168
 
187
169
                void ShowConfirmationDialog (string title, string text, string icon_name, Action action)
188
170
                {
189
 
                                Console.WriteLine ("Calling {0}", title);
190
 
                                
191
171
                                Gtk.MessageDialog md = new Gtk.MessageDialog (null, 0, Gtk.MessageType.Question, Gtk.ButtonsType.None, text);
192
172
                                
193
173
                                md.Title = title;
199
179
                                md.AddButton (title, Gtk.ResponseType.Ok);
200
180
                                
201
181
                                md.Response += (o, args) => { 
202
 
                                        
203
 
                                        if (args.ResponseId == Gtk.ResponseType.Ok) {
204
 
                                                Console.WriteLine ("{0} now...", title);
 
182
                                        if (args.ResponseId == Gtk.ResponseType.Ok)
205
183
                                                action.Invoke ();
206
 
                                        }
207
184
                                        md.Destroy ();
208
185
                                };
209
186
                                
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) {
 
223
                        } else {
247
224
                                current_index = (current_index + 1) % SessionDockItems.Count;
248
 
                        } else
249
 
                                return;
 
225
                        }
250
226
                        
251
227
                        HoverText = SessionDockItems[current_index].hover_text;
252
228
                        Icon = SessionDockItems[current_index].icon;