Merge lp:~robertcarr/unity/tab-lens-navigation into lp:unity

Proposed by Robert Carr
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 1533
Proposed branch: lp:~robertcarr/unity/tab-lens-navigation
Merge into: lp:unity
Diff against target: 113 lines (+60/-0)
5 files modified
plugins/unityshell/src/DashView.cpp (+8/-0)
plugins/unityshell/src/DashView.h (+2/-0)
plugins/unityshell/src/IMTextEntry.cpp (+4/-0)
plugins/unityshell/src/LensBar.cpp (+43/-0)
plugins/unityshell/src/LensBar.h (+3/-0)
To merge this branch: bzr merge lp:~robertcarr/unity/tab-lens-navigation
Reviewer Review Type Date Requested Status
Gord Allott Pending
Review via email: mp+74917@code.launchpad.net

Description of the change

Implement tab and shift tab navigation support to switch between lenses. Depends on https://code.launchpad.net/~robertcarr/nux/nux-keynav-tabprev/+merge/74916 to work.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/DashView.cpp'
2--- plugins/unityshell/src/DashView.cpp 2011-09-08 12:43:05 +0000
3+++ plugins/unityshell/src/DashView.cpp 2011-09-11 17:02:15 +0000
4@@ -820,6 +820,14 @@
5 void DashView::AddProperties(GVariantBuilder* builder)
6 {}
7
8+nux::Area * DashView::KeyNavIteration(nux::KeyNavDirection direction)
9+{
10+ if (direction == KEY_NAV_TAB_NEXT)
11+ lens_bar_->ActivateNext();
12+ else if (direction == KEY_NAV_TAB_PREVIOUS)
13+ lens_bar_->ActivatePrevious();
14+ return this;
15+}
16
17 }
18 }
19
20=== modified file 'plugins/unityshell/src/DashView.h'
21--- plugins/unityshell/src/DashView.h 2011-09-08 11:23:14 +0000
22+++ plugins/unityshell/src/DashView.h 2011-09-11 17:02:15 +0000
23@@ -93,6 +93,8 @@
24 bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character);
25 const gchar* GetName();
26 void AddProperties(GVariantBuilder* builder);
27+
28+ nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
29
30 private:
31 UBusManager ubus_manager_;
32
33=== modified file 'plugins/unityshell/src/IMTextEntry.cpp'
34--- plugins/unityshell/src/IMTextEntry.cpp 2011-09-07 17:03:52 +0000
35+++ plugins/unityshell/src/IMTextEntry.cpp 2011-09-11 17:02:15 +0000
36@@ -193,6 +193,10 @@
37 {
38 Paste();
39 }
40+ else if (keyval == NUX_VK_TAB || keyval == NUX_VK_LEFT_TAB)
41+ {
42+ return true;
43+ }
44 else
45 {
46 return false;
47
48=== modified file 'plugins/unityshell/src/LensBar.cpp'
49--- plugins/unityshell/src/LensBar.cpp 2011-09-07 21:45:10 +0000
50+++ plugins/unityshell/src/LensBar.cpp 2011-09-11 17:02:15 +0000
51@@ -140,6 +140,49 @@
52 lens_activated.emit(activated->id);
53 }
54
55+void LensBar::ActivateNext()
56+{
57+ bool activate_next = false;
58+ for (auto it = icons_.begin();
59+ it < icons_.end();
60+ it++)
61+ {
62+ LensBarIcon *icon = *it;
63+
64+ if (activate_next && icon->IsVisible())
65+ {
66+ SetActive(icon);
67+ return;
68+ }
69+ if (icon->active)
70+ activate_next = true;
71+ }
72+ SetActive(icons_[0]);
73+
74+}
75+
76+void LensBar::ActivatePrevious()
77+{
78+ bool activate_previous = false;
79+
80+ for (auto it = icons_.rbegin();
81+ it < icons_.rend();
82+ ++it)
83+ {
84+ LensBarIcon *icon = *it;
85+
86+ if (activate_previous && icon->IsVisible())
87+ {
88+ SetActive(icon);
89+ return;
90+ }
91+ if (icon->active)
92+ activate_previous = true;
93+ }
94+ SetActive(icons_.back());
95+
96+}
97+
98 // Keyboard navigation
99 bool LensBar::AcceptKeyNavFocus()
100 {
101
102=== modified file 'plugins/unityshell/src/LensBar.h'
103--- plugins/unityshell/src/LensBar.h 2011-08-22 17:17:26 +0000
104+++ plugins/unityshell/src/LensBar.h 2011-09-11 17:02:15 +0000
105@@ -48,6 +48,9 @@
106
107 void AddLens(Lens::Ptr& lens);
108 void Activate(std::string id);
109+ void ActivateNext();
110+ void ActivatePrevious();
111+
112
113 sigc::signal<void, std::string const&> lens_activated;
114