#!/usr/bin/env python
import os
from gi.repository import Gtk

def dbus_shutdown(self):
	os.system("dbus-send --system --print-reply  --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager  org.freedesktop.ConsoleKit.Manager.Stop")

def dbus_reboot(self):
	os.system("dbus-send --system --print-reply  --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager  org.freedesktop.ConsoleKit.Manager.Restart")

def dbus_logout(self):
	os.system("openbox --exit")

win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)

box = Gtk.Box(spacing=5)
win.add(box)

reboot = Gtk.Button(label="Reboot")
reboot.connect("clicked", dbus_reboot)
box.pack_start(reboot, True, True, 0)

logout= Gtk.Button(label="Logout")
logout.connect("clicked", dbus_logout)
box.pack_start(logout, True, True, 0)

shutdown = Gtk.Button(label="ShutDown")
shutdown.connect("clicked", dbus_shutdown)
box.pack_start(shutdown, True, True, 0)

win.set_title("Session Manager")
win.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
win.set_default_size(200,200)
win.set_resizable(False)
win.show_all()
Gtk.main()
