summaryrefslogtreecommitdiff
path: root/src/actionGroups
diff options
context:
space:
mode:
Diffstat (limited to 'src/actionGroups')
-rw-r--r--src/actionGroups/actionGroup.vala68
-rw-r--r--src/actionGroups/bookmarkGroup.vala80
-rw-r--r--src/actionGroups/clipboardGroup.vala80
-rw-r--r--src/actionGroups/devicesGroup.vala72
-rw-r--r--src/actionGroups/groupRegistry.vala68
-rw-r--r--src/actionGroups/menuGroup.vala148
-rw-r--r--src/actionGroups/sessionGroup.vala70
-rw-r--r--src/actionGroups/windowListGroup.vala100
8 files changed, 343 insertions, 343 deletions
diff --git a/src/actionGroups/actionGroup.vala b/src/actionGroups/actionGroup.vala
index c54be2f..8bbcde4 100644
--- a/src/actionGroups/actionGroup.vala
+++ b/src/actionGroups/actionGroup.vala
@@ -1,23 +1,23 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
// A base class storing a set of Actions. Derived classes may define
// how these Actions are created. This base class serves for custom
// actions, defined by the user.
@@ -28,67 +28,67 @@ public class ActionGroup : GLib.Object {
/////////////////////////////////////////////////////////////////////
/// A list of all stored actions.
/////////////////////////////////////////////////////////////////////
-
+
public Gee.ArrayList<Action?> actions { get; private set; }
-
+
/////////////////////////////////////////////////////////////////////
/// The ID of the pie to which this group is attached.
/////////////////////////////////////////////////////////////////////
-
+
public string parent_id { get; construct set; }
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members.
/////////////////////////////////////////////////////////////////////
-
+
public ActionGroup(string parent_id) {
GLib.Object(parent_id : parent_id);
}
-
+
construct {
this.actions = new Gee.ArrayList<Action?>();
}
-
+
/////////////////////////////////////////////////////////////////////
/// This one is called, when the ActionGroup is deleted.
/////////////////////////////////////////////////////////////////////
-
+
public virtual void on_remove() {}
-
+
/////////////////////////////////////////////////////////////////////
/// Adds a new Action to the group.
/////////////////////////////////////////////////////////////////////
-
+
public void add_action(Action new_action) {
this.actions.add(new_action);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Removes all Actions from the group.
/////////////////////////////////////////////////////////////////////
-
+
public void delete_all() {
actions.clear();
}
-
+
/////////////////////////////////////////////////////////////////////
/// Makes all contained Slices no Quick Actions.
/////////////////////////////////////////////////////////////////////
-
+
public void disable_quickactions() {
foreach (var action in actions)
action.is_quickaction = false;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Returns true, if one o the contained Slices is a Quick Action
/////////////////////////////////////////////////////////////////////
-
+
public bool has_quickaction() {
foreach (var action in actions)
if (action.is_quickaction)
return true;
-
+
return false;
}
}
diff --git a/src/actionGroups/bookmarkGroup.vala b/src/actionGroups/bookmarkGroup.vala
index 0a560c5..791d609 100644
--- a/src/actionGroups/bookmarkGroup.vala
+++ b/src/actionGroups/bookmarkGroup.vala
@@ -1,36 +1,36 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// A group of Actions, which represent the users gtk-bookmarks, his home
-/// directory, desktop and trash. It stay up-to-date, even if the
+/// directory, desktop and trash. It stay up-to-date, even if the
/// bookmarks change.
/////////////////////////////////////////////////////////////////////////
public class BookmarkGroup : 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
+ /// 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: Bookmarks");
@@ -41,34 +41,34 @@ public class BookmarkGroup : ActionGroup {
}
/////////////////////////////////////////////////////////////////////
- /// Two members needed to avoid useless, frequent changes of the
+ /// Two members needed to avoid useless, frequent changes of the
/// stored Actions.
/////////////////////////////////////////////////////////////////////
private bool changing = false;
private bool changed_again = false;
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members.
/////////////////////////////////////////////////////////////////////
-
+
public BookmarkGroup(string parent_id) {
GLib.Object(parent_id : parent_id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Construct block loads the bookmarks of the user and adds a file
/// monitor in order to update the BookmarkGroup when the bookmarks
/// of the user change.
/////////////////////////////////////////////////////////////////////
-
+
construct {
this.load();
-
+
// add monitor
var bookmark_file = GLib.File.new_for_path(
GLib.Environment.get_home_dir()).get_child(".gtk-bookmarks");
-
+
if (bookmark_file.query_exists()) {
try {
var monitor = bookmark_file.monitor(GLib.FileMonitorFlags.NONE);
@@ -78,31 +78,31 @@ public class BookmarkGroup : ActionGroup {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Adds Actions for each gtk-bookmark of the user and for his home
/// folder, desktop and trash.
/////////////////////////////////////////////////////////////////////
-
+
private void load() {
// add home folder
this.add_action(ActionRegistry.new_for_uri("file://" + GLib.Environment.get_home_dir()));
-
+
// add .gtk-bookmarks
var bookmark_file = GLib.File.new_for_path(
GLib.Environment.get_home_dir()).get_child(".gtk-bookmarks");
-
+
if (!bookmark_file.query_exists()) {
warning("Failed to find file \".gtk-bookmarks\"!");
return;
}
-
+
try {
var dis = new DataInputStream(bookmark_file.read());
string line;
while ((line = dis.read_line(null)) != null) {
var parts = line.split(" ");
-
+
string uri = parts[0];
string name = parts[1];
@@ -111,19 +111,19 @@ public class BookmarkGroup : ActionGroup {
} catch (Error e) {
error ("%s", e.message);
}
-
+
// add 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)));
}
-
+
/////////////////////////////////////////////////////////////////////
/// Reloads all Bookmarks. Is called when the user's gtk-bookmarks
/// file changes.
/////////////////////////////////////////////////////////////////////
-
+
private void reload() {
// avoid too frequent changes...
if (!this.changing) {
@@ -138,13 +138,13 @@ public class BookmarkGroup : ActionGroup {
message("Bookmarks changed...");
this.delete_all();
this.load();
-
+
this.changing = false;
return false;
});
} else {
this.changed_again = true;
- }
+ }
}
}
diff --git a/src/actionGroups/clipboardGroup.vala b/src/actionGroups/clipboardGroup.vala
index c104d62..ad18740 100644
--- a/src/actionGroups/clipboardGroup.vala
+++ b/src/actionGroups/clipboardGroup.vala
@@ -1,23 +1,23 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 keeps a history of the last used Clipboard entries.
/// Experimental. Not enabled.
/////////////////////////////////////////////////////////////////////////
@@ -25,40 +25,40 @@ namespace GnomePie {
public class ClipboardGroup : ActionGroup {
/////////////////////////////////////////////////////////////////////
- ///
+ ///
/////////////////////////////////////////////////////////////////////
private class ClipboardItem : GLib.Object {
-
+
public string name { get; private set; }
public string icon { get; private set; }
-
+
private Gtk.SelectionData contents;
-
+
public ClipboardItem(Gtk.SelectionData contents) {
this.contents = contents.copy();
this.name = this.contents.get_text() ?? "";
this.icon = "edit-paste";
}
-
+
public void paste() {
debug(name);
}
}
-
+
public ClipboardGroup(string parent_id) {
GLib.Object(parent_id : parent_id);
}
-
+
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
-
+
/////////////////////////////////////////////////////////////////////
/// Used to register this type of ActionGroup. It sets the display
- /// name for this ActionGroup, it's icon name and the string used in
+ /// 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: Clipboard");
@@ -67,45 +67,45 @@ public class ClipboardGroup : ActionGroup {
description.id = "clipboard";
return description;
}
-
+
/////////////////////////////////////////////////////////////////////
/// The clipboard to be monitored.
/////////////////////////////////////////////////////////////////////
-
+
private Gtk.Clipboard clipboard;
-
-
+
+
/////////////////////////////////////////////////////////////////////
/// The maximum remembered items of the clipboard.
/////////////////////////////////////////////////////////////////////
-
+
private static const int max_items = 6;
-
+
private Gee.ArrayList<ClipboardItem?> items;
-
+
construct {
this.items = new Gee.ArrayList<ClipboardItem?>();
this.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD);
this.clipboard.owner_change.connect(this.on_change);
}
-
+
private void on_change() {
if (this.clipboard.wait_is_text_available()) {
this.clipboard.request_contents(Gdk.Atom.intern("text/plain", false), this.add_item);
}
}
-
+
private void add_item(Gtk.Clipboard c, Gtk.SelectionData contents) {
var new_item = new ClipboardItem(contents);
-
+
if (this.items.size == ClipboardGroup.max_items)
this.items.remove_at(0);
-
+
this.items.add(new_item);
-
+
// update slices
this.delete_all();
-
+
for (int i=0; i<this.items.size; ++i) {
var action = new SigAction(items[i].name, items[i].icon, i.to_string());
action.activated.connect(() => {
diff --git a/src/actionGroups/devicesGroup.vala b/src/actionGroups/devicesGroup.vala
index d3892fe..1078296 100644
--- a/src/actionGroups/devicesGroup.vala
+++ b/src/actionGroups/devicesGroup.vala
@@ -1,35 +1,35 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 {
/////////////////////////////////////////////////////////////////////
-/// An ActionGroup which contains all currently plugged-in devices,
+/// An ActionGroup which contains all currently plugged-in devices,
/// such as CD-ROM's or USB-sticks.
/////////////////////////////////////////////////////////////////////
public class DevicesGroup : 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
+ /// 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: Devices");
@@ -40,63 +40,63 @@ public class DevicesGroup : ActionGroup {
}
/////////////////////////////////////////////////////////////////////
- /// Two members needed to avoid useless, frequent changes of the
+ /// Two members needed to avoid useless, frequent changes of the
/// stored Actions.
/////////////////////////////////////////////////////////////////////
private bool changing = false;
private bool changed_again = false;
-
+
/////////////////////////////////////////////////////////////////////
/// The VolumeMonitor used to check for added or removed devices.
/////////////////////////////////////////////////////////////////////
-
+
private GLib.VolumeMonitor monitor;
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members.
/////////////////////////////////////////////////////////////////////
-
+
public DevicesGroup(string parent_id) {
GLib.Object(parent_id : parent_id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Construct block loads all currently plugged-in devices and
/// connects signal handlers to the VolumeMonitor.
/////////////////////////////////////////////////////////////////////
-
+
construct {
this.monitor = GLib.VolumeMonitor.get();
-
+
this.load();
// add monitor
this.monitor.mount_added.connect(this.reload);
this.monitor.mount_removed.connect(this.reload);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Loads all currently plugged-in devices.
/////////////////////////////////////////////////////////////////////
-
+
private void load() {
// add root device
this.add_action(new UriAction(_("Root"), "harddrive", "file:///"));
-
+
// add all other devices
foreach(var mount in this.monitor.get_mounts()) {
// get icon
var icon = mount.get_icon();
-
+
this.add_action(new UriAction(mount.get_name(), Icon.get_icon_name(icon), mount.get_root().get_uri()));
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Reloads all devices. Is called when the VolumeMonitor changes.
/////////////////////////////////////////////////////////////////////
-
+
private void reload() {
// avoid too frequent changes...
if (!this.changing) {
@@ -111,13 +111,13 @@ public class DevicesGroup : ActionGroup {
message("Devices changed...");
this.delete_all();
this.load();
-
+
this.changing = false;
return false;
});
} else {
this.changed_again = true;
- }
+ }
}
}
diff --git a/src/actionGroups/groupRegistry.vala b/src/actionGroups/groupRegistry.vala
index 7510a03..ca0dc4d 100644
--- a/src/actionGroups/groupRegistry.vala
+++ b/src/actionGroups/groupRegistry.vala
@@ -1,83 +1,83 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// A which has knowledge on all possible acion group types.
/////////////////////////////////////////////////////////////////////////
public class GroupRegistry : GLib.Object {
-
+
/////////////////////////////////////////////////////////////////////
/// A list containing all available ActionGroup types.
/////////////////////////////////////////////////////////////////////
-
+
public static Gee.ArrayList<string> types { get; private set; }
-
+
/////////////////////////////////////////////////////////////////////
- /// A map associating a displayable name for each ActionGroup,
+ /// A map associating a displayable name for each ActionGroup,
/// an icon name and a name for the pies.conf file with it's type.
/////////////////////////////////////////////////////////////////////
-
+
public static Gee.HashMap<string, TypeDescription?> descriptions { get; private set; }
-
+
public class TypeDescription {
public string name { get; set; default=""; }
public string icon { get; set; default=""; }
public string description { get; set; default=""; }
public string id { get; set; default=""; }
}
-
+
/////////////////////////////////////////////////////////////////////
/// Registers all ActionGroup types.
/////////////////////////////////////////////////////////////////////
-
+
public static void init() {
types = new Gee.ArrayList<string>();
descriptions = new Gee.HashMap<string, TypeDescription?>();
-
+
TypeDescription type_description;
-
+
type_description = BookmarkGroup.register();
types.add(typeof(BookmarkGroup).name());
descriptions.set(typeof(BookmarkGroup).name(), type_description);
-
+
type_description = DevicesGroup.register();
types.add(typeof(DevicesGroup).name());
descriptions.set(typeof(DevicesGroup).name(), type_description);
-
+
type_description = MenuGroup.register();
types.add(typeof(MenuGroup).name());
descriptions.set(typeof(MenuGroup).name(), type_description);
-
+
type_description = SessionGroup.register();
types.add(typeof(SessionGroup).name());
descriptions.set(typeof(SessionGroup).name(), type_description);
-
+
type_description = WindowListGroup.register();
types.add(typeof(WindowListGroup).name());
descriptions.set(typeof(WindowListGroup).name(), type_description);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Creates a Group for a given type name.
/////////////////////////////////////////////////////////////////////
-
+
public static ActionGroup? create_group(string type_id, string parent_id) {
switch (type_id) {
case "bookmarks": return new BookmarkGroup(parent_id);
@@ -86,7 +86,7 @@ public class GroupRegistry : GLib.Object {
case "session": return new SessionGroup(parent_id);
case "window_list": return new WindowListGroup(parent_id);
}
-
+
return null;
}
}
diff --git a/src/actionGroups/menuGroup.vala b/src/actionGroups/menuGroup.vala
index 26a2662..7a1e344 100644
--- a/src/actionGroups/menuGroup.vala
+++ b/src/actionGroups/menuGroup.vala
@@ -1,35 +1,35 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// An ActionGroup which displays the user's main menu. It's a bit ugly,
/// but it supports both, an older version and libgnome-menus-3 at the
/// same time.
/////////////////////////////////////////////////////////////////////////
-
+
public class MenuGroup : 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
+ /// 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: Main menu");
@@ -38,50 +38,50 @@ public class MenuGroup : ActionGroup {
description.id = "menu";
return description;
}
-
+
/////////////////////////////////////////////////////////////////////
/// True, if this MenuGroup is the top most menu.
/////////////////////////////////////////////////////////////////////
-
+
public bool is_toplevel {get; construct set; default = true;}
-
+
/////////////////////////////////////////////////////////////////////
/// The menu tree displayed by the MenuGroup. Only set for the
/// toplevel MenuGroup.
/////////////////////////////////////////////////////////////////////
-
+
private GMenu.Tree menu = null;
-
+
/////////////////////////////////////////////////////////////////////
/// A list of all sub menus of this MenuGroup.
/////////////////////////////////////////////////////////////////////
-
+
private Gee.ArrayList<MenuGroup?> childs;
-
+
/////////////////////////////////////////////////////////////////////
- /// Two members needed to avoid useless, frequent changes of the
+ /// Two members needed to avoid useless, frequent changes of the
/// stored Actions.
/////////////////////////////////////////////////////////////////////
-
+
private bool changing = false;
private bool changed_again = false;
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members. Used for the toplevel menu.
/////////////////////////////////////////////////////////////////////
-
+
public MenuGroup(string parent_id) {
GLib.Object(parent_id : parent_id, is_toplevel : true);
}
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members. Used for sub menus.
/////////////////////////////////////////////////////////////////////
-
+
public MenuGroup.sub_menu(string parent_id) {
GLib.Object(parent_id : parent_id, is_toplevel : false);
}
-
+
construct {
this.childs = new Gee.ArrayList<MenuGroup?>();
@@ -89,16 +89,16 @@ public class MenuGroup : ActionGroup {
#if HAVE_GMENU_3
this.menu = new GMenu.Tree("applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED);
this.menu.changed.connect(this.reload);
- #endif
-
- this.load_toplevel();
- }
+ #endif
+
+ this.load_toplevel();
+ }
}
-
+
/////////////////////////////////////////////////////////////////////
/// Starts to load the menu.
/////////////////////////////////////////////////////////////////////
-
+
private void load_toplevel() {
#if HAVE_GMENU_3
try {
@@ -113,13 +113,13 @@ public class MenuGroup : ActionGroup {
this.menu.add_monitor(this.reload);
var dir = this.menu.get_root_directory();
this.load_contents(dir, this.parent_id);
- #endif
+ #endif
}
/////////////////////////////////////////////////////////////////////
/// Parses the main menu recursively.
/////////////////////////////////////////////////////////////////////
-
+
private void load_contents(GMenu.TreeDirectory dir, string parent_id) {
#if HAVE_GMENU_3
var item = dir.iter();
@@ -128,35 +128,35 @@ public class MenuGroup : ActionGroup {
var type = item.next();
if (type == GMenu.TreeItemType.INVALID)
break;
-
+
if (type == GMenu.TreeItemType.DIRECTORY && !item.get_directory().get_is_nodisplay()) {
- // create a MenuGroup for sub menus
-
+ // create a MenuGroup for sub menus
+
// get icon
var icon = item.get_directory().get_icon();
-
+
var sub_menu = PieManager.create_dynamic_pie(item.get_directory().get_name(), Icon.get_icon_name(icon));
var group = new MenuGroup.sub_menu(sub_menu.id);
group.add_action(new PieAction(parent_id, true));
group.load_contents(item.get_directory(), sub_menu.id);
childs.add(group);
-
+
sub_menu.add_group(group);
-
- this.add_action(new PieAction(sub_menu.id));
+
+ this.add_action(new PieAction(sub_menu.id));
} else if (type == GMenu.TreeItemType.ENTRY ) {
// create an AppAction for entries
if (!item.get_entry().get_is_excluded()) {
- this.add_action(ActionRegistry.new_for_app_info(item.get_entry().get_app_info()));
- }
+ this.add_action(ActionRegistry.new_for_app_info(item.get_entry().get_app_info()));
+ }
}
}
#else
foreach (var item in dir.get_contents()) {
switch(item.get_type()) {
case GMenu.TreeItemType.DIRECTORY:
- // create a MenuGroup for sub menus
+ // create a MenuGroup for sub menus
if (!((GMenu.TreeDirectory)item).get_is_nodisplay()) {
var sub_menu = PieManager.create_dynamic_pie(
((GMenu.TreeDirectory)item).get_name(),
@@ -165,30 +165,30 @@ public class MenuGroup : ActionGroup {
group.add_action(new PieAction(parent_id, true));
group.load_contents((GMenu.TreeDirectory)item, sub_menu.id);
childs.add(group);
-
+
sub_menu.add_group(group);
-
- this.add_action(new PieAction(sub_menu.id));
- }
+
+ this.add_action(new PieAction(sub_menu.id));
+ }
break;
-
+
case GMenu.TreeItemType.ENTRY:
// create an AppAction for entries
if (!((GMenu.TreeEntry)item).get_is_nodisplay() && !((GMenu.TreeEntry)item).get_is_excluded()) {
- this.add_action(new AppAction(((GMenu.TreeEntry)item).get_name(),
- ((GMenu.TreeEntry)item).get_icon(),
- ((GMenu.TreeEntry)item).get_exec()));
- }
+ this.add_action(new AppAction(((GMenu.TreeEntry)item).get_name(),
+ ((GMenu.TreeEntry)item).get_icon(),
+ ((GMenu.TreeEntry)item).get_exec()));
+ }
break;
}
}
#endif
}
-
+
/////////////////////////////////////////////////////////////////////
/// Reloads the menu.
/////////////////////////////////////////////////////////////////////
-
+
private void reload() {
// avoid too frequent changes...
if (!this.changing) {
@@ -204,46 +204,46 @@ public class MenuGroup : ActionGroup {
#if !HAVE_GMENU_3
this.menu.remove_monitor(this.reload);
#endif
-
+
this.clear();
this.load_toplevel();
-
+
this.changing = false;
return false;
});
} else {
this.changed_again = true;
- }
+ }
}
-
+
/////////////////////////////////////////////////////////////////////
/// Deletes all generated Pies, when the toplevel menu is deleted.
/////////////////////////////////////////////////////////////////////
-
+
public override void on_remove() {
if (this.is_toplevel)
this.clear();
}
-
+
/////////////////////////////////////////////////////////////////////
/// Clears this ActionGroup recursively.
/////////////////////////////////////////////////////////////////////
-
+
private void clear() {
foreach (var child in childs)
child.clear();
if (!this.is_toplevel)
PieManager.remove_pie(this.parent_id);
-
+
this.delete_all();
-
+
this.childs.clear();
-
+
#if !HAVE_GMENU_3
this.menu = null;
#endif
-
+
}
}
diff --git a/src/actionGroups/sessionGroup.vala b/src/actionGroups/sessionGroup.vala
index 26f8ebc..7b989a6 100644
--- a/src/actionGroups/sessionGroup.vala
+++ b/src/actionGroups/sessionGroup.vala
@@ -1,19 +1,19 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 {
@@ -23,13 +23,13 @@ namespace GnomePie {
/////////////////////////////////////////////////////////////////////
public class SessionGroup : 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
+ /// 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: Session Control");
@@ -38,38 +38,38 @@ public class SessionGroup : ActionGroup {
description.id = "session";
return description;
}
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all members.
/////////////////////////////////////////////////////////////////////
-
+
public SessionGroup(string parent_id) {
GLib.Object(parent_id : parent_id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Construct block adds the three Actions.
/////////////////////////////////////////////////////////////////////
-
+
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",
+// 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"));
-
- this.add_action(new AppAction(_("Logout"), "gnome-session-logout",
+
+ this.add_action(new AppAction(_("Logout"), "gnome-session-logout",
"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",
+
+ this.add_action(new AppAction(_("Reboot"), "gnome-session-reboot",
"dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.RequestReboot"));
}
-
+
// TODO: check for available interfaces --- these may work too:
// 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 --print-reply --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 2 2
// 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
index 774666f..a2dc19c 100644
--- a/src/actionGroups/windowListGroup.vala
+++ b/src/actionGroups/windowListGroup.vala
@@ -1,19 +1,19 @@
-/*
-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/>.
-*/
+/////////////////////////////////////////////////////////////////////////
+// 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 {
@@ -22,13 +22,13 @@ namespace GnomePie {
/////////////////////////////////////////////////////////////////////
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
+ /// 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");
@@ -39,86 +39,86 @@ public class WindowListGroup : ActionGroup {
}
/////////////////////////////////////////////////////////////////////
- /// Two members needed to avoid useless, frequent changes of the
+ /// 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()) {
+ && !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())
+ "%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);
+ 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) {
@@ -132,13 +132,13 @@ public class WindowListGroup : ActionGroup {
// reload
this.delete_all();
this.load();
-
+
this.changing = false;
return false;
});
} else {
this.changed_again = true;
- }
+ }
}
}