Moved powerbutton UI in the right place
authorEnrico Zini <enrico@enricozini.org>
Tue, 11 Aug 2009 20:53:44 +0000 (21:53 +0100)
committerEnrico Zini <enrico@enricozini.org>
Tue, 11 Aug 2009 20:53:44 +0000 (21:53 +0100)
src/app_powerbutton.vala
src/input.vala
src/zavai.vala

index 035f4646489324bda8c7e1110af64f5f23828411..62f29e6aa7a625f6a61aeb2bd3e18038620c07a4 100644 (file)
@@ -109,6 +109,41 @@ public class WindowList : Applet
 }
 */
 
+public class CommandButton : Gtk.Button
+{
+       private string command;
+
+       public CommandButton(string name, string command)
+       {
+               label = name;
+               this.command = command;
+               clicked += on_clicked;
+               set_size_request(0, zavai.config.min_button_height);
+       }
+
+       public void on_clicked()
+       {
+               zavai.log.info("Run program: " + command);
+               string[] args = command.split(" ");
+               Pid pid;
+               Process.spawn_async(
+                       Environment.get_home_dir(),
+                       args,
+                       null,
+                       SpawnFlags.SEARCH_PATH,
+                       null,
+                       out pid);
+       }
+}
+
+private void on_power_button(Posix.timeval* time, bool pressed)
+{
+               if (!pressed)
+               {
+                       zavai.app.push_applet("menu.power");
+               }
+}
+
 /*
 RaiseIcon raise_icon;
 CloseOrBack close_or_back;
@@ -118,7 +153,18 @@ Launcher launcher;
 
 public void init()
 {
-    zavai.registry.gets("input.buttons").request("powerbutton");
+       zavai.input.power_button.power_button += on_power_button;
+
+    // Menus
+    var menu_power = new zavai.Menu("Power menu");
+       menu_power.add_widget(new CommandButton("Suspend", "apm -s"));
+       menu_power.add_widget(new CommandButton("Shutdown", "shutdown -h now"));
+       menu_power.add_widget(new CommandButton("Reboot", "shutdown -r now"));
+    zavai.registry.register_menu("menu.power", menu_power);
+
+    zavai.registry.getmenu("menu.main").add_applet("menu.power");
+
+    zavai.registry.gets("input.power_button").request("powerbutton");
 
     /*
        raise_icon = new RaiseIcon();
index 7eeb9a8d2a05e5289e03d758953416d4e2a2442e..882e69d8b599ac570aee2dcf11604df1893f47fd 100644 (file)
@@ -127,7 +127,6 @@ public class PowerButton : DevInput
         device = "/dev/input/event0";
 
                event += on_event;
-               power_button += on_power_button;
     }
 
        protected bool on_event(LinuxInput.Event* ev)
@@ -139,14 +138,6 @@ public class PowerButton : DevInput
                }
                return true;
        }
-
-       protected void on_power_button(Posix.timeval* time, bool pressed)
-       {
-               if (!pressed)
-               {
-                       zavai.app.push_applet("menu.power");
-               }
-       }
 }
 
 /*
@@ -289,32 +280,6 @@ class Audio:
         if res != 0:
             raise RuntimeError("Setting mixer failed")
 */
-public class CommandButton : Gtk.Button
-{
-       private string command;
-
-       public CommandButton(string name, string command)
-       {
-               label = name;
-               this.command = command;
-               clicked += on_clicked;
-               set_size_request(0, zavai.config.min_button_height);
-       }
-
-       public void on_clicked()
-       {
-               zavai.log.info("Run program: " + command);
-               string[] args = command.split(" ");
-               Pid pid;
-               Process.spawn_async(
-                       Environment.get_home_dir(),
-                       args,
-                       null,
-                       SpawnFlags.SEARCH_PATH,
-                       null,
-                       out pid);
-       }
-}
 
 
 public PowerButton power_button = null;
@@ -326,17 +291,5 @@ public void init()
        zavai.registry.register_service(power_button);
 }
 
-public void ui_init()
-{
-    // Menus
-    var menu_power = new zavai.Menu("Power menu");
-       menu_power.add_widget(new CommandButton("Suspend", "apm -s"));
-       menu_power.add_widget(new CommandButton("Shutdown", "shutdown -h now"));
-       menu_power.add_widget(new CommandButton("Reboot", "shutdown -r now"));
-    zavai.registry.register_menu("menu.power", menu_power);
-
-    zavai.registry.getmenu("menu.main").add_applet("menu.power");
-}
-
 }
 }
index a8719050d6937f2cb2cf9adccc111467670295ac..c11b2065214be7bb8cb091fe5ab4ae4af947c2b5 100644 (file)
@@ -68,7 +68,6 @@ static int main (string[] args) {
        zavai.ui.kbd.init();
        zavai.ui.wm.init();
        zavai.ui.powerbutton.init();
-       zavai.input.ui_init();
        zavai.ui.debug.init();
 
        zavai.app.show_applet("menu.main");