1/*
2Copyright (c) 2011 by Simon Schneegans
3
4This program is free software: you can redistribute it and/or modify it
5under the terms of the GNU General Public License as published by the Free
6Software Foundation, either version 3 of the License, or (at your option)
7any later version.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12more details.
13
14You should have received a copy of the GNU General Public License along with
15this program.  If not, see <http://www.gnu.org/licenses/>.
16*/
17
18namespace GnomePie {
19
20/////////////////////////////////////////////////////////////////////////
21/// This Action opens another pie.
22/////////////////////////////////////////////////////////////////////////
23
24public class PieAction : Action {
25
26    /////////////////////////////////////////////////////////////////////
27    /// Used to register this type of Action. It sets the display name
28    /// for this Action, whether it has a custom Icon/Name and the string
29    /// used in the pies.conf file for this kind of Actions.
30    /////////////////////////////////////////////////////////////////////
31
32    public static ActionRegistry.TypeDescription register() {
33        var description = new ActionRegistry.TypeDescription();
34        description.name = _("Open Pie");
35        description.icon = "gnome-pie";
36        description.description = _("Opens another Pie of Gnome-Pie. You may create sub menus this way.");
37        description.icon_name_editable = false;
38        description.id = "pie";
39        return description;
40    }
41
42    /////////////////////////////////////////////////////////////////////
43    /// Stores the ID of the referenced Pie.
44    /////////////////////////////////////////////////////////////////////
45
46    public override string real_command { get; construct set; }
47
48    /////////////////////////////////////////////////////////////////////
49    /// Returns the name of the referenced Pie.
50    /////////////////////////////////////////////////////////////////////
51
52    public override string display_command { get {return name;} }
53
54    /////////////////////////////////////////////////////////////////////
55    /// Returns the name of the referenced Pie.
56    /////////////////////////////////////////////////////////////////////
57
58    public override string name {
59        get {
60            var referee = PieManager.all_pies[real_command];
61            if (referee != null) {
62                owned_name = "↪" + referee.name;
63                return owned_name;
64            }
65            return "";
66        }
67        protected set {}
68    }
69
70    private string owned_name;
71
72    /////////////////////////////////////////////////////////////////////
73    /// Returns the icon of the referenced Pie.
74    /////////////////////////////////////////////////////////////////////
75
76    public override string icon {
77        get {
78            var referee = PieManager.all_pies[real_command];
79            if (referee != null)
80                return referee.icon;
81            return "";
82        }
83        protected set {}
84    }
85
86    /////////////////////////////////////////////////////////////////////
87    /// C'tor, initializes all members.
88    /////////////////////////////////////////////////////////////////////
89
90    public PieAction(string id, bool is_quickaction = false) {
91        GLib.Object(name : "", icon : "", real_command : id, is_quickaction : is_quickaction);
92    }
93
94    /////////////////////////////////////////////////////////////////////
95    /// Opens the desired Pie.
96    /////////////////////////////////////////////////////////////////////
97
98    public override void activate() {
99        PieManager.open_pie(real_command);
100    }
101}
102
103}
104