Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (72 sloc) 3.49 KB
--- pygtk-shutdown 2011-08-22 19:18:04.000000000 -0700
+++ pygtk-shutdown-ck-up 2011-08-22 19:19:40.000000000 -0700
@@ -37,13 +37,17 @@
self.frame1 = gtk.Frame()
self.frame2 = gtk.Frame()
+ self.frame3 = gtk.Frame()
self.layoutBox = gtk.VBox(False, 5)
self.layoutBox.set_border_width(5)
self.buttonsBox1 = gtk.HBox(True, 5)
self.buttonsBox2 = gtk.HBox(True, 5)
+ self.buttonsBox3 = gtk.HBox(True, 5)
self.buttonsBox1.set_border_width(5)
+ self.buttonsBox2 = gtk.HBox(True, 5)
self.buttonsBox2.set_border_width(5)
+ self.buttonsBox3.set_border_width(5)
self.cancelButtonAlignment = gtk.Alignment(1.0, 0.5)
self.logoutButton = gtk.Button("Logout")
@@ -61,16 +65,30 @@
ico.set_from_icon_name("gnome-shutdown", iconsize)
self.haltButton.set_image(ico)
+ self.suspendButton = gtk.Button("Suspend")
+ ico = gtk.Image()
+ ico.set_from_icon_name("gnome-session-suspend", iconsize)
+ self.suspendButton.set_image(ico)
+
+ self.hibernateButton = gtk.Button("Hibernate")
+ ico = gtk.Image()
+ ico.set_from_icon_name("gnome-session-hibernate", iconsize)
+ self.hibernateButton.set_image(ico)
+
self.cancelButton = gtk.Button(None, gtk.STOCK_CANCEL)
self.buttonsBox1.pack_start(self.logoutButton)
self.buttonsBox2.pack_start(self.restartButton)
self.buttonsBox2.pack_start(self.haltButton)
+ self.buttonsBox3.pack_start(self.suspendButton)
+ self.buttonsBox3.pack_start(self.hibernateButton)
self.cancelButtonAlignment.add(self.cancelButton)
self.frame1.add(self.buttonsBox1)
self.frame2.add(self.buttonsBox2)
+ self.frame3.add(self.buttonsBox3)
self.layoutBox.pack_start(self.frame1)
self.layoutBox.pack_start(self.frame2)
+ self.layoutBox.pack_start(self.frame3)
self.layoutBox.pack_start(self.cancelButtonAlignment)
self.window.add(self.layoutBox)
@@ -88,6 +106,8 @@
self.logoutButton.connect("clicked", self.logout)
self.restartButton.connect("clicked", self.reboot)
self.haltButton.connect("clicked", self.shutdown)
+ self.suspendButton.connect("clicked", self.suspend)
+ self.hibernateButton.connect("clicked", self.hibernate)
def main(self):
gtk.main()
@@ -100,11 +120,19 @@
gtk.main_quit()
def shutdown(self, widget = None, data = None):
- os.system("/usr/bin/gksudo \"/sbin/shutdown -h now\" &")
+ os.system("dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop &")
gtk.main_quit()
def reboot(self, widget = None, data = None):
- os.system("/usr/bin/gksudo \"/sbin/shutdown -r now\" &")
+ os.system("dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart &")
+ gtk.main_quit()
+
+ def suspend(self, widget = None, data = None):
+ os.system("dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend &")
+ gtk.main_quit()
+
+ def hibernate(self, widget = None, data = None):
+ os.system("dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Hibernate &")
gtk.main_quit()
def main():