Merge lp:~unity-team/unity/collapsing-place-groups into lp:unity
- collapsing-place-groups
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 370 |
Proposed branch: | lp:~unity-team/unity/collapsing-place-groups |
Merge into: | lp:unity |
Prerequisite: | lp:~unity-team/unity/njpatel-2010-07-02-bug-fixes |
Diff against target: |
741 lines (+395/-78) 11 files modified
.bzrignore (+1/-0) unity-private/places/places-default-renderer-group.vala (+138/-36) unity-private/places/places-default-renderer.vala (+1/-1) unity-private/places/places-place-search-bar.vala (+6/-1) unity-private/places/places-place-search-entry.vala (+14/-11) unity-private/places/places-view.vala (+4/-1) unity-private/testing/test-window.vala (+3/-0) unity/Makefile.am (+1/-0) unity/unity-expanding-bin.vala (+179/-0) unity/unity-pixbuf-cache.vala (+42/-28) vapi/clutk-0.3.vapi (+6/-0) |
To merge this branch: | bzr merge lp:~unity-team/unity/collapsing-place-groups |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jay Taoko (community) | Approve | ||
Review via email: mp+29371@code.launchpad.net |
Commit message
Description of the change
- Add an expandable bin actor that had three states, CLOSED (hidden), UNEXPANDED (open to a certian height) and EXPANDED (open to the height requested by children). It animates between the three states
- Add support for the auto-fade iconview property
- Adds incredibly lazy icon and text loading by deferring loading to the last possible point. Using the new api from the iconview, the DefaultRenderer
- There are lot's of other fixes for places
**** YOU REQUIRE lp:~unity-team/clutk/icon-view-auto-fade-children FOR THIS TO WORK PROPERLY ****
Neil J. Patel (njpatel) wrote : | # |
Jay Taoko (jaytaoko) wrote : | # |
Tested and Approved!
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2010-07-07 09:12:51 +0000 | |||
3 | +++ .bzrignore 2010-07-07 09:12:51 +0000 | |||
4 | @@ -321,3 +321,4 @@ | |||
5 | 321 | tests/unit/test-io.c | 321 | tests/unit/test-io.c |
6 | 322 | unity/unity-appinfo-manager.c | 322 | unity/unity-appinfo-manager.c |
7 | 323 | unity/unity-io.c | 323 | unity/unity-io.c |
8 | 324 | unity/unity-expanding-bin.c | ||
9 | 324 | 325 | ||
10 | === modified file 'unity-private/places/places-default-renderer-group.vala' | |||
11 | --- unity-private/places/places-default-renderer-group.vala 2010-07-07 09:12:51 +0000 | |||
12 | +++ unity-private/places/places-default-renderer-group.vala 2010-07-07 09:12:51 +0000 | |||
13 | @@ -19,9 +19,9 @@ | |||
14 | 19 | 19 | ||
15 | 20 | namespace Unity.Places | 20 | namespace Unity.Places |
16 | 21 | { | 21 | { |
18 | 22 | public class DefaultRendererGroup : Ctk.Box | 22 | public class DefaultRendererGroup : ExpandingBin |
19 | 23 | { | 23 | { |
21 | 24 | static const float PADDING = 0.0f; | 24 | static const float PADDING = 24.0f; |
22 | 25 | static const int SPACING = 0; | 25 | static const int SPACING = 0; |
23 | 26 | 26 | ||
24 | 27 | public uint group_id { get; construct; } | 27 | public uint group_id { get; construct; } |
25 | @@ -30,12 +30,17 @@ | |||
26 | 30 | public string icon_hint { get; construct; } | 30 | public string icon_hint { get; construct; } |
27 | 31 | public Dee.Model results { get; construct; } | 31 | public Dee.Model results { get; construct; } |
28 | 32 | 32 | ||
29 | 33 | private Ctk.VBox vbox; | ||
30 | 33 | private Ctk.HBox title_box; | 34 | private Ctk.HBox title_box; |
31 | 34 | private Ctk.Image icon; | 35 | private Ctk.Image icon; |
32 | 35 | private Ctk.Text text; | 36 | private Ctk.Text text; |
33 | 36 | private Ctk.Image expander; | 37 | private Ctk.Image expander; |
34 | 37 | private Ctk.IconView renderer; | 38 | private Ctk.IconView renderer; |
35 | 38 | 39 | ||
36 | 40 | /* Some caching to speed up lookups */ | ||
37 | 41 | private uint n_results = 0; | ||
38 | 42 | private bool dirty = false; | ||
39 | 43 | |||
40 | 39 | public DefaultRendererGroup (uint group_id, | 44 | public DefaultRendererGroup (uint group_id, |
41 | 40 | string group_renderer, | 45 | string group_renderer, |
42 | 41 | string display_name, | 46 | string display_name, |
43 | @@ -51,17 +56,22 @@ | |||
44 | 51 | 56 | ||
45 | 52 | construct | 57 | construct |
46 | 53 | { | 58 | { |
51 | 54 | padding = { PADDING, PADDING, PADDING , PADDING}; | 59 | padding = { 0.0f, 0.0f, PADDING , 0.0f}; |
48 | 55 | orientation = Ctk.Orientation.VERTICAL; | ||
49 | 56 | spacing = SPACING; | ||
50 | 57 | homogeneous = false; | ||
52 | 58 | hide (); | 60 | hide (); |
53 | 59 | 61 | ||
56 | 60 | title_box = new Ctk.HBox (8); | 62 | vbox = new Ctk.VBox (SPACING); |
57 | 61 | pack (title_box, false, false); | 63 | vbox.spacing = SPACING; |
58 | 64 | vbox.homogeneous = false; | ||
59 | 65 | add_actor (vbox); | ||
60 | 66 | vbox.show (); | ||
61 | 67 | |||
62 | 68 | title_box = new Ctk.HBox (5); | ||
63 | 69 | vbox.pack (title_box, false, false); | ||
64 | 62 | title_box.show (); | 70 | title_box.show (); |
65 | 71 | title_box.reactive = true; | ||
66 | 63 | 72 | ||
68 | 64 | icon = new Ctk.Image (24); | 73 | icon = new Ctk.Image (22); |
69 | 74 | icon.set_from_filename (PKGDATADIR + "/favourites.png"); | ||
70 | 65 | title_box.pack (icon, false, false); | 75 | title_box.pack (icon, false, false); |
71 | 66 | icon.show (); | 76 | icon.show (); |
72 | 67 | 77 | ||
73 | @@ -69,20 +79,53 @@ | |||
74 | 69 | title_box.pack (text, true, true); | 79 | title_box.pack (text, true, true); |
75 | 70 | text.show (); | 80 | text.show (); |
76 | 71 | 81 | ||
78 | 72 | expander = new Ctk.Image (24); | 82 | expander = new Ctk.Image (22); |
79 | 83 | expander.set_from_filename (PKGDATADIR + "/maximize_up.png"); | ||
80 | 84 | expander.opacity = 0; | ||
81 | 73 | title_box.pack (expander, false, true); | 85 | title_box.pack (expander, false, true); |
82 | 74 | expander.show (); | 86 | expander.show (); |
83 | 75 | 87 | ||
88 | 76 | var sep = new Clutter.Rectangle.with_color ({ 255, 255, 255, 255 }); | 88 | var rect = new Clutter.Rectangle.with_color ({ 255, 255, 255, 255 }); |
89 | 77 | sep.set_height (1); | 89 | rect.height = 1; |
90 | 78 | pack (sep, false, false); | 90 | vbox.pack (rect, false, false); |
91 | 79 | sep.show (); | 91 | rect.show (); |
92 | 92 | |||
93 | 93 | title_box.button_release_event.connect (() => { | ||
94 | 94 | if (n_results <= renderer.get_n_cols ()) | ||
95 | 95 | return true; | ||
96 | 96 | |||
97 | 97 | if (bin_state == ExpandingBinState.UNEXPANDED) | ||
98 | 98 | { | ||
99 | 99 | bin_state = ExpandingBinState.EXPANDED; | ||
100 | 100 | expander.set_from_filename (PKGDATADIR + "/minimize_up.png"); | ||
101 | 101 | } | ||
102 | 102 | else | ||
103 | 103 | { | ||
104 | 104 | bin_state = ExpandingBinState.UNEXPANDED; | ||
105 | 105 | expander.set_from_filename (PKGDATADIR + "/maximize_up.png"); | ||
106 | 106 | } | ||
107 | 107 | return true; | ||
108 | 108 | }); | ||
109 | 109 | title_box.motion_event.connect (() => { | ||
110 | 110 | if (dirty) | ||
111 | 111 | { | ||
112 | 112 | var children = renderer.get_children (); | ||
113 | 113 | foreach (Clutter.Actor child in children) | ||
114 | 114 | { | ||
115 | 115 | Tile tile = child as Tile; | ||
116 | 116 | tile.about_to_show (); | ||
117 | 117 | } | ||
118 | 118 | dirty = false; | ||
119 | 119 | } | ||
120 | 120 | }); | ||
121 | 80 | 121 | ||
122 | 81 | renderer = new Ctk.IconView (); | 122 | renderer = new Ctk.IconView (); |
123 | 82 | renderer.padding = { 12.0f, 0.0f, 0.0f, 0.0f }; | 123 | renderer.padding = { 12.0f, 0.0f, 0.0f, 0.0f }; |
124 | 83 | renderer.spacing = 24; | 124 | renderer.spacing = 24; |
126 | 84 | pack (renderer, true, true); | 125 | vbox.pack (renderer, true, true); |
127 | 85 | renderer.show (); | 126 | renderer.show (); |
128 | 127 | renderer.set ("auto-fade-children", true); | ||
129 | 128 | renderer.notify["n-cols"].connect (on_n_cols_changed); | ||
130 | 86 | 129 | ||
131 | 87 | unowned Dee.ModelIter iter = results.get_first_iter (); | 130 | unowned Dee.ModelIter iter = results.get_first_iter (); |
132 | 88 | while (!results.is_last (iter)) | 131 | while (!results.is_last (iter)) |
133 | @@ -97,21 +140,22 @@ | |||
134 | 97 | results.row_removed.connect (on_result_removed); | 140 | results.row_removed.connect (on_result_removed); |
135 | 98 | } | 141 | } |
136 | 99 | 142 | ||
140 | 100 | private override void get_preferred_height (float for_width, | 143 | private override void allocate (Clutter.ActorBox box, |
141 | 101 | out float min_height, | 144 | Clutter.AllocationFlags flags) |
139 | 102 | out float nat_height) | ||
142 | 103 | { | 145 | { |
143 | 146 | base.allocate (box, flags); | ||
144 | 147 | |||
145 | 148 | /* Update the unexpanded height if necessary */ | ||
146 | 149 | /* FIXME: Can we please add some nice methods to CluTK which allow | ||
147 | 150 | * doing something like $clutk_container.get_nth_child (), and so | ||
148 | 151 | * bypass the stupid get_children stuff. In any case, cache the result | ||
149 | 152 | */ | ||
150 | 104 | var children = renderer.get_children (); | 153 | var children = renderer.get_children (); |
161 | 105 | if (children.length () > 0) | 154 | var child = children.nth_data (0) as Clutter.Actor; |
162 | 106 | { | 155 | if (child is Clutter.Actor && |
163 | 107 | base.get_preferred_height (for_width, out min_height, out nat_height); | 156 | child.height != unexpanded_height) |
164 | 108 | show (); | 157 | { |
165 | 109 | } | 158 | unexpanded_height = title_box.height + 1.0f + child.height; |
156 | 110 | else | ||
157 | 111 | { | ||
158 | 112 | min_height = 0; | ||
159 | 113 | nat_height = 0; | ||
160 | 114 | hide (); | ||
166 | 115 | } | 159 | } |
167 | 116 | } | 160 | } |
168 | 117 | 161 | ||
169 | @@ -132,7 +176,15 @@ | |||
170 | 132 | renderer.add_actor (button); | 176 | renderer.add_actor (button); |
171 | 133 | button.show (); | 177 | button.show (); |
172 | 134 | 178 | ||
174 | 135 | show (); | 179 | add_to_n_results (1); |
175 | 180 | |||
176 | 181 | if (bin_state == ExpandingBinState.CLOSED) | ||
177 | 182 | { | ||
178 | 183 | bin_state = ExpandingBinState.UNEXPANDED; | ||
179 | 184 | show (); | ||
180 | 185 | } | ||
181 | 186 | |||
182 | 187 | dirty = true; | ||
183 | 136 | } | 188 | } |
184 | 137 | 189 | ||
185 | 138 | private void on_result_removed (Dee.ModelIter iter) | 190 | private void on_result_removed (Dee.ModelIter iter) |
186 | @@ -148,18 +200,62 @@ | |||
187 | 148 | if (tile.iter == iter) | 200 | if (tile.iter == iter) |
188 | 149 | { | 201 | { |
189 | 150 | actor.destroy (); | 202 | actor.destroy (); |
190 | 203 | add_to_n_results (-1); | ||
191 | 151 | break; | 204 | break; |
192 | 152 | } | 205 | } |
193 | 153 | } | 206 | } |
194 | 154 | 207 | ||
197 | 155 | if (children.length () <= 1) | 208 | if (n_results < 1) |
198 | 156 | hide (); | 209 | { |
199 | 210 | bin_state = ExpandingBinState.CLOSED; | ||
200 | 211 | } | ||
201 | 157 | } | 212 | } |
202 | 158 | 213 | ||
203 | 159 | private bool interesting (Dee.ModelIter iter) | 214 | private bool interesting (Dee.ModelIter iter) |
204 | 160 | { | 215 | { |
205 | 161 | return (results.get_uint (iter, 2) == group_id); | 216 | return (results.get_uint (iter, 2) == group_id); |
206 | 162 | } | 217 | } |
207 | 218 | |||
208 | 219 | private void add_to_n_results (int i) | ||
209 | 220 | { | ||
210 | 221 | n_results += i; | ||
211 | 222 | |||
212 | 223 | if (n_results > renderer.get_n_cols ()) | ||
213 | 224 | { | ||
214 | 225 | expander.animate (Clutter.AnimationMode.EASE_IN_SINE, 200, | ||
215 | 226 | "opacity", 255); | ||
216 | 227 | } | ||
217 | 228 | else | ||
218 | 229 | { | ||
219 | 230 | expander.animate (Clutter.AnimationMode.EASE_IN_SINE, 200, | ||
220 | 231 | "opacity", 0); | ||
221 | 232 | } | ||
222 | 233 | } | ||
223 | 234 | |||
224 | 235 | private void on_n_cols_changed () | ||
225 | 236 | { | ||
226 | 237 | var n_cols = renderer.get_n_cols (); | ||
227 | 238 | |||
228 | 239 | if (bin_state == ExpandingBinState.UNEXPANDED) | ||
229 | 240 | { | ||
230 | 241 | var children = renderer.get_children (); | ||
231 | 242 | int i = 0; | ||
232 | 243 | |||
233 | 244 | foreach (Clutter.Actor child in children) | ||
234 | 245 | { | ||
235 | 246 | Tile tile = child as Tile; | ||
236 | 247 | if (i < n_cols) | ||
237 | 248 | { | ||
238 | 249 | tile.about_to_show (); | ||
239 | 250 | i++; | ||
240 | 251 | } | ||
241 | 252 | else | ||
242 | 253 | break; | ||
243 | 254 | } | ||
244 | 255 | } | ||
245 | 256 | |||
246 | 257 | add_to_n_results (0); | ||
247 | 258 | } | ||
248 | 163 | } | 259 | } |
249 | 164 | 260 | ||
250 | 165 | public class Tile : Ctk.Button | 261 | public class Tile : Ctk.Button |
251 | @@ -175,6 +271,8 @@ | |||
252 | 175 | public string? mimetype { get; construct; } | 271 | public string? mimetype { get; construct; } |
253 | 176 | public string? comment { get; construct; } | 272 | public string? comment { get; construct; } |
254 | 177 | 273 | ||
255 | 274 | private bool shown = false; | ||
256 | 275 | |||
257 | 178 | public Tile (Dee.ModelIter iter, | 276 | public Tile (Dee.ModelIter iter, |
258 | 179 | string uri, | 277 | string uri, |
259 | 180 | string? icon_hint, | 278 | string? icon_hint, |
260 | @@ -193,11 +291,17 @@ | |||
261 | 193 | 291 | ||
262 | 194 | construct | 292 | construct |
263 | 195 | { | 293 | { |
264 | 196 | set_label (display_name); | ||
265 | 197 | |||
266 | 198 | unowned Ctk.Text text = get_text (); | 294 | unowned Ctk.Text text = get_text (); |
267 | 199 | text.ellipsize = Pango.EllipsizeMode.END; | 295 | text.ellipsize = Pango.EllipsizeMode.END; |
269 | 200 | 296 | } | |
270 | 297 | |||
271 | 298 | public void about_to_show () | ||
272 | 299 | { | ||
273 | 300 | if (shown) | ||
274 | 301 | return; | ||
275 | 302 | shown = true; | ||
276 | 303 | |||
277 | 304 | set_label (display_name); | ||
278 | 201 | set_icon (); | 305 | set_icon (); |
279 | 202 | } | 306 | } |
280 | 203 | 307 | ||
281 | @@ -226,7 +330,6 @@ | |||
282 | 226 | try { | 330 | try { |
283 | 227 | var appinfos = AppInfoManager.get_instance (); | 331 | var appinfos = AppInfoManager.get_instance (); |
284 | 228 | info = yield appinfos.lookup_async (id); | 332 | info = yield appinfos.lookup_async (id); |
285 | 229 | debug ("Foo: %s", info.get_name()); | ||
286 | 230 | } catch (Error ee) { | 333 | } catch (Error ee) { |
287 | 231 | warning ("Unable to read .desktop file '%s': %s", uri, ee.message); | 334 | warning ("Unable to read .desktop file '%s': %s", uri, ee.message); |
288 | 232 | return; | 335 | return; |
289 | @@ -236,7 +339,6 @@ | |||
290 | 236 | { | 339 | { |
291 | 237 | try { | 340 | try { |
292 | 238 | info.launch (null,null); | 341 | info.launch (null,null); |
293 | 239 | debug ("Launched"); | ||
294 | 240 | } catch (Error e) { | 342 | } catch (Error e) { |
295 | 241 | warning ("Unable to launch desktop file %s: %s\n", | 343 | warning ("Unable to launch desktop file %s: %s\n", |
296 | 242 | id, | 344 | id, |
297 | 243 | 345 | ||
298 | === modified file 'unity-private/places/places-default-renderer.vala' | |||
299 | --- unity-private/places/places-default-renderer.vala 2010-07-01 13:50:01 +0000 | |||
300 | +++ unity-private/places/places-default-renderer.vala 2010-07-07 09:12:51 +0000 | |||
301 | @@ -22,7 +22,7 @@ | |||
302 | 22 | public class DefaultRenderer : Ctk.ScrollView, Unity.Place.Renderer | 22 | public class DefaultRenderer : Ctk.ScrollView, Unity.Place.Renderer |
303 | 23 | { | 23 | { |
304 | 24 | static const float PADDING = 12.0f; | 24 | static const float PADDING = 12.0f; |
306 | 25 | static const int SPACING = 12; | 25 | static const int SPACING = 0; |
307 | 26 | 26 | ||
308 | 27 | private Ctk.VBox box; | 27 | private Ctk.VBox box; |
309 | 28 | private Dee.Model groups_model; | 28 | private Dee.Model groups_model; |
310 | 29 | 29 | ||
311 | === modified file 'unity-private/places/places-place-search-bar.vala' | |||
312 | --- unity-private/places/places-place-search-bar.vala 2010-06-24 07:43:05 +0000 | |||
313 | +++ unity-private/places/places-place-search-bar.vala 2010-07-07 09:12:51 +0000 | |||
314 | @@ -62,6 +62,11 @@ | |||
315 | 62 | bg.show (); | 62 | bg.show (); |
316 | 63 | } | 63 | } |
317 | 64 | 64 | ||
318 | 65 | public void reset () | ||
319 | 66 | { | ||
320 | 67 | entry.reset (); | ||
321 | 68 | } | ||
322 | 69 | |||
323 | 65 | private override void allocate (Clutter.ActorBox box, | 70 | private override void allocate (Clutter.ActorBox box, |
324 | 66 | Clutter.AllocationFlags flags) | 71 | Clutter.AllocationFlags flags) |
325 | 67 | { | 72 | { |
326 | @@ -94,7 +99,7 @@ | |||
327 | 94 | nat_height = nheight + SPACING * 3; | 99 | nat_height = nheight + SPACING * 3; |
328 | 95 | } | 100 | } |
329 | 96 | 101 | ||
331 | 97 | private void on_search_text_changed (string text) | 102 | private void on_search_text_changed (string? text) |
332 | 98 | { | 103 | { |
333 | 99 | if (active_entry is PlaceEntry) | 104 | if (active_entry is PlaceEntry) |
334 | 100 | { | 105 | { |
335 | 101 | 106 | ||
336 | === modified file 'unity-private/places/places-place-search-entry.vala' | |||
337 | --- unity-private/places/places-place-search-entry.vala 2010-07-01 14:22:01 +0000 | |||
338 | +++ unity-private/places/places-place-search-entry.vala 2010-07-07 09:12:51 +0000 | |||
339 | @@ -23,7 +23,7 @@ | |||
340 | 23 | { | 23 | { |
341 | 24 | static const string SEARCH_ICON_FILE = PKGDATADIR + "/search_icon.png"; | 24 | static const string SEARCH_ICON_FILE = PKGDATADIR + "/search_icon.png"; |
342 | 25 | static const float PADDING = 1.0f; | 25 | static const float PADDING = 1.0f; |
344 | 26 | static const int LIVE_SEARCH_TIMEOUT = 300; /* Milliseconds */ | 26 | static const int LIVE_SEARCH_TIMEOUT = 200; /* Milliseconds */ |
345 | 27 | const Clutter.Color nofocus_color = { 0xff, 0xff, 0xff, 0xbb }; | 27 | const Clutter.Color nofocus_color = { 0xff, 0xff, 0xff, 0xbb }; |
346 | 28 | const Clutter.Color focus_color = { 0xff, 0xff, 0xff, 0xff }; | 28 | const Clutter.Color focus_color = { 0xff, 0xff, 0xff, 0xff }; |
347 | 29 | 29 | ||
348 | @@ -32,9 +32,9 @@ | |||
349 | 32 | public ThemeImage right_icon; | 32 | public ThemeImage right_icon; |
350 | 33 | 33 | ||
351 | 34 | private uint live_search_timeout = 0; | 34 | private uint live_search_timeout = 0; |
353 | 35 | private string _static_text = "Search"; | 35 | private string _static_text = _("Search"); |
354 | 36 | 36 | ||
356 | 37 | public signal void text_changed (string text); | 37 | public signal void text_changed (string? text); |
357 | 38 | 38 | ||
358 | 39 | public PlaceSearchEntry () | 39 | public PlaceSearchEntry () |
359 | 40 | { | 40 | { |
360 | @@ -89,7 +89,7 @@ | |||
361 | 89 | Source.remove (live_search_timeout); | 89 | Source.remove (live_search_timeout); |
362 | 90 | 90 | ||
363 | 91 | live_search_timeout = Timeout.add (LIVE_SEARCH_TIMEOUT, () => { | 91 | live_search_timeout = Timeout.add (LIVE_SEARCH_TIMEOUT, () => { |
365 | 92 | text_changed (text.text); | 92 | text_changed (text.text == _static_text ? "" : text.text); |
366 | 93 | live_search_timeout = 0; | 93 | live_search_timeout = 0; |
367 | 94 | 94 | ||
368 | 95 | return false; | 95 | return false; |
369 | @@ -99,21 +99,24 @@ | |||
370 | 99 | private void on_key_focus_in () | 99 | private void on_key_focus_in () |
371 | 100 | { | 100 | { |
372 | 101 | if (text.text == _static_text) | 101 | if (text.text == _static_text) |
373 | 102 | { | ||
374 | 103 | text.set_text (""); | 102 | text.set_text (""); |
379 | 104 | text.cursor_visible = true; | 103 | |
380 | 105 | text.set_selection (0, -1); | 104 | text.cursor_visible = true; |
381 | 106 | text.color = focus_color; | 105 | text.color = focus_color; |
378 | 107 | } | ||
382 | 108 | } | 106 | } |
383 | 109 | 107 | ||
384 | 110 | private void on_key_focus_out () | 108 | private void on_key_focus_out () |
385 | 111 | { | 109 | { |
386 | 112 | 110 | ||
387 | 113 | text.cursor_visible = false; | 111 | text.cursor_visible = false; |
388 | 112 | text.color = nofocus_color; | ||
389 | 113 | } | ||
390 | 114 | |||
391 | 115 | public void reset () | ||
392 | 116 | { | ||
393 | 117 | text.cursor_visible = false; | ||
394 | 118 | text.color = nofocus_color; | ||
395 | 114 | text.text = _static_text; | 119 | text.text = _static_text; |
396 | 115 | text.color = nofocus_color; | ||
397 | 116 | |||
398 | 117 | } | 120 | } |
399 | 118 | } | 121 | } |
400 | 119 | } | 122 | } |
401 | 120 | 123 | ||
402 | === modified file 'unity-private/places/places-view.vala' | |||
403 | --- unity-private/places/places-view.vala 2010-07-01 13:50:01 +0000 | |||
404 | +++ unity-private/places/places-view.vala 2010-07-07 09:12:51 +0000 | |||
405 | @@ -52,7 +52,10 @@ | |||
406 | 52 | public void about_to_show () | 52 | public void about_to_show () |
407 | 53 | { | 53 | { |
408 | 54 | if (_model is PlaceFileModel) | 54 | if (_model is PlaceFileModel) |
410 | 55 | return; | 55 | { |
411 | 56 | search_bar.reset (); | ||
412 | 57 | return; | ||
413 | 58 | } | ||
414 | 56 | 59 | ||
415 | 57 | _model = new PlaceFileModel () as PlaceModel; | 60 | _model = new PlaceFileModel () as PlaceModel; |
416 | 58 | 61 | ||
417 | 59 | 62 | ||
418 | === modified file 'unity-private/testing/test-window.vala' | |||
419 | --- unity-private/testing/test-window.vala 2010-07-07 09:12:51 +0000 | |||
420 | +++ unity-private/testing/test-window.vala 2010-07-07 09:12:51 +0000 | |||
421 | @@ -300,12 +300,14 @@ | |||
422 | 300 | { | 300 | { |
423 | 301 | this.showing_places = false; | 301 | this.showing_places = false; |
424 | 302 | this.panel.set_indicator_mode (true); | 302 | this.panel.set_indicator_mode (true); |
425 | 303 | this.background.opacity = 160; | ||
426 | 303 | this.places.opacity = 255; | 304 | this.places.opacity = 255; |
427 | 304 | } | 305 | } |
428 | 305 | else | 306 | else |
429 | 306 | { | 307 | { |
430 | 307 | this.showing_places = true; | 308 | this.showing_places = true; |
431 | 308 | this.panel.set_indicator_mode (false); | 309 | this.panel.set_indicator_mode (false); |
432 | 310 | this.background.opacity = 255; | ||
433 | 309 | this.places.opacity = 0; | 311 | this.places.opacity = 0; |
434 | 310 | } | 312 | } |
435 | 311 | 313 | ||
436 | @@ -318,6 +320,7 @@ | |||
437 | 318 | { | 320 | { |
438 | 319 | showing_places = true; | 321 | showing_places = true; |
439 | 320 | panel.set_indicator_mode (false); | 322 | panel.set_indicator_mode (false); |
440 | 323 | background.opacity = 255; | ||
441 | 321 | places.opacity = 0; | 324 | places.opacity = 0; |
442 | 322 | } | 325 | } |
443 | 323 | } | 326 | } |
444 | 324 | 327 | ||
445 | === modified file 'unity/Makefile.am' | |||
446 | --- unity/Makefile.am 2010-07-01 15:22:49 +0000 | |||
447 | +++ unity/Makefile.am 2010-07-07 09:12:51 +0000 | |||
448 | @@ -70,6 +70,7 @@ | |||
449 | 70 | theme.vala \ | 70 | theme.vala \ |
450 | 71 | unity-appinfo-manager.vala \ | 71 | unity-appinfo-manager.vala \ |
451 | 72 | unity-cairo-canvas.vala \ | 72 | unity-cairo-canvas.vala \ |
452 | 73 | unity-expanding-bin.vala \ | ||
453 | 73 | unity-favorites.vala \ | 74 | unity-favorites.vala \ |
454 | 74 | unity-io.vala \ | 75 | unity-io.vala \ |
455 | 75 | unity-pixbuf-cache.vala \ | 76 | unity-pixbuf-cache.vala \ |
456 | 76 | 77 | ||
457 | === added file 'unity/unity-expanding-bin.vala' | |||
458 | --- unity/unity-expanding-bin.vala 1970-01-01 00:00:00 +0000 | |||
459 | +++ unity/unity-expanding-bin.vala 2010-07-07 09:12:51 +0000 | |||
460 | @@ -0,0 +1,179 @@ | |||
461 | 1 | /* | ||
462 | 2 | * Copyright (C) 2010 Canonical, Ltd. | ||
463 | 3 | * | ||
464 | 4 | * This library is free software; you can redistribute it and/or modify | ||
465 | 5 | * it under the terms of the GNU Lesser General Public License | ||
466 | 6 | * version 3.0 as published by the Free Software Foundation. | ||
467 | 7 | * | ||
468 | 8 | * This library is distributed in the hope that it will be useful, | ||
469 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
470 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
471 | 11 | * GNU Lesser General Public License version 3.0 for more details. | ||
472 | 12 | * | ||
473 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
474 | 14 | * License along with this library. If not, see | ||
475 | 15 | <http://www.gnu.org/licenses/>. | ||
476 | 16 | * | ||
477 | 17 | * Authored by Neil Jagdish Patel <neil.patel@canonical.com> | ||
478 | 18 | */ | ||
479 | 19 | |||
480 | 20 | using GLib; | ||
481 | 21 | |||
482 | 22 | namespace Unity | ||
483 | 23 | { | ||
484 | 24 | public enum ExpandingBinState | ||
485 | 25 | { | ||
486 | 26 | CLOSED, | ||
487 | 27 | UNEXPANDED, | ||
488 | 28 | EXPANDED | ||
489 | 29 | } | ||
490 | 30 | |||
491 | 31 | public class ExpandingBin : Ctk.Bin | ||
492 | 32 | { | ||
493 | 33 | public static const int ANIMATION_TIME = 200; | ||
494 | 34 | /* | ||
495 | 35 | * Properties | ||
496 | 36 | */ | ||
497 | 37 | public float size_factor { | ||
498 | 38 | get { return _size_factor; } | ||
499 | 39 | set { _size_factor = value; queue_relayout (); } | ||
500 | 40 | } | ||
501 | 41 | |||
502 | 42 | public ExpandingBinState bin_state { | ||
503 | 43 | get { return _state; } | ||
504 | 44 | set { _change_state (value); } | ||
505 | 45 | } | ||
506 | 46 | |||
507 | 47 | public float unexpanded_height { | ||
508 | 48 | get { return _unexpanded_height; } | ||
509 | 49 | set { | ||
510 | 50 | if (_unexpanded_height != value) | ||
511 | 51 | { | ||
512 | 52 | _unexpanded_height = value; | ||
513 | 53 | |||
514 | 54 | if (_state == ExpandingBinState.UNEXPANDED) | ||
515 | 55 | { | ||
516 | 56 | _state = ExpandingBinState.CLOSED; | ||
517 | 57 | _change_state (ExpandingBinState.UNEXPANDED); | ||
518 | 58 | } | ||
519 | 59 | } | ||
520 | 60 | } | ||
521 | 61 | } | ||
522 | 62 | |||
523 | 63 | private float _size_factor = 0.0f; | ||
524 | 64 | private ExpandingBinState _state = ExpandingBinState.CLOSED; | ||
525 | 65 | private ExpandingBinState _old_state = ExpandingBinState.CLOSED; | ||
526 | 66 | private float _unexpanded_height = 100.0f; | ||
527 | 67 | private float _expanded_height = 0.0f; | ||
528 | 68 | private float _target_height = 0.0f; | ||
529 | 69 | |||
530 | 70 | private float last_height; | ||
531 | 71 | private float last_width; | ||
532 | 72 | |||
533 | 73 | /* | ||
534 | 74 | * Construction | ||
535 | 75 | */ | ||
536 | 76 | public ExpandingBin () | ||
537 | 77 | { | ||
538 | 78 | Object (); | ||
539 | 79 | } | ||
540 | 80 | |||
541 | 81 | construct | ||
542 | 82 | { | ||
543 | 83 | } | ||
544 | 84 | |||
545 | 85 | /* | ||
546 | 86 | * Private Methods | ||
547 | 87 | */ | ||
548 | 88 | private override void allocate (Clutter.ActorBox box, | ||
549 | 89 | Clutter.AllocationFlags flags) | ||
550 | 90 | { | ||
551 | 91 | float x = padding.left; | ||
552 | 92 | float y = padding.top; | ||
553 | 93 | float width = Math.floorf (box.x2 - box.x1) - padding.left - padding.right; | ||
554 | 94 | Clutter.ActorBox child_box = Clutter.ActorBox (); | ||
555 | 95 | child_box.x1 = x; | ||
556 | 96 | child_box.x2 = x + width; | ||
557 | 97 | child_box.y1 = y; | ||
558 | 98 | child_box.y2 = y + last_height + ((_target_height - last_height) * _size_factor); | ||
559 | 99 | |||
560 | 100 | base.allocate (box, flags); | ||
561 | 101 | get_child ().allocate (child_box, flags); | ||
562 | 102 | |||
563 | 103 | last_height = child_box.y2 - child_box.y1; | ||
564 | 104 | last_width = child_box.x2 - child_box.x1; | ||
565 | 105 | } | ||
566 | 106 | |||
567 | 107 | private override void get_preferred_height (float for_width, | ||
568 | 108 | out float min_height, | ||
569 | 109 | out float nat_height) | ||
570 | 110 | { | ||
571 | 111 | var vpadding = padding.top + padding.bottom; | ||
572 | 112 | |||
573 | 113 | get_child ().get_preferred_height (last_width, null, out _expanded_height); | ||
574 | 114 | if (_state == ExpandingBinState.CLOSED) | ||
575 | 115 | { | ||
576 | 116 | _target_height = 0.0f; | ||
577 | 117 | } | ||
578 | 118 | else if (_state == ExpandingBinState.UNEXPANDED) | ||
579 | 119 | { | ||
580 | 120 | _target_height = _unexpanded_height + vpadding; | ||
581 | 121 | } | ||
582 | 122 | else | ||
583 | 123 | { | ||
584 | 124 | _target_height = _expanded_height + vpadding; | ||
585 | 125 | } | ||
586 | 126 | |||
587 | 127 | min_height = last_height + ((_target_height - last_height) *_size_factor); | ||
588 | 128 | nat_height = last_height + ((_target_height - last_height) *_size_factor); | ||
589 | 129 | } | ||
590 | 130 | |||
591 | 131 | private void _change_state (ExpandingBinState new_state) | ||
592 | 132 | { | ||
593 | 133 | if (_state == new_state) | ||
594 | 134 | return; | ||
595 | 135 | |||
596 | 136 | _old_state = _state; | ||
597 | 137 | _state = new_state; | ||
598 | 138 | |||
599 | 139 | _size_factor = 0.0f; | ||
600 | 140 | switch (_state) | ||
601 | 141 | { | ||
602 | 142 | case ExpandingBinState.CLOSED: | ||
603 | 143 | var anim = animate (Clutter.AnimationMode.EASE_OUT_SINE, ANIMATION_TIME, | ||
604 | 144 | "size_factor", 1.0f, | ||
605 | 145 | "opacity", 0); | ||
606 | 146 | _target_height = 0.0f; | ||
607 | 147 | |||
608 | 148 | anim.completed.connect (() => { | ||
609 | 149 | if (_state == ExpandingBinState.CLOSED) | ||
610 | 150 | hide (); | ||
611 | 151 | }); | ||
612 | 152 | break; | ||
613 | 153 | |||
614 | 154 | case ExpandingBinState.UNEXPANDED: | ||
615 | 155 | animate (_old_state == ExpandingBinState.CLOSED ? Clutter.AnimationMode.EASE_IN_SINE | ||
616 | 156 | : Clutter.AnimationMode.EASE_OUT_SINE, | ||
617 | 157 | ANIMATION_TIME, | ||
618 | 158 | "size_factor", 1.0f, | ||
619 | 159 | "opacity", 255); | ||
620 | 160 | _target_height = _unexpanded_height; | ||
621 | 161 | show (); | ||
622 | 162 | break; | ||
623 | 163 | |||
624 | 164 | case ExpandingBinState.EXPANDED: | ||
625 | 165 | animate (Clutter.AnimationMode.EASE_IN_SINE, ANIMATION_TIME, | ||
626 | 166 | "size_factor", 1.0f, | ||
627 | 167 | "opacity", 255); | ||
628 | 168 | get_child ().get_preferred_height (width, null, out _expanded_height); | ||
629 | 169 | _target_height = _expanded_height; | ||
630 | 170 | show (); | ||
631 | 171 | break; | ||
632 | 172 | |||
633 | 173 | default: | ||
634 | 174 | warning ("ExpandingBinState %d not supported", _state); | ||
635 | 175 | break; | ||
636 | 176 | } | ||
637 | 177 | } | ||
638 | 178 | } | ||
639 | 179 | } | ||
640 | 0 | 180 | ||
641 | === modified file 'unity/unity-pixbuf-cache.vala' | |||
642 | --- unity/unity-pixbuf-cache.vala 2010-07-01 14:02:24 +0000 | |||
643 | +++ unity/unity-pixbuf-cache.vala 2010-07-07 09:12:51 +0000 | |||
644 | @@ -157,36 +157,50 @@ | |||
645 | 157 | 157 | ||
646 | 158 | if (ret == null) | 158 | if (ret == null) |
647 | 159 | { | 159 | { |
665 | 160 | try { | 160 | if (gicon_as_string[0] == '/') |
666 | 161 | unowned GLib.Icon icon = GLib.Icon.new_for_string (gicon_as_string); | 161 | { |
667 | 162 | var info = theme.lookup_by_gicon (icon, size, 0); | 162 | try { |
668 | 163 | if (info != null) | 163 | ret = new Gdk.Pixbuf.from_file (gicon_as_string); |
669 | 164 | ret = info.load_icon (); | 164 | } catch (Error err) { |
670 | 165 | 165 | message (@"Unable to load $gicon_as_string as file: %s", | |
671 | 166 | if (ret == null) | 166 | err.message); |
672 | 167 | { | 167 | } |
673 | 168 | /* There is some funkiness in some programs where they install | 168 | } |
674 | 169 | * their icon to /usr/share/icons/hicolor/apps/, but they | 169 | |
675 | 170 | * name the Icon= key as `foo.$extension` which breaks loading | 170 | if (ret == null) |
676 | 171 | * So we can try and work around that here. | 171 | { |
677 | 172 | */ | 172 | try { |
678 | 173 | if (gicon_as_string.has_suffix (".png") | 173 | unowned GLib.Icon icon = GLib.Icon.new_for_string (gicon_as_string); |
679 | 174 | || gicon_as_string.has_suffix (".xpm") | 174 | var info = theme.lookup_by_gicon (icon, size, 0); |
680 | 175 | || gicon_as_string.has_suffix (".gir") | 175 | if (info != null) |
681 | 176 | || gicon_as_string.has_suffix (".jpg")) | 176 | ret = info.load_icon (); |
682 | 177 | |||
683 | 178 | if (ret == null) | ||
684 | 177 | { | 179 | { |
687 | 178 | string real_name = gicon_as_string[0:gicon_as_string.length-4]; | 180 | /* There is some funkiness in some programs where they install |
688 | 179 | ret = theme.load_icon (real_name, size, 0); | 181 | * their icon to /usr/share/icons/hicolor/apps/, but they |
689 | 182 | * name the Icon= key as `foo.$extension` which breaks loading | ||
690 | 183 | * So we can try and work around that here. | ||
691 | 184 | */ | ||
692 | 185 | if (gicon_as_string.has_suffix (".png") | ||
693 | 186 | || gicon_as_string.has_suffix (".xpm") | ||
694 | 187 | || gicon_as_string.has_suffix (".gir") | ||
695 | 188 | || gicon_as_string.has_suffix (".jpg")) | ||
696 | 189 | { | ||
697 | 190 | string real_name = gicon_as_string[0:gicon_as_string.length-4]; | ||
698 | 191 | ret = theme.load_icon (real_name, size, 0); | ||
699 | 192 | } | ||
700 | 180 | } | 193 | } |
710 | 181 | } | 194 | |
711 | 182 | 195 | } catch (Error e) { | |
712 | 183 | if (ret is Pixbuf) | 196 | warning (@"Unable to load icon $gicon_as_string: '%s'", e.message); |
713 | 184 | { | 197 | } |
714 | 185 | cache[key] = ret; | 198 | } |
715 | 186 | } | 199 | |
716 | 187 | } catch (Error e) { | 200 | if (ret is Pixbuf) |
717 | 188 | warning (@"Unable to load icon $gicon_as_string: '%s'", e.message); | 201 | { |
718 | 189 | } | 202 | cache[key] = ret; |
719 | 203 | } | ||
720 | 190 | } | 204 | } |
721 | 191 | 205 | ||
722 | 192 | if (ret is Pixbuf) | 206 | if (ret is Pixbuf) |
723 | 193 | 207 | ||
724 | === modified file 'vapi/clutk-0.3.vapi' | |||
725 | --- vapi/clutk-0.3.vapi 2010-03-25 13:26:16 +0000 | |||
726 | +++ vapi/clutk-0.3.vapi 2010-07-07 09:12:51 +0000 | |||
727 | @@ -162,8 +162,14 @@ | |||
728 | 162 | public class IconView : Ctk.Actor, Clutter.Scriptable, Ctk.Focusable, Clutter.Container { | 162 | public class IconView : Ctk.Actor, Clutter.Scriptable, Ctk.Focusable, Clutter.Container { |
729 | 163 | [CCode (type = "ClutterActor*", has_construct_function = false)] | 163 | [CCode (type = "ClutterActor*", has_construct_function = false)] |
730 | 164 | public IconView (); | 164 | public IconView (); |
731 | 165 | public uint get_n_cols (); | ||
732 | 166 | public uint get_n_rows (); | ||
733 | 165 | public int get_spacing (); | 167 | public int get_spacing (); |
734 | 166 | public void set_spacing (int spacing); | 168 | public void set_spacing (int spacing); |
735 | 169 | [NoAccessorMethod] | ||
736 | 170 | public bool auto_fade_children { get; set construct; } | ||
737 | 171 | public uint n_cols { get; } | ||
738 | 172 | public uint n_rows { get; } | ||
739 | 167 | public int spacing { get; set construct; } | 173 | public int spacing { get; set construct; } |
740 | 168 | } | 174 | } |
741 | 169 | [CCode (cheader_filename = "clutk/clutk.h")] | 175 | [CCode (cheader_filename = "clutk/clutk.h")] |
The clutk branch has been merged into trunk, so just grab lp:clutk to test this work