Added feature to keep backlight on
authorEnrico Zini <enrico@enricozini.org>
Fri, 14 Aug 2009 12:56:54 +0000 (13:56 +0100)
committerEnrico Zini <enrico@enricozini.org>
Fri, 14 Aug 2009 12:56:54 +0000 (13:56 +0100)
src/app_power.vala
src/gps.vala

index cd049f0c4d35860d9d825225d255efd186beffe8..70eb57e117c6917b0a09b069f5d3b72e865bfa7e 100644 (file)
@@ -220,12 +220,60 @@ public class RebootButton : Gtk.Button
        }
 }
 
        }
 }
 
+// For a list of dbus services, look in /etc/dbus-1/system.d/
+public class Backlight: zavai.Service
+{
+       public dynamic DBus.Object usage;
+
+       public Backlight()
+       {
+               name = "backlight";
+
+               usage = zavai.registry.sbus.get_object(
+                       "org.freesmartphone.ousaged",
+                       "/org/freesmartphone/Usage",
+                       "org.freesmartphone.Usage");
+       }
+
+       /// Request GPS resource
+       public override void start()
+       {
+               if (started) return;
+               try {
+                       usage.RequestResource("Display");
+                       zavai.log.info("Acquired display");
+                       base.start();
+               } catch (GLib.Error e) {
+                       zavai.log.error(e.message);
+               }
+               base.start();
+       }
+
+       // Release usage of GPS
+       public override void stop()
+       {
+               if (!started) return;
+               try {
+                       usage.ReleaseResource("Display");
+                       zavai.log.info("Released display");
+                       base.stop();
+               } catch (GLib.Error e) {
+                       zavai.log.error(e.message);
+               }
+               base.stop();
+       }
+}
+
+
 Power power;
 BatteryIcon battery_icon;
 Power power;
 BatteryIcon battery_icon;
+Backlight backlight;
 
 public void init()
 {
        power = new Power();
 
 public void init()
 {
        power = new Power();
+       backlight = new Backlight();
+       zavai.registry.register_service(backlight);
 
        battery_icon = new BatteryIcon();
        battery_icon.set_visible(true);
 
        battery_icon = new BatteryIcon();
        battery_icon.set_visible(true);
@@ -236,8 +284,10 @@ public void init()
        menu_power.add_widget(new SuspendButton());
        menu_power.add_widget(new ShutdownButton());
        menu_power.add_widget(new RebootButton());
        menu_power.add_widget(new SuspendButton());
        menu_power.add_widget(new ShutdownButton());
        menu_power.add_widget(new RebootButton());
+    menu_power.add_service_toggle("backlight", "Keep backlight on", "Let backlight fade");
     zavai.registry.register_menu("menu.power", menu_power);
 
     zavai.registry.register_menu("menu.power", menu_power);
 
+
     //zavai.registry.getmenu("menu.main").add_applet("menu.power");
 
     /*
     //zavai.registry.getmenu("menu.main").add_applet("menu.power");
 
     /*
index 3b455f0d5ff90fd01e27e7b3b7477c6003f14a35..4ce8deb79945c05c40b313114a67e92bbd9d06ce 100644 (file)
@@ -50,13 +50,15 @@ public class GPS: zavai.Service
 //         self.gps_time = dbus.Interface(gps, "org.freedesktop.Gypsy.Time")
 //         self.gps_position = dbus.Interface(gps, 'org.freedesktop.Gypsy.Position')
 //         self.gps_ubx = dbus.Interface(gps, 'org.freesmartphone.GPS.UBX')
 //         self.gps_time = dbus.Interface(gps, "org.freedesktop.Gypsy.Time")
 //         self.gps_position = dbus.Interface(gps, 'org.freedesktop.Gypsy.Position')
 //         self.gps_ubx = dbus.Interface(gps, 'org.freesmartphone.GPS.UBX')
-               usage.ResourceChanged += on_resourcechanged;
+//             usage.ResourceChanged += on_resourcechanged;
        }
 
        }
 
+/*
        public void on_resourcechanged(dynamic DBus.Object pos, string name, bool state, HashTable<string, Value?> attributes)
        {
                zavai.log.info("RESOURCE CHANGED " + name);
        }
        public void on_resourcechanged(dynamic DBus.Object pos, string name, bool state, HashTable<string, Value?> attributes)
        {
                zavai.log.info("RESOURCE CHANGED " + name);
        }
+*/
 
        /// Request GPS resource
        public override void start()
 
        /// Request GPS resource
        public override void start()