Merge lp:~3v1n0/unity/shortcuts-modeller into lp:unity

Proposed by Marco Trevisan (Treviño)
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
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.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+ AbstractModeller() {}

empty ctor?

Revision history for this message
Andrea Azzarone (azzar1) wrote :

793 + sigc::signal<void, Model::Ptr const&> model_changed;

? :)

Revision history for this message
Andrea Azzarone (azzar1) wrote :

Code looks good. Tests pass.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2013-01-21 14:38:56 +0000
+++ plugins/unityshell/src/unityshell.cpp 2013-01-23 00:09:20 +0000
@@ -45,6 +45,7 @@
45#include "launcher/XdndCollectionWindowImp.h"45#include "launcher/XdndCollectionWindowImp.h"
46#include "launcher/XdndManagerImp.h"46#include "launcher/XdndManagerImp.h"
47#include "launcher/XdndStartStopNotifierImp.h"47#include "launcher/XdndStartStopNotifierImp.h"
48#include "CompizShortcutModeller.h"
4849
49#include <glib/gi18n-lib.h>50#include <glib/gi18n-lib.h>
50#include <gtk/gtk.h>51#include <gtk/gtk.h>
@@ -128,7 +129,6 @@
128 , cScreen(CompositeScreen::get(screen))129 , cScreen(CompositeScreen::get(screen))
129 , gScreen(GLScreen::get(screen))130 , gScreen(GLScreen::get(screen))
130 , debugger_(this)131 , debugger_(this)
131 , enable_shortcut_overlay_(true)
132 , needsRelayout(false)132 , needsRelayout(false)
133 , _in_paint(false)133 , _in_paint(false)
134 , super_keypressed_(false)134 , super_keypressed_(false)
@@ -1787,7 +1787,7 @@
1787 launcher_controller_->HandleLauncherKeyRelease(was_tap, when);1787 launcher_controller_->HandleLauncherKeyRelease(was_tap, when);
1788 EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false);1788 EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false);
17891789
1790 shortcut_controller_->SetEnabled(enable_shortcut_overlay_);1790 shortcut_controller_->SetEnabled(optionGetShortcutOverlay());
1791 shortcut_controller_->Hide();1791 shortcut_controller_->Hide();
1792 LOG_DEBUG(logger) << "Hiding shortcut controller";1792 LOG_DEBUG(logger) << "Hiding shortcut controller";
1793 EnableCancelAction(CancelActionTarget::SHORTCUT_HINT, false);1793 EnableCancelAction(CancelActionTarget::SHORTCUT_HINT, false);
@@ -2983,8 +2983,7 @@
2983 screen->leaveShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ());2983 screen->leaveShowDesktopModeSetEnabled (this, optionGetShowMinimizedWindows ());
2984 break;2984 break;
2985 case UnityshellOptions::ShortcutOverlay:2985 case UnityshellOptions::ShortcutOverlay:
2986 enable_shortcut_overlay_ = optionGetShortcutOverlay();2986 shortcut_controller_->SetEnabled(optionGetShortcutOverlay());
2987 shortcut_controller_->SetEnabled(enable_shortcut_overlay_);
2988 break;2987 break;
2989 case UnityshellOptions::DecayRate:2988 case UnityshellOptions::DecayRate:
2990 launcher_options->edge_decay_rate = optionGetDecayRate() * 100;2989 launcher_options->edge_decay_rate = optionGetDecayRate() * 100;
@@ -3130,6 +3129,7 @@
3130 /* Setup Places */3129 /* Setup Places */
3131 dash_controller_ = std::make_shared<dash::Controller>();3130 dash_controller_ = std::make_shared<dash::Controller>();
3132 dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized));3131 dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized));
3132 AddChild(dash_controller_.get());
31333133
3134 /* Setup Hud */3134 /* Setup Hud */
3135 hud_controller_ = std::make_shared<hud::Controller>();3135 hud_controller_ = std::make_shared<hud::Controller>();
@@ -3142,13 +3142,11 @@
3142 LOG_INFO(logger) << "initLauncher-hud " << timer.ElapsedSeconds() << "s";3142 LOG_INFO(logger) << "initLauncher-hud " << timer.ElapsedSeconds() << "s";
31433143
3144 // Setup Shortcut Hint3144 // Setup Shortcut Hint
3145 InitHints();3145 auto base_window_raiser = std::make_shared<shortcut::BaseWindowRaiserImp>();
3146 auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>();3146 auto shortcuts_modeller = std::make_shared<shortcut::CompizModeller>();
3147 shortcut_controller_ = std::make_shared<shortcut::Controller>(hints_, base_window_raiser_);3147 shortcut_controller_ = std::make_shared<shortcut::Controller>(base_window_raiser, shortcuts_modeller);
3148 AddChild(shortcut_controller_.get());3148 AddChild(shortcut_controller_.get());
31493149
3150 AddChild(dash_controller_.get());
3151
3152 launcher_controller_->launcher().size_changed.connect([this] (nux::Area*, int w, int h) {3150 launcher_controller_->launcher().size_changed.connect([this] (nux::Area*, int w, int h) {
3153 /* The launcher geometry includes 1px used to draw the right margin3151 /* The launcher geometry includes 1px used to draw the right margin
3154 * that must not be considered when drawing an overlay */3152 * that must not be considered when drawing an overlay */
@@ -3172,274 +3170,6 @@
3172 return launcher_controller_;3170 return launcher_controller_;
3173}3171}
31743172
3175void UnityScreen::InitHints()
3176{
3177 // TODO move category text into a vector...
3178
3179 // Compiz' plug-in names
3180 static const std::string COMPIZ_CORE_PLUGIN_NAME = "core";
3181 static const std::string COMPIZ_EXPO_PLUGIN_NAME = "expo";
3182 static const std::string COMPIZ_GRID_PLUGIN_NAME = "grid";
3183 static const std::string COMPIZ_MOVE_PLUGIN_NAME = "move";
3184 static const std::string COMPIZ_RESIZE_PLUGIN_NAME = "resize";
3185 static const std::string COMPIZ_SCALE_PLUGIN_NAME = "scale";
3186 static const std::string COMPIZ_UNITYSHELL_PLUGIN_NAME = "unityshell";
3187 static const std::string COMPIZ_WALL_PLUGIN_NAME = "wall";
3188
3189 // Compiz Core Options
3190 static const std::string COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY = "show_desktop_key";
3191 static const std::string COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY = "maximize_window_key";
3192 static const std::string COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY = "unmaximize_window_key";
3193 static const std::string COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY = "close_window_key";
3194 static const std::string COMPIZ_CORE_OPTION_WINDOW_MENU_KEY = "window_menu_key";
3195
3196 // Compiz Expo Options
3197 static const std::string COMPIZ_EXPO_OPTION_EXPO_KEY = "expo_key";
3198
3199 // Compiz Grid Options
3200 static const std::string COMPIZ_GRID_OPTION_PUT_LEFT_KEY = "put_left_key";
3201
3202 // Compiz Move Options
3203 static const std::string COMPIZ_MOVE_OPTION_INITIATE_BUTTON = "initiate_button";
3204
3205 // Compiz Resize Options
3206 static const std::string COMPIZ_RESIZE_OPTION_INITIATE_BUTTON = "initiate_button";
3207
3208 // Compiz Scale Options
3209 static const std::string COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY = "initiate_all_key";
3210
3211 // Compiz Unityshell Options
3212 static const std::string COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER = "show_launcher";
3213 static const std::string COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS = "keyboard_focus";
3214 static const std::string COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward";
3215 static const std::string COMPIZ_UNITYSHELL_OPTION_SHOW_HUD = "show_hud";
3216 static const std::string COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";
3217 static const std::string COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";
3218 static const std::string COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";
3219
3220 // Compiz Wall Options
3221 static const std::string COMPIZ_WALL_OPTION_LEFT_KEY = "left_key";
3222 static const std::string COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY = "left_window_key";
3223
3224
3225 // Launcher...
3226 static const std::string launcher(_("Launcher"));
3227
3228 hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" (Hold)"),
3229 _("Opens the Launcher, displays shortcuts."),
3230 shortcut::OptionType::COMPIZ_KEY,
3231 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3232 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3233
3234 hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "",
3235 _("Opens Launcher keyboard navigation mode."),
3236 shortcut::OptionType::COMPIZ_KEY,
3237 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3238 COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS));
3239
3240 hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "",
3241 _("Switches applications via the Launcher."),
3242 shortcut::OptionType::COMPIZ_KEY,
3243 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3244 COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD));
3245
3246 hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + 1 to 9"),
3247 _("Same as clicking on a Launcher icon."),
3248 shortcut::OptionType::COMPIZ_KEY,
3249 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3250 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3251
3252 hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + Shift + 1 to 9"),
3253 _("Opens a new window in the app."),
3254 shortcut::OptionType::COMPIZ_KEY,
3255 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3256 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3257
3258 hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", " + T",
3259 _("Opens the Trash."),
3260 shortcut::OptionType::COMPIZ_KEY,
3261 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3262 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3263
3264
3265 // Dash...
3266 static const std::string dash( _("Dash"));
3267
3268 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", _(" (Tap)"),
3269 _("Opens the Dash Home."),
3270 shortcut::OptionType::COMPIZ_KEY,
3271 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3272 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3273
3274 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + A",
3275 _("Opens the Dash App Lens."),
3276 shortcut::OptionType::COMPIZ_KEY,
3277 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3278 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3279
3280 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + F",
3281 _("Opens the Dash Files Lens."),
3282 shortcut::OptionType::COMPIZ_KEY,
3283 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3284 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3285
3286 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + M",
3287 _("Opens the Dash Music Lens."),
3288 shortcut::OptionType::COMPIZ_KEY,
3289 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3290 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3291
3292 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + V",
3293 _("Opens the Dash Video Lens."),
3294 shortcut::OptionType::COMPIZ_KEY,
3295 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3296 COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER));
3297
3298 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "",
3299 _("Switches between Lenses."),
3300 shortcut::OptionType::HARDCODED,
3301 _("Ctrl + Tab")));
3302
3303 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "",
3304 _("Moves the focus."),
3305 shortcut::OptionType::HARDCODED,
3306 _("Arrow Keys")));
3307
3308 hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "",
3309 _("Opens the currently focused item."),
3310 shortcut::OptionType::HARDCODED,
3311 _("Enter")));
3312
3313 // Menu Bar
3314 static const std::string menubar(_("HUD & Menu Bar"));
3315
3316 hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Tap)"),
3317 _("Opens the HUD."),
3318 shortcut::OptionType::COMPIZ_KEY,
3319 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3320 COMPIZ_UNITYSHELL_OPTION_SHOW_HUD));
3321
3322 hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Hold)"),
3323 _("Reveals the application menu."),
3324 shortcut::OptionType::HARDCODED,
3325 "Alt"));
3326
3327 hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "",
3328 _("Opens the indicator menu."),
3329 shortcut::OptionType::COMPIZ_KEY,
3330 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3331 COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU));
3332
3333 hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "",
3334 _("Moves focus between indicators."),
3335 shortcut::OptionType::HARDCODED,
3336 _("Cursor Left or Right")));
3337
3338 // Switching
3339 static const std::string switching(_("Switching"));
3340
3341 hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
3342 _("Switches between applications."),
3343 shortcut::OptionType::COMPIZ_KEY,
3344 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3345 COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD));
3346
3347 hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
3348 _("Switches windows of current applications."),
3349 shortcut::OptionType::COMPIZ_KEY,
3350 COMPIZ_UNITYSHELL_PLUGIN_NAME,
3351 COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW));
3352
3353 hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
3354 _("Moves the focus."),
3355 shortcut::OptionType::HARDCODED,
3356 _("Cursor Left or Right")));
3357
3358 // Workspaces
3359 static const std::string workspaces(_("Workspaces"));
3360
3361 hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", "",
3362 _("Switches between workspaces."),
3363 shortcut::OptionType::COMPIZ_KEY,
3364 COMPIZ_EXPO_PLUGIN_NAME,
3365 COMPIZ_EXPO_OPTION_EXPO_KEY));
3366
3367 hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"),
3368 _("Switches workspaces."),
3369 shortcut::OptionType::COMPIZ_KEY,
3370 COMPIZ_WALL_PLUGIN_NAME,
3371 COMPIZ_WALL_OPTION_LEFT_KEY));
3372
3373 hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"),
3374 _("Moves focused window to another workspace."),
3375 shortcut::OptionType::COMPIZ_KEY,
3376 COMPIZ_WALL_PLUGIN_NAME,
3377 COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY));
3378
3379
3380 // Windows
3381 static const std::string windows(_("Windows"));
3382
3383 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
3384 _("Spreads all windows in the current workspace."),
3385 shortcut::OptionType::COMPIZ_KEY,
3386 COMPIZ_SCALE_PLUGIN_NAME,
3387 COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY));
3388
3389 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
3390 _("Minimises all windows."),
3391 shortcut::OptionType::COMPIZ_KEY,
3392 COMPIZ_CORE_PLUGIN_NAME,
3393 COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY));
3394
3395 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
3396 _("Maximises the current window."),
3397 shortcut::OptionType::COMPIZ_KEY,
3398 COMPIZ_CORE_PLUGIN_NAME,
3399 COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY));
3400
3401 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
3402 _("Restores or minimises the current window."),
3403 shortcut::OptionType::COMPIZ_KEY,
3404 COMPIZ_CORE_PLUGIN_NAME,
3405 COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY));
3406
3407 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"),
3408 _("Semi-maximise the current window."),
3409 shortcut::OptionType::COMPIZ_KEY,
3410 COMPIZ_GRID_PLUGIN_NAME,
3411 COMPIZ_GRID_OPTION_PUT_LEFT_KEY));
3412
3413 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
3414 _("Closes the current window."),
3415 shortcut::OptionType::COMPIZ_KEY,
3416 COMPIZ_CORE_PLUGIN_NAME,
3417 COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY));
3418
3419 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
3420 _("Opens the window accessibility menu."),
3421 shortcut::OptionType::COMPIZ_KEY,
3422 COMPIZ_CORE_PLUGIN_NAME,
3423 COMPIZ_CORE_OPTION_WINDOW_MENU_KEY));
3424
3425 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
3426 _("Places the window in corresponding position."),
3427 shortcut::OptionType::HARDCODED,
3428 _("Ctrl + Alt + Num")));
3429
3430 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"),
3431 _("Moves the window."),
3432 shortcut::OptionType::COMPIZ_MOUSE,
3433 COMPIZ_MOVE_PLUGIN_NAME,
3434 COMPIZ_MOVE_OPTION_INITIATE_BUTTON));
3435
3436 hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"),
3437 _("Resizes the window."),
3438 shortcut::OptionType::COMPIZ_MOUSE,
3439 COMPIZ_RESIZE_PLUGIN_NAME,
3440 COMPIZ_RESIZE_OPTION_INITIATE_BUTTON));
3441}
3442
3443void UnityScreen::InitGesturesSupport()3173void UnityScreen::InitGesturesSupport()
3444{3174{
3445 std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker);3175 std::unique_ptr<nux::GestureBroker> gesture_broker(new UnityGestureBroker);
34463176
=== modified file 'plugins/unityshell/src/unityshell.h'
--- plugins/unityshell/src/unityshell.h 2012-12-19 09:45:55 +0000
+++ plugins/unityshell/src/unityshell.h 2013-01-23 00:09:20 +0000
@@ -43,7 +43,6 @@
43#include "FavoriteStoreGSettings.h"43#include "FavoriteStoreGSettings.h"
44#include "FontSettings.h"44#include "FontSettings.h"
45#include "ShortcutController.h"45#include "ShortcutController.h"
46#include "ShortcutHint.h"
47#include "LauncherController.h"46#include "LauncherController.h"
48#include "PanelController.h"47#include "PanelController.h"
49#include "PanelStyle.h"48#include "PanelStyle.h"
@@ -240,8 +239,6 @@
240 void RestoreWindow(GVariant* data);239 void RestoreWindow(GVariant* data);
241 bool SaveInputThenFocus(const guint xid);240 bool SaveInputThenFocus(const guint xid);
242241
243 void InitHints();
244
245 void OnPanelStyleChanged();242 void OnPanelStyleChanged();
246243
247 void InitGesturesSupport();244 void InitGesturesSupport();
@@ -273,9 +270,6 @@
273 shortcut::Controller::Ptr shortcut_controller_;270 shortcut::Controller::Ptr shortcut_controller_;
274 debug::DebugDBusInterface debugger_;271 debug::DebugDBusInterface debugger_;
275272
276 std::list<shortcut::AbstractHint::Ptr> hints_;
277 bool enable_shortcut_overlay_;
278
279 /* Subscription for gestures that manipulate Unity launcher */273 /* Subscription for gestures that manipulate Unity launcher */
280 std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_;274 std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_;
281275
282276
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2012-11-29 01:25:12 +0000
+++ po/POTFILES.in 2013-01-23 00:09:20 +0000
@@ -31,6 +31,7 @@
31plugins/unityshell/unityshell.xml.in31plugins/unityshell/unityshell.xml.in
32shortcuts/ShortcutHintPrivate.cpp32shortcuts/ShortcutHintPrivate.cpp
33shortcuts/ShortcutView.cpp33shortcuts/ShortcutView.cpp
34shortcuts/CompizShortcutsModeller.cpp
34services/panel-service.c35services/panel-service.c
35unity-shared/DashStyle.cpp36unity-shared/DashStyle.cpp
36unity-shared/SearchBar.cpp37unity-shared/SearchBar.cpp
3738
=== added file 'shortcuts/AbstractShortcutModeller.h'
--- shortcuts/AbstractShortcutModeller.h 1970-01-01 00:00:00 +0000
+++ shortcuts/AbstractShortcutModeller.h 2013-01-23 00:09:20 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#ifndef UNITYSHELL_ABSTRACT_SHORTCUT_MODELLER_H
21#define UNITYSHELL_ABSTRACT_SHORTCUT_MODELLER_H
22
23#include "ShortcutModel.h"
24
25namespace unity
26{
27namespace shortcut
28{
29
30class AbstractModeller : boost::noncopyable
31{
32public:
33 typedef std::shared_ptr<AbstractModeller> Ptr;
34
35 AbstractModeller() {}
36 virtual ~AbstractModeller() {}
37
38 virtual Model::Ptr GetCurrentModel() const = 0;
39
40 sigc::signal<void, Model::Ptr const&> model_changed;
41};
42
43}
44}
45
46#endif
047
=== modified file 'shortcuts/CMakeLists.txt'
--- shortcuts/CMakeLists.txt 2012-12-19 20:53:12 +0000
+++ shortcuts/CMakeLists.txt 2013-01-23 00:09:20 +0000
@@ -18,7 +18,9 @@
18#18#
19set (SHORTCUTS_SOURCES19set (SHORTCUTS_SOURCES
20 AbstractShortcutHint.h20 AbstractShortcutHint.h
21 AbstractShortcutModeller.h
21 BaseWindowRaiserImp.cpp22 BaseWindowRaiserImp.cpp
23 CompizShortcutModeller.cpp
22 MockShortcutHint.h24 MockShortcutHint.h
23 ShortcutController.cpp25 ShortcutController.cpp
24 ShortcutController.h26 ShortcutController.h
2527
=== added file 'shortcuts/CompizShortcutModeller.cpp'
--- shortcuts/CompizShortcutModeller.cpp 1970-01-01 00:00:00 +0000
+++ shortcuts/CompizShortcutModeller.cpp 2013-01-23 00:09:20 +0000
@@ -0,0 +1,301 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#include "config.h"
21#include <glib/gi18n-lib.h>
22#include "CompizShortcutModeller.h"
23#include "ShortcutHint.h"
24
25namespace unity
26{
27namespace shortcut
28{
29namespace
30{
31 // Compiz' plug-in names
32 const std::string CORE_PLUGIN_NAME = "core";
33 const std::string EXPO_PLUGIN_NAME = "expo";
34 const std::string GRID_PLUGIN_NAME = "grid";
35 const std::string MOVE_PLUGIN_NAME = "move";
36 const std::string RESIZE_PLUGIN_NAME = "resize";
37 const std::string SCALE_PLUGIN_NAME = "scale";
38 const std::string UNITYSHELL_PLUGIN_NAME = "unityshell";
39 const std::string WALL_PLUGIN_NAME = "wall";
40
41 // Compiz Core Options
42 const std::string CORE_OPTION_SHOW_DESKTOP_KEY = "show_desktop_key";
43 const std::string CORE_OPTION_MAXIMIZE_WINDOW_KEY = "maximize_window_key";
44 const std::string CORE_OPTION_UNMAXIMIZE_WINDOW_KEY = "unmaximize_window_key";
45 const std::string CORE_OPTION_CLOSE_WINDOW_KEY = "close_window_key";
46 const std::string CORE_OPTION_WINDOW_MENU_KEY = "window_menu_key";
47
48 // Compiz Expo Options
49 const std::string EXPO_OPTION_EXPO_KEY = "expo_key";
50
51 // Compiz Grid Options
52 const std::string GRID_OPTION_PUT_LEFT_KEY = "put_left_key";
53
54 // Compiz Move Options
55 const std::string MOVE_OPTION_INITIATE_BUTTON = "initiate_button";
56
57 // Compiz Resize Options
58 const std::string RESIZE_OPTION_INITIATE_BUTTON = "initiate_button";
59
60 // Compiz Scale Options
61 const std::string SCALE_OPTION_INITIATE_ALL_KEY = "initiate_all_key";
62
63 // Compiz Unityshell Options
64 const std::string UNITYSHELL_OPTION_SHOW_LAUNCHER = "show_launcher";
65 const std::string UNITYSHELL_OPTION_KEYBOARD_FOCUS = "keyboard_focus";
66 const std::string UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward";
67 const std::string UNITYSHELL_OPTION_SHOW_HUD = "show_hud";
68 const std::string UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";
69 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";
70 const std::string UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";
71
72 // Compiz Wall Options
73 const std::string WALL_OPTION_LEFT_KEY = "left_key";
74 const std::string WALL_OPTION_LEFT_WINDOW_KEY = "left_window_key";
75}
76
77CompizModeller::CompizModeller()
78{
79 // Launcher...
80 const std::string launcher(_("Launcher"));
81
82 std::list<shortcut::AbstractHint::Ptr> hints;
83 hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" (Hold)"),
84 _("Opens the Launcher, displays shortcuts."),
85 shortcut::OptionType::COMPIZ_KEY,
86 UNITYSHELL_PLUGIN_NAME,
87 UNITYSHELL_OPTION_SHOW_LAUNCHER));
88
89 hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", "",
90 _("Opens Launcher keyboard navigation mode."),
91 shortcut::OptionType::COMPIZ_KEY,
92 UNITYSHELL_PLUGIN_NAME,
93 UNITYSHELL_OPTION_KEYBOARD_FOCUS));
94
95 hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", "",
96 _("Switches applications via the Launcher."),
97 shortcut::OptionType::COMPIZ_KEY,
98 UNITYSHELL_PLUGIN_NAME,
99 UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD));
100
101 hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + 1 to 9"),
102 _("Same as clicking on a Launcher icon."),
103 shortcut::OptionType::COMPIZ_KEY,
104 UNITYSHELL_PLUGIN_NAME,
105 UNITYSHELL_OPTION_SHOW_LAUNCHER));
106
107 hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + Shift + 1 to 9"),
108 _("Opens a new window in the app."),
109 shortcut::OptionType::COMPIZ_KEY,
110 UNITYSHELL_PLUGIN_NAME,
111 UNITYSHELL_OPTION_SHOW_LAUNCHER));
112
113 hints.push_back(std::make_shared<shortcut::Hint>(launcher, "", " + T",
114 _("Opens the Trash."),
115 shortcut::OptionType::COMPIZ_KEY,
116 UNITYSHELL_PLUGIN_NAME,
117 UNITYSHELL_OPTION_SHOW_LAUNCHER));
118
119
120 // Dash...
121 static const std::string dash( _("Dash"));
122
123 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", _(" (Tap)"),
124 _("Opens the Dash Home."),
125 shortcut::OptionType::COMPIZ_KEY,
126 UNITYSHELL_PLUGIN_NAME,
127 UNITYSHELL_OPTION_SHOW_LAUNCHER));
128
129 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + A",
130 _("Opens the Dash App Lens."),
131 shortcut::OptionType::COMPIZ_KEY,
132 UNITYSHELL_PLUGIN_NAME,
133 UNITYSHELL_OPTION_SHOW_LAUNCHER));
134
135 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + F",
136 _("Opens the Dash Files Lens."),
137 shortcut::OptionType::COMPIZ_KEY,
138 UNITYSHELL_PLUGIN_NAME,
139 UNITYSHELL_OPTION_SHOW_LAUNCHER));
140
141 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + M",
142 _("Opens the Dash Music Lens."),
143 shortcut::OptionType::COMPIZ_KEY,
144 UNITYSHELL_PLUGIN_NAME,
145 UNITYSHELL_OPTION_SHOW_LAUNCHER));
146
147 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", " + V",
148 _("Opens the Dash Video Lens."),
149 shortcut::OptionType::COMPIZ_KEY,
150 UNITYSHELL_PLUGIN_NAME,
151 UNITYSHELL_OPTION_SHOW_LAUNCHER));
152
153 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", "",
154 _("Switches between Lenses."),
155 shortcut::OptionType::HARDCODED,
156 _("Ctrl + Tab")));
157
158 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", "",
159 _("Moves the focus."),
160 shortcut::OptionType::HARDCODED,
161 _("Arrow Keys")));
162
163 hints.push_back(std::make_shared<shortcut::Hint>(dash, "", "",
164 _("Opens the currently focused item."),
165 shortcut::OptionType::HARDCODED,
166 _("Enter")));
167
168 // Menu Bar
169 static const std::string menubar(_("HUD & Menu Bar"));
170
171 hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Tap)"),
172 _("Opens the HUD."),
173 shortcut::OptionType::COMPIZ_KEY,
174 UNITYSHELL_PLUGIN_NAME,
175 UNITYSHELL_OPTION_SHOW_HUD));
176
177 hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Hold)"),
178 _("Reveals the application menu."),
179 shortcut::OptionType::HARDCODED,
180 "Alt"));
181
182 hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", "",
183 _("Opens the indicator menu."),
184 shortcut::OptionType::COMPIZ_KEY,
185 UNITYSHELL_PLUGIN_NAME,
186 UNITYSHELL_OPTION_PANEL_FIRST_MENU));
187
188 hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", "",
189 _("Moves focus between indicators."),
190 shortcut::OptionType::HARDCODED,
191 _("Cursor Left or Right")));
192
193 // Switching
194 static const std::string switching(_("Switching"));
195
196 hints.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
197 _("Switches between applications."),
198 shortcut::OptionType::COMPIZ_KEY,
199 UNITYSHELL_PLUGIN_NAME,
200 UNITYSHELL_OPTION_ALT_TAB_FORWARD));
201
202 hints.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
203 _("Switches windows of current applications."),
204 shortcut::OptionType::COMPIZ_KEY,
205 UNITYSHELL_PLUGIN_NAME,
206 UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW));
207
208 hints.push_back(std::make_shared<shortcut::Hint>(switching, "", "",
209 _("Moves the focus."),
210 shortcut::OptionType::HARDCODED,
211 _("Cursor Left or Right")));
212
213 // Workspaces
214 static const std::string workspaces(_("Workspaces"));
215
216 hints.push_back(std::make_shared<shortcut::Hint>(workspaces, "", "",
217 _("Switches between workspaces."),
218 shortcut::OptionType::COMPIZ_KEY,
219 EXPO_PLUGIN_NAME,
220 EXPO_OPTION_EXPO_KEY));
221
222 hints.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"),
223 _("Switches workspaces."),
224 shortcut::OptionType::COMPIZ_KEY,
225 WALL_PLUGIN_NAME,
226 WALL_OPTION_LEFT_KEY));
227
228 hints.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"),
229 _("Moves focused window to another workspace."),
230 shortcut::OptionType::COMPIZ_KEY,
231 WALL_PLUGIN_NAME,
232 WALL_OPTION_LEFT_WINDOW_KEY));
233
234
235 // Windows
236 static const std::string windows(_("Windows"));
237
238 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
239 _("Spreads all windows in the current workspace."),
240 shortcut::OptionType::COMPIZ_KEY,
241 SCALE_PLUGIN_NAME,
242 SCALE_OPTION_INITIATE_ALL_KEY));
243
244 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
245 _("Minimises all windows."),
246 shortcut::OptionType::COMPIZ_KEY,
247 CORE_PLUGIN_NAME,
248 CORE_OPTION_SHOW_DESKTOP_KEY));
249
250 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
251 _("Maximises the current window."),
252 shortcut::OptionType::COMPIZ_KEY,
253 CORE_PLUGIN_NAME,
254 CORE_OPTION_MAXIMIZE_WINDOW_KEY));
255
256 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
257 _("Restores or minimises the current window."),
258 shortcut::OptionType::COMPIZ_KEY,
259 CORE_PLUGIN_NAME,
260 CORE_OPTION_UNMAXIMIZE_WINDOW_KEY));
261
262 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"),
263 _("Semi-maximise the current window."),
264 shortcut::OptionType::COMPIZ_KEY,
265 GRID_PLUGIN_NAME,
266 GRID_OPTION_PUT_LEFT_KEY));
267
268 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
269 _("Closes the current window."),
270 shortcut::OptionType::COMPIZ_KEY,
271 CORE_PLUGIN_NAME,
272 CORE_OPTION_CLOSE_WINDOW_KEY));
273
274 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
275 _("Opens the window accessibility menu."),
276 shortcut::OptionType::COMPIZ_KEY,
277 CORE_PLUGIN_NAME,
278 CORE_OPTION_WINDOW_MENU_KEY));
279
280 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
281 _("Places the window in corresponding position."),
282 shortcut::OptionType::HARDCODED,
283 _("Ctrl + Alt + Num")));
284
285 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"),
286 _("Moves the window."),
287 shortcut::OptionType::COMPIZ_MOUSE,
288 MOVE_PLUGIN_NAME,
289 MOVE_OPTION_INITIATE_BUTTON));
290
291 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"),
292 _("Resizes the window."),
293 shortcut::OptionType::COMPIZ_MOUSE,
294 RESIZE_PLUGIN_NAME,
295 RESIZE_OPTION_INITIATE_BUTTON));
296
297 model_ = std::make_shared<shortcut::Model>(hints);
298}
299
300}
301}
0302
=== added file 'shortcuts/CompizShortcutModeller.h'
--- shortcuts/CompizShortcutModeller.h 1970-01-01 00:00:00 +0000
+++ shortcuts/CompizShortcutModeller.h 2013-01-23 00:09:20 +0000
@@ -0,0 +1,43 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
18 */
19
20#ifndef UNITYSHELL_COMPIZ_SHORTCUT_MODELLER_H
21#define UNITYSHELL_COMPIZ_SHORTCUT_MODELLER_H
22
23#include "AbstractShortcutModeller.h"
24
25namespace unity
26{
27namespace shortcut
28{
29
30class CompizModeller : public AbstractModeller
31{
32public:
33 CompizModeller();
34 Model::Ptr GetCurrentModel() const {return model_;}
35
36private:
37 Model::Ptr model_;
38};
39
40}
41}
42
43#endif
044
=== modified file 'shortcuts/ShortcutController.cpp'
--- shortcuts/ShortcutController.cpp 2013-01-21 16:12:58 +0000
+++ shortcuts/ShortcutController.cpp 2013-01-23 00:09:20 +0000
@@ -18,6 +18,7 @@
18 */18 */
1919
20#include "ShortcutController.h"20#include "ShortcutController.h"
21#include "ShortcutModel.h"
2122
22#include "unity-shared/UBusMessages.h"23#include "unity-shared/UBusMessages.h"
23#include "unity-shared/UScreen.h"24#include "unity-shared/UScreen.h"
@@ -34,17 +35,15 @@
34const unsigned int FADE_DURATION = 100;35const unsigned int FADE_DURATION = 100;
35}36}
3637
37Controller::Controller(std::list<AbstractHint::Ptr> const& hints,38Controller::Controller(BaseWindowRaiser::Ptr const& base_window_raiser,
38 BaseWindowRaiser::Ptr const& base_window_raiser)39 AbstractModeller::Ptr const& modeller)
39 : model_(std::make_shared<Model>(hints))40 : modeller_(modeller)
40 , base_window_raiser_(base_window_raiser)41 , base_window_raiser_(base_window_raiser)
41 , visible_(false)42 , visible_(false)
42 , enabled_(true)43 , enabled_(true)
43 , bg_color_(0.0, 0.0, 0.0, 0.5)44 , bg_color_(0.0, 0.0, 0.0, 0.5)
44 , fade_animator_(FADE_DURATION)45 , fade_animator_(FADE_DURATION)
45{46{
46 model_->Fill();
47
48 ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED,47 ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED,
49 sigc::mem_fun(this, &Controller::OnBackgroundUpdate));48 sigc::mem_fun(this, &Controller::OnBackgroundUpdate));
5049
@@ -65,6 +64,16 @@
65 fade_animator_.updated.connect([this] (double opacity) {64 fade_animator_.updated.connect([this] (double opacity) {
66 SetOpacity(opacity);65 SetOpacity(opacity);
67 });66 });
67
68 modeller->model_changed.connect([this] (Model::Ptr const& model) {
69 if (!view_)
70 return;
71
72 if (visible_)
73 model->Fill();
74
75 view_->SetModel(model);
76 });
68}77}
6978
70Controller::~Controller()79Controller::~Controller()
@@ -82,12 +91,9 @@
8291
83bool Controller::Show()92bool Controller::Show()
84{93{
85 if (enabled_)94 if (enabled_ && modeller_->GetCurrentModel())
86 {95 {
87 EnsureView();
88
89 show_timer_.reset(new glib::Timeout(SUPER_TAP_DURATION, sigc::mem_fun(this, &Controller::OnShowTimer)));96 show_timer_.reset(new glib::Timeout(SUPER_TAP_DURATION, sigc::mem_fun(this, &Controller::OnShowTimer)));
90 model_->Fill();
91 visible_ = true;97 visible_ = true;
9298
93 return true;99 return true;
@@ -98,10 +104,11 @@
98104
99bool Controller::OnShowTimer()105bool Controller::OnShowTimer()
100{106{
101 if (!enabled_)107 if (!enabled_ || !modeller_->GetCurrentModel())
102 return false;108 return false;
103109
104 base_window_raiser_->Raise(view_window_);110 modeller_->GetCurrentModel()->Fill();
111 EnsureView();
105112
106 int monitor = UScreen::GetDefault()->GetMonitorWithMouse();113 int monitor = UScreen::GetDefault()->GetMonitorWithMouse();
107 auto const& geo = GetGeometryPerMonitor(monitor);114 auto const& geo = GetGeometryPerMonitor(monitor);
@@ -109,6 +116,7 @@
109 if (geo.IsNull())116 if (geo.IsNull())
110 return false;117 return false;
111118
119 base_window_raiser_->Raise(view_window_);
112 view_window_->SetGeometry(geo);120 view_window_->SetGeometry(geo);
113121
114 if (visible_)122 if (visible_)
@@ -131,8 +139,7 @@
131139
132nux::Geometry Controller::GetGeometryPerMonitor(int monitor)140nux::Geometry Controller::GetGeometryPerMonitor(int monitor)
133{141{
134 if (!view_)142 EnsureView();
135 ConstructView();
136143
137 auto const& view_geo = view_->GetAbsoluteGeometry();144 auto const& view_geo = view_->GetAbsoluteGeometry();
138 auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);145 auto const& monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
@@ -154,7 +161,7 @@
154{161{
155 view_ = View::Ptr(new View());162 view_ = View::Ptr(new View());
156 AddChild(view_.GetPointer());163 AddChild(view_.GetPointer());
157 view_->SetModel(model_);164 view_->SetModel(modeller_->GetCurrentModel());
158 view_->background_color = bg_color_;165 view_->background_color = bg_color_;
159166
160 if (!view_window_)167 if (!view_window_)
@@ -165,7 +172,7 @@
165172
166 view_window_ = new nux::BaseWindow("ShortcutHint");173 view_window_ = new nux::BaseWindow("ShortcutHint");
167 view_window_->SetLayout(main_layout_);174 view_window_->SetLayout(main_layout_);
168 view_window_->SetBackgroundColor(nux::Color(0x00000000));175 view_window_->SetBackgroundColor(nux::color::Transparent);
169 }176 }
170177
171 main_layout_->AddView(view_.GetPointer());178 main_layout_->AddView(view_.GetPointer());
172179
=== modified file 'shortcuts/ShortcutController.h'
--- shortcuts/ShortcutController.h 2013-01-21 16:06:36 +0000
+++ shortcuts/ShortcutController.h 2013-01-23 00:09:20 +0000
@@ -30,7 +30,7 @@
30#include <UnityCore/GLibSource.h>30#include <UnityCore/GLibSource.h>
3131
32#include "BaseWindowRaiser.h"32#include "BaseWindowRaiser.h"
33#include "ShortcutModel.h"33#include "AbstractShortcutModeller.h"
34#include "ShortcutView.h"34#include "ShortcutView.h"
35#include "unity-shared/Introspectable.h"35#include "unity-shared/Introspectable.h"
36#include "unity-shared/UBusWrapper.h"36#include "unity-shared/UBusWrapper.h"
@@ -45,8 +45,7 @@
45public:45public:
46 typedef std::shared_ptr<Controller> Ptr;46 typedef std::shared_ptr<Controller> Ptr;
4747
48 Controller(std::list<AbstractHint::Ptr> const& hints,48 Controller(BaseWindowRaiser::Ptr const& raiser, AbstractModeller::Ptr const& modeller);
49 BaseWindowRaiser::Ptr const& raiser);
50 virtual ~Controller();49 virtual ~Controller();
5150
52 bool Show();51 bool Show();
@@ -72,7 +71,7 @@
72 bool OnShowTimer();71 bool OnShowTimer();
7372
74 View::Ptr view_;73 View::Ptr view_;
75 Model::Ptr model_;74 AbstractModeller::Ptr modeller_;
76 BaseWindowRaiser::Ptr base_window_raiser_;75 BaseWindowRaiser::Ptr base_window_raiser_;
7776
78 nux::Geometry workarea_;77 nux::Geometry workarea_;
7978
=== modified file 'shortcuts/ShortcutModel.cpp'
--- shortcuts/ShortcutModel.cpp 2013-01-19 00:25:07 +0000
+++ shortcuts/ShortcutModel.cpp 2013-01-23 00:09:20 +0000
@@ -50,7 +50,6 @@
50 hints_[hint->category()].push_back(hint);50 hints_[hint->category()].push_back(hint);
51}51}
5252
53
54void Model::Fill()53void Model::Fill()
55{54{
56 for (auto const& category : categories_)55 for (auto const& category : categories_)
5756
=== modified file 'shortcuts/ShortcutView.cpp'
--- shortcuts/ShortcutView.cpp 2013-01-21 21:12:57 +0000
+++ shortcuts/ShortcutView.cpp 2013-01-23 00:09:20 +0000
@@ -94,7 +94,9 @@
94void View::SetModel(Model::Ptr model)94void View::SetModel(Model::Ptr model)
95{95{
96 model_ = model;96 model_ = model;
97 model_->categories_per_column.changed.connect(sigc::hide(sigc::mem_fun(this, &View::RenderColumns)));97
98 if (model_)
99 model_->categories_per_column.changed.connect(sigc::hide(sigc::mem_fun(this, &View::RenderColumns)));
98100
99 // Fills the columns...101 // Fills the columns...
100 RenderColumns();102 RenderColumns();
@@ -186,13 +188,10 @@
186188
187nux::Geometry View::GetBackgroundGeometry()189nux::Geometry View::GetBackgroundGeometry()
188{190{
189 nux::Geometry base = GetGeometry();191 nux::Geometry background_geo = GetGeometry();
190 nux::Geometry background_geo;
191192
192 background_geo.width = base.width;193 background_geo.x = 0;
193 background_geo.height = base.height;194 background_geo.y = 0;
194 background_geo.x = (base.width - background_geo.width)/2;
195 background_geo.y = (base.height - background_geo.height)/2;
196195
197 return background_geo;196 return background_geo;
198}197}
@@ -206,6 +205,12 @@
206{205{
207 columns_layout_->Clear();206 columns_layout_->Clear();
208207
208 if (!model_)
209 {
210 QueueRelayout();
211 return;
212 }
213
209 int i = 0;214 int i = 0;
210 int column_idx = 0;215 int column_idx = 0;
211 auto const& columns = columns_layout_->GetChildren();216 auto const& columns = columns_layout_->GetChildren();
212217
=== modified file 'shortcuts/StandaloneShortcuts.cpp'
--- shortcuts/StandaloneShortcuts.cpp 2013-01-21 16:07:47 +0000
+++ shortcuts/StandaloneShortcuts.cpp 2013-01-23 00:09:20 +0000
@@ -39,9 +39,8 @@
39{39{
40struct StandaloneController : Controller40struct StandaloneController : Controller
41{41{
42 StandaloneController(std::list<AbstractHint::Ptr> const& hints,42 StandaloneController(BaseWindowRaiser::Ptr const& raiser, AbstractModeller::Ptr const& modeller)
43 BaseWindowRaiser::Ptr const& raiser)43 : Controller(raiser, modeller)
44 : Controller(hints, raiser)
45 {}44 {}
4645
47 nux::Geometry GetGeometryPerMonitor(int monitor) override46 nux::Geometry GetGeometryPerMonitor(int monitor) override
@@ -52,6 +51,216 @@
52}51}
53}52}
5453
54struct StandaloneModeller : shortcut::AbstractModeller
55{
56 StandaloneModeller()
57 {
58 std::list<shortcut::AbstractHint::Ptr> hints;
59
60 // Launcher...
61 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" (Hold)"),
62 _("Opens the Launcher, displays shortcuts."),
63 shortcut::OptionType::COMPIZ_KEY,
64 "unityshell",
65 "show_launcher" )));
66
67 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "",
68 _("Opens Launcher keyboard navigation mode."),
69 shortcut::OptionType::COMPIZ_KEY,
70 "unityshell",
71 "keyboard_focus")));
72
73 // FIXME: Implemstd::shared_ptr<shortcut::AbstractHint>(ent it...
74 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "",
75 _("Switches applications via the Launcher."),
76 shortcut::OptionType::HARDCODED,
77 "Super + Tab")));
78
79 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + 1 to 9"),
80 _("Same as clicking on a Launcher icon."),
81 shortcut::OptionType::COMPIZ_KEY,
82 "unityshell",
83 "show_launcher")));
84
85 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + Shift + 1 to 9"),
86 _("Opens a new window in the app."),
87 shortcut::OptionType::COMPIZ_KEY,
88 "unityshell",
89 "show_launcher")));
90
91 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", " + T",
92 _("Opens the Trash."),
93 shortcut::OptionType::COMPIZ_KEY,
94 "unityshell",
95 "show_launcher")));
96
97 // Dash...
98 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", _(" (Tap)"),
99 _("Opens the Dash Home."),
100 shortcut::OptionType::COMPIZ_KEY,
101 "unityshell",
102 "show_launcher")));
103
104 // These are notstd::shared_ptr<shortcut::AbstractHint>( really hardcoded...
105 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + A",
106 _("Opens the Dash App Lens."),
107 shortcut::OptionType::COMPIZ_KEY,
108 "unityshell",
109 "show_launcher")));
110
111 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + F",
112 _("Opens the Dash Files Lens."),
113 shortcut::OptionType::COMPIZ_KEY,
114 "unityshell",
115 "show_launcher")));
116
117 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + M",
118 _("Opens the Dash Music Lens."),
119 shortcut::OptionType::COMPIZ_KEY,
120 "unityshell",
121 "show_launcher")));
122
123 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "",
124 _("Switches between Lenses."),
125 shortcut::OptionType::HARDCODED,
126 "Ctrl + Tab")));
127
128 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "",
129 _("Moves the focus."),
130 shortcut::OptionType::HARDCODED,
131 _("Arrow Keys"))));
132
133 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "",
134 _("Opens the currently focused item."),
135 shortcut::OptionType::HARDCODED,
136 _("Enter"))));
137
138 // Hud Menu Bar
139 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Tap)"),
140 _("Opens the HUD."),
141 shortcut::OptionType::COMPIZ_KEY,
142 "unityshell",
143 "show_hud")));
144
145 // Is it really std::shared_ptr<shortcut::AbstractHint>(hard coded?
146 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Hold)"),
147 _("Reveals the application menu."),
148 shortcut::OptionType::HARDCODED,
149 "Alt")));
150
151 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "",
152 _("Opens the indicator menu."),
153 shortcut::OptionType::COMPIZ_KEY,
154 "unityshell",
155 "panel_first_menu")));
156
157 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "",
158 _("Moves focus between indicators."),
159 shortcut::OptionType::HARDCODED,
160 _("Cursor Left or Right"))));
161
162 // Switching
163 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "",
164 _("Switches between applications."),
165 shortcut::OptionType::COMPIZ_KEY,
166 "unityshell",
167 "alt_tab_forward")));
168
169 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "",
170 _("Switches windows of current applications."),
171 shortcut::OptionType::COMPIZ_KEY,
172 "unityshell",
173 "alt_tab_next_window")));
174
175 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "",
176 _("Moves the focus."),
177 shortcut::OptionType::HARDCODED,
178 _("Cursor Left or Right"))));
179
180 // Workspaces
181 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "",
182 _("Switches between workspaces."),
183 shortcut::OptionType::COMPIZ_KEY,
184 "expo",
185 "expo_key")));
186
187 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "",
188 _("Switches workspaces."),
189 shortcut::OptionType::HARDCODED,
190 _("Arrow Keys"))));
191
192 //hints.push_bacstd::shared_ptr<shortcut::AbstractHint>(k(new shortcut::MockHint(_("Workspaces"), "", "", _("Move focused window to other workspace."), ...)
193
194 // Windows
195 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
196 _("Spreads all windows in the current workspace."),
197 shortcut::OptionType::COMPIZ_KEY,
198 "scale",
199 "initiate_output_key")));
200
201 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
202 _("Minimises all windows."),
203 shortcut::OptionType::COMPIZ_KEY,
204 "core",
205 "show_desktop_key")));
206
207 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
208 _("Maximises the current window."),
209 shortcut::OptionType::COMPIZ_KEY,
210 "core",
211 "maximize_window_key")));
212
213 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
214 _("Restores or minimises the current window."),
215 shortcut::OptionType::COMPIZ_KEY,
216 "core",
217 "unmaximize_window_key")));
218
219 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", _(" or Right"),
220 _("Semi-maximises the current window."),
221 shortcut::OptionType::COMPIZ_KEY,
222 "grid",
223 "put_left_key")));
224
225 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
226 _("Closes the current window."),
227 shortcut::OptionType::COMPIZ_KEY,
228 "core",
229 "close_window_key")));
230
231 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
232 _("Opens the window accessibility menu."),
233 shortcut::OptionType::COMPIZ_KEY,
234 "core",
235 "window_menu_key")));
236
237 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
238 _("Places the window in corresponding position."),
239 shortcut::OptionType::HARDCODED,
240 "Ctrl + Alt + Num")));
241
242 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
243 _("Moves the window."),
244 shortcut::OptionType::COMPIZ_KEY,
245 "move",
246 "initiate_key")));
247
248 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
249 _("Resizes the current window."),
250 shortcut::OptionType::COMPIZ_KEY,
251 "resize",
252 "initiate_key")));
253 model = std::make_shared<shortcut::Model>(hints);
254 }
255
256 shortcut::Model::Ptr GetCurrentModel() const
257 {
258 return model;
259 }
260
261 shortcut::Model::Ptr model;
262};
263
55struct ShortcutsWindow264struct ShortcutsWindow
56{265{
57 ShortcutsWindow()266 ShortcutsWindow()
@@ -82,204 +291,9 @@
82void ShortcutsWindow::Init()291void ShortcutsWindow::Init()
83{292{
84 BackgroundEffectHelper::blur_type = BLUR_NONE;293 BackgroundEffectHelper::blur_type = BLUR_NONE;
85 std::list<std::shared_ptr<shortcut::AbstractHint>> hints;
86
87 // Launcher...
88 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" (Hold)"),
89 _("Opens the Launcher, displays shortcuts."),
90 shortcut::OptionType::COMPIZ_KEY,
91 "unityshell",
92 "show_launcher" )));
93
94 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "",
95 _("Opens Launcher keyboard navigation mode."),
96 shortcut::OptionType::COMPIZ_KEY,
97 "unityshell",
98 "keyboard_focus")));
99
100 // FIXME: Implemstd::shared_ptr<shortcut::AbstractHint>(ent it...
101 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", "",
102 _("Switches applications via the Launcher."),
103 shortcut::OptionType::HARDCODED,
104 "Super + Tab")));
105
106 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + 1 to 9"),
107 _("Same as clicking on a Launcher icon."),
108 shortcut::OptionType::COMPIZ_KEY,
109 "unityshell",
110 "show_launcher")));
111
112 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", _(" + Shift + 1 to 9"),
113 _("Opens a new window in the app."),
114 shortcut::OptionType::COMPIZ_KEY,
115 "unityshell",
116 "show_launcher")));
117
118 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Launcher"), "", " + T",
119 _("Opens the Trash."),
120 shortcut::OptionType::COMPIZ_KEY,
121 "unityshell",
122 "show_launcher")));
123
124 // Dash...
125 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", _(" (Tap)"),
126 _("Opens the Dash Home."),
127 shortcut::OptionType::COMPIZ_KEY,
128 "unityshell",
129 "show_launcher")));
130
131 // These are notstd::shared_ptr<shortcut::AbstractHint>( really hardcoded...
132 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + A",
133 _("Opens the Dash App Lens."),
134 shortcut::OptionType::COMPIZ_KEY,
135 "unityshell",
136 "show_launcher")));
137
138 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + F",
139 _("Opens the Dash Files Lens."),
140 shortcut::OptionType::COMPIZ_KEY,
141 "unityshell",
142 "show_launcher")));
143
144 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", " + M",
145 _("Opens the Dash Music Lens."),
146 shortcut::OptionType::COMPIZ_KEY,
147 "unityshell",
148 "show_launcher")));
149
150 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "",
151 _("Switches between Lenses."),
152 shortcut::OptionType::HARDCODED,
153 "Ctrl + Tab")));
154
155 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "",
156 _("Moves the focus."),
157 shortcut::OptionType::HARDCODED,
158 _("Arrow Keys"))));
159
160 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Dash"), "", "",
161 _("Opens the currently focused item."),
162 shortcut::OptionType::HARDCODED,
163 _("Enter"))));
164
165 // Hud Menu Bar
166 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Tap)"),
167 _("Opens the HUD."),
168 shortcut::OptionType::COMPIZ_KEY,
169 "unityshell",
170 "show_hud")));
171
172 // Is it really std::shared_ptr<shortcut::AbstractHint>(hard coded?
173 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", _(" (Hold)"),
174 _("Reveals the application menu."),
175 shortcut::OptionType::HARDCODED,
176 "Alt")));
177
178 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "",
179 _("Opens the indicator menu."),
180 shortcut::OptionType::COMPIZ_KEY,
181 "unityshell",
182 "panel_first_menu")));
183
184 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("HUD & Menu Bar"), "", "",
185 _("Moves focus between indicators."),
186 shortcut::OptionType::HARDCODED,
187 _("Cursor Left or Right"))));
188
189 // Switching
190 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "",
191 _("Switches between applications."),
192 shortcut::OptionType::COMPIZ_KEY,
193 "unityshell",
194 "alt_tab_forward")));
195
196 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "",
197 _("Switches windows of current applications."),
198 shortcut::OptionType::COMPIZ_KEY,
199 "unityshell",
200 "alt_tab_next_window")));
201
202 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Switching"), "", "",
203 _("Moves the focus."),
204 shortcut::OptionType::HARDCODED,
205 _("Cursor Left or Right"))));
206
207 // Workspaces
208 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "",
209 _("Switches between workspaces."),
210 shortcut::OptionType::COMPIZ_KEY,
211 "expo",
212 "expo_key")));
213
214 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Workspaces"), "", "",
215 _("Switches workspaces."),
216 shortcut::OptionType::HARDCODED,
217 _("Arrow Keys"))));
218
219 //hints.push_bacstd::shared_ptr<shortcut::AbstractHint>(k(new shortcut::MockHint(_("Workspaces"), "", "", _("Move focused window to other workspace."), ...)
220
221 // Windows
222 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
223 _("Spreads all windows in the current workspace."),
224 shortcut::OptionType::COMPIZ_KEY,
225 "scale",
226 "initiate_output_key")));
227
228 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
229 _("Minimises all windows."),
230 shortcut::OptionType::COMPIZ_KEY,
231 "core",
232 "show_desktop_key")));
233
234 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
235 _("Maximises the current window."),
236 shortcut::OptionType::COMPIZ_KEY,
237 "core",
238 "maximize_window_key")));
239
240 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
241 _("Restores or minimises the current window."),
242 shortcut::OptionType::COMPIZ_KEY,
243 "core",
244 "unmaximize_window_key")));
245
246 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", _(" or Right"),
247 _("Semi-maximises the current window."),
248 shortcut::OptionType::COMPIZ_KEY,
249 "grid",
250 "put_left_key")));
251
252 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
253 _("Closes the current window."),
254 shortcut::OptionType::COMPIZ_KEY,
255 "core",
256 "close_window_key")));
257
258 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
259 _("Opens the window accessibility menu."),
260 shortcut::OptionType::COMPIZ_KEY,
261 "core",
262 "window_menu_key")));
263
264 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
265 _("Places the window in corresponding position."),
266 shortcut::OptionType::HARDCODED,
267 "Ctrl + Alt + Num")));
268
269 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
270 _("Moves the window."),
271 shortcut::OptionType::COMPIZ_KEY,
272 "move",
273 "initiate_key")));
274
275 hints.push_back(std::shared_ptr<shortcut::AbstractHint>(new shortcut::MockHint(_("Windows"), "", "",
276 _("Resizes the current window."),
277 shortcut::OptionType::COMPIZ_KEY,
278 "resize",
279 "initiate_key")));
280
281 auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>();294 auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>();
282 controller = std::make_shared<shortcut::StandaloneController>(hints, base_window_raiser_);295 auto modeller = std::make_shared<StandaloneModeller>();
296 controller = std::make_shared<shortcut::StandaloneController>(base_window_raiser_, modeller);
283 controller->Show();297 controller->Show();
284}298}
285299
286300
=== modified file 'tests/test_shortcut_controller.cpp'
--- tests/test_shortcut_controller.cpp 2013-01-21 16:08:34 +0000
+++ tests/test_shortcut_controller.cpp 2013-01-23 00:09:20 +0000
@@ -39,6 +39,14 @@
3939
40 MOCK_METHOD1 (Raise, void(nux::ObjectPtr<nux::BaseWindow> window));40 MOCK_METHOD1 (Raise, void(nux::ObjectPtr<nux::BaseWindow> window));
41};41};
42
43struct StandaloneModeller : shortcut::AbstractModeller
44{
45 shortcut::Model::Ptr GetCurrentModel() const
46 {
47 return std::make_shared<shortcut::Model>(std::list<shortcut::AbstractHint::Ptr>());
48 }
49};
42}50}
4351
44namespace unity52namespace unity
@@ -49,9 +57,9 @@
49{57{
50 struct MockShortcutController : public Controller58 struct MockShortcutController : public Controller
51 {59 {
52 MockShortcutController(std::list<AbstractHint::Ptr> const& hints,60 MockShortcutController(BaseWindowRaiser::Ptr const& base_window_raiser,
53 BaseWindowRaiser::Ptr const& base_window_raiser)61 AbstractModeller::Ptr const& modeller)
54 : Controller(hints, base_window_raiser)62 : Controller(base_window_raiser, modeller)
55 {}63 {}
5664
57 MOCK_METHOD1(SetOpacity, void(double));65 MOCK_METHOD1(SetOpacity, void(double));
@@ -67,8 +75,9 @@
6775
68public:76public:
69 TestShortcutController()77 TestShortcutController()
70 : base_window_raiser_(std::make_shared<MockBaseWindowRaiser>())78 : base_window_raiser_(std::make_shared<NiceMock<MockBaseWindowRaiser>>())
71 , controller_(hints_, base_window_raiser_)79 , modeller_(std::make_shared<StandaloneModeller>())
80 , controller_(base_window_raiser_, modeller_)
72 , animation_controller_(tick_source_)81 , animation_controller_(tick_source_)
73 {82 {
74 ON_CALL(controller_, SetOpacity(_))83 ON_CALL(controller_, SetOpacity(_))
@@ -77,15 +86,15 @@
7786
78 MockUScreen uscreen;87 MockUScreen uscreen;
79 Settings unity_settings;88 Settings unity_settings;
80 std::list<shortcut::AbstractHint::Ptr> hints_;
81 MockBaseWindowRaiser::Ptr base_window_raiser_;89 MockBaseWindowRaiser::Ptr base_window_raiser_;
90 AbstractModeller::Ptr const& modeller_;
82 NiceMock<MockShortcutController> controller_;91 NiceMock<MockShortcutController> controller_;
8392
84 nux::animation::TickSource tick_source_;93 nux::animation::TickSource tick_source_;
85 nux::animation::AnimationController animation_controller_;94 nux::animation::AnimationController animation_controller_;
86};95};
8796
88TEST_F (TestShortcutController, WindowIsRaisedOnShow)97TEST_F(TestShortcutController, WindowIsRaisedOnShow)
89{98{
90 EXPECT_CALL(*base_window_raiser_, Raise(_))99 EXPECT_CALL(*base_window_raiser_, Raise(_))
91 .Times(1);100 .Times(1);
@@ -94,8 +103,7 @@
94 Utils::WaitForTimeout(1);103 Utils::WaitForTimeout(1);
95}104}
96105
97106TEST_F(TestShortcutController, HiddeenOnConstruction)
98TEST_F (TestShortcutController, Hide)
99{107{
100 {108 {
101 InSequence sequence;109 InSequence sequence;
@@ -105,13 +113,11 @@
105 .Times(0);113 .Times(0);
106 }114 }
107115
108 controller_.Show();116 controller_.ConstructView();
109
110 controller_.Hide();117 controller_.Hide();
111 tick_source_.tick(1000);
112}118}
113119
114TEST_F (TestShortcutController, GetGeometryPerMonitor)120TEST_F(TestShortcutController, GetGeometryPerMonitor)
115{121{
116 nux::Geometry good_monitor(0, 0, 1366, 768);122 nux::Geometry good_monitor(0, 0, 1366, 768);
117 nux::Geometry invalid_monitor(good_monitor.x + good_monitor.width, 0, 1, 1);123 nux::Geometry invalid_monitor(good_monitor.x + good_monitor.width, 0, 1, 1);
@@ -129,6 +135,17 @@
129 EXPECT_TRUE(controller_.GetGeometryPerMonitor(1).IsNull());135 EXPECT_TRUE(controller_.GetGeometryPerMonitor(1).IsNull());
130}136}
131137
138TEST_F(TestShortcutController, ModelIsChangedOnModellerChange)
139{
140 controller_.ConstructView();
141 auto old_model = controller_.view_->GetModel();
142 auto model = std::make_shared<Model>(std::list<AbstractHint::Ptr>());
143 modeller_->model_changed(model);
144
145 ASSERT_NE(controller_.view_->GetModel(), old_model);
146 EXPECT_EQ(controller_.view_->GetModel(), model);
147}
148
132149
133}150}
134}151}
135152
=== modified file 'tests/test_shortcut_view.cpp'
--- tests/test_shortcut_view.cpp 2013-01-21 21:12:57 +0000
+++ tests/test_shortcut_view.cpp 2013-01-23 00:09:20 +0000
@@ -73,6 +73,14 @@
73 EXPECT_FALSE(model->categories_per_column.changed.empty());73 EXPECT_FALSE(model->categories_per_column.changed.empty());
74}74}
7575
76TEST_F(TestShortcutView, SetNullModel)
77{
78 view.SetModel(GetMockModel({}, 0));
79 view.SetModel(nullptr);
80 EXPECT_EQ(view.GetModel(), nullptr);
81 EXPECT_TRUE(view.columns_layout_->GetChildren().empty());
82}
83
76TEST_F(TestShortcutView, SettingModelAddsColumns)84TEST_F(TestShortcutView, SettingModelAddsColumns)
77{85{
78 auto model = GetMockModel({"Cat1", "Cat2"}, 1);86 auto model = GetMockModel({"Cat1", "Cat2"}, 1);