1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011-2017 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,
/// 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();
if (type_description != null) {
types.add(typeof(BookmarkGroup).name());
descriptions.set(typeof(BookmarkGroup).name(), type_description);
}
type_description = ClipboardGroup.register();
if (type_description != null) {
types.add(typeof(ClipboardGroup).name());
descriptions.set(typeof(ClipboardGroup).name(), type_description);
}
type_description = DevicesGroup.register();
if (type_description != null) {
types.add(typeof(DevicesGroup).name());
descriptions.set(typeof(DevicesGroup).name(), type_description);
}
type_description = MenuGroup.register();
if (type_description != null) {
types.add(typeof(MenuGroup).name());
descriptions.set(typeof(MenuGroup).name(), type_description);
}
type_description = SessionGroup.register();
if (type_description != null) {
types.add(typeof(SessionGroup).name());
descriptions.set(typeof(SessionGroup).name(), type_description);
}
type_description = WindowListGroup.register();
if (type_description != null) {
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) {
bool wayland = GLib.Environment.get_variable("XDG_SESSION_TYPE") == "wayland";
switch (type_id) {
case "bookmarks":
return new BookmarkGroup(parent_id);
case "clipboard":
return new ClipboardGroup(parent_id);
case "devices":
return new DevicesGroup(parent_id);
case "menu":
return new MenuGroup(parent_id);
case "session":
return new SessionGroup(parent_id);
case "window_list":
if (wayland) return null;
return new WindowListGroup(parent_id);
// deprecated
case "workspace_window_list":
if (wayland) return null;
var group = new WindowListGroup(parent_id);
group.current_workspace_only = true;
return group;
}
return null;
}
}
}
|