@@ -21,9 +21,22 @@ namespace Keyboard.Shortcuts {
2121 struct Group {
2222 public string icon_name;
2323 public string label;
24- public string [] actions;
25- public Schema [] schemas;
26- public string [] keys;
24+
25+ public GLib . ListStore list;
26+ }
27+
28+ public class Action : Object {
29+ public Schema schema { get ; construct; }
30+ public string action { get ; construct; }
31+ public string key { get ; construct; }
32+
33+ public Action (Schema schema , string action , string key ) {
34+ Object (
35+ schema: schema,
36+ action: action,
37+ key: key
38+ );
39+ }
2740 }
2841
2942 class ShortcutsList : GLib .Object {
@@ -48,7 +61,9 @@ namespace Keyboard.Shortcuts {
4861 private ShortcutsList () {}
4962
5063 construct {
51- windows_group = {};
64+ windows_group = Group () {
65+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
66+ };
5267 windows_group. icon_name = " io.elementary.settings.keyboard.windows" ;
5368 windows_group. label = _(" Windows" );
5469 add_action (ref windows_group, Schema . WM , _(" Close" ), " close" );
@@ -74,7 +89,9 @@ namespace Keyboard.Shortcuts {
7489 add_action (ref windows_group, Schema . WM , _(" Move to right display" ), " move-to-monitor-right" );
7590 add_action (ref windows_group, Schema . WM , _(" Move to left display" ), " move-to-monitor-left" );
7691
77- workspaces_group = {};
92+ workspaces_group = Group () {
93+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
94+ };
7895 workspaces_group. icon_name = " preferences-desktop-workspaces" ;
7996 workspaces_group. label = _(" Workspaces" );
8097 add_action (ref workspaces_group, Schema . GALA , _(" Multitasking View" ), " toggle-multitasking-view" );
@@ -105,7 +122,9 @@ namespace Keyboard.Shortcuts {
105122 add_action (ref workspaces_group, Schema . WM , _(" Move to left workspace" ), " move-to-workspace-left" );
106123 add_action (ref workspaces_group, Schema . WM , _(" Move to right workspace" ), " move-to-workspace-right" );
107124
108- screenshot_group = {};
125+ screenshot_group = Group () {
126+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
127+ };
109128 screenshot_group. icon_name = " accessories-screenshot-tool" ;
110129 screenshot_group. label = _(" Screenshots" );
111130 add_action (ref screenshot_group, Schema . GALA , _(" Grab the whole screen" ), " screenshot" );
@@ -115,7 +134,9 @@ namespace Keyboard.Shortcuts {
115134 add_action (ref screenshot_group, Schema . GALA , _(" Select an area to grab" ), " area-screenshot" );
116135 add_action (ref screenshot_group, Schema . GALA , _(" Copy an area to clipboard" ), " area-screenshot-clip" );
117136
118- launchers_group = {};
137+ launchers_group = Group () {
138+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
139+ };
119140 launchers_group. icon_name = " io.elementary.settings.keyboard.applications" ;
120141 launchers_group. label = _(" Applications" );
121142 add_action (ref launchers_group, Schema . MEDIA , _(" Email" ), " email" );
@@ -133,7 +154,9 @@ namespace Keyboard.Shortcuts {
133154 add_action (ref launchers_group, Schema . DOCK , _(" Launch eighth dock item" ), " launch-dock-8" );
134155 add_action (ref launchers_group, Schema . DOCK , _(" Launch ninth dock item" ), " launch-dock-9" );
135156
136- media_group = {};
157+ media_group = Group () {
158+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
159+ };
137160 media_group. icon_name = " applications-multimedia" ;
138161 media_group. label = _(" Media" );
139162 add_action (ref media_group, Schema . SOUND_INDICATOR , _(" Volume Up" ), " volume-up" );
@@ -146,7 +169,9 @@ namespace Keyboard.Shortcuts {
146169 add_action (ref media_group, Schema . MEDIA , _(" Next Track" ), " next" );
147170 add_action (ref media_group, Schema . MEDIA , _(" Eject" ), " eject" );
148171
149- a11y_group = {};
172+ a11y_group = Group () {
173+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
174+ };
150175 a11y_group. icon_name = " preferences-desktop-accessibility" ;
151176 a11y_group. label = _(" Universal Access" );
152177 add_action (ref a11y_group, Schema . MEDIA , _(" Decrease Text Size" ), " decrease-text-size" );
@@ -156,23 +181,29 @@ namespace Keyboard.Shortcuts {
156181 add_action (ref a11y_group, Schema . MEDIA , _(" Toggle On Screen Keyboard" ), " on-screen-keyboard" );
157182 add_action (ref a11y_group, Schema . MEDIA , _(" Toggle Screenreader" ), " screenreader" );
158183
159- system_group = {};
184+ system_group = Group () {
185+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
186+ };
160187 system_group. icon_name = " preferences-system" ;
161188 system_group. label = _(" System" );
162189 add_action (ref system_group, Schema . GALA , _(" Applications Menu" ), " panel-main-menu" );
163190 add_action (ref system_group, Schema . MEDIA , _(" Lock" ), " screensaver" );
164191 add_action (ref system_group, Schema . MEDIA , _(" Log Out" ), " logout" );
165192 add_action (ref system_group, Schema . MUTTER , _(" Cycle display mode" ), " switch-monitor" );
166193
167- keyboard_layouts_group = {};
194+ keyboard_layouts_group = Group () {
195+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
196+ };
168197 keyboard_layouts_group. icon_name = " preferences-desktop-locale" ;
169198 keyboard_layouts_group. label = _(" Keyboard Layouts" );
170199 add_action (ref keyboard_layouts_group, Schema . GALA , _(" Switch Keyboard Layout" ), " switch-input-source" );
171200 add_action (ref keyboard_layouts_group, Schema . GALA , _(" Switch Keyboard Layout Backwards" ), " switch-input-source-backward" );
172201 add_action (ref keyboard_layouts_group, Schema . IBUS , _(" Enable Emoji Typing" ), " hotkey" );
173202 add_action (ref keyboard_layouts_group, Schema . IBUS , _(" Enable Unicode Typing" ), " unicode-hotkey" );
174203
175- custom_group = {};
204+ custom_group = Group () {
205+ list = new GLib .ListStore (typeof (Keyboard . Shortcuts . Action ))
206+ };
176207 custom_group. icon_name = " applications-other" ;
177208 custom_group. label = _(" Custom" );
178209
@@ -188,17 +219,16 @@ namespace Keyboard.Shortcuts {
188219 };
189220 }
190221
191- public void get_group (SectionID group , out string [] a , out Schema [] s , out string [] k ) {
192- a = groups[group]. actions;
193- s = groups[group]. schemas;
194- k = groups[group]. keys;
195- return ;
222+ public ListStore get_model (SectionID group ) {
223+ return groups[group]. list;
196224 }
197225
198226 public void add_action (ref Group group , Schema schema , string action , string key ) {
199- group. keys + = key;
200- group. schemas + = schema;
201- group. actions + = action;
227+ var action_object = new Keyboard .Shortcuts .Action (schema, action, key);
228+
229+ if (Settings . get_default (). valid (schema, key)) {
230+ group. list. append (action_object);
231+ }
202232 }
203233 }
204234}
0 commit comments