Merge lp:~3v1n0/unity/shortcuts-modeller into lp:unity
- shortcuts-modeller
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3058 |
Proposed branch: | lp:~3v1n0/unity/shortcuts-modeller |
Merge into: | lp:unity |
Diff against target: |
1568 lines (+689/-523) 14 files modified
plugins/unityshell/src/unityshell.cpp (+7/-277) plugins/unityshell/src/unityshell.h (+0/-6) po/POTFILES.in (+1/-0) shortcuts/AbstractShortcutModeller.h (+46/-0) shortcuts/CMakeLists.txt (+2/-0) shortcuts/CompizShortcutModeller.cpp (+301/-0) shortcuts/CompizShortcutModeller.h (+43/-0) shortcuts/ShortcutController.cpp (+22/-15) shortcuts/ShortcutController.h (+3/-4) shortcuts/ShortcutModel.cpp (+0/-1) shortcuts/ShortcutView.cpp (+12/-7) shortcuts/StandaloneShortcuts.cpp (+214/-200) tests/test_shortcut_controller.cpp (+30/-13) tests/test_shortcut_view.cpp (+8/-0) |
To merge this branch: | bzr merge lp:~3v1n0/unity/shortcuts-modeller |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Andrea Azzarone (community) | Approve | ||
Review via email: mp+144414@code.launchpad.net |
Commit message
ShortcutModeller: added a modeller that generates the shortcuts models for both compiz and standalone view
Description of the change
Using an abstract modeller to be passed to the ShortcutController to generate a model in a more dynamical way.
Added and updated tests.
Andrea Azzarone (azzar1) wrote : | # |
Andrea Azzarone (azzar1) wrote : | # |
793 + sigc::signal<void, Model::Ptr const&> model_changed;
? :)
Andrea Azzarone (azzar1) wrote : | # |
Code looks good. Tests pass.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
Preview Diff
1 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
2 | --- plugins/unityshell/src/unityshell.cpp 2013-01-21 14:38:56 +0000 |
3 | +++ plugins/unityshell/src/unityshell.cpp 2013-01-23 00:09:20 +0000 |
4 | @@ -45,6 +45,7 @@ |
5 | #include "launcher/XdndCollectionWindowImp.h" |
6 | #include "launcher/XdndManagerImp.h" |
7 | #include "launcher/XdndStartStopNotifierImp.h" |
8 | +#include "CompizShortcutModeller.h" |
9 | |
10 | #include <glib/gi18n-lib.h> |
11 | #include <gtk/gtk.h> |
12 | @@ -128,7 +129,6 @@ |
13 | , cScreen(CompositeScreen::get(screen)) |
14 | , gScreen(GLScreen::get(screen)) |
15 | , debugger_(this) |
16 | - , enable_shortcut_overlay_(true) |
17 | , needsRelayout(false) |
18 | , _in_paint(false) |
19 | , super_keypressed_(false) |
20 | @@ -1787,7 +1787,7 @@ |
21 | launcher_controller_->HandleLauncherKeyRelease(was_tap, when); |
22 | EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false); |
23 | |
24 | - shortcut_controller_->SetEnabled(enable_shortcut_overlay_); |
25 | + shortcut_controller_->SetEnabled(optionGetShortcutOverlay()); |
26 | shortcut_controller_->Hide(); |
27 | LOG_DEBUG(logger) << "Hiding shortcut controller"; |
28 | EnableCancelAction(CancelActionTarget::SHORTCUT_HINT, false); |
29 | @@ -2983,8 +2983,7 @@ |
30 | screen->leaveShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ()); |
31 | break; |
32 | case UnityshellOptions::ShortcutOverlay: |
33 | - enable_shortcut_overlay_ = optionGetShortcutOverlay(); |
34 | - shortcut_controller_->SetEnabled(enable_shortcut_overlay_); |
35 | + shortcut_controller_->SetEnabled(optionGetShortcutOverlay()); |
36 | break; |
37 | case UnityshellOptions::DecayRate: |
38 | launcher_options->edge_decay_rate = optionGetDecayRate() * 100; |
39 | @@ -3130,6 +3129,7 @@ |
40 | /* Setup Places */ |
41 | dash_controller_ = std::make_shared<dash::Controller>(); |
42 | dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized)); |
43 | + AddChild(dash_controller_.get()); |
44 | |
45 | /* Setup Hud */ |
46 | hud_controller_ = std::make_shared<hud::Controller>(); |
47 | @@ -3142,13 +3142,11 @@ |
48 | LOG_INFO(logger) << "initLauncher-hud " << timer.ElapsedSeconds() << "s"; |
49 | |
50 | // Setup Shortcut Hint |
51 | - InitHints(); |
52 | - auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>(); |
53 | - shortcut_controller_ = std::make_shared<shortcut::Controller>(hints_, base_window_raiser_); |
54 | + auto base_window_raiser = std::make_shared<shortcut::BaseWindowRaiserImp>(); |
55 | + auto shortcuts_modeller = std::make_shared<shortcut::CompizModeller>(); |
56 | + shortcut_controller_ = std::make_shared<shortcut::Controller>(base_window_raiser, shortcuts_modeller); |
57 | AddChild(shortcut_controller_.get()); |
58 | |
59 | - AddChild(dash_controller_.get()); |
60 | - |
61 | launcher_controller_->launcher().size_changed.connect([this] (nux::Area*, int w, int h) { |
62 | /* The launcher geometry includes 1px used to draw the right margin |
63 | * that must not be considered when drawing an overlay */ |
64 | @@ -3172,274 +3170,6 @@ |
65 | return launcher_controller_; |
66 | } |
67 | |
68 | -void UnityScreen::InitHints() |
69 | -{ |
70 | - // TODO move category text into a vector... |
71 | - |
72 | - // Compiz' plug-in names |
73 | - static const std::string COMPIZ_CORE_PLUGIN_NAME = "core"; |
74 | - static const std::string COMPIZ_EXPO_PLUGIN_NAME = "expo"; |
75 | - static const std::string COMPIZ_GRID_PLUGIN_NAME = "grid"; |
76 | - static const std::string COMPIZ_MOVE_PLUGIN_NAME = "move"; |
77 | - static const std::string COMPIZ_RESIZE_PLUGIN_NAME = "resize"; |
78 | - static const std::string COMPIZ_SCALE_PLUGIN_NAME = "scale"; |
79 | - static const std::string COMPIZ_UNITYSHELL_PLUGIN_NAME = "unityshell"; |
80 | - static const std::string COMPIZ_WALL_PLUGIN_NAME = "wall"; |
81 | - |
82 | - // Compiz Core Options |
83 | - static const std::string COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY = "show_desktop_key"; |
84 | - static const std::string COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY = "maximize_window_key"; |
85 | - static const std::string COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY = "unmaximize_window_key"; |
86 | - static const std::string COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY = "close_window_key"; |
87 | - static const std::string COMPIZ_CORE_OPTION_WINDOW_MENU_KEY = "window_menu_key"; |
88 | - |
89 | - // Compiz Expo Options |
90 | - static const std::string COMPIZ_EXPO_OPTION_EXPO_KEY = "expo_key"; |
91 | - |
92 | - // Compiz Grid Options |
93 | - static const std::string COMPIZ_GRID_OPTION_PUT_LEFT_KEY = "put_left_key"; |
94 | - |
95 | - // Compiz Move Options |
96 | - static const std::string COMPIZ_MOVE_OPTION_INITIATE_BUTTON = "initiate_button"; |
97 | - |
98 | - // Compiz Resize Options |
99 | - static const std::string COMPIZ_RESIZE_OPTION_INITIATE_BUTTON = "initiate_button"; |
100 | - |
101 | - // Compiz Scale Options |
102 | - static const std::string COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY = "initiate_all_key"; |
103 | - |
104 | - // Compiz Unityshell Options |
105 | - static const std::string COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER = "show_launcher"; |
106 | - static const std::string COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS = "keyboard_focus"; |
107 | - static const std::string COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward"; |
108 | - static const std::string COMPIZ_UNITYSHELL_OPTION_SHOW_HUD = "show_hud"; |
109 | - static const std::string COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu"; |
110 | - static const std::string COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward"; |
111 | - static const std::string COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window"; |
112 | - |
113 | - // Compiz Wall Options |
114 | - static const std::string COMPIZ_WALL_OPTION_LEFT_KEY = "left_key"; |
115 | - static const std::string COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY = "left_window_key"; |
116 | - |
117 | - |
118 | - // Launcher... |
119 | - static const std::string launcher(_("Launcher")); |
120 | - |
121 | - hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" (Hold)"), |
122 | - _("Opens the Launcher, displays shortcuts."), |
123 | - shortcut::OptionType::COMPIZ_KEY, |
124 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
125 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
126 | - |
127 | - hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "", |
128 | - _("Opens Launcher keyboard navigation mode."), |
129 | - shortcut::OptionType::COMPIZ_KEY, |
130 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
131 | - COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS)); |
132 | - |
133 | - hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "", |
134 | - _("Switches applications via the Launcher."), |
135 | - shortcut::OptionType::COMPIZ_KEY, |
136 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
137 | - COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD)); |
138 | - |
139 | - hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + 1 to 9"), |
140 | - _("Same as clicking on a Launcher icon."), |
141 | - shortcut::OptionType::COMPIZ_KEY, |
142 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
143 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
144 | - |
145 | - hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + Shift + 1 to 9"), |
146 | - _("Opens a new window in the app."), |
147 | - shortcut::OptionType::COMPIZ_KEY, |
148 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
149 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
150 | - |
151 | - hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", " + T", |
152 | - _("Opens the Trash."), |
153 | - shortcut::OptionType::COMPIZ_KEY, |
154 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
155 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
156 | - |
157 | - |
158 | - // Dash... |
159 | - static const std::string dash( _("Dash")); |
160 | - |
161 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", _(" (Tap)"), |
162 | - _("Opens the Dash Home."), |
163 | - shortcut::OptionType::COMPIZ_KEY, |
164 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
165 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
166 | - |
167 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + A", |
168 | - _("Opens the Dash App Lens."), |
169 | - shortcut::OptionType::COMPIZ_KEY, |
170 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
171 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
172 | - |
173 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + F", |
174 | - _("Opens the Dash Files Lens."), |
175 | - shortcut::OptionType::COMPIZ_KEY, |
176 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
177 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
178 | - |
179 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + M", |
180 | - _("Opens the Dash Music Lens."), |
181 | - shortcut::OptionType::COMPIZ_KEY, |
182 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
183 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
184 | - |
185 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + V", |
186 | - _("Opens the Dash Video Lens."), |
187 | - shortcut::OptionType::COMPIZ_KEY, |
188 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
189 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
190 | - |
191 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "", |
192 | - _("Switches between Lenses."), |
193 | - shortcut::OptionType::HARDCODED, |
194 | - _("Ctrl + Tab"))); |
195 | - |
196 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "", |
197 | - _("Moves the focus."), |
198 | - shortcut::OptionType::HARDCODED, |
199 | - _("Arrow Keys"))); |
200 | - |
201 | - hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "", |
202 | - _("Opens the currently focused item."), |
203 | - shortcut::OptionType::HARDCODED, |
204 | - _("Enter"))); |
205 | - |
206 | - // Menu Bar |
207 | - static const std::string menubar(_("HUD & Menu Bar")); |
208 | - |
209 | - hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Tap)"), |
210 | - _("Opens the HUD."), |
211 | - shortcut::OptionType::COMPIZ_KEY, |
212 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
213 | - COMPIZ_UNITYSHELL_OPTION_SHOW_HUD)); |
214 | - |
215 | - hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Hold)"), |
216 | - _("Reveals the application menu."), |
217 | - shortcut::OptionType::HARDCODED, |
218 | - "Alt")); |
219 | - |
220 | - hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", |
221 | - _("Opens the indicator menu."), |
222 | - shortcut::OptionType::COMPIZ_KEY, |
223 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
224 | - COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU)); |
225 | - |
226 | - hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", |
227 | - _("Moves focus between indicators."), |
228 | - shortcut::OptionType::HARDCODED, |
229 | - _("Cursor Left or Right"))); |
230 | - |
231 | - // Switching |
232 | - static const std::string switching(_("Switching")); |
233 | - |
234 | - hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
235 | - _("Switches between applications."), |
236 | - shortcut::OptionType::COMPIZ_KEY, |
237 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
238 | - COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD)); |
239 | - |
240 | - hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
241 | - _("Switches windows of current applications."), |
242 | - shortcut::OptionType::COMPIZ_KEY, |
243 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
244 | - COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW)); |
245 | - |
246 | - hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
247 | - _("Moves the focus."), |
248 | - shortcut::OptionType::HARDCODED, |
249 | - _("Cursor Left or Right"))); |
250 | - |
251 | - // Workspaces |
252 | - static const std::string workspaces(_("Workspaces")); |
253 | - |
254 | - hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", "", |
255 | - _("Switches between workspaces."), |
256 | - shortcut::OptionType::COMPIZ_KEY, |
257 | - COMPIZ_EXPO_PLUGIN_NAME, |
258 | - COMPIZ_EXPO_OPTION_EXPO_KEY)); |
259 | - |
260 | - hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"), |
261 | - _("Switches workspaces."), |
262 | - shortcut::OptionType::COMPIZ_KEY, |
263 | - COMPIZ_WALL_PLUGIN_NAME, |
264 | - COMPIZ_WALL_OPTION_LEFT_KEY)); |
265 | - |
266 | - hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"), |
267 | - _("Moves focused window to another workspace."), |
268 | - shortcut::OptionType::COMPIZ_KEY, |
269 | - COMPIZ_WALL_PLUGIN_NAME, |
270 | - COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY)); |
271 | - |
272 | - |
273 | - // Windows |
274 | - static const std::string windows(_("Windows")); |
275 | - |
276 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
277 | - _("Spreads all windows in the current workspace."), |
278 | - shortcut::OptionType::COMPIZ_KEY, |
279 | - COMPIZ_SCALE_PLUGIN_NAME, |
280 | - COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY)); |
281 | - |
282 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
283 | - _("Minimises all windows."), |
284 | - shortcut::OptionType::COMPIZ_KEY, |
285 | - COMPIZ_CORE_PLUGIN_NAME, |
286 | - COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY)); |
287 | - |
288 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
289 | - _("Maximises the current window."), |
290 | - shortcut::OptionType::COMPIZ_KEY, |
291 | - COMPIZ_CORE_PLUGIN_NAME, |
292 | - COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY)); |
293 | - |
294 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
295 | - _("Restores or minimises the current window."), |
296 | - shortcut::OptionType::COMPIZ_KEY, |
297 | - COMPIZ_CORE_PLUGIN_NAME, |
298 | - COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY)); |
299 | - |
300 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"), |
301 | - _("Semi-maximise the current window."), |
302 | - shortcut::OptionType::COMPIZ_KEY, |
303 | - COMPIZ_GRID_PLUGIN_NAME, |
304 | - COMPIZ_GRID_OPTION_PUT_LEFT_KEY)); |
305 | - |
306 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
307 | - _("Closes the current window."), |
308 | - shortcut::OptionType::COMPIZ_KEY, |
309 | - COMPIZ_CORE_PLUGIN_NAME, |
310 | - COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY)); |
311 | - |
312 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
313 | - _("Opens the window accessibility menu."), |
314 | - shortcut::OptionType::COMPIZ_KEY, |
315 | - COMPIZ_CORE_PLUGIN_NAME, |
316 | - COMPIZ_CORE_OPTION_WINDOW_MENU_KEY)); |
317 | - |
318 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
319 | - _("Places the window in corresponding position."), |
320 | - shortcut::OptionType::HARDCODED, |
321 | - _("Ctrl + Alt + Num"))); |
322 | - |
323 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"), |
324 | - _("Moves the window."), |
325 | - shortcut::OptionType::COMPIZ_MOUSE, |
326 | - COMPIZ_MOVE_PLUGIN_NAME, |
327 | - COMPIZ_MOVE_OPTION_INITIATE_BUTTON)); |
328 | - |
329 | - hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"), |
330 | - _("Resizes the window."), |
331 | - shortcut::OptionType::COMPIZ_MOUSE, |
332 | - COMPIZ_RESIZE_PLUGIN_NAME, |
333 | - COMPIZ_RESIZE_OPTION_INITIATE_BUTTON)); |
334 | -} |
335 | - |
336 | void UnityScreen::InitGesturesSupport() |
337 | { |
338 | std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker); |
339 | |
340 | === modified file 'plugins/unityshell/src/unityshell.h' |
341 | --- plugins/unityshell/src/unityshell.h 2012-12-19 09:45:55 +0000 |
342 | +++ plugins/unityshell/src/unityshell.h 2013-01-23 00:09:20 +0000 |
343 | @@ -43,7 +43,6 @@ |
344 | #include "FavoriteStoreGSettings.h" |
345 | #include "FontSettings.h" |
346 | #include "ShortcutController.h" |
347 | -#include "ShortcutHint.h" |
348 | #include "LauncherController.h" |
349 | #include "PanelController.h" |
350 | #include "PanelStyle.h" |
351 | @@ -240,8 +239,6 @@ |
352 | void RestoreWindow(GVariant* data); |
353 | bool SaveInputThenFocus(const guint xid); |
354 | |
355 | - void InitHints(); |
356 | - |
357 | void OnPanelStyleChanged(); |
358 | |
359 | void InitGesturesSupport(); |
360 | @@ -273,9 +270,6 @@ |
361 | shortcut::Controller::Ptr shortcut_controller_; |
362 | debug::DebugDBusInterface debugger_; |
363 | |
364 | - std::list<shortcut::AbstractHint::Ptr> hints_; |
365 | - bool enable_shortcut_overlay_; |
366 | - |
367 | /* Subscription for gestures that manipulate Unity launcher */ |
368 | std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_; |
369 | |
370 | |
371 | === modified file 'po/POTFILES.in' |
372 | --- po/POTFILES.in 2012-11-29 01:25:12 +0000 |
373 | +++ po/POTFILES.in 2013-01-23 00:09:20 +0000 |
374 | @@ -31,6 +31,7 @@ |
375 | plugins/unityshell/unityshell.xml.in |
376 | shortcuts/ShortcutHintPrivate.cpp |
377 | shortcuts/ShortcutView.cpp |
378 | +shortcuts/CompizShortcutsModeller.cpp |
379 | services/panel-service.c |
380 | unity-shared/DashStyle.cpp |
381 | unity-shared/SearchBar.cpp |
382 | |
383 | === added file 'shortcuts/AbstractShortcutModeller.h' |
384 | --- shortcuts/AbstractShortcutModeller.h 1970-01-01 00:00:00 +0000 |
385 | +++ shortcuts/AbstractShortcutModeller.h 2013-01-23 00:09:20 +0000 |
386 | @@ -0,0 +1,46 @@ |
387 | +/* |
388 | + * Copyright 2013 Canonical Ltd. |
389 | + * |
390 | + * This program is free software: you can redistribute it and/or modify it |
391 | + * under the terms of the GNU General Public License version 3, as published |
392 | + * by the Free Software Foundation. |
393 | + * |
394 | + * This program is distributed in the hope that it will be useful, but |
395 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
396 | + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
397 | + * PURPOSE. See the GNU General Public License for more details. |
398 | + * |
399 | + * You should have received a copy of the GNU General Public License |
400 | + * version 3 along with this program. If not, see |
401 | + * <http://www.gnu.org/licenses/> |
402 | + * |
403 | + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> |
404 | + */ |
405 | + |
406 | +#ifndef UNITYSHELL_ABSTRACT_SHORTCUT_MODELLER_H |
407 | +#define UNITYSHELL_ABSTRACT_SHORTCUT_MODELLER_H |
408 | + |
409 | +#include "ShortcutModel.h" |
410 | + |
411 | +namespace unity |
412 | +{ |
413 | +namespace shortcut |
414 | +{ |
415 | + |
416 | +class AbstractModeller : boost::noncopyable |
417 | +{ |
418 | +public: |
419 | + typedef std::shared_ptr<AbstractModeller> Ptr; |
420 | + |
421 | + AbstractModeller() {} |
422 | + virtual ~AbstractModeller() {} |
423 | + |
424 | + virtual Model::Ptr GetCurrentModel() const = 0; |
425 | + |
426 | + sigc::signal<void, Model::Ptr const&> model_changed; |
427 | +}; |
428 | + |
429 | +} |
430 | +} |
431 | + |
432 | +#endif |
433 | |
434 | === modified file 'shortcuts/CMakeLists.txt' |
435 | --- shortcuts/CMakeLists.txt 2012-12-19 20:53:12 +0000 |
436 | +++ shortcuts/CMakeLists.txt 2013-01-23 00:09:20 +0000 |
437 | @@ -18,7 +18,9 @@ |
438 | # |
439 | set (SHORTCUTS_SOURCES |
440 | AbstractShortcutHint.h |
441 | + AbstractShortcutModeller.h |
442 | BaseWindowRaiserImp.cpp |
443 | + CompizShortcutModeller.cpp |
444 | MockShortcutHint.h |
445 | ShortcutController.cpp |
446 | ShortcutController.h |
447 | |
448 | === added file 'shortcuts/CompizShortcutModeller.cpp' |
449 | --- shortcuts/CompizShortcutModeller.cpp 1970-01-01 00:00:00 +0000 |
450 | +++ shortcuts/CompizShortcutModeller.cpp 2013-01-23 00:09:20 +0000 |
451 | @@ -0,0 +1,301 @@ |
452 | +/* |
453 | + * Copyright 2013 Canonical Ltd. |
454 | + * |
455 | + * This program is free software: you can redistribute it and/or modify it |
456 | + * under the terms of the GNU General Public License version 3, as published |
457 | + * by the Free Software Foundation. |
458 | + * |
459 | + * This program is distributed in the hope that it will be useful, but |
460 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
461 | + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
462 | + * PURPOSE. See the GNU General Public License for more details. |
463 | + * |
464 | + * You should have received a copy of the GNU General Public License |
465 | + * version 3 along with this program. If not, see |
466 | + * <http://www.gnu.org/licenses/> |
467 | + * |
468 | + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> |
469 | + */ |
470 | + |
471 | +#include "config.h" |
472 | +#include <glib/gi18n-lib.h> |
473 | +#include "CompizShortcutModeller.h" |
474 | +#include "ShortcutHint.h" |
475 | + |
476 | +namespace unity |
477 | +{ |
478 | +namespace shortcut |
479 | +{ |
480 | +namespace |
481 | +{ |
482 | + // Compiz' plug-in names |
483 | + const std::string CORE_PLUGIN_NAME = "core"; |
484 | + const std::string EXPO_PLUGIN_NAME = "expo"; |
485 | + const std::string GRID_PLUGIN_NAME = "grid"; |
486 | + const std::string MOVE_PLUGIN_NAME = "move"; |
487 | + const std::string RESIZE_PLUGIN_NAME = "resize"; |
488 | + const std::string SCALE_PLUGIN_NAME = "scale"; |
489 | + const std::string UNITYSHELL_PLUGIN_NAME = "unityshell"; |
490 | + const std::string WALL_PLUGIN_NAME = "wall"; |
491 | + |
492 | + // Compiz Core Options |
493 | + const std::string CORE_OPTION_SHOW_DESKTOP_KEY = "show_desktop_key"; |
494 | + const std::string CORE_OPTION_MAXIMIZE_WINDOW_KEY = "maximize_window_key"; |
495 | + const std::string CORE_OPTION_UNMAXIMIZE_WINDOW_KEY = "unmaximize_window_key"; |
496 | + const std::string CORE_OPTION_CLOSE_WINDOW_KEY = "close_window_key"; |
497 | + const std::string CORE_OPTION_WINDOW_MENU_KEY = "window_menu_key"; |
498 | + |
499 | + // Compiz Expo Options |
500 | + const std::string EXPO_OPTION_EXPO_KEY = "expo_key"; |
501 | + |
502 | + // Compiz Grid Options |
503 | + const std::string GRID_OPTION_PUT_LEFT_KEY = "put_left_key"; |
504 | + |
505 | + // Compiz Move Options |
506 | + const std::string MOVE_OPTION_INITIATE_BUTTON = "initiate_button"; |
507 | + |
508 | + // Compiz Resize Options |
509 | + const std::string RESIZE_OPTION_INITIATE_BUTTON = "initiate_button"; |
510 | + |
511 | + // Compiz Scale Options |
512 | + const std::string SCALE_OPTION_INITIATE_ALL_KEY = "initiate_all_key"; |
513 | + |
514 | + // Compiz Unityshell Options |
515 | + const std::string UNITYSHELL_OPTION_SHOW_LAUNCHER = "show_launcher"; |
516 | + const std::string UNITYSHELL_OPTION_KEYBOARD_FOCUS = "keyboard_focus"; |
517 | + const std::string UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward"; |
518 | + const std::string UNITYSHELL_OPTION_SHOW_HUD = "show_hud"; |
519 | + const std::string UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu"; |
520 | + const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward"; |
521 | + const std::string UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window"; |
522 | + |
523 | + // Compiz Wall Options |
524 | + const std::string WALL_OPTION_LEFT_KEY = "left_key"; |
525 | + const std::string WALL_OPTION_LEFT_WINDOW_KEY = "left_window_key"; |
526 | +} |
527 | + |
528 | +CompizModeller::CompizModeller() |
529 | +{ |
530 | + // Launcher... |
531 | + const std::string launcher(_("Launcher")); |
532 | + |
533 | + std::list<shortcut::AbstractHint::Ptr> hints; |
534 | + hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" (Hold)"), |
535 | + _("Opens the Launcher, displays shortcuts."), |
536 | + shortcut::OptionType::COMPIZ_KEY, |
537 | + UNITYSHELL_PLUGIN_NAME, |
538 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
539 | + |
540 | + hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", "", |
541 | + _("Opens Launcher keyboard navigation mode."), |
542 | + shortcut::OptionType::COMPIZ_KEY, |
543 | + UNITYSHELL_PLUGIN_NAME, |
544 | + UNITYSHELL_OPTION_KEYBOARD_FOCUS)); |
545 | + |
546 | + hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", "", |
547 | + _("Switches applications via the Launcher."), |
548 | + shortcut::OptionType::COMPIZ_KEY, |
549 | + UNITYSHELL_PLUGIN_NAME, |
550 | + UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD)); |
551 | + |
552 | + hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + 1 to 9"), |
553 | + _("Same as clicking on a Launcher icon."), |
554 | + shortcut::OptionType::COMPIZ_KEY, |
555 | + UNITYSHELL_PLUGIN_NAME, |
556 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
557 | + |
558 | + hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + Shift + 1 to 9"), |
559 | + _("Opens a new window in the app."), |
560 | + shortcut::OptionType::COMPIZ_KEY, |
561 | + UNITYSHELL_PLUGIN_NAME, |
562 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
563 | + |
564 | + hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", " + T", |
565 | + _("Opens the Trash."), |
566 | + shortcut::OptionType::COMPIZ_KEY, |
567 | + UNITYSHELL_PLUGIN_NAME, |
568 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
569 | + |
570 | + |
571 | + // Dash... |
572 | + static const std::string dash( _("Dash")); |
573 | + |
574 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", _(" (Tap)"), |
575 | + _("Opens the Dash Home."), |
576 | + shortcut::OptionType::COMPIZ_KEY, |
577 | + UNITYSHELL_PLUGIN_NAME, |
578 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
579 | + |
580 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + A", |
581 | + _("Opens the Dash App Lens."), |
582 | + shortcut::OptionType::COMPIZ_KEY, |
583 | + UNITYSHELL_PLUGIN_NAME, |
584 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
585 | + |
586 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + F", |
587 | + _("Opens the Dash Files Lens."), |
588 | + shortcut::OptionType::COMPIZ_KEY, |
589 | + UNITYSHELL_PLUGIN_NAME, |
590 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
591 | + |
592 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + M", |
593 | + _("Opens the Dash Music Lens."), |
594 | + shortcut::OptionType::COMPIZ_KEY, |
595 | + UNITYSHELL_PLUGIN_NAME, |
596 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
597 | + |
598 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + V", |
599 | + _("Opens the Dash Video Lens."), |
600 | + shortcut::OptionType::COMPIZ_KEY, |
601 | + UNITYSHELL_PLUGIN_NAME, |
602 | + UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
603 | + |
604 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", "", |
605 | + _("Switches between Lenses."), |
606 | + shortcut::OptionType::HARDCODED, |
607 | + _("Ctrl + Tab"))); |
608 | + |
609 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", "", |
610 | + _("Moves the focus."), |
611 | + shortcut::OptionType::HARDCODED, |
612 | + _("Arrow Keys"))); |
613 | + |
614 | + hints.push_back(std::make_shared<shortcut::Hint>(dash, "", "", |
615 | + _("Opens the currently focused item."), |
616 | + shortcut::OptionType::HARDCODED, |
617 | + _("Enter"))); |
618 | + |
619 | + // Menu Bar |
620 | + static const std::string menubar(_("HUD & Menu Bar")); |
621 | + |
622 | + hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Tap)"), |
623 | + _("Opens the HUD."), |
624 | + shortcut::OptionType::COMPIZ_KEY, |
625 | + UNITYSHELL_PLUGIN_NAME, |
626 | + UNITYSHELL_OPTION_SHOW_HUD)); |
627 | + |
628 | + hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Hold)"), |
629 | + _("Reveals the application menu."), |
630 | + shortcut::OptionType::HARDCODED, |
631 | + "Alt")); |
632 | + |
633 | + hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", |
634 | + _("Opens the indicator menu."), |
635 | + shortcut::OptionType::COMPIZ_KEY, |
636 | + UNITYSHELL_PLUGIN_NAME, |
637 | + UNITYSHELL_OPTION_PANEL_FIRST_MENU)); |
638 | + |
639 | + hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", |
640 | + _("Moves focus between indicators."), |
641 | + shortcut::OptionType::HARDCODED, |
642 | + _("Cursor Left or Right"))); |
643 | + |
644 | + // Switching |
645 | + static const std::string switching(_("Switching")); |
646 | + |
647 | + hints.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
648 | + _("Switches between applications."), |
649 | + shortcut::OptionType::COMPIZ_KEY, |
650 | + UNITYSHELL_PLUGIN_NAME, |
651 | + UNITYSHELL_OPTION_ALT_TAB_FORWARD)); |
652 | + |
653 | + hints.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
654 | + _("Switches windows of current applications."), |
655 | + shortcut::OptionType::COMPIZ_KEY, |
656 | + UNITYSHELL_PLUGIN_NAME, |
657 | + UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW)); |
658 | + |
659 | + hints.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
660 | + _("Moves the focus."), |
661 | + shortcut::OptionType::HARDCODED, |
662 | + _("Cursor Left or Right"))); |
663 | + |
664 | + // Workspaces |
665 | + static const std::string workspaces(_("Workspaces")); |
666 | + |
667 | + hints.push_back(std::make_shared<shortcut::Hint>(workspaces, "", "", |
668 | + _("Switches between workspaces."), |
669 | + shortcut::OptionType::COMPIZ_KEY, |
670 | + EXPO_PLUGIN_NAME, |
671 | + EXPO_OPTION_EXPO_KEY)); |
672 | + |
673 | + hints.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"), |
674 | + _("Switches workspaces."), |
675 | + shortcut::OptionType::COMPIZ_KEY, |
676 | + WALL_PLUGIN_NAME, |
677 | + WALL_OPTION_LEFT_KEY)); |
678 | + |
679 | + hints.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"), |
680 | + _("Moves focused window to another workspace."), |
681 | + shortcut::OptionType::COMPIZ_KEY, |
682 | + WALL_PLUGIN_NAME, |
683 | + WALL_OPTION_LEFT_WINDOW_KEY)); |
684 | + |
685 | + |
686 | + // Windows |
687 | + static const std::string windows(_("Windows")); |
688 | + |
689 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
690 | + _("Spreads all windows in the current workspace."), |
691 | + shortcut::OptionType::COMPIZ_KEY, |
692 | + SCALE_PLUGIN_NAME, |
693 | + SCALE_OPTION_INITIATE_ALL_KEY)); |
694 | + |
695 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
696 | + _("Minimises all windows."), |
697 | + shortcut::OptionType::COMPIZ_KEY, |
698 | + CORE_PLUGIN_NAME, |
699 | + CORE_OPTION_SHOW_DESKTOP_KEY)); |
700 | + |
701 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
702 | + _("Maximises the current window."), |
703 | + shortcut::OptionType::COMPIZ_KEY, |
704 | + CORE_PLUGIN_NAME, |
705 | + CORE_OPTION_MAXIMIZE_WINDOW_KEY)); |
706 | + |
707 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
708 | + _("Restores or minimises the current window."), |
709 | + shortcut::OptionType::COMPIZ_KEY, |
710 | + CORE_PLUGIN_NAME, |
711 | + CORE_OPTION_UNMAXIMIZE_WINDOW_KEY)); |
712 | + |
713 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"), |
714 | + _("Semi-maximise the current window."), |
715 | + shortcut::OptionType::COMPIZ_KEY, |
716 | + GRID_PLUGIN_NAME, |
717 | + GRID_OPTION_PUT_LEFT_KEY)); |
718 | + |
719 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
720 | + _("Closes the current window."), |
721 | + shortcut::OptionType::COMPIZ_KEY, |
722 | + CORE_PLUGIN_NAME, |
723 | + CORE_OPTION_CLOSE_WINDOW_KEY)); |
724 | + |
725 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
726 | + _("Opens the window accessibility menu."), |
727 | + shortcut::OptionType::COMPIZ_KEY, |
728 | + CORE_PLUGIN_NAME, |
729 | + CORE_OPTION_WINDOW_MENU_KEY)); |
730 | + |
731 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
732 | + _("Places the window in corresponding position."), |
733 | + shortcut::OptionType::HARDCODED, |
734 | + _("Ctrl + Alt + Num"))); |
735 | + |
736 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"), |
737 | + _("Moves the window."), |
738 | + shortcut::OptionType::COMPIZ_MOUSE, |
739 | + MOVE_PLUGIN_NAME, |
740 | + MOVE_OPTION_INITIATE_BUTTON)); |
741 | + |
742 | + hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"), |
743 | + _("Resizes the window."), |
744 | + shortcut::OptionType::COMPIZ_MOUSE, |
745 | + RESIZE_PLUGIN_NAME, |
746 | + RESIZE_OPTION_INITIATE_BUTTON)); |
747 | + |
748 | + model_ = std::make_shared<shortcut::Model>(hints); |
749 | +} |
750 | + |
751 | +} |
752 | +} |
753 | |
754 | === added file 'shortcuts/CompizShortcutModeller.h' |
755 | --- shortcuts/CompizShortcutModeller.h 1970-01-01 00:00:00 +0000 |
756 | +++ shortcuts/CompizShortcutModeller.h 2013-01-23 00:09:20 +0000 |
757 | @@ -0,0 +1,43 @@ |
758 | +/* |
759 | + * Copyright 2013 Canonical Ltd. |
760 | + * |
761 | + * This program is free software: you can redistribute it and/or modify it |
762 | + * under the terms of the GNU General Public License version 3, as published |
763 | + * by the Free Software Foundation. |
764 | + * |
765 | + * This program is distributed in the hope that it will be useful, but |
766 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
767 | + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR |
768 | + * PURPOSE. See the GNU General Public License for more details. |
769 | + * |
770 | + * You should have received a copy of the GNU General Public License |
771 | + * version 3 along with this program. If not, see |
772 | + * <http://www.gnu.org/licenses/> |
773 | + * |
774 | + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> |
775 | + */ |
776 | + |
777 | +#ifndef UNITYSHELL_COMPIZ_SHORTCUT_MODELLER_H |
778 | +#define UNITYSHELL_COMPIZ_SHORTCUT_MODELLER_H |
779 | + |
780 | +#include "AbstractShortcutModeller.h" |
781 | + |
782 | +namespace unity |
783 | +{ |
784 | +namespace shortcut |
785 | +{ |
786 | + |
787 | +class CompizModeller : public AbstractModeller |
788 | +{ |
789 | +public: |
790 | + CompizModeller(); |
791 | + Model::Ptr GetCurrentModel() const {return model_;} |
792 | + |
793 | +private: |
794 | + Model::Ptr model_; |
795 | +}; |
796 | + |
797 | +} |
798 | +} |
799 | + |
800 | +#endif |
801 | |
802 | === modified file 'shortcuts/ShortcutController.cpp' |
803 | --- shortcuts/ShortcutController.cpp 2013-01-21 16:12:58 +0000 |
804 | +++ shortcuts/ShortcutController.cpp 2013-01-23 00:09:20 +0000 |
805 | @@ -18,6 +18,7 @@ |
806 | */ |
807 | |
808 | #include "ShortcutController.h" |
809 | +#include "ShortcutModel.h" |
810 | |
811 | #include "unity-shared/UBusMessages.h" |
812 | #include "unity-shared/UScreen.h" |
813 | @@ -34,17 +35,15 @@ |
814 | const unsigned int FADE_DURATION = 100; |
815 | } |
816 | |
817 | -Controller::Controller(std::list<AbstractHint::Ptr> const& hints, |
818 | - BaseWindowRaiser::Ptr const& base_window_raiser) |
819 | - : model_(std::make_shared<Model>(hints)) |
820 | +Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser, |
821 | + AbstractModeller::Ptr const& modeller) |
822 | + : modeller_(modeller) |
823 | , base_window_raiser_(base_window_raiser) |
824 | , visible_(false) |
825 | , enabled_(true) |
826 | , bg_color_(0.0, 0.0, 0.0, 0.5) |
827 | , fade_animator_(FADE_DURATION) |
828 | { |
829 | - model_->Fill(); |
830 | - |
831 | ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, |
832 | sigc::mem_fun(this, &Controller::OnBackgroundUpdate)); |
833 | |
834 | @@ -65,6 +64,16 @@ |
835 | fade_animator_.updated.connect([this] (double opacity) { |
836 | SetOpacity(opacity); |
837 | }); |
838 | + |
839 | + modeller->model_changed.connect([this] (Model::Ptr const& model) { |
840 | + if (!view_) |
841 | + return; |
842 | + |
843 | + if (visible_) |
844 | + model->Fill(); |
845 | + |
846 | + view_->SetModel(model); |
847 | + }); |
848 | } |
849 | |
850 | Controller::~Controller() |
851 | @@ -82,12 +91,9 @@ |
852 | |
853 | bool Controller::Show() |
854 | { |
855 | - if (enabled_) |
856 | + if (enabled_ && modeller_->GetCurrentModel()) |
857 | { |
858 | - EnsureView(); |
859 | - |
860 | show_timer_.reset(new glib::Timeout(SUPER_TAP_DURATION, sigc::mem_fun(this, &Controller::OnShowTimer))); |
861 | - model_->Fill(); |
862 | visible_ = true; |
863 | |
864 | return true; |
865 | @@ -98,10 +104,11 @@ |
866 | |
867 | bool Controller::OnShowTimer() |
868 | { |
869 | - if (!enabled_) |
870 | + if (!enabled_ || !modeller_->GetCurrentModel()) |
871 | return false; |
872 | |
873 | - base_window_raiser_->Raise(view_window_); |
874 | + modeller_->GetCurrentModel()->Fill(); |
875 | + EnsureView(); |
876 | |
877 | int monitor = UScreen::GetDefault()->GetMonitorWithMouse(); |
878 | auto const& geo = GetGeometryPerMonitor(monitor); |
879 | @@ -109,6 +116,7 @@ |
880 | if (geo.IsNull()) |
881 | return false; |
882 | |
883 | + base_window_raiser_->Raise(view_window_); |
884 | view_window_->SetGeometry(geo); |
885 | |
886 | if (visible_) |
887 | @@ -131,8 +139,7 @@ |
888 | |
889 | nux::Geometry Controller::GetGeometryPerMonitor(int monitor) |
890 | { |
891 | - if (!view_) |
892 | - ConstructView(); |
893 | + EnsureView(); |
894 | |
895 | auto const& view_geo = view_->GetAbsoluteGeometry(); |
896 | auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor); |
897 | @@ -154,7 +161,7 @@ |
898 | { |
899 | view_ = View::Ptr(new View()); |
900 | AddChild(view_.GetPointer()); |
901 | - view_->SetModel(model_); |
902 | + view_->SetModel(modeller_->GetCurrentModel()); |
903 | view_->background_color = bg_color_; |
904 | |
905 | if (!view_window_) |
906 | @@ -165,7 +172,7 @@ |
907 | |
908 | view_window_ = new nux::BaseWindow("ShortcutHint"); |
909 | view_window_->SetLayout(main_layout_); |
910 | - view_window_->SetBackgroundColor(nux::Color(0x00000000)); |
911 | + view_window_->SetBackgroundColor(nux::color::Transparent); |
912 | } |
913 | |
914 | main_layout_->AddView(view_.GetPointer()); |
915 | |
916 | === modified file 'shortcuts/ShortcutController.h' |
917 | --- shortcuts/ShortcutController.h 2013-01-21 16:06:36 +0000 |
918 | +++ shortcuts/ShortcutController.h 2013-01-23 00:09:20 +0000 |
919 | @@ -30,7 +30,7 @@ |
920 | #include <UnityCore/GLibSource.h> |
921 | |
922 | #include "BaseWindowRaiser.h" |
923 | -#include "ShortcutModel.h" |
924 | +#include "AbstractShortcutModeller.h" |
925 | #include "ShortcutView.h" |
926 | #include "unity-shared/Introspectable.h" |
927 | #include "unity-shared/UBusWrapper.h" |
928 | @@ -45,8 +45,7 @@ |
929 | public: |
930 | typedef std::shared_ptr<Controller> Ptr; |
931 | |
932 | - Controller(std::list<AbstractHint::Ptr> const& hints, |
933 | - BaseWindowRaiser::Ptr const& raiser); |
934 | + Controller(BaseWindowRaiser::Ptr const& raiser, AbstractModeller::Ptr const& modeller); |
935 | virtual ~Controller(); |
936 | |
937 | bool Show(); |
938 | @@ -72,7 +71,7 @@ |
939 | bool OnShowTimer(); |
940 | |
941 | View::Ptr view_; |
942 | - Model::Ptr model_; |
943 | + AbstractModeller::Ptr modeller_; |
944 | BaseWindowRaiser::Ptr base_window_raiser_; |
945 | |
946 | nux::Geometry workarea_; |
947 | |
948 | === modified file 'shortcuts/ShortcutModel.cpp' |
949 | --- shortcuts/ShortcutModel.cpp 2013-01-19 00:25:07 +0000 |
950 | +++ shortcuts/ShortcutModel.cpp 2013-01-23 00:09:20 +0000 |
951 | @@ -50,7 +50,6 @@ |
952 | hints_[hint->category()].push_back(hint); |
953 | } |
954 | |
955 | - |
956 | void Model::Fill() |
957 | { |
958 | for (auto const& category : categories_) |
959 | |
960 | === modified file 'shortcuts/ShortcutView.cpp' |
961 | --- shortcuts/ShortcutView.cpp 2013-01-21 21:12:57 +0000 |
962 | +++ shortcuts/ShortcutView.cpp 2013-01-23 00:09:20 +0000 |
963 | @@ -94,7 +94,9 @@ |
964 | void View::SetModel(Model::Ptr model) |
965 | { |
966 | model_ = model; |
967 | - model_->categories_per_column.changed.connect(sigc::hide(sigc::mem_fun(this, &View::RenderColumns))); |
968 | + |
969 | + if (model_) |
970 | + model_->categories_per_column.changed.connect(sigc::hide(sigc::mem_fun(this, &View::RenderColumns))); |
971 | |
972 | // Fills the columns... |
973 | RenderColumns(); |
974 | @@ -186,13 +188,10 @@ |
975 | |
976 | nux::Geometry View::GetBackgroundGeometry() |
977 | { |
978 | - nux::Geometry base = GetGeometry(); |
979 | - nux::Geometry background_geo; |
980 | + nux::Geometry background_geo = GetGeometry(); |
981 | |
982 | - background_geo.width = base.width; |
983 | - background_geo.height = base.height; |
984 | - background_geo.x = (base.width - background_geo.width)/2; |
985 | - background_geo.y = (base.height - background_geo.height)/2; |
986 | + background_geo.x = 0; |
987 | + background_geo.y = 0; |
988 | |
989 | return background_geo; |
990 | } |
991 | @@ -206,6 +205,12 @@ |
992 | { |
993 | columns_layout_->Clear(); |
994 | |
995 | + if (!model_) |
996 | + { |
997 | + QueueRelayout(); |
998 | + return; |
999 | + } |
1000 | + |
1001 | int i = 0; |
1002 | int column_idx = 0; |
1003 | auto const& columns = columns_layout_->GetChildren(); |
1004 | |
1005 | === modified file 'shortcuts/StandaloneShortcuts.cpp' |
1006 | --- shortcuts/StandaloneShortcuts.cpp 2013-01-21 16:07:47 +0000 |
1007 | +++ shortcuts/StandaloneShortcuts.cpp 2013-01-23 00:09:20 +0000 |
1008 | @@ -39,9 +39,8 @@ |
1009 | { |
1010 | struct StandaloneController : Controller |
1011 | { |
1012 | - StandaloneController(std::list<AbstractHint::Ptr> const& hints, |
1013 | - BaseWindowRaiser::Ptr const& raiser) |
1014 | - : Controller(hints, raiser) |
1015 | + StandaloneController(BaseWindowRaiser::Ptr const& raiser, AbstractModeller::Ptr const& modeller) |
1016 | + : Controller(raiser, modeller) |
1017 | {} |
1018 | |
1019 | nux::Geometry GetGeometryPerMonitor(int monitor) override |
1020 | @@ -52,6 +51,216 @@ |
1021 | } |
1022 | } |
1023 | |
1024 | +struct StandaloneModeller : shortcut::AbstractModeller |
1025 | +{ |
1026 | + StandaloneModeller() |
1027 | + { |
1028 | + std::list<shortcut::AbstractHint::Ptr> hints; |
1029 | + |
1030 | + // Launcher... |
1031 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" (Hold)"), |
1032 | + _("Opens the Launcher, displays shortcuts."), |
1033 | + shortcut::OptionType::COMPIZ_KEY, |
1034 | + "unityshell", |
1035 | + "show_launcher" ))); |
1036 | + |
1037 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "", |
1038 | + _("Opens Launcher keyboard navigation mode."), |
1039 | + shortcut::OptionType::COMPIZ_KEY, |
1040 | + "unityshell", |
1041 | + "keyboard_focus"))); |
1042 | + |
1043 | + // FIXME: Implemstd::shared_ptr<shortcut::AbstractHint>(ent it... |
1044 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "", |
1045 | + _("Switches applications via the Launcher."), |
1046 | + shortcut::OptionType::HARDCODED, |
1047 | + "Super + Tab"))); |
1048 | + |
1049 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + 1 to 9"), |
1050 | + _("Same as clicking on a Launcher icon."), |
1051 | + shortcut::OptionType::COMPIZ_KEY, |
1052 | + "unityshell", |
1053 | + "show_launcher"))); |
1054 | + |
1055 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + Shift + 1 to 9"), |
1056 | + _("Opens a new window in the app."), |
1057 | + shortcut::OptionType::COMPIZ_KEY, |
1058 | + "unityshell", |
1059 | + "show_launcher"))); |
1060 | + |
1061 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", " + T", |
1062 | + _("Opens the Trash."), |
1063 | + shortcut::OptionType::COMPIZ_KEY, |
1064 | + "unityshell", |
1065 | + "show_launcher"))); |
1066 | + |
1067 | + // Dash... |
1068 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", _(" (Tap)"), |
1069 | + _("Opens the Dash Home."), |
1070 | + shortcut::OptionType::COMPIZ_KEY, |
1071 | + "unityshell", |
1072 | + "show_launcher"))); |
1073 | + |
1074 | + // These are notstd::shared_ptr<shortcut::AbstractHint>( really hardcoded... |
1075 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + A", |
1076 | + _("Opens the Dash App Lens."), |
1077 | + shortcut::OptionType::COMPIZ_KEY, |
1078 | + "unityshell", |
1079 | + "show_launcher"))); |
1080 | + |
1081 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + F", |
1082 | + _("Opens the Dash Files Lens."), |
1083 | + shortcut::OptionType::COMPIZ_KEY, |
1084 | + "unityshell", |
1085 | + "show_launcher"))); |
1086 | + |
1087 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + M", |
1088 | + _("Opens the Dash Music Lens."), |
1089 | + shortcut::OptionType::COMPIZ_KEY, |
1090 | + "unityshell", |
1091 | + "show_launcher"))); |
1092 | + |
1093 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "", |
1094 | + _("Switches between Lenses."), |
1095 | + shortcut::OptionType::HARDCODED, |
1096 | + "Ctrl + Tab"))); |
1097 | + |
1098 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "", |
1099 | + _("Moves the focus."), |
1100 | + shortcut::OptionType::HARDCODED, |
1101 | + _("Arrow Keys")))); |
1102 | + |
1103 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "", |
1104 | + _("Opens the currently focused item."), |
1105 | + shortcut::OptionType::HARDCODED, |
1106 | + _("Enter")))); |
1107 | + |
1108 | + // Hud Menu Bar |
1109 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Tap)"), |
1110 | + _("Opens the HUD."), |
1111 | + shortcut::OptionType::COMPIZ_KEY, |
1112 | + "unityshell", |
1113 | + "show_hud"))); |
1114 | + |
1115 | + // Is it really std::shared_ptr<shortcut::AbstractHint>(hard coded? |
1116 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Hold)"), |
1117 | + _("Reveals the application menu."), |
1118 | + shortcut::OptionType::HARDCODED, |
1119 | + "Alt"))); |
1120 | + |
1121 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "", |
1122 | + _("Opens the indicator menu."), |
1123 | + shortcut::OptionType::COMPIZ_KEY, |
1124 | + "unityshell", |
1125 | + "panel_first_menu"))); |
1126 | + |
1127 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "", |
1128 | + _("Moves focus between indicators."), |
1129 | + shortcut::OptionType::HARDCODED, |
1130 | + _("Cursor Left or Right")))); |
1131 | + |
1132 | + // Switching |
1133 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "", |
1134 | + _("Switches between applications."), |
1135 | + shortcut::OptionType::COMPIZ_KEY, |
1136 | + "unityshell", |
1137 | + "alt_tab_forward"))); |
1138 | + |
1139 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "", |
1140 | + _("Switches windows of current applications."), |
1141 | + shortcut::OptionType::COMPIZ_KEY, |
1142 | + "unityshell", |
1143 | + "alt_tab_next_window"))); |
1144 | + |
1145 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "", |
1146 | + _("Moves the focus."), |
1147 | + shortcut::OptionType::HARDCODED, |
1148 | + _("Cursor Left or Right")))); |
1149 | + |
1150 | + // Workspaces |
1151 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "", |
1152 | + _("Switches between workspaces."), |
1153 | + shortcut::OptionType::COMPIZ_KEY, |
1154 | + "expo", |
1155 | + "expo_key"))); |
1156 | + |
1157 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "", |
1158 | + _("Switches workspaces."), |
1159 | + shortcut::OptionType::HARDCODED, |
1160 | + _("Arrow Keys")))); |
1161 | + |
1162 | + //hints.push_bacstd::shared_ptr<shortcut::AbstractHint>(k(new shortcut::MockHint(_("Workspaces"), "", "", _("Move focused window to other workspace."), ...) |
1163 | + |
1164 | + // Windows |
1165 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1166 | + _("Spreads all windows in the current workspace."), |
1167 | + shortcut::OptionType::COMPIZ_KEY, |
1168 | + "scale", |
1169 | + "initiate_output_key"))); |
1170 | + |
1171 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1172 | + _("Minimises all windows."), |
1173 | + shortcut::OptionType::COMPIZ_KEY, |
1174 | + "core", |
1175 | + "show_desktop_key"))); |
1176 | + |
1177 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1178 | + _("Maximises the current window."), |
1179 | + shortcut::OptionType::COMPIZ_KEY, |
1180 | + "core", |
1181 | + "maximize_window_key"))); |
1182 | + |
1183 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1184 | + _("Restores or minimises the current window."), |
1185 | + shortcut::OptionType::COMPIZ_KEY, |
1186 | + "core", |
1187 | + "unmaximize_window_key"))); |
1188 | + |
1189 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", _(" or Right"), |
1190 | + _("Semi-maximises the current window."), |
1191 | + shortcut::OptionType::COMPIZ_KEY, |
1192 | + "grid", |
1193 | + "put_left_key"))); |
1194 | + |
1195 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1196 | + _("Closes the current window."), |
1197 | + shortcut::OptionType::COMPIZ_KEY, |
1198 | + "core", |
1199 | + "close_window_key"))); |
1200 | + |
1201 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1202 | + _("Opens the window accessibility menu."), |
1203 | + shortcut::OptionType::COMPIZ_KEY, |
1204 | + "core", |
1205 | + "window_menu_key"))); |
1206 | + |
1207 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1208 | + _("Places the window in corresponding position."), |
1209 | + shortcut::OptionType::HARDCODED, |
1210 | + "Ctrl + Alt + Num"))); |
1211 | + |
1212 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1213 | + _("Moves the window."), |
1214 | + shortcut::OptionType::COMPIZ_KEY, |
1215 | + "move", |
1216 | + "initiate_key"))); |
1217 | + |
1218 | + hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1219 | + _("Resizes the current window."), |
1220 | + shortcut::OptionType::COMPIZ_KEY, |
1221 | + "resize", |
1222 | + "initiate_key"))); |
1223 | + model = std::make_shared<shortcut::Model>(hints); |
1224 | + } |
1225 | + |
1226 | + shortcut::Model::Ptr GetCurrentModel() const |
1227 | + { |
1228 | + return model; |
1229 | + } |
1230 | + |
1231 | + shortcut::Model::Ptr model; |
1232 | +}; |
1233 | + |
1234 | struct ShortcutsWindow |
1235 | { |
1236 | ShortcutsWindow() |
1237 | @@ -82,204 +291,9 @@ |
1238 | void ShortcutsWindow::Init() |
1239 | { |
1240 | BackgroundEffectHelper::blur_type = BLUR_NONE; |
1241 | - std::list<std::shared_ptr<shortcut::AbstractHint>> hints; |
1242 | - |
1243 | - // Launcher... |
1244 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" (Hold)"), |
1245 | - _("Opens the Launcher, displays shortcuts."), |
1246 | - shortcut::OptionType::COMPIZ_KEY, |
1247 | - "unityshell", |
1248 | - "show_launcher" ))); |
1249 | - |
1250 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "", |
1251 | - _("Opens Launcher keyboard navigation mode."), |
1252 | - shortcut::OptionType::COMPIZ_KEY, |
1253 | - "unityshell", |
1254 | - "keyboard_focus"))); |
1255 | - |
1256 | - // FIXME: Implemstd::shared_ptr<shortcut::AbstractHint>(ent it... |
1257 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "", |
1258 | - _("Switches applications via the Launcher."), |
1259 | - shortcut::OptionType::HARDCODED, |
1260 | - "Super + Tab"))); |
1261 | - |
1262 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + 1 to 9"), |
1263 | - _("Same as clicking on a Launcher icon."), |
1264 | - shortcut::OptionType::COMPIZ_KEY, |
1265 | - "unityshell", |
1266 | - "show_launcher"))); |
1267 | - |
1268 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + Shift + 1 to 9"), |
1269 | - _("Opens a new window in the app."), |
1270 | - shortcut::OptionType::COMPIZ_KEY, |
1271 | - "unityshell", |
1272 | - "show_launcher"))); |
1273 | - |
1274 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", " + T", |
1275 | - _("Opens the Trash."), |
1276 | - shortcut::OptionType::COMPIZ_KEY, |
1277 | - "unityshell", |
1278 | - "show_launcher"))); |
1279 | - |
1280 | - // Dash... |
1281 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", _(" (Tap)"), |
1282 | - _("Opens the Dash Home."), |
1283 | - shortcut::OptionType::COMPIZ_KEY, |
1284 | - "unityshell", |
1285 | - "show_launcher"))); |
1286 | - |
1287 | - // These are notstd::shared_ptr<shortcut::AbstractHint>( really hardcoded... |
1288 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + A", |
1289 | - _("Opens the Dash App Lens."), |
1290 | - shortcut::OptionType::COMPIZ_KEY, |
1291 | - "unityshell", |
1292 | - "show_launcher"))); |
1293 | - |
1294 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + F", |
1295 | - _("Opens the Dash Files Lens."), |
1296 | - shortcut::OptionType::COMPIZ_KEY, |
1297 | - "unityshell", |
1298 | - "show_launcher"))); |
1299 | - |
1300 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + M", |
1301 | - _("Opens the Dash Music Lens."), |
1302 | - shortcut::OptionType::COMPIZ_KEY, |
1303 | - "unityshell", |
1304 | - "show_launcher"))); |
1305 | - |
1306 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "", |
1307 | - _("Switches between Lenses."), |
1308 | - shortcut::OptionType::HARDCODED, |
1309 | - "Ctrl + Tab"))); |
1310 | - |
1311 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "", |
1312 | - _("Moves the focus."), |
1313 | - shortcut::OptionType::HARDCODED, |
1314 | - _("Arrow Keys")))); |
1315 | - |
1316 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "", |
1317 | - _("Opens the currently focused item."), |
1318 | - shortcut::OptionType::HARDCODED, |
1319 | - _("Enter")))); |
1320 | - |
1321 | - // Hud Menu Bar |
1322 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Tap)"), |
1323 | - _("Opens the HUD."), |
1324 | - shortcut::OptionType::COMPIZ_KEY, |
1325 | - "unityshell", |
1326 | - "show_hud"))); |
1327 | - |
1328 | - // Is it really std::shared_ptr<shortcut::AbstractHint>(hard coded? |
1329 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Hold)"), |
1330 | - _("Reveals the application menu."), |
1331 | - shortcut::OptionType::HARDCODED, |
1332 | - "Alt"))); |
1333 | - |
1334 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "", |
1335 | - _("Opens the indicator menu."), |
1336 | - shortcut::OptionType::COMPIZ_KEY, |
1337 | - "unityshell", |
1338 | - "panel_first_menu"))); |
1339 | - |
1340 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "", |
1341 | - _("Moves focus between indicators."), |
1342 | - shortcut::OptionType::HARDCODED, |
1343 | - _("Cursor Left or Right")))); |
1344 | - |
1345 | - // Switching |
1346 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "", |
1347 | - _("Switches between applications."), |
1348 | - shortcut::OptionType::COMPIZ_KEY, |
1349 | - "unityshell", |
1350 | - "alt_tab_forward"))); |
1351 | - |
1352 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "", |
1353 | - _("Switches windows of current applications."), |
1354 | - shortcut::OptionType::COMPIZ_KEY, |
1355 | - "unityshell", |
1356 | - "alt_tab_next_window"))); |
1357 | - |
1358 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "", |
1359 | - _("Moves the focus."), |
1360 | - shortcut::OptionType::HARDCODED, |
1361 | - _("Cursor Left or Right")))); |
1362 | - |
1363 | - // Workspaces |
1364 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "", |
1365 | - _("Switches between workspaces."), |
1366 | - shortcut::OptionType::COMPIZ_KEY, |
1367 | - "expo", |
1368 | - "expo_key"))); |
1369 | - |
1370 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "", |
1371 | - _("Switches workspaces."), |
1372 | - shortcut::OptionType::HARDCODED, |
1373 | - _("Arrow Keys")))); |
1374 | - |
1375 | - //hints.push_bacstd::shared_ptr<shortcut::AbstractHint>(k(new shortcut::MockHint(_("Workspaces"), "", "", _("Move focused window to other workspace."), ...) |
1376 | - |
1377 | - // Windows |
1378 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1379 | - _("Spreads all windows in the current workspace."), |
1380 | - shortcut::OptionType::COMPIZ_KEY, |
1381 | - "scale", |
1382 | - "initiate_output_key"))); |
1383 | - |
1384 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1385 | - _("Minimises all windows."), |
1386 | - shortcut::OptionType::COMPIZ_KEY, |
1387 | - "core", |
1388 | - "show_desktop_key"))); |
1389 | - |
1390 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1391 | - _("Maximises the current window."), |
1392 | - shortcut::OptionType::COMPIZ_KEY, |
1393 | - "core", |
1394 | - "maximize_window_key"))); |
1395 | - |
1396 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1397 | - _("Restores or minimises the current window."), |
1398 | - shortcut::OptionType::COMPIZ_KEY, |
1399 | - "core", |
1400 | - "unmaximize_window_key"))); |
1401 | - |
1402 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", _(" or Right"), |
1403 | - _("Semi-maximises the current window."), |
1404 | - shortcut::OptionType::COMPIZ_KEY, |
1405 | - "grid", |
1406 | - "put_left_key"))); |
1407 | - |
1408 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1409 | - _("Closes the current window."), |
1410 | - shortcut::OptionType::COMPIZ_KEY, |
1411 | - "core", |
1412 | - "close_window_key"))); |
1413 | - |
1414 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1415 | - _("Opens the window accessibility menu."), |
1416 | - shortcut::OptionType::COMPIZ_KEY, |
1417 | - "core", |
1418 | - "window_menu_key"))); |
1419 | - |
1420 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1421 | - _("Places the window in corresponding position."), |
1422 | - shortcut::OptionType::HARDCODED, |
1423 | - "Ctrl + Alt + Num"))); |
1424 | - |
1425 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1426 | - _("Moves the window."), |
1427 | - shortcut::OptionType::COMPIZ_KEY, |
1428 | - "move", |
1429 | - "initiate_key"))); |
1430 | - |
1431 | - hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "", |
1432 | - _("Resizes the current window."), |
1433 | - shortcut::OptionType::COMPIZ_KEY, |
1434 | - "resize", |
1435 | - "initiate_key"))); |
1436 | - |
1437 | auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>(); |
1438 | - controller = std::make_shared<shortcut::StandaloneController>(hints, base_window_raiser_); |
1439 | + auto modeller = std::make_shared<StandaloneModeller>(); |
1440 | + controller = std::make_shared<shortcut::StandaloneController>(base_window_raiser_, modeller); |
1441 | controller->Show(); |
1442 | } |
1443 | |
1444 | |
1445 | === modified file 'tests/test_shortcut_controller.cpp' |
1446 | --- tests/test_shortcut_controller.cpp 2013-01-21 16:08:34 +0000 |
1447 | +++ tests/test_shortcut_controller.cpp 2013-01-23 00:09:20 +0000 |
1448 | @@ -39,6 +39,14 @@ |
1449 | |
1450 | MOCK_METHOD1 (Raise, void(nux::ObjectPtr<nux::BaseWindow> window)); |
1451 | }; |
1452 | + |
1453 | +struct StandaloneModeller : shortcut::AbstractModeller |
1454 | +{ |
1455 | + shortcut::Model::Ptr GetCurrentModel() const |
1456 | + { |
1457 | + return std::make_shared<shortcut::Model>(std::list<shortcut::AbstractHint::Ptr>()); |
1458 | + } |
1459 | +}; |
1460 | } |
1461 | |
1462 | namespace unity |
1463 | @@ -49,9 +57,9 @@ |
1464 | { |
1465 | struct MockShortcutController : public Controller |
1466 | { |
1467 | - MockShortcutController(std::list<AbstractHint::Ptr> const& hints, |
1468 | - BaseWindowRaiser::Ptr const& base_window_raiser) |
1469 | - : Controller(hints, base_window_raiser) |
1470 | + MockShortcutController(BaseWindowRaiser::Ptr const& base_window_raiser, |
1471 | + AbstractModeller::Ptr const& modeller) |
1472 | + : Controller(base_window_raiser, modeller) |
1473 | {} |
1474 | |
1475 | MOCK_METHOD1(SetOpacity, void(double)); |
1476 | @@ -67,8 +75,9 @@ |
1477 | |
1478 | public: |
1479 | TestShortcutController() |
1480 | - : base_window_raiser_(std::make_shared<MockBaseWindowRaiser>()) |
1481 | - , controller_(hints_, base_window_raiser_) |
1482 | + : base_window_raiser_(std::make_shared<NiceMock<MockBaseWindowRaiser>>()) |
1483 | + , modeller_(std::make_shared<StandaloneModeller>()) |
1484 | + , controller_(base_window_raiser_, modeller_) |
1485 | , animation_controller_(tick_source_) |
1486 | { |
1487 | ON_CALL(controller_, SetOpacity(_)) |
1488 | @@ -77,15 +86,15 @@ |
1489 | |
1490 | MockUScreen uscreen; |
1491 | Settings unity_settings; |
1492 | - std::list<shortcut::AbstractHint::Ptr> hints_; |
1493 | MockBaseWindowRaiser::Ptr base_window_raiser_; |
1494 | + AbstractModeller::Ptr const& modeller_; |
1495 | NiceMock<MockShortcutController> controller_; |
1496 | |
1497 | nux::animation::TickSource tick_source_; |
1498 | nux::animation::AnimationController animation_controller_; |
1499 | }; |
1500 | |
1501 | -TEST_F (TestShortcutController, WindowIsRaisedOnShow) |
1502 | +TEST_F(TestShortcutController, WindowIsRaisedOnShow) |
1503 | { |
1504 | EXPECT_CALL(*base_window_raiser_, Raise(_)) |
1505 | .Times(1); |
1506 | @@ -94,8 +103,7 @@ |
1507 | Utils::WaitForTimeout(1); |
1508 | } |
1509 | |
1510 | - |
1511 | -TEST_F (TestShortcutController, Hide) |
1512 | +TEST_F(TestShortcutController, HiddeenOnConstruction) |
1513 | { |
1514 | { |
1515 | InSequence sequence; |
1516 | @@ -105,13 +113,11 @@ |
1517 | .Times(0); |
1518 | } |
1519 | |
1520 | - controller_.Show(); |
1521 | - |
1522 | + controller_.ConstructView(); |
1523 | controller_.Hide(); |
1524 | - tick_source_.tick(1000); |
1525 | } |
1526 | |
1527 | -TEST_F (TestShortcutController, GetGeometryPerMonitor) |
1528 | +TEST_F(TestShortcutController, GetGeometryPerMonitor) |
1529 | { |
1530 | nux::Geometry good_monitor(0, 0, 1366, 768); |
1531 | nux::Geometry invalid_monitor(good_monitor.x + good_monitor.width, 0, 1, 1); |
1532 | @@ -129,6 +135,17 @@ |
1533 | EXPECT_TRUE(controller_.GetGeometryPerMonitor(1).IsNull()); |
1534 | } |
1535 | |
1536 | +TEST_F(TestShortcutController, ModelIsChangedOnModellerChange) |
1537 | +{ |
1538 | + controller_.ConstructView(); |
1539 | + auto old_model = controller_.view_->GetModel(); |
1540 | + auto model = std::make_shared<Model>(std::list<AbstractHint::Ptr>()); |
1541 | + modeller_->model_changed(model); |
1542 | + |
1543 | + ASSERT_NE(controller_.view_->GetModel(), old_model); |
1544 | + EXPECT_EQ(controller_.view_->GetModel(), model); |
1545 | +} |
1546 | + |
1547 | |
1548 | } |
1549 | } |
1550 | |
1551 | === modified file 'tests/test_shortcut_view.cpp' |
1552 | --- tests/test_shortcut_view.cpp 2013-01-21 21:12:57 +0000 |
1553 | +++ tests/test_shortcut_view.cpp 2013-01-23 00:09:20 +0000 |
1554 | @@ -73,6 +73,14 @@ |
1555 | EXPECT_FALSE(model->categories_per_column.changed.empty()); |
1556 | } |
1557 | |
1558 | +TEST_F(TestShortcutView, SetNullModel) |
1559 | +{ |
1560 | + view.SetModel(GetMockModel({}, 0)); |
1561 | + view.SetModel(nullptr); |
1562 | + EXPECT_EQ(view.GetModel(), nullptr); |
1563 | + EXPECT_TRUE(view.columns_layout_->GetChildren().empty()); |
1564 | +} |
1565 | + |
1566 | TEST_F(TestShortcutView, SettingModelAddsColumns) |
1567 | { |
1568 | auto model = GetMockModel({"Cat1", "Cat2"}, 1); |
+ AbstractModeller() {}
empty ctor?