Retabbed
authorEnrico Zini <enrico@enricozini.org>
Wed, 16 Dec 2009 14:55:20 +0000 (14:55 +0000)
committerEnrico Zini <enrico@enricozini.org>
Wed, 16 Dec 2009 14:55:20 +0000 (14:55 +0000)
src/app.vala
src/app_calendar.vala
src/app_debug.vala
src/app_gps.vala
src/app_keyboard.vala
src/app_main.vala
src/app_wm.vala
src/clock.vala
src/gsm.vala
src/input.vala

index b1095d5f6b3b7ff6a0b81e2ec583268edb50224e..12f41dd0608c813570c4789a7b9e329668f04362 100644 (file)
@@ -24,386 +24,386 @@ namespace zavai {
 
 public class Zavai : Gtk.Window, zavai.Resource
 {
-       public bool visibility = true;
-       public signal void visibility_changed(bool visible);
-
-       zavai.Applet current;
-       string current_name;
-
-       public Zavai()
-       {
-               title = "Zavai";
-               current = null;
-               current_name = null;
-               destroy += Gtk.main_quit;
-               set_events(get_events() | Gdk.EventMask.VISIBILITY_NOTIFY_MASK);
-               visibility_notify_event += on_visibility;
-               set_skip_pager_hint(true);
-               set_skip_taskbar_hint(true);
-               //set_type_hint(Gdk.WindowTypeHint.DESKTOP);
-       }
-
-       private bool on_visibility(Gdk.Event event)
-       {
-               visibility = (event.visibility.state == Gdk.VisibilityState.UNOBSCURED);
-               //visible = visibility;
-               visibility_changed(visibility);
-               return true;
-       }
-
-       public void toggle_visibility()
-       {
-               if (visibility)
-               {
-                       visible = false;
-                       visibility = false;
-                       visibility_changed(visibility);
-                       //zavai.app.iconify();
-               } else {
-                       visible = true;
-                       present();
-                       set_skip_pager_hint(true);
-                       set_skip_taskbar_hint(true);
-               }
-       }
-
-       public void ensure_visible()
-       {
-               if (!visibility)
-               {
-                       visible = true;
-                       present();
-                       set_skip_pager_hint(true);
-                       set_skip_taskbar_hint(true);
-               }
-       }
-
-       public void ensure_hidden()
-       {
-               if (visibility)
-               {
-                       visible = false;
-                       visibility = false;
-                       visibility_changed(visibility);
-               }
-       }
-
-       public void show_applet(string name)
-       {
-               zavai.Applet applet = zavai.registry.geta(name);
-
-               // Remove the current applet
-               if (current != null)
-               {
-                       current.stop();
-                       remove(current);
-                       current = null;
-                       current_name = null;
-               }
-
-               // Add the new applet
-               current = applet;
-               current_name = name;
-               add(current);
-               current.start();
-               current.show_all();
-       }
-
-       public void push_applet(string name)
-       {
-               // Make the function idempotent
-               if (current_name == name)
-                       return;
+    public bool visibility = true;
+    public signal void visibility_changed(bool visible);
+
+    zavai.Applet current;
+    string current_name;
+
+    public Zavai()
+    {
+        title = "Zavai";
+        current = null;
+        current_name = null;
+        destroy += Gtk.main_quit;
+        set_events(get_events() | Gdk.EventMask.VISIBILITY_NOTIFY_MASK);
+        visibility_notify_event += on_visibility;
+        set_skip_pager_hint(true);
+        set_skip_taskbar_hint(true);
+        //set_type_hint(Gdk.WindowTypeHint.DESKTOP);
+    }
+
+    private bool on_visibility(Gdk.Event event)
+    {
+        visibility = (event.visibility.state == Gdk.VisibilityState.UNOBSCURED);
+        //visible = visibility;
+        visibility_changed(visibility);
+        return true;
+    }
+
+    public void toggle_visibility()
+    {
+        if (visibility)
+        {
+            visible = false;
+            visibility = false;
+            visibility_changed(visibility);
+            //zavai.app.iconify();
+        } else {
+            visible = true;
+            present();
+            set_skip_pager_hint(true);
+            set_skip_taskbar_hint(true);
+        }
+    }
+
+    public void ensure_visible()
+    {
+        if (!visibility)
+        {
+            visible = true;
+            present();
+            set_skip_pager_hint(true);
+            set_skip_taskbar_hint(true);
+        }
+    }
+
+    public void ensure_hidden()
+    {
+        if (visibility)
+        {
+            visible = false;
+            visibility = false;
+            visibility_changed(visibility);
+        }
+    }
+
+    public void show_applet(string name)
+    {
+        zavai.Applet applet = zavai.registry.geta(name);
+
+        // Remove the current applet
+        if (current != null)
+        {
+            current.stop();
+            remove(current);
+            current = null;
+            current_name = null;
+        }
+
+        // Add the new applet
+        current = applet;
+        current_name = name;
+        add(current);
+        current.start();
+        current.show_all();
+    }
+
+    public void push_applet(string name)
+    {
+        // Make the function idempotent
+        if (current_name == name)
+            return;
 
 //stderr.printf("push applet %s -> %s\n", current_name, name);
-               zavai.Applet applet = zavai.registry.geta(name);
+        zavai.Applet applet = zavai.registry.geta(name);
 
-               // Remove the current applet
-               if (current != null)
-               {
+        // Remove the current applet
+        if (current != null)
+        {
 //stderr.printf("push applet remove %s\n", current_name);
-                       applet.back_link = current_name;
-                       current.stop();
-                       remove(current);
-                       current = null;
-                       current_name = null;
-               }
+            applet.back_link = current_name;
+            current.stop();
+            remove(current);
+            current = null;
+            current_name = null;
+        }
 
 //stderr.printf("push applet add %s\n", name);
-               // Add the new applet
-               current = applet;
-               current_name = name;
-               add(current);
-               current.start();
-               current.show_all();
-       }
-
-       public void back()
-       {
-               if (current != null)
-                       current.back();
-       }
-
-       public void back_to_main()
-       {
-               show_applet("zavai.status");
-       }
-
-       public void shutdown()
-       {
-       }
-
-       public void run()
-       {
-               set_size_request(300, 500);
-               //fullscreen();
-               show_all();
-       }
-
-       public void run_script(string command)
-       {
-               zavai.log.info("Run program: " + command);
-               string[] args = command.split(" ");
-               Pid pid;
-               try {
-                       Process.spawn_async(
-                               Environment.get_home_dir(),
-                               args,
-                               null,
-                               SpawnFlags.SEARCH_PATH,
-                               null,
-                               out pid);
-               } catch (SpawnError e) {
-                       zavai.log.error("Running " + command + ": " + e.message);
-               }
-       }
+        // Add the new applet
+        current = applet;
+        current_name = name;
+        add(current);
+        current.start();
+        current.show_all();
+    }
+
+    public void back()
+    {
+        if (current != null)
+            current.back();
+    }
+
+    public void back_to_main()
+    {
+        show_applet("zavai.status");
+    }
+
+    public void shutdown()
+    {
+    }
+
+    public void run()
+    {
+        set_size_request(300, 500);
+        //fullscreen();
+        show_all();
+    }
+
+    public void run_script(string command)
+    {
+        zavai.log.info("Run program: " + command);
+        string[] args = command.split(" ");
+        Pid pid;
+        try {
+            Process.spawn_async(
+                Environment.get_home_dir(),
+                args,
+                null,
+                SpawnFlags.SEARCH_PATH,
+                null,
+                out pid);
+        } catch (SpawnError e) {
+            zavai.log.error("Running " + command + ": " + e.message);
+        }
+    }
 }
 
 public abstract class Applet : Gtk.VBox, Resource
 {
-       // 'label' property: label to show in window title or button names
-       protected string _label;
-       public string label {
-               get { return this._label; }
-               set {
-                       if (_label != value)
-                       {
-                               _label = value;
-                               label_changed();
-                       }
-               }
-       }
-       public signal void label_changed();
-
-       protected Gtk.HBox button_box;
-
-       // 'back_link' property: link to use to "go back". If null, do not show
-       // a way to go back.
-       protected AppletLink _back_link = null;
-       public string back_link {
-               get { return _back_link.target; }
-               set {
+    // 'label' property: label to show in window title or button names
+    protected string _label;
+    public string label {
+        get { return this._label; }
+        set {
+            if (_label != value)
+            {
+                _label = value;
+                label_changed();
+            }
+        }
+    }
+    public signal void label_changed();
+
+    protected Gtk.HBox button_box;
+
+    // 'back_link' property: link to use to "go back". If null, do not show
+    // a way to go back.
+    protected AppletLink _back_link = null;
+    public string back_link {
+        get { return _back_link.target; }
+        set {
 //stderr.printf("Set back link of %s to %s\n", _label, value);
-                       if (value == null && _back_link != null)
-                       {
-                               _back_link.target = value;
-                               button_box.remove(_back_link);
-                       } else if (value != null) {
-                               if (_back_link.target == null)
-                               {
-                                       _back_link.target = value;
-                                       button_box.pack_end(_back_link, true, true, 0);
-                                       _back_link.show();
-                               } else
-                                       _back_link.target = value;
-                       }
-               }
-       }
-
-       public Applet()
-       {
-               button_box = new Gtk.HBox(true, 0);
-               this.homogeneous = false;
-               this.spacing = 0;
-               pack_end(button_box, false, true, 0);
-               _back_link = new AppletStraightLink();
-       }
-
-       public virtual void back()
-       {
-               _back_link.activate_applet();
-       }
-
-       public virtual void back_to_main()
-       {
-               zavai.app.back_to_main();
-       }
-
-       public void shutdown()
-       {
-               stop();
-       }
-
-       public virtual void start() {}
-       public virtual void stop() {}
+            if (value == null && _back_link != null)
+            {
+                _back_link.target = value;
+                button_box.remove(_back_link);
+            } else if (value != null) {
+                if (_back_link.target == null)
+                {
+                    _back_link.target = value;
+                    button_box.pack_end(_back_link, true, true, 0);
+                    _back_link.show();
+                } else
+                    _back_link.target = value;
+            }
+        }
+    }
+
+    public Applet()
+    {
+        button_box = new Gtk.HBox(true, 0);
+        this.homogeneous = false;
+        this.spacing = 0;
+        pack_end(button_box, false, true, 0);
+        _back_link = new AppletStraightLink();
+    }
+
+    public virtual void back()
+    {
+        _back_link.activate_applet();
+    }
+
+    public virtual void back_to_main()
+    {
+        zavai.app.back_to_main();
+    }
+
+    public void shutdown()
+    {
+        stop();
+    }
+
+    public virtual void start() {}
+    public virtual void stop() {}
 }
 
 public class Menu : Applet
 {
-       public Menu(string label)
-       {
-               _label = label;
-       }
-
-       public void add_applet(string target)
-       {
-               pack_start(new AppletPushLink(target), false, false, 0);
-       }
-
-       public void add_service_toggle(string service_name, string label_start, string label_stop)
-       {
-               pack_start(new ServiceRequestLink(service_name, label_start, label_stop), false, false, 0);
-       }
-
-       public void add_widget(Gtk.Widget w)
-       {
-               pack_start(w, false, false, 0);
-       }
+    public Menu(string label)
+    {
+        _label = label;
+    }
+
+    public void add_applet(string target)
+    {
+        pack_start(new AppletPushLink(target), false, false, 0);
+    }
+
+    public void add_service_toggle(string service_name, string label_start, string label_stop)
+    {
+        pack_start(new ServiceRequestLink(service_name, label_start, label_stop), false, false, 0);
+    }
+
+    public void add_widget(Gtk.Widget w)
+    {
+        pack_start(w, false, false, 0);
+    }
 }
 
 public class BigButton : Gtk.Button
 {
-       public BigButton()
-       {
-               set_size_request(0, zavai.config.min_button_height);
-       }
+    public BigButton()
+    {
+        set_size_request(0, zavai.config.min_button_height);
+    }
 }
 
 public abstract class AppletLink : BigButton
 {
-       protected string _target;
-       public string target {
-               get { return _target; }
-               set
-               {
-                       if (_target != null)
-                       {
-                               Applet a = zavai.registry.geta(_target);
-                               a.label_changed -= on_label_changed;
-                       }
-                       bool was_shown = _target != null;
-                       _target = value;
-                       if (_target != null)
-                       {
-                               Applet a = zavai.registry.geta(_target);
-                               set_label(a.label);
-                               a.label_changed += on_label_changed;
-                               if (!was_shown) show();
-                       } else {
-                               if (was_shown) hide();
-                       }
-               }
-       }
-
-       private void on_label_changed(Applet a)
-       {
-               set_label(a.label);
-       }
-
-       private abstract void on_clicked(Gtk.Button src);
-
-       public AppletLink(string? name = null)
-       {
-               _target = null;
-               target = name;
-
-               clicked += on_clicked;
-       }
-
-       public virtual void activate_applet()
-       {
-               on_clicked(this);
-       }
+    protected string _target;
+    public string target {
+        get { return _target; }
+        set
+        {
+            if (_target != null)
+            {
+                Applet a = zavai.registry.geta(_target);
+                a.label_changed -= on_label_changed;
+            }
+            bool was_shown = _target != null;
+            _target = value;
+            if (_target != null)
+            {
+                Applet a = zavai.registry.geta(_target);
+                set_label(a.label);
+                a.label_changed += on_label_changed;
+                if (!was_shown) show();
+            } else {
+                if (was_shown) hide();
+            }
+        }
+    }
+
+    private void on_label_changed(Applet a)
+    {
+        set_label(a.label);
+    }
+
+    private abstract void on_clicked(Gtk.Button src);
+
+    public AppletLink(string? name = null)
+    {
+        _target = null;
+        target = name;
+
+        clicked += on_clicked;
+    }
+
+    public virtual void activate_applet()
+    {
+        on_clicked(this);
+    }
 }
 
 public class AppletStraightLink : AppletLink
 {
-       private override void on_clicked(Gtk.Button src)
-       {
+    private override void on_clicked(Gtk.Button src)
+    {
 //stderr.printf("straight link: %s\n", _target);
-               if (_target != null)
-                       zavai.app.show_applet(_target);
-       }
-
-       public AppletStraightLink(string? name = null)
-       {
-               base(name);
-       }
+        if (_target != null)
+            zavai.app.show_applet(_target);
+    }
+
+    public AppletStraightLink(string? name = null)
+    {
+        base(name);
+    }
 }
 
 public class AppletPushLink : AppletLink
 {
-       private override void on_clicked(Gtk.Button src)
-       {
+    private override void on_clicked(Gtk.Button src)
+    {
 //stderr.printf("push link: %s\n", _target);
-               if (_target != null)
-                       zavai.app.push_applet(_target);
-       }
-
-       public AppletPushLink(string? name = null)
-       {
-               base(name);
-       }
+        if (_target != null)
+            zavai.app.push_applet(_target);
+    }
+
+    public AppletPushLink(string? name = null)
+    {
+        base(name);
+    }
 }
 
 public class ServiceRequestLink : Gtk.ToggleButton
 {
-       protected string service_name;
-       protected string label_start;
-       protected string label_stop;
-
-       private void on_toggled(Gtk.Button src)
-       {
-               Service s = zavai.registry.gets(service_name);
-               if (get_active())
-                       s.request("servicerequestlink");
-               else
-                       s.release("servicerequestlink");
-               set_label(get_active() ? label_stop : label_start);
-       }
-
-       public ServiceRequestLink(string service_name, string label_start, string label_stop)
-       {
-               this.service_name = service_name;
-               this.label_start = label_start;
-               this.label_stop = label_stop;
-               set_size_request(0, zavai.config.min_button_height);
-               toggled += on_toggled;
-
-               set_label(get_active() ? label_stop : label_start);
-       }
+    protected string service_name;
+    protected string label_start;
+    protected string label_stop;
+
+    private void on_toggled(Gtk.Button src)
+    {
+        Service s = zavai.registry.gets(service_name);
+        if (get_active())
+            s.request("servicerequestlink");
+        else
+            s.release("servicerequestlink");
+        set_label(get_active() ? label_stop : label_start);
+    }
+
+    public ServiceRequestLink(string service_name, string label_start, string label_stop)
+    {
+        this.service_name = service_name;
+        this.label_start = label_start;
+        this.label_stop = label_stop;
+        set_size_request(0, zavai.config.min_button_height);
+        toggled += on_toggled;
+
+        set_label(get_active() ? label_stop : label_start);
+    }
 }
 
 public class StatusIcon : Gtk.Button
 {
-       private Gtk.Image image_widget;
-
-       public StatusIcon()
-       {
-               relief = Gtk.ReliefStyle.NONE;
-               image_widget = new Gtk.Image();
-               image = image_widget;
-       }
-
-       public void set_from_file(string file)
-       {
-               image_widget.set_from_file(file);
-       }
-
-       public void install()
-       {
-               zavai.ui.main.status.status_icons.pack_start(this, false, false, 0);
-       }
+    private Gtk.Image image_widget;
+
+    public StatusIcon()
+    {
+        relief = Gtk.ReliefStyle.NONE;
+        image_widget = new Gtk.Image();
+        image = image_widget;
+    }
+
+    public void set_from_file(string file)
+    {
+        image_widget.set_from_file(file);
+    }
+
+    public void install()
+    {
+        zavai.ui.main.status.status_icons.pack_start(this, false, false, 0);
+    }
 }
 
 
index 05b3138f62a7c1ff87c92e1f39f4f777282f7b7e..6dae536efc5058865d55b69f6901de3dccbaa3a7 100644 (file)
@@ -24,32 +24,32 @@ namespace calendar {
 
 public class Calendar : Applet
 {
-       protected widgets.Calendar calendar;
+    protected widgets.Calendar calendar;
 
-       public Calendar()
-       {
-               _label = "Calendar";
-               calendar = new widgets.Calendar();
-               pack_start(calendar, true, true, 0);
-       }
-       
-       public override void start()
-       {
-               calendar.show_today();
-       }
-       public override void stop()
-       {
-               calendar.flush();
-       }
+    public Calendar()
+    {
+        _label = "Calendar";
+        calendar = new widgets.Calendar();
+        pack_start(calendar, true, true, 0);
+    }
+
+    public override void start()
+    {
+        calendar.show_today();
+    }
+    public override void stop()
+    {
+        calendar.flush();
+    }
 }
 
 Calendar calendar;
 
 public void init()
 {
-       calendar = new Calendar();
-        zavai.registry.register_applet("ui.calendar", calendar);
-        zavai.registry.getmenu("menu.misc").add_applet("ui.calendar");
+    calendar = new Calendar();
+    zavai.registry.register_applet("ui.calendar", calendar);
+    zavai.registry.getmenu("menu.misc").add_applet("ui.calendar");
 }
 
 }
index bf6a1fa3882662b159e627936f02a58317e552d6..e00b48dc9bf433125ff8d83b4745af1991513996 100644 (file)
@@ -46,7 +46,7 @@ public class Quitter : Applet
         _label = "Quit";
     }
 
-       public override void start()
+    public override void start()
     {
         Gtk.main_quit();
     }
@@ -60,11 +60,11 @@ public class PowerMenuService : Service
     }
     public override void start()
     {
-       zavai.ui.power.power_menu.toggle();
+        zavai.ui.power.power_menu.toggle();
     }
     public override void stop()
     {
-       zavai.ui.power.power_menu.toggle();
+        zavai.ui.power.power_menu.toggle();
     }
 }
 
@@ -80,8 +80,8 @@ class Quitter(gtk.Action):
 
 public void init()
 {
-               //label_on = "Stop useless service";
-               //label_off = "Start useless service";
+    //label_on = "Stop useless service";
+    //label_off = "Start useless service";
     // Apps
     var useless = new Useless();
     var quitter = new Quitter();
index a4512a5db1c3f04a1c70c07493ddd958847c858d..aac99d770fb87a878d90cae2b0be7c219fc45d71 100644 (file)
@@ -26,25 +26,25 @@ namespace gps {
 
 public class Waypoint : BigButton
 {
-       public Waypoint()
-       {
-               set_label("Take waypoint");
-               zavai.gps.gpx.tracking_changed += on_gpx_tracking_changed;
-               clicked += on_clicked;
-               set_sensitive(zavai.gps.gpx.tracking);
-       }
-
-       protected void on_gpx_tracking_changed(zavai.gps.GPX gpx, bool new_state)
-       {
-               stderr.printf("Toggled %d\n", (int)new_state);
-               set_sensitive(new_state);
-       }
-
-       protected void on_clicked()
-       {
-               stderr.printf("Activate\n");
-               zavai.gps.gpx.waypoint();
-       }
+    public Waypoint()
+    {
+        set_label("Take waypoint");
+        zavai.gps.gpx.tracking_changed += on_gpx_tracking_changed;
+        clicked += on_clicked;
+        set_sensitive(zavai.gps.gpx.tracking);
+    }
+
+    protected void on_gpx_tracking_changed(zavai.gps.GPX gpx, bool new_state)
+    {
+        stderr.printf("Toggled %d\n", (int)new_state);
+        set_sensitive(new_state);
+    }
+
+    protected void on_clicked()
+    {
+        stderr.printf("Activate\n");
+        zavai.gps.gpx.waypoint();
+    }
 }
 
 /*
@@ -95,92 +95,92 @@ class GPXAudioTracer(gtk.ToggleAction):
 
 public class GPSRequestLink : Gtk.ToggleButton
 {
-       protected string service_name;
-       protected string label_start;
-       protected string label_stop;
-       protected zavai.StatusIcon status_icon;
-       protected int fix_status = 0;
-
-       public GPSRequestLink()
-       {
-               service_name = "gps";
-               label_start = "Keep GPS on";
-               label_stop = "Stop keeping GPS on";
-               set_size_request(0, zavai.config.min_button_height);
-               toggled += on_toggled;
-
-               set_label(get_active() ? label_stop : label_start);
-
-               //tooltip = "GPS status";
-               try {
-                       fix_status = zavai.gps.gps.device.GetFixStatus();
-               } catch (Error e) {
-                       fix_status = 0;
-               }
-               zavai.gps.gps.device.FixStatusChanged += on_fix_status_changed;
-
-               // GPS status icon
-               status_icon = new zavai.StatusIcon();
-               status_icon.install();
-               status_icon.clicked += on_status_clicked;
-               update_icon();
-       }
-
-       protected void update_icon()
-       {
-               string name;
-               if (fix_status == 2 || fix_status == 3)
-                       name = zavai.config.icondir + "/" + (get_active() ? "gps_fix_on.png" : "gps_fix_off.png");
-               else
-                       name = zavai.config.icondir + "/" + (get_active() ? "gps_nofix_on.png" : "gps_nofix_off.png");
-               stderr.printf("load icon from %s\n", name);
-               status_icon.set_from_file(name);
-       }
-
-       private void on_fix_status_changed(dynamic DBus.Object pos, int fix_status)
-       {
-               this.fix_status = fix_status;
-               update_icon();
-       }
-
-       private void on_toggled(Gtk.Button src)
-       {
-               Service s = zavai.registry.gets(service_name);
-               if (get_active())
-                       s.request("servicerequestlink");
-               else
-                       s.release("servicerequestlink");
-               set_label(get_active() ? label_stop : label_start);
-               update_icon();
-       }
-
-       private void on_status_clicked(Gtk.Button b)
-       {
-               set_active(!get_active());
-       }
+    protected string service_name;
+    protected string label_start;
+    protected string label_stop;
+    protected zavai.StatusIcon status_icon;
+    protected int fix_status = 0;
+
+    public GPSRequestLink()
+    {
+        service_name = "gps";
+        label_start = "Keep GPS on";
+        label_stop = "Stop keeping GPS on";
+        set_size_request(0, zavai.config.min_button_height);
+        toggled += on_toggled;
+
+        set_label(get_active() ? label_stop : label_start);
+
+        //tooltip = "GPS status";
+        try {
+            fix_status = zavai.gps.gps.device.GetFixStatus();
+        } catch (Error e) {
+            fix_status = 0;
+        }
+        zavai.gps.gps.device.FixStatusChanged += on_fix_status_changed;
+
+        // GPS status icon
+        status_icon = new zavai.StatusIcon();
+        status_icon.install();
+        status_icon.clicked += on_status_clicked;
+        update_icon();
+    }
+
+    protected void update_icon()
+    {
+        string name;
+        if (fix_status == 2 || fix_status == 3)
+            name = zavai.config.icondir + "/" + (get_active() ? "gps_fix_on.png" : "gps_fix_off.png");
+        else
+            name = zavai.config.icondir + "/" + (get_active() ? "gps_nofix_on.png" : "gps_nofix_off.png");
+        stderr.printf("load icon from %s\n", name);
+        status_icon.set_from_file(name);
+    }
+
+    private void on_fix_status_changed(dynamic DBus.Object pos, int fix_status)
+    {
+        this.fix_status = fix_status;
+        update_icon();
+    }
+
+    private void on_toggled(Gtk.Button src)
+    {
+        Service s = zavai.registry.gets(service_name);
+        if (get_active())
+            s.request("servicerequestlink");
+        else
+            s.release("servicerequestlink");
+        set_label(get_active() ? label_stop : label_start);
+        update_icon();
+    }
+
+    private void on_status_clicked(Gtk.Button b)
+    {
+        set_active(!get_active());
+    }
 }
 
 public class GPSStuck : Gtk.Button
 {
-       protected bool happened;
-
-       public GPSStuck()
-       {
-               label = "The GPS is stuck";
-               happened = false;
-               clicked += on_clicked;
-               set_size_request(0, zavai.config.min_button_height);
-       }
-
-       public void on_clicked()
-       {
-               zavai.gps.gps.power_cycle(happened);
-               happened = !happened;
-               if (happened)
-                       label = "The GPS is stuck AGAIN";
-               else
-                       label = "The GPS is stuck";
-       }
+    protected bool happened;
+
+    public GPSStuck()
+    {
+        label = "The GPS is stuck";
+        happened = false;
+        clicked += on_clicked;
+        set_size_request(0, zavai.config.min_button_height);
+    }
+
+    public void on_clicked()
+    {
+        zavai.gps.gps.power_cycle(happened);
+        happened = !happened;
+        if (happened)
+            label = "The GPS is stuck AGAIN";
+        else
+            label = "The GPS is stuck";
+    }
 }
 
 public void init()
index c5caa3bab8783c3a5fbbfa124cc42af985dbaf05..467c1f631314e61bce3ebc58eab5459251c6251a 100644 (file)
@@ -26,103 +26,103 @@ namespace kbd {
 
 public class Keyboard : Service
 {
-       protected Pid pid;
-
-       public Keyboard()
-       {
-               Object(name: "keyboard");
-       }
-
-       private void on_child_quit(Pid pid, int status)
-       {
-               Process.close_pid(pid);
-               pid = (Pid)0;
-               stop();
-       }
-
-       protected override void start()
-       {
-               string[] args = { zavai.config.homedir + "/keyboard", null };
-               int opid;
-               try {
-                       Gdk.spawn_on_screen(
-                               Gdk.Screen.get_default(),
-                               "/",
-                               args,
-                               null,
-                               SpawnFlags.SEARCH_PATH | SpawnFlags.STDOUT_TO_DEV_NULL | SpawnFlags.STDERR_TO_DEV_NULL,
-                               null,
-                               out opid);
-                       pid = (Pid)opid;
-                       ChildWatch.add(pid, on_child_quit);
-                       base.start();
-               } catch (Error e) {
-                       log.error("Running " + zavai.config.homedir + "/keyboard: " + e.message);
-                       pid = (Pid)0;
-               }
-       }
-
-       protected override void stop()
-       {
-               if ((int)pid != 0)
-               {
-                       Posix.kill((int)pid, 15);
-                       pid = (Pid)0;
-               }
-               base.stop();
-       }
+    protected Pid pid;
+
+    public Keyboard()
+    {
+        Object(name: "keyboard");
+    }
+
+    private void on_child_quit(Pid pid, int status)
+    {
+        Process.close_pid(pid);
+        pid = (Pid)0;
+        stop();
+    }
+
+    protected override void start()
+    {
+        string[] args = { zavai.config.homedir + "/keyboard", null };
+        int opid;
+        try {
+            Gdk.spawn_on_screen(
+                Gdk.Screen.get_default(),
+                "/",
+                args,
+                null,
+                SpawnFlags.SEARCH_PATH | SpawnFlags.STDOUT_TO_DEV_NULL | SpawnFlags.STDERR_TO_DEV_NULL,
+                null,
+                out opid);
+            pid = (Pid)opid;
+            ChildWatch.add(pid, on_child_quit);
+            base.start();
+        } catch (Error e) {
+            log.error("Running " + zavai.config.homedir + "/keyboard: " + e.message);
+            pid = (Pid)0;
+        }
+    }
+
+    protected override void stop()
+    {
+        if ((int)pid != 0)
+        {
+            Posix.kill((int)pid, 15);
+            pid = (Pid)0;
+        }
+        base.stop();
+    }
 }
 
 public class KeyboardIcon : Gtk.StatusIcon
 {
-       bool requested = false;
+    bool requested = false;
 
-       public KeyboardIcon()
-       {
-               activate += on_activate;
+    public KeyboardIcon()
+    {
+        activate += on_activate;
         zavai.ui.power.power.screen_lock_changed += on_screen_lock_changed;
 
-               update_icon();
-       }
+        update_icon();
+    }
 
-       private void on_activate()
-       {
-               requested = !requested;
-               update_icon();
-               if (requested)
-                       keyboard.request("keyboardicon");
-               else
-                       keyboard.release("keyboardicon");
-       }
+    private void on_activate()
+    {
+        requested = !requested;
+        update_icon();
+        if (requested)
+            keyboard.request("keyboardicon");
+        else
+            keyboard.release("keyboardicon");
+    }
 
     protected void on_screen_lock_changed(bool val)
     {
         update_icon();
     }
 
-       protected void update_icon()
-       {
-               string name = zavai.config.icondir + "/";
+    protected void update_icon()
+    {
+        string name = zavai.config.icondir + "/";
         if (zavai.ui.power.power.screen_locked)
             name += "screen_lock.png";
         else
             name += (requested ? "kbd_on.png" : "kbd_off.png");
-               stderr.printf("load icon from %s\n", name);
-               set_from_file(name);
-       }
+        stderr.printf("load icon from %s\n", name);
+        set_from_file(name);
+    }
 }
 
 /*
 public class GPSRequestLink : Gtk.ToggleButton
 {
-       public GPSRequestLink()
-       {
+    public GPSRequestLink()
+    {
         // GPS status icon
         status_icon = new Gtk.StatusIcon();
         status_icon.set_visible(true);
         status_icon.activate += on_status_activate;
         update_icon();
-       }
+    }
 
     private void on_fix_status_changed(dynamic DBus.Object pos, int fix_status)
     {
@@ -130,16 +130,16 @@ public class GPSRequestLink : Gtk.ToggleButton
         update_icon();
     }
 
-       private void on_toggled(Gtk.Button src)
-       {
-               Service s = zavai.registry.gets(service_name);
-               if (get_active())
-                       s.request("servicerequestlink");
-               else
-                       s.release("servicerequestlink");
-               set_label(get_active() ? label_stop : label_start);
+    private void on_toggled(Gtk.Button src)
+    {
+        Service s = zavai.registry.gets(service_name);
+        if (get_active())
+            s.request("servicerequestlink");
+        else
+            s.release("servicerequestlink");
+        set_label(get_active() ? label_stop : label_start);
         update_icon();
-       }
+    }
 
     private void on_status_activate()
     {
@@ -154,10 +154,10 @@ KeyboardIcon icon;
 public void init()
 {
 stderr.printf("INIT KBD\n");
-       keyboard = new Keyboard();
-       zavai.registry.register_service(keyboard);
-       icon = new KeyboardIcon();
-       icon.set_visible(true);
+    keyboard = new Keyboard();
+    zavai.registry.register_service(keyboard);
+    icon = new KeyboardIcon();
+    icon.set_visible(true);
 }
 
 }
index eb8a72c3abb6782c728b5e91939745a36f794d3e..d8265f1911fbb750e8d46816d621158029e9220c 100644 (file)
@@ -53,10 +53,10 @@ public class Clock : Gtk.VBox
 
         l_date = new Gtk.Label("--");
         l_date.modify_font(Pango.FontDescription.from_string("Sans 40"));
-       l_date_button = new Gtk.Button();
-       l_date_button.set_image(l_date);
-       l_date_button.relief = Gtk.ReliefStyle.NONE;
-       l_date_button.clicked += on_date_clicked;
+        l_date_button = new Gtk.Button();
+        l_date_button.set_image(l_date);
+        l_date_button.relief = Gtk.ReliefStyle.NONE;
+        l_date_button.clicked += on_date_clicked;
         pack_start(l_date_button, false, false, 0);
         l_time = new Gtk.Label("--:--");
         l_time.modify_font(Pango.FontDescription.from_string("Sans 60"));
@@ -68,27 +68,27 @@ public class Clock : Gtk.VBox
 
         zavai.clock.clock.minute_changed += on_minute_changed;
         zavai.clock.clock.schedule_changed += on_schedule_changed;
-       on_schedule_changed(zavai.clock.clock.next_alarm());
+        on_schedule_changed(zavai.clock.clock.next_alarm());
 
         zavai.clock.clock.request("ui.main.clock");
     }
 
     private void on_date_clicked(Gtk.Button b)
     {
-           zavai.app.push_applet("ui.calendar");
+        zavai.app.push_applet("ui.calendar");
     }
 
     private void on_schedule_changed(zavai.clock.Alarm? next)
     {
-           if (next == null)
-           {
-                   last_deadline = 0;
-                   last_deadline_label = "";
-           } else {
-                   last_deadline = next.ev.deadline;
-                   last_deadline_label = next.label;
-           }
-           on_minute_changed((long)last_time, last_time_type);
+        if (next == null)
+        {
+            last_deadline = 0;
+            last_deadline_label = "";
+        } else {
+            last_deadline = next.ev.deadline;
+            last_deadline_label = next.label;
+        }
+        on_minute_changed((long)last_time, last_time_type);
     }
 
     private void on_minute_changed(long ts, zavai.clock.SourceType type)
@@ -106,7 +106,7 @@ public class Clock : Gtk.VBox
                 typetag = "sys";
                 break;
         }
-                
+
         var t = Time.local((time_t)ts);
         l_date.set_text(t.format("%a %d %b"));
         l_time.set_text("%2d:%02d (%s)".printf(t.hour, t.minute, typetag));
@@ -132,17 +132,17 @@ public class Status : Applet
     public Clock clock;
     public AppletPushLink menu;
 
-       public Status(string label)
-       {
-               _label = label;
+    public Status(string label)
+    {
+        _label = label;
         status_icons = new Gtk.HBox(false, 0);
         clock = new Clock();
         menu = new AppletPushLink("menu.main");
 
-               pack_start(status_icons, false, false, 0);
-               pack_start(clock, false, false, 0);
-               pack_end(menu, false, false, 0);
-       }
+        pack_start(status_icons, false, false, 0);
+        pack_start(clock, false, false, 0);
+        pack_end(menu, false, false, 0);
+    }
 }
 
 public class IncDec : Gtk.HBox
@@ -160,13 +160,13 @@ public class IncDec : Gtk.HBox
     {
         homogeneous = true;
         b_decmore = new Gtk.Button.with_label("«");
-               b_decmore.set_size_request(BW, BH);
+        b_decmore.set_size_request(BW, BH);
         b_dec = new Gtk.Button.with_label("<");
-               b_dec.set_size_request(BW, BH);
+        b_dec.set_size_request(BW, BH);
         b_inc = new Gtk.Button.with_label(">");
-               b_inc.set_size_request(BW, BH);
+        b_inc.set_size_request(BW, BH);
         b_incmore = new Gtk.Button.with_label("»");
-               b_incmore.set_size_request(BW, BH);
+        b_incmore.set_size_request(BW, BH);
         pack_start(b_decmore, false, true, 0);
         pack_start(b_dec, false, true, 0);
         pack_start(b_inc, false, true, 0);
@@ -214,7 +214,7 @@ public abstract class AddDeadline : Applet
         button_box.pack_start(dl_submit, true, true, 0);
     }
 
-       public override void start()
+    public override void start()
     {
         ((Gtk.Entry)dl_label.get_child()).set_text("");
         update();
@@ -235,11 +235,11 @@ public abstract class AddDeadline : Applet
     protected void on_submit(Gtk.Button b)
     {
         string label = ((Gtk.Entry)dl_label.get_child()).get_text();
-       time_t deadlinets = get_deadline();
-       Time deadline = Time.local(deadlinets);
-       string timespec = deadline.format("%H:%M %m/%d/%Y");
+        time_t deadlinets = get_deadline();
+        Time deadline = Time.local(deadlinets);
+        string timespec = deadline.format("%H:%M %m/%d/%Y");
         zavai.log.info("Scheduling deadline " + label + " at " + timespec);
-       zavai.clock.clock.schedule(timespec, label);
+        zavai.clock.clock.schedule(timespec, label);
         back();
     }
 }
@@ -290,7 +290,7 @@ public class AddAbsoluteDeadline : AddDeadline
         pack_start(hbox, false, false, 0);
     }
 
-       public override void start()
+    public override void start()
     {
         dl_time = time_t();
         base.start();
@@ -360,7 +360,7 @@ public class AddRelativeDeadline : AddDeadline
         pack_start(hbox, false, false, 0);
     }
 
-       public override void start()
+    public override void start()
     {
         dl_time = 0;
         base.start();
@@ -421,9 +421,9 @@ public void init()
     */
 
     var menu_misc = zavai.registry.getmenu("menu.misc");
-       menu_misc.add_applet("clock.addabsolute");
-       menu_misc.add_applet("clock.addrelative");
-       //menu_misc.add_applet("clock.adddaily");
+    menu_misc.add_applet("clock.addabsolute");
+    menu_misc.add_applet("clock.addrelative");
+    //menu_misc.add_applet("clock.adddaily");
 }
 
 }
index 471f9fc9f5be1c7744489238f9d636f7512fe0f3..217f5901cd7b683cd9fd36aabd244e0753351b79 100644 (file)
@@ -27,230 +27,230 @@ namespace wm {
 /*
 static void print_window_state(Gtk.Window w)
 {
-       Gdk.WindowState state = w.window.get_state();
-       int istate = (int) state;
-       bool is_icon = (state & Gdk.WindowState.ICONIFIED) != 0;
-       bool is_visible = w.visible;
-       bool is_focus = w.is_focus;
-       bool has_focus = ((Gtk.Widget)w).has_focus;
-       bool is_active = w.is_active;
-       bool is_toplevel = w.is_toplevel();
-       bool is_tfocus = w.has_toplevel_focus;
-
-       stderr.printf("istate: %d; is_icon: %s; is_visible: %s; is_focus: %s; has_focus: %s, is_active: %s; is_toplevel: %s; is_tfocus: %s\n",
-                       istate,
-                       is_icon ? "true" : "false",
-                       is_visible ? "true" : "false",
-                       is_focus ? "true" : "false",
-                       has_focus ? "true" : "false",
-                       is_active ? "true" : "false",
-                       is_toplevel ? "true" : "false",
-                       is_tfocus ? "true" : "false"
-                    );
+    Gdk.WindowState state = w.window.get_state();
+    int istate = (int) state;
+    bool is_icon = (state & Gdk.WindowState.ICONIFIED) != 0;
+    bool is_visible = w.visible;
+    bool is_focus = w.is_focus;
+    bool has_focus = ((Gtk.Widget)w).has_focus;
+    bool is_active = w.is_active;
+    bool is_toplevel = w.is_toplevel();
+    bool is_tfocus = w.has_toplevel_focus;
+
+    stderr.printf("istate: %d; is_icon: %s; is_visible: %s; is_focus: %s; has_focus: %s, is_active: %s; is_toplevel: %s; is_tfocus: %s\n",
+            istate,
+            is_icon ? "true" : "false",
+            is_visible ? "true" : "false",
+            is_focus ? "true" : "false",
+            has_focus ? "true" : "false",
+            is_active ? "true" : "false",
+            is_toplevel ? "true" : "false",
+            is_tfocus ? "true" : "false"
+             );
 }
 */
 
 public class RaiseIcon : Gtk.StatusIcon
 {
-       public RaiseIcon()
-       {
-               activate += on_activate;
-               zavai.app.visibility_changed += on_visibility_changed;
-               update_icon();
-       }
-
-       private void on_visibility_changed(bool visible)
-       {
-               update_icon();
-       }
-
-       private void on_activate()
-       {
-               zavai.app.toggle_visibility();
-               update_icon();
-       }
-
-       protected void update_icon()
-       {
-               string name = zavai.config.icondir + "/";
-               if (!zavai.app.visibility)
-                       name += "zavai_on.png";
-               else
-                       name += "zavai_off.png";
-               set_from_file(name);
-       }
+    public RaiseIcon()
+    {
+        activate += on_activate;
+        zavai.app.visibility_changed += on_visibility_changed;
+        update_icon();
+    }
+
+    private void on_visibility_changed(bool visible)
+    {
+        update_icon();
+    }
+
+    private void on_activate()
+    {
+        zavai.app.toggle_visibility();
+        update_icon();
+    }
+
+    protected void update_icon()
+    {
+        string name = zavai.config.icondir + "/";
+        if (!zavai.app.visibility)
+            name += "zavai_on.png";
+        else
+            name += "zavai_off.png";
+        set_from_file(name);
+    }
 }
 
 public class CloseOrBack : Gtk.StatusIcon
 {
-       public CloseOrBack()
-       {
-               activate += on_activate;
-               zavai.app.visibility_changed += on_visibility_changed;
-               update_icon();
-       }
-
-       private void on_visibility_changed(bool visible)
-       {
-               update_icon();
-       }
-
-       private void on_activate()
-       {
-               if (zavai.app.visibility)
-               {
-                       // Back
-                       zavai.app.back();
-               } else {
-                       // Close current app
-                       Gdk.Window w = zavai.app.get_screen().get_active_window();
-                       if (w != zavai.app.window)
-                       {
-                               w.destroy();
-                       }
-               }
-       }
-
-       protected void update_icon()
-       {
-               string name = zavai.config.icondir + "/";
-               if (!zavai.app.visibility)
-                       name += "quit_on.png";
-               else
-                       name += "quit_off.png";
-               set_from_file(name);
-       }
+    public CloseOrBack()
+    {
+        activate += on_activate;
+        zavai.app.visibility_changed += on_visibility_changed;
+        update_icon();
+    }
+
+    private void on_visibility_changed(bool visible)
+    {
+        update_icon();
+    }
+
+    private void on_activate()
+    {
+        if (zavai.app.visibility)
+        {
+            // Back
+            zavai.app.back();
+        } else {
+            // Close current app
+            Gdk.Window w = zavai.app.get_screen().get_active_window();
+            if (w != zavai.app.window)
+            {
+                w.destroy();
+            }
+        }
+    }
+
+    protected void update_icon()
+    {
+        string name = zavai.config.icondir + "/";
+        if (!zavai.app.visibility)
+            name += "quit_on.png";
+        else
+            name += "quit_off.png";
+        set_from_file(name);
+    }
 }
 
 public class WindowList : Applet
 {
-       protected Wnck.Tasklist selector;
-       protected AppletPushLink launcher_link;
+    protected Wnck.Tasklist selector;
+    protected AppletPushLink launcher_link;
 
-       public WindowList(string label)
-       {
-               _label = label;
-               selector = new Wnck.Tasklist(Wnck.Screen.get_default());
-               pack_start(selector, true, true, 0);
+    public WindowList(string label)
+    {
+        _label = label;
+        selector = new Wnck.Tasklist(Wnck.Screen.get_default());
+        pack_start(selector, true, true, 0);
 
-               launcher_link = new AppletPushLink("wm.launcher");
+        launcher_link = new AppletPushLink("wm.launcher");
         button_box.pack_start(launcher_link, true, true, 0);
-       }
+    }
 }
 
 public class LauncherButton : Gtk.Button
 {
-       private string exec;
-
-       public LauncherButton(string name, string exec)
-       {
-               label = name;
-               this.exec = exec;
-               clicked += on_clicked;
-               set_size_request(0, zavai.config.min_button_height);
-       }
-
-       public void on_clicked()
-       {
-               zavai.log.info("Run program: " + exec);
-               string[] args = exec.split(" ");
-               string[] args1 = new string[args.length + 1];
-               int cout = 0;
-               for (int cin = 0; cin < args.length; ++cin)
-               {
-                       if (args[cin][0] == '%') continue;
-                       args1[cout++] = args[cin];
-               }
-               args1[cout] = null;
-               Pid pid;
-               try {
-                       Process.spawn_async(
-                               Environment.get_home_dir(),
-                               args1,
-                               null,
-                               SpawnFlags.SEARCH_PATH,
-                               null,
-                               out pid);
-               } catch (SpawnError e) {
-                       zavai.log.error("Launching " + exec + ": " + e.message);
-               }
-       }
+    private string exec;
+
+    public LauncherButton(string name, string exec)
+    {
+        label = name;
+        this.exec = exec;
+        clicked += on_clicked;
+        set_size_request(0, zavai.config.min_button_height);
+    }
+
+    public void on_clicked()
+    {
+        zavai.log.info("Run program: " + exec);
+        string[] args = exec.split(" ");
+        string[] args1 = new string[args.length + 1];
+        int cout = 0;
+        for (int cin = 0; cin < args.length; ++cin)
+        {
+            if (args[cin][0] == '%') continue;
+            args1[cout++] = args[cin];
+        }
+        args1[cout] = null;
+        Pid pid;
+        try {
+            Process.spawn_async(
+                Environment.get_home_dir(),
+                args1,
+                null,
+                SpawnFlags.SEARCH_PATH,
+                null,
+                out pid);
+        } catch (SpawnError e) {
+            zavai.log.error("Launching " + exec + ": " + e.message);
+        }
+    }
 }
 
 public class Launcher: Applet
 {
-       static const string DENTRY_GROUP = "Desktop Entry";
-
-       public Launcher(string label) throws Error
-       {
-               _label = label;
-
-               var dir = File.new_for_path(zavai.config.homedir);
-               var enumerator = dir.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
-
-               FileInfo file_info;
-               var icon_theme = Gtk.IconTheme.get_default();
-               Gee.ArrayList<LauncherButton> buttons = new Gee.ArrayList<LauncherButton>();
-               while ((file_info = enumerator.next_file(null)) != null)
-               {
-                       if (!file_info.get_name().has_suffix(".desktop")) continue;
-                               
-                       string pathname = zavai.config.homedir + "/" + file_info.get_name();
-                       //stdout.printf("Load %s\n", pathname);
-
-                       string icon = null;
-                       var kf = new KeyFile();
-                       try {
-                               kf.load_from_file(pathname, KeyFileFlags.NONE);
-                               if (! kf.has_group(DENTRY_GROUP)) continue;
-                               if (! kf.has_key(DENTRY_GROUP, "Name")) continue;
-                               if (! kf.has_key(DENTRY_GROUP, "Exec")) continue;
-                               if (kf.has_key(DENTRY_GROUP, "Icon"))
-                                       icon = kf.get_string(DENTRY_GROUP, "Icon");
-                       } catch (Error e) {
-                               zavai.log.error("Skipping file " + pathname + ": " + e.message);
-                               continue;
-                       }
-                       var name = kf.get_string(DENTRY_GROUP, "Name");
-                       var exec = kf.get_string(DENTRY_GROUP, "Exec");
-                       var button = new LauncherButton(name, exec);
-                       if (icon != null && icon_theme.has_icon(icon))
-                       {
-                               try {
-                                       var pb = icon_theme.load_icon(icon, zavai.config.min_button_height * 2 / 3, 0);
-                                       button.image = new Gtk.Image.from_pixbuf(pb);
-                               } catch (Error e) {
-                                       zavai.log.error("Skipping icon " + icon + ": " + e.message);
-                               }
-                       }
-                       button.clicked += a => { this.back_to_main(); zavai.app.ensure_hidden(); };
-                       buttons.add(button);
-               }
-
-               // Create the table with the launcher buttons
-               uint ROWMAX = 5;        // Maximum number of rows
-               uint cols = 1 + (buttons.size + 1) / ROWMAX; // ceil(size/ROWMAX)
-               uint rows = (buttons.size + 1) / cols;   // ceil(size/cols)
-               var table = new Gtk.Table(rows, cols, true);
-
-               // Attach the buttons in the table
-               uint row = 0;
-               uint col = 0;
-               foreach (LauncherButton b in buttons)
-               {
-                       table.attach(b, col, col+1, row, row+1,
-                               Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
-                               Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
-                               0, 0);
-                       ++col;
-                       if (col == cols)
-                       {
-                               col = 0;
-                               ++row;
-                       }
-               }
-
-               pack_start(table, true, true, 0);
+    static const string DENTRY_GROUP = "Desktop Entry";
+
+    public Launcher(string label) throws Error
+    {
+        _label = label;
+
+        var dir = File.new_for_path(zavai.config.homedir);
+        var enumerator = dir.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
+
+        FileInfo file_info;
+        var icon_theme = Gtk.IconTheme.get_default();
+        Gee.ArrayList<LauncherButton> buttons = new Gee.ArrayList<LauncherButton>();
+        while ((file_info = enumerator.next_file(null)) != null)
+        {
+            if (!file_info.get_name().has_suffix(".desktop")) continue;
+
+            string pathname = zavai.config.homedir + "/" + file_info.get_name();
+            //stdout.printf("Load %s\n", pathname);
+
+            string icon = null;
+            var kf = new KeyFile();
+            try {
+                kf.load_from_file(pathname, KeyFileFlags.NONE);
+                if (! kf.has_group(DENTRY_GROUP)) continue;
+                if (! kf.has_key(DENTRY_GROUP, "Name")) continue;
+                if (! kf.has_key(DENTRY_GROUP, "Exec")) continue;
+                if (kf.has_key(DENTRY_GROUP, "Icon"))
+                    icon = kf.get_string(DENTRY_GROUP, "Icon");
+            } catch (Error e) {
+                zavai.log.error("Skipping file " + pathname + ": " + e.message);
+                continue;
+            }
+            var name = kf.get_string(DENTRY_GROUP, "Name");
+            var exec = kf.get_string(DENTRY_GROUP, "Exec");
+            var button = new LauncherButton(name, exec);
+            if (icon != null && icon_theme.has_icon(icon))
+            {
+                try {
+                    var pb = icon_theme.load_icon(icon, zavai.config.min_button_height * 2 / 3, 0);
+                    button.image = new Gtk.Image.from_pixbuf(pb);
+                } catch (Error e) {
+                    zavai.log.error("Skipping icon " + icon + ": " + e.message);
+                }
+            }
+            button.clicked += a => { this.back_to_main(); zavai.app.ensure_hidden(); };
+            buttons.add(button);
+        }
+
+        // Create the table with the launcher buttons
+        uint ROWMAX = 5;    // Maximum number of rows
+        uint cols = 1 + (buttons.size + 1) / ROWMAX; // ceil(size/ROWMAX)
+        uint rows = (buttons.size + 1) / cols;   // ceil(size/cols)
+        var table = new Gtk.Table(rows, cols, true);
+
+        // Attach the buttons in the table
+        uint row = 0;
+        uint col = 0;
+        foreach (LauncherButton b in buttons)
+        {
+            table.attach(b, col, col+1, row, row+1,
+                Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
+                Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
+                0, 0);
+            ++col;
+            if (col == cols)
+            {
+                col = 0;
+                ++row;
+            }
+        }
+
+        pack_start(table, true, true, 0);
 
 /*
     try {
@@ -259,29 +259,29 @@ public class Launcher: Applet
         return 1;
     }
 
-               for (string file in confdir)
-               {
-               }
+        for (string file in confdir)
+        {
+        }
 */
-       }
+    }
 }
 
 public class AppShortcut : Object
 {
-       private StatusIcon icon;
-
-       public AppShortcut()
-       {
-               icon = new StatusIcon();
-               icon.install();
-               icon.clicked += on_icon_clicked;
-               icon.set_from_file(zavai.config.icondir + "/apps.png");
-       }
-
-       public void on_icon_clicked()
-       {
-               zavai.app.push_applet("wm.list");
-       }
+    private StatusIcon icon;
+
+    public AppShortcut()
+    {
+        icon = new StatusIcon();
+        icon.install();
+        icon.clicked += on_icon_clicked;
+        icon.set_from_file(zavai.config.icondir + "/apps.png");
+    }
+
+    public void on_icon_clicked()
+    {
+        zavai.app.push_applet("wm.list");
+    }
 }
 
 RaiseIcon raise_icon;
@@ -292,27 +292,27 @@ AppShortcut app_shortcut;
 
 public void init()
 {
-       raise_icon = new RaiseIcon();
-       raise_icon.set_visible(true);
+    raise_icon = new RaiseIcon();
+    raise_icon.set_visible(true);
 
-       close_or_back = new CloseOrBack();
-       close_or_back.set_visible(true);
+    close_or_back = new CloseOrBack();
+    close_or_back.set_visible(true);
 
-       app_shortcut = new AppShortcut();
+    app_shortcut = new AppShortcut();
 
-       try {
-               launcher = new Launcher("Run program");
-               zavai.registry.register_applet("wm.launcher", launcher);
-       } catch (Error e) {
-               stderr.printf("Error creating app launcher: %s\n", e.message);
-               launcher = null;
-       }
+    try {
+        launcher = new Launcher("Run program");
+        zavai.registry.register_applet("wm.launcher", launcher);
+    } catch (Error e) {
+        stderr.printf("Error creating app launcher: %s\n", e.message);
+        launcher = null;
+    }
 
-       window_list = new WindowList("Apps");
-       zavai.registry.register_applet("wm.list", window_list);
-       zavai.registry.getmenu("menu.main").add_applet("wm.list");
+    window_list = new WindowList("Apps");
+    zavai.registry.register_applet("wm.list", window_list);
+    zavai.registry.getmenu("menu.main").add_applet("wm.list");
 
-       //zavai.registry.getmenu("menu.main").add_applet("wm.launcher");
+    //zavai.registry.getmenu("menu.main").add_applet("wm.launcher");
 }
 
 }
index 6bc889c5816cbf7673619a3d3ef77d5451a497b5..d470432d99a001835f42a114e8e3c0bda7754f93 100644 (file)
@@ -25,8 +25,8 @@ namespace clock {
 
 public enum SourceType
 {
-       SYSTEM,
-       GPS
+    SYSTEM,
+    GPS
 }
 
 /*
@@ -49,15 +49,15 @@ generic at job.
 
 refresh_alarms()
 {
-       oldtime = next_alarm ? next_alarm.time : 0
-       next_alarm = the first alarm from atq
-       if (oldtime != next_alarm.time)
-       {
-               remove existing triggers
-                 (triggers can be skipped if we don't need to support non-zavai alarms)
-               schedule a trigger calling refresh_alarms() at next_alarm.time + 30 seconds
-                 (triggers can be skipped if we don't need to support non-zavai alarms)
-       }
+    oldtime = next_alarm ? next_alarm.time : 0
+    next_alarm = the first alarm from atq
+    if (oldtime != next_alarm.time)
+    {
+        remove existing triggers
+          (triggers can be skipped if we don't need to support non-zavai alarms)
+        schedule a trigger calling refresh_alarms() at next_alarm.time + 30 seconds
+          (triggers can be skipped if we don't need to support non-zavai alarms)
+    }
 }
 
 at clock constructor: refresh_alarms()
@@ -71,218 +71,218 @@ at alarm triggered through zavai: refresh_alarms()
 
 public class Alarm : Object
 {
-       public at.Event ev;
-       public string label;
-
-       // Schedule with at
-       public static void schedule(string timespec, string label) throws Error
-       {
-               string argv[5];
-               argv[0] = "/usr/bin/at";
-               argv[1] = "-q";
-               argv[2] = "z";
-               argv[3] = timespec;
-               argv[4] = null;
-
-               Pid pid;
-               int stdinfd;
-
-               if (!Process.spawn_async_with_pipes("/", argv, null, SpawnFlags.STDERR_TO_DEV_NULL, null, out pid, out stdinfd, null, null))
-                       return;
-
-               {
-                       FileStream fs = FileStream.fdopen(stdinfd, "w");
-                       string display = GLib.Environment.get_variable("DISPLAY");
-                       if (display != null)
-                               fs.printf("DISPLAY=\"%s\"; export DISPLAY\n", display);
-                       fs.printf("# Zavai variables start here\n");
-                       fs.printf("ZAVAI_LABEL=\"%s\"\n", label.escape(""));
-                       fs.printf("# Zavai commands starts here\n");
-                       fs.printf("%s notify \"$ZAVAI_LABEL\"", zavai.config.argv0);
-               }
-               
-               Process.close_pid(pid);
-       }
-
-       // Get the label of the job with the given at ID
-       public static string? getLabel(int atID)
-       {
-               string label = null;
-               at.jobContents(atID, fd => {
-                       FileStream fs = FileStream.fdopen(fd, "r");
-                       while (true)
-                       {
-                               string? line = fs.read_line();
-                               if (line == null) break;
-                               if (line.has_prefix("ZAVAI_LABEL=\""))
-                               {
-                                       size_t size = line.size();
-                                       if (size < 15) continue;
-                                       label = line.substring(13, (long)(size - 14));
-                                       label = label.compress();
-                                       break;
-                               }
-                       }
-                       return true;
-               });
-               return label;
-       }
+    public at.Event ev;
+    public string label;
+
+    // Schedule with at
+    public static void schedule(string timespec, string label) throws Error
+    {
+        string argv[5];
+        argv[0] = "/usr/bin/at";
+        argv[1] = "-q";
+        argv[2] = "z";
+        argv[3] = timespec;
+        argv[4] = null;
+
+        Pid pid;
+        int stdinfd;
+
+        if (!Process.spawn_async_with_pipes("/", argv, null, SpawnFlags.STDERR_TO_DEV_NULL, null, out pid, out stdinfd, null, null))
+            return;
+
+        {
+            FileStream fs = FileStream.fdopen(stdinfd, "w");
+            string display = GLib.Environment.get_variable("DISPLAY");
+            if (display != null)
+                fs.printf("DISPLAY=\"%s\"; export DISPLAY\n", display);
+            fs.printf("# Zavai variables start here\n");
+            fs.printf("ZAVAI_LABEL=\"%s\"\n", label.escape(""));
+            fs.printf("# Zavai commands starts here\n");
+            fs.printf("%s notify \"$ZAVAI_LABEL\"", zavai.config.argv0);
+        }
+        
+        Process.close_pid(pid);
+    }
+
+    // Get the label of the job with the given at ID
+    public static string? getLabel(int atID)
+    {
+        string label = null;
+        at.jobContents(atID, fd => {
+            FileStream fs = FileStream.fdopen(fd, "r");
+            while (true)
+            {
+                string? line = fs.read_line();
+                if (line == null) break;
+                if (line.has_prefix("ZAVAI_LABEL=\""))
+                {
+                    size_t size = line.size();
+                    if (size < 15) continue;
+                    label = line.substring(13, (long)(size - 14));
+                    label = label.compress();
+                    break;
+                }
+            }
+            return true;
+        });
+        return label;
+    }
 }
 
 [DBus (name = "org.enricozini.zavai.Alarm")]
 public class ZavaiClock : Object {
-       public void Notify (string label) {
-               clock.notify_alarm(label);
-       }
+    public void Notify (string label) {
+        clock.notify_alarm(label);
+    }
 }
 
 public class Clock: zavai.Service
 {
-       protected time_t last_gps_time;
-       protected time_t last_gps_time_system_time;
-       protected time_t last_system_time;
-       protected dynamic DBus.Object gps_time;
-       protected uint system_time_timeout;
-       protected time_t last_minute;
-       protected time_t chosen_time;
-       protected SourceType chosen_type;
-       protected ZavaiClock dbusClock;
-
-       protected dynamic DBus.Object otimed_alarm;
-       protected dynamic DBus.Object rtc;
-       protected SList<Alarm> alarms;
-
-       // Ticks once a minute
-       public signal void minute_changed(long time, SourceType source);
-       public signal void schedule_changed(Alarm? next);
-       public signal void alarm_triggered(string label);
-
-       public Clock()
-       {
-               Object(name: "clock");
-               alarms = null;
-               dbusClock = new ZavaiClock();
-               last_minute = 0;
-               last_gps_time = 0;
-               last_gps_time_system_time = 0;
-               last_system_time = time_t();
-               chosen_time = last_system_time;
-
-               gps_time = zavai.registry.sbus.get_object(
-                               "org.freesmartphone.ogpsd",
-                               "/org/freedesktop/Gypsy",
-                               "org.freedesktop.Gypsy.Time");
-
-               // FSO alarm system
-               otimed_alarm = zavai.registry.sbus.get_object(
-                               "org.freesmartphone.otimed",
-                               "/org/freesmartphone/Time/Alarm",
-                               "org.freesmartphone.Time.Alarm");
-
-               rtc = zavai.registry.sbus.get_object(
-                               "org.freesmartphone.odeviced",
-                               "/org/freesmartphone/Device/RTC/0",
-                               "org.freesmartphone.Device.RealtimeClock");
-
-               zavai.registry.sbus.register_object("/org/enricozini/Zavai/Clock", dbusClock);
-       }
-
-       public void notify_alarm(string label)
-       {
-               stderr.printf("Notifying %s\n", label);
-               alarm_triggered(label);
-               schedule_changed(next_alarm());
-       }
-
-       public Alarm? next_alarm()
-       {
-               at.Event ev;
-               ev = at.earliestID("z");
-               if (ev.deadline == 0)
-                       return null;
-               string label = Alarm.getLabel(ev.id);
-               Alarm res = new Alarm();
-               res.ev = ev;
-               res.label = label;
-               return res;
-       }
-
-       public void schedule(string timespec, string label) throws Error
-       {
-               Alarm.schedule(timespec, label);
-               schedule_changed(next_alarm());
-       }
-
-       private void on_gps_time(dynamic DBus.Object pos, int t)
-       {
-               if (t == 0)
-               {
-                       last_gps_time_system_time = 0;
-                       update_time();
-               } else {
-                       last_gps_time = (time_t)t;
-                       last_gps_time_system_time = time_t();
-                       update_time();
-               }
-       }
-
-       private bool on_system_time()
-       {
-               last_system_time = time_t();
-               update_time();
-               return true;
-       }
-
-       private void update_time()
-       {
-               if (last_gps_time_system_time + 10 > last_system_time)
-               {
-                       chosen_time = last_gps_time;
-                       chosen_type = SourceType.GPS;
-               }
-               else
-               {
-                       chosen_time = last_system_time;
-                       chosen_type = SourceType.SYSTEM;
-               }
-               if (chosen_time / 60 != last_minute)
-               {
-                       last_minute = chosen_time / 60;
-                       minute_changed(chosen_time, chosen_type);
-               }
-       }
-
-       /// Request GPS resource
-       public override void start()
-       {
-               if (started) return;
-
-               system_time_timeout = Timeout.add(5000, on_system_time);
-               gps_time.TimeChanged += on_gps_time;
-               last_system_time = time_t();
-               update_time();
-
-               base.start();
-       }
-
-       public override void stop()
-       {
-               if (!started) return;
-
-               Source.remove(system_time_timeout);
-               gps_time.TimeChanged -= on_gps_time;
-
-               base.stop();
-       }
+    protected time_t last_gps_time;
+    protected time_t last_gps_time_system_time;
+    protected time_t last_system_time;
+    protected dynamic DBus.Object gps_time;
+    protected uint system_time_timeout;
+    protected time_t last_minute;
+    protected time_t chosen_time;
+    protected SourceType chosen_type;
+    protected ZavaiClock dbusClock;
+
+    protected dynamic DBus.Object otimed_alarm;
+    protected dynamic DBus.Object rtc;
+    protected SList<Alarm> alarms;
+
+    // Ticks once a minute
+    public signal void minute_changed(long time, SourceType source);
+    public signal void schedule_changed(Alarm? next);
+    public signal void alarm_triggered(string label);
+
+    public Clock()
+    {
+        Object(name: "clock");
+        alarms = null;
+        dbusClock = new ZavaiClock();
+        last_minute = 0;
+        last_gps_time = 0;
+        last_gps_time_system_time = 0;
+        last_system_time = time_t();
+        chosen_time = last_system_time;
+
+        gps_time = zavai.registry.sbus.get_object(
+                "org.freesmartphone.ogpsd",
+                "/org/freedesktop/Gypsy",
+                "org.freedesktop.Gypsy.Time");
+
+        // FSO alarm system
+        otimed_alarm = zavai.registry.sbus.get_object(
+                "org.freesmartphone.otimed",
+                "/org/freesmartphone/Time/Alarm",
+                "org.freesmartphone.Time.Alarm");
+
+        rtc = zavai.registry.sbus.get_object(
+                "org.freesmartphone.odeviced",
+                "/org/freesmartphone/Device/RTC/0",
+                "org.freesmartphone.Device.RealtimeClock");
+
+        zavai.registry.sbus.register_object("/org/enricozini/Zavai/Clock", dbusClock);
+    }
+
+    public void notify_alarm(string label)
+    {
+        stderr.printf("Notifying %s\n", label);
+        alarm_triggered(label);
+        schedule_changed(next_alarm());
+    }
+
+    public Alarm? next_alarm()
+    {
+        at.Event ev;
+        ev = at.earliestID("z");
+        if (ev.deadline == 0)
+            return null;
+        string label = Alarm.getLabel(ev.id);
+        Alarm res = new Alarm();
+        res.ev = ev;
+        res.label = label;
+        return res;
+    }
+
+    public void schedule(string timespec, string label) throws Error
+    {
+        Alarm.schedule(timespec, label);
+        schedule_changed(next_alarm());
+    }
+
+    private void on_gps_time(dynamic DBus.Object pos, int t)
+    {
+        if (t == 0)
+        {
+            last_gps_time_system_time = 0;
+            update_time();
+        } else {
+            last_gps_time = (time_t)t;
+            last_gps_time_system_time = time_t();
+            update_time();
+        }
+    }
+
+    private bool on_system_time()
+    {
+        last_system_time = time_t();
+        update_time();
+        return true;
+    }
+
+    private void update_time()
+    {
+        if (last_gps_time_system_time + 10 > last_system_time)
+        {
+            chosen_time = last_gps_time;
+            chosen_type = SourceType.GPS;
+        }
+        else
+        {
+            chosen_time = last_system_time;
+            chosen_type = SourceType.SYSTEM;
+        }
+        if (chosen_time / 60 != last_minute)
+        {
+            last_minute = chosen_time / 60;
+            minute_changed(chosen_time, chosen_type);
+        }
+    }
+
+    /// Request GPS resource
+    public override void start()
+    {
+        if (started) return;
+
+        system_time_timeout = Timeout.add(5000, on_system_time);
+        gps_time.TimeChanged += on_gps_time;
+        last_system_time = time_t();
+        update_time();
+
+        base.start();
+    }
+
+    public override void stop()
+    {
+        if (!started) return;
+
+        Source.remove(system_time_timeout);
+        gps_time.TimeChanged -= on_gps_time;
+
+        base.stop();
+    }
 }
 
 public Clock clock = null;
 
 public void init()
 {
-       clock = new Clock();
+    clock = new Clock();
 
-       zavai.registry.register_service(clock);
+    zavai.registry.register_service(clock);
 }
 
 }
index 5d55b61c28391b5aaa24eb9b863ea98e4f075830..05e2a47222f31e16426b0a394981cc7fbe562308 100644 (file)
@@ -25,93 +25,93 @@ namespace gsm {
 
 public class GSM: zavai.Service
 {
-       public dynamic DBus.Object device;
-
-       public GSM()
-       {
-               Object(name: "gsm.gsm");
-
-               device = zavai.registry.sbus.get_object(
-                       "org.freesmartphone.ogpsd", 
-                       "/org/freesmartphone/GSM/Device",
-                       "org.freesmartphone.Resource");
-       }
-
-       /// Request GPS resource
-       public override void start()
-       {
-               if (started) return;
-               try {
-                       device.Enable();
-                       zavai.log.info("Started GSM");
-                       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 {
-                       device.Disable();
-                       zavai.log.info("Stopped GSM");
-                       base.stop();
-               } catch (GLib.Error e) {
-                       zavai.log.error(e.message);
-               }
-               base.stop();
-       }
+    public dynamic DBus.Object device;
+
+    public GSM()
+    {
+        Object(name: "gsm.gsm");
+
+        device = zavai.registry.sbus.get_object(
+            "org.freesmartphone.ogpsd", 
+            "/org/freesmartphone/GSM/Device",
+            "org.freesmartphone.Resource");
+    }
+
+    /// Request GPS resource
+    public override void start()
+    {
+        if (started) return;
+        try {
+            device.Enable();
+            zavai.log.info("Started GSM");
+            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 {
+            device.Disable();
+            zavai.log.info("Stopped GSM");
+            base.stop();
+        } catch (GLib.Error e) {
+            zavai.log.error(e.message);
+        }
+        base.stop();
+    }
 }
 
 public class GPRS: zavai.Service
 {
-       public dynamic DBus.Object device;
-
-       public GPRS()
-       {
-               Object(name: "gsm.gprs");
-
-               device = zavai.registry.sbus.get_object(
-                       "org.freesmartphone.ogsmd", 
-                       "/org/freesmartphone/GSM/Device",
-                       "org.freesmartphone.GSM.PDP");
-       }
-
-       /// Request GPS resource
-       public override void start()
-       {
-               if (started) return;
-               try {
-                       //gsm.request(name);
-                       device.ActivateContext(
-                               zavai.config.gprs_apn,
-                               zavai.config.gprs_user,
-                               zavai.config.gprs_pass);
-                       zavai.log.info("Started GPRS");
-                       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 {
-                       //gsm.release(name);
-                       device.DeactivateContext();
-                       zavai.log.info("Stopped GPRS");
-                       base.stop();
-               } catch (GLib.Error e) {
-                       zavai.log.error(e.message);
-               }
-               base.stop();
-       }
+    public dynamic DBus.Object device;
+
+    public GPRS()
+    {
+        Object(name: "gsm.gprs");
+
+        device = zavai.registry.sbus.get_object(
+            "org.freesmartphone.ogsmd", 
+            "/org/freesmartphone/GSM/Device",
+            "org.freesmartphone.GSM.PDP");
+    }
+
+    /// Request GPS resource
+    public override void start()
+    {
+        if (started) return;
+        try {
+            //gsm.request(name);
+            device.ActivateContext(
+                zavai.config.gprs_apn,
+                zavai.config.gprs_user,
+                zavai.config.gprs_pass);
+            zavai.log.info("Started GPRS");
+            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 {
+            //gsm.release(name);
+            device.DeactivateContext();
+            zavai.log.info("Stopped GPRS");
+            base.stop();
+        } catch (GLib.Error e) {
+            zavai.log.error(e.message);
+        }
+        base.stop();
+    }
 }
 
 public zavai.gsm.GSM gsm = null;
@@ -119,11 +119,11 @@ public zavai.gsm.GPRS gprs = null;
 
 public void init()
 {
-       gsm = new GSM();
-       gprs = new GPRS();
+    gsm = new GSM();
+    gprs = new GPRS();
 
-       zavai.registry.register_service(gsm);
-       zavai.registry.register_service(gprs);
+    zavai.registry.register_service(gsm);
+    zavai.registry.register_service(gprs);
 }
 
 }
index 19fc0908b766abcdf4387bbc7840d96945197f2c..e551e468331e3a53c9c00430d99162222d9c6ef6 100644 (file)
@@ -23,9 +23,9 @@ namespace input {
 
 public abstract class DevInput : zavai.Service
 {
-       public string device { get; construct; }
+    public string device { get; construct; }
 
-       public signal bool event(LinuxInput.Event* ev);
+    public signal bool event(LinuxInput.Event* ev);
 
     protected IOChannel fd = null;
     protected uint fd_watch = 0;
@@ -46,20 +46,20 @@ public abstract class DevInput : zavai.Service
 
     protected bool on_input_data(IOChannel source, IOCondition condition)
     {
-               if (condition != IOCondition.IN) return true;
+        if (condition != IOCondition.IN) return true;
 
         //stderr.printf("GOT INPUT ON %s %d\n", device, source.unix_get_fd());
         char[] buf = new char[sizeof(LinuxInput.Event)];
-               size_t count_read;
-               try {
-                       source.read_chars(buf, out count_read);
-               } catch (Error e) {
-                       zavai.log.error("Reading from " + device + ": " + e.message);
-                       return true;
-               }
+        size_t count_read;
+        try {
+            source.read_chars(buf, out count_read);
+        } catch (Error e) {
+            zavai.log.error("Reading from " + device + ": " + e.message);
+            return true;
+        }
         //stderr.printf("READ %zu chars\n", count_read);
 
-               LinuxInput.Event* ie = (LinuxInput.Event*)buf;
+        LinuxInput.Event* ie = (LinuxInput.Event*)buf;
         //stderr.printf("INPUT EVENT time %lu.%lu type %hu code %hu val %d\n", (ulong)ie->time.tv_sec, ie->time.tv_usec, ie->type, ie->code, ie->val);
 
         /*
@@ -86,32 +86,32 @@ public abstract class DevInput : zavai.Service
         return event(ie);
     }
 
-       /// Start reading from the device
-       public override void start()
-       {
-               if (started) return;
+    /// Start reading from the device
+    public override void start()
+    {
+        if (started) return;
 
         if (fd != null)
             close_fd();
 
         // Open the device and listed to it using the GObject main loop
-               zavai.log.info("Opening device " + device);
+        zavai.log.info("Opening device " + device);
         fd = new IOChannel.file(device, "r");
-               try {
-                       fd.set_encoding(null);
-               } catch (Error e) {
-                       zavai.log.error("Setting encoding to null on " + device + ": " + e.message);
-               }
-               fd.set_buffered(false);
+        try {
+            fd.set_encoding(null);
+        } catch (Error e) {
+            zavai.log.error("Setting encoding to null on " + device + ": " + e.message);
+        }
+        fd.set_buffered(false);
         fd_watch = fd.add_watch(IOCondition.IN, on_input_data);
 
-               base.start();
-       }
+        base.start();
+    }
 
-       // Stop reading from the device
-       public override void stop()
-       {
-               if (!started) return;
+    // Stop reading from the device
+    public override void stop()
+    {
+        if (!started) return;
 
         if (fd != null)
         {
@@ -119,13 +119,13 @@ public abstract class DevInput : zavai.Service
             close_fd();
         }
 
-               base.stop();
-       }
+        base.stop();
+    }
 }
 
 public class PowerButton : DevInput
 {
-       public signal void power_button(Posix.timeval* time, bool pressed);
+    public signal void power_button(Posix.timeval* time, bool pressed);
 
     public PowerButton()
     {
@@ -133,22 +133,22 @@ public class PowerButton : DevInput
         // FIXME: change to event4 for the aux button and headset button
         //device = "/dev/input/event1";
         Object(
-               name: "input.power_button",
-               device: "/dev/input/event0"
-       );
+        name: "input.power_button",
+        device: "/dev/input/event0"
+    );
 
-               event += on_event;
+        event += on_event;
     }
 
-       protected bool on_event(LinuxInput.Event* ev)
-       {
-               if (ev->type == LinuxInput.Type.KEY && 
-                       ev->code == LinuxInput.Key.POWER)
-               {
-                       power_button(&(ev->time), ev->val == 0 ? false : true);
-               }
-               return true;
-       }
+    protected bool on_event(LinuxInput.Event* ev)
+    {
+        if (ev->type == LinuxInput.Type.KEY && 
+            ev->code == LinuxInput.Key.POWER)
+        {
+            power_button(&(ev->time), ev->val == 0 ? false : true);
+        }
+        return true;
+    }
 }
 
 /*
@@ -297,9 +297,9 @@ public PowerButton power_button = null;
 
 public void init()
 {
-       power_button = new PowerButton();
+    power_button = new PowerButton();
 
-       zavai.registry.register_service(power_button);
+    zavai.registry.register_service(power_button);
 }
 
 }