Set zavai to not appear in pagers and taskbars
[gregoa/zavai.git] / src / app_wm.vala
index 630b25879fa9d8a309c71e8744a4530e9a08373d..2100b0d32bb92a41d78044a6906fbadbf134e399 100644 (file)
@@ -81,12 +81,74 @@ public class RaiseIcon : Gtk.StatusIcon
        }
 }
 
+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
+               } 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
+{
+       Wnck.Tasklist selector;
+
+       public WindowList(string label)
+       {
+               _label = label;
+               selector = new Wnck.Tasklist(Wnck.Screen.get_default());
+               pack_start(selector, true, true, 0);
+       }
+}
+
+
 RaiseIcon raise_icon;
+CloseOrBack close_or_back;
+WindowList window_list;
 
 public void init()
 {
        raise_icon = new RaiseIcon();
        raise_icon.set_visible(true);
+
+       close_or_back = new CloseOrBack();
+       close_or_back.set_visible(true);
+
+       window_list = new WindowList("Current apps");
+       zavai.registry.register_applet("wm.list", window_list);
+       zavai.registry.getmenu("menu.main").add_applet("wm.list");
 }
 
 }