diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-05-03 07:25:37 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-05-03 07:25:37 +0200 |
commit | a1c05d93bbb3c1bdb0c0fed9d7110804037cfd55 (patch) | |
tree | cb97ed3768912934cfc0e817beca620200d91993 /src/actionGroups | |
parent | 5478fe2ceb86715f4ab9a51eb97c517465febfa6 (diff) |
Imported Upstream version 0.6.2upstream/0.6.2
Diffstat (limited to 'src/actionGroups')
-rw-r--r-- | src/actionGroups/devicesGroup.vala | 4 | ||||
-rw-r--r-- | src/actionGroups/groupRegistry.vala | 5 | ||||
-rw-r--r-- | src/actionGroups/menuGroup.vala | 2 | ||||
-rw-r--r-- | src/actionGroups/sessionGroup.vala | 12 | ||||
-rw-r--r-- | src/actionGroups/windowListGroup.vala | 32 | ||||
-rw-r--r-- | src/actionGroups/workspaceWindowListGroup.vala | 145 |
6 files changed, 183 insertions, 17 deletions
diff --git a/src/actionGroups/devicesGroup.vala b/src/actionGroups/devicesGroup.vala index 1078296..e18f4c0 100644 --- a/src/actionGroups/devicesGroup.vala +++ b/src/actionGroups/devicesGroup.vala @@ -33,7 +33,7 @@ public class DevicesGroup : ActionGroup { public static GroupRegistry.TypeDescription register() { var description = new GroupRegistry.TypeDescription(); description.name = _("Group: Devices"); - description.icon = "harddrive"; + description.icon = "drive-harddisk"; description.description = _("Shows a Slice for each plugged in devices, like USB-Sticks."); description.id = "devices"; return description; @@ -82,7 +82,7 @@ public class DevicesGroup : ActionGroup { private void load() { // add root device - this.add_action(new UriAction(_("Root"), "harddrive", "file:///")); + this.add_action(new UriAction(_("Root"), "drive-harddisk", "file:///")); // add all other devices foreach(var mount in this.monitor.get_mounts()) { diff --git a/src/actionGroups/groupRegistry.vala b/src/actionGroups/groupRegistry.vala index ca0dc4d..ebf34ba 100644 --- a/src/actionGroups/groupRegistry.vala +++ b/src/actionGroups/groupRegistry.vala @@ -72,6 +72,10 @@ public class GroupRegistry : GLib.Object { type_description = WindowListGroup.register(); types.add(typeof(WindowListGroup).name()); descriptions.set(typeof(WindowListGroup).name(), type_description); + + type_description = WorkspaceWindowListGroup.register(); + types.add(typeof(WorkspaceWindowListGroup).name()); + descriptions.set(typeof(WorkspaceWindowListGroup).name(), type_description); } ///////////////////////////////////////////////////////////////////// @@ -85,6 +89,7 @@ public class GroupRegistry : GLib.Object { case "menu": return new MenuGroup(parent_id); case "session": return new SessionGroup(parent_id); case "window_list": return new WindowListGroup(parent_id); + case "workspace_window_list": return new WorkspaceWindowListGroup(parent_id); } return null; diff --git a/src/actionGroups/menuGroup.vala b/src/actionGroups/menuGroup.vala index 7a1e344..ccb5407 100644 --- a/src/actionGroups/menuGroup.vala +++ b/src/actionGroups/menuGroup.vala @@ -33,7 +33,7 @@ public class MenuGroup : ActionGroup { public static GroupRegistry.TypeDescription register() { var description = new GroupRegistry.TypeDescription(); description.name = _("Group: Main menu"); - description.icon = "gnome-main-menu"; + description.icon = "start-here"; description.description = _("Displays your main menu structure."); description.id = "menu"; return description; diff --git a/src/actionGroups/sessionGroup.vala b/src/actionGroups/sessionGroup.vala index 7b989a6..42afafc 100644 --- a/src/actionGroups/sessionGroup.vala +++ b/src/actionGroups/sessionGroup.vala @@ -33,7 +33,7 @@ public class SessionGroup : ActionGroup { public static GroupRegistry.TypeDescription register() { var description = new GroupRegistry.TypeDescription(); description.name = _("Group: Session Control"); - description.icon = "gnome-logout"; + description.icon = "system-log-out"; description.description = _("Shows a Slice for Shutdown, Reboot, and Hibernate."); description.id = "session"; return description; @@ -57,14 +57,14 @@ public class SessionGroup : ActionGroup { // 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")); + this.add_action(new AppAction(_("Shutdown"), "system-shutdown", + "dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Shutdown")); - this.add_action(new AppAction(_("Logout"), "gnome-session-logout", + this.add_action(new AppAction(_("Logout"), "system-log-out", "dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1")); - this.add_action(new AppAction(_("Reboot"), "gnome-session-reboot", - "dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestReboot")); + this.add_action(new AppAction(_("Reboot"), "view-refresh", + "dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Reboot")); } // TODO: check for available interfaces --- these may work too: diff --git a/src/actionGroups/windowListGroup.vala b/src/actionGroups/windowListGroup.vala index a2dc19c..1560f5f 100644 --- a/src/actionGroups/windowListGroup.vala +++ b/src/actionGroups/windowListGroup.vala @@ -32,7 +32,7 @@ public class WindowListGroup : ActionGroup { public static GroupRegistry.TypeDescription register() { var description = new GroupRegistry.TypeDescription(); description.name = _("Group: Window List"); - description.icon = "gnome-window-manager"; + description.icon = "preferences-system-windows"; description.description = _("Shows a Slice for each of your opened Windows. Almost like Alt-Tab."); description.id = "window_list"; return description; @@ -94,21 +94,37 @@ public class WindowListGroup : ActionGroup { (bamf_app == null) ? application.get_icon_name().down() : bamf_app.get_icon(), "%lu".printf(window.get_xid()) ); - action.activated.connect(() => { + action.activated.connect((time_stamp) => { 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.get_workspace() != null) { + //select the workspace + if (win.get_workspace() != win.get_screen().get_active_workspace()) + win.get_workspace().activate(time_stamp); + + //select the viewport inside the wprkspace + if (!win.is_in_viewport(win.get_workspace()) ) { + int xp, yp, widthp, heightp, scx, scy, nx, ny, wx, wy; + win.get_geometry (out xp, out yp, out widthp, out heightp); + scx= win.get_screen().get_width(); + scy= win.get_screen().get_height(); + wx= win.get_workspace().get_viewport_x(); + wy= win.get_workspace().get_viewport_y(); + if (scx > 0 && scy > 0) { + nx= ((wx+xp) / scx) * scx; + ny= ((wy+yp) / scy) * scy; + win.get_screen().move_viewport(nx, ny); + } + } + } if (win.is_minimized()) - win.unminimize(time); + win.unminimize(time_stamp); - win.activate_transient(time); + win.activate_transient(time_stamp); }); this.add_action(action); } diff --git a/src/actionGroups/workspaceWindowListGroup.vala b/src/actionGroups/workspaceWindowListGroup.vala new file mode 100644 index 0000000..42a4863 --- /dev/null +++ b/src/actionGroups/workspaceWindowListGroup.vala @@ -0,0 +1,145 @@ +///////////////////////////////////////////////////////////////////////// +// Copyright (c) 2011-2015 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 of +/// the current workspace. +///////////////////////////////////////////////////////////////////// + +public class WorkspaceWindowListGroup : 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 GroupRegistry.TypeDescription register() { + var description = new GroupRegistry.TypeDescription(); + description.name = _("Group: Window List for current workspace"); + description.icon = "preferences-system-windows"; + description.description = _("Shows a Slice for each of your opened windows on the current workspace."); + description.id = "workspace_window_list"; + return description; + } + + ///////////////////////////////////////////////////////////////////// + /// 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 WorkspaceWindowListGroup(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.screen.active_workspace_changed.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() + && window.get_workspace() != null + && window.get_workspace() == this.screen.get_active_workspace()) { + + 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((time_stamp) => { + Wnck.Screen.get_default().force_update(); + + var xid = (X.Window)uint64.parse(action.real_command); + var win = Wnck.Window.get(xid); + + if (win.is_minimized()) + win.unminimize(time_stamp); + + win.activate_transient(time_stamp); + }); + 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; + } + } +} + +} |