Added GPS tray icon
authorEnrico Zini <enrico@enricozini.org>
Wed, 22 Jul 2009 15:45:38 +0000 (17:45 +0200)
committerEnrico Zini <enrico@enricozini.org>
Wed, 22 Jul 2009 15:45:38 +0000 (17:45 +0200)
vala/app_gps.vala
vala/config.vala
vala/gps.vala
vala/gps_fix_off.png [new file with mode: 0644]
vala/gps_fix_on.png [new file with mode: 0644]
vala/gps_nofix_off.png [new file with mode: 0644]
vala/gps_nofix_on.png [new file with mode: 0644]

index edc2526913e9dc1517a2b91bbc151579d060ece3..bb22edfb979af6e2c407347e583c69d64f545259 100644 (file)
@@ -147,6 +147,53 @@ class GPXAudioTracer(gtk.ToggleAction):
             self.recorder.stop()
 */
 
             self.recorder.stop()
 */
 
+public class GPSTrayIcon : Gtk.StatusIcon
+{
+    bool requested = false;
+    int fix_status = 0;
+
+    public string icon_fname()
+    {
+        if (fix_status == 2 || fix_status == 3)
+            return zavai.config.icondir + "/" + (requested ? "gps_fix_on.png" : "gps_fix_off.png");
+        else
+            return zavai.config.icondir + "/" + (requested ? "gps_nofix_on.png" : "gps_nofix_off.png");
+    }
+
+    public GPSTrayIcon()
+    {
+        //tooltip = "GPS status";
+stderr.printf("ZAZAZA\n");
+        try {
+            fix_status = zavai.gps.gps.device.GetFixStatus();
+        } catch (Error e) {
+stderr.printf("MRDMRDMRD\n");
+        }
+stderr.printf("NAME %s\n", icon_fname());
+        set_from_file(icon_fname());
+        activate += on_activate;
+        zavai.gps.gps.device.FixStatusChanged += on_fix_status_changed;
+    }
+
+    void on_fix_status_changed(dynamic DBus.Object pos, int fix_status)
+    {
+        this.fix_status = fix_status;
+        set_from_file(icon_fname());
+    }
+
+    void on_activate()
+    {
+        if (!requested)
+            zavai.gps.gps.request("gpstrayicon");
+        else
+            zavai.gps.gps.release("gpstrayicon");
+        requested = !requested;
+        set_from_file(icon_fname());
+    }
+}
+
+public GPSTrayIcon tray_icon = null;
+
 public void init()
 {
     /*
 public void init()
 {
     /*
@@ -176,6 +223,10 @@ public void init()
 
     zavai.registry.register_menu("menu.gps", menu_gps);
     zavai.registry.getmenu("menu.main").add_applet("menu.gps");
 
     zavai.registry.register_menu("menu.gps", menu_gps);
     zavai.registry.getmenu("menu.main").add_applet("menu.gps");
+
+    // GPS status icon
+    tray_icon = new GPSTrayIcon();
+    tray_icon.set_visible(true);
 }
 
 }
 }
 
 }
index 235b8a5f891f9028c4f6b447ee130f1ae3e3b68a..53923e3c13944bbdf2e3855713582ad81f00cc09 100644 (file)
@@ -24,6 +24,7 @@ public class Config
 {
     public string version { get; set; }
     public string homedir { get; set; }
 {
     public string version { get; set; }
     public string homedir { get; set; }
+    public string icondir { get; set; }
     public int min_button_height { get; set; }
 
     public Config()
     public int min_button_height { get; set; }
 
     public Config()
@@ -31,6 +32,7 @@ public class Config
         // Set defaults
         version = "0.1";
         homedir = "/root/.zavai";
         // Set defaults
         version = "0.1";
         homedir = "/root/.zavai";
+        icondir = ".";
         min_button_height = 80;
     }
 
         min_button_height = 80;
     }
 
index e85d40e8d2506c0f3ad3b2fb6dc605baa3822cb8..a405a545045cc6339fd137d02d3260ecad20c758 100644 (file)
@@ -26,7 +26,8 @@ namespace gps {
 // For a list of dbus services, look in /etc/dbus-1/system.d/
 public class GPS: zavai.Service
 {
 // For a list of dbus services, look in /etc/dbus-1/system.d/
 public class GPS: zavai.Service
 {
-       dynamic DBus.Object usage;
+       public dynamic DBus.Object usage;
+       public dynamic DBus.Object device;
 
        public GPS()
        {
 
        public GPS()
        {
@@ -38,6 +39,11 @@ public class GPS: zavai.Service
                        "/org/freesmartphone/Usage",
                        "org.freesmartphone.Usage");
 
                        "/org/freesmartphone/Usage",
                        "org.freesmartphone.Usage");
 
+               device = zavai.registry.sbus.get_object(
+                       "org.freesmartphone.ogpsd", 
+                       "/org/freedesktop/Gypsy",
+                       "org.freedesktop.Gypsy.Device");
+
 //         # see mdbus -s org.freesmartphone.ogpsd /org/freedesktop/Gypsy
 //         gps = self.bus.get_object('org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy') 
 //         self.gps = dbus.Interface(gps, "org.freedesktop.Gypsy.Device")
 //         # see mdbus -s org.freesmartphone.ogpsd /org/freedesktop/Gypsy
 //         gps = self.bus.get_object('org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy') 
 //         self.gps = dbus.Interface(gps, "org.freedesktop.Gypsy.Device")
diff --git a/vala/gps_fix_off.png b/vala/gps_fix_off.png
new file mode 100644 (file)
index 0000000..8ba91fc
Binary files /dev/null and b/vala/gps_fix_off.png differ
diff --git a/vala/gps_fix_on.png b/vala/gps_fix_on.png
new file mode 100644 (file)
index 0000000..70f9c9d
Binary files /dev/null and b/vala/gps_fix_on.png differ
diff --git a/vala/gps_nofix_off.png b/vala/gps_nofix_off.png
new file mode 100644 (file)
index 0000000..609747f
Binary files /dev/null and b/vala/gps_nofix_off.png differ
diff --git a/vala/gps_nofix_on.png b/vala/gps_nofix_on.png
new file mode 100644 (file)
index 0000000..30d3584
Binary files /dev/null and b/vala/gps_nofix_on.png differ