Button to toggle visibility
authorEnrico Zini <enrico@enricozini.org>
Mon, 27 Jul 2009 17:17:01 +0000 (19:17 +0200)
committerEnrico Zini <enrico@enricozini.org>
Mon, 27 Jul 2009 17:17:01 +0000 (19:17 +0200)
src/Makefile.am
src/app.vala
src/zavai.vala

index 8e165361ac13f7935df9fef67404cb463c49b3a7..defbcbd1fcd2307947b0013ef3dcaf268dfb7dc4 100644 (file)
@@ -31,6 +31,7 @@ zavai_VALASOURCES = \
        gps.vala \
        app.vala \
        app_keyboard.vala \
        gps.vala \
        app.vala \
        app_keyboard.vala \
+       app_wm.vala \
        app_gps.vala \
        app_debug.vala \
        zavai.vala
        app_gps.vala \
        app_debug.vala \
        zavai.vala
index 05e81667bcfa250b6a7ee5da9e33d30a017712ea..2b2c8d79e1e426e5ba43e7989f71563f59f05c39 100644 (file)
@@ -24,6 +24,9 @@ namespace zavai {
 
 public class Zavai : Gtk.Window, zavai.Resource
 {
 
 public class Zavai : Gtk.Window, zavai.Resource
 {
+       public bool visibility = true;
+       public signal void visibility_changed(bool visible);
+
        zavai.Applet current;
        string current_name;
 
        zavai.Applet current;
        string current_name;
 
@@ -33,6 +36,29 @@ public class Zavai : Gtk.Window, zavai.Resource
                current = null;
                current_name = null;
                destroy += Gtk.main_quit;
                current = null;
                current_name = null;
                destroy += Gtk.main_quit;
+               set_events(get_events() | Gdk.EventMask.VISIBILITY_NOTIFY_MASK);
+               visibility_notify_event += on_visibility;
+       }
+
+       private bool on_visibility(Gdk.Event event)
+       {
+               visibility = (event.visibility.state == Gdk.VisibilityState.UNOBSCURED);
+               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();
+               }
        }
 
        public void show_applet(string name)
        }
 
        public void show_applet(string name)
index 69585b9f6c401fd3b2882f5a6b6ee4d1d5af4c6b..3a92d78c1958e6ca92d12b6eb05eed0c7bae40bd 100644 (file)
@@ -57,6 +57,7 @@ static int main (string[] args) {
        // TODO: register the rest of menus here
        zavai.ui.gps.init();
        zavai.ui.kbd.init();
        // TODO: register the rest of menus here
        zavai.ui.gps.init();
        zavai.ui.kbd.init();
+       zavai.ui.wm.init();
        zavai.ui.debug.init();
 
        zavai.app.show_applet("menu.main");
        zavai.ui.debug.init();
 
        zavai.app.show_applet("menu.main");