add fastdial html page
[cinan.git] / skripty / shutdown.rb
blobc1385e3e21cbd40e3373a790f463c2fa4987aceb
1 require 'gtk2'
3 # Creates the window.
4 window = Gtk::Window.new
6 # The program will directly end upon 'delete_event'.
7 window.signal_connect('delete_event') do
8   Gtk.main_quit
9   false
10 end
12 # We create a box to pack widgets into.  
13 # This is described in detail in the following section.
14 # The box is not really visible, it is just used as a tool to arrange 
15 # widgets.
16 box1 = Gtk::HBox.new(true, 0)
18 # Put the box into the main window.
19 window.add(box1)
21 # Creates a new button with the label "Button 1".
22 button3 = Gtk::Button.new("Shut down")
23 button1 = Gtk::Button.new("Restart")
24 button2 = Gtk::Button.new("Suspend")
25 button4 = Gtk::Button.new("Lock screen")
27 # Now when the button is clicked, we call the "callback" method
28 # with a reference to "button 1" as its argument.
29 button2.signal_connect( "clicked" ) do 
30   `sudo reboot`
31 end
33 button3.signal_connect("clicked") do
34   `sudo pm-suspend`
35   `/etc/rc.d/mpd stop`
36 end
38 button1.signal_connect("clicked") do
39   `sudo shutdown -h now`
40 end
42 button4.signal_connect("clicked") do 
43   `xlock -mode blank`
44 end
45 # Instead of window.add, we pack this button into the invisible
46 # box, which has been packed into the window.
47 box1.pack_start(button3, true, true, 0)
48 box1.pack_start(button1, true, true, 0)
49 box1.pack_start(button2, true, true, 0)
50 box1.pack_start(button4, true, true, 0)
52 window.show_all
53 Gtk.main