summaryrefslogtreecommitdiff
path: root/src/pies
diff options
context:
space:
mode:
Diffstat (limited to 'src/pies')
-rw-r--r--src/pies/defaultConfig.vala48
-rw-r--r--src/pies/load.vala82
-rw-r--r--src/pies/pie.vala86
-rw-r--r--src/pies/pieManager.vala194
-rw-r--r--src/pies/save.vala50
5 files changed, 246 insertions, 214 deletions
diff --git a/src/pies/defaultConfig.vala b/src/pies/defaultConfig.vala
index 87fd30d..6ca45e4 100644
--- a/src/pies/defaultConfig.vala
+++ b/src/pies/defaultConfig.vala
@@ -1,37 +1,37 @@
-/*
-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 helper class which creates a user-specific default configuration.
/////////////////////////////////////////////////////////////////////////
namespace Pies {
public void create_default_config() {
-
+
// add a pie with playback controls
var multimedia = PieManager.create_persistent_pie(_("Multimedia"), "stock_media-play", new Trigger.from_string("<Control><Alt>m"));
multimedia.add_action(new KeyAction(_("Next Track"), "stock_media-next", "XF86AudioNext", true));
multimedia.add_action(new KeyAction(_("Stop"), "stock_media-stop", "XF86AudioStop"));
multimedia.add_action(new KeyAction(_("Previous Track"), "stock_media-prev", "XF86AudioPrev"));
multimedia.add_action(new KeyAction(_("Play/Pause"), "stock_media-play", "XF86AudioPlay"));
-
+
// add a pie with the users default applications
var apps = PieManager.create_persistent_pie(_("Applications"), "applications-accessories", new Trigger.from_string("<Control><Alt>a"));
apps.add_action(ActionRegistry.default_for_mime_type("text/plain"));
@@ -40,20 +40,20 @@ namespace Pies {
apps.add_action(ActionRegistry.default_for_mime_type("image/jpg"));
apps.add_action(ActionRegistry.default_for_uri("http"));
apps.add_action(ActionRegistry.default_for_uri("mailto"));
-
+
// add a pie with the users bookmarks and devices
var bookmarks = PieManager.create_persistent_pie(_("Bookmarks"), "user-bookmarks", new Trigger.from_string("<Control><Alt>b"));
bookmarks.add_group(new BookmarkGroup(bookmarks.id));
bookmarks.add_group(new DevicesGroup(bookmarks.id));
-
+
// add a pie with session controls
var session = PieManager.create_persistent_pie(_("Session"), "gnome-session-halt", new Trigger.from_string("<Control><Alt>q"));
session.add_group(new SessionGroup(session.id));
-
+
// add a pie with a main menu
var menu = PieManager.create_persistent_pie(_("Main Menu"), "alacarte", new Trigger.from_string("<Control><Alt>space"));
menu.add_group(new MenuGroup(menu.id));
-
+
// add a pie with window controls
var window = PieManager.create_persistent_pie(_("Window"), "gnome-window-manager", new Trigger.from_string("<Control><Alt>w"));
window.add_action(new KeyAction(_("Scale"), "top", "<Control><Alt>s"));
@@ -61,7 +61,7 @@ namespace Pies {
window.add_action(new KeyAction(_("Close"), "window-close", "<Alt>F4"));
window.add_action(new KeyAction(_("Maximize"), "window_fullscreen", "<Alt>F10"));
window.add_action(new KeyAction(_("Restore"), "window_nofullscreen", "<Alt>F5"));
-
+
// save the configuration to file
Pies.save();
}
diff --git a/src/pies/load.vala b/src/pies/load.vala
index cb08a8a..7402094 100644
--- a/src/pies/load.vala
+++ b/src/pies/load.vala
@@ -1,25 +1,25 @@
-/*
-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/>.
+/////////////////////////////////////////////////////////////////////////
using GLib.Math;
namespace GnomePie {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// A helper method which loads pies according to the configuration file.
/////////////////////////////////////////////////////////////////////////
@@ -28,7 +28,7 @@ namespace Pies {
/////////////////////////////////////////////////////////////////////
/// Loads all Pies from the pies.conf file.
/////////////////////////////////////////////////////////////////////
-
+
public void load() {
// check whether the config file exists
if (!GLib.File.new_for_path(Paths.pie_config).query_exists()) {
@@ -36,13 +36,13 @@ namespace Pies {
Pies.create_default_config();
return;
}
-
+
message("Loading Pies from \"" + Paths.pie_config + "\".");
-
+
// load the settings file
Xml.Parser.init();
Xml.Doc* piesXML = Xml.Parser.parse_file(Paths.pie_config);
-
+
if (piesXML != null) {
// begin parsing at the root element
Xml.Node* root = piesXML->get_root_element();
@@ -57,36 +57,36 @@ namespace Pies {
default:
warning("Invalid child element <" + node_name + "> in <pies> element pies.conf!");
break;
- }
+ }
}
}
} else {
warning("Error loading pies: pies.conf is empty! The cake is a lie...");
}
-
+
delete piesXML;
-
+
} else {
warning("Error loading pies: pies.conf not found! The cake is a lie...");
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <pie> element from the pies.conf file.
/////////////////////////////////////////////////////////////////////
-
+
private static void parse_pie(Xml.Node* node) {
string hotkey = "";
string name = "";
string icon = "";
string id = "";
int quickaction = -1;
-
+
// parse all attributes of this node
for (Xml.Attr* attribute = node->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
string attr_content = attribute->children->content;
-
+
switch (attr_name) {
case "hotkey":
hotkey = attr_content;
@@ -108,15 +108,15 @@ namespace Pies {
break;
}
}
-
+
if (name == "") {
warning("Invalid <pie> element in pies.conf: No name specified!");
return;
}
-
+
// add a new Pie with the loaded properties
var pie = PieManager.create_persistent_pie(name, icon, new Trigger.from_string(hotkey), id);
-
+
// and parse all child elements
for (Xml.Node* slice = node->children; slice != null; slice = slice->next) {
if (slice->type == Xml.ElementType.ELEMENT_NODE) {
@@ -131,22 +131,22 @@ namespace Pies {
default:
warning("Invalid child element <" + node_name + "> in <pie> element in pies.conf!");
break;
- }
+ }
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <slice> element from the pies.conf file.
/////////////////////////////////////////////////////////////////////
-
+
private static void parse_slice(Xml.Node* slice, Pie pie) {
string name="";
string icon="";
string command="";
string type="";
bool quickaction = false;
-
+
// parse all attributes of this node
for (Xml.Attr* attribute = slice->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
@@ -173,20 +173,20 @@ namespace Pies {
break;
}
}
-
+
// create a new Action according to the loaded type
Action action = ActionRegistry.create_action(type, name, icon, command, quickaction);
-
+
if (action != null) pie.add_action(action);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Parses a <group> element from the pies.conf file.
/////////////////////////////////////////////////////////////////////
-
+
private static void parse_group(Xml.Node* slice, Pie pie) {
string type="";
-
+
// parse all attributes of this node
for (Xml.Attr* attribute = slice->properties; attribute != null; attribute = attribute->next) {
string attr_name = attribute->name.down();
@@ -201,7 +201,7 @@ namespace Pies {
break;
}
}
-
+
ActionGroup group = GroupRegistry.create_group(type, pie.id);
if (group != null) pie.add_group(group);
diff --git a/src/pies/pie.vala b/src/pies/pie.vala
index fa205c7..1699ada 100644
--- a/src/pies/pie.vala
+++ b/src/pies/pie.vala
@@ -1,109 +1,109 @@
-/*
-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 class stores information on a pie. A pie consists of a name, an
+/////////////////////////////////////////////////////////////////////////
+/// This class stores information on a pie. A pie consists of a name, an
/// icon name and an unique ID. Furthermore it has an arbitrary amount
/// of ActionGroups storing Actions.
/////////////////////////////////////////////////////////////////////////
public class Pie : GLib.Object {
-
+
/////////////////////////////////////////////////////////////////////
/// The name of this Pie. It has not to be unique.
/////////////////////////////////////////////////////////////////////
-
+
public string name { get; set; }
-
+
/////////////////////////////////////////////////////////////////////
/// The name of the icon to be used for this Pie. It should exist in
/// the users current icon theme, else a standard icon will be used.
/////////////////////////////////////////////////////////////////////
-
+
public string icon { get; set; }
-
+
/////////////////////////////////////////////////////////////////////
/// The ID of this Pie. It has to be unique among all Pies. This ID
- /// consists of three digits when the Pie was created by the user,
- /// of four digits when it was created dynamically by another class,
+ /// consists of three digits when the Pie was created by the user,
+ /// of four digits when it was created dynamically by another class,
/// for example by an ActionGroup.
/////////////////////////////////////////////////////////////////////
-
+
public string id { get; construct; }
-
+
/////////////////////////////////////////////////////////////////////
/// Stores all ActionGroups of this Pie.
/////////////////////////////////////////////////////////////////////
-
+
public Gee.ArrayList<ActionGroup?> action_groups { get; private set; }
-
+
/////////////////////////////////////////////////////////////////////
/// C'tor, initializes all given members.
/////////////////////////////////////////////////////////////////////
-
+
public Pie(string id, string name, string icon) {
GLib.Object(id: id, name: name, icon:icon);
-
+
this.action_groups = new Gee.ArrayList<ActionGroup?>();
}
-
+
/////////////////////////////////////////////////////////////////////
/// Should be called when this Pie is deleted, in order to clean up
/// stuff created by contained ActionGroups.
/////////////////////////////////////////////////////////////////////
-
+
public virtual void on_remove() {
foreach (var action_group in action_groups)
action_group.on_remove();
}
-
+
/////////////////////////////////////////////////////////////////////
/// Adds an Action to this Pie.
/////////////////////////////////////////////////////////////////////
-
+
public void add_action(Action action, int at_position = -1) {
var group = new ActionGroup(this.id);
group.add_action(action);
this.add_group(group, at_position);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Adds an ActionGroup to this Pie.
/////////////////////////////////////////////////////////////////////
-
- public void add_group(ActionGroup group, int at_position = -1) {
+
+ public void add_group(ActionGroup group, int at_position = -1) {
if (group.has_quickaction()) {
foreach (var action_group in action_groups)
action_group.disable_quickactions();
}
-
- if (at_position < 0 || at_position >= this.action_groups.size)
+
+ if (at_position < 0 || at_position >= this.action_groups.size)
this.action_groups.add(group);
else
this.action_groups.insert(at_position, group);
}
-
+
public void remove_group(int index) {
if (this.action_groups.size > index)
this.action_groups.remove_at(index);
}
-
+
public void move_group(int from, int to) {
if (this.action_groups.size > from && this.action_groups.size > to) {
var tmp = this.action_groups[from];
@@ -111,7 +111,7 @@ public class Pie : GLib.Object {
this.add_group(tmp, to);
}
}
-
+
public void update_group(ActionGroup group, int index) {
if (this.action_groups.size > index)
this.action_groups.set(index, group);
diff --git a/src/pies/pieManager.vala b/src/pies/pieManager.vala
index 83a8309..55cb353 100644
--- a/src/pies/pieManager.vala
+++ b/src/pies/pieManager.vala
@@ -1,24 +1,24 @@
-/*
-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 static class which stores all Pies. It can be used to add, delete
+/////////////////////////////////////////////////////////////////////////
+/// A static class which stores all Pies. It can be used to add, delete
/// and open Pies.
/////////////////////////////////////////////////////////////////////////
@@ -30,196 +30,227 @@ public class PieManager : GLib.Object {
/////////////////////////////////////////////////////////////////////
public static Gee.HashMap<string, Pie?> all_pies { get; private set; }
-
+
/////////////////////////////////////////////////////////////////////
/// Stores all PieWindows which are currently opened. Should be
/// rarely more than two...
/////////////////////////////////////////////////////////////////////
-
+
public static Gee.HashSet<PieWindow?> opened_windows { get; private set; }
-
+
/////////////////////////////////////////////////////////////////////
/// Stores all global hotkeys.
/////////////////////////////////////////////////////////////////////
-
+
private static BindingManager bindings;
-
+
/////////////////////////////////////////////////////////////////////
/// True, if any pie has the current focus. If it is closing this
/// will be false already.
/////////////////////////////////////////////////////////////////////
-
+
private static bool a_pie_is_active = false;
-
+
/////////////////////////////////////////////////////////////////////
/// Storing the position of the last Pie. Used for subpies, which are
/// opened at their parents location.
/////////////////////////////////////////////////////////////////////
-
+
private static int last_x = 0;
private static int last_y = 0;
-
+
/////////////////////////////////////////////////////////////////////
/// Initializes all Pies. They are loaded from the pies.conf file.
/////////////////////////////////////////////////////////////////////
-
+
public static void init() {
all_pies = new Gee.HashMap<string, Pie?>();
opened_windows = new Gee.HashSet<PieWindow?>();
bindings = new BindingManager();
-
+
// load all Pies from th pies.conf file
Pies.load();
-
+
// open the according pie if it's hotkey is pressed
bindings.on_press.connect((id) => {
open_pie(id);
});
}
-
+
/////////////////////////////////////////////////////////////////////
/// Opens the Pie with the given ID, if it exists.
/////////////////////////////////////////////////////////////////////
-
+
public static void open_pie(string id) {
if (!a_pie_is_active) {
Pie? pie = all_pies[id];
-
+
if (pie != null) {
-
+
a_pie_is_active = true;
-
+
+ //change WM_CLASS so launchers can track windows properly
+ Gdk.set_program_class("gnome-pie-" + id);
+
var window = new PieWindow();
window.load_pie(pie);
-
+
window.open();
-
+
opened_windows.add(window);
-
+
window.on_closed.connect(() => {
opened_windows.remove(window);
if (opened_windows.size == 0) {
Icon.clear_cache();
}
});
-
+
window.on_closing.connect(() => {
window.get_center_pos(out last_x, out last_y);
a_pie_is_active = false;
});
-
-
+
+
+ //restore default WM_CLASS after window open
+ Gdk.set_program_class("gnome-pie");
+
} else {
warning("Failed to open pie with ID \"" + id + "\": ID does not exist!");
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Returns the hotkey which the Pie with the given ID is bound to.
/////////////////////////////////////////////////////////////////////
-
+
public static string get_accelerator_of(string id) {
return bindings.get_accelerator_of(id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Returns a human-readable version of the hotkey which the Pie
/// with the given ID is bound to.
/////////////////////////////////////////////////////////////////////
-
+
public static string get_accelerator_label_of(string id) {
return bindings.get_accelerator_label_of(id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Bind the Pie with the given ID to the given trigger.
/////////////////////////////////////////////////////////////////////
-
+
public static void bind_trigger(Trigger trigger, string id) {
bindings.unbind(id);
bindings.bind(trigger, id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Returns true if the pie with the given id is in turbo mode.
/////////////////////////////////////////////////////////////////////
-
+
public static bool get_is_turbo(string id) {
return bindings.get_is_turbo(id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Returns true if the pie with the given id opens in the middle of
/// the screen.
/////////////////////////////////////////////////////////////////////
-
+
public static bool get_is_centered(string id) {
return bindings.get_is_centered(id);
}
-
+
+ /////////////////////////////////////////////////////////////////////
+ /// Returns true if the mouse pointer will be warped to the center of
+ /// the pie.
+ /////////////////////////////////////////////////////////////////////
+
+ public static bool get_is_warp(string id) {
+ return bindings.get_is_warp(id);
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ /// Returns true if the pie with the given id is auto shaped
+ /////////////////////////////////////////////////////////////////////
+
+ public static bool get_is_auto_shape(string id) {
+ return bindings.get_is_auto_shape(id);
+ }
+
+ /////////////////////////////////////////////////////////////////////
+ /// Returns the prefered pie shape number
+ /////////////////////////////////////////////////////////////////////
+
+ public static int get_shape_number(string id) {
+ return bindings.get_shape_number(id);
+ }
+
/////////////////////////////////////////////////////////////////////
/// Returns the name of the Pie with the given ID.
/////////////////////////////////////////////////////////////////////
-
+
public static string get_name_of(string id) {
Pie? pie = all_pies[id];
if (pie == null) return "";
else return pie.name;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Returns the name ID of the Pie bound to the given Trigger.
/// Returns "" if there is nothing bound to this trigger.
/////////////////////////////////////////////////////////////////////
-
+
public static string get_assigned_id(Trigger trigger) {
return bindings.get_assigned_id(trigger);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Creates a new Pie which is displayed in the configuration dialog
/// and gets saved.
/////////////////////////////////////////////////////////////////////
-
+
public static Pie create_persistent_pie(string name, string icon_name, Trigger? hotkey, string? desired_id = null) {
Pie pie = create_pie(name, icon_name, 100, 999, desired_id);
if (hotkey != null) bindings.bind(hotkey, pie.id);
-
+
create_launcher(pie.id);
-
+
return pie;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Creates a new Pie which is not displayed in the configuration
/// dialog and is not saved.
/////////////////////////////////////////////////////////////////////
-
+
public static Pie create_dynamic_pie(string name, string icon_name, string? desired_id = null) {
return create_pie(name, icon_name, 1000, 9999, desired_id);
}
-
+
/////////////////////////////////////////////////////////////////////
/// Adds a new Pie. Can't be accesd from outer scope. Use
/// create_persistent_pie or create_dynamic_pie instead.
/////////////////////////////////////////////////////////////////////
-
+
private static Pie create_pie(string name, string icon_name, int min_id, int max_id, string? desired_id = null) {
var random = new GLib.Rand();
-
+
string final_id;
-
- if (desired_id == null)
+
+ if (desired_id == null)
final_id = random.int_range(min_id, max_id).to_string();
else {
final_id = desired_id;
final_id.canon("0123456789", '_');
final_id = final_id.replace("_", "");
-
+
int id = int.parse(final_id);
-
+
if (id < min_id || id > max_id) {
final_id = random.int_range(min_id, max_id).to_string();
warning("The ID for pie \"" + name + "\" should be in range %u - %u! Using \"" + final_id + "\" instead of \"" + desired_id + "\"...", min_id, max_id);
@@ -237,21 +268,21 @@ public class PieManager : GLib.Object {
Pie pie = new Pie(final_id, name, icon_name);
all_pies.set(final_id, pie);
-
+
return pie;
}
-
+
/////////////////////////////////////////////////////////////////////
/// Removes the Pie with the given ID if it exists. Additionally it
/// unbinds it's global hotkey.
/////////////////////////////////////////////////////////////////////
-
+
public static void remove_pie(string id) {
if (all_pies.has_key(id)) {
all_pies[id].on_remove();
all_pies.unset(id);
bindings.unbind(id);
-
+
if (id.length == 3)
remove_launcher(id);
}
@@ -259,27 +290,28 @@ public class PieManager : GLib.Object {
warning("Failed to remove pie with ID \"" + id + "\": ID does not exist!");
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Creates a desktop file for which opens the Pie with given ID.
/////////////////////////////////////////////////////////////////////
-
+
public static void create_launcher(string id) {
if (all_pies.has_key(id)) {
Pie? pie = all_pies[id];
-
- string launcher_entry =
- "#!/usr/bin/env xdg-open\n" +
+
+ string launcher_entry =
+ "#!/usr/bin/env xdg-open\n" +
"[Desktop Entry]\n" +
"Name=%s\n".printf(pie.name) +
"Exec=%s -o %s\n".printf(Paths.executable, pie.id) +
"Encoding=UTF-8\n" +
"Type=Application\n" +
- "Icon=%s\n".printf(pie.icon);
+ "Icon=%s\n".printf(pie.icon) +
+ "StartupWMClass=gnome-pie-%s\n".printf(pie.id);
// create the launcher file
string launcher = Paths.launchers + "/%s.desktop".printf(pie.id);
-
+
try {
FileUtils.set_contents(launcher, launcher_entry);
FileUtils.chmod(launcher, 0755);
@@ -288,11 +320,11 @@ public class PieManager : GLib.Object {
}
}
}
-
+
/////////////////////////////////////////////////////////////////////
/// Deletes the desktop file for the Pie with the given ID.
/////////////////////////////////////////////////////////////////////
-
+
private static void remove_launcher(string id) {
string launcher = Paths.launchers + "/%s.desktop".printf(id);
if (FileUtils.test(launcher, FileTest.EXISTS)) {
diff --git a/src/pies/save.vala b/src/pies/save.vala
index 60fc0b2..9760cce 100644
--- a/src/pies/save.vala
+++ b/src/pies/save.vala
@@ -1,25 +1,25 @@
-/*
-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/>.
+/////////////////////////////////////////////////////////////////////////
using GLib.Math;
namespace GnomePie {
-/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
/// A helper method which saves pies in a configuration file.
/////////////////////////////////////////////////////////////////////////
@@ -28,23 +28,23 @@ namespace Pies {
/////////////////////////////////////////////////////////////////////
/// Saves all Pies of the PieManager to the pies.conf file.
/////////////////////////////////////////////////////////////////////
-
+
public void save() {
message("Saving Pies to \"" + Paths.pie_config + "\".");
-
+
// initializes the XML-Writer
var writer = new Xml.TextWriter.filename(Paths.pie_config);
writer.set_indent(true);
writer.start_document("1.0");
writer.start_element("pies");
-
+
// iterate through all Pies
foreach (var pie_entry in PieManager.all_pies.entries) {
var pie = pie_entry.value;
-
+
// if it's no dynamically created Pie
if (pie.id.length == 3) {
- int slice_count = 0;
+ int slice_count = 0;
// write all attributes of the Pie
writer.start_element("pie");
@@ -52,7 +52,7 @@ namespace Pies {
writer.write_attribute("id", pie.id);
writer.write_attribute("icon", pie.icon);
writer.write_attribute("hotkey", PieManager.get_accelerator_of(pie.id));
-
+
// and all of it's Actions
foreach (var group in pie.action_groups) {
// if it's a custom ActionGroup
@@ -67,14 +67,14 @@ namespace Pies {
writer.write_attribute("command", action.real_command);
writer.write_attribute("quickAction", action.is_quickaction ? "true" : "false");
writer.end_element();
-
+
++ slice_count;
}
} else {
writer.start_element("group");
writer.write_attribute("type", GroupRegistry.descriptions[group.get_type().name()].id);
writer.end_element();
-
+
slice_count += group.actions.size;
}
}