Added the close current app button
authorEnrico Zini <enrico@enricozini.org>
Mon, 27 Jul 2009 17:54:11 +0000 (19:54 +0200)
committerEnrico Zini <enrico@enricozini.org>
Mon, 27 Jul 2009 17:54:11 +0000 (19:54 +0200)
icons/quit.xcf [new file with mode: 0644]
icons/quit_off.png [new file with mode: 0644]
icons/quit_on.png [new file with mode: 0644]
src/app_wm.vala

diff --git a/icons/quit.xcf b/icons/quit.xcf
new file mode 100644 (file)
index 0000000..c08be9e
Binary files /dev/null and b/icons/quit.xcf differ
diff --git a/icons/quit_off.png b/icons/quit_off.png
new file mode 100644 (file)
index 0000000..4d79a8c
Binary files /dev/null and b/icons/quit_off.png differ
diff --git a/icons/quit_on.png b/icons/quit_on.png
new file mode 100644 (file)
index 0000000..c20e4b9
Binary files /dev/null and b/icons/quit_on.png differ
index 630b25879fa9d8a309c71e8744a4530e9a08373d..4a559178a4a4bf9c82415b92e353d9adabba835c 100644 (file)
@@ -81,12 +81,56 @@ 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);
+       }
+}
+
 RaiseIcon raise_icon;
+CloseOrBack close_or_back;
 
 public void init()
 {
        raise_icon = new RaiseIcon();
        raise_icon.set_visible(true);
+
+       close_or_back = new CloseOrBack();
+       close_or_back.set_visible(true);
 }
 
 }