From d6b2677825cbb423e2099563c16321c3e23d7899 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Sun, 20 Nov 2011 15:50:38 +0100 Subject: Imported Upstream version 0.3.1 --- src/pies/pieManager.vala | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/pies/pieManager.vala') diff --git a/src/pies/pieManager.vala b/src/pies/pieManager.vala index eb031d0..5f84ea0 100644 --- a/src/pies/pieManager.vala +++ b/src/pies/pieManager.vala @@ -102,6 +102,14 @@ public class PieManager : GLib.Object { return bindings.get_accelerator_label_of(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 the name of the Pie with the given ID. ///////////////////////////////////////////////////////////////////// @@ -112,15 +120,24 @@ public class PieManager : GLib.Object { 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, string hotkey, string? desired_id = null) { + 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 != "") bindings.bind(hotkey, pie.id); + if (hotkey != null) bindings.bind(hotkey, pie.id); create_launcher(pie.id); -- cgit v1.2.3 From 60560a030fda3c539ff9dc1563b9926414a193da Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Sat, 21 Jan 2012 19:07:09 +0100 Subject: Imported Upstream version 0.4.0 --- src/pies/pieManager.vala | 54 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) (limited to 'src/pies/pieManager.vala') diff --git a/src/pies/pieManager.vala b/src/pies/pieManager.vala index 5f84ea0..0263d23 100644 --- a/src/pies/pieManager.vala +++ b/src/pies/pieManager.vala @@ -31,6 +31,13 @@ public class PieManager : GLib.Object { public static Gee.HashMap all_pies { get; private set; } + ///////////////////////////////////////////////////////////////////// + /// Stores all PieWindows which are currently opened. Should be + /// rarely more than two... + ///////////////////////////////////////////////////////////////////// + + public static Gee.HashSet opened_windows { get; private set; } + ///////////////////////////////////////////////////////////////////// /// Stores all global hotkeys. ///////////////////////////////////////////////////////////////////// @@ -42,7 +49,7 @@ public class PieManager : GLib.Object { /// will be false already. ///////////////////////////////////////////////////////////////////// - private static bool a_pie_is_opened = false; + private static bool a_pie_is_active = false; ///////////////////////////////////////////////////////////////////// /// Initializes all Pies. They are loaded from the pies.conf file. @@ -50,6 +57,7 @@ public class PieManager : GLib.Object { public static void init() { all_pies = new Gee.HashMap(); + opened_windows = new Gee.HashSet(); bindings = new BindingManager(); // load all Pies from th pies.conf file @@ -66,19 +74,27 @@ public class PieManager : GLib.Object { ///////////////////////////////////////////////////////////////////// public static void open_pie(string id) { - if (!a_pie_is_opened) { + if (!a_pie_is_active) { Pie? pie = all_pies[id]; if (pie != null) { - a_pie_is_opened = true; + a_pie_is_active = true; var window = new PieWindow(); window.load_pie(pie); window.open(); + opened_windows.add(window); + + window.on_closed.connect(() => { + opened_windows.remove(window); + }); + window.on_closing.connect(() => { - a_pie_is_opened = false; + a_pie_is_active = false; }); + + } else { warning("Failed to open pie with ID \"" + id + "\": ID does not exist!"); } @@ -102,6 +118,15 @@ public class PieManager : GLib.Object { 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. ///////////////////////////////////////////////////////////////////// @@ -110,6 +135,15 @@ public class PieManager : GLib.Object { 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 the name of the Pie with the given ID. ///////////////////////////////////////////////////////////////////// @@ -212,7 +246,11 @@ public class PieManager : GLib.Object { } } - private static void create_launcher(string id) { + ///////////////////////////////////////////////////////////////////// + /// 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]; @@ -220,7 +258,7 @@ public class PieManager : GLib.Object { "#!/usr/bin/env xdg-open\n" + "[Desktop Entry]\n" + "Name=%s\n".printf(pie.name) + - "Exec=gnome-pie -o %s\n".printf(pie.id) + + "Exec=%s -o %s\n".printf(Paths.executable, pie.id) + "Encoding=UTF-8\n" + "Type=Application\n" + "Icon=%s\n".printf(pie.icon); @@ -237,6 +275,10 @@ 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)) { -- cgit v1.2.3