2
* Show/hide desktop applet written in Vala.
4
* Copyright (C) 2009 Mark Lee <avant-wn@lazymalevolence.com>
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
* Author : Mark Lee <avant-wn@lazymalevolence.com>
25
class ShowDesktop : AppletSimple
27
private const string[] authors = {
28
"Mark Lee <avant-wn@lazymalevolence.com>"
30
private Gtk.Menu _menu;
32
public ShowDesktop (string canonical_name, string uid, int panel_id)
34
unowned Wnck.Screen screen;
36
GLib.Object (canonical_name: canonical_name,
40
this.display_name = Gettext._ ("Show Desktop");
41
this.clicked.connect (this.on_clicked);
42
this.context_menu_popup.connect (this.on_context_menu_popup);
44
screen = Wnck.Screen.get_default ();
45
screen.showing_desktop_changed.connect (this.on_show_desktop_changed);
46
this.on_show_desktop_changed (screen);
48
this.map_event.connect (this.on_map_event);
52
on_map_event (Gdk.Event event)
54
Awn.Tooltip tooltip = (this.get_icon () as Awn.Icon).get_tooltip ();
55
tooltip.toggle_on_click = false;
62
unowned Wnck.Screen screen;
64
screen = Wnck.Screen.get_default ();
65
screen.toggle_showing_desktop (!screen.get_showing_desktop ());
69
on_context_menu_popup (Gdk.EventButton event)
71
if (this._menu == null)
73
Gtk.Widget about_item;
75
this._menu = this.create_default_menu () as Gtk.Menu;
76
about_item = this.create_about_item ("Copyright © 2009 Mark Lee",
77
AppletLicense.GPLV2, Build.VERSION,
78
Gettext._ ("Hides your windows and shows your desktop."),
79
null, null, "user-desktop",
80
null, authors, null, null);
82
this._menu.append (about_item as Gtk.MenuItem);
84
this._menu.set_screen (null);
85
this.get_icon ().popup_gtk_menu (this._menu, event.button, event.time);
89
on_show_desktop_changed (Wnck.Screen screen)
91
if (screen.get_showing_desktop ())
93
this.set_tooltip_text (Gettext._ ("Show hidden windows"));
94
this.set_icon_name ("view-restore");
98
this.set_tooltip_text (Gettext._ ("Hide windows and show desktop"));
99
this.set_icon_name ("user-desktop");
105
awn_applet_factory_initp (string canonical_name, string uid, int panel_id)
107
Intl.setlocale (LocaleCategory.ALL, "");
108
Gettext.bindtextdomain (Build.GETTEXT_PACKAGE, Build.LOCALEDIR);
109
Gettext.textdomain (Build.GETTEXT_PACKAGE);
110
return new ShowDesktop (canonical_name, uid, panel_id);
113
// vim:ft=vala:et:ts=2 sts=2 sw=2:ai:cindent