diff options
author | Alessandro Ghedini <al3xbio@gmail.com> | 2011-11-20 15:50:38 +0100 |
---|---|---|
committer | Alessandro Ghedini <al3xbio@gmail.com> | 2011-11-20 15:51:50 +0100 |
commit | 3997b71e281a5f43cc8c1892e85de30728df7b2d (patch) | |
tree | 96f2be7c48af03b7c540eba9dd6680eb270f23b8 /src/actionGroups | |
parent | 902829c62f552f35517783570025b479745de3c5 (diff) |
Imported Upstream version 0.3.1
Diffstat (limited to 'src/actionGroups')
-rw-r--r-- | src/actionGroups/bookmarkGroup.vala | 2 | ||||
-rw-r--r-- | src/actionGroups/clipboardGroup.vala | 1 | ||||
-rw-r--r-- | src/actionGroups/groupRegistry.vala | 7 | ||||
-rw-r--r-- | src/actionGroups/sessionGroup.vala | 9 | ||||
-rw-r--r-- | src/actionGroups/windowListGroup.vala | 142 |
5 files changed, 157 insertions, 4 deletions
diff --git a/src/actionGroups/bookmarkGroup.vala b/src/actionGroups/bookmarkGroup.vala index f4ba66e..389b14a 100644 --- a/src/actionGroups/bookmarkGroup.vala +++ b/src/actionGroups/bookmarkGroup.vala @@ -110,7 +110,7 @@ public class BookmarkGroup : ActionGroup { } // add trash - this.add_action(ActionRegistry.new_for_uri("trash:///")); + this.add_action(ActionRegistry.new_for_uri("trash://")); // add desktop this.add_action(ActionRegistry.new_for_uri("file://" + GLib.Environment.get_user_special_dir(GLib.UserDirectory.DESKTOP))); diff --git a/src/actionGroups/clipboardGroup.vala b/src/actionGroups/clipboardGroup.vala index 0e95b65..cd1da36 100644 --- a/src/actionGroups/clipboardGroup.vala +++ b/src/actionGroups/clipboardGroup.vala @@ -19,6 +19,7 @@ namespace GnomePie { ///////////////////////////////////////////////////////////////////////// /// This Group keeps a history of the last used Clipboard entries. +/// Experimental. Not enabled. ///////////////////////////////////////////////////////////////////////// public class ClipboardGroup : ActionGroup { diff --git a/src/actionGroups/groupRegistry.vala b/src/actionGroups/groupRegistry.vala index 94169d5..a9f8d06 100644 --- a/src/actionGroups/groupRegistry.vala +++ b/src/actionGroups/groupRegistry.vala @@ -38,7 +38,6 @@ public class GroupRegistry : GLib.Object { public static Gee.HashMap<Type, string> icons { get; private set; } public static Gee.HashMap<Type, string> settings_names { get; private set; } - ///////////////////////////////////////////////////////////////////// /// Registers all ActionGroup types. ///////////////////////////////////////////////////////////////////// @@ -78,6 +77,12 @@ public class GroupRegistry : GLib.Object { icons.set(typeof(SessionGroup), icon); settings_names.set(typeof(SessionGroup), settings_name); + WindowListGroup.register(out name, out icon, out settings_name); + types.add(typeof(WindowListGroup)); + names.set(typeof(WindowListGroup), name); + icons.set(typeof(WindowListGroup), icon); + settings_names.set(typeof(WindowListGroup), settings_name); + // ClipboardGroup.register(out name, out icon, out settings_name); // types.add(typeof(ClipboardGroup)); // names.set(typeof(ClipboardGroup), name); diff --git a/src/actionGroups/sessionGroup.vala b/src/actionGroups/sessionGroup.vala index 9fcab1d..0b3f249 100644 --- a/src/actionGroups/sessionGroup.vala +++ b/src/actionGroups/sessionGroup.vala @@ -49,6 +49,11 @@ public class SessionGroup : ActionGroup { ///////////////////////////////////////////////////////////////////// construct { +// string iface = GLib.Bus.get_proxy_sync(GLib.BusType.SESSION, "org.gnome.SessionManager", "/org/gnome/SessionManager"); +// iface = GLib.Bus.get_proxy_sync(GLib.BusType.SESSION, "org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer"); +// iface = GLib.Bus.get_proxy_sync(GLib.BusType.SESSION, "org.kde.ksmserver", "/KSMServer"); +// iface = GLib.Bus.get_proxy_sync(GLib.BusType.SESSION, "org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager"); + this.add_action(new AppAction(_("Shutdown"), "gnome-shutdown", "dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestShutdown")); @@ -60,9 +65,9 @@ public class SessionGroup : ActionGroup { } // TODO: check for available interfaces --- these may work too: - // dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown + // dbus-send --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown // dbus-send --print-reply --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 2 2 - // dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop + // dbus-send --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop } } diff --git a/src/actionGroups/windowListGroup.vala b/src/actionGroups/windowListGroup.vala new file mode 100644 index 0000000..b12f188 --- /dev/null +++ b/src/actionGroups/windowListGroup.vala @@ -0,0 +1,142 @@ +/* +Copyright (c) 2011 by Simon Schneegans + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +namespace GnomePie { + +///////////////////////////////////////////////////////////////////// +/// This group displays a list of all running application windows. +///////////////////////////////////////////////////////////////////// + +public class WindowListGroup : ActionGroup { + + ///////////////////////////////////////////////////////////////////// + /// Used to register this type of ActionGroup. It sets the display + /// name for this ActionGroup, it's icon name and the string used in + /// the pies.conf file for this kind of ActionGroups. + ///////////////////////////////////////////////////////////////////// + + public static void register(out string name, out string icon, out string settings_name) { + name = _("Window List"); + icon = "window-manager"; + settings_name = "window_list"; + } + + ///////////////////////////////////////////////////////////////////// + /// Two members needed to avoid useless, frequent changes of the + /// stored Actions. + ///////////////////////////////////////////////////////////////////// + + private bool changing = false; + private bool changed_again = false; + + private Wnck.Screen screen; + + ///////////////////////////////////////////////////////////////////// + /// C'tor, initializes all members. + ///////////////////////////////////////////////////////////////////// + + public WindowListGroup(string parent_id) { + GLib.Object(parent_id : parent_id); + } + + ///////////////////////////////////////////////////////////////////// + /// Loads all windows. + ///////////////////////////////////////////////////////////////////// + + construct { + this.screen = Wnck.Screen.get_default(); + + this.screen.window_opened.connect(reload); + this.screen.window_closed.connect(reload); + + this.load(); + } + + ///////////////////////////////////////////////////////////////////// + /// Loads all currently opened windows and creates actions for them. + ///////////////////////////////////////////////////////////////////// + + private void load() { + unowned GLib.List<Wnck.Window?> windows = this.screen.get_windows(); + + var matcher = Bamf.Matcher.get_default(); + + foreach (var window in windows) { + if (window.get_window_type() == Wnck.WindowType.NORMAL + && !window.is_skip_pager() && !window.is_skip_tasklist()) { + var application = window.get_application(); + var bamf_app = matcher.get_application_for_xid((uint32)window.get_xid()); + + string name = window.get_name(); + + if (name.length > 30) + name = name.substring(0, 30) + "..."; + + var action = new SigAction( + name, + (bamf_app == null) ? application.get_icon_name().down() : bamf_app.get_icon(), + "%lu".printf(window.get_xid()) + ); + action.activated.connect(() => { + Wnck.Screen.get_default().force_update(); + + var xid = (X.Window)uint64.parse(action.real_command); + var win = Wnck.Window.get(xid); + var time = Gtk.get_current_event_time(); + + if (win.get_workspace() != null + && win.get_workspace() != win.get_screen().get_active_workspace()) + win.get_workspace().activate(time); + + if (win.is_minimized()) + win.unminimize(time); + + win.activate_transient(time); + }); + this.add_action(action); + } + } + } + + ///////////////////////////////////////////////////////////////////// + /// Reloads all running applications. + ///////////////////////////////////////////////////////////////////// + + private void reload() { + // avoid too frequent changes... + if (!this.changing) { + this.changing = true; + Timeout.add(500, () => { + if (this.changed_again) { + this.changed_again = false; + return true; + } + + // reload + this.delete_all(); + this.load(); + + this.changing = false; + return false; + }); + } else { + this.changed_again = true; + } + } +} + +} |