2 * app_wm - zavai window management functions
4 * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 static void print_window_state(Gtk.Window w)
30 Gdk.WindowState state = w.window.get_state();
31 int istate = (int) state;
32 bool is_icon = (state & Gdk.WindowState.ICONIFIED) != 0;
33 bool is_visible = w.visible;
34 bool is_focus = w.is_focus;
35 bool has_focus = ((Gtk.Widget)w).has_focus;
36 bool is_active = w.is_active;
37 bool is_toplevel = w.is_toplevel();
38 bool is_tfocus = w.has_toplevel_focus;
40 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",
42 is_icon ? "true" : "false",
43 is_visible ? "true" : "false",
44 is_focus ? "true" : "false",
45 has_focus ? "true" : "false",
46 is_active ? "true" : "false",
47 is_toplevel ? "true" : "false",
48 is_tfocus ? "true" : "false"
53 public class RaiseIcon : Gtk.StatusIcon
57 activate += on_activate;
58 zavai.app.visibility_changed += on_visibility_changed;
62 private void on_visibility_changed(bool visible)
67 private void on_activate()
69 zavai.app.toggle_visibility();
73 protected void update_icon()
75 string name = zavai.config.icondir + "/";
76 if (!zavai.app.visibility)
77 name += "zavai_on.png";
79 name += "zavai_off.png";
84 public class CloseOrBack : Gtk.StatusIcon
88 activate += on_activate;
89 zavai.app.visibility_changed += on_visibility_changed;
93 private void on_visibility_changed(bool visible)
98 private void on_activate()
100 if (zavai.app.visibility)
105 Gdk.Window w = zavai.app.get_screen().get_active_window();
106 if (w != zavai.app.window)
113 protected void update_icon()
115 string name = zavai.config.icondir + "/";
116 if (!zavai.app.visibility)
117 name += "quit_on.png";
119 name += "quit_off.png";
124 RaiseIcon raise_icon;
125 CloseOrBack close_or_back;
129 raise_icon = new RaiseIcon();
130 raise_icon.set_visible(true);
132 close_or_back = new CloseOrBack();
133 close_or_back.set_visible(true);