Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Gord Allott | ||||||||||||||||
Approved revision: | no longer in the source branch. | ||||||||||||||||
Merged at revision: | 1900 | ||||||||||||||||
Proposed branch: | lp:~gordallott/unity/hud | ||||||||||||||||
Merge into: | lp:unity | ||||||||||||||||
Prerequisite: | lp:~gordallott/unity/rename-ubus-place-view-messages | ||||||||||||||||
Diff against target: |
4304 lines (+3163/-177) 45 files modified
CMakeLists.txt (+1/-1) UnityCore/CMakeLists.txt (+2/-0) UnityCore/GLibDBusProxy.cpp (+0/-4) UnityCore/Hud.cpp (+255/-0) UnityCore/Hud.h (+127/-0) manual-tests/Hud.txt (+57/-0) plugins/unityshell/src/DashController.cpp (+12/-0) plugins/unityshell/src/DashStyle.cpp (+136/-4) plugins/unityshell/src/DashStyle.h (+9/-2) plugins/unityshell/src/DashView.h (+1/-1) plugins/unityshell/src/FilterAllButton.cpp (+1/-0) plugins/unityshell/src/HudButton.cpp (+208/-0) plugins/unityshell/src/HudButton.h (+81/-0) plugins/unityshell/src/HudController.cpp (+385/-0) plugins/unityshell/src/HudController.h (+113/-0) plugins/unityshell/src/HudIcon.cpp (+95/-0) plugins/unityshell/src/HudIcon.h (+73/-0) plugins/unityshell/src/HudIconTextureSource.cpp (+110/-0) plugins/unityshell/src/HudIconTextureSource.h (+51/-0) plugins/unityshell/src/HudView.cpp (+398/-0) plugins/unityshell/src/HudView.h (+118/-0) plugins/unityshell/src/IMTextEntry.cpp (+1/-4) plugins/unityshell/src/IMTextEntry.h (+0/-3) plugins/unityshell/src/IconTexture.cpp (+12/-3) plugins/unityshell/src/IconTexture.h (+5/-2) plugins/unityshell/src/OverlayRenderer.cpp (+5/-5) plugins/unityshell/src/OverlayRenderer.h (+1/-1) plugins/unityshell/src/SearchBar.cpp (+124/-55) plugins/unityshell/src/SearchBar.h (+11/-8) plugins/unityshell/src/SearchBarSpinner.cpp (+1/-4) plugins/unityshell/src/SearchBarSpinner.h (+2/-5) plugins/unityshell/src/UBusMessages.h (+2/-0) plugins/unityshell/src/unity-search-bar-accessible.cpp (+3/-3) plugins/unityshell/src/unitya11y.cpp (+1/-1) plugins/unityshell/src/unityshell.cpp (+67/-21) plugins/unityshell/src/unityshell.h (+8/-1) plugins/unityshell/unityshell.xml.in (+46/-41) po/POTFILES.in (+1/-1) standalone-clients/CMakeLists.txt (+41/-4) standalone-clients/StandaloneHud.cpp (+171/-0) tests/CMakeLists.txt (+4/-1) tests/test_hud.cpp (+104/-0) tests/test_service_hud.c (+268/-0) tests/test_service_hud.h (+46/-0) tests/test_service_main.c (+6/-2) |
||||||||||||||||
To merge this branch: | bzr merge lp:~gordallott/unity/hud | ||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gord Allott (community) | Approve | ||
John Lea (community) | design review | Approve | |
Andrea Azzarone (community) | Needs Fixing | ||
Mirco Müller (community) | Needs Fixing | ||
Thomi Richards (community) | Needs Fixing | ||
Marco Biscaro (community) | Needs Fixing | ||
Review via email: mp+90085@code.launchpad.net |
This proposal supersedes a proposal from 2012-01-25.
Commit message
Description of the change
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal | # |
Marco Biscaro (marcobiscaro2112) wrote : | # |
- lens_ = service_lens_new();
- model_ = service_
+ //lens_ = service_lens_new();
+ //model_ = service_
+ hud_ = service_hud_new();
If this lines are no longer necessary, they can be removed instead of commented.
- g_object_
- g_object_
+ //g_object_
+ //g_object_
+ g_object_
The same thing here.
Marco Biscaro (marcobiscaro2112) : | # |
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Hi,
There are a few introspection / autopilot issues with this branch:
Your HUDController derives from Introspectable, but you never use it. You need to:
1) Add it to the introspection tree.At Diff line 2729 (where you create the HUDController instance) you need to call "AddChild(
2) Add properties to the HUD controller that will be useful in autopilot tests.
You need to repeat this process with all child objects of the HUDController that derive from Introspectable.
Finally, the string returned from "GetName" should be "HUDController" - you don't need to qualify it with "unity.hud".
In HUDIcon.h you #include "Introspectable.h", but never use it.
In HUDView.h, you've declared a "const gchar* GetName()" method, which is from Introspectable, but there's two problems:
1) You don't derive from Introsopectable (as noted above, you should).
2) That's not the correct method signiture - the return type is "std::string", and the method is const.
In the same class, make sure you add the search bar to the introspection tree - that way we can get the current search string.
Finally, it'd be really nice to have some autopilot tests written when this is merged. I don't mind helping you with this.
Cheers,
Gord Allott (gordallott) wrote : | # |
> Hi,
>
> There are a few introspection / autopilot issues with this branch:
>
> Your HUDController derives from Introspectable, but you never use it. You need
> to:
> 1) Add it to the introspection tree.At Diff line 2729 (where you create the
> HUDController instance) you need to call "AddChild(
> If the HUDController is ever deleted, you need to call
> "RemoveChild(
>
> 2) Add properties to the HUD controller that will be useful in autopilot
> tests.
>
>
> You need to repeat this process with all child objects of the HUDController
> that derive from Introspectable.
>
> Finally, the string returned from "GetName" should be "HUDController" - you
> don't need to qualify it with "unity.hud".
>
> In HUDIcon.h you #include "Introspectable.h", but never use it.
>
> In HUDView.h, you've declared a "const gchar* GetName()" method, which is from
> Introspectable, but there's two problems:
> 1) You don't derive from Introsopectable (as noted above, you should).
> 2) That's not the correct method signiture - the return type is
> "std::string", and the method is const.
>
> In the same class, make sure you add the search bar to the introspection tree
> - that way we can get the current search string.
>
Very much so, Introspection was on my todo list for earlier in the week before last minute changes bumped it off, will fix that up
> Finally, it'd be really nice to have some autopilot tests written when this is
> merged. I don't mind helping you with this.
>
Already have a guy from Systems helping out there, for now manual but he's going through and converting them :)
> Cheers,
Gord Allott (gordallott) wrote : | # |
> - lens_ = service_lens_new();
> - model_ = service_
> + //lens_ = service_lens_new();
> + //model_ = service_
> + hud_ = service_hud_new();
>
> If this lines are no longer necessary, they can be removed instead of
> commented.
>
> - g_object_
> - g_object_
> + //g_object_
> + //g_object_
> + g_object_
>
> The same thing here.
Actually was just left over debugging code ;)
Michal Hruby (mhr3) wrote : | # |
49 self->connected_ = true;
50 - self->owner_
So can we at least not fool IsConnected() users (ie remove the "self->connected_ = true;" as well pls)
150 + GVariant* query_key = g_variant_
Please check that the variant has at least 2 children (or at least that query_key != NULL)
153 + GVariant* queries = g_variant_
173, 176, 189, 192
Same
Mirco Müller (macslow) wrote : | # |
Getting this error during compilation atm:
CMakeFiles/
/tmp/fasel/
/tmp/fasel/
/tmp/fasel/
collect2: ld returned 1 exit status
make[2]: *** [tests/
make[1]: *** [tests/
make: *** [all] Error 2
Mirco Müller (macslow) wrote : | # |
Above mentioned issue solved... typical cmake picking up the wrong libunity-core.so *sigh³*
Mirco Müller (macslow) wrote : | # |
Is the HUD really meant to use the exact same button-visuals from the dash? Does Design demand that?
Should the HUD-searchbar not be of the same width as the Dash-searchbar (in non-fullscreen state at least)?
Please get into the habbit of using const int/float in an unnamed namespace instead of "magic" numbers for padding/
...
+ layout_
...
+ icon_layout-
...
+ search_bar_ = new unity::
...
+ button_
+ button_
...
+ hud_controller_
Andrea Azzarone (azzar1) wrote : | # |
997 + nux::Geometry content_geo = view_->
998 + nux::Geometry geo = GetIdealWindowG
If is it possible, please do something like this:
997 + nux::Geometry const& content_geo = view_->
998 + nux::Geometry geo(GetIdealWin
or at least:
997 + nux::Geometry content_
998 + nux::Geometry geo(GetIdealWin
Andrea Azzarone (azzar1) : | # |
John Lea (johnlea) wrote : | # |
A great improvement, still a bunch of outstanding changes required but a good step in the right direction. Branch approved, look forward to seeing the next iteration with further finesse.
Gord Allott (gordallott) wrote : | # |
approving as latest revision just fixed up conflicts
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2012-02-03 15:02:15 +0000 | |||
3 | +++ CMakeLists.txt 2012-02-06 11:00:29 +0000 | |||
4 | @@ -113,7 +113,7 @@ | |||
5 | 113 | SET (BOOT_LOGGER_FLAG "-DENABLE_LOGGER") | 113 | SET (BOOT_LOGGER_FLAG "-DENABLE_LOGGER") |
6 | 114 | endif (BOOT_LOGGER) | 114 | endif (BOOT_LOGGER) |
7 | 115 | 115 | ||
9 | 116 | SET (MAINTAINER_CFLAGS "-Werror -Wall -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self -Warray-bounds") | 116 | SET (MAINTAINER_CFLAGS "-Wall -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self -Warray-bounds") |
10 | 117 | option (DISABLE_MAINTAINER_CFLAGS "Disable maintainer CFlags" OFF) | 117 | option (DISABLE_MAINTAINER_CFLAGS "Disable maintainer CFlags" OFF) |
11 | 118 | if (DISABLE_MAINTAINER_CFLAGS) | 118 | if (DISABLE_MAINTAINER_CFLAGS) |
12 | 119 | SET (MAINTAINER_CFLAGS "") | 119 | SET (MAINTAINER_CFLAGS "") |
13 | 120 | 120 | ||
14 | === modified file 'UnityCore/CMakeLists.txt' | |||
15 | --- UnityCore/CMakeLists.txt 2012-01-18 13:32:26 +0000 | |||
16 | +++ UnityCore/CMakeLists.txt 2012-02-06 11:00:29 +0000 | |||
17 | @@ -21,6 +21,7 @@ | |||
18 | 21 | GLibSignal-inl.h | 21 | GLibSignal-inl.h |
19 | 22 | GLibWrapper.h | 22 | GLibWrapper.h |
20 | 23 | GLibWrapper-inl.h | 23 | GLibWrapper-inl.h |
21 | 24 | Hud.h | ||
22 | 24 | HomeLens.h | 25 | HomeLens.h |
23 | 25 | IndicatorEntry.h | 26 | IndicatorEntry.h |
24 | 26 | Indicator.h | 27 | Indicator.h |
25 | @@ -54,6 +55,7 @@ | |||
26 | 54 | GLibDBusProxy.cpp | 55 | GLibDBusProxy.cpp |
27 | 55 | GLibSignal.cpp | 56 | GLibSignal.cpp |
28 | 56 | GLibWrapper.cpp | 57 | GLibWrapper.cpp |
29 | 58 | Hud.cpp | ||
30 | 57 | HomeLens.cpp | 59 | HomeLens.cpp |
31 | 58 | Indicator.cpp | 60 | Indicator.cpp |
32 | 59 | IndicatorEntry.cpp | 61 | IndicatorEntry.cpp |
33 | 60 | 62 | ||
34 | === modified file 'UnityCore/GLibDBusProxy.cpp' | |||
35 | --- UnityCore/GLibDBusProxy.cpp 2012-01-19 11:01:58 +0000 | |||
36 | +++ UnityCore/GLibDBusProxy.cpp 2012-02-06 11:00:29 +0000 | |||
37 | @@ -141,11 +141,7 @@ | |||
38 | 141 | gpointer impl) | 141 | gpointer impl) |
39 | 142 | { | 142 | { |
40 | 143 | DBusProxy::Impl* self = static_cast<DBusProxy::Impl*>(impl); | 143 | DBusProxy::Impl* self = static_cast<DBusProxy::Impl*>(impl); |
41 | 144 | |||
42 | 145 | LOG_DEBUG(logger) << self->name_ << " appeared"; | 144 | LOG_DEBUG(logger) << self->name_ << " appeared"; |
43 | 146 | |||
44 | 147 | self->connected_ = true; | ||
45 | 148 | self->owner_->connected.emit(); | ||
46 | 149 | } | 145 | } |
47 | 150 | 146 | ||
48 | 151 | void DBusProxy::Impl::OnNameVanished(GDBusConnection* connection, | 147 | void DBusProxy::Impl::OnNameVanished(GDBusConnection* connection, |
49 | 152 | 148 | ||
50 | === added file 'UnityCore/Hud.cpp' | |||
51 | --- UnityCore/Hud.cpp 1970-01-01 00:00:00 +0000 | |||
52 | +++ UnityCore/Hud.cpp 2012-02-06 11:00:29 +0000 | |||
53 | @@ -0,0 +1,255 @@ | |||
54 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
55 | 2 | /* | ||
56 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
57 | 4 | * | ||
58 | 5 | * This program is free software: you can redistribute it and/or modify | ||
59 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
60 | 7 | * published by the Free Software Foundation. | ||
61 | 8 | * | ||
62 | 9 | * This program is distributed in the hope that it will be useful, | ||
63 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
64 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
65 | 12 | * GNU General Public License for more details. | ||
66 | 13 | * | ||
67 | 14 | * You should have received a copy of the GNU General Public License | ||
68 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
69 | 16 | * | ||
70 | 17 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
71 | 18 | */ | ||
72 | 19 | // | ||
73 | 20 | #include "Hud.h" | ||
74 | 21 | |||
75 | 22 | #include <gio/gio.h> | ||
76 | 23 | #include <glib.h> | ||
77 | 24 | #include <NuxCore/Logger.h> | ||
78 | 25 | #include "GLibWrapper.h" | ||
79 | 26 | #include "GLibDBusProxy.h" | ||
80 | 27 | |||
81 | 28 | #include "config.h" | ||
82 | 29 | |||
83 | 30 | #include <sigc++/bind.h> | ||
84 | 31 | |||
85 | 32 | namespace unity | ||
86 | 33 | { | ||
87 | 34 | namespace hud | ||
88 | 35 | { | ||
89 | 36 | |||
90 | 37 | namespace | ||
91 | 38 | { | ||
92 | 39 | nux::logging::Logger logger("unity.hud.hud"); | ||
93 | 40 | const int request_number_of_results = 6; | ||
94 | 41 | } | ||
95 | 42 | |||
96 | 43 | // Impl classes | ||
97 | 44 | class HudImpl | ||
98 | 45 | { | ||
99 | 46 | public: | ||
100 | 47 | HudImpl(std::string const& dbus_name, | ||
101 | 48 | std::string const& dbus_path, | ||
102 | 49 | Hud *parent) | ||
103 | 50 | : query_key_(NULL) | ||
104 | 51 | , proxy_(dbus_name, dbus_path, "com.canonical.hud") | ||
105 | 52 | , parent_(parent) | ||
106 | 53 | { | ||
107 | 54 | LOG_DEBUG(logger) << "Hud init with name: " << dbus_name << "and path: " << dbus_path; | ||
108 | 55 | proxy_.connected.connect([&]() { | ||
109 | 56 | LOG_DEBUG(logger) << "Hud Connected"; | ||
110 | 57 | parent_->connected = true; | ||
111 | 58 | }); | ||
112 | 59 | |||
113 | 60 | proxy_.Connect("UpdatedQuery", sigc::mem_fun(this, &HudImpl::UpdateQueryCallback)); | ||
114 | 61 | } | ||
115 | 62 | |||
116 | 63 | void QueryCallback(GVariant* data); | ||
117 | 64 | void UpdateQueryCallback(GVariant* data); | ||
118 | 65 | void BuildQueries(GVariant* query_array); | ||
119 | 66 | void ExecuteByKey(GVariant* key, unsigned int timestamp); | ||
120 | 67 | void ExecuteQueryByStringCallback(GVariant* query, unsigned int timestamp); | ||
121 | 68 | void CloseQuery(); | ||
122 | 69 | |||
123 | 70 | GVariant* query_key_; | ||
124 | 71 | Hud::Queries queries_; | ||
125 | 72 | glib::DBusProxy proxy_; | ||
126 | 73 | Hud* parent_; | ||
127 | 74 | }; | ||
128 | 75 | |||
129 | 76 | void HudImpl::ExecuteByKey(GVariant* key, unsigned int timestamp) | ||
130 | 77 | { | ||
131 | 78 | LOG_DEBUG(logger) << "Executing by Key"; | ||
132 | 79 | |||
133 | 80 | GVariantBuilder tuple; | ||
134 | 81 | g_variant_builder_init(&tuple, G_VARIANT_TYPE_TUPLE); | ||
135 | 82 | g_variant_builder_add_value(&tuple, g_variant_new_variant(key)); | ||
136 | 83 | g_variant_builder_add_value(&tuple, g_variant_new_uint32(timestamp)); | ||
137 | 84 | |||
138 | 85 | proxy_.Call("ExecuteQuery", g_variant_builder_end(&tuple)); | ||
139 | 86 | } | ||
140 | 87 | |||
141 | 88 | void HudImpl::ExecuteQueryByStringCallback(GVariant* query, unsigned int timestamp) | ||
142 | 89 | { | ||
143 | 90 | if (g_variant_n_children(query) < 3) | ||
144 | 91 | { | ||
145 | 92 | LOG_ERROR(logger) << "Received (" << g_variant_n_children(query) << ") children in a query, expected 3"; | ||
146 | 93 | return; | ||
147 | 94 | } | ||
148 | 95 | |||
149 | 96 | queries_.clear(); | ||
150 | 97 | |||
151 | 98 | GVariant* query_key = g_variant_get_child_value(query, 2); | ||
152 | 99 | query_key_ = query_key; | ||
153 | 100 | |||
154 | 101 | GVariant* queries = g_variant_get_child_value(query, 1); | ||
155 | 102 | BuildQueries(queries); | ||
156 | 103 | g_variant_unref(queries); | ||
157 | 104 | |||
158 | 105 | if (queries_.empty() == false) | ||
159 | 106 | { | ||
160 | 107 | // we now execute based off the first result | ||
161 | 108 | ExecuteByKey(queries_.front()->key, timestamp); | ||
162 | 109 | CloseQuery(); | ||
163 | 110 | } | ||
164 | 111 | } | ||
165 | 112 | |||
166 | 113 | void HudImpl::QueryCallback(GVariant* query) | ||
167 | 114 | { | ||
168 | 115 | if (g_variant_n_children(query) < 3) | ||
169 | 116 | { | ||
170 | 117 | LOG_ERROR(logger) << "Received (" << g_variant_n_children(query) << ") children in a query, expected 3"; | ||
171 | 118 | return; | ||
172 | 119 | } | ||
173 | 120 | queries_.clear(); | ||
174 | 121 | |||
175 | 122 | // extract the information from the GVariants | ||
176 | 123 | GVariant* target = g_variant_get_child_value(query, 0); | ||
177 | 124 | g_variant_unref(target); | ||
178 | 125 | |||
179 | 126 | GVariant* query_key = g_variant_get_child_value(query, 2); | ||
180 | 127 | query_key_ = query_key; | ||
181 | 128 | |||
182 | 129 | GVariant* queries = g_variant_get_child_value(query, 1); | ||
183 | 130 | BuildQueries(queries); | ||
184 | 131 | g_variant_unref(queries); | ||
185 | 132 | |||
186 | 133 | parent_->queries_updated.emit(queries_); | ||
187 | 134 | } | ||
188 | 135 | |||
189 | 136 | void HudImpl::UpdateQueryCallback(GVariant* query) | ||
190 | 137 | { | ||
191 | 138 | if (g_variant_n_children(query) < 3) | ||
192 | 139 | { | ||
193 | 140 | LOG_ERROR(logger) << "Received (" << g_variant_n_children(query) << ") children in a query, expected 3"; | ||
194 | 141 | return; | ||
195 | 142 | } | ||
196 | 143 | // as we are expecting an update, we want to check | ||
197 | 144 | // and make sure that we are the actual receivers of | ||
198 | 145 | // the signal | ||
199 | 146 | |||
200 | 147 | GVariant* query_key = g_variant_get_child_value(query, 2); | ||
201 | 148 | if (g_variant_equal(query_key_, query_key)) | ||
202 | 149 | { | ||
203 | 150 | GVariant* queries = g_variant_get_child_value(query, 1); | ||
204 | 151 | BuildQueries(queries); | ||
205 | 152 | g_variant_unref(queries); | ||
206 | 153 | } | ||
207 | 154 | } | ||
208 | 155 | |||
209 | 156 | void HudImpl::BuildQueries(GVariant* query_array) | ||
210 | 157 | { | ||
211 | 158 | GVariantIter iter; | ||
212 | 159 | g_variant_iter_init(&iter, query_array); | ||
213 | 160 | glib::String formatted_text; | ||
214 | 161 | glib::String icon; | ||
215 | 162 | glib::String item_icon; | ||
216 | 163 | glib::String completion_text; | ||
217 | 164 | glib::String shortcut; | ||
218 | 165 | GVariant* key = NULL; | ||
219 | 166 | |||
220 | 167 | while (g_variant_iter_loop(&iter, "(sssssv)", | ||
221 | 168 | &formatted_text, &icon, &item_icon, &completion_text, &shortcut, &key)) | ||
222 | 169 | { | ||
223 | 170 | queries_.push_back(Query::Ptr(new Query(formatted_text, | ||
224 | 171 | icon, | ||
225 | 172 | item_icon, | ||
226 | 173 | completion_text, | ||
227 | 174 | shortcut, | ||
228 | 175 | key))); | ||
229 | 176 | } | ||
230 | 177 | } | ||
231 | 178 | |||
232 | 179 | void HudImpl::CloseQuery() | ||
233 | 180 | { | ||
234 | 181 | if (query_key_ == NULL) | ||
235 | 182 | { | ||
236 | 183 | LOG_WARN(logger) << "Attempted to close the hud connection without starting it"; | ||
237 | 184 | } | ||
238 | 185 | else | ||
239 | 186 | { | ||
240 | 187 | GVariant* paramaters = g_variant_new("(v)", query_key_); | ||
241 | 188 | proxy_.Call("CloseQuery", paramaters); | ||
242 | 189 | g_variant_unref(query_key_); | ||
243 | 190 | query_key_ = NULL; | ||
244 | 191 | queries_.clear(); | ||
245 | 192 | } | ||
246 | 193 | } | ||
247 | 194 | |||
248 | 195 | |||
249 | 196 | Hud::Hud(std::string const& dbus_name, | ||
250 | 197 | std::string const& dbus_path) | ||
251 | 198 | : connected(false) | ||
252 | 199 | , pimpl_(new HudImpl(dbus_name, dbus_path, this)) | ||
253 | 200 | { | ||
254 | 201 | pimpl_->parent_ = this; | ||
255 | 202 | } | ||
256 | 203 | |||
257 | 204 | Hud::~Hud() | ||
258 | 205 | { | ||
259 | 206 | delete pimpl_; | ||
260 | 207 | } | ||
261 | 208 | |||
262 | 209 | void Hud::RequestQuery(std::string const& search_string) | ||
263 | 210 | { | ||
264 | 211 | LOG_DEBUG(logger) << "Getting Query: " << search_string; | ||
265 | 212 | if (pimpl_->query_key_ != NULL) | ||
266 | 213 | { | ||
267 | 214 | CloseQuery(); | ||
268 | 215 | } | ||
269 | 216 | |||
270 | 217 | GVariant* paramaters = g_variant_new("(si)", | ||
271 | 218 | search_string.c_str(), | ||
272 | 219 | request_number_of_results); | ||
273 | 220 | pimpl_->proxy_.Call("StartQuery", paramaters, sigc::mem_fun(this->pimpl_, &HudImpl::QueryCallback)); | ||
274 | 221 | } | ||
275 | 222 | |||
276 | 223 | |||
277 | 224 | void Hud::ExecuteQuery(Query::Ptr query, unsigned int timestamp) | ||
278 | 225 | { | ||
279 | 226 | LOG_DEBUG(logger) << "Executing query: " << query->formatted_text; | ||
280 | 227 | pimpl_->ExecuteByKey(query->key, timestamp); | ||
281 | 228 | } | ||
282 | 229 | |||
283 | 230 | void Hud::ExecuteQueryBySearch(std::string execute_string, unsigned int timestamp) | ||
284 | 231 | { | ||
285 | 232 | //Does a search then executes the result based on that search | ||
286 | 233 | LOG_DEBUG(logger) << "Executing by string" << execute_string; | ||
287 | 234 | if (pimpl_->query_key_ != NULL) | ||
288 | 235 | { | ||
289 | 236 | CloseQuery(); | ||
290 | 237 | } | ||
291 | 238 | |||
292 | 239 | GVariant* paramaters = g_variant_new("(si)", | ||
293 | 240 | execute_string.c_str(), | ||
294 | 241 | 1); | ||
295 | 242 | |||
296 | 243 | auto functor = sigc::mem_fun(this->pimpl_, &HudImpl::ExecuteQueryByStringCallback); | ||
297 | 244 | |||
298 | 245 | pimpl_->proxy_.Call("StartQuery", paramaters, sigc::bind(functor, timestamp)); | ||
299 | 246 | } | ||
300 | 247 | |||
301 | 248 | void Hud::CloseQuery() | ||
302 | 249 | { | ||
303 | 250 | //Send close hint to the hud | ||
304 | 251 | pimpl_->CloseQuery(); | ||
305 | 252 | } | ||
306 | 253 | |||
307 | 254 | } | ||
308 | 255 | } | ||
309 | 0 | 256 | ||
310 | === added file 'UnityCore/Hud.h' | |||
311 | --- UnityCore/Hud.h 1970-01-01 00:00:00 +0000 | |||
312 | +++ UnityCore/Hud.h 2012-02-06 11:00:29 +0000 | |||
313 | @@ -0,0 +1,127 @@ | |||
314 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
315 | 2 | /* | ||
316 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
317 | 4 | * | ||
318 | 5 | * This program is free software: you can redistribute it and/or modify | ||
319 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
320 | 7 | * published by the Free Software Foundation. | ||
321 | 8 | * | ||
322 | 9 | * This program is distributed in the hope that it will be useful, | ||
323 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
324 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
325 | 12 | * GNU General Public License for more details. | ||
326 | 13 | * | ||
327 | 14 | * You should have received a copy of the GNU General Public License | ||
328 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
329 | 16 | * | ||
330 | 17 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
331 | 18 | */ | ||
332 | 19 | |||
333 | 20 | #ifndef UNITY_HUD_H | ||
334 | 21 | #define UNITY_HUD_H | ||
335 | 22 | |||
336 | 23 | #include <deque> | ||
337 | 24 | #include <string> | ||
338 | 25 | #include <memory> | ||
339 | 26 | #include <NuxCore/Property.h> | ||
340 | 27 | #include <glib/gvariant.h> | ||
341 | 28 | |||
342 | 29 | namespace unity | ||
343 | 30 | { | ||
344 | 31 | namespace hud | ||
345 | 32 | { | ||
346 | 33 | |||
347 | 34 | |||
348 | 35 | class Query | ||
349 | 36 | { | ||
350 | 37 | public: | ||
351 | 38 | typedef std::shared_ptr<Query> Ptr; | ||
352 | 39 | |||
353 | 40 | Query(std::string const& formatted_text_, std::string const& icon_name_, | ||
354 | 41 | std::string const& item_icon_, std::string const& completion_text_, | ||
355 | 42 | std::string const& shortcut_, GVariant* key_) | ||
356 | 43 | : formatted_text(formatted_text_) | ||
357 | 44 | , icon_name(icon_name_) | ||
358 | 45 | , item_icon(item_icon_) | ||
359 | 46 | , completion_text(completion_text_) | ||
360 | 47 | , shortcut(shortcut_) | ||
361 | 48 | , key(key_) | ||
362 | 49 | { | ||
363 | 50 | g_variant_ref(key); | ||
364 | 51 | } | ||
365 | 52 | |||
366 | 53 | ~Query() | ||
367 | 54 | { | ||
368 | 55 | g_variant_unref(key); | ||
369 | 56 | } | ||
370 | 57 | |||
371 | 58 | Query(const Query &rhs); | ||
372 | 59 | Query& operator=(Query); | ||
373 | 60 | |||
374 | 61 | std::string formatted_text; // Pango formatted text | ||
375 | 62 | std::string icon_name; // icon name using standard lookups | ||
376 | 63 | std::string item_icon; // Future API | ||
377 | 64 | std::string completion_text; // Non formatted text f or completion | ||
378 | 65 | std::string shortcut; // Shortcut key | ||
379 | 66 | GVariant *key; | ||
380 | 67 | }; | ||
381 | 68 | |||
382 | 69 | |||
383 | 70 | class HudImpl; | ||
384 | 71 | class Hud | ||
385 | 72 | { | ||
386 | 73 | public: | ||
387 | 74 | typedef std::shared_ptr<Hud> Ptr; | ||
388 | 75 | typedef std::deque<Query::Ptr> Queries; | ||
389 | 76 | |||
390 | 77 | /* | ||
391 | 78 | * Constructor for the hud | ||
392 | 79 | * \param dbus_name string that specifies the name of the hud service | ||
393 | 80 | * \param dbus_path string that specifies the path of the hud service | ||
394 | 81 | */ | ||
395 | 82 | Hud(std::string const& dbus_name, | ||
396 | 83 | std::string const& dbus_path); | ||
397 | 84 | |||
398 | 85 | ~Hud(); | ||
399 | 86 | |||
400 | 87 | Hud(const Hud &rhs); | ||
401 | 88 | Hud& operator=(Hud); | ||
402 | 89 | |||
403 | 90 | nux::Property<std::string> target; | ||
404 | 91 | nux::Property<bool> connected; | ||
405 | 92 | |||
406 | 93 | /* | ||
407 | 94 | * Queries the service for new suggestions, will fire off the | ||
408 | 95 | * suggestion_search_finished signal when the suggestions are returned | ||
409 | 96 | */ | ||
410 | 97 | void RequestQuery(std::string const& search_string); | ||
411 | 98 | |||
412 | 99 | /* | ||
413 | 100 | * Executes a Query | ||
414 | 101 | */ | ||
415 | 102 | void ExecuteQuery(Query::Ptr query, unsigned int timestamp); | ||
416 | 103 | |||
417 | 104 | /* | ||
418 | 105 | * Executes a query that returns from a search, | ||
419 | 106 | * Implicitly calls CloseQuery(); | ||
420 | 107 | */ | ||
421 | 108 | void ExecuteQueryBySearch(std::string execute_string, unsigned int timestamp); | ||
422 | 109 | |||
423 | 110 | /* | ||
424 | 111 | * Closes the query connection, call when the hud closes | ||
425 | 112 | */ | ||
426 | 113 | void CloseQuery(); | ||
427 | 114 | |||
428 | 115 | /* | ||
429 | 116 | * Returns a deque of Query types when the service provides them | ||
430 | 117 | */ | ||
431 | 118 | sigc::signal<void, Queries> queries_updated; | ||
432 | 119 | |||
433 | 120 | private: | ||
434 | 121 | HudImpl *pimpl_; | ||
435 | 122 | }; | ||
436 | 123 | |||
437 | 124 | } | ||
438 | 125 | } | ||
439 | 126 | |||
440 | 127 | #endif /* UNITY_HUD_H */ | ||
441 | 0 | 128 | ||
442 | === added file 'manual-tests/Hud.txt' | |||
443 | --- manual-tests/Hud.txt 1970-01-01 00:00:00 +0000 | |||
444 | +++ manual-tests/Hud.txt 2012-02-06 11:00:29 +0000 | |||
445 | @@ -0,0 +1,57 @@ | |||
446 | 1 | For reference, the term Tap means to press the indicated key and release it, within a timeframe of 50ms | ||
447 | 2 | |||
448 | 3 | Hud Invocate | ||
449 | 4 | ----------- | ||
450 | 5 | This test makes sure that the hud presents itself, the launcher hides | ||
451 | 6 | and the panel changes | ||
452 | 7 | |||
453 | 8 | #. Tap Alt | ||
454 | 9 | |||
455 | 10 | Outcome | ||
456 | 11 | The hud interface presents itself with no other interface such as the dash present. | ||
457 | 12 | The Launcher hides, the panel becomes transparent with a colour tint matching the hud | ||
458 | 13 | |||
459 | 14 | Hud Search | ||
460 | 15 | ----------- | ||
461 | 16 | This test makes sure that the hud will search and activate items. | ||
462 | 17 | |||
463 | 18 | #. Ensure the devices indicator is present | ||
464 | 19 | #. Tap Alt | ||
465 | 20 | #. Type "system" to search for the "System settings..." item in the devices indicator | ||
466 | 21 | #. Press return to activate the search query. | ||
467 | 22 | |||
468 | 23 | Outcome | ||
469 | 24 | The system settings interface presents itself, the hud disappears. | ||
470 | 25 | If the hud does not disappear, this test failed. If the system settings interface | ||
471 | 26 | did not present itself, this test did *not* fail. | ||
472 | 27 | |||
473 | 28 | |||
474 | 29 | Hud Key-Navigation | ||
475 | 30 | ----------- | ||
476 | 31 | This test ensures the hud key navigation is intact | ||
477 | 32 | |||
478 | 33 | #. Ensure the messaging indicator is present | ||
479 | 34 | #. Tap Alt | ||
480 | 35 | #. Type "Message" to search for items from the messaging indicator | ||
481 | 36 | #. Press down twice | ||
482 | 37 | #. Press return | ||
483 | 38 | |||
484 | 39 | Outcome | ||
485 | 40 | The item selected will activate and the hud with disappear. | ||
486 | 41 | If the hud does not disappear, this test failed. | ||
487 | 42 | If the buttons under the search box do not highlight, this test failed. | ||
488 | 43 | |||
489 | 44 | |||
490 | 45 | Hud Dismiss | ||
491 | 46 | ---------- | ||
492 | 47 | This test ensures that the hud is dismissable | ||
493 | 48 | |||
494 | 49 | #. Tap Alt | ||
495 | 50 | #. Type "test" | ||
496 | 51 | #. Press escape | ||
497 | 52 | #. Click anywhere on the screen that is not the hud interface | ||
498 | 53 | |||
499 | 54 | Outcome | ||
500 | 55 | After pressing escape in step three, the text "test" should be removed from the hud search | ||
501 | 56 | After step four, the hud should dismiss itself and not be present. | ||
502 | 57 | |||
503 | 0 | 58 | ||
504 | === modified file 'plugins/unityshell/src/DashController.cpp' | |||
505 | --- plugins/unityshell/src/DashController.cpp 2012-02-04 01:55:49 +0000 | |||
506 | +++ plugins/unityshell/src/DashController.cpp 2012-02-06 11:00:29 +0000 | |||
507 | @@ -118,6 +118,18 @@ | |||
508 | 118 | sigc::mem_fun(this, &Controller::OnActivateRequest)); | 118 | sigc::mem_fun(this, &Controller::OnActivateRequest)); |
509 | 119 | ubus_manager_.RegisterInterest(UBUS_DASH_ABOUT_TO_SHOW, | 119 | ubus_manager_.RegisterInterest(UBUS_DASH_ABOUT_TO_SHOW, |
510 | 120 | [&] (GVariant*) { EnsureDash(); }); | 120 | [&] (GVariant*) { EnsureDash(); }); |
511 | 121 | ubus_manager_.RegisterInterest(UBUS_OVERLAY_SHOWN, [&] (GVariant *data) { | ||
512 | 122 | unity::glib::String overlay_identity; | ||
513 | 123 | gboolean can_maximise = FALSE; | ||
514 | 124 | gint32 overlay_monitor = 0; | ||
515 | 125 | g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING, &overlay_identity, &can_maximise, &overlay_monitor); | ||
516 | 126 | |||
517 | 127 | // hide if something else is coming up | ||
518 | 128 | if (g_strcmp0(overlay_identity, "dash")) | ||
519 | 129 | { | ||
520 | 130 | HideDash(true); | ||
521 | 131 | } | ||
522 | 132 | }); | ||
523 | 121 | } | 133 | } |
524 | 122 | 134 | ||
525 | 123 | void Controller::EnsureDash() | 135 | void Controller::EnsureDash() |
526 | 124 | 136 | ||
527 | === modified file 'plugins/unityshell/src/DashStyle.cpp' | |||
528 | --- plugins/unityshell/src/DashStyle.cpp 2012-01-19 11:57:37 +0000 | |||
529 | +++ plugins/unityshell/src/DashStyle.cpp 2012-02-06 11:00:29 +0000 | |||
530 | @@ -119,6 +119,7 @@ | |||
531 | 119 | void Text(cairo_t* cr, | 119 | void Text(cairo_t* cr, |
532 | 120 | nux::Color const& color, | 120 | nux::Color const& color, |
533 | 121 | std::string const& label, | 121 | std::string const& label, |
534 | 122 | int font_size = -1, | ||
535 | 122 | double horizMargin = 10.0, | 123 | double horizMargin = 10.0, |
536 | 123 | Alignment alignment = Alignment::CENTER); | 124 | Alignment alignment = Alignment::CENTER); |
537 | 124 | 125 | ||
538 | @@ -1325,6 +1326,7 @@ | |||
539 | 1325 | void Style::Impl::Text(cairo_t* cr, | 1326 | void Style::Impl::Text(cairo_t* cr, |
540 | 1326 | nux::Color const& color, | 1327 | nux::Color const& color, |
541 | 1327 | std::string const& label, | 1328 | std::string const& label, |
542 | 1329 | int text_size, | ||
543 | 1328 | double horizMargin, | 1330 | double horizMargin, |
544 | 1329 | Alignment alignment) | 1331 | Alignment alignment) |
545 | 1330 | { | 1332 | { |
546 | @@ -1358,6 +1360,11 @@ | |||
547 | 1358 | else | 1360 | else |
548 | 1359 | desc = pango_font_description_from_string(fontName); | 1361 | desc = pango_font_description_from_string(fontName); |
549 | 1360 | 1362 | ||
550 | 1363 | if (text_size > 0) | ||
551 | 1364 | { | ||
552 | 1365 | pango_font_description_set_absolute_size(desc, text_size * PANGO_SCALE); | ||
553 | 1366 | } | ||
554 | 1367 | |||
555 | 1361 | PangoWeight weight; | 1368 | PangoWeight weight; |
556 | 1362 | switch (regular_text_weight_) | 1369 | switch (regular_text_weight_) |
557 | 1363 | { | 1370 | { |
558 | @@ -1428,6 +1435,7 @@ | |||
559 | 1428 | pango_layout_get_extents(layout, &ink, &log); | 1435 | pango_layout_get_extents(layout, &ink, &log); |
560 | 1429 | x = horizMargin; // let pango alignment handle the x position | 1436 | x = horizMargin; // let pango alignment handle the x position |
561 | 1430 | y = ((double) h - pango_units_to_double(log.height)) / 2.0; | 1437 | y = ((double) h - pango_units_to_double(log.height)) / 2.0; |
562 | 1438 | |||
563 | 1431 | cairo_move_to(cr, x, y); | 1439 | cairo_move_to(cr, x, y); |
564 | 1432 | pango_cairo_show_layout(cr, layout); | 1440 | pango_cairo_show_layout(cr, layout); |
565 | 1433 | 1441 | ||
566 | @@ -1530,7 +1538,9 @@ | |||
567 | 1530 | cairo_set_operator(cr, old); | 1538 | cairo_set_operator(cr, old); |
568 | 1531 | } | 1539 | } |
569 | 1532 | 1540 | ||
571 | 1533 | bool Style::Button(cairo_t* cr, nux::ButtonVisualState state, std::string const& label, Alignment alignment) | 1541 | bool Style::Button(cairo_t* cr, nux::ButtonVisualState state, |
572 | 1542 | std::string const& label, int font_size, | ||
573 | 1543 | Alignment alignment, bool zeromargin) | ||
574 | 1534 | { | 1544 | { |
575 | 1535 | // sanity checks | 1545 | // sanity checks |
576 | 1536 | if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) | 1546 | if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) |
577 | @@ -1539,8 +1549,10 @@ | |||
578 | 1539 | if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE) | 1549 | if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE) |
579 | 1540 | return false; | 1550 | return false; |
580 | 1541 | 1551 | ||
583 | 1542 | unsigned int garnish = GetButtonGarnishSize(); | 1552 | unsigned int garnish = 0; |
584 | 1543 | 1553 | if (zeromargin == false) | |
585 | 1554 | garnish = GetButtonGarnishSize(); | ||
586 | 1555 | |||
587 | 1544 | //ButtonOutlinePath(cr, true); | 1556 | //ButtonOutlinePath(cr, true); |
588 | 1545 | double w = cairo_image_surface_get_width(cairo_get_target(cr)); | 1557 | double w = cairo_image_surface_get_width(cairo_get_target(cr)); |
589 | 1546 | double h = cairo_image_surface_get_height(cairo_get_target(cr)); | 1558 | double h = cairo_image_surface_get_height(cairo_get_target(cr)); |
590 | @@ -1571,7 +1583,6 @@ | |||
591 | 1571 | cairo_fill_preserve(cr); | 1583 | cairo_fill_preserve(cr); |
592 | 1572 | } | 1584 | } |
593 | 1573 | cairo_set_source_rgba(cr, pimpl->button_label_border_color_[state]); | 1585 | cairo_set_source_rgba(cr, pimpl->button_label_border_color_[state]); |
594 | 1574 | //cairo_set_line_width(cr, pimpl->button_label_border_size_[state]); | ||
595 | 1575 | cairo_stroke(cr); | 1586 | cairo_stroke(cr); |
596 | 1576 | 1587 | ||
597 | 1577 | pimpl->DrawOverlay(cr, | 1588 | pimpl->DrawOverlay(cr, |
598 | @@ -1582,12 +1593,133 @@ | |||
599 | 1582 | pimpl->Text(cr, | 1593 | pimpl->Text(cr, |
600 | 1583 | pimpl->button_label_text_color_[state], | 1594 | pimpl->button_label_text_color_[state], |
601 | 1584 | label, | 1595 | label, |
602 | 1596 | font_size, | ||
603 | 1585 | 10.0, | 1597 | 10.0, |
604 | 1586 | alignment); | 1598 | alignment); |
605 | 1587 | 1599 | ||
606 | 1588 | return true; | 1600 | return true; |
607 | 1589 | } | 1601 | } |
608 | 1590 | 1602 | ||
609 | 1603 | bool Style::SquareButton(cairo_t* cr, nux::ButtonVisualState state, | ||
610 | 1604 | std::string const& label, bool curve_bottom, | ||
611 | 1605 | int font_size, Alignment alignment, | ||
612 | 1606 | bool zeromargin) | ||
613 | 1607 | { | ||
614 | 1608 | // sanity checks | ||
615 | 1609 | if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) | ||
616 | 1610 | return false; | ||
617 | 1611 | |||
618 | 1612 | if (cairo_surface_get_type(cairo_get_target(cr)) != CAIRO_SURFACE_TYPE_IMAGE) | ||
619 | 1613 | return false; | ||
620 | 1614 | |||
621 | 1615 | unsigned int garnish = 0; | ||
622 | 1616 | if (zeromargin == false) | ||
623 | 1617 | garnish = GetButtonGarnishSize(); | ||
624 | 1618 | |||
625 | 1619 | double w = cairo_image_surface_get_width(cairo_get_target(cr)); | ||
626 | 1620 | double h = cairo_image_surface_get_height(cairo_get_target(cr)); | ||
627 | 1621 | |||
628 | 1622 | double x = garnish; | ||
629 | 1623 | double y = garnish; | ||
630 | 1624 | |||
631 | 1625 | double width = w - (2.0 * garnish) - 1.0; | ||
632 | 1626 | double height = h - (2.0 * garnish) - 1.0; | ||
633 | 1627 | |||
634 | 1628 | bool odd = true; | ||
635 | 1629 | double radius = 7.0; | ||
636 | 1630 | |||
637 | 1631 | // draw the grid background | ||
638 | 1632 | { | ||
639 | 1633 | cairo_set_line_width(cr, 1); | ||
640 | 1634 | cairo_move_to(cr, _align(x + width, odd), _align(y, odd)); | ||
641 | 1635 | if (curve_bottom) | ||
642 | 1636 | { | ||
643 | 1637 | LOG_DEBUG(logger) << "curve: " << _align(x + width, odd) << " - " << _align(y + height - radius, odd); | ||
644 | 1638 | // line to bottom-right corner | ||
645 | 1639 | cairo_line_to(cr, _align(x + width, odd), _align(y + height - radius, odd)); | ||
646 | 1640 | |||
647 | 1641 | // line to bottom-right, left of the corner | ||
648 | 1642 | cairo_arc(cr, | ||
649 | 1643 | _align(x + width - radius, odd), | ||
650 | 1644 | _align(y + height - radius, odd), | ||
651 | 1645 | radius, | ||
652 | 1646 | 0.0f * G_PI / 180.0f, | ||
653 | 1647 | 90.0f * G_PI / 180.0f); | ||
654 | 1648 | |||
655 | 1649 | // line to bottom-left, right of the corner | ||
656 | 1650 | cairo_line_to(cr, _align(x + radius, odd), _align(y + height, odd)); | ||
657 | 1651 | |||
658 | 1652 | // line to bottom-left, above the corner | ||
659 | 1653 | cairo_arc(cr, | ||
660 | 1654 | _align(x + radius, odd), | ||
661 | 1655 | _align(y + height - radius, odd), | ||
662 | 1656 | radius, | ||
663 | 1657 | 90.0f * G_PI / 180.0f, | ||
664 | 1658 | 180.0f * G_PI / 180.0f); | ||
665 | 1659 | |||
666 | 1660 | // line to top | ||
667 | 1661 | cairo_line_to(cr, _align(x, odd), _align(y, odd)); | ||
668 | 1662 | } | ||
669 | 1663 | else | ||
670 | 1664 | { | ||
671 | 1665 | cairo_line_to(cr, _align(x + width, odd), _align(y + height, odd)); | ||
672 | 1666 | cairo_line_to(cr, _align(x, odd), _align(x + height, odd)); | ||
673 | 1667 | cairo_line_to(cr, _align(x, odd), _align(y, odd)); | ||
674 | 1668 | } | ||
675 | 1669 | |||
676 | 1670 | cairo_set_source_rgba(cr, pimpl->button_label_border_color_[nux::ButtonVisualState::VISUAL_STATE_NORMAL]); | ||
677 | 1671 | cairo_stroke(cr); | ||
678 | 1672 | } | ||
679 | 1673 | |||
680 | 1674 | cairo_set_line_width(cr, pimpl->button_label_border_size_[state]); | ||
681 | 1675 | odd = cairo_get_line_width(cr) == 2.0 ? false : true; | ||
682 | 1676 | |||
683 | 1677 | |||
684 | 1678 | if (pimpl->button_label_border_size_[state] == 2.0) | ||
685 | 1679 | { | ||
686 | 1680 | x += 1; | ||
687 | 1681 | y += 1; | ||
688 | 1682 | width -= 1.0; | ||
689 | 1683 | height -= 1.0; | ||
690 | 1684 | } | ||
691 | 1685 | |||
692 | 1686 | if (state == nux::ButtonVisualState::VISUAL_STATE_PRESSED) | ||
693 | 1687 | { | ||
694 | 1688 | RoundedRect(cr, | ||
695 | 1689 | 1.0, | ||
696 | 1690 | _align(x, odd), _align(y, odd), | ||
697 | 1691 | 5.0, | ||
698 | 1692 | _align(width, odd), _align(height, odd)); | ||
699 | 1693 | |||
700 | 1694 | if (pimpl->button_label_fill_color_[state].alpha != 0.0) | ||
701 | 1695 | { | ||
702 | 1696 | cairo_set_source_rgba(cr, pimpl->button_label_fill_color_[state]); | ||
703 | 1697 | cairo_fill_preserve(cr); | ||
704 | 1698 | } | ||
705 | 1699 | cairo_set_source_rgba(cr, pimpl->button_label_border_color_[state]); | ||
706 | 1700 | cairo_stroke(cr); | ||
707 | 1701 | } | ||
708 | 1702 | |||
709 | 1703 | pimpl->DrawOverlay(cr, | ||
710 | 1704 | pimpl->button_label_overlay_opacity_[state], | ||
711 | 1705 | pimpl->button_label_overlay_mode_[state], | ||
712 | 1706 | pimpl->button_label_blur_size_[state] * 0.75); | ||
713 | 1707 | |||
714 | 1708 | // FIXME - magic value of 42 here for the offset in the HUD, | ||
715 | 1709 | // replace with a nicer style system that lets hud override | ||
716 | 1710 | // default values when it needs to | ||
717 | 1711 | pimpl->Text(cr, | ||
718 | 1712 | pimpl->button_label_text_color_[state], | ||
719 | 1713 | label, | ||
720 | 1714 | font_size, | ||
721 | 1715 | 42.0 + 10.0, | ||
722 | 1716 | alignment); | ||
723 | 1717 | |||
724 | 1718 | cairo_surface_write_to_png(cairo_get_target(cr), "/tmp/wut.png"); | ||
725 | 1719 | |||
726 | 1720 | return true; | ||
727 | 1721 | } | ||
728 | 1722 | |||
729 | 1591 | bool Style::StarEmpty(cairo_t* cr, nux::ButtonVisualState state) | 1723 | bool Style::StarEmpty(cairo_t* cr, nux::ButtonVisualState state) |
730 | 1592 | { | 1724 | { |
731 | 1593 | // sanity checks | 1725 | // sanity checks |
732 | 1594 | 1726 | ||
733 | === modified file 'plugins/unityshell/src/DashStyle.h' | |||
734 | --- plugins/unityshell/src/DashStyle.h 2012-01-19 11:51:57 +0000 | |||
735 | +++ plugins/unityshell/src/DashStyle.h 2012-02-06 11:00:29 +0000 | |||
736 | @@ -87,8 +87,15 @@ | |||
737 | 87 | static Style& Instance(); | 87 | static Style& Instance(); |
738 | 88 | 88 | ||
739 | 89 | virtual bool Button(cairo_t* cr, nux::ButtonVisualState state, | 89 | virtual bool Button(cairo_t* cr, nux::ButtonVisualState state, |
742 | 90 | std::string const& label, | 90 | std::string const& label, int font_size=-1, |
743 | 91 | Alignment alignment = Alignment::CENTER); | 91 | Alignment alignment = Alignment::CENTER, |
744 | 92 | bool zeromargin=false); | ||
745 | 93 | |||
746 | 94 | virtual bool SquareButton(cairo_t* cr, nux::ButtonVisualState state, | ||
747 | 95 | std::string const& label, bool curve_bottom, | ||
748 | 96 | int font_size=-1, | ||
749 | 97 | Alignment alignment = Alignment::CENTER, | ||
750 | 98 | bool zeromargin=false); | ||
751 | 92 | 99 | ||
752 | 93 | virtual bool StarEmpty(cairo_t* cr, nux::ButtonVisualState state); | 100 | virtual bool StarEmpty(cairo_t* cr, nux::ButtonVisualState state); |
753 | 94 | 101 | ||
754 | 95 | 102 | ||
755 | === modified file 'plugins/unityshell/src/DashView.h' | |||
756 | --- plugins/unityshell/src/DashView.h 2012-01-27 06:58:20 +0000 | |||
757 | +++ plugins/unityshell/src/DashView.h 2012-02-06 11:00:29 +0000 | |||
758 | @@ -30,7 +30,7 @@ | |||
759 | 30 | #include <UnityCore/HomeLens.h> | 30 | #include <UnityCore/HomeLens.h> |
760 | 31 | 31 | ||
761 | 32 | #include "BackgroundEffectHelper.h" | 32 | #include "BackgroundEffectHelper.h" |
763 | 33 | #include "DashSearchBar.h" | 33 | #include "SearchBar.h" |
764 | 34 | #include "Introspectable.h" | 34 | #include "Introspectable.h" |
765 | 35 | #include "LensBar.h" | 35 | #include "LensBar.h" |
766 | 36 | #include "LensView.h" | 36 | #include "LensView.h" |
767 | 37 | 37 | ||
768 | === modified file 'plugins/unityshell/src/FilterAllButton.cpp' | |||
769 | --- plugins/unityshell/src/FilterAllButton.cpp 2012-01-10 14:09:12 +0000 | |||
770 | +++ plugins/unityshell/src/FilterAllButton.cpp 2012-02-06 11:00:29 +0000 | |||
771 | @@ -59,6 +59,7 @@ | |||
772 | 59 | { | 59 | { |
773 | 60 | if (filter_ and Active()) | 60 | if (filter_ and Active()) |
774 | 61 | filter_->Clear(); | 61 | filter_->Clear(); |
775 | 62 | QueueDraw(); | ||
776 | 62 | } | 63 | } |
777 | 63 | 64 | ||
778 | 64 | void FilterAllButton::OnFilteringChanged(bool filtering) | 65 | void FilterAllButton::OnFilteringChanged(bool filtering) |
779 | 65 | 66 | ||
780 | === added file 'plugins/unityshell/src/HudButton.cpp' | |||
781 | --- plugins/unityshell/src/HudButton.cpp 1970-01-01 00:00:00 +0000 | |||
782 | +++ plugins/unityshell/src/HudButton.cpp 2012-02-06 11:00:29 +0000 | |||
783 | @@ -0,0 +1,208 @@ | |||
784 | 1 | /* | ||
785 | 2 | * Copyright 2011 Canonical Ltd. | ||
786 | 3 | * | ||
787 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
788 | 5 | * under the terms of the GNU Lesser General Public License version 3, as | ||
789 | 6 | * published by the Free Software Foundation. | ||
790 | 7 | * | ||
791 | 8 | * This program is distributed in the hope that it will be useful, but | ||
792 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
793 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
794 | 11 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
795 | 12 | * License for more details. | ||
796 | 13 | * | ||
797 | 14 | * You should have received a copy of both the GNU Lesser General Public | ||
798 | 15 | * License version 3 along with this program. If not, see | ||
799 | 16 | * <http://www.gnu.org/licenses/> | ||
800 | 17 | * | ||
801 | 18 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
802 | 19 | * | ||
803 | 20 | */ | ||
804 | 21 | #include "config.h" | ||
805 | 22 | |||
806 | 23 | #include <pango/pango.h> | ||
807 | 24 | #include <pango/pangocairo.h> | ||
808 | 25 | #include <gdk/gdk.h> | ||
809 | 26 | #include <gtk/gtk.h> | ||
810 | 27 | |||
811 | 28 | #include <Nux/Nux.h> | ||
812 | 29 | #include <NuxCore/Logger.h> | ||
813 | 30 | #include <NuxImage/CairoGraphics.h> | ||
814 | 31 | #include <NuxGraphics/NuxGraphics.h> | ||
815 | 32 | #include <UnityCore/GLibWrapper.h> | ||
816 | 33 | #include "DashStyle.h" | ||
817 | 34 | |||
818 | 35 | #include "HudButton.h" | ||
819 | 36 | |||
820 | 37 | namespace | ||
821 | 38 | { | ||
822 | 39 | nux::logging::Logger logger("unity.hud.HudButton"); | ||
823 | 40 | } | ||
824 | 41 | |||
825 | 42 | namespace unity | ||
826 | 43 | { | ||
827 | 44 | namespace hud | ||
828 | 45 | { | ||
829 | 46 | |||
830 | 47 | |||
831 | 48 | HudButton::HudButton (nux::TextureArea *image, NUX_FILE_LINE_DECL) | ||
832 | 49 | : nux::Button (image, NUX_FILE_LINE_PARAM) | ||
833 | 50 | , is_rounded(false) | ||
834 | 51 | , is_focused_(false) | ||
835 | 52 | { | ||
836 | 53 | InitTheme(); | ||
837 | 54 | key_nav_focus_change.connect([this](nux::Area *area, bool recieving, nux::KeyNavDirection direction){ QueueDraw(); }); | ||
838 | 55 | } | ||
839 | 56 | |||
840 | 57 | HudButton::HudButton (const std::string label_, NUX_FILE_LINE_DECL) | ||
841 | 58 | : nux::Button (NUX_FILE_LINE_PARAM) | ||
842 | 59 | , is_rounded(false) | ||
843 | 60 | , is_focused_(false) | ||
844 | 61 | { | ||
845 | 62 | InitTheme(); | ||
846 | 63 | } | ||
847 | 64 | |||
848 | 65 | HudButton::HudButton (const std::string label_, nux::TextureArea *image, NUX_FILE_LINE_DECL) | ||
849 | 66 | : nux::Button (image, NUX_FILE_LINE_PARAM) | ||
850 | 67 | , is_rounded(false) | ||
851 | 68 | , is_focused_(false) | ||
852 | 69 | { | ||
853 | 70 | InitTheme(); | ||
854 | 71 | } | ||
855 | 72 | |||
856 | 73 | HudButton::HudButton (NUX_FILE_LINE_DECL) | ||
857 | 74 | : nux::Button (NUX_FILE_LINE_PARAM) | ||
858 | 75 | , is_rounded(false) | ||
859 | 76 | , is_focused_(false) | ||
860 | 77 | { | ||
861 | 78 | InitTheme(); | ||
862 | 79 | } | ||
863 | 80 | |||
864 | 81 | HudButton::~HudButton() { | ||
865 | 82 | } | ||
866 | 83 | |||
867 | 84 | void HudButton::InitTheme() | ||
868 | 85 | { | ||
869 | 86 | is_rounded.changed.connect([&] (bool rounded) | ||
870 | 87 | { | ||
871 | 88 | nux::Geometry geo = GetGeometry(); | ||
872 | 89 | prelight_->Invalidate(geo); | ||
873 | 90 | active_->Invalidate(geo); | ||
874 | 91 | normal_->Invalidate(geo); | ||
875 | 92 | }); | ||
876 | 93 | |||
877 | 94 | SetMinimumHeight(42); | ||
878 | 95 | if (!active_) | ||
879 | 96 | { | ||
880 | 97 | nux::Geometry const& geo = GetGeometry(); | ||
881 | 98 | |||
882 | 99 | prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT))); | ||
883 | 100 | active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED))); | ||
884 | 101 | normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &HudButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL))); | ||
885 | 102 | } | ||
886 | 103 | } | ||
887 | 104 | |||
888 | 105 | void HudButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state) | ||
889 | 106 | { | ||
890 | 107 | dash::Style::Instance().SquareButton(cr, faked_state, label_, | ||
891 | 108 | is_rounded, 17, | ||
892 | 109 | dash::Alignment::LEFT, true); | ||
893 | 110 | } | ||
894 | 111 | |||
895 | 112 | bool HudButton::AcceptKeyNavFocus() | ||
896 | 113 | { | ||
897 | 114 | return true; | ||
898 | 115 | } | ||
899 | 116 | |||
900 | 117 | |||
901 | 118 | long HudButton::ComputeContentSize () | ||
902 | 119 | { | ||
903 | 120 | long ret = nux::Button::ComputeContentSize(); | ||
904 | 121 | nux::Geometry const& geo = GetGeometry(); | ||
905 | 122 | |||
906 | 123 | if (cached_geometry_ != geo) | ||
907 | 124 | { | ||
908 | 125 | prelight_->Invalidate(geo); | ||
909 | 126 | active_->Invalidate(geo); | ||
910 | 127 | normal_->Invalidate(geo); | ||
911 | 128 | |||
912 | 129 | cached_geometry_ = geo; | ||
913 | 130 | } | ||
914 | 131 | |||
915 | 132 | return ret; | ||
916 | 133 | } | ||
917 | 134 | |||
918 | 135 | void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) | ||
919 | 136 | { | ||
920 | 137 | nux::Geometry const& geo = GetGeometry(); | ||
921 | 138 | gPainter.PaintBackground(GfxContext, geo); | ||
922 | 139 | // set up our texture mode | ||
923 | 140 | nux::TexCoordXForm texxform; | ||
924 | 141 | texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP); | ||
925 | 142 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); | ||
926 | 143 | |||
927 | 144 | // clear what is behind us | ||
928 | 145 | unsigned int alpha = 0, src = 0, dest = 0; | ||
929 | 146 | GfxContext.GetRenderStates().GetBlend(alpha, src, dest); | ||
930 | 147 | GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); | ||
931 | 148 | GfxContext.GetRenderStates().SetBlend(true); | ||
932 | 149 | |||
933 | 150 | nux::Color col = nux::color::Black; | ||
934 | 151 | col.alpha = 0; | ||
935 | 152 | GfxContext.QRP_Color(geo.x, | ||
936 | 153 | geo.y, | ||
937 | 154 | geo.width, | ||
938 | 155 | geo.height, | ||
939 | 156 | col); | ||
940 | 157 | |||
941 | 158 | nux::BaseTexture* texture = normal_->GetTexture(); | ||
942 | 159 | if (HasKeyFocus()) | ||
943 | 160 | texture = active_->GetTexture(); | ||
944 | 161 | else if (HasKeyFocus()) | ||
945 | 162 | texture = prelight_->GetTexture(); | ||
946 | 163 | else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED) | ||
947 | 164 | texture = active_->GetTexture(); | ||
948 | 165 | |||
949 | 166 | GfxContext.QRP_1Tex(geo.x, | ||
950 | 167 | geo.y, | ||
951 | 168 | texture->GetWidth() + 1, // FIXME !! - jay, nux has gone crazy, unless i specify +1 here, it won't render the entire texture | ||
952 | 169 | texture->GetHeight(), | ||
953 | 170 | texture->GetDeviceTexture(), | ||
954 | 171 | texxform, | ||
955 | 172 | nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); | ||
956 | 173 | |||
957 | 174 | GfxContext.GetRenderStates().SetBlend(alpha, src, dest); | ||
958 | 175 | } | ||
959 | 176 | |||
960 | 177 | void HudButton::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) { | ||
961 | 178 | } | ||
962 | 179 | |||
963 | 180 | void HudButton::PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw) { | ||
964 | 181 | nux::Button::PostDraw(GfxContext, force_draw); | ||
965 | 182 | } | ||
966 | 183 | |||
967 | 184 | void HudButton::SetQuery(Query::Ptr query) | ||
968 | 185 | { | ||
969 | 186 | query_ = query; | ||
970 | 187 | label_ = query->formatted_text; | ||
971 | 188 | label = query->formatted_text; | ||
972 | 189 | } | ||
973 | 190 | |||
974 | 191 | Query::Ptr HudButton::GetQuery() | ||
975 | 192 | { | ||
976 | 193 | return query_; | ||
977 | 194 | } | ||
978 | 195 | |||
979 | 196 | // Introspectable | ||
980 | 197 | std::string HudButton::GetName() const | ||
981 | 198 | { | ||
982 | 199 | return "HudButton"; | ||
983 | 200 | } | ||
984 | 201 | |||
985 | 202 | void HudButton::AddProperties(GVariantBuilder* builder) | ||
986 | 203 | { | ||
987 | 204 | g_variant_builder_add(builder, "{sv}", "label", g_variant_new_string(label_.c_str())); | ||
988 | 205 | } | ||
989 | 206 | |||
990 | 207 | } | ||
991 | 208 | } | ||
992 | 0 | 209 | ||
993 | === added file 'plugins/unityshell/src/HudButton.h' | |||
994 | --- plugins/unityshell/src/HudButton.h 1970-01-01 00:00:00 +0000 | |||
995 | +++ plugins/unityshell/src/HudButton.h 2012-02-06 11:00:29 +0000 | |||
996 | @@ -0,0 +1,81 @@ | |||
997 | 1 | /* | ||
998 | 2 | * Copyright 2011 Canonical Ltd. | ||
999 | 3 | * | ||
1000 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1001 | 5 | * under the terms of the GNU Lesser General Public License version 3, as | ||
1002 | 6 | * published by the Free Software Foundation. | ||
1003 | 7 | * | ||
1004 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1005 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1006 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
1007 | 11 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
1008 | 12 | * License for more details. | ||
1009 | 13 | * | ||
1010 | 14 | * You should have received a copy of both the GNU Lesser General Public | ||
1011 | 15 | * License version 3 along with this program. If not, see | ||
1012 | 16 | * <http://www.gnu.org/licenses/> | ||
1013 | 17 | * | ||
1014 | 18 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
1015 | 19 | * | ||
1016 | 20 | */ | ||
1017 | 21 | |||
1018 | 22 | |||
1019 | 23 | |||
1020 | 24 | #ifndef FILTERBASICBUTTON_H | ||
1021 | 25 | #define FILTERBASICBUTTON_H | ||
1022 | 26 | |||
1023 | 27 | #include <Nux/Nux.h> | ||
1024 | 28 | #include <Nux/CairoWrapper.h> | ||
1025 | 29 | #include <Nux/Button.h> | ||
1026 | 30 | #include <Nux/TextureArea.h> | ||
1027 | 31 | #include <UnityCore/Hud.h> | ||
1028 | 32 | #include "Introspectable.h" | ||
1029 | 33 | |||
1030 | 34 | namespace unity { | ||
1031 | 35 | namespace hud { | ||
1032 | 36 | class HudButton : public nux::Button, public unity::debug::Introspectable | ||
1033 | 37 | { | ||
1034 | 38 | typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr; | ||
1035 | 39 | public: | ||
1036 | 40 | typedef nux::ObjectPtr<HudButton> Ptr; | ||
1037 | 41 | HudButton (nux::TextureArea *image, NUX_FILE_LINE_PROTO); | ||
1038 | 42 | HudButton (const std::string label, NUX_FILE_LINE_PROTO); | ||
1039 | 43 | HudButton (const std::string label, nux::TextureArea *image, NUX_FILE_LINE_PROTO); | ||
1040 | 44 | HudButton (NUX_FILE_LINE_PROTO); | ||
1041 | 45 | virtual ~HudButton(); | ||
1042 | 46 | |||
1043 | 47 | void SetQuery(Query::Ptr query); | ||
1044 | 48 | std::shared_ptr<Query> GetQuery(); | ||
1045 | 49 | |||
1046 | 50 | nux::Property<std::string> label; | ||
1047 | 51 | nux::Property<std::string> hint; | ||
1048 | 52 | nux::Property<bool> is_rounded; | ||
1049 | 53 | protected: | ||
1050 | 54 | |||
1051 | 55 | virtual bool AcceptKeyNavFocus(); | ||
1052 | 56 | virtual long ComputeContentSize(); | ||
1053 | 57 | virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
1054 | 58 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
1055 | 59 | virtual void PostDraw(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
1056 | 60 | |||
1057 | 61 | std::string GetName() const; | ||
1058 | 62 | void AddProperties(GVariantBuilder* builder); | ||
1059 | 63 | |||
1060 | 64 | void InitTheme (); | ||
1061 | 65 | void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state); | ||
1062 | 66 | typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr; | ||
1063 | 67 | |||
1064 | 68 | NuxCairoPtr prelight_; | ||
1065 | 69 | NuxCairoPtr active_; | ||
1066 | 70 | NuxCairoPtr normal_; | ||
1067 | 71 | |||
1068 | 72 | private: | ||
1069 | 73 | std::string label_; | ||
1070 | 74 | |||
1071 | 75 | Query::Ptr query_; | ||
1072 | 76 | nux::Geometry cached_geometry_; | ||
1073 | 77 | bool is_focused_; | ||
1074 | 78 | }; | ||
1075 | 79 | } | ||
1076 | 80 | } | ||
1077 | 81 | #endif // FILTERBASICBUTTON_H | ||
1078 | 0 | 82 | ||
1079 | === added file 'plugins/unityshell/src/HudController.cpp' | |||
1080 | --- plugins/unityshell/src/HudController.cpp 1970-01-01 00:00:00 +0000 | |||
1081 | +++ plugins/unityshell/src/HudController.cpp 2012-02-06 11:00:29 +0000 | |||
1082 | @@ -0,0 +1,385 @@ | |||
1083 | 1 | /* | ||
1084 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
1085 | 3 | * | ||
1086 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1087 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1088 | 6 | * published by the Free Software Foundation. | ||
1089 | 7 | * | ||
1090 | 8 | * This program is distributed in the hope that it will be useful, | ||
1091 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1092 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1093 | 11 | * GNU General Public License for more details. | ||
1094 | 12 | * | ||
1095 | 13 | * You should have received a copy of the GNU General Public License | ||
1096 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1097 | 15 | * | ||
1098 | 16 | * Authored by: Gord Allott <gord.allott@canonical.com> | ||
1099 | 17 | */ | ||
1100 | 18 | |||
1101 | 19 | #include "HudController.h" | ||
1102 | 20 | |||
1103 | 21 | #include <NuxCore/Logger.h> | ||
1104 | 22 | #include <Nux/HLayout.h> | ||
1105 | 23 | #include "PluginAdapter.h" | ||
1106 | 24 | #include "UBusMessages.h" | ||
1107 | 25 | #include "UScreen.h" | ||
1108 | 26 | namespace unity | ||
1109 | 27 | { | ||
1110 | 28 | namespace hud | ||
1111 | 29 | { | ||
1112 | 30 | |||
1113 | 31 | namespace | ||
1114 | 32 | { | ||
1115 | 33 | nux::logging::Logger logger("unity.hud.controller"); | ||
1116 | 34 | } | ||
1117 | 35 | |||
1118 | 36 | Controller::Controller() | ||
1119 | 37 | : launcher_width(66) | ||
1120 | 38 | , panel_height(24) | ||
1121 | 39 | , hud_service_("com.canonical.hud", "/com/canonical/hud") | ||
1122 | 40 | , window_(0) | ||
1123 | 41 | , visible_(false) | ||
1124 | 42 | , need_show_(false) | ||
1125 | 43 | , timeline_id_(0) | ||
1126 | 44 | , last_opacity_(0.0f) | ||
1127 | 45 | , start_time_(0) | ||
1128 | 46 | { | ||
1129 | 47 | LOG_DEBUG(logger) << "hud startup"; | ||
1130 | 48 | SetupRelayoutCallbacks(); | ||
1131 | 49 | |||
1132 | 50 | ubus.RegisterInterest(UBUS_HUD_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud)); | ||
1133 | 51 | |||
1134 | 52 | //!!FIXME!! - just hijacks the dash close request so we get some more requests than normal, | ||
1135 | 53 | ubus.RegisterInterest(UBUS_PLACE_VIEW_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud)); | ||
1136 | 54 | |||
1137 | 55 | ubus.RegisterInterest(UBUS_OVERLAY_SHOWN, [&] (GVariant *data) { | ||
1138 | 56 | unity::glib::String overlay_identity; | ||
1139 | 57 | gboolean can_maximise = FALSE; | ||
1140 | 58 | gint32 overlay_monitor = 0; | ||
1141 | 59 | g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING, &overlay_identity, &can_maximise, &overlay_monitor); | ||
1142 | 60 | |||
1143 | 61 | if (g_strcmp0(overlay_identity, "hud")) | ||
1144 | 62 | { | ||
1145 | 63 | HideHud(true); | ||
1146 | 64 | } | ||
1147 | 65 | }); | ||
1148 | 66 | |||
1149 | 67 | PluginAdapter::Default()->compiz_screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed)); | ||
1150 | 68 | |||
1151 | 69 | hud_service_.queries_updated.connect(sigc::mem_fun(this, &Controller::OnQueriesFinished)); | ||
1152 | 70 | EnsureHud(); | ||
1153 | 71 | } | ||
1154 | 72 | |||
1155 | 73 | Controller::~Controller() | ||
1156 | 74 | { | ||
1157 | 75 | if (window_) | ||
1158 | 76 | window_->UnReference(); | ||
1159 | 77 | window_ = 0; | ||
1160 | 78 | |||
1161 | 79 | g_source_remove(timeline_id_); | ||
1162 | 80 | g_source_remove(ensure_id_); | ||
1163 | 81 | } | ||
1164 | 82 | |||
1165 | 83 | void Controller::SetupWindow() | ||
1166 | 84 | { | ||
1167 | 85 | window_ = new nux::BaseWindow("Hud"); | ||
1168 | 86 | window_->SinkReference(); | ||
1169 | 87 | window_->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); | ||
1170 | 88 | window_->SetConfigureNotifyCallback(&Controller::OnWindowConfigure, this); | ||
1171 | 89 | window_->ShowWindow(false); | ||
1172 | 90 | window_->SetOpacity(0.0f); | ||
1173 | 91 | window_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); | ||
1174 | 92 | } | ||
1175 | 93 | |||
1176 | 94 | void Controller::SetupHudView() | ||
1177 | 95 | { | ||
1178 | 96 | LOG_DEBUG(logger) << "SetupHudView called"; | ||
1179 | 97 | view_ = new View(); | ||
1180 | 98 | |||
1181 | 99 | layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); | ||
1182 | 100 | layout_->AddView(view_, 1); | ||
1183 | 101 | window_->SetLayout(layout_); | ||
1184 | 102 | |||
1185 | 103 | view_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); | ||
1186 | 104 | |||
1187 | 105 | LOG_DEBUG(logger) << "connecting to signals"; | ||
1188 | 106 | view_->search_changed.connect(sigc::mem_fun(this, &Controller::OnSearchChanged)); | ||
1189 | 107 | view_->search_activated.connect(sigc::mem_fun(this, &Controller::OnSearchActivated)); | ||
1190 | 108 | view_->query_activated.connect(sigc::mem_fun(this, &Controller::OnQueryActivated)); | ||
1191 | 109 | view_->query_selected.connect(sigc::mem_fun(this, &Controller::OnQuerySelected)); | ||
1192 | 110 | } | ||
1193 | 111 | |||
1194 | 112 | void Controller::SetupRelayoutCallbacks() | ||
1195 | 113 | { | ||
1196 | 114 | GdkScreen* screen = gdk_screen_get_default(); | ||
1197 | 115 | |||
1198 | 116 | sig_manager_.Add(new glib::Signal<void, GdkScreen*>(screen, | ||
1199 | 117 | "monitors-changed", sigc::mem_fun(this, &Controller::Relayout))); | ||
1200 | 118 | sig_manager_.Add(new glib::Signal<void, GdkScreen*>(screen, | ||
1201 | 119 | "size-changed", sigc::mem_fun(this, &Controller::Relayout))); | ||
1202 | 120 | } | ||
1203 | 121 | |||
1204 | 122 | void Controller::EnsureHud() | ||
1205 | 123 | { | ||
1206 | 124 | if (window_) | ||
1207 | 125 | return; | ||
1208 | 126 | |||
1209 | 127 | LOG_DEBUG(logger) << "Initializing Hud"; | ||
1210 | 128 | |||
1211 | 129 | SetupWindow(); | ||
1212 | 130 | SetupHudView(); | ||
1213 | 131 | Relayout(); | ||
1214 | 132 | ensure_id_ = 0; | ||
1215 | 133 | } | ||
1216 | 134 | |||
1217 | 135 | nux::BaseWindow* Controller::window() const | ||
1218 | 136 | { | ||
1219 | 137 | return window_; | ||
1220 | 138 | } | ||
1221 | 139 | |||
1222 | 140 | // We update the @geo that's sent in with our desired width and height | ||
1223 | 141 | void Controller::OnWindowConfigure(int window_width, int window_height, | ||
1224 | 142 | nux::Geometry& geo, void* data) | ||
1225 | 143 | { | ||
1226 | 144 | Controller* self = static_cast<Controller*>(data); | ||
1227 | 145 | geo = self->GetIdealWindowGeometry(); | ||
1228 | 146 | } | ||
1229 | 147 | |||
1230 | 148 | nux::Geometry Controller::GetIdealWindowGeometry() | ||
1231 | 149 | { | ||
1232 | 150 | UScreen *uscreen = UScreen::GetDefault(); | ||
1233 | 151 | int primary_monitor = uscreen->GetPrimaryMonitor(); | ||
1234 | 152 | auto monitor_geo = uscreen->GetMonitorGeometry(primary_monitor); | ||
1235 | 153 | |||
1236 | 154 | // We want to cover as much of the screen as possible to grab any mouse events outside | ||
1237 | 155 | // of our window | ||
1238 | 156 | return nux::Geometry (monitor_geo.x, | ||
1239 | 157 | monitor_geo.y + panel_height, | ||
1240 | 158 | monitor_geo.width, | ||
1241 | 159 | monitor_geo.height - panel_height); | ||
1242 | 160 | } | ||
1243 | 161 | |||
1244 | 162 | void Controller::Relayout(GdkScreen*screen) | ||
1245 | 163 | { | ||
1246 | 164 | EnsureHud(); | ||
1247 | 165 | nux::Geometry content_geo = view_->GetGeometry(); | ||
1248 | 166 | nux::Geometry geo = GetIdealWindowGeometry(); | ||
1249 | 167 | |||
1250 | 168 | window_->SetGeometry(geo); | ||
1251 | 169 | layout_->SetMinMaxSize(content_geo.width, content_geo.height); | ||
1252 | 170 | view_->SetWindowGeometry(window_->GetAbsoluteGeometry(), window_->GetGeometry()); | ||
1253 | 171 | view_->Relayout(); | ||
1254 | 172 | } | ||
1255 | 173 | |||
1256 | 174 | void Controller::OnMouseDownOutsideWindow(int x, int y, | ||
1257 | 175 | unsigned long bflags, unsigned long kflags) | ||
1258 | 176 | { | ||
1259 | 177 | LOG_DEBUG(logger) << "OnMouseDownOutsideWindow called"; | ||
1260 | 178 | HideHud(); | ||
1261 | 179 | } | ||
1262 | 180 | |||
1263 | 181 | void Controller::OnScreenUngrabbed() | ||
1264 | 182 | { | ||
1265 | 183 | LOG_DEBUG(logger) << "OnScreenUngrabbed called"; | ||
1266 | 184 | if (need_show_) | ||
1267 | 185 | { | ||
1268 | 186 | EnsureHud(); | ||
1269 | 187 | ShowHud(); | ||
1270 | 188 | } | ||
1271 | 189 | } | ||
1272 | 190 | |||
1273 | 191 | void Controller::OnExternalShowHud(GVariant* variant) | ||
1274 | 192 | { | ||
1275 | 193 | EnsureHud(); | ||
1276 | 194 | visible_ ? HideHud() : ShowHud(); | ||
1277 | 195 | } | ||
1278 | 196 | |||
1279 | 197 | void Controller::OnExternalHideHud(GVariant* variant) | ||
1280 | 198 | { | ||
1281 | 199 | LOG_DEBUG(logger) << "External Hiding the hud"; | ||
1282 | 200 | EnsureHud(); | ||
1283 | 201 | HideHud(); | ||
1284 | 202 | } | ||
1285 | 203 | |||
1286 | 204 | void Controller::ShowHideHud() | ||
1287 | 205 | { | ||
1288 | 206 | EnsureHud(); | ||
1289 | 207 | visible_ ? HideHud(true) : ShowHud(); | ||
1290 | 208 | } | ||
1291 | 209 | |||
1292 | 210 | bool Controller::IsVisible() | ||
1293 | 211 | { | ||
1294 | 212 | return visible_; | ||
1295 | 213 | } | ||
1296 | 214 | |||
1297 | 215 | void Controller::ShowHud() | ||
1298 | 216 | { | ||
1299 | 217 | LOG_DEBUG(logger) << "Showing the hud"; | ||
1300 | 218 | EnsureHud(); | ||
1301 | 219 | view_->AboutToShow(); | ||
1302 | 220 | |||
1303 | 221 | window_->ShowWindow(true); | ||
1304 | 222 | window_->PushToFront(); | ||
1305 | 223 | window_->EnableInputWindow(true, "Hud", true, false); | ||
1306 | 224 | window_->SetInputFocus(); | ||
1307 | 225 | nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus()); | ||
1308 | 226 | window_->CaptureMouseDownAnyWhereElse(true); | ||
1309 | 227 | view_->CaptureMouseDownAnyWhereElse(true); | ||
1310 | 228 | window_->QueueDraw(); | ||
1311 | 229 | |||
1312 | 230 | view_->ResetToDefault(); | ||
1313 | 231 | |||
1314 | 232 | view_->SetIcon(""); | ||
1315 | 233 | hud_service_.RequestQuery(""); | ||
1316 | 234 | need_show_ = false; | ||
1317 | 235 | visible_ = true; | ||
1318 | 236 | |||
1319 | 237 | StartShowHideTimeline(); | ||
1320 | 238 | view_->SetWindowGeometry(window_->GetAbsoluteGeometry(), window_->GetGeometry()); | ||
1321 | 239 | |||
1322 | 240 | // hide the launcher | ||
1323 | 241 | GVariant* message_data = g_variant_new("(b)", TRUE); | ||
1324 | 242 | ubus.SendMessage(UBUS_LAUNCHER_LOCK_HIDE, message_data); | ||
1325 | 243 | |||
1326 | 244 | GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "hud", FALSE, 0); | ||
1327 | 245 | ubus.SendMessage(UBUS_OVERLAY_SHOWN, info); | ||
1328 | 246 | } | ||
1329 | 247 | void Controller::HideHud(bool restore) | ||
1330 | 248 | { | ||
1331 | 249 | LOG_DEBUG (logger) << "hiding the hud"; | ||
1332 | 250 | if (visible_ == false) | ||
1333 | 251 | return; | ||
1334 | 252 | |||
1335 | 253 | EnsureHud(); | ||
1336 | 254 | view_->AboutToHide(); | ||
1337 | 255 | window_->CaptureMouseDownAnyWhereElse(false); | ||
1338 | 256 | window_->EnableInputWindow(false, "Hud", true, false); | ||
1339 | 257 | visible_ = false; | ||
1340 | 258 | |||
1341 | 259 | StartShowHideTimeline(); | ||
1342 | 260 | |||
1343 | 261 | restore = true; | ||
1344 | 262 | if (restore) | ||
1345 | 263 | PluginAdapter::Default ()->restoreInputFocus (); | ||
1346 | 264 | |||
1347 | 265 | hud_service_.CloseQuery(); | ||
1348 | 266 | |||
1349 | 267 | //unhide the launcher | ||
1350 | 268 | GVariant* message_data = g_variant_new("(b)", FALSE); | ||
1351 | 269 | ubus.SendMessage(UBUS_LAUNCHER_LOCK_HIDE, message_data); | ||
1352 | 270 | |||
1353 | 271 | GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "hud", FALSE, 0); | ||
1354 | 272 | ubus.SendMessage(UBUS_OVERLAY_HIDDEN, info); | ||
1355 | 273 | } | ||
1356 | 274 | |||
1357 | 275 | void Controller::StartShowHideTimeline() | ||
1358 | 276 | { | ||
1359 | 277 | EnsureHud(); | ||
1360 | 278 | |||
1361 | 279 | if (timeline_id_) | ||
1362 | 280 | g_source_remove(timeline_id_); | ||
1363 | 281 | |||
1364 | 282 | timeline_id_ = g_timeout_add(15, (GSourceFunc)Controller::OnViewShowHideFrame, this); | ||
1365 | 283 | last_opacity_ = window_->GetOpacity(); | ||
1366 | 284 | start_time_ = g_get_monotonic_time(); | ||
1367 | 285 | |||
1368 | 286 | } | ||
1369 | 287 | |||
1370 | 288 | gboolean Controller::OnViewShowHideFrame(Controller* self) | ||
1371 | 289 | { | ||
1372 | 290 | #define _LENGTH_ 90000 | ||
1373 | 291 | float diff = g_get_monotonic_time() - self->start_time_; | ||
1374 | 292 | float progress = diff / (float)_LENGTH_; | ||
1375 | 293 | float last_opacity = self->last_opacity_; | ||
1376 | 294 | |||
1377 | 295 | if (self->visible_) | ||
1378 | 296 | { | ||
1379 | 297 | self->window_->SetOpacity(last_opacity + ((1.0f - last_opacity) * progress)); | ||
1380 | 298 | } | ||
1381 | 299 | else | ||
1382 | 300 | { | ||
1383 | 301 | self->window_->SetOpacity(last_opacity - (last_opacity * progress)); | ||
1384 | 302 | } | ||
1385 | 303 | |||
1386 | 304 | if (diff > _LENGTH_) | ||
1387 | 305 | { | ||
1388 | 306 | self->timeline_id_ = 0; | ||
1389 | 307 | |||
1390 | 308 | // Make sure the state is right | ||
1391 | 309 | self->window_->SetOpacity(self->visible_ ? 1.0f : 0.0f); | ||
1392 | 310 | if (!self->visible_) | ||
1393 | 311 | { | ||
1394 | 312 | self->window_->ShowWindow(false); | ||
1395 | 313 | } | ||
1396 | 314 | |||
1397 | 315 | return FALSE; | ||
1398 | 316 | } | ||
1399 | 317 | |||
1400 | 318 | return TRUE; | ||
1401 | 319 | } | ||
1402 | 320 | |||
1403 | 321 | void Controller::OnActivateRequest(GVariant* variant) | ||
1404 | 322 | { | ||
1405 | 323 | EnsureHud(); | ||
1406 | 324 | ShowHud(); | ||
1407 | 325 | } | ||
1408 | 326 | |||
1409 | 327 | void Controller::OnSearchChanged(std::string search_string) | ||
1410 | 328 | { | ||
1411 | 329 | LOG_DEBUG(logger) << "Search Changed"; | ||
1412 | 330 | hud_service_.RequestQuery(search_string); | ||
1413 | 331 | } | ||
1414 | 332 | |||
1415 | 333 | void Controller::OnSearchActivated(std::string search_string) | ||
1416 | 334 | { | ||
1417 | 335 | unsigned int timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp; | ||
1418 | 336 | hud_service_.ExecuteQueryBySearch(search_string, timestamp); | ||
1419 | 337 | HideHud(); | ||
1420 | 338 | } | ||
1421 | 339 | |||
1422 | 340 | void Controller::OnQueryActivated(Query::Ptr query) | ||
1423 | 341 | { | ||
1424 | 342 | LOG_DEBUG(logger) << "Activating query, " << query->formatted_text; | ||
1425 | 343 | unsigned int timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp; | ||
1426 | 344 | hud_service_.ExecuteQuery(query, timestamp); | ||
1427 | 345 | HideHud(); | ||
1428 | 346 | } | ||
1429 | 347 | |||
1430 | 348 | void Controller::OnQuerySelected(Query::Ptr query) | ||
1431 | 349 | { | ||
1432 | 350 | LOG_DEBUG(logger) << "Selected query, " << query->formatted_text; | ||
1433 | 351 | view_->SetIcon(query->icon_name); | ||
1434 | 352 | } | ||
1435 | 353 | |||
1436 | 354 | |||
1437 | 355 | void Controller::OnQueriesFinished(Hud::Queries queries) | ||
1438 | 356 | { | ||
1439 | 357 | view_->SetQueries(queries); | ||
1440 | 358 | std::string icon_name = ""; | ||
1441 | 359 | for (auto query = queries.begin(); query != queries.end(); query++) | ||
1442 | 360 | { | ||
1443 | 361 | if (!(*query)->icon_name.empty()) | ||
1444 | 362 | { | ||
1445 | 363 | icon_name = (*query)->icon_name; | ||
1446 | 364 | break; | ||
1447 | 365 | } | ||
1448 | 366 | } | ||
1449 | 367 | |||
1450 | 368 | LOG_DEBUG(logger) << "setting icon to - " << icon_name; | ||
1451 | 369 | view_->SetIcon(icon_name); | ||
1452 | 370 | } | ||
1453 | 371 | |||
1454 | 372 | // Introspectable | ||
1455 | 373 | std::string Controller::GetName() const | ||
1456 | 374 | { | ||
1457 | 375 | return "HudController"; | ||
1458 | 376 | } | ||
1459 | 377 | |||
1460 | 378 | void Controller::AddProperties(GVariantBuilder* builder) | ||
1461 | 379 | { | ||
1462 | 380 | g_variant_builder_add(builder, "{sv}", "visible", g_variant_new_boolean (visible_)); | ||
1463 | 381 | } | ||
1464 | 382 | |||
1465 | 383 | |||
1466 | 384 | } | ||
1467 | 385 | } | ||
1468 | 0 | 386 | ||
1469 | === added file 'plugins/unityshell/src/HudController.h' | |||
1470 | --- plugins/unityshell/src/HudController.h 1970-01-01 00:00:00 +0000 | |||
1471 | +++ plugins/unityshell/src/HudController.h 2012-02-06 11:00:29 +0000 | |||
1472 | @@ -0,0 +1,113 @@ | |||
1473 | 1 | /* | ||
1474 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
1475 | 3 | * | ||
1476 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1477 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1478 | 6 | * published by the Free Software Foundation. | ||
1479 | 7 | * | ||
1480 | 8 | * This program is distributed in the hope that it will be useful, | ||
1481 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1482 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1483 | 11 | * GNU General Public License for more details. | ||
1484 | 12 | * | ||
1485 | 13 | * You should have received a copy of the GNU General Public License | ||
1486 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1487 | 15 | * | ||
1488 | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | ||
1489 | 17 | */ | ||
1490 | 18 | |||
1491 | 19 | #ifndef UNITY_HUD_CONTROLLER_H_ | ||
1492 | 20 | #define UNITY_HUD_CONTROLLER_H_ | ||
1493 | 21 | |||
1494 | 22 | #include <memory> | ||
1495 | 23 | |||
1496 | 24 | #include <gdk/gdk.h> | ||
1497 | 25 | #include <UnityCore/GLibSignal.h> | ||
1498 | 26 | #include <UnityCore/Hud.h> | ||
1499 | 27 | |||
1500 | 28 | #include <NuxCore/Property.h> | ||
1501 | 29 | #include <NuxGraphics/GraphicsEngine.h> | ||
1502 | 30 | #include <Nux/Nux.h> | ||
1503 | 31 | #include <Nux/BaseWindow.h> | ||
1504 | 32 | |||
1505 | 33 | #include "HudView.h" | ||
1506 | 34 | #include "UBusWrapper.h" | ||
1507 | 35 | |||
1508 | 36 | namespace unity | ||
1509 | 37 | { | ||
1510 | 38 | namespace hud | ||
1511 | 39 | { | ||
1512 | 40 | |||
1513 | 41 | class Controller : public unity::debug::Introspectable | ||
1514 | 42 | { | ||
1515 | 43 | public: | ||
1516 | 44 | typedef std::shared_ptr<Controller> Ptr; | ||
1517 | 45 | |||
1518 | 46 | Controller(); | ||
1519 | 47 | ~Controller(); | ||
1520 | 48 | |||
1521 | 49 | nux::BaseWindow* window() const; | ||
1522 | 50 | |||
1523 | 51 | nux::Property<int> launcher_width; | ||
1524 | 52 | nux::Property<int> panel_height; | ||
1525 | 53 | |||
1526 | 54 | void ShowHideHud(); | ||
1527 | 55 | void ShowHud(); | ||
1528 | 56 | void HideHud(bool restore_focus = true); | ||
1529 | 57 | bool IsVisible(); | ||
1530 | 58 | protected: | ||
1531 | 59 | std::string GetName() const; | ||
1532 | 60 | void AddProperties(GVariantBuilder* builder); | ||
1533 | 61 | |||
1534 | 62 | private: | ||
1535 | 63 | void EnsureHud(); | ||
1536 | 64 | void SetupWindow(); | ||
1537 | 65 | void SetupHudView(); | ||
1538 | 66 | void SetupRelayoutCallbacks(); | ||
1539 | 67 | void RegisterUBusInterests(); | ||
1540 | 68 | |||
1541 | 69 | nux::Geometry GetIdealWindowGeometry(); | ||
1542 | 70 | void Relayout(GdkScreen*screen=NULL); | ||
1543 | 71 | |||
1544 | 72 | void OnMouseDownOutsideWindow(int x, int y, unsigned long bflags, unsigned long kflags); | ||
1545 | 73 | void OnScreenUngrabbed(); | ||
1546 | 74 | void OnExternalShowHud(GVariant* variant); | ||
1547 | 75 | void OnExternalHideHud(GVariant* variant); | ||
1548 | 76 | void OnActivateRequest(GVariant* variant); | ||
1549 | 77 | |||
1550 | 78 | void OnSearchChanged(std::string search_string); | ||
1551 | 79 | void OnSearchActivated(std::string search_string); | ||
1552 | 80 | void OnQueryActivated(Query::Ptr query); | ||
1553 | 81 | void OnQuerySelected(Query::Ptr query); | ||
1554 | 82 | |||
1555 | 83 | |||
1556 | 84 | private: | ||
1557 | 85 | void StartShowHideTimeline(); | ||
1558 | 86 | static gboolean OnViewShowHideFrame(Controller* self); | ||
1559 | 87 | |||
1560 | 88 | static void OnWindowConfigure(int width, int height, nux::Geometry& geo, void* data); | ||
1561 | 89 | |||
1562 | 90 | void OnQueriesFinished(Hud::Queries queries); | ||
1563 | 91 | |||
1564 | 92 | private: | ||
1565 | 93 | UBusManager ubus; | ||
1566 | 94 | Hud hud_service_; | ||
1567 | 95 | glib::SignalManager sig_manager_; | ||
1568 | 96 | nux::BaseWindow* window_; | ||
1569 | 97 | bool visible_; | ||
1570 | 98 | bool need_show_; | ||
1571 | 99 | |||
1572 | 100 | guint timeline_id_; | ||
1573 | 101 | float last_opacity_; | ||
1574 | 102 | gint64 start_time_; | ||
1575 | 103 | |||
1576 | 104 | View* view_; | ||
1577 | 105 | guint ensure_id_; | ||
1578 | 106 | |||
1579 | 107 | nux::Layout* layout_; | ||
1580 | 108 | }; | ||
1581 | 109 | |||
1582 | 110 | |||
1583 | 111 | } | ||
1584 | 112 | } | ||
1585 | 113 | #endif | ||
1586 | 0 | 114 | ||
1587 | === added file 'plugins/unityshell/src/HudIcon.cpp' | |||
1588 | --- plugins/unityshell/src/HudIcon.cpp 1970-01-01 00:00:00 +0000 | |||
1589 | +++ plugins/unityshell/src/HudIcon.cpp 2012-02-06 11:00:29 +0000 | |||
1590 | @@ -0,0 +1,95 @@ | |||
1591 | 1 | /* | ||
1592 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
1593 | 3 | * | ||
1594 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1595 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1596 | 6 | * published by the Free Software Foundation. | ||
1597 | 7 | * | ||
1598 | 8 | * This program is distributed in the hope that it will be useful, | ||
1599 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1600 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1601 | 11 | * GNU General Public License for more details. | ||
1602 | 12 | * | ||
1603 | 13 | * You should have received a copy of the GNU General Public License | ||
1604 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1605 | 15 | * | ||
1606 | 16 | * Authored by: Gord Allott <gord.allott@canonical.com> | ||
1607 | 17 | */ | ||
1608 | 18 | |||
1609 | 19 | |||
1610 | 20 | #include "HudIcon.h" | ||
1611 | 21 | #include "NuxCore/Logger.h" | ||
1612 | 22 | namespace | ||
1613 | 23 | { | ||
1614 | 24 | nux::logging::Logger logger("unity.hud.icon"); | ||
1615 | 25 | } | ||
1616 | 26 | |||
1617 | 27 | namespace unity | ||
1618 | 28 | { | ||
1619 | 29 | namespace hud | ||
1620 | 30 | { | ||
1621 | 31 | |||
1622 | 32 | Icon::Icon(nux::BaseTexture* texture, guint width, guint height) | ||
1623 | 33 | : unity::IconTexture(texture, width, height) | ||
1624 | 34 | { | ||
1625 | 35 | Init(); | ||
1626 | 36 | icon_renderer_.SetTargetSize(54, 46, 0); | ||
1627 | 37 | } | ||
1628 | 38 | |||
1629 | 39 | Icon::Icon(const char* icon_name, unsigned int size, bool defer_icon_loading) | ||
1630 | 40 | : unity::IconTexture(icon_name, size, defer_icon_loading) | ||
1631 | 41 | { | ||
1632 | 42 | Init(); | ||
1633 | 43 | } | ||
1634 | 44 | |||
1635 | 45 | Icon::~Icon() | ||
1636 | 46 | { | ||
1637 | 47 | } | ||
1638 | 48 | |||
1639 | 49 | void Icon::Init() | ||
1640 | 50 | { | ||
1641 | 51 | SetMinimumWidth(66); | ||
1642 | 52 | SetMinimumHeight(66); | ||
1643 | 53 | background_ = nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true); | ||
1644 | 54 | gloss_ = nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true); | ||
1645 | 55 | edge_ = nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1, true); | ||
1646 | 56 | |||
1647 | 57 | texture_updated.connect([&] (nux::BaseTexture* texture) | ||
1648 | 58 | { | ||
1649 | 59 | icon_texture_source_ = new HudIconTextureSource(nux::ObjectPtr<nux::BaseTexture>(texture)); | ||
1650 | 60 | icon_texture_source_->ColorForIcon(_pixbuf_cached); | ||
1651 | 61 | QueueDraw(); | ||
1652 | 62 | LOG_DEBUG(logger) << "got our texture"; | ||
1653 | 63 | }); | ||
1654 | 64 | } | ||
1655 | 65 | |||
1656 | 66 | void Icon::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) | ||
1657 | 67 | { | ||
1658 | 68 | if (texture() == nullptr) | ||
1659 | 69 | return; | ||
1660 | 70 | |||
1661 | 71 | unity::ui::RenderArg arg; | ||
1662 | 72 | arg.icon = icon_texture_source_.GetPointer(); | ||
1663 | 73 | arg.colorify = nux::color::White; | ||
1664 | 74 | arg.running_arrow = true; | ||
1665 | 75 | arg.running_on_viewport = true; | ||
1666 | 76 | arg.render_center = nux::Point3(32, 32, 0); | ||
1667 | 77 | arg.logical_center = nux::Point3(52, 50, 0); | ||
1668 | 78 | arg.window_indicators = true; | ||
1669 | 79 | arg.backlight_intensity = 1.0f; | ||
1670 | 80 | arg.alpha = 1.0f; | ||
1671 | 81 | |||
1672 | 82 | std::list<unity::ui::RenderArg> args; | ||
1673 | 83 | args.push_front(arg); | ||
1674 | 84 | |||
1675 | 85 | |||
1676 | 86 | auto toplevel = GetToplevel(); | ||
1677 | 87 | icon_renderer_.SetTargetSize(54, 46, 0); | ||
1678 | 88 | icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry()); | ||
1679 | 89 | icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry()); | ||
1680 | 90 | } | ||
1681 | 91 | |||
1682 | 92 | |||
1683 | 93 | } | ||
1684 | 94 | } | ||
1685 | 95 | |||
1686 | 0 | 96 | ||
1687 | === added file 'plugins/unityshell/src/HudIcon.h' | |||
1688 | --- plugins/unityshell/src/HudIcon.h 1970-01-01 00:00:00 +0000 | |||
1689 | +++ plugins/unityshell/src/HudIcon.h 2012-02-06 11:00:29 +0000 | |||
1690 | @@ -0,0 +1,73 @@ | |||
1691 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1692 | 2 | /* | ||
1693 | 3 | * Copyright (C) 2010 Canonical Ltd | ||
1694 | 4 | * | ||
1695 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1696 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1697 | 7 | * published by the Free Software Foundation. | ||
1698 | 8 | * | ||
1699 | 9 | * This program is distributed in the hope that it will be useful, | ||
1700 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1701 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1702 | 12 | * GNU General Public License for more details. | ||
1703 | 13 | * | ||
1704 | 14 | * You should have received a copy of the GNU General Public License | ||
1705 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1706 | 16 | * | ||
1707 | 17 | * Authored by: Gord Allott <gord.allott@canonical.com> | ||
1708 | 18 | * | ||
1709 | 19 | */ | ||
1710 | 20 | |||
1711 | 21 | #ifndef HUDICON_H | ||
1712 | 22 | #define HUDICON_H | ||
1713 | 23 | |||
1714 | 24 | #include <set> | ||
1715 | 25 | #include <string> | ||
1716 | 26 | |||
1717 | 27 | #include "config.h" | ||
1718 | 28 | |||
1719 | 29 | #include <Nux/Nux.h> | ||
1720 | 30 | #include <Nux/BaseWindow.h> | ||
1721 | 31 | #include <NuxCore/Math/MathInc.h> | ||
1722 | 32 | |||
1723 | 33 | #include <sigc++/trackable.h> | ||
1724 | 34 | #include <sigc++/signal.h> | ||
1725 | 35 | #include <sigc++/functors/ptr_fun.h> | ||
1726 | 36 | #include <sigc++/functors/mem_fun.h> | ||
1727 | 37 | |||
1728 | 38 | #include <gtk/gtk.h> | ||
1729 | 39 | |||
1730 | 40 | #include "IconTexture.h" | ||
1731 | 41 | #include "HudIconTextureSource.h" | ||
1732 | 42 | #include "IconRenderer.h" | ||
1733 | 43 | #include "Introspectable.h" | ||
1734 | 44 | |||
1735 | 45 | namespace unity | ||
1736 | 46 | { | ||
1737 | 47 | namespace hud | ||
1738 | 48 | { | ||
1739 | 49 | |||
1740 | 50 | class Icon : public unity::IconTexture | ||
1741 | 51 | { | ||
1742 | 52 | public: | ||
1743 | 53 | typedef nux::ObjectPtr<IconTexture> Ptr; | ||
1744 | 54 | Icon(nux::BaseTexture* texture, guint width, guint height); | ||
1745 | 55 | Icon(const char* icon_name, unsigned int size, bool defer_icon_loading = false); | ||
1746 | 56 | ~Icon(); | ||
1747 | 57 | |||
1748 | 58 | protected: | ||
1749 | 59 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | ||
1750 | 60 | void Init(); | ||
1751 | 61 | |||
1752 | 62 | nux::ObjectPtr<nux::BaseTexture> background_; | ||
1753 | 63 | nux::ObjectPtr<nux::BaseTexture> gloss_; | ||
1754 | 64 | nux::ObjectPtr<nux::BaseTexture> edge_; | ||
1755 | 65 | nux::ObjectPtr<HudIconTextureSource> icon_texture_source_; | ||
1756 | 66 | unity::ui::IconRenderer icon_renderer_; | ||
1757 | 67 | }; | ||
1758 | 68 | |||
1759 | 69 | } | ||
1760 | 70 | |||
1761 | 71 | } | ||
1762 | 72 | |||
1763 | 73 | #endif /* HUDICON_H */ | ||
1764 | 0 | 74 | ||
1765 | === added file 'plugins/unityshell/src/HudIconTextureSource.cpp' | |||
1766 | --- plugins/unityshell/src/HudIconTextureSource.cpp 1970-01-01 00:00:00 +0000 | |||
1767 | +++ plugins/unityshell/src/HudIconTextureSource.cpp 2012-02-06 11:00:29 +0000 | |||
1768 | @@ -0,0 +1,110 @@ | |||
1769 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1770 | 2 | /* | ||
1771 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1772 | 4 | * | ||
1773 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1774 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1775 | 7 | * published by the Free Software Foundation. | ||
1776 | 8 | * | ||
1777 | 9 | * This program is distributed in the hope that it will be useful, | ||
1778 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1779 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1780 | 12 | * GNU General Public License for more details. | ||
1781 | 13 | * | ||
1782 | 14 | * You should have received a copy of the GNU General Public License | ||
1783 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1784 | 16 | * | ||
1785 | 17 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
1786 | 18 | */ | ||
1787 | 19 | |||
1788 | 20 | |||
1789 | 21 | #include "HudIconTextureSource.h" | ||
1790 | 22 | #include "config.h" | ||
1791 | 23 | |||
1792 | 24 | #include <glib.h> | ||
1793 | 25 | |||
1794 | 26 | #include <Nux/Nux.h> | ||
1795 | 27 | #include <NuxCore/Logger.h> | ||
1796 | 28 | |||
1797 | 29 | |||
1798 | 30 | namespace unity | ||
1799 | 31 | { | ||
1800 | 32 | namespace hud | ||
1801 | 33 | { | ||
1802 | 34 | |||
1803 | 35 | HudIconTextureSource::HudIconTextureSource(nux::ObjectPtr<nux::BaseTexture> texture) | ||
1804 | 36 | : unity::ui::IconTextureSource() | ||
1805 | 37 | , icon_texture_(texture) | ||
1806 | 38 | { | ||
1807 | 39 | } | ||
1808 | 40 | |||
1809 | 41 | HudIconTextureSource::~HudIconTextureSource() | ||
1810 | 42 | { | ||
1811 | 43 | } | ||
1812 | 44 | |||
1813 | 45 | void HudIconTextureSource::ColorForIcon(GdkPixbuf* pixbuf) | ||
1814 | 46 | { | ||
1815 | 47 | unsigned int width = gdk_pixbuf_get_width(pixbuf); | ||
1816 | 48 | unsigned int height = gdk_pixbuf_get_height(pixbuf); | ||
1817 | 49 | unsigned int row_bytes = gdk_pixbuf_get_rowstride(pixbuf); | ||
1818 | 50 | |||
1819 | 51 | long int rtotal = 0, gtotal = 0, btotal = 0; | ||
1820 | 52 | float total = 0.0f; | ||
1821 | 53 | |||
1822 | 54 | guchar* img = gdk_pixbuf_get_pixels(pixbuf); | ||
1823 | 55 | |||
1824 | 56 | for (unsigned int i = 0; i < width; i++) | ||
1825 | 57 | { | ||
1826 | 58 | for (unsigned int j = 0; j < height; j++) | ||
1827 | 59 | { | ||
1828 | 60 | guchar* pixels = img + (j * row_bytes + i * 4); | ||
1829 | 61 | guchar r = *(pixels + 0); | ||
1830 | 62 | guchar g = *(pixels + 1); | ||
1831 | 63 | guchar b = *(pixels + 2); | ||
1832 | 64 | guchar a = *(pixels + 3); | ||
1833 | 65 | |||
1834 | 66 | float saturation = (MAX(r, MAX(g, b)) - MIN(r, MIN(g, b))) / 255.0f; | ||
1835 | 67 | float relevance = .1 + .9 * (a / 255.0f) * saturation; | ||
1836 | 68 | |||
1837 | 69 | rtotal += (guchar)(r * relevance); | ||
1838 | 70 | gtotal += (guchar)(g * relevance); | ||
1839 | 71 | btotal += (guchar)(b * relevance); | ||
1840 | 72 | |||
1841 | 73 | total += relevance * 255; | ||
1842 | 74 | } | ||
1843 | 75 | } | ||
1844 | 76 | |||
1845 | 77 | nux::color::RedGreenBlue rgb(rtotal / total, | ||
1846 | 78 | gtotal / total, | ||
1847 | 79 | btotal / total); | ||
1848 | 80 | nux::color::HueSaturationValue hsv(rgb); | ||
1849 | 81 | |||
1850 | 82 | if (hsv.saturation > 0.15f) | ||
1851 | 83 | hsv.saturation = 0.65f; | ||
1852 | 84 | |||
1853 | 85 | hsv.value = 0.90f; | ||
1854 | 86 | bg_color = nux::Color(nux::color::RedGreenBlue(hsv)); | ||
1855 | 87 | } | ||
1856 | 88 | |||
1857 | 89 | nux::Color HudIconTextureSource::BackgroundColor() | ||
1858 | 90 | { | ||
1859 | 91 | return bg_color; | ||
1860 | 92 | } | ||
1861 | 93 | |||
1862 | 94 | nux::BaseTexture* HudIconTextureSource::TextureForSize(int size) | ||
1863 | 95 | { | ||
1864 | 96 | return icon_texture_.GetPointer(); | ||
1865 | 97 | } | ||
1866 | 98 | |||
1867 | 99 | nux::Color HudIconTextureSource::GlowColor() | ||
1868 | 100 | { | ||
1869 | 101 | return nux::Color(0.0f, 0.0f, 0.0f, 0.0f); | ||
1870 | 102 | } | ||
1871 | 103 | |||
1872 | 104 | nux::BaseTexture* HudIconTextureSource::Emblem() | ||
1873 | 105 | { | ||
1874 | 106 | return nullptr; | ||
1875 | 107 | } | ||
1876 | 108 | |||
1877 | 109 | } | ||
1878 | 110 | } | ||
1879 | 0 | \ No newline at end of file | 111 | \ No newline at end of file |
1880 | 1 | 112 | ||
1881 | === added file 'plugins/unityshell/src/HudIconTextureSource.h' | |||
1882 | --- plugins/unityshell/src/HudIconTextureSource.h 1970-01-01 00:00:00 +0000 | |||
1883 | +++ plugins/unityshell/src/HudIconTextureSource.h 2012-02-06 11:00:29 +0000 | |||
1884 | @@ -0,0 +1,51 @@ | |||
1885 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1886 | 2 | /* | ||
1887 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
1888 | 4 | * | ||
1889 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1890 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
1891 | 7 | * published by the Free Software Foundation. | ||
1892 | 8 | * | ||
1893 | 9 | * This program is distributed in the hope that it will be useful, | ||
1894 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1895 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1896 | 12 | * GNU General Public License for more details. | ||
1897 | 13 | * | ||
1898 | 14 | * You should have received a copy of the GNU General Public License | ||
1899 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1900 | 16 | * | ||
1901 | 17 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
1902 | 18 | */ | ||
1903 | 19 | |||
1904 | 20 | |||
1905 | 21 | #ifndef HUDICONTEXTURESOURCE_H | ||
1906 | 22 | #define HUDICONTEXTURESOURCE_H | ||
1907 | 23 | |||
1908 | 24 | #include "IconTextureSource.h" | ||
1909 | 25 | |||
1910 | 26 | namespace unity | ||
1911 | 27 | { | ||
1912 | 28 | namespace hud | ||
1913 | 29 | { | ||
1914 | 30 | |||
1915 | 31 | class HudIconTextureSource : public unity::ui::IconTextureSource | ||
1916 | 32 | { | ||
1917 | 33 | public: | ||
1918 | 34 | HudIconTextureSource(nux::ObjectPtr<nux::BaseTexture> texture); | ||
1919 | 35 | ~HudIconTextureSource(); | ||
1920 | 36 | |||
1921 | 37 | virtual nux::Color BackgroundColor(); | ||
1922 | 38 | virtual nux::BaseTexture* TextureForSize(int size); | ||
1923 | 39 | virtual nux::Color GlowColor(); | ||
1924 | 40 | virtual nux::BaseTexture* Emblem(); | ||
1925 | 41 | void ColorForIcon(GdkPixbuf* pixbuf); | ||
1926 | 42 | |||
1927 | 43 | private: | ||
1928 | 44 | nux::Color bg_color; | ||
1929 | 45 | nux::ObjectPtr<nux::BaseTexture> icon_texture_; | ||
1930 | 46 | }; | ||
1931 | 47 | |||
1932 | 48 | } | ||
1933 | 49 | } | ||
1934 | 50 | |||
1935 | 51 | #endif // HUDICONTEXTURESOURCE_H | ||
1936 | 0 | 52 | ||
1937 | === added file 'plugins/unityshell/src/HudView.cpp' | |||
1938 | --- plugins/unityshell/src/HudView.cpp 1970-01-01 00:00:00 +0000 | |||
1939 | +++ plugins/unityshell/src/HudView.cpp 2012-02-06 11:00:29 +0000 | |||
1940 | @@ -0,0 +1,398 @@ | |||
1941 | 1 | /* | ||
1942 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
1943 | 3 | * | ||
1944 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1945 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1946 | 6 | * published by the Free Software Foundation. | ||
1947 | 7 | * | ||
1948 | 8 | * This program is distributed in the hope that it will be useful, | ||
1949 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1950 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1951 | 11 | * GNU General Public License for more details. | ||
1952 | 12 | * | ||
1953 | 13 | * You should have received a copy of the GNU General Public License | ||
1954 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1955 | 15 | * | ||
1956 | 16 | * Authored by: Gord Allott <gord.allott@canonical.com> | ||
1957 | 17 | */ | ||
1958 | 18 | |||
1959 | 19 | #include "HudView.h" | ||
1960 | 20 | |||
1961 | 21 | #include <math.h> | ||
1962 | 22 | |||
1963 | 23 | #include <gio/gdesktopappinfo.h> | ||
1964 | 24 | #include <glib/gi18n-lib.h> | ||
1965 | 25 | #include <gtk/gtk.h> | ||
1966 | 26 | #include <Nux/Button.h> | ||
1967 | 27 | #include <iostream> | ||
1968 | 28 | #include <sstream> | ||
1969 | 29 | |||
1970 | 30 | #include <NuxCore/Logger.h> | ||
1971 | 31 | #include <UnityCore/GLibWrapper.h> | ||
1972 | 32 | #include <UnityCore/RadioOptionFilter.h> | ||
1973 | 33 | #include <Nux/HLayout.h> | ||
1974 | 34 | #include <Nux/LayeredLayout.h> | ||
1975 | 35 | |||
1976 | 36 | #include <NuxCore/Logger.h> | ||
1977 | 37 | #include "HudButton.h" | ||
1978 | 38 | #include "UBusMessages.h" | ||
1979 | 39 | #include "DashStyle.h" | ||
1980 | 40 | |||
1981 | 41 | namespace unity | ||
1982 | 42 | { | ||
1983 | 43 | namespace hud | ||
1984 | 44 | { | ||
1985 | 45 | |||
1986 | 46 | namespace | ||
1987 | 47 | { | ||
1988 | 48 | nux::logging::Logger logger("unity.hud.view"); | ||
1989 | 49 | int icon_size = 42; | ||
1990 | 50 | const std::string default_text = _("Type your command"); | ||
1991 | 51 | } | ||
1992 | 52 | |||
1993 | 53 | NUX_IMPLEMENT_OBJECT_TYPE(View); | ||
1994 | 54 | |||
1995 | 55 | View::View() | ||
1996 | 56 | : nux::View(NUX_TRACKER_LOCATION) | ||
1997 | 57 | , button_views_(NULL) | ||
1998 | 58 | { | ||
1999 | 59 | renderer_.SetOwner(this); | ||
2000 | 60 | renderer_.need_redraw.connect([this] () { | ||
2001 | 61 | QueueDraw(); | ||
2002 | 62 | }); | ||
2003 | 63 | |||
2004 | 64 | nux::ROPConfig rop; | ||
2005 | 65 | rop.Blend = true; | ||
2006 | 66 | rop.SrcBlend = GL_ONE; | ||
2007 | 67 | rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; | ||
2008 | 68 | |||
2009 | 69 | SetupViews(); | ||
2010 | 70 | search_bar_->key_down.connect (sigc::mem_fun (this, &View::OnKeyDown)); | ||
2011 | 71 | |||
2012 | 72 | search_bar_->activated.connect ([&]() { | ||
2013 | 73 | search_activated.emit(search_bar_->search_string); | ||
2014 | 74 | }); | ||
2015 | 75 | |||
2016 | 76 | mouse_down.connect(sigc::mem_fun(this, &View::OnMouseButtonDown)); | ||
2017 | 77 | |||
2018 | 78 | Relayout(); | ||
2019 | 79 | |||
2020 | 80 | } | ||
2021 | 81 | |||
2022 | 82 | View::~View() | ||
2023 | 83 | { | ||
2024 | 84 | RemoveChild(search_bar_.GetPointer()); | ||
2025 | 85 | for (auto button = buttons_.begin(); button != buttons_.end(); button++) | ||
2026 | 86 | { | ||
2027 | 87 | RemoveChild((*button).GetPointer()); | ||
2028 | 88 | } | ||
2029 | 89 | } | ||
2030 | 90 | |||
2031 | 91 | void View::ResetToDefault() | ||
2032 | 92 | { | ||
2033 | 93 | search_bar_->search_string = ""; | ||
2034 | 94 | search_bar_->search_hint = default_text; | ||
2035 | 95 | } | ||
2036 | 96 | |||
2037 | 97 | void View::Relayout() | ||
2038 | 98 | { | ||
2039 | 99 | nux::Geometry geo = GetGeometry(); | ||
2040 | 100 | content_geo_ = GetBestFitGeometry(geo); | ||
2041 | 101 | LOG_DEBUG(logger) << "content_geo: " << content_geo_.width << "x" << content_geo_.height; | ||
2042 | 102 | |||
2043 | 103 | layout_->SetMinMaxSize(content_geo_.width, content_geo_.height); | ||
2044 | 104 | |||
2045 | 105 | QueueDraw(); | ||
2046 | 106 | } | ||
2047 | 107 | |||
2048 | 108 | long View::PostLayoutManagement(long LayoutResult) | ||
2049 | 109 | { | ||
2050 | 110 | Relayout(); | ||
2051 | 111 | return LayoutResult; | ||
2052 | 112 | } | ||
2053 | 113 | |||
2054 | 114 | |||
2055 | 115 | nux::View* View::default_focus() const | ||
2056 | 116 | { | ||
2057 | 117 | return search_bar_->text_entry(); | ||
2058 | 118 | } | ||
2059 | 119 | |||
2060 | 120 | void View::SetQueries(Hud::Queries queries) | ||
2061 | 121 | { | ||
2062 | 122 | // remove the previous children | ||
2063 | 123 | for (auto button = buttons_.begin(); button != buttons_.end(); button++) | ||
2064 | 124 | { | ||
2065 | 125 | RemoveChild((*button).GetPointer()); | ||
2066 | 126 | } | ||
2067 | 127 | |||
2068 | 128 | queries_ = queries_; | ||
2069 | 129 | buttons_.clear(); | ||
2070 | 130 | button_views_->Clear(); | ||
2071 | 131 | int found_items = 0; | ||
2072 | 132 | for (auto query = queries.begin(); query != queries.end(); query++) | ||
2073 | 133 | { | ||
2074 | 134 | if (found_items > 5) | ||
2075 | 135 | break; | ||
2076 | 136 | |||
2077 | 137 | HudButton::Ptr button = HudButton::Ptr(new HudButton()); | ||
2078 | 138 | buttons_.push_front(button); | ||
2079 | 139 | button->SetQuery(*query); | ||
2080 | 140 | button_views_->AddView(button.GetPointer(), 0, nux::MINOR_POSITION_LEFT); | ||
2081 | 141 | |||
2082 | 142 | button->click.connect([&](nux::View* view) { | ||
2083 | 143 | query_activated.emit(dynamic_cast<HudButton*>(view)->GetQuery()); | ||
2084 | 144 | }); | ||
2085 | 145 | |||
2086 | 146 | button->key_nav_focus_activate.connect([&](nux::Area *area) { | ||
2087 | 147 | query_activated.emit(dynamic_cast<HudButton*>(area)->GetQuery()); | ||
2088 | 148 | }); | ||
2089 | 149 | |||
2090 | 150 | button->key_nav_focus_change.connect([&](nux::Area *area, bool recieving, KeyNavDirection direction){ | ||
2091 | 151 | if (recieving) | ||
2092 | 152 | query_selected.emit(dynamic_cast<HudButton*>(area)->GetQuery()); | ||
2093 | 153 | }); | ||
2094 | 154 | |||
2095 | 155 | button->is_rounded = (query == --(queries.end())) ? true : false; | ||
2096 | 156 | button->SetMinimumWidth(941); | ||
2097 | 157 | found_items++; | ||
2098 | 158 | } | ||
2099 | 159 | |||
2100 | 160 | QueueRelayout(); | ||
2101 | 161 | QueueDraw(); | ||
2102 | 162 | } | ||
2103 | 163 | |||
2104 | 164 | void View::SetIcon(std::string icon_name) | ||
2105 | 165 | { | ||
2106 | 166 | LOG_DEBUG(logger) << "Setting icon to " << icon_name; | ||
2107 | 167 | icon_->SetByIconName(icon_name.c_str(), icon_size); | ||
2108 | 168 | QueueDraw(); | ||
2109 | 169 | } | ||
2110 | 170 | |||
2111 | 171 | // Gives us the width and height of the contents that will give us the best "fit", | ||
2112 | 172 | // which means that the icons/views will not have uneccessary padding, everything will | ||
2113 | 173 | // look tight | ||
2114 | 174 | nux::Geometry View::GetBestFitGeometry(nux::Geometry const& for_geo) | ||
2115 | 175 | { | ||
2116 | 176 | //FIXME - remove magic values, replace with scalable text depending on DPI | ||
2117 | 177 | // requires smarter font settings really... | ||
2118 | 178 | int width, height = 0; | ||
2119 | 179 | width = 1024; | ||
2120 | 180 | height = 276; | ||
2121 | 181 | |||
2122 | 182 | LOG_DEBUG (logger) << "best fit is, " << width << ", " << height; | ||
2123 | 183 | |||
2124 | 184 | return nux::Geometry(0, 0, width, height); | ||
2125 | 185 | } | ||
2126 | 186 | |||
2127 | 187 | void View::AboutToShow() | ||
2128 | 188 | { | ||
2129 | 189 | renderer_.AboutToShow(); | ||
2130 | 190 | } | ||
2131 | 191 | |||
2132 | 192 | void View::AboutToHide() | ||
2133 | 193 | { | ||
2134 | 194 | renderer_.AboutToHide(); | ||
2135 | 195 | } | ||
2136 | 196 | |||
2137 | 197 | void View::SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo) | ||
2138 | 198 | { | ||
2139 | 199 | window_geometry_ = geo; | ||
2140 | 200 | window_geometry_.x = 0; | ||
2141 | 201 | window_geometry_.y = 0; | ||
2142 | 202 | absolute_window_geometry_ = absolute_geo; | ||
2143 | 203 | } | ||
2144 | 204 | |||
2145 | 205 | namespace | ||
2146 | 206 | { | ||
2147 | 207 | const int top_spacing = 9; | ||
2148 | 208 | const int content_width = 941; | ||
2149 | 209 | const int icon_vertical_margin = 5; | ||
2150 | 210 | const int spacing_between_icon_and_content = 8; | ||
2151 | 211 | } | ||
2152 | 212 | |||
2153 | 213 | void View::SetupViews() | ||
2154 | 214 | { | ||
2155 | 215 | layout_ = new nux::HLayout(); | ||
2156 | 216 | |||
2157 | 217 | icon_ = new Icon("", icon_size, true); | ||
2158 | 218 | nux::Layout* icon_layout = new nux::VLayout(); | ||
2159 | 219 | icon_layout->SetVerticalExternalMargin(icon_vertical_margin); | ||
2160 | 220 | icon_layout->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL); | ||
2161 | 221 | layout_->AddLayout(icon_layout, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_MATCHCONTENT); | ||
2162 | 222 | layout_->AddLayout(new nux::SpaceLayout(spacing_between_icon_and_content, | ||
2163 | 223 | spacing_between_icon_and_content, | ||
2164 | 224 | spacing_between_icon_and_content, | ||
2165 | 225 | spacing_between_icon_and_content), 0); | ||
2166 | 226 | |||
2167 | 227 | |||
2168 | 228 | content_layout_ = new nux::VLayout(); | ||
2169 | 229 | layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP); | ||
2170 | 230 | SetLayout(layout_.GetPointer()); | ||
2171 | 231 | |||
2172 | 232 | // add the top spacing | ||
2173 | 233 | content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0); | ||
2174 | 234 | |||
2175 | 235 | // add the search bar to the composite | ||
2176 | 236 | search_bar_ = new unity::SearchBar(content_width, true); | ||
2177 | 237 | search_bar_->disable_glow = true; | ||
2178 | 238 | search_bar_->search_hint = default_text; | ||
2179 | 239 | search_bar_->search_changed.connect(sigc::mem_fun(this, &View::OnSearchChanged)); | ||
2180 | 240 | AddChild(search_bar_.GetPointer()); | ||
2181 | 241 | content_layout_->AddView(search_bar_.GetPointer(), 0, nux::MINOR_POSITION_LEFT); | ||
2182 | 242 | |||
2183 | 243 | button_views_ = new nux::VLayout(); | ||
2184 | 244 | button_views_->SetMaximumWidth(content_width); | ||
2185 | 245 | |||
2186 | 246 | content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT); | ||
2187 | 247 | } | ||
2188 | 248 | |||
2189 | 249 | void View::OnSearchChanged(std::string const& search_string) | ||
2190 | 250 | { | ||
2191 | 251 | LOG_DEBUG(logger) << "got search change"; | ||
2192 | 252 | search_changed.emit(search_string); | ||
2193 | 253 | if (search_string.empty()) | ||
2194 | 254 | { | ||
2195 | 255 | search_bar_->search_hint = default_text; | ||
2196 | 256 | } | ||
2197 | 257 | else | ||
2198 | 258 | { | ||
2199 | 259 | search_bar_->search_hint = ""; | ||
2200 | 260 | } | ||
2201 | 261 | } | ||
2202 | 262 | |||
2203 | 263 | |||
2204 | 264 | void View::OnKeyDown (unsigned long event_type, unsigned long keysym, | ||
2205 | 265 | unsigned long event_state, const TCHAR* character, | ||
2206 | 266 | unsigned short key_repeat_count) | ||
2207 | 267 | { | ||
2208 | 268 | if (keysym == NUX_VK_ESCAPE) | ||
2209 | 269 | { | ||
2210 | 270 | LOG_DEBUG(logger) << "got escape key"; | ||
2211 | 271 | ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST); | ||
2212 | 272 | } | ||
2213 | 273 | } | ||
2214 | 274 | |||
2215 | 275 | void View::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) | ||
2216 | 276 | { | ||
2217 | 277 | if (!content_geo_.IsPointInside(x, y)) | ||
2218 | 278 | { | ||
2219 | 279 | ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST); | ||
2220 | 280 | } | ||
2221 | 281 | } | ||
2222 | 282 | |||
2223 | 283 | void View::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) | ||
2224 | 284 | { | ||
2225 | 285 | renderer_.DrawFull(gfx_context, layout_->GetGeometry(), absolute_window_geometry_, window_geometry_, true); | ||
2226 | 286 | } | ||
2227 | 287 | |||
2228 | 288 | void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) | ||
2229 | 289 | { | ||
2230 | 290 | renderer_.DrawInner(gfx_context, layout_->GetGeometry(), absolute_window_geometry_, window_geometry_); | ||
2231 | 291 | |||
2232 | 292 | if (IsFullRedraw()) | ||
2233 | 293 | { | ||
2234 | 294 | nux::GetPainter().PushBackgroundStack(); | ||
2235 | 295 | layout_->ProcessDraw(gfx_context, force_draw); | ||
2236 | 296 | nux::GetPainter().PopBackgroundStack(); | ||
2237 | 297 | } | ||
2238 | 298 | else | ||
2239 | 299 | { | ||
2240 | 300 | layout_->ProcessDraw(gfx_context, force_draw); | ||
2241 | 301 | } | ||
2242 | 302 | |||
2243 | 303 | renderer_.DrawInnerCleanup(gfx_context, layout_->GetGeometry(), absolute_window_geometry_, window_geometry_); | ||
2244 | 304 | } | ||
2245 | 305 | |||
2246 | 306 | // Keyboard navigation | ||
2247 | 307 | bool View::AcceptKeyNavFocus() | ||
2248 | 308 | { | ||
2249 | 309 | return false; | ||
2250 | 310 | } | ||
2251 | 311 | |||
2252 | 312 | // Introspectable | ||
2253 | 313 | std::string View::GetName() const | ||
2254 | 314 | { | ||
2255 | 315 | return "HudView"; | ||
2256 | 316 | } | ||
2257 | 317 | |||
2258 | 318 | void View::AddProperties(GVariantBuilder* builder) | ||
2259 | 319 | { | ||
2260 | 320 | |||
2261 | 321 | } | ||
2262 | 322 | |||
2263 | 323 | bool View::InspectKeyEvent(unsigned int eventType, | ||
2264 | 324 | unsigned int key_sym, | ||
2265 | 325 | const char* character) | ||
2266 | 326 | { | ||
2267 | 327 | if ((eventType == nux::NUX_KEYDOWN) && (key_sym == NUX_VK_ESCAPE)) | ||
2268 | 328 | { | ||
2269 | 329 | if (search_bar_->search_string == "") | ||
2270 | 330 | { | ||
2271 | 331 | ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST); | ||
2272 | 332 | } | ||
2273 | 333 | else | ||
2274 | 334 | { | ||
2275 | 335 | search_bar_->search_string = ""; | ||
2276 | 336 | search_bar_->search_hint = default_text; | ||
2277 | 337 | } | ||
2278 | 338 | return true; | ||
2279 | 339 | } | ||
2280 | 340 | return false; | ||
2281 | 341 | } | ||
2282 | 342 | |||
2283 | 343 | nux::Area* View::FindKeyFocusArea(unsigned int key_symbol, | ||
2284 | 344 | unsigned long x11_key_code, | ||
2285 | 345 | unsigned long special_keys_state) | ||
2286 | 346 | { | ||
2287 | 347 | // Do what nux::View does, but if the event isn't a key navigation, | ||
2288 | 348 | // designate the text entry to process it. | ||
2289 | 349 | |||
2290 | 350 | nux::KeyNavDirection direction = nux::KEY_NAV_NONE; | ||
2291 | 351 | switch (x11_key_code) | ||
2292 | 352 | { | ||
2293 | 353 | case NUX_VK_UP: | ||
2294 | 354 | direction = nux::KEY_NAV_UP; | ||
2295 | 355 | break; | ||
2296 | 356 | case NUX_VK_DOWN: | ||
2297 | 357 | direction = nux::KEY_NAV_DOWN; | ||
2298 | 358 | break; | ||
2299 | 359 | case NUX_VK_LEFT: | ||
2300 | 360 | direction = nux::KEY_NAV_LEFT; | ||
2301 | 361 | break; | ||
2302 | 362 | case NUX_VK_RIGHT: | ||
2303 | 363 | direction = nux::KEY_NAV_RIGHT; | ||
2304 | 364 | break; | ||
2305 | 365 | case NUX_VK_LEFT_TAB: | ||
2306 | 366 | direction = nux::KEY_NAV_TAB_PREVIOUS; | ||
2307 | 367 | break; | ||
2308 | 368 | case NUX_VK_TAB: | ||
2309 | 369 | direction = nux::KEY_NAV_TAB_NEXT; | ||
2310 | 370 | break; | ||
2311 | 371 | case NUX_VK_ENTER: | ||
2312 | 372 | case NUX_KP_ENTER: | ||
2313 | 373 | // Not sure if Enter should be a navigation key | ||
2314 | 374 | direction = nux::KEY_NAV_ENTER; | ||
2315 | 375 | break; | ||
2316 | 376 | default: | ||
2317 | 377 | direction = nux::KEY_NAV_NONE; | ||
2318 | 378 | break; | ||
2319 | 379 | } | ||
2320 | 380 | |||
2321 | 381 | if (has_key_focus_) | ||
2322 | 382 | { | ||
2323 | 383 | return this; | ||
2324 | 384 | } | ||
2325 | 385 | else if (direction == nux::KEY_NAV_NONE) | ||
2326 | 386 | { | ||
2327 | 387 | // then send the event to the search entry | ||
2328 | 388 | return search_bar_->text_entry(); | ||
2329 | 389 | } | ||
2330 | 390 | else if (next_object_to_key_focus_area_) | ||
2331 | 391 | { | ||
2332 | 392 | return next_object_to_key_focus_area_->FindKeyFocusArea(key_symbol, x11_key_code, special_keys_state); | ||
2333 | 393 | } | ||
2334 | 394 | return NULL; | ||
2335 | 395 | } | ||
2336 | 396 | |||
2337 | 397 | } | ||
2338 | 398 | } | ||
2339 | 0 | 399 | ||
2340 | === added file 'plugins/unityshell/src/HudView.h' | |||
2341 | --- plugins/unityshell/src/HudView.h 1970-01-01 00:00:00 +0000 | |||
2342 | +++ plugins/unityshell/src/HudView.h 2012-02-06 11:00:29 +0000 | |||
2343 | @@ -0,0 +1,118 @@ | |||
2344 | 1 | /* | ||
2345 | 2 | * Copyright (C) 2010 Canonical Ltd | ||
2346 | 3 | * | ||
2347 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2348 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
2349 | 6 | * published by the Free Software Foundation. | ||
2350 | 7 | * | ||
2351 | 8 | * This program is distributed in the hope that it will be useful, | ||
2352 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2353 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2354 | 11 | * GNU General Public License for more details. | ||
2355 | 12 | * | ||
2356 | 13 | * You should have received a copy of the GNU General Public License | ||
2357 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2358 | 15 | * | ||
2359 | 16 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
2360 | 17 | */ | ||
2361 | 18 | |||
2362 | 19 | #ifndef UNITY_HUD_VIEW_H_ | ||
2363 | 20 | #define UNITY_HUD_VIEW_H_ | ||
2364 | 21 | |||
2365 | 22 | #include <string> | ||
2366 | 23 | |||
2367 | 24 | #include <NuxGraphics/GraphicsEngine.h> | ||
2368 | 25 | #include <Nux/Nux.h> | ||
2369 | 26 | #include <Nux/PaintLayer.h> | ||
2370 | 27 | #include <Nux/View.h> | ||
2371 | 28 | #include <Nux/VLayout.h> | ||
2372 | 29 | #include <StaticCairoText.h> | ||
2373 | 30 | |||
2374 | 31 | #include <glib.h> | ||
2375 | 32 | |||
2376 | 33 | #include <UnityCore/Hud.h> | ||
2377 | 34 | #include "Introspectable.h" | ||
2378 | 35 | |||
2379 | 36 | #include "UBusWrapper.h" | ||
2380 | 37 | #include "HudIcon.h" | ||
2381 | 38 | #include "HudButton.h" | ||
2382 | 39 | #include "SearchBar.h" | ||
2383 | 40 | #include "OverlayRenderer.h" | ||
2384 | 41 | |||
2385 | 42 | namespace unity | ||
2386 | 43 | { | ||
2387 | 44 | namespace hud | ||
2388 | 45 | { | ||
2389 | 46 | |||
2390 | 47 | class View : public nux::View, public unity::debug::Introspectable | ||
2391 | 48 | { | ||
2392 | 49 | NUX_DECLARE_OBJECT_TYPE(HudView, nux::View); | ||
2393 | 50 | typedef nux::ObjectPtr<View> Ptr; | ||
2394 | 51 | public: | ||
2395 | 52 | View(); | ||
2396 | 53 | ~View(); | ||
2397 | 54 | |||
2398 | 55 | void ResetToDefault(); | ||
2399 | 56 | |||
2400 | 57 | void Relayout(); | ||
2401 | 58 | nux::View* default_focus() const; | ||
2402 | 59 | |||
2403 | 60 | void SetQueries(Hud::Queries queries); | ||
2404 | 61 | void SetIcon(std::string icon_name); | ||
2405 | 62 | |||
2406 | 63 | void AboutToShow(); | ||
2407 | 64 | void AboutToHide(); | ||
2408 | 65 | |||
2409 | 66 | void SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo); | ||
2410 | 67 | |||
2411 | 68 | sigc::signal<void, std::string> search_changed; | ||
2412 | 69 | sigc::signal<void, std::string> search_activated; | ||
2413 | 70 | sigc::signal<void, Query::Ptr> query_activated; | ||
2414 | 71 | sigc::signal<void, Query::Ptr> query_selected; | ||
2415 | 72 | |||
2416 | 73 | protected: | ||
2417 | 74 | virtual Area* FindKeyFocusArea(unsigned int key_symbol, | ||
2418 | 75 | unsigned long x11_key_code, | ||
2419 | 76 | unsigned long special_keys_state); | ||
2420 | 77 | |||
2421 | 78 | void SetupViews(); | ||
2422 | 79 | void OnSearchChanged(std::string const& search_string); | ||
2423 | 80 | virtual long PostLayoutManagement(long LayoutResult); | ||
2424 | 81 | private: | ||
2425 | 82 | void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key); | ||
2426 | 83 | void OnKeyDown (unsigned long event_type, unsigned long event_keysym, | ||
2427 | 84 | unsigned long event_state, const TCHAR* character, | ||
2428 | 85 | unsigned short key_repeat_count); | ||
2429 | 86 | void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); | ||
2430 | 87 | void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw); | ||
2431 | 88 | bool InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character); | ||
2432 | 89 | bool AcceptKeyNavFocus(); | ||
2433 | 90 | nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo); | ||
2434 | 91 | |||
2435 | 92 | std::string GetName() const; | ||
2436 | 93 | void AddProperties(GVariantBuilder* builder); | ||
2437 | 94 | |||
2438 | 95 | private: | ||
2439 | 96 | UBusManager ubus; | ||
2440 | 97 | nux::ObjectPtr<nux::Layout> layout_; | ||
2441 | 98 | nux::ObjectPtr<nux::Layout> content_layout_; | ||
2442 | 99 | nux::ObjectPtr<nux::VLayout> button_views_; | ||
2443 | 100 | std::list<HudButton::Ptr> buttons_; | ||
2444 | 101 | |||
2445 | 102 | //FIXME - replace with dash search bar once modifications to dash search bar land | ||
2446 | 103 | SearchBar::Ptr search_bar_; | ||
2447 | 104 | Icon::Ptr icon_; | ||
2448 | 105 | bool visible_; | ||
2449 | 106 | |||
2450 | 107 | Hud::Queries queries_; | ||
2451 | 108 | nux::Geometry content_geo_; | ||
2452 | 109 | OverlayRenderer renderer_; | ||
2453 | 110 | nux::Geometry window_geometry_; | ||
2454 | 111 | nux::Geometry absolute_window_geometry_; | ||
2455 | 112 | }; | ||
2456 | 113 | |||
2457 | 114 | |||
2458 | 115 | } | ||
2459 | 116 | } | ||
2460 | 117 | #endif | ||
2461 | 118 | |||
2462 | 0 | 119 | ||
2463 | === modified file 'plugins/unityshell/src/IMTextEntry.cpp' | |||
2464 | --- plugins/unityshell/src/IMTextEntry.cpp 2012-01-26 12:59:18 +0000 | |||
2465 | +++ plugins/unityshell/src/IMTextEntry.cpp 2012-02-06 11:00:29 +0000 | |||
2466 | @@ -27,12 +27,10 @@ | |||
2467 | 27 | 27 | ||
2468 | 28 | namespace unity | 28 | namespace unity |
2469 | 29 | { | 29 | { |
2470 | 30 | namespace dash | ||
2471 | 31 | { | ||
2472 | 32 | 30 | ||
2473 | 33 | namespace | 31 | namespace |
2474 | 34 | { | 32 | { |
2476 | 35 | nux::logging::Logger logger("unity.dash.imtextentry"); | 33 | nux::logging::Logger logger("unity.imtextentry"); |
2477 | 36 | } | 34 | } |
2478 | 37 | 35 | ||
2479 | 38 | NUX_IMPLEMENT_OBJECT_TYPE(IMTextEntry); | 36 | NUX_IMPLEMENT_OBJECT_TYPE(IMTextEntry); |
2480 | @@ -338,4 +336,3 @@ | |||
2481 | 338 | } | 336 | } |
2482 | 339 | 337 | ||
2483 | 340 | } | 338 | } |
2484 | 341 | } | ||
2485 | 342 | 339 | ||
2486 | === modified file 'plugins/unityshell/src/IMTextEntry.h' | |||
2487 | --- plugins/unityshell/src/IMTextEntry.h 2012-01-03 00:51:51 +0000 | |||
2488 | +++ plugins/unityshell/src/IMTextEntry.h 2012-02-06 11:00:29 +0000 | |||
2489 | @@ -30,8 +30,6 @@ | |||
2490 | 30 | 30 | ||
2491 | 31 | namespace unity | 31 | namespace unity |
2492 | 32 | { | 32 | { |
2493 | 33 | namespace dash | ||
2494 | 34 | { | ||
2495 | 35 | 33 | ||
2496 | 36 | using namespace unity::glib; | 34 | using namespace unity::glib; |
2497 | 37 | using namespace nux; | 35 | using namespace nux; |
2498 | @@ -80,6 +78,5 @@ | |||
2499 | 80 | }; | 78 | }; |
2500 | 81 | 79 | ||
2501 | 82 | } | 80 | } |
2502 | 83 | } | ||
2503 | 84 | 81 | ||
2504 | 85 | #endif | 82 | #endif |
2505 | 86 | 83 | ||
2506 | === modified file 'plugins/unityshell/src/IconTexture.cpp' | |||
2507 | --- plugins/unityshell/src/IconTexture.cpp 2011-11-08 18:21:44 +0000 | |||
2508 | +++ plugins/unityshell/src/IconTexture.cpp 2012-02-06 11:00:29 +0000 | |||
2509 | @@ -24,6 +24,7 @@ | |||
2510 | 24 | #include <pango/pangocairo.h> | 24 | #include <pango/pangocairo.h> |
2511 | 25 | 25 | ||
2512 | 26 | #include <Nux/Nux.h> | 26 | #include <Nux/Nux.h> |
2513 | 27 | #include <NuxCore/Logger.h> | ||
2514 | 27 | #include <NuxGraphics/GLThread.h> | 28 | #include <NuxGraphics/GLThread.h> |
2515 | 28 | #include <UnityCore/GLibWrapper.h> | 29 | #include <UnityCore/GLibWrapper.h> |
2516 | 29 | #include <UnityCore/Variant.h> | 30 | #include <UnityCore/Variant.h> |
2517 | @@ -37,6 +38,7 @@ | |||
2518 | 37 | namespace | 38 | namespace |
2519 | 38 | { | 39 | { |
2520 | 39 | const char* const DEFAULT_ICON = "text-x-preview"; | 40 | const char* const DEFAULT_ICON = "text-x-preview"; |
2521 | 41 | nux::logging::Logger logger("unity.icontexture"); | ||
2522 | 40 | } | 42 | } |
2523 | 41 | 43 | ||
2524 | 42 | using namespace unity; | 44 | using namespace unity; |
2525 | @@ -67,7 +69,7 @@ | |||
2526 | 67 | { | 69 | { |
2527 | 68 | _icon_name = g_strdup(icon_name ? icon_name : DEFAULT_ICON); | 70 | _icon_name = g_strdup(icon_name ? icon_name : DEFAULT_ICON); |
2528 | 69 | 71 | ||
2530 | 70 | if (!g_strcmp0(_icon_name, "") == 0 && !defer_icon_loading) | 72 | if (g_strcmp0(_icon_name, "") != 0 && !defer_icon_loading) |
2531 | 71 | LoadIcon(); | 73 | LoadIcon(); |
2532 | 72 | } | 74 | } |
2533 | 73 | 75 | ||
2534 | @@ -95,8 +97,11 @@ | |||
2535 | 95 | 97 | ||
2536 | 96 | void IconTexture::LoadIcon() | 98 | void IconTexture::LoadIcon() |
2537 | 97 | { | 99 | { |
2540 | 98 | static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview"; | 100 | LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading; |
2541 | 99 | 101 | static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview"; | |
2542 | 102 | if (!g_strcmp0(_icon_name, "")) | ||
2543 | 103 | return; | ||
2544 | 104 | |||
2545 | 100 | if (_loading) | 105 | if (_loading) |
2546 | 101 | return; | 106 | return; |
2547 | 102 | _loading = true; | 107 | _loading = true; |
2548 | @@ -144,6 +149,7 @@ | |||
2549 | 144 | _texture_height, | 149 | _texture_height, |
2550 | 145 | sigc::mem_fun(this, &IconTexture::CreateTextureCallback)); | 150 | sigc::mem_fun(this, &IconTexture::CreateTextureCallback)); |
2551 | 146 | QueueDraw(); | 151 | QueueDraw(); |
2552 | 152 | _loading = false; | ||
2553 | 147 | } | 153 | } |
2554 | 148 | 154 | ||
2555 | 149 | void IconTexture::IconLoaded(std::string const& icon_name, unsigned size, | 155 | void IconTexture::IconLoaded(std::string const& icon_name, unsigned size, |
2556 | @@ -162,6 +168,9 @@ | |||
2557 | 162 | if (icon_name != DEFAULT_ICON) | 168 | if (icon_name != DEFAULT_ICON) |
2558 | 163 | SetByIconName(DEFAULT_ICON, _size); | 169 | SetByIconName(DEFAULT_ICON, _size); |
2559 | 164 | } | 170 | } |
2560 | 171 | |||
2561 | 172 | texture_updated.emit(_texture_cached.GetPointer()); | ||
2562 | 173 | QueueDraw(); | ||
2563 | 165 | } | 174 | } |
2564 | 166 | 175 | ||
2565 | 167 | void IconTexture::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) | 176 | void IconTexture::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) |
2566 | 168 | 177 | ||
2567 | === modified file 'plugins/unityshell/src/IconTexture.h' | |||
2568 | --- plugins/unityshell/src/IconTexture.h 2011-12-08 01:23:11 +0000 | |||
2569 | +++ plugins/unityshell/src/IconTexture.h 2012-02-06 11:00:29 +0000 | |||
2570 | @@ -53,6 +53,8 @@ | |||
2571 | 53 | 53 | ||
2572 | 54 | nux::BaseTexture* texture(); | 54 | nux::BaseTexture* texture(); |
2573 | 55 | 55 | ||
2574 | 56 | sigc::signal<void, nux::BaseTexture*> texture_updated; | ||
2575 | 57 | |||
2576 | 56 | protected: | 58 | protected: |
2577 | 57 | // Key navigation | 59 | // Key navigation |
2578 | 58 | virtual bool AcceptKeyNavFocus(); | 60 | virtual bool AcceptKeyNavFocus(); |
2579 | @@ -61,7 +63,8 @@ | |||
2580 | 61 | std::string GetName() const; | 63 | std::string GetName() const; |
2581 | 62 | void AddProperties(GVariantBuilder* builder); | 64 | void AddProperties(GVariantBuilder* builder); |
2582 | 63 | virtual bool DoCanFocus(); | 65 | virtual bool DoCanFocus(); |
2584 | 64 | 66 | GdkPixbuf* _pixbuf_cached; | |
2585 | 67 | |||
2586 | 65 | protected: | 68 | protected: |
2587 | 66 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); | 69 | void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); |
2588 | 67 | 70 | ||
2589 | @@ -74,7 +77,7 @@ | |||
2590 | 74 | char* _icon_name; | 77 | char* _icon_name; |
2591 | 75 | unsigned int _size; | 78 | unsigned int _size; |
2592 | 76 | 79 | ||
2594 | 77 | GdkPixbuf* _pixbuf_cached; | 80 | |
2595 | 78 | nux::ObjectPtr<nux::BaseTexture> _texture_cached; | 81 | nux::ObjectPtr<nux::BaseTexture> _texture_cached; |
2596 | 79 | // FIXME: make these two a nux::Size. | 82 | // FIXME: make these two a nux::Size. |
2597 | 80 | int _texture_width; | 83 | int _texture_width; |
2598 | 81 | 84 | ||
2599 | === modified file 'plugins/unityshell/src/OverlayRenderer.cpp' | |||
2600 | --- plugins/unityshell/src/OverlayRenderer.cpp 2012-02-03 21:56:04 +0000 | |||
2601 | +++ plugins/unityshell/src/OverlayRenderer.cpp 2012-02-06 11:00:29 +0000 | |||
2602 | @@ -50,7 +50,7 @@ | |||
2603 | 50 | void Init(); | 50 | void Init(); |
2604 | 51 | void OnBackgroundColorChanged(GVariant* args); | 51 | void OnBackgroundColorChanged(GVariant* args); |
2605 | 52 | 52 | ||
2607 | 53 | void Draw(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry); | 53 | void Draw(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry, bool force_draw); |
2608 | 54 | void DrawContent(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry); | 54 | void DrawContent(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry); |
2609 | 55 | void DrawContentCleanup(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry); | 55 | void DrawContentCleanup(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry); |
2610 | 56 | 56 | ||
2611 | @@ -118,12 +118,12 @@ | |||
2612 | 118 | parent->need_redraw.emit(); | 118 | parent->need_redraw.emit(); |
2613 | 119 | } | 119 | } |
2614 | 120 | 120 | ||
2616 | 121 | void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry) | 121 | void OverlayRendererImpl::Draw(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geometry, bool force_edges) |
2617 | 122 | { | 122 | { |
2618 | 123 | bool paint_blur = BackgroundEffectHelper::blur_type != BLUR_NONE; | 123 | bool paint_blur = BackgroundEffectHelper::blur_type != BLUR_NONE; |
2619 | 124 | nux::Geometry geo = content_geo; | 124 | nux::Geometry geo = content_geo; |
2620 | 125 | 125 | ||
2622 | 126 | if (dash::Settings::Instance().GetFormFactor() != dash::FormFactor::NETBOOK) | 126 | if (dash::Settings::Instance().GetFormFactor() != dash::FormFactor::NETBOOK || force_edges) |
2623 | 127 | { | 127 | { |
2624 | 128 | // Paint the edges | 128 | // Paint the edges |
2625 | 129 | { | 129 | { |
2626 | @@ -475,9 +475,9 @@ | |||
2627 | 475 | pimpl_->bg_effect_helper_.blur_type = BLUR_NONE; | 475 | pimpl_->bg_effect_helper_.blur_type = BLUR_NONE; |
2628 | 476 | } | 476 | } |
2629 | 477 | 477 | ||
2631 | 478 | void OverlayRenderer::DrawFull(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo) | 478 | void OverlayRenderer::DrawFull(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo, bool force_edges) |
2632 | 479 | { | 479 | { |
2634 | 480 | pimpl_->Draw(gfx_context, content_geo, absolute_geo, geo); | 480 | pimpl_->Draw(gfx_context, content_geo, absolute_geo, geo, force_edges); |
2635 | 481 | } | 481 | } |
2636 | 482 | 482 | ||
2637 | 483 | void OverlayRenderer::DrawInner(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo) | 483 | void OverlayRenderer::DrawInner(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo) |
2638 | 484 | 484 | ||
2639 | === modified file 'plugins/unityshell/src/OverlayRenderer.h' | |||
2640 | --- plugins/unityshell/src/OverlayRenderer.h 2012-01-27 06:58:20 +0000 | |||
2641 | +++ plugins/unityshell/src/OverlayRenderer.h 2012-02-06 11:00:29 +0000 | |||
2642 | @@ -70,7 +70,7 @@ | |||
2643 | 70 | * absolute_geo: your views GetAbsoluteGeometry() | 70 | * absolute_geo: your views GetAbsoluteGeometry() |
2644 | 71 | * geo: your views GetGeometry() | 71 | * geo: your views GetGeometry() |
2645 | 72 | */ | 72 | */ |
2647 | 73 | void DrawFull(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo); | 73 | void DrawFull(nux::GraphicsEngine& gfx_context, nux::Geometry content_geo, nux::Geometry absolute_geo, nux::Geometry geo, bool force_edges=false); |
2648 | 74 | 74 | ||
2649 | 75 | /* | 75 | /* |
2650 | 76 | * Draws just the stack that is overlay behind the inner_geometry using push/pop layers, call in DrawContent() before drawing your content | 76 | * Draws just the stack that is overlay behind the inner_geometry using push/pop layers, call in DrawContent() before drawing your content |
2651 | 77 | 77 | ||
2652 | === renamed file 'plugins/unityshell/src/DashSearchBar.cpp' => 'plugins/unityshell/src/SearchBar.cpp' | |||
2653 | --- plugins/unityshell/src/DashSearchBar.cpp 2012-01-26 22:17:41 +0000 | |||
2654 | +++ plugins/unityshell/src/SearchBar.cpp 2012-02-06 11:00:29 +0000 | |||
2655 | @@ -25,6 +25,7 @@ | |||
2656 | 25 | #include <Nux/VLayout.h> | 25 | #include <Nux/VLayout.h> |
2657 | 26 | #include <Nux/Layout.h> | 26 | #include <Nux/Layout.h> |
2658 | 27 | #include <Nux/WindowCompositor.h> | 27 | #include <Nux/WindowCompositor.h> |
2659 | 28 | #include <NuxCore/Logger.h> | ||
2660 | 28 | 29 | ||
2661 | 29 | #include <NuxImage/CairoGraphics.h> | 30 | #include <NuxImage/CairoGraphics.h> |
2662 | 30 | #include <NuxImage/ImageSurface.h> | 31 | #include <NuxImage/ImageSurface.h> |
2663 | @@ -36,7 +37,7 @@ | |||
2664 | 36 | #include <glib.h> | 37 | #include <glib.h> |
2665 | 37 | #include <glib/gi18n-lib.h> | 38 | #include <glib/gi18n-lib.h> |
2666 | 38 | 39 | ||
2668 | 39 | #include "DashSearchBar.h" | 40 | #include "SearchBar.h" |
2669 | 40 | #include <UnityCore/Variant.h> | 41 | #include <UnityCore/Variant.h> |
2670 | 41 | 42 | ||
2671 | 42 | #include "CairoTexture.h" | 43 | #include "CairoTexture.h" |
2672 | @@ -48,12 +49,17 @@ | |||
2673 | 48 | namespace | 49 | namespace |
2674 | 49 | { | 50 | { |
2675 | 50 | const float kExpandDefaultIconOpacity = 1.0f; | 51 | const float kExpandDefaultIconOpacity = 1.0f; |
2676 | 52 | const int external_margin_vertical = 8; | ||
2677 | 53 | const int external_margin_horizontal = 7; | ||
2678 | 54 | } | ||
2679 | 55 | |||
2680 | 56 | namespace | ||
2681 | 57 | { | ||
2682 | 58 | nux::logging::Logger logger("unity"); | ||
2683 | 51 | } | 59 | } |
2684 | 52 | 60 | ||
2685 | 53 | namespace unity | 61 | namespace unity |
2686 | 54 | { | 62 | { |
2687 | 55 | namespace dash | ||
2688 | 56 | { | ||
2689 | 57 | 63 | ||
2690 | 58 | NUX_IMPLEMENT_OBJECT_TYPE(SearchBar); | 64 | NUX_IMPLEMENT_OBJECT_TYPE(SearchBar); |
2691 | 59 | 65 | ||
2692 | @@ -62,18 +68,53 @@ | |||
2693 | 62 | , search_hint("") | 68 | , search_hint("") |
2694 | 63 | , showing_filters(false) | 69 | , showing_filters(false) |
2695 | 64 | , can_refine_search(false) | 70 | , can_refine_search(false) |
2696 | 71 | , disable_glow(false) | ||
2697 | 72 | , show_filter_hint_(true) | ||
2698 | 65 | , search_bar_width_(642) | 73 | , search_bar_width_(642) |
2699 | 66 | , live_search_timeout_(0) | 74 | , live_search_timeout_(0) |
2700 | 67 | , start_spinner_timeout_(0) | 75 | , start_spinner_timeout_(0) |
2701 | 68 | { | 76 | { |
2702 | 77 | Init(); | ||
2703 | 78 | } | ||
2704 | 79 | |||
2705 | 80 | SearchBar::SearchBar(int search_bar_width, bool show_filter_hint_, NUX_FILE_LINE_DECL) | ||
2706 | 81 | : View(NUX_FILE_LINE_PARAM) | ||
2707 | 82 | , search_hint("") | ||
2708 | 83 | , showing_filters(false) | ||
2709 | 84 | , can_refine_search(false) | ||
2710 | 85 | , disable_glow(false) | ||
2711 | 86 | , show_filter_hint_(show_filter_hint_) | ||
2712 | 87 | , search_bar_width_(search_bar_width) | ||
2713 | 88 | , live_search_timeout_(0) | ||
2714 | 89 | , start_spinner_timeout_(0) | ||
2715 | 90 | { | ||
2716 | 91 | Init(); | ||
2717 | 92 | } | ||
2718 | 93 | |||
2719 | 94 | SearchBar::SearchBar(int search_bar_width, NUX_FILE_LINE_DECL) | ||
2720 | 95 | : View(NUX_FILE_LINE_PARAM) | ||
2721 | 96 | , search_hint("") | ||
2722 | 97 | , showing_filters(false) | ||
2723 | 98 | , can_refine_search(false) | ||
2724 | 99 | , disable_glow(false) | ||
2725 | 100 | , show_filter_hint_(true) | ||
2726 | 101 | , search_bar_width_(search_bar_width) | ||
2727 | 102 | , live_search_timeout_(0) | ||
2728 | 103 | , start_spinner_timeout_(0) | ||
2729 | 104 | { | ||
2730 | 105 | Init(); | ||
2731 | 106 | } | ||
2732 | 107 | |||
2733 | 108 | void SearchBar::Init() | ||
2734 | 109 | { | ||
2735 | 69 | nux::BaseTexture* icon = dash::Style::Instance().GetSearchMagnifyIcon(); | 110 | nux::BaseTexture* icon = dash::Style::Instance().GetSearchMagnifyIcon(); |
2736 | 70 | 111 | ||
2737 | 71 | bg_layer_ = new nux::ColorLayer(nux::Color(0xff595853), true); | 112 | bg_layer_ = new nux::ColorLayer(nux::Color(0xff595853), true); |
2738 | 72 | 113 | ||
2739 | 73 | layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); | 114 | layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); |
2740 | 74 | layout_->SetHorizontalInternalMargin(0); | 115 | layout_->SetHorizontalInternalMargin(0); |
2743 | 75 | layout_->SetVerticalExternalMargin(8); | 116 | layout_->SetVerticalExternalMargin(external_margin_vertical); |
2744 | 76 | layout_->SetHorizontalExternalMargin(7); | 117 | layout_->SetHorizontalExternalMargin(external_margin_horizontal); |
2745 | 77 | SetLayout(layout_); | 118 | SetLayout(layout_); |
2746 | 78 | 119 | ||
2747 | 79 | spinner_ = new SearchBarSpinner(); | 120 | spinner_ = new SearchBarSpinner(); |
2748 | @@ -102,42 +143,44 @@ | |||
2749 | 102 | layered_layout_->SetMaximumWidth(search_bar_width_); | 143 | layered_layout_->SetMaximumWidth(search_bar_width_); |
2750 | 103 | layout_->AddView(layered_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); | 144 | layout_->AddView(layered_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX); |
2751 | 104 | 145 | ||
2788 | 105 | std::string filter_str = _("<small><b>Filter results</b></small>"); | 146 | if (show_filter_hint_) |
2789 | 106 | show_filters_ = new nux::StaticCairoText(filter_str.c_str()); | 147 | { |
2790 | 107 | show_filters_->SetVisible(false); | 148 | std::string filter_str = _("<small><b>Filter results</b></small>"); |
2791 | 108 | show_filters_->SetFont("Ubuntu 10"); | 149 | show_filters_ = new nux::StaticCairoText(filter_str.c_str()); |
2792 | 109 | show_filters_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); | 150 | show_filters_->SetVisible(false); |
2793 | 110 | show_filters_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_LEFT); | 151 | show_filters_->SetFont("Ubuntu 10"); |
2794 | 111 | show_filters_->mouse_click.connect([&] (int x, int y, unsigned long b, unsigned long k) { showing_filters = !showing_filters; }); | 152 | show_filters_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 1.0f)); |
2795 | 112 | 153 | show_filters_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_LEFT); | |
2796 | 113 | nux::BaseTexture* arrow; | 154 | show_filters_->mouse_click.connect([&] (int x, int y, unsigned long b, unsigned long k) { showing_filters = !showing_filters; }); |
2797 | 114 | arrow = dash::Style::Instance().GetGroupExpandIcon(); | 155 | |
2798 | 115 | expand_icon_ = new IconTexture(arrow, | 156 | nux::BaseTexture* arrow; |
2799 | 116 | arrow->GetWidth(), | 157 | arrow = dash::Style::Instance().GetGroupExpandIcon(); |
2800 | 117 | arrow->GetHeight()); | 158 | expand_icon_ = new IconTexture(arrow, |
2801 | 118 | expand_icon_->SetOpacity(kExpandDefaultIconOpacity); | 159 | arrow->GetWidth(), |
2802 | 119 | expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); | 160 | arrow->GetHeight()); |
2803 | 120 | expand_icon_->SetVisible(false); | 161 | expand_icon_->SetOpacity(kExpandDefaultIconOpacity); |
2804 | 121 | expand_icon_->mouse_click.connect([&] (int x, int y, unsigned long b, unsigned long k) { showing_filters = !showing_filters; }); | 162 | expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight()); |
2805 | 122 | 163 | expand_icon_->SetVisible(false); | |
2806 | 123 | filter_layout_ = new nux::HLayout(); | 164 | expand_icon_->mouse_click.connect([&] (int x, int y, unsigned long b, unsigned long k) { showing_filters = !showing_filters; }); |
2807 | 124 | filter_layout_->SetHorizontalInternalMargin(8); | 165 | |
2808 | 125 | filter_layout_->SetHorizontalExternalMargin(6); | 166 | filter_layout_ = new nux::HLayout(); |
2809 | 126 | filter_space_ = new nux::SpaceLayout(100, 10000, 0, 1); | 167 | filter_layout_->SetHorizontalInternalMargin(8); |
2810 | 127 | filter_layout_->AddLayout(filter_space_, 1); | 168 | filter_layout_->SetHorizontalExternalMargin(6); |
2811 | 128 | filter_layout_->AddView(show_filters_, 0, nux::MINOR_POSITION_CENTER); | 169 | filter_space_ = new nux::SpaceLayout(100, 10000, 0, 1); |
2812 | 129 | 170 | filter_layout_->AddLayout(filter_space_, 1); | |
2813 | 130 | arrow_layout_ = new nux::VLayout(); | 171 | filter_layout_->AddView(show_filters_, 0, nux::MINOR_POSITION_CENTER); |
2814 | 131 | arrow_top_space_ = new nux::SpaceLayout(2, 2, 12, 12); | 172 | |
2815 | 132 | arrow_bottom_space_ = new nux::SpaceLayout(2, 2, 8, 8); | 173 | arrow_layout_ = new nux::VLayout(); |
2816 | 133 | arrow_layout_->AddView(arrow_top_space_, 0, nux::MINOR_POSITION_CENTER); | 174 | arrow_top_space_ = new nux::SpaceLayout(2, 2, 12, 12); |
2817 | 134 | arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER); | 175 | arrow_bottom_space_ = new nux::SpaceLayout(2, 2, 8, 8); |
2818 | 135 | arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER); | 176 | arrow_layout_->AddView(arrow_top_space_, 0, nux::MINOR_POSITION_CENTER); |
2819 | 136 | 177 | arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER); | |
2820 | 137 | filter_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER); | 178 | arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER); |
2821 | 138 | 179 | ||
2822 | 139 | layout_->AddView(filter_layout_, 1, nux::MINOR_POSITION_RIGHT, nux::MINOR_SIZE_FULL); | 180 | filter_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER); |
2823 | 140 | 181 | ||
2824 | 182 | layout_->AddView(filter_layout_, 1, nux::MINOR_POSITION_RIGHT, nux::MINOR_SIZE_FULL); | ||
2825 | 183 | } | ||
2826 | 141 | sig_manager_.Add(new Signal<void, GtkSettings*, GParamSpec*> | 184 | sig_manager_.Add(new Signal<void, GtkSettings*, GParamSpec*> |
2827 | 142 | (gtk_settings_get_default(), | 185 | (gtk_settings_get_default(), |
2828 | 143 | "notify::gtk-font-name", | 186 | "notify::gtk-font-name", |
2829 | @@ -151,9 +194,21 @@ | |||
2830 | 151 | showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged)); | 194 | showing_filters.changed.connect(sigc::mem_fun(this, &SearchBar::OnShowingFiltersChanged)); |
2831 | 152 | can_refine_search.changed.connect([&] (bool can_refine) | 195 | can_refine_search.changed.connect([&] (bool can_refine) |
2832 | 153 | { | 196 | { |
2836 | 154 | show_filters_->SetVisible(can_refine); | 197 | if (show_filter_hint_) |
2837 | 155 | expand_icon_->SetVisible(can_refine); | 198 | { |
2838 | 156 | }); | 199 | show_filters_->SetVisible(can_refine); |
2839 | 200 | expand_icon_->SetVisible(can_refine); | ||
2840 | 201 | } | ||
2841 | 202 | }); | ||
2842 | 203 | |||
2843 | 204 | disable_glow.changed.connect([&](bool disabled) | ||
2844 | 205 | { | ||
2845 | 206 | layout_->SetVerticalExternalMargin(0); | ||
2846 | 207 | layout_->SetHorizontalExternalMargin(0); | ||
2847 | 208 | UpdateBackground(true); | ||
2848 | 209 | QueueDraw(); | ||
2849 | 210 | }); | ||
2850 | 211 | |||
2851 | 157 | } | 212 | } |
2852 | 158 | 213 | ||
2853 | 159 | SearchBar::~SearchBar() | 214 | SearchBar::~SearchBar() |
2854 | @@ -259,18 +314,21 @@ | |||
2855 | 259 | 314 | ||
2856 | 260 | void SearchBar::OnShowingFiltersChanged(bool is_showing) | 315 | void SearchBar::OnShowingFiltersChanged(bool is_showing) |
2857 | 261 | { | 316 | { |
2863 | 262 | dash::Style& style = dash::Style::Instance(); | 317 | if (show_filter_hint_) |
2864 | 263 | if (is_showing) | 318 | { |
2865 | 264 | expand_icon_->SetTexture(style.GetGroupUnexpandIcon()); | 319 | dash::Style& style = dash::Style::Instance(); |
2866 | 265 | else | 320 | if (is_showing) |
2867 | 266 | expand_icon_->SetTexture(style.GetGroupExpandIcon()); | 321 | expand_icon_->SetTexture(style.GetGroupUnexpandIcon()); |
2868 | 322 | else | ||
2869 | 323 | expand_icon_->SetTexture(style.GetGroupExpandIcon()); | ||
2870 | 324 | } | ||
2871 | 267 | } | 325 | } |
2872 | 268 | 326 | ||
2873 | 269 | void SearchBar::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) | 327 | void SearchBar::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) |
2874 | 270 | { | 328 | { |
2875 | 271 | nux::Geometry geo = GetGeometry(); | 329 | nux::Geometry geo = GetGeometry(); |
2876 | 272 | 330 | ||
2878 | 273 | UpdateBackground(); | 331 | UpdateBackground(false); |
2879 | 274 | 332 | ||
2880 | 275 | GfxContext.PushClippingRectangle(geo); | 333 | GfxContext.PushClippingRectangle(geo); |
2881 | 276 | 334 | ||
2882 | @@ -344,21 +402,33 @@ | |||
2883 | 344 | spinner_->SetState(is_empty ? STATE_READY : STATE_CLEAR); | 402 | spinner_->SetState(is_empty ? STATE_READY : STATE_CLEAR); |
2884 | 345 | } | 403 | } |
2885 | 346 | 404 | ||
2887 | 347 | void SearchBar::UpdateBackground() | 405 | void SearchBar::UpdateBackground(bool force) |
2888 | 348 | { | 406 | { |
2891 | 349 | #define PADDING 12 | 407 | int PADDING = 12; |
2892 | 350 | #define RADIUS 5 | 408 | int RADIUS = 5; |
2893 | 351 | int x, y, width, height; | 409 | int x, y, width, height; |
2894 | 352 | nux::Geometry geo = GetGeometry(); | 410 | nux::Geometry geo = GetGeometry(); |
2895 | 353 | geo.width = layered_layout_->GetGeometry().width; | 411 | geo.width = layered_layout_->GetGeometry().width; |
2896 | 354 | 412 | ||
2898 | 355 | if (geo.width == last_width_ && geo.height == last_height_) | 413 | LOG_DEBUG(logger) << "height: " |
2899 | 414 | << geo.height << " - " | ||
2900 | 415 | << layered_layout_->GetGeometry().height << " - " | ||
2901 | 416 | << pango_entry_->GetGeometry().height; | ||
2902 | 417 | |||
2903 | 418 | if (geo.width == last_width_ | ||
2904 | 419 | && geo.height == last_height_ | ||
2905 | 420 | && force == false) | ||
2906 | 356 | return; | 421 | return; |
2907 | 357 | 422 | ||
2908 | 358 | last_width_ = geo.width; | 423 | last_width_ = geo.width; |
2909 | 359 | last_height_ = geo.height; | 424 | last_height_ = geo.height; |
2910 | 360 | 425 | ||
2911 | 426 | if (disable_glow) | ||
2912 | 427 | PADDING = 2; | ||
2913 | 428 | |||
2914 | 429 | |||
2915 | 361 | x = y = PADDING - 1; | 430 | x = y = PADDING - 1; |
2916 | 431 | |||
2917 | 362 | width = last_width_ - (2 * PADDING); | 432 | width = last_width_ - (2 * PADDING); |
2918 | 363 | height = last_height_ - (2 * PADDING) + 1; | 433 | height = last_height_ - (2 * PADDING) + 1; |
2919 | 364 | 434 | ||
2920 | @@ -473,5 +543,4 @@ | |||
2921 | 473 | g_variant_builder_add (builder, "{sv}", "search_string", g_variant_new_string (pango_entry_->GetText().c_str()) ); | 543 | g_variant_builder_add (builder, "{sv}", "search_string", g_variant_new_string (pango_entry_->GetText().c_str()) ); |
2922 | 474 | } | 544 | } |
2923 | 475 | 545 | ||
2924 | 476 | } // namespace dash | ||
2925 | 477 | } // namespace unity | 546 | } // namespace unity |
2926 | 478 | 547 | ||
2927 | === renamed file 'plugins/unityshell/src/DashSearchBar.h' => 'plugins/unityshell/src/SearchBar.h' | |||
2928 | --- plugins/unityshell/src/DashSearchBar.h 2012-01-17 15:39:16 +0000 | |||
2929 | +++ plugins/unityshell/src/SearchBar.h 2012-02-06 11:00:29 +0000 | |||
2930 | @@ -17,8 +17,8 @@ | |||
2931 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
2932 | 18 | */ | 18 | */ |
2933 | 19 | 19 | ||
2936 | 20 | #ifndef DASH_SEARCH_BAR_H | 20 | #ifndef SEARCH_BAR_H |
2937 | 21 | #define DASH_SEARCH_BAR_H | 21 | #define SEARCH_BAR_H |
2938 | 22 | 22 | ||
2939 | 23 | #include <gtk/gtk.h> | 23 | #include <gtk/gtk.h> |
2940 | 24 | 24 | ||
2941 | @@ -32,7 +32,7 @@ | |||
2942 | 32 | #include <Nux/TextEntry.h> | 32 | #include <Nux/TextEntry.h> |
2943 | 33 | #include <UnityCore/GLibSignal.h> | 33 | #include <UnityCore/GLibSignal.h> |
2944 | 34 | 34 | ||
2946 | 35 | #include "DashSearchBarSpinner.h" | 35 | #include "SearchBarSpinner.h" |
2947 | 36 | #include "IconTexture.h" | 36 | #include "IconTexture.h" |
2948 | 37 | #include "IMTextEntry.h" | 37 | #include "IMTextEntry.h" |
2949 | 38 | #include "Introspectable.h" | 38 | #include "Introspectable.h" |
2950 | @@ -40,8 +40,6 @@ | |||
2951 | 40 | 40 | ||
2952 | 41 | namespace unity | 41 | namespace unity |
2953 | 42 | { | 42 | { |
2954 | 43 | namespace dash | ||
2955 | 44 | { | ||
2956 | 45 | 43 | ||
2957 | 46 | using namespace unity::glib; | 44 | using namespace unity::glib; |
2958 | 47 | 45 | ||
2959 | @@ -49,7 +47,10 @@ | |||
2960 | 49 | { | 47 | { |
2961 | 50 | NUX_DECLARE_OBJECT_TYPE(SearchBar, nux::View); | 48 | NUX_DECLARE_OBJECT_TYPE(SearchBar, nux::View); |
2962 | 51 | public: | 49 | public: |
2963 | 50 | typedef nux::ObjectPtr<SearchBar> Ptr; | ||
2964 | 52 | SearchBar(NUX_FILE_LINE_PROTO); | 51 | SearchBar(NUX_FILE_LINE_PROTO); |
2965 | 52 | SearchBar(int search_width, bool show_filter_hint, NUX_FILE_LINE_PROTO); | ||
2966 | 53 | SearchBar(int search_width, NUX_FILE_LINE_PROTO); | ||
2967 | 53 | ~SearchBar(); | 54 | ~SearchBar(); |
2968 | 54 | 55 | ||
2969 | 55 | void SearchFinished(); | 56 | void SearchFinished(); |
2970 | @@ -59,6 +60,7 @@ | |||
2971 | 59 | nux::Property<std::string> search_hint; | 60 | nux::Property<std::string> search_hint; |
2972 | 60 | nux::Property<bool> showing_filters; | 61 | nux::Property<bool> showing_filters; |
2973 | 61 | nux::Property<bool> can_refine_search; | 62 | nux::Property<bool> can_refine_search; |
2974 | 63 | nux::Property<bool> disable_glow; | ||
2975 | 62 | nux::ROProperty<bool> im_active; | 64 | nux::ROProperty<bool> im_active; |
2976 | 63 | 65 | ||
2977 | 64 | sigc::signal<void> activated; | 66 | sigc::signal<void> activated; |
2978 | @@ -67,6 +69,8 @@ | |||
2979 | 67 | 69 | ||
2980 | 68 | private: | 70 | private: |
2981 | 69 | 71 | ||
2982 | 72 | void Init(); | ||
2983 | 73 | |||
2984 | 70 | void OnFontChanged(GtkSettings* settings, GParamSpec* pspec=NULL); | 74 | void OnFontChanged(GtkSettings* settings, GParamSpec* pspec=NULL); |
2985 | 71 | void OnSearchHintChanged(); | 75 | void OnSearchHintChanged(); |
2986 | 72 | 76 | ||
2987 | @@ -76,7 +80,7 @@ | |||
2988 | 76 | void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags); | 80 | void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags); |
2989 | 77 | void OnEndKeyFocus(); | 81 | void OnEndKeyFocus(); |
2990 | 78 | 82 | ||
2992 | 79 | void UpdateBackground(); | 83 | void UpdateBackground(bool force); |
2993 | 80 | void OnSearchChanged(nux::TextEntry* text_entry); | 84 | void OnSearchChanged(nux::TextEntry* text_entry); |
2994 | 81 | void OnClearClicked(int x, int y, unsigned long button_flags, unsigned long key_flags); | 85 | void OnClearClicked(int x, int y, unsigned long button_flags, unsigned long key_flags); |
2995 | 82 | void OnEntryActivated(); | 86 | void OnEntryActivated(); |
2996 | @@ -85,6 +89,7 @@ | |||
2997 | 85 | std::string get_search_string() const; | 89 | std::string get_search_string() const; |
2998 | 86 | bool set_search_string(std::string const& string); | 90 | bool set_search_string(std::string const& string); |
2999 | 87 | bool get_im_active() const; | 91 | bool get_im_active() const; |
3000 | 92 | bool show_filter_hint_; | ||
3001 | 88 | 93 | ||
3002 | 89 | static gboolean OnLiveSearchTimeout(SearchBar* self); | 94 | static gboolean OnLiveSearchTimeout(SearchBar* self); |
3003 | 90 | static gboolean OnSpinnerStartCb(SearchBar* self); | 95 | static gboolean OnSpinnerStartCb(SearchBar* self); |
3004 | @@ -110,7 +115,6 @@ | |||
3005 | 110 | IconTexture* expand_icon_; | 115 | IconTexture* expand_icon_; |
3006 | 111 | int search_bar_width_; | 116 | int search_bar_width_; |
3007 | 112 | 117 | ||
3008 | 113 | |||
3009 | 114 | int last_width_; | 118 | int last_width_; |
3010 | 115 | int last_height_; | 119 | int last_height_; |
3011 | 116 | 120 | ||
3012 | @@ -121,6 +125,5 @@ | |||
3013 | 121 | }; | 125 | }; |
3014 | 122 | 126 | ||
3015 | 123 | } | 127 | } |
3016 | 124 | } | ||
3017 | 125 | 128 | ||
3018 | 126 | #endif | 129 | #endif |
3019 | 127 | 130 | ||
3020 | === renamed file 'plugins/unityshell/src/DashSearchBarSpinner.cpp' => 'plugins/unityshell/src/SearchBarSpinner.cpp' | |||
3021 | --- plugins/unityshell/src/DashSearchBarSpinner.cpp 2011-12-16 22:10:23 +0000 | |||
3022 | +++ plugins/unityshell/src/SearchBarSpinner.cpp 2012-02-06 11:00:29 +0000 | |||
3023 | @@ -17,7 +17,7 @@ | |||
3024 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
3025 | 18 | */ | 18 | */ |
3026 | 19 | 19 | ||
3028 | 20 | #include "DashSearchBarSpinner.h" | 20 | #include "SearchBarSpinner.h" |
3029 | 21 | 21 | ||
3030 | 22 | #include <Nux/VLayout.h> | 22 | #include <Nux/VLayout.h> |
3031 | 23 | 23 | ||
3032 | @@ -25,8 +25,6 @@ | |||
3033 | 25 | 25 | ||
3034 | 26 | namespace unity | 26 | namespace unity |
3035 | 27 | { | 27 | { |
3036 | 28 | namespace dash | ||
3037 | 29 | { | ||
3038 | 30 | 28 | ||
3039 | 31 | NUX_IMPLEMENT_OBJECT_TYPE(SearchBarSpinner); | 29 | NUX_IMPLEMENT_OBJECT_TYPE(SearchBarSpinner); |
3040 | 32 | 30 | ||
3041 | @@ -236,4 +234,3 @@ | |||
3042 | 236 | } | 234 | } |
3043 | 237 | 235 | ||
3044 | 238 | } | 236 | } |
3045 | 239 | } | ||
3046 | 240 | 237 | ||
3047 | === renamed file 'plugins/unityshell/src/DashSearchBarSpinner.h' => 'plugins/unityshell/src/SearchBarSpinner.h' | |||
3048 | --- plugins/unityshell/src/DashSearchBarSpinner.h 2011-12-08 01:23:11 +0000 | |||
3049 | +++ plugins/unityshell/src/SearchBarSpinner.h 2012-02-06 11:00:29 +0000 | |||
3050 | @@ -17,8 +17,8 @@ | |||
3051 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
3052 | 18 | */ | 18 | */ |
3053 | 19 | 19 | ||
3056 | 20 | #ifndef DASH_SEARCH_BAR_SPINNER_H | 20 | #ifndef SEARCH_BAR_SPINNER_H |
3057 | 21 | #define DASH_SEARCH_BAR_SPINNER_H | 21 | #define SEARCH_BAR_SPINNER_H |
3058 | 22 | 22 | ||
3059 | 23 | #include <Nux/Nux.h> | 23 | #include <Nux/Nux.h> |
3060 | 24 | #include <Nux/View.h> | 24 | #include <Nux/View.h> |
3061 | @@ -29,8 +29,6 @@ | |||
3062 | 29 | 29 | ||
3063 | 30 | namespace unity | 30 | namespace unity |
3064 | 31 | { | 31 | { |
3065 | 32 | namespace dash | ||
3066 | 33 | { | ||
3067 | 34 | 32 | ||
3068 | 35 | enum SpinnerState | 33 | enum SpinnerState |
3069 | 36 | { | 34 | { |
3070 | @@ -80,6 +78,5 @@ | |||
3071 | 80 | }; | 78 | }; |
3072 | 81 | 79 | ||
3073 | 82 | } | 80 | } |
3074 | 83 | } | ||
3075 | 84 | 81 | ||
3076 | 85 | #endif | 82 | #endif |
3077 | 86 | 83 | ||
3078 | === modified file 'plugins/unityshell/src/UBusMessages.h' | |||
3079 | --- plugins/unityshell/src/UBusMessages.h 2012-01-31 10:59:11 +0000 | |||
3080 | +++ plugins/unityshell/src/UBusMessages.h 2012-02-06 11:00:29 +0000 | |||
3081 | @@ -78,6 +78,8 @@ | |||
3082 | 78 | // FIXME - fix the nux focus api so we don't need this | 78 | // FIXME - fix the nux focus api so we don't need this |
3083 | 79 | #define UBUS_RESULT_VIEW_KEYNAV_CHANGED "RESULT_VIEW_KEYNAV_CHANGED" | 79 | #define UBUS_RESULT_VIEW_KEYNAV_CHANGED "RESULT_VIEW_KEYNAV_CHANGED" |
3084 | 80 | 80 | ||
3085 | 81 | #define UBUS_HUD_CLOSE_REQUEST "HUD_CLOSE_REQUEST" | ||
3086 | 82 | |||
3087 | 81 | // Signals sent when the switcher is shown, hidden or changes selection | 83 | // Signals sent when the switcher is shown, hidden or changes selection |
3088 | 82 | #define UBUS_SWITCHER_SHOWN "SWITCHER_SHOWN" | 84 | #define UBUS_SWITCHER_SHOWN "SWITCHER_SHOWN" |
3089 | 83 | #define UBUS_SWITCHER_SELECTION_CHANGED "SWITCHER_SELECTION_CHANGED" | 85 | #define UBUS_SWITCHER_SELECTION_CHANGED "SWITCHER_SELECTION_CHANGED" |
3090 | 84 | 86 | ||
3091 | === modified file 'plugins/unityshell/src/unity-search-bar-accessible.cpp' | |||
3092 | --- plugins/unityshell/src/unity-search-bar-accessible.cpp 2011-09-15 13:58:42 +0000 | |||
3093 | +++ plugins/unityshell/src/unity-search-bar-accessible.cpp 2012-02-06 11:00:29 +0000 | |||
3094 | @@ -20,7 +20,7 @@ | |||
3095 | 20 | * SECTION:unity-search_bar-accessible | 20 | * SECTION:unity-search_bar-accessible |
3096 | 21 | * @Title: UnitySearchBarAccessible | 21 | * @Title: UnitySearchBarAccessible |
3097 | 22 | * @short_description: Implementation of the ATK interfaces for #SearchBar | 22 | * @short_description: Implementation of the ATK interfaces for #SearchBar |
3099 | 23 | * @see_also: SearchBar at DashSearchBar.h | 23 | * @see_also: SearchBar at SearchBar.h |
3100 | 24 | * | 24 | * |
3101 | 25 | * #UnitySearchBarAccessible implements the required ATK interfaces for | 25 | * #UnitySearchBarAccessible implements the required ATK interfaces for |
3102 | 26 | * #SearchBar, ie: exposing the different SearchBarIcon on the model as | 26 | * #SearchBar, ie: exposing the different SearchBarIcon on the model as |
3103 | @@ -33,9 +33,9 @@ | |||
3104 | 33 | #include "unity-search-bar-accessible.h" | 33 | #include "unity-search-bar-accessible.h" |
3105 | 34 | 34 | ||
3106 | 35 | #include "unitya11y.h" | 35 | #include "unitya11y.h" |
3108 | 36 | #include "DashSearchBar.h" | 36 | #include "SearchBar.h" |
3109 | 37 | 37 | ||
3111 | 38 | using namespace unity::dash; | 38 | using namespace unity; |
3112 | 39 | 39 | ||
3113 | 40 | /* GObject */ | 40 | /* GObject */ |
3114 | 41 | static void unity_search_bar_accessible_class_init(UnitySearchBarAccessibleClass* klass); | 41 | static void unity_search_bar_accessible_class_init(UnitySearchBarAccessibleClass* klass); |
3115 | 42 | 42 | ||
3116 | === modified file 'plugins/unityshell/src/unitya11y.cpp' | |||
3117 | --- plugins/unityshell/src/unitya11y.cpp 2011-11-07 22:28:01 +0000 | |||
3118 | +++ plugins/unityshell/src/unitya11y.cpp 2012-02-06 11:00:29 +0000 | |||
3119 | @@ -299,7 +299,7 @@ | |||
3120 | 299 | if (object->Type().IsDerivedFromType(unity::dash::ResultViewGrid::StaticObjectType)) | 299 | if (object->Type().IsDerivedFromType(unity::dash::ResultViewGrid::StaticObjectType)) |
3121 | 300 | return unity_rvgrid_accessible_new(object); | 300 | return unity_rvgrid_accessible_new(object); |
3122 | 301 | 301 | ||
3124 | 302 | if (object->Type().IsDerivedFromType(unity::dash::SearchBar::StaticObjectType)) | 302 | if (object->Type().IsDerivedFromType(unity::SearchBar::StaticObjectType)) |
3125 | 303 | return unity_search_bar_accessible_new(object); | 303 | return unity_search_bar_accessible_new(object); |
3126 | 304 | 304 | ||
3127 | 305 | if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType)) | 305 | if (object->Type().IsDerivedFromType(unity::switcher::SwitcherView::StaticObjectType)) |
3128 | 306 | 306 | ||
3129 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
3130 | --- plugins/unityshell/src/unityshell.cpp 2012-02-04 01:55:49 +0000 | |||
3131 | +++ plugins/unityshell/src/unityshell.cpp 2012-02-06 11:00:29 +0000 | |||
3132 | @@ -52,7 +52,6 @@ | |||
3133 | 52 | 52 | ||
3134 | 53 | #include "unitya11y.h" | 53 | #include "unitya11y.h" |
3135 | 54 | 54 | ||
3136 | 55 | #include "ubus-server.h" | ||
3137 | 56 | #include "UBusMessages.h" | 55 | #include "UBusMessages.h" |
3138 | 57 | #include "UScreen.h" | 56 | #include "UScreen.h" |
3139 | 58 | 57 | ||
3140 | @@ -119,6 +118,7 @@ | |||
3141 | 119 | , dash_is_open_ (false) | 118 | , dash_is_open_ (false) |
3142 | 120 | , grab_index_ (0) | 119 | , grab_index_ (0) |
3143 | 121 | , painting_tray_ (false) | 120 | , painting_tray_ (false) |
3144 | 121 | , last_hud_show_time_(0) | ||
3145 | 122 | { | 122 | { |
3146 | 123 | Timer timer; | 123 | Timer timer; |
3147 | 124 | gfloat version; | 124 | gfloat version; |
3148 | @@ -258,6 +258,8 @@ | |||
3149 | 258 | } | 258 | } |
3150 | 259 | #endif | 259 | #endif |
3151 | 260 | 260 | ||
3152 | 261 | optionSetShowHudInitiate(boost::bind(&UnityScreen::ShowHudInitiate, this, _1, _2, _3)); | ||
3153 | 262 | optionSetShowHudTerminate(boost::bind(&UnityScreen::ShowHudTerminate, this, _1, _2, _3)); | ||
3154 | 261 | optionSetBackgroundColorNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 263 | optionSetBackgroundColorNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
3155 | 262 | optionSetLauncherHideModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 264 | optionSetLauncherHideModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
3156 | 263 | optionSetBacklightModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); | 265 | optionSetBacklightModeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2)); |
3157 | @@ -371,7 +373,7 @@ | |||
3158 | 371 | sout << "<Alt>" << XKeysymToString(above_tab_keysym); | 373 | sout << "<Alt>" << XKeysymToString(above_tab_keysym); |
3159 | 372 | 374 | ||
3160 | 373 | screen->removeAction(&optionGetAltTabNextWindow()); | 375 | screen->removeAction(&optionGetAltTabNextWindow()); |
3162 | 374 | 376 | ||
3163 | 375 | CompAction action = CompAction(); | 377 | CompAction action = CompAction(); |
3164 | 376 | action.keyFromString(sout.str()); | 378 | action.keyFromString(sout.str()); |
3165 | 377 | action.setState (CompAction::StateInitKey | CompAction::StateAutoGrab); | 379 | action.setState (CompAction::StateInitKey | CompAction::StateAutoGrab); |
3166 | @@ -386,7 +388,7 @@ | |||
3167 | 386 | sout << "<Alt><Shift>" << XKeysymToString(above_tab_keysym); | 388 | sout << "<Alt><Shift>" << XKeysymToString(above_tab_keysym); |
3168 | 387 | 389 | ||
3169 | 388 | screen->removeAction(&optionGetAltTabPrevWindow()); | 390 | screen->removeAction(&optionGetAltTabPrevWindow()); |
3171 | 389 | 391 | ||
3172 | 390 | CompAction action = CompAction(); | 392 | CompAction action = CompAction(); |
3173 | 391 | action.keyFromString(sout.str()); | 393 | action.keyFromString(sout.str()); |
3174 | 392 | action.setState (CompAction::StateInitKey | CompAction::StateAutoGrab); | 394 | action.setState (CompAction::StateInitKey | CompAction::StateAutoGrab); |
3175 | @@ -820,8 +822,8 @@ | |||
3176 | 820 | bool UnityScreen::forcePaintOnTop () | 822 | bool UnityScreen::forcePaintOnTop () |
3177 | 821 | { | 823 | { |
3178 | 822 | return !allowWindowPaint || | 824 | return !allowWindowPaint || |
3181 | 823 | ((switcher_controller_->Visible() || | 825 | ((switcher_controller_->Visible() || |
3182 | 824 | dash_is_open_) && !fullscreen_windows_.empty () && (!(screen->grabbed () && !screen->otherGrabExist (NULL)))); | 826 | dash_is_open_) && !fullscreen_windows_.empty () && (!(screen->grabbed () && !screen->otherGrabExist (NULL)))); |
3183 | 825 | } | 827 | } |
3184 | 826 | 828 | ||
3185 | 827 | void UnityWindow::paintThumbnail (nux::Geometry const& bounding, float alpha) | 829 | void UnityWindow::paintThumbnail (nux::Geometry const& bounding, float alpha) |
3186 | @@ -967,7 +969,7 @@ | |||
3187 | 967 | { | 969 | { |
3188 | 968 | if (mShowdesktopHandler) | 970 | if (mShowdesktopHandler) |
3189 | 969 | if (mShowdesktopHandler->animate (ms)) | 971 | if (mShowdesktopHandler->animate (ms)) |
3191 | 970 | { | 972 | { |
3192 | 971 | delete mShowdesktopHandler; | 973 | delete mShowdesktopHandler; |
3193 | 972 | mShowdesktopHandler = NULL; | 974 | mShowdesktopHandler = NULL; |
3194 | 973 | return true; | 975 | return true; |
3195 | @@ -996,7 +998,7 @@ | |||
3196 | 996 | return false; | 998 | return false; |
3197 | 997 | 999 | ||
3198 | 998 | if (w->state () & (CompWindowStateSkipPagerMask | | 1000 | if (w->state () & (CompWindowStateSkipPagerMask | |
3200 | 999 | CompWindowStateSkipTaskbarMask)) | 1001 | CompWindowStateSkipTaskbarMask)) |
3201 | 1000 | return false; | 1002 | return false; |
3202 | 1001 | 1003 | ||
3203 | 1002 | if ((w->state () & CompWindowStateHiddenMask)) | 1004 | if ((w->state () & CompWindowStateHiddenMask)) |
3204 | @@ -1669,7 +1671,7 @@ | |||
3205 | 1669 | altTabInitiateCommon(action, state, options); | 1671 | altTabInitiateCommon(action, state, options); |
3206 | 1670 | switcher_controller_->Select(1); // always select the current application | 1672 | switcher_controller_->Select(1); // always select the current application |
3207 | 1671 | } | 1673 | } |
3209 | 1672 | 1674 | ||
3210 | 1673 | switcher_controller_->NextDetail(); | 1675 | switcher_controller_->NextDetail(); |
3211 | 1674 | 1676 | ||
3212 | 1675 | action->setState(action->state() | CompAction::StateTermKey); | 1677 | action->setState(action->state() | CompAction::StateTermKey); |
3213 | @@ -1680,7 +1682,7 @@ | |||
3214 | 1680 | { | 1682 | { |
3215 | 1681 | if (switcher_controller_->Visible()) | 1683 | if (switcher_controller_->Visible()) |
3216 | 1682 | switcher_controller_->PrevDetail(); | 1684 | switcher_controller_->PrevDetail(); |
3218 | 1683 | 1685 | ||
3219 | 1684 | return false; | 1686 | return false; |
3220 | 1685 | } | 1687 | } |
3221 | 1686 | 1688 | ||
3222 | @@ -1735,6 +1737,44 @@ | |||
3223 | 1735 | PluginAdapter::Default ()->restoreInputFocus (); | 1737 | PluginAdapter::Default ()->restoreInputFocus (); |
3224 | 1736 | } | 1738 | } |
3225 | 1737 | 1739 | ||
3226 | 1740 | bool UnityScreen::ShowHudInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) | ||
3227 | 1741 | { | ||
3228 | 1742 | // to receive the Terminate event | ||
3229 | 1743 | if (state & CompAction::StateInitKey) | ||
3230 | 1744 | action->setState(action->state() | CompAction::StateTermKey); | ||
3231 | 1745 | |||
3232 | 1746 | last_hud_show_time_ = g_get_monotonic_time(); | ||
3233 | 1747 | |||
3234 | 1748 | return false; | ||
3235 | 1749 | } | ||
3236 | 1750 | |||
3237 | 1751 | bool UnityScreen::ShowHudTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options) | ||
3238 | 1752 | { | ||
3239 | 1753 | if (optionGetShowHud().key().toString() == action->key().toString()) | ||
3240 | 1754 | { | ||
3241 | 1755 | if (switcher_controller_->Visible()) | ||
3242 | 1756 | return false; // early exit if the switcher is open | ||
3243 | 1757 | |||
3244 | 1758 | gint64 current_time = g_get_monotonic_time(); | ||
3245 | 1759 | if (current_time - last_hud_show_time_ < 150 * 1000) | ||
3246 | 1760 | { | ||
3247 | 1761 | if (hud_controller_->IsVisible()) | ||
3248 | 1762 | { | ||
3249 | 1763 | ubus_manager_.SendMessage(UBUS_HUD_CLOSE_REQUEST); | ||
3250 | 1764 | } | ||
3251 | 1765 | else | ||
3252 | 1766 | { | ||
3253 | 1767 | hud_controller_->ShowHud(); | ||
3254 | 1768 | } | ||
3255 | 1769 | last_hud_show_time_ = 0; | ||
3256 | 1770 | } | ||
3257 | 1771 | } | ||
3258 | 1772 | |||
3259 | 1773 | action->setState(action->state() & ~CompAction::StateTermKey); | ||
3260 | 1774 | |||
3261 | 1775 | return false; | ||
3262 | 1776 | } | ||
3263 | 1777 | |||
3264 | 1738 | gboolean UnityScreen::initPluginActions(gpointer data) | 1778 | gboolean UnityScreen::initPluginActions(gpointer data) |
3265 | 1739 | { | 1779 | { |
3266 | 1740 | CompPlugin* p = CompPlugin::find("expo"); | 1780 | CompPlugin* p = CompPlugin::find("expo"); |
3267 | @@ -1821,7 +1861,7 @@ | |||
3268 | 1821 | bool result = screen->initPluginForScreen(p); | 1861 | bool result = screen->initPluginForScreen(p); |
3269 | 1822 | if (p->vTable->name() == "unityshell") | 1862 | if (p->vTable->name() == "unityshell") |
3270 | 1823 | initAltTabNextWindow(); | 1863 | initAltTabNextWindow(); |
3272 | 1824 | 1864 | ||
3273 | 1825 | return result; | 1865 | return result; |
3274 | 1826 | } | 1866 | } |
3275 | 1827 | 1867 | ||
3276 | @@ -1834,8 +1874,8 @@ | |||
3277 | 1834 | return "Unity"; | 1874 | return "Unity"; |
3278 | 1835 | } | 1875 | } |
3279 | 1836 | 1876 | ||
3282 | 1837 | bool isNuxWindow (CompWindow* value) | 1877 | bool isNuxWindow (CompWindow* value) |
3283 | 1838 | { | 1878 | { |
3284 | 1839 | std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList(); | 1879 | std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList(); |
3285 | 1840 | auto id = value->id(); | 1880 | auto id = value->id(); |
3286 | 1841 | 1881 | ||
3287 | @@ -1862,7 +1902,7 @@ | |||
3288 | 1862 | void UnityScreen::RaiseInputWindows() | 1902 | void UnityScreen::RaiseInputWindows() |
3289 | 1863 | { | 1903 | { |
3290 | 1864 | std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList(); | 1904 | std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList(); |
3292 | 1865 | 1905 | ||
3293 | 1866 | for (auto window : xwns) | 1906 | for (auto window : xwns) |
3294 | 1867 | { | 1907 | { |
3295 | 1868 | CompWindow* cwin = screen->findWindow(window); | 1908 | CompWindow* cwin = screen->findWindow(window); |
3296 | @@ -1995,7 +2035,7 @@ | |||
3297 | 1995 | if (!window->onCurrentDesktop ()) | 2035 | if (!window->onCurrentDesktop ()) |
3298 | 1996 | return false; | 2036 | return false; |
3299 | 1997 | 2037 | ||
3301 | 1998 | /* Only withdrawn windows | 2038 | /* Only withdrawn windows |
3302 | 1999 | * which are marked hidden | 2039 | * which are marked hidden |
3303 | 2000 | * are excluded */ | 2040 | * are excluded */ |
3304 | 2001 | if (!window->shaded () && | 2041 | if (!window->shaded () && |
3305 | @@ -2003,8 +2043,8 @@ | |||
3306 | 2003 | (window->state () & CompWindowStateHiddenMask)) | 2043 | (window->state () & CompWindowStateHiddenMask)) |
3307 | 2004 | return false; | 2044 | return false; |
3308 | 2005 | 2045 | ||
3311 | 2006 | if (window->geometry ().x () + window->geometry ().width () <= 0 || | 2046 | if (window->geometry ().x () + window->geometry ().width () <= 0 || |
3312 | 2007 | window->geometry ().y () + window->geometry ().height () <= 0 || | 2047 | window->geometry ().y () + window->geometry ().height () <= 0 || |
3313 | 2008 | window->geometry ().x () >= (int) screen->width ()|| | 2048 | window->geometry ().x () >= (int) screen->width ()|| |
3314 | 2009 | window->geometry ().y () >= (int) screen->height ()) | 2049 | window->geometry ().y () >= (int) screen->height ()) |
3315 | 2010 | return false; | 2050 | return false; |
3316 | @@ -2110,7 +2150,7 @@ | |||
3317 | 2110 | !(lastState & CompWindowStateFullscreenMask)) | 2150 | !(lastState & CompWindowStateFullscreenMask)) |
3318 | 2111 | UnityScreen::get (screen)->fullscreen_windows_.push_back(window); | 2151 | UnityScreen::get (screen)->fullscreen_windows_.push_back(window); |
3319 | 2112 | else if (lastState & CompWindowStateFullscreenMask && | 2152 | else if (lastState & CompWindowStateFullscreenMask && |
3321 | 2113 | !(window->state () & CompWindowStateFullscreenMask)) | 2153 | !(window->state () & CompWindowStateFullscreenMask)) |
3322 | 2114 | UnityScreen::get (screen)->fullscreen_windows_.remove(window); | 2154 | UnityScreen::get (screen)->fullscreen_windows_.remove(window); |
3323 | 2115 | 2155 | ||
3324 | 2116 | PluginAdapter::Default()->NotifyStateChange(window, window->state(), lastState); | 2156 | PluginAdapter::Default()->NotifyStateChange(window, window->state(), lastState); |
3325 | @@ -2259,9 +2299,9 @@ | |||
3326 | 2259 | { | 2299 | { |
3327 | 2260 | case UnityshellOptions::BackgroundColor: | 2300 | case UnityshellOptions::BackgroundColor: |
3328 | 2261 | { | 2301 | { |
3332 | 2262 | nux::Color override_color (optionGetBackgroundColorRed() / 65535.0f, | 2302 | nux::Color override_color (optionGetBackgroundColorRed() / 65535.0f, |
3333 | 2263 | optionGetBackgroundColorGreen() / 65535.0f, | 2303 | optionGetBackgroundColorGreen() / 65535.0f, |
3334 | 2264 | optionGetBackgroundColorBlue() / 65535.0f, | 2304 | optionGetBackgroundColorBlue() / 65535.0f, |
3335 | 2265 | optionGetBackgroundColorAlpha() / 65535.0f); | 2305 | optionGetBackgroundColorAlpha() / 65535.0f); |
3336 | 2266 | 2306 | ||
3337 | 2267 | override_color.red = override_color.red / override_color.alpha; | 2307 | override_color.red = override_color.red / override_color.alpha; |
3338 | @@ -2309,6 +2349,7 @@ | |||
3339 | 2309 | launcher_options->icon_size = optionGetIconSize(); | 2349 | launcher_options->icon_size = optionGetIconSize(); |
3340 | 2310 | launcher_options->tile_size = optionGetIconSize() + 6; | 2350 | launcher_options->tile_size = optionGetIconSize() + 6; |
3341 | 2311 | 2351 | ||
3342 | 2352 | hud_controller_->launcher_width = launcher_controller_->launcher().GetAbsoluteWidth() - 1; | ||
3343 | 2312 | /* The launcher geometry includes 1px used to draw the right margin | 2353 | /* The launcher geometry includes 1px used to draw the right margin |
3344 | 2313 | * that must not be considered when drawing the dash */ | 2354 | * that must not be considered when drawing the dash */ |
3345 | 2314 | dash_controller_->launcher_width = launcher_controller_->launcher().GetAbsoluteWidth() - 1; | 2355 | dash_controller_->launcher_width = launcher_controller_->launcher().GetAbsoluteWidth() - 1; |
3346 | @@ -2497,6 +2538,11 @@ | |||
3347 | 2497 | /* Setup Places */ | 2538 | /* Setup Places */ |
3348 | 2498 | dash_controller_.reset(new dash::Controller()); | 2539 | dash_controller_.reset(new dash::Controller()); |
3349 | 2499 | dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized)); | 2540 | dash_controller_->on_realize.connect(sigc::mem_fun(this, &UnityScreen::OnDashRealized)); |
3350 | 2541 | |||
3351 | 2542 | /* Setup Hud */ | ||
3352 | 2543 | hud_controller_.reset(new hud::Controller()); | ||
3353 | 2544 | AddChild(hud_controller_.get()); | ||
3354 | 2545 | LOG_INFO(logger) << "initLauncher-hud " << timer.ElapsedSeconds() << "s"; | ||
3355 | 2500 | 2546 | ||
3356 | 2501 | // Setup Shortcut Hint | 2547 | // Setup Shortcut Hint |
3357 | 2502 | InitHints(); | 2548 | InitHints(); |
3358 | @@ -2646,7 +2692,7 @@ | |||
3359 | 2646 | 2692 | ||
3360 | 2647 | if (mShowdesktopHandler) | 2693 | if (mShowdesktopHandler) |
3361 | 2648 | delete mShowdesktopHandler; | 2694 | delete mShowdesktopHandler; |
3363 | 2649 | 2695 | ||
3364 | 2650 | if (focusdesktop_handle_) | 2696 | if (focusdesktop_handle_) |
3365 | 2651 | g_source_remove(focusdesktop_handle_); | 2697 | g_source_remove(focusdesktop_handle_); |
3366 | 2652 | 2698 | ||
3367 | 2653 | 2699 | ||
3368 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
3369 | --- plugins/unityshell/src/unityshell.h 2012-01-29 06:08:20 +0000 | |||
3370 | +++ plugins/unityshell/src/unityshell.h 2012-02-06 11:00:29 +0000 | |||
3371 | @@ -58,6 +58,8 @@ | |||
3372 | 58 | #include <compiztoolbox/compiztoolbox.h> | 58 | #include <compiztoolbox/compiztoolbox.h> |
3373 | 59 | #include <dlfcn.h> | 59 | #include <dlfcn.h> |
3374 | 60 | 60 | ||
3375 | 61 | #include "HudController.h" | ||
3376 | 62 | |||
3377 | 61 | namespace unity | 63 | namespace unity |
3378 | 62 | { | 64 | { |
3379 | 63 | 65 | ||
3380 | @@ -202,6 +204,9 @@ | |||
3381 | 202 | bool altTabNextWindowInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); | 204 | bool altTabNextWindowInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); |
3382 | 203 | bool altTabPrevWindowInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); | 205 | bool altTabPrevWindowInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); |
3383 | 204 | 206 | ||
3384 | 207 | /* handle hud key activations */ | ||
3385 | 208 | bool ShowHudInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); | ||
3386 | 209 | bool ShowHudTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options); | ||
3387 | 205 | bool launcherSwitcherForwardInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); | 210 | bool launcherSwitcherForwardInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); |
3388 | 206 | bool launcherSwitcherPrevInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); | 211 | bool launcherSwitcherPrevInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options); |
3389 | 207 | bool launcherSwitcherTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options); | 212 | bool launcherSwitcherTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options); |
3390 | @@ -268,6 +273,7 @@ | |||
3391 | 268 | dash::Controller::Ptr dash_controller_; | 273 | dash::Controller::Ptr dash_controller_; |
3392 | 269 | panel::Controller::Ptr panel_controller_; | 274 | panel::Controller::Ptr panel_controller_; |
3393 | 270 | switcher::Controller::Ptr switcher_controller_; | 275 | switcher::Controller::Ptr switcher_controller_; |
3394 | 276 | hud::Controller::Ptr hud_controller_; | ||
3395 | 271 | 277 | ||
3396 | 272 | shortcut::Controller::Ptr shortcut_controller_; | 278 | shortcut::Controller::Ptr shortcut_controller_; |
3397 | 273 | std::list<shortcut::AbstractHint*> hints_; | 279 | std::list<shortcut::AbstractHint*> hints_; |
3398 | @@ -322,6 +328,7 @@ | |||
3399 | 322 | CompWindowList fullscreen_windows_; | 328 | CompWindowList fullscreen_windows_; |
3400 | 323 | bool painting_tray_; | 329 | bool painting_tray_; |
3401 | 324 | unsigned int tray_paint_mask_; | 330 | unsigned int tray_paint_mask_; |
3402 | 331 | gint64 last_hud_show_time_; | ||
3403 | 325 | 332 | ||
3404 | 326 | #ifndef USE_GLES | 333 | #ifndef USE_GLES |
3405 | 327 | ScreenEffectFramebufferObject::GLXGetProcAddressProc glXGetProcAddressP; | 334 | ScreenEffectFramebufferObject::GLXGetProcAddressProc glXGetProcAddressP; |
3406 | @@ -396,7 +403,7 @@ | |||
3407 | 396 | UnityMinimizedHandler *mMinimizeHandler; | 403 | UnityMinimizedHandler *mMinimizeHandler; |
3408 | 397 | 404 | ||
3409 | 398 | UnityShowdesktopHandler *mShowdesktopHandler; | 405 | UnityShowdesktopHandler *mShowdesktopHandler; |
3411 | 399 | 406 | ||
3412 | 400 | private: | 407 | private: |
3413 | 401 | 408 | ||
3414 | 402 | guint focusdesktop_handle_; | 409 | guint focusdesktop_handle_; |
3415 | 403 | 410 | ||
3416 | === modified file 'plugins/unityshell/unityshell.xml.in' | |||
3417 | --- plugins/unityshell/unityshell.xml.in 2012-02-01 00:06:29 +0000 | |||
3418 | +++ plugins/unityshell/unityshell.xml.in 2012-02-06 11:00:29 +0000 | |||
3419 | @@ -40,9 +40,14 @@ | |||
3420 | 40 | </requirement> | 40 | </requirement> |
3421 | 41 | </deps> | 41 | </deps> |
3422 | 42 | <options> | 42 | <options> |
3424 | 43 | <group> | 43 | <group> |
3425 | 44 | <_short>Behaviour</_short> | 44 | <_short>Behaviour</_short> |
3427 | 45 | <option name="launcher_hide_mode" type="int"> | 45 | <option name="show_hud" type="key"> |
3428 | 46 | <_short>Key to show the HUD</_short> | ||
3429 | 47 | <_long>Make the HUD appear with this key</_long> | ||
3430 | 48 | <default><Alt></default> | ||
3431 | 49 | </option> | ||
3432 | 50 | <option name="launcher_hide_mode" type="int"> | ||
3433 | 46 | <_short>Hide Launcher</_short> | 51 | <_short>Hide Launcher</_short> |
3434 | 47 | <_long>Make the launcher hide automatically after some time of inactivity: always or just when the focussed window is not over the launcher</_long> | 52 | <_long>Make the launcher hide automatically after some time of inactivity: always or just when the focussed window is not over the launcher</_long> |
3435 | 48 | <min>0</min> | 53 | <min>0</min> |
3436 | @@ -64,16 +69,16 @@ | |||
3437 | 64 | <value>3</value> | 69 | <value>3</value> |
3438 | 65 | <_name>Dodge Active Window</_name> | 70 | <_name>Dodge Active Window</_name> |
3439 | 66 | </desc> | 71 | </desc> |
3442 | 67 | </option> | 72 | </option> |
3443 | 68 | <option name="show_launcher" type="key"> | 73 | <option name="show_launcher" type="key"> |
3444 | 69 | <_short>Key to show the launcher</_short> | 74 | <_short>Key to show the launcher</_short> |
3445 | 70 | <_long>Make the launcher appear with that key</_long> | 75 | <_long>Make the launcher appear with that key</_long> |
3446 | 71 | <default><Super></default> | 76 | <default><Super></default> |
3447 | 72 | </option> | 77 | </option> |
3448 | 73 | <option name="keyboard_focus" type="key"> | 78 | <option name="keyboard_focus" type="key"> |
3452 | 74 | <_short>Key to put keyboard-focus on launcher</_short> | 79 | <_short>Key to put keyboard-focus on launcher</_short> |
3453 | 75 | <_long>Set the keyboard-focus on the launcher so it can be navigated with the cursor-keys</_long> | 80 | <_long>Set the keyboard-focus on the launcher so it can be navigated with the cursor-keys</_long> |
3454 | 76 | <default><Alt>F1</default> | 81 | <default><Alt>F1</default> |
3455 | 77 | </option> | 82 | </option> |
3456 | 78 | <option name="execute_command" type="key"> | 83 | <option name="execute_command" type="key"> |
3457 | 79 | <_short>Key to execute a command</_short> | 84 | <_short>Key to execute a command</_short> |
3458 | @@ -118,37 +123,37 @@ | |||
3459 | 118 | <_long>fixme</_long> | 123 | <_long>fixme</_long> |
3460 | 119 | <default><Alt><Shift>Tab</default> | 124 | <default><Alt><Shift>Tab</default> |
3461 | 120 | </option> | 125 | </option> |
3476 | 121 | <option name="alt_tab_right" type="key"> | 126 | <option name="alt_tab_right" type="key"> |
3477 | 122 | <_short>Go right in the switcher</_short> | 127 | <_short>Go right in the switcher</_short> |
3478 | 123 | <_long>fixme</_long> | 128 | <_long>fixme</_long> |
3479 | 124 | <default><Alt>Right</default> | 129 | <default><Alt>Right</default> |
3480 | 125 | <passive_grab>false</passive_grab> | 130 | <passive_grab>false</passive_grab> |
3481 | 126 | <internal/> | 131 | <internal/> |
3482 | 127 | </option> | 132 | </option> |
3483 | 128 | <option name="alt_tab_left" type="key"> | 133 | <option name="alt_tab_left" type="key"> |
3484 | 129 | <_short>Go left in the switcher</_short> | 134 | <_short>Go left in the switcher</_short> |
3485 | 130 | <_long>fixme</_long> | 135 | <_long>fixme</_long> |
3486 | 131 | <default><Alt>Left</default> | 136 | <default><Alt>Left</default> |
3487 | 132 | <passive_grab>false</passive_grab> | 137 | <passive_grab>false</passive_grab> |
3488 | 133 | <internal/> | 138 | <internal/> |
3489 | 134 | </option> | 139 | </option> |
3490 | 135 | <option name="alt_tab_detail_start" type="key"> | 140 | <option name="alt_tab_detail_start" type="key"> |
3496 | 136 | <_short>Key to expose the windows in the switcher</_short> | 141 | <_short>Key to expose the windows in the switcher</_short> |
3497 | 137 | <_long>fixme</_long> | 142 | <_long>fixme</_long> |
3498 | 138 | <default><Alt>Down</default> | 143 | <default><Alt>Down</default> |
3499 | 139 | <passive_grab>false</passive_grab> | 144 | <passive_grab>false</passive_grab> |
3500 | 140 | <internal/> | 145 | <internal/> |
3501 | 141 | </option> | 146 | </option> |
3509 | 142 | <option name="alt_tab_detail_stop" type="key"> | 147 | <option name="alt_tab_detail_stop" type="key"> |
3510 | 143 | <_short>Key to collapse windows in the switcher</_short> | 148 | <_short>Key to collapse windows in the switcher</_short> |
3511 | 144 | <_long>fixme</_long> | 149 | <_long>fixme</_long> |
3512 | 145 | <default><Alt>Up</default> | 150 | <default><Alt>Up</default> |
3513 | 146 | <passive_grab>false</passive_grab> | 151 | <passive_grab>false</passive_grab> |
3514 | 147 | <internal/> | 152 | <internal/> |
3515 | 148 | </option> | 153 | </option> |
3516 | 149 | <option name="alt_tab_next_window" type="key"> | 154 | <option name="alt_tab_next_window" type="key"> |
3519 | 150 | <_short>Key to flip through windows in the switcher</_short> | 155 | <_short>Key to flip through windows in the switcher</_short> |
3520 | 151 | <_long>fixme</_long> | 156 | <_long>fixme</_long> |
3521 | 152 | <passive_grab>false</passive_grab> | 157 | <passive_grab>false</passive_grab> |
3522 | 153 | </option> | 158 | </option> |
3523 | 154 | <option name="alt_tab_prev_window" type="key"> | 159 | <option name="alt_tab_prev_window" type="key"> |
3524 | @@ -156,11 +161,11 @@ | |||
3525 | 156 | <_long>fixme</_long> | 161 | <_long>fixme</_long> |
3526 | 157 | <passive_grab>false</passive_grab> | 162 | <passive_grab>false</passive_grab> |
3527 | 158 | </option> | 163 | </option> |
3533 | 159 | <option name="show_minimized_windows" type="bool"> | 164 | <option name="show_minimized_windows" type="bool"> |
3534 | 160 | <_short>Show minimized windows in switcher</_short> | 165 | <_short>Show minimized windows in switcher</_short> |
3535 | 161 | <_long>Hack to enable minimized windows in switcher. Disable and report bugs if problems are caused</_long> | 166 | <_long>Hack to enable minimized windows in switcher. Disable and report bugs if problems are caused</_long> |
3536 | 162 | <default>true</default> | 167 | <default>true</default> |
3537 | 163 | </option> | 168 | </option> |
3538 | 164 | </group> | 169 | </group> |
3539 | 165 | <group> | 170 | <group> |
3540 | 166 | <_short>Experimental</_short> | 171 | <_short>Experimental</_short> |
3541 | @@ -359,7 +364,7 @@ | |||
3542 | 359 | <max>100</max> | 364 | <max>100</max> |
3543 | 360 | <default>75</default> | 365 | <default>75</default> |
3544 | 361 | </option> | 366 | </option> |
3546 | 362 | 367 | ||
3547 | 363 | <option name="devices_option" type="int"> | 368 | <option name="devices_option" type="int"> |
3548 | 364 | <_short>Show Devices</_short> | 369 | <_short>Show Devices</_short> |
3549 | 365 | <_long>Show devices in the launcher</_long> | 370 | <_long>Show devices in the launcher</_long> |
3550 | 366 | 371 | ||
3551 | === modified file 'po/POTFILES.in' | |||
3552 | --- po/POTFILES.in 2012-01-24 09:02:23 +0000 | |||
3553 | +++ po/POTFILES.in 2012-02-06 11:00:29 +0000 | |||
3554 | @@ -6,7 +6,7 @@ | |||
3555 | 6 | plugins/unityshell/src/SpacerLauncherIcon.cpp | 6 | plugins/unityshell/src/SpacerLauncherIcon.cpp |
3556 | 7 | plugins/unityshell/src/TrashLauncherIcon.cpp | 7 | plugins/unityshell/src/TrashLauncherIcon.cpp |
3557 | 8 | plugins/unityshell/src/BFBLauncherIcon.cpp | 8 | plugins/unityshell/src/BFBLauncherIcon.cpp |
3559 | 9 | plugins/unityshell/src/DashSearchBar.cpp | 9 | plugins/unityshell/src/SearchBar.cpp |
3560 | 10 | plugins/unityshell/src/DashView.cpp | 10 | plugins/unityshell/src/DashView.cpp |
3561 | 11 | plugins/unityshell/src/DesktopLauncherIcon.cpp | 11 | plugins/unityshell/src/DesktopLauncherIcon.cpp |
3562 | 12 | plugins/unityshell/src/FilterExpanderLabel.cpp | 12 | plugins/unityshell/src/FilterExpanderLabel.cpp |
3563 | 13 | 13 | ||
3564 | === modified file 'standalone-clients/CMakeLists.txt' | |||
3565 | --- standalone-clients/CMakeLists.txt 2012-01-24 08:53:48 +0000 | |||
3566 | +++ standalone-clients/CMakeLists.txt 2012-02-06 11:00:29 +0000 | |||
3567 | @@ -47,10 +47,10 @@ | |||
3568 | 47 | ${UNITY_SRC}/BackgroundEffectHelper.h | 47 | ${UNITY_SRC}/BackgroundEffectHelper.h |
3569 | 48 | ${UNITY_SRC}/BGHash.cpp | 48 | ${UNITY_SRC}/BGHash.cpp |
3570 | 49 | ${UNITY_SRC}/BGHash.h | 49 | ${UNITY_SRC}/BGHash.h |
3575 | 50 | ${UNITY_SRC}/DashSearchBar.cpp | 50 | ${UNITY_SRC}/SearchBar.cpp |
3576 | 51 | ${UNITY_SRC}/DashSearchBar.h | 51 | ${UNITY_SRC}/SearchBar.h |
3577 | 52 | ${UNITY_SRC}/DashSearchBarSpinner.cpp | 52 | ${UNITY_SRC}/SearchBarSpinner.cpp |
3578 | 53 | ${UNITY_SRC}/DashSearchBarSpinner.h | 53 | ${UNITY_SRC}/SearchBarSpinner.h |
3579 | 54 | ${UNITY_SRC}/DashView.cpp | 54 | ${UNITY_SRC}/DashView.cpp |
3580 | 55 | ${UNITY_SRC}/DashView.h | 55 | ${UNITY_SRC}/DashView.h |
3581 | 56 | ${UNITY_SRC}/DashViewPrivate.cpp | 56 | ${UNITY_SRC}/DashViewPrivate.cpp |
3582 | @@ -84,6 +84,10 @@ | |||
3583 | 84 | ${UNITY_SRC}/PlacesSimpleTile.h | 84 | ${UNITY_SRC}/PlacesSimpleTile.h |
3584 | 85 | ${UNITY_SRC}/PlacesVScrollBar.cpp | 85 | ${UNITY_SRC}/PlacesVScrollBar.cpp |
3585 | 86 | ${UNITY_SRC}/PlacesVScrollBar.h | 86 | ${UNITY_SRC}/PlacesVScrollBar.h |
3586 | 87 | ${UNITY_SRC}/DashView.cpp | ||
3587 | 88 | ${UNITY_SRC}/DashView.h | ||
3588 | 89 | ${UNITY_SRC}/DashViewPrivate.cpp | ||
3589 | 90 | ${UNITY_SRC}/DashViewPrivate.h | ||
3590 | 87 | ${UNITY_SRC}/DashStyle.cpp | 91 | ${UNITY_SRC}/DashStyle.cpp |
3591 | 88 | ${UNITY_SRC}/IconLoader.cpp | 92 | ${UNITY_SRC}/IconLoader.cpp |
3592 | 89 | ${UNITY_SRC}/IconLoader.h | 93 | ${UNITY_SRC}/IconLoader.h |
3593 | @@ -456,6 +460,39 @@ | |||
3594 | 456 | ) | 460 | ) |
3595 | 457 | add_dependencies (bg-hash unity-core-${UNITY_API_VERSION}) | 461 | add_dependencies (bg-hash unity-core-${UNITY_API_VERSION}) |
3596 | 458 | 462 | ||
3597 | 463 | add_executable (hud | ||
3598 | 464 | StandaloneHud.cpp | ||
3599 | 465 | ${UNITY_SRC}/BackgroundEffectHelper.cpp | ||
3600 | 466 | ${UNITY_SRC}/BackgroundEffectHelper.h | ||
3601 | 467 | ${UNITY_SRC}/DashSettings.cpp | ||
3602 | 468 | ${UNITY_SRC}/DashSettings.h | ||
3603 | 469 | ${UNITY_SRC}/DashStyle.cpp | ||
3604 | 470 | ${UNITY_SRC}/HudButton.cpp | ||
3605 | 471 | ${UNITY_SRC}/HudIcon.cpp | ||
3606 | 472 | ${UNITY_SRC}/HudIcon.h | ||
3607 | 473 | ${UNITY_SRC}/HudIconTextureSource.cpp | ||
3608 | 474 | ${UNITY_SRC}/HudIconTextureSource.h | ||
3609 | 475 | ${UNITY_SRC}/HudView.cpp | ||
3610 | 476 | ${UNITY_SRC}/IMTextEntry.cpp | ||
3611 | 477 | ${UNITY_SRC}/Introspectable.cpp | ||
3612 | 478 | ${UNITY_SRC}/IconTexture.cpp | ||
3613 | 479 | ${UNITY_SRC}/IconLoader.cpp | ||
3614 | 480 | ${UNITY_SRC}/IconRenderer.cpp | ||
3615 | 481 | ${UNITY_SRC}/IconTextureSource.cpp | ||
3616 | 482 | ${UNITY_SRC}/JSONParser.cpp | ||
3617 | 483 | ${UNITY_SRC}/OverlayRenderer.cpp | ||
3618 | 484 | ${UNITY_SRC}/SearchBar.cpp | ||
3619 | 485 | ${UNITY_SRC}/SearchBarSpinner.cpp | ||
3620 | 486 | ${UNITY_SRC}/StaticCairoText.cpp | ||
3621 | 487 | ${UNITY_SRC}/TextureCache.cpp | ||
3622 | 488 | ${UNITY_SRC}/Timer.cpp | ||
3623 | 489 | ${UNITY_SRC}/UBusWrapper.cpp | ||
3624 | 490 | ${UNITY_SRC}/ubus-server.cpp | ||
3625 | 491 | ${UNITY_SRC}/UScreen.cpp | ||
3626 | 492 | ${UNITY_SRC}/UScreen.h | ||
3627 | 493 | ) | ||
3628 | 494 | add_dependencies (hud unity-core-${UNITY_API_VERSION}) | ||
3629 | 495 | |||
3630 | 459 | add_executable (test-shortcut | 496 | add_executable (test-shortcut |
3631 | 460 | TestShortcut.cpp | 497 | TestShortcut.cpp |
3632 | 461 | ${UNITY_SRC}/AbstractSeparator.cpp | 498 | ${UNITY_SRC}/AbstractSeparator.cpp |
3633 | 462 | 499 | ||
3634 | === added file 'standalone-clients/StandaloneHud.cpp' | |||
3635 | --- standalone-clients/StandaloneHud.cpp 1970-01-01 00:00:00 +0000 | |||
3636 | +++ standalone-clients/StandaloneHud.cpp 2012-02-06 11:00:29 +0000 | |||
3637 | @@ -0,0 +1,171 @@ | |||
3638 | 1 | /* | ||
3639 | 2 | * Copyright 2010 Canonical Ltd. | ||
3640 | 3 | * | ||
3641 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
3642 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
3643 | 6 | * by the Free Software Foundation. | ||
3644 | 7 | * | ||
3645 | 8 | * This program is distributed in the hope that it will be useful, but | ||
3646 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
3647 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
3648 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
3649 | 12 | * | ||
3650 | 13 | * You should have received a copy of the GNU General Public License | ||
3651 | 14 | * version 3 along with this program. If not, see | ||
3652 | 15 | * <http://www.gnu.org/licenses/> | ||
3653 | 16 | * | ||
3654 | 17 | * Authored by: Gordon Allott <gord.allott@canonical.com> | ||
3655 | 18 | * | ||
3656 | 19 | */ | ||
3657 | 20 | |||
3658 | 21 | #include <sstream> | ||
3659 | 22 | #include "Nux/Nux.h" | ||
3660 | 23 | #include "Nux/VLayout.h" | ||
3661 | 24 | #include "Nux/Button.h" | ||
3662 | 25 | #include "Nux/TextureArea.h" | ||
3663 | 26 | #include "Nux/WindowThread.h" | ||
3664 | 27 | #include "NuxGraphics/GraphicsEngine.h" | ||
3665 | 28 | #include <gtk/gtk.h> | ||
3666 | 29 | |||
3667 | 30 | #include "HudView.h" | ||
3668 | 31 | #include "DashStyle.h" | ||
3669 | 32 | #include "DashSettings.h" | ||
3670 | 33 | #include <NuxCore/Logger.h> | ||
3671 | 34 | |||
3672 | 35 | namespace | ||
3673 | 36 | { | ||
3674 | 37 | nux::logging::Logger logger("unity.tests.Hud"); | ||
3675 | 38 | } | ||
3676 | 39 | |||
3677 | 40 | class TestRunner | ||
3678 | 41 | { | ||
3679 | 42 | public: | ||
3680 | 43 | TestRunner (); | ||
3681 | 44 | ~TestRunner (); | ||
3682 | 45 | |||
3683 | 46 | static void InitWindowThread (nux::NThread* thread, void* InitData); | ||
3684 | 47 | void Init (); | ||
3685 | 48 | nux::Layout *layout; | ||
3686 | 49 | unity::hud::View* hud_view_; | ||
3687 | 50 | unity::dash::Settings dash_settings_; | ||
3688 | 51 | |||
3689 | 52 | private: | ||
3690 | 53 | unity::hud::Hud hud_service_; | ||
3691 | 54 | }; | ||
3692 | 55 | |||
3693 | 56 | TestRunner::TestRunner () | ||
3694 | 57 | : hud_service_("com.canonical.hud", "/com/canonical/hud") | ||
3695 | 58 | { | ||
3696 | 59 | } | ||
3697 | 60 | |||
3698 | 61 | TestRunner::~TestRunner () | ||
3699 | 62 | { | ||
3700 | 63 | } | ||
3701 | 64 | |||
3702 | 65 | void TestRunner::Init () | ||
3703 | 66 | { | ||
3704 | 67 | LOG_WARNING(logger) << "test init"; | ||
3705 | 68 | layout = new nux::VLayout(); | ||
3706 | 69 | |||
3707 | 70 | hud_view_ = new unity::hud::View(); | ||
3708 | 71 | |||
3709 | 72 | layout->AddView (hud_view_, 1, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL); | ||
3710 | 73 | nux::GetWindowCompositor().SetKeyFocusArea(hud_view_->default_focus()); | ||
3711 | 74 | |||
3712 | 75 | nux::GetWindowThread()->SetLayout (layout); | ||
3713 | 76 | |||
3714 | 77 | // things the controller normally does | ||
3715 | 78 | hud_service_.queries_updated.connect([&] (unity::hud::Hud::Queries queries) { | ||
3716 | 79 | hud_view_->SetQueries(queries); | ||
3717 | 80 | std::string icon_name = ""; | ||
3718 | 81 | for (auto query = queries.begin(); query != queries.end(); query++) | ||
3719 | 82 | { | ||
3720 | 83 | if (!(*query)->icon_name.empty()) | ||
3721 | 84 | { | ||
3722 | 85 | LOG_DEBUG(logger) << "Setting icon name to: " << (*query)->icon_name; | ||
3723 | 86 | icon_name = (*query)->icon_name; | ||
3724 | 87 | break; | ||
3725 | 88 | } | ||
3726 | 89 | } | ||
3727 | 90 | |||
3728 | 91 | hud_view_->SetIcon(icon_name); | ||
3729 | 92 | |||
3730 | 93 | }); | ||
3731 | 94 | |||
3732 | 95 | hud_view_->query_activated.connect([&] (unity::hud::Query::Ptr query) { | ||
3733 | 96 | hud_service_.ExecuteQuery(query, 0); | ||
3734 | 97 | }); | ||
3735 | 98 | |||
3736 | 99 | hud_view_->query_selected.connect([&] (unity::hud::Query::Ptr query) { | ||
3737 | 100 | hud_view_->SetIcon(query->icon_name); | ||
3738 | 101 | }); | ||
3739 | 102 | |||
3740 | 103 | hud_view_->search_changed.connect([&] (std::string search_string) { | ||
3741 | 104 | hud_service_.RequestQuery(search_string); | ||
3742 | 105 | }); | ||
3743 | 106 | |||
3744 | 107 | hud_view_->search_activated.connect([&] (std::string search_string) { | ||
3745 | 108 | hud_service_.ExecuteQueryBySearch(search_string, 0); | ||
3746 | 109 | }); | ||
3747 | 110 | |||
3748 | 111 | hud_service_.RequestQuery(""); | ||
3749 | 112 | |||
3750 | 113 | hud_view_->SetWindowGeometry(layout->GetAbsoluteGeometry(), layout->GetGeometry()); | ||
3751 | 114 | |||
3752 | 115 | } | ||
3753 | 116 | |||
3754 | 117 | void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) | ||
3755 | 118 | { | ||
3756 | 119 | TestRunner *self = (TestRunner *) InitData; | ||
3757 | 120 | self->Init (); | ||
3758 | 121 | } | ||
3759 | 122 | |||
3760 | 123 | void | ||
3761 | 124 | ControlThread (nux::NThread* thread, | ||
3762 | 125 | void* data) | ||
3763 | 126 | { | ||
3764 | 127 | // sleep for 3 seconds | ||
3765 | 128 | nux::SleepForMilliseconds (3000); | ||
3766 | 129 | printf ("ControlThread successfully started\n"); | ||
3767 | 130 | } | ||
3768 | 131 | |||
3769 | 132 | |||
3770 | 133 | int main(int argc, char **argv) | ||
3771 | 134 | { | ||
3772 | 135 | nux::SystemThread* st = NULL; | ||
3773 | 136 | nux::WindowThread* wt = NULL; | ||
3774 | 137 | |||
3775 | 138 | // no real tests right now, just make sure we don't get any criticals and such | ||
3776 | 139 | // waiting on nice perceptual diff support before we can build real tests | ||
3777 | 140 | // for views | ||
3778 | 141 | |||
3779 | 142 | g_type_init (); | ||
3780 | 143 | gtk_init (&argc, &argv); | ||
3781 | 144 | |||
3782 | 145 | nux::NuxInitialize(0); | ||
3783 | 146 | |||
3784 | 147 | // Slightly higher as we're more likely to test things we know will fail | ||
3785 | 148 | nux::logging::configure_logging("unity.hud=debug"); | ||
3786 | 149 | |||
3787 | 150 | nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); | ||
3788 | 151 | LOG_DEBUG(logger) << "starting the standalone hud"; | ||
3789 | 152 | // The instances for the pseudo-singletons. | ||
3790 | 153 | unity::dash::Style dash_style; | ||
3791 | 154 | |||
3792 | 155 | TestRunner *test_runner = new TestRunner (); | ||
3793 | 156 | wt = nux::CreateGUIThread(TEXT("Hud Prototype Test"), | ||
3794 | 157 | 1200, 768, | ||
3795 | 158 | 0, | ||
3796 | 159 | &TestRunner::InitWindowThread, | ||
3797 | 160 | test_runner); | ||
3798 | 161 | |||
3799 | 162 | st = nux::CreateSystemThread (NULL, ControlThread, wt); | ||
3800 | 163 | |||
3801 | 164 | if (st) | ||
3802 | 165 | st->Start (NULL); | ||
3803 | 166 | |||
3804 | 167 | wt->Run (NULL); | ||
3805 | 168 | delete st; | ||
3806 | 169 | delete wt; | ||
3807 | 170 | return 0; | ||
3808 | 171 | } | ||
3809 | 0 | 172 | ||
3810 | === modified file 'tests/CMakeLists.txt' | |||
3811 | --- tests/CMakeLists.txt 2012-02-01 03:39:14 +0000 | |||
3812 | +++ tests/CMakeLists.txt 2012-02-06 11:00:29 +0000 | |||
3813 | @@ -99,6 +99,8 @@ | |||
3814 | 99 | 99 | ||
3815 | 100 | # The service that provides DBus services to test against | 100 | # The service that provides DBus services to test against |
3816 | 101 | add_executable(test-gtest-service | 101 | add_executable(test-gtest-service |
3817 | 102 | test_service_hud.c | ||
3818 | 103 | test_service_hud.h | ||
3819 | 102 | test_service_lens.c | 104 | test_service_lens.c |
3820 | 103 | test_service_lens.h | 105 | test_service_lens.h |
3821 | 104 | test_service_main.c | 106 | test_service_main.c |
3822 | @@ -183,7 +185,8 @@ | |||
3823 | 183 | test_utils.h | 185 | test_utils.h |
3824 | 184 | test_ratings_filter.cpp | 186 | test_ratings_filter.cpp |
3825 | 185 | test_results.cpp | 187 | test_results.cpp |
3827 | 186 | ) | 188 | test_hud.cpp |
3828 | 189 | ) | ||
3829 | 187 | target_link_libraries(test-gtest-dbus ${GTEST_BOTH_LIBRARIES}) | 190 | target_link_libraries(test-gtest-dbus ${GTEST_BOTH_LIBRARIES}) |
3830 | 188 | add_test(UnityGTestDBus test-gtest-dbus) | 191 | add_test(UnityGTestDBus test-gtest-dbus) |
3831 | 189 | add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service) | 192 | add_dependencies(test-gtest-dbus unity-core-${UNITY_API_VERSION} test-gtest-service) |
3832 | 190 | 193 | ||
3833 | === added file 'tests/test_hud.cpp' | |||
3834 | --- tests/test_hud.cpp 1970-01-01 00:00:00 +0000 | |||
3835 | +++ tests/test_hud.cpp 2012-02-06 11:00:29 +0000 | |||
3836 | @@ -0,0 +1,104 @@ | |||
3837 | 1 | #include <gtest/gtest.h> | ||
3838 | 2 | #include <glib-object.h> | ||
3839 | 3 | #include <UnityCore/GLibWrapper.h> | ||
3840 | 4 | #include <UnityCore/Hud.h> | ||
3841 | 5 | |||
3842 | 6 | using namespace std; | ||
3843 | 7 | |||
3844 | 8 | namespace | ||
3845 | 9 | { | ||
3846 | 10 | |||
3847 | 11 | GMainLoop* loop_ = NULL; | ||
3848 | 12 | unity::hud::Hud *hud; | ||
3849 | 13 | |||
3850 | 14 | class TestHud : public ::testing::Test | ||
3851 | 15 | { | ||
3852 | 16 | public: | ||
3853 | 17 | TestHud() | ||
3854 | 18 | : query_return_result(false) | ||
3855 | 19 | , connected_result(false) | ||
3856 | 20 | { | ||
3857 | 21 | } | ||
3858 | 22 | unity::hud::Hud::Queries queries; | ||
3859 | 23 | bool query_return_result; | ||
3860 | 24 | bool connected_result; | ||
3861 | 25 | }; | ||
3862 | 26 | |||
3863 | 27 | TEST_F(TestHud, TestConstruction) | ||
3864 | 28 | { | ||
3865 | 29 | loop_ = g_main_loop_new(NULL, FALSE); | ||
3866 | 30 | hud = new unity::hud::Hud("com.canonical.Unity.Test", "/com/canonical/hud"); | ||
3867 | 31 | |||
3868 | 32 | // performs a check on the hud, if the hud is connected, report a sucess | ||
3869 | 33 | auto timeout_check = [] (gpointer data) -> gboolean | ||
3870 | 34 | { | ||
3871 | 35 | TestHud* self = static_cast<TestHud*>(data); | ||
3872 | 36 | if (hud->connected) | ||
3873 | 37 | { | ||
3874 | 38 | self->connected_result = true; | ||
3875 | 39 | g_main_loop_quit(loop_); | ||
3876 | 40 | return FALSE; | ||
3877 | 41 | } | ||
3878 | 42 | else | ||
3879 | 43 | { | ||
3880 | 44 | self->connected_result = false; | ||
3881 | 45 | return TRUE; | ||
3882 | 46 | } | ||
3883 | 47 | }; | ||
3884 | 48 | |||
3885 | 49 | |||
3886 | 50 | // if the hud is not connected when this lambda runs, fail. | ||
3887 | 51 | auto timeout_bailout = [] (gpointer data) -> gboolean | ||
3888 | 52 | { | ||
3889 | 53 | TestHud* self = static_cast<TestHud*>(data); | ||
3890 | 54 | // reached timeout, failed testing | ||
3891 | 55 | self->connected_result = false; | ||
3892 | 56 | g_main_loop_quit(loop_); | ||
3893 | 57 | return FALSE; | ||
3894 | 58 | }; | ||
3895 | 59 | |||
3896 | 60 | g_timeout_add_seconds(1, timeout_check, this); | ||
3897 | 61 | g_timeout_add_seconds(10, timeout_bailout, this); | ||
3898 | 62 | |||
3899 | 63 | g_main_loop_run(loop_); | ||
3900 | 64 | |||
3901 | 65 | EXPECT_EQ(connected_result, true); | ||
3902 | 66 | } | ||
3903 | 67 | |||
3904 | 68 | TEST_F(TestHud, TestQueryReturn) | ||
3905 | 69 | { | ||
3906 | 70 | query_return_result = false; | ||
3907 | 71 | |||
3908 | 72 | // make sure we receive the queries | ||
3909 | 73 | auto query_connection = [this](unity::hud::Hud::Queries queries_) | ||
3910 | 74 | { | ||
3911 | 75 | query_return_result = true; | ||
3912 | 76 | g_main_loop_quit(loop_); | ||
3913 | 77 | queries = queries_; | ||
3914 | 78 | }; | ||
3915 | 79 | |||
3916 | 80 | auto timeout_bailout = [] (gpointer data) -> gboolean | ||
3917 | 81 | { | ||
3918 | 82 | TestHud* self = static_cast<TestHud*>(data); | ||
3919 | 83 | self->query_return_result = false; | ||
3920 | 84 | g_main_loop_quit(loop_); | ||
3921 | 85 | return FALSE; | ||
3922 | 86 | }; | ||
3923 | 87 | |||
3924 | 88 | hud->queries_updated.connect(query_connection); | ||
3925 | 89 | |||
3926 | 90 | guint source_id = g_timeout_add_seconds(10, timeout_bailout, this); | ||
3927 | 91 | |||
3928 | 92 | // next check we get 30 entries from this specific known callback | ||
3929 | 93 | hud->RequestQuery("Request30Queries"); | ||
3930 | 94 | g_main_loop_run(loop_); | ||
3931 | 95 | EXPECT_EQ(query_return_result, true); | ||
3932 | 96 | EXPECT_NE(queries.size(), 0); | ||
3933 | 97 | g_source_remove(source_id); | ||
3934 | 98 | |||
3935 | 99 | // finally close the connection - Nothing to check for here | ||
3936 | 100 | hud->CloseQuery(); | ||
3937 | 101 | } | ||
3938 | 102 | |||
3939 | 103 | |||
3940 | 104 | } | ||
3941 | 0 | 105 | ||
3942 | === added file 'tests/test_service_hud.c' | |||
3943 | --- tests/test_service_hud.c 1970-01-01 00:00:00 +0000 | |||
3944 | +++ tests/test_service_hud.c 2012-02-06 11:00:29 +0000 | |||
3945 | @@ -0,0 +1,268 @@ | |||
3946 | 1 | #include "test_service_hud.h" | ||
3947 | 2 | #include <unity.h> | ||
3948 | 3 | #include <gio/gio.h> | ||
3949 | 4 | |||
3950 | 5 | const char * hud_interface = | ||
3951 | 6 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
3952 | 7 | "<node name=\"/\">\n" | ||
3953 | 8 | " <interface name=\"com.canonical.hud\">\n" | ||
3954 | 9 | "<!-- Properties -->\n" | ||
3955 | 10 | " <!-- None -->\n" | ||
3956 | 11 | "\n" | ||
3957 | 12 | "<!-- Functions -->\n" | ||
3958 | 13 | " <method name=\"StartQuery\">\n" | ||
3959 | 14 | " <!-- in -->\n" | ||
3960 | 15 | " <arg type=\"s\" name=\"query\" direction=\"in\" />\n" | ||
3961 | 16 | " <arg type=\"i\" name=\"entries\" direction=\"in\" />\n" | ||
3962 | 17 | " <!-- out -->\n" | ||
3963 | 18 | " <arg type=\"s\" name=\"target\" direction=\"out\" />\n" | ||
3964 | 19 | " <arg type=\"a(sssssv)\" name=\"suggestions\" direction=\"out\" />\n" | ||
3965 | 20 | " <arg type=\"v\" name=\"querykey\" direction=\"out\" />\n" | ||
3966 | 21 | " </method>\n" | ||
3967 | 22 | "\n" | ||
3968 | 23 | " <method name=\"ExecuteQuery\">\n" | ||
3969 | 24 | " <arg type=\"v\" name=\"key\" direction=\"in\" />\n" | ||
3970 | 25 | " <arg type=\"u\" name=\"timestamp\" direction=\"in\" />\n" | ||
3971 | 26 | " </method>\n" | ||
3972 | 27 | "\n" | ||
3973 | 28 | " <method name=\"CloseQuery\">\n" | ||
3974 | 29 | " <arg type=\"v\" name=\"querykey\" direction=\"in\" />\n" | ||
3975 | 30 | " </method>\n" | ||
3976 | 31 | "\n" | ||
3977 | 32 | "<!-- Signals -->\n" | ||
3978 | 33 | " <signal name=\"UpdatedQuery\">\n" | ||
3979 | 34 | " <arg type=\"s\" name=\"target\" direction=\"out\" />\n" | ||
3980 | 35 | " <arg type=\"a(sssssv)\" name=\"suggestions\" direction=\"out\" />\n" | ||
3981 | 36 | " <arg type=\"v\" name=\"querykey\" direction=\"out\" />\n" | ||
3982 | 37 | " </signal>\n" | ||
3983 | 38 | "\n" | ||
3984 | 39 | "<!-- End of interesting stuff -->\n" | ||
3985 | 40 | "\n" | ||
3986 | 41 | " </interface>\n" | ||
3987 | 42 | "</node>\n" | ||
3988 | 43 | ; | ||
3989 | 44 | static void bus_got_cb (GObject *object, GAsyncResult * res, gpointer user_data); | ||
3990 | 45 | static void bus_method (GDBusConnection *connection, | ||
3991 | 46 | const gchar *sender, | ||
3992 | 47 | const gchar *object_path, | ||
3993 | 48 | const gchar *interface_name, | ||
3994 | 49 | const gchar *method_name, | ||
3995 | 50 | GVariant *parameters, | ||
3996 | 51 | GDBusMethodInvocation *invocation, | ||
3997 | 52 | gpointer user_data); | ||
3998 | 53 | |||
3999 | 54 | G_DEFINE_TYPE(ServiceHud, service_hud, G_TYPE_OBJECT); | ||
4000 | 55 | static GDBusNodeInfo * node_info = NULL; | ||
4001 | 56 | static GDBusInterfaceInfo * iface_info = NULL; | ||
4002 | 57 | static GDBusInterfaceVTable bus_vtable = { | ||
4003 | 58 | method_call: bus_method, | ||
4004 | 59 | get_property: NULL, | ||
4005 | 60 | set_property: NULL, | ||
4006 | 61 | }; | ||
4007 | 62 | |||
4008 | 63 | |||
4009 | 64 | struct _ServiceHudPrivate | ||
4010 | 65 | { | ||
4011 | 66 | GDBusConnection * bus; | ||
4012 | 67 | GCancellable * bus_lookup; | ||
4013 | 68 | guint bus_registration; | ||
4014 | 69 | }; | ||
4015 | 70 | |||
4016 | 71 | static void | ||
4017 | 72 | service_hud_dispose(GObject* object) | ||
4018 | 73 | { | ||
4019 | 74 | ServiceHud* self = SERVICE_HUD(object); | ||
4020 | 75 | if (self->priv->bus_lookup != NULL) { | ||
4021 | 76 | g_cancellable_cancel(self->priv->bus_lookup); | ||
4022 | 77 | g_object_unref(self->priv->bus_lookup); | ||
4023 | 78 | self->priv->bus_lookup = NULL; | ||
4024 | 79 | } | ||
4025 | 80 | |||
4026 | 81 | if (self->priv->bus_registration != 0) { | ||
4027 | 82 | g_dbus_connection_unregister_object(self->priv->bus, self->priv->bus_registration); | ||
4028 | 83 | self->priv->bus_registration = 0; | ||
4029 | 84 | } | ||
4030 | 85 | |||
4031 | 86 | if (self->priv->bus != NULL) { | ||
4032 | 87 | g_object_unref(self->priv->bus); | ||
4033 | 88 | self->priv->bus = NULL; | ||
4034 | 89 | } | ||
4035 | 90 | |||
4036 | 91 | } | ||
4037 | 92 | |||
4038 | 93 | static void | ||
4039 | 94 | service_hud_class_init(ServiceHudClass* klass) | ||
4040 | 95 | { | ||
4041 | 96 | G_OBJECT_CLASS(klass)->dispose = service_hud_dispose; | ||
4042 | 97 | g_type_class_add_private (klass, sizeof (ServiceHudPrivate)); | ||
4043 | 98 | |||
4044 | 99 | if (node_info == NULL) | ||
4045 | 100 | { | ||
4046 | 101 | GError * error = NULL; | ||
4047 | 102 | |||
4048 | 103 | node_info = g_dbus_node_info_new_for_xml(hud_interface, &error); | ||
4049 | 104 | if (error != NULL) | ||
4050 | 105 | { | ||
4051 | 106 | g_error("Unable to parse HUD interface: %s", error->message); | ||
4052 | 107 | g_error_free(error); | ||
4053 | 108 | } | ||
4054 | 109 | } | ||
4055 | 110 | |||
4056 | 111 | if (node_info != NULL && iface_info == NULL) | ||
4057 | 112 | { | ||
4058 | 113 | iface_info = g_dbus_node_info_lookup_interface(node_info,"com.canonical.hud"); | ||
4059 | 114 | if (iface_info == NULL) | ||
4060 | 115 | { | ||
4061 | 116 | g_error("Unable to find interface 'com.canonical.hud'"); | ||
4062 | 117 | } | ||
4063 | 118 | } | ||
4064 | 119 | |||
4065 | 120 | } | ||
4066 | 121 | |||
4067 | 122 | static void | ||
4068 | 123 | service_hud_init(ServiceHud* self) | ||
4069 | 124 | { | ||
4070 | 125 | self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, SERVICE_TYPE_HUD, ServiceHudPrivate); | ||
4071 | 126 | self->priv->bus = NULL; | ||
4072 | 127 | self->priv->bus_lookup = NULL; | ||
4073 | 128 | self->priv->bus_registration = 0; | ||
4074 | 129 | |||
4075 | 130 | self->priv->bus_lookup = g_cancellable_new(); | ||
4076 | 131 | g_bus_get(G_BUS_TYPE_SESSION, self->priv->bus_lookup, bus_got_cb, self); | ||
4077 | 132 | |||
4078 | 133 | } | ||
4079 | 134 | |||
4080 | 135 | ServiceHud* | ||
4081 | 136 | service_hud_new() | ||
4082 | 137 | { | ||
4083 | 138 | return g_object_new(SERVICE_TYPE_HUD, NULL); | ||
4084 | 139 | } | ||
4085 | 140 | |||
4086 | 141 | static void | ||
4087 | 142 | bus_got_cb (GObject *object, GAsyncResult * res, gpointer user_data) | ||
4088 | 143 | { | ||
4089 | 144 | GError * error = NULL; | ||
4090 | 145 | ServiceHud * self = SERVICE_HUD(user_data); | ||
4091 | 146 | GDBusConnection * bus; | ||
4092 | 147 | |||
4093 | 148 | bus = g_bus_get_finish(res, &error); | ||
4094 | 149 | if (error != NULL) { | ||
4095 | 150 | g_critical("Unable to get bus: %s", error->message); | ||
4096 | 151 | g_error_free(error); | ||
4097 | 152 | return; | ||
4098 | 153 | } | ||
4099 | 154 | |||
4100 | 155 | self->priv->bus = bus; | ||
4101 | 156 | |||
4102 | 157 | /* Register object */ | ||
4103 | 158 | self->priv->bus_registration = g_dbus_connection_register_object(bus, | ||
4104 | 159 | /* path */ "/com/canonical/hud", | ||
4105 | 160 | /* interface */ iface_info, | ||
4106 | 161 | /* vtable */ &bus_vtable, | ||
4107 | 162 | /* userdata */ self, | ||
4108 | 163 | /* destroy */ NULL, | ||
4109 | 164 | /* error */ &error); | ||
4110 | 165 | |||
4111 | 166 | if (error != NULL) { | ||
4112 | 167 | g_critical ("Unable to create bus connection object, %s", error->message); | ||
4113 | 168 | g_error_free(error); | ||
4114 | 169 | return; | ||
4115 | 170 | } | ||
4116 | 171 | |||
4117 | 172 | return; | ||
4118 | 173 | } | ||
4119 | 174 | |||
4120 | 175 | static void | ||
4121 | 176 | bus_method (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) | ||
4122 | 177 | { | ||
4123 | 178 | if (g_strcmp0(method_name, "StartQuery") == 0) | ||
4124 | 179 | { | ||
4125 | 180 | GVariant * ret = NULL; | ||
4126 | 181 | gchar * query = NULL; | ||
4127 | 182 | int num_entries = 0; | ||
4128 | 183 | |||
4129 | 184 | g_variant_get(parameters, "(si)", &query, &num_entries); | ||
4130 | 185 | |||
4131 | 186 | /* Build into into a variant */ | ||
4132 | 187 | GVariantBuilder ret_builder; | ||
4133 | 188 | g_variant_builder_init(&ret_builder, G_VARIANT_TYPE_TUPLE); | ||
4134 | 189 | g_variant_builder_add_value(&ret_builder, g_variant_new_string("target")); | ||
4135 | 190 | GVariantBuilder builder; | ||
4136 | 191 | |||
4137 | 192 | g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); | ||
4138 | 193 | |||
4139 | 194 | int i = 0; | ||
4140 | 195 | for (i = 0; i < num_entries; i++) | ||
4141 | 196 | { | ||
4142 | 197 | gchar* target = g_strdup_printf("test-%i", i); | ||
4143 | 198 | gchar* icon = g_strdup_printf("icon-%i", i); | ||
4144 | 199 | gchar* future_icon = g_strdup(icon); | ||
4145 | 200 | gchar* completion_text = g_strdup_printf("completion-%i", i); | ||
4146 | 201 | gchar* accelerator = g_strdup_printf("<alt>+whatever"); | ||
4147 | 202 | |||
4148 | 203 | GVariantBuilder tuple; | ||
4149 | 204 | g_variant_builder_init(&tuple, G_VARIANT_TYPE_TUPLE); | ||
4150 | 205 | g_variant_builder_add_value(&tuple, g_variant_new_string(target)); | ||
4151 | 206 | g_variant_builder_add_value(&tuple, g_variant_new_string(icon)); | ||
4152 | 207 | g_variant_builder_add_value(&tuple, g_variant_new_string(future_icon)); | ||
4153 | 208 | g_variant_builder_add_value(&tuple, g_variant_new_string(completion_text)); | ||
4154 | 209 | g_variant_builder_add_value(&tuple, g_variant_new_string(accelerator)); | ||
4155 | 210 | // build a fake key | ||
4156 | 211 | GVariant* key; | ||
4157 | 212 | { | ||
4158 | 213 | GVariantBuilder keybuilder; | ||
4159 | 214 | g_variant_builder_init(&keybuilder, G_VARIANT_TYPE_TUPLE); | ||
4160 | 215 | g_variant_builder_add_value(&keybuilder, g_variant_new_string("dummy string")); | ||
4161 | 216 | g_variant_builder_add_value(&keybuilder, g_variant_new_string("dummy string")); | ||
4162 | 217 | g_variant_builder_add_value(&keybuilder, g_variant_new_string("dummy string")); | ||
4163 | 218 | g_variant_builder_add_value(&keybuilder, g_variant_new_int32(1986)); | ||
4164 | 219 | |||
4165 | 220 | key = g_variant_new_variant(g_variant_builder_end(&keybuilder)); | ||
4166 | 221 | } | ||
4167 | 222 | g_variant_ref_sink(key); | ||
4168 | 223 | g_variant_builder_add_value(&tuple, key); | ||
4169 | 224 | g_variant_builder_add_value(&builder, g_variant_builder_end(&tuple)); | ||
4170 | 225 | g_free(target); | ||
4171 | 226 | g_free(icon); | ||
4172 | 227 | g_free(future_icon); | ||
4173 | 228 | g_free(completion_text); | ||
4174 | 229 | } | ||
4175 | 230 | g_variant_builder_add_value(&ret_builder, g_variant_builder_end(&builder)); | ||
4176 | 231 | |||
4177 | 232 | GVariant* query_key; | ||
4178 | 233 | { | ||
4179 | 234 | GVariantBuilder keybuilder; | ||
4180 | 235 | g_variant_builder_init(&keybuilder, G_VARIANT_TYPE_TUPLE); | ||
4181 | 236 | g_variant_builder_add_value(&keybuilder, g_variant_new_string("dummy string")); | ||
4182 | 237 | g_variant_builder_add_value(&keybuilder, g_variant_new_string("dummy string")); | ||
4183 | 238 | g_variant_builder_add_value(&keybuilder, g_variant_new_string("dummy string")); | ||
4184 | 239 | g_variant_builder_add_value(&keybuilder, g_variant_new_int32(1986)); | ||
4185 | 240 | |||
4186 | 241 | query_key = g_variant_new_variant(g_variant_builder_end(&keybuilder)); | ||
4187 | 242 | } | ||
4188 | 243 | g_variant_ref_sink(query_key); | ||
4189 | 244 | g_variant_builder_add_value(&ret_builder, query_key); | ||
4190 | 245 | |||
4191 | 246 | ret = g_variant_builder_end(&ret_builder); | ||
4192 | 247 | |||
4193 | 248 | g_dbus_method_invocation_return_value(invocation, ret); | ||
4194 | 249 | g_free(query); | ||
4195 | 250 | } | ||
4196 | 251 | else if (g_strcmp0(method_name, "ExecuteQuery") == 0) | ||
4197 | 252 | { | ||
4198 | 253 | GVariant * key = NULL; | ||
4199 | 254 | key = g_variant_get_child_value(parameters, 0); | ||
4200 | 255 | g_dbus_method_invocation_return_value(invocation, NULL); | ||
4201 | 256 | g_variant_unref(key); | ||
4202 | 257 | } | ||
4203 | 258 | else if (g_strcmp0(method_name, "CloseQuery") == 0) | ||
4204 | 259 | { | ||
4205 | 260 | GVariant * key = NULL; | ||
4206 | 261 | key = g_variant_get_child_value(parameters, 0); | ||
4207 | 262 | g_dbus_method_invocation_return_value(invocation, NULL); | ||
4208 | 263 | g_variant_unref(key); | ||
4209 | 264 | } | ||
4210 | 265 | |||
4211 | 266 | return; | ||
4212 | 267 | } | ||
4213 | 268 | |||
4214 | 0 | 269 | ||
4215 | === added file 'tests/test_service_hud.h' | |||
4216 | --- tests/test_service_hud.h 1970-01-01 00:00:00 +0000 | |||
4217 | +++ tests/test_service_hud.h 2012-02-06 11:00:29 +0000 | |||
4218 | @@ -0,0 +1,46 @@ | |||
4219 | 1 | #ifndef _SERVICE_HUD_H_ | ||
4220 | 2 | #define _SERVICE_HUD_H_ | ||
4221 | 3 | |||
4222 | 4 | #include <glib-object.h> | ||
4223 | 5 | G_BEGIN_DECLS | ||
4224 | 6 | |||
4225 | 7 | #define SERVICE_TYPE_HUD (service_hud_get_type ()) | ||
4226 | 8 | |||
4227 | 9 | #define SERVICE_HUD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ | ||
4228 | 10 | SERVICE_TYPE_HUD, ServiceHud)) | ||
4229 | 11 | |||
4230 | 12 | #define SERVICE_HUD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ | ||
4231 | 13 | SERVICE_TYPE_HUD, ServiceHudClass)) | ||
4232 | 14 | |||
4233 | 15 | #define SERVICE_IS_HUD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ | ||
4234 | 16 | SERVICE_TYPE_HUD)) | ||
4235 | 17 | |||
4236 | 18 | #define SERVICE_IS_HUD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ | ||
4237 | 19 | SERVICE_TYPE_HUD)) | ||
4238 | 20 | |||
4239 | 21 | #define ServiceHud_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ | ||
4240 | 22 | SERVICE_TYPE_HUD, ServiceHudClass)) | ||
4241 | 23 | |||
4242 | 24 | typedef struct _ServiceHud ServiceHud; | ||
4243 | 25 | typedef struct _ServiceHudClass ServiceHudClass; | ||
4244 | 26 | typedef struct _ServiceHudPrivate ServiceHudPrivate; | ||
4245 | 27 | |||
4246 | 28 | struct _ServiceHud | ||
4247 | 29 | { | ||
4248 | 30 | GObject parent; | ||
4249 | 31 | |||
4250 | 32 | ServiceHudPrivate *priv; | ||
4251 | 33 | }; | ||
4252 | 34 | |||
4253 | 35 | struct _ServiceHudClass | ||
4254 | 36 | { | ||
4255 | 37 | GObjectClass parent_class; | ||
4256 | 38 | }; | ||
4257 | 39 | |||
4258 | 40 | GType service_hud_get_type(void) G_GNUC_CONST; | ||
4259 | 41 | |||
4260 | 42 | ServiceHud* service_hud_new(void); | ||
4261 | 43 | |||
4262 | 44 | G_END_DECLS | ||
4263 | 45 | |||
4264 | 46 | #endif /* _SERVICE_HUD_H_ */ | ||
4265 | 0 | 47 | ||
4266 | === modified file 'tests/test_service_main.c' | |||
4267 | --- tests/test_service_main.c 2011-07-26 09:08:42 +0000 | |||
4268 | +++ tests/test_service_main.c 2012-02-06 11:00:29 +0000 | |||
4269 | @@ -2,6 +2,7 @@ | |||
4270 | 2 | 2 | ||
4271 | 3 | #include "test_service_lens.h" | 3 | #include "test_service_lens.h" |
4272 | 4 | #include "test_service_model.h" | 4 | #include "test_service_model.h" |
4273 | 5 | #include "test_service_hud.h" | ||
4274 | 5 | 6 | ||
4275 | 6 | static void on_bus_aquired(GDBusConnection* conn, const gchar* name, gpointer null); | 7 | static void on_bus_aquired(GDBusConnection* conn, const gchar* name, gpointer null); |
4276 | 7 | static void handle_method_call(GDBusConnection *connection, | 8 | static void handle_method_call(GDBusConnection *connection, |
4277 | @@ -34,6 +35,7 @@ | |||
4278 | 34 | static GMainLoop* loop_ = NULL; | 35 | static GMainLoop* loop_ = NULL; |
4279 | 35 | static ServiceLens* lens_ = NULL; | 36 | static ServiceLens* lens_ = NULL; |
4280 | 36 | static ServiceModel* model_ = NULL; | 37 | static ServiceModel* model_ = NULL; |
4281 | 38 | static ServiceHud* hud_ = NULL; | ||
4282 | 37 | 39 | ||
4283 | 38 | gint | 40 | gint |
4284 | 39 | main(gint argc, gchar** argv) | 41 | main(gint argc, gchar** argv) |
4285 | @@ -44,6 +46,7 @@ | |||
4286 | 44 | 46 | ||
4287 | 45 | lens_ = service_lens_new(); | 47 | lens_ = service_lens_new(); |
4288 | 46 | model_ = service_model_new(); | 48 | model_ = service_model_new(); |
4289 | 49 | hud_ = service_hud_new(); | ||
4290 | 47 | 50 | ||
4291 | 48 | g_bus_own_name(G_BUS_TYPE_SESSION, | 51 | g_bus_own_name(G_BUS_TYPE_SESSION, |
4292 | 49 | "com.canonical.Unity.Test", | 52 | "com.canonical.Unity.Test", |
4293 | @@ -57,8 +60,9 @@ | |||
4294 | 57 | g_main_loop_run(loop_); | 60 | g_main_loop_run(loop_); |
4295 | 58 | g_main_loop_unref(loop_); | 61 | g_main_loop_unref(loop_); |
4296 | 59 | 62 | ||
4299 | 60 | g_object_unref(lens_); | 63 | //g_object_unref(lens_); |
4300 | 61 | g_object_unref(model_); | 64 | //g_object_unref(model_); |
4301 | 65 | g_object_unref(hud_); | ||
4302 | 62 | g_dbus_node_info_unref(introspection_data); | 66 | g_dbus_node_info_unref(introspection_data); |
4303 | 63 | 67 | ||
4304 | 64 | return 0; | 68 | return 0; |
50 - self->owner_ ->connected. emit();
Why is this needed?