summaryrefslogtreecommitdiff
path: root/src/actionGroups
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2011-11-20 15:50:38 +0100
committerAlessandro Ghedini <al3xbio@gmail.com>2011-11-20 15:50:38 +0100
commitd6b2677825cbb423e2099563c16321c3e23d7899 (patch)
treefd04dbf76a9bc0fdd3f7755e65d1c175ac5c99dd /src/actionGroups
parent6451a495637c6e3047a5a56573cffc6e3de9a515 (diff)
Imported Upstream version 0.3.1upstream/0.3.1
Diffstat (limited to 'src/actionGroups')
-rw-r--r--src/actionGroups/bookmarkGroup.vala2
-rw-r--r--src/actionGroups/clipboardGroup.vala1
-rw-r--r--src/actionGroups/groupRegistry.vala7
-rw-r--r--src/actionGroups/sessionGroup.vala9
-rw-r--r--src/actionGroups/windowListGroup.vala142
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;
+ }
+ }
+}
+
+}