Implemented brightness slider in power menu
[gregoa/zavai.git] / src / app_power.vala
index d2c1f74cf654034aa39bf8baa0f585713481ca0d..c4af85c27de5b411146d15783311092198edea80 100644 (file)
@@ -464,14 +464,42 @@ public class Backlight: zavai.Service
        }
 }
 
+public class BrightnessAdjustment : Gtk.Adjustment
+{
+       public BrightnessAdjustment()
+       {
+               lower = 0;
+               upper = Omhacks.Screen.Brightness.get_max();
+               value = Omhacks.Screen.Brightness.get();
+               step_increment = 1;
+               page_increment = upper/10;
+               page_size = upper/10;
+               value_changed += on_value_changed;
+
+               /*
+               Gtk.Adjustment(
+                       zavai.config.backlight_max/2,
+                       0, zavai.config.backlight_max,
+                       1, zavai.config.backlight_max/10, zavai.config.backlight_max/10);
+               */
+       }
+
+       protected void on_value_changed()
+       {
+               Omhacks.Screen.Brightness.set((int)value);
+       }
+}
+
 public class PowerMenu : zavai.Resource, Gtk.Window
 {
        protected Gtk.VBox vbox;
+       protected Gtk.HBox hbox;
        protected ScreenLockButton act_screen_lock;
        protected SuspendButton act_suspend;
        protected ShutdownButton act_shutdown;
        protected RebootButton act_reboot;
        protected ServiceRequestLink act_backlight_on;
+       protected Gtk.VScrollbar bscroll;
        protected bool shown;
 
        public PowerMenu()
@@ -487,8 +515,15 @@ public class PowerMenu : zavai.Resource, Gtk.Window
                set_position(Gtk.WindowPosition.CENTER_ON_PARENT);
                set_size_request(300, 500);
 
+               hbox = new Gtk.HBox(false, 0);
+               add(hbox);
+
                vbox = new Gtk.VBox(false, 0);
-               add(vbox);
+               hbox.pack_start(vbox, true, true, 0);
+
+               bscroll = new Gtk.VScrollbar(brightness);
+               bscroll.inverted = true;
+               hbox.pack_start(bscroll, false, false, 0);
 
                //destroy += Gtk.main_quit;
                //set_events(get_events() | Gdk.EventMask.VISIBILITY_NOTIFY_MASK);
@@ -563,6 +598,7 @@ Power power;
 PowerMenu power_menu;
 Gee.ArrayList<BatteryIcon> battery_icons;
 Backlight backlight;
+BrightnessAdjustment brightness;
 //TogglePowerMenu tpm;
 
 public void init()
@@ -570,6 +606,7 @@ public void init()
        power = new Power();
        backlight = new Backlight();
        zavai.registry.register_service(backlight);
+       brightness = new BrightnessAdjustment();
        
        try {
                battery_icons = new Gee.ArrayList<BatteryIcon>();