Merge lp:~unity-team/unity/unity.sprint-fixes into lp:unity
- unity.sprint-fixes
- Merge into trunk
Proposed by
Gord Allott
Status: | Merged |
---|---|
Merged at revision: | 392 |
Proposed branch: | lp:~unity-team/unity/unity.sprint-fixes |
Merge into: | lp:unity |
Diff against target: |
2485 lines (+955/-886) 17 files modified
targets/mutter/expose-manager.vala (+37/-79) targets/mutter/plugin.vala (+10/-33) targets/mutter/spaces-manager.vala (+68/-2) tests/unit/test-launcher.vala (+0/-3) unity-private/Makefile.am (+0/-1) unity-private/launcher/application-controller.vala (+46/-128) unity-private/launcher/launcher-child.vala (+0/-571) unity-private/launcher/launcher.vala (+2/-1) unity-private/launcher/quicklist-controller.vala (+8/-1) unity-private/launcher/scroller-controller.vala (+73/-40) unity-private/launcher/scroller-model.vala (+1/-0) unity-private/launcher/scroller-view.vala (+40/-10) unity-private/launcher/scrollerchild-controller.vala (+109/-7) unity-private/launcher/scrollerchild.vala (+548/-7) unity/drag-controller.vala (+3/-1) unity/drag-view.vala (+2/-1) unity/icon-postprocessor.vala (+8/-1) |
To merge this branch: | bzr merge lp:~unity-team/unity/unity.sprint-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2010-07-22.
Commit message
Description of the change
bunch of fixes from the sprint
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'targets/mutter/expose-manager.vala' |
2 | --- targets/mutter/expose-manager.vala 2010-07-19 09:12:30 +0000 |
3 | +++ targets/mutter/expose-manager.vala 2010-07-22 16:19:42 +0000 |
4 | @@ -25,6 +25,8 @@ |
5 | private Clutter.Clone clone; |
6 | private Clutter.Actor darken_box; |
7 | private bool hovered; |
8 | + |
9 | + public bool fade_on_close { get; set; } |
10 | |
11 | public unowned Clutter.Actor source { get; private set; } |
12 | |
13 | @@ -48,7 +50,7 @@ |
14 | unhovered_opacity = 255; |
15 | |
16 | this.source = source; |
17 | - |
18 | + |
19 | if (source is Mutter.Window) |
20 | clone = new Clutter.Clone ((source as Mutter.Window).get_texture ()); |
21 | else |
22 | @@ -90,6 +92,33 @@ |
23 | darken_box.opacity = darken; |
24 | return false; |
25 | } |
26 | + |
27 | + public void restore_window_position (int active_workspace) |
28 | + { |
29 | + set_anchor_point_from_gravity (Clutter.Gravity.NORTH_WEST); |
30 | + Clutter.Actor window = source; |
31 | + |
32 | + uint8 opacity = 0; |
33 | + if (!fade_on_close || (window is Mutter.Window && (window as Mutter.Window).showing_on_its_workspace () && |
34 | + (window as Mutter.Window).get_workspace () == active_workspace)) |
35 | + opacity = 255; |
36 | + |
37 | + |
38 | + set ("scale-gravity", Clutter.Gravity.CENTER); |
39 | + Clutter.Animation anim = animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, |
40 | + "scale-x", 1f, |
41 | + "scale-y", 1f, |
42 | + "opacity", opacity, |
43 | + "x", window.x, |
44 | + "y", window.y); |
45 | + |
46 | + window.opacity = 0; |
47 | + |
48 | + anim.completed.connect (() => { |
49 | + destroy (); |
50 | + window.opacity = 255; |
51 | + }); |
52 | + } |
53 | } |
54 | |
55 | public class ExposeManager : Object |
56 | @@ -117,7 +146,6 @@ |
57 | |
58 | private ExposeClone? last_selected_clone = null; |
59 | |
60 | - private bool menu_in_hover_close_state = false; |
61 | |
62 | public ExposeManager (Plugin plugin, Launcher.Launcher launcher) |
63 | { |
64 | @@ -137,12 +165,6 @@ |
65 | |
66 | public void start_expose (SList<Clutter.Actor> windows) |
67 | { |
68 | - var controller = Launcher.QuicklistController.get_current_menu (); |
69 | - if (controller.is_menu_open ()) |
70 | - { |
71 | - controller.get_view ().destroy.connect (this.end_expose); |
72 | - this.menu_in_hover_close_state = controller.get_view ().get_close_on_leave (); |
73 | - } |
74 | exposed_windows = new List<ExposeClone> (); |
75 | |
76 | if (expose_group != null) |
77 | @@ -164,6 +186,7 @@ |
78 | continue; |
79 | |
80 | ExposeClone clone = new ExposeClone (actor); |
81 | + clone.fade_on_close = true; |
82 | clone.set_position (actor.x, actor.y); |
83 | clone.set_size (actor.width, actor.height); |
84 | exposed_windows.append (clone); |
85 | @@ -175,26 +198,6 @@ |
86 | clone.unhovered_opacity = unhovered_opacity; |
87 | clone.opacity = unhovered_opacity; |
88 | clone.darken = darken; |
89 | - |
90 | - clone.enter_event.connect (() => { |
91 | - var ql_controller = Launcher.QuicklistController.get_current_menu (); |
92 | - if (ql_controller.state == Launcher.QuicklistControllerState.MENU |
93 | - && this.menu_in_hover_close_state) |
94 | - { |
95 | - ql_controller.get_view ().set_close_on_leave (false); |
96 | - } |
97 | - return false; |
98 | - }); |
99 | - |
100 | - clone.leave_event.connect (() => { |
101 | - var ql_controller = Launcher.QuicklistController.get_current_menu (); |
102 | - if (ql_controller.state == Launcher.QuicklistControllerState.MENU |
103 | - && this.menu_in_hover_close_state) |
104 | - { |
105 | - ql_controller.get_view ().set_close_on_leave (true); |
106 | - } |
107 | - return false; |
108 | - }); |
109 | } |
110 | |
111 | unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows (); |
112 | @@ -211,7 +214,7 @@ |
113 | if (coverflow) |
114 | position_windows_coverflow (exposed_windows, exposed_windows.nth_data (coverflow_index)); |
115 | else |
116 | - position_windows_on_grid (exposed_windows); |
117 | + position_windows_on_grid (exposed_windows, top_buffer, left_buffer, right_buffer, bottom_buffer); |
118 | |
119 | expose_showing = true; |
120 | |
121 | @@ -223,13 +226,6 @@ |
122 | { |
123 | if (!expose_showing) |
124 | return; |
125 | - |
126 | - var controller = Launcher.QuicklistController.get_current_menu (); |
127 | - if (controller.is_menu_open ()) |
128 | - { |
129 | - controller.get_view ().destroy.disconnect (this.end_expose); |
130 | - controller.state = Launcher.QuicklistControllerState.CLOSED; |
131 | - } |
132 | |
133 | unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows (); |
134 | foreach (Mutter.Window window in mutter_windows) |
135 | @@ -249,8 +245,8 @@ |
136 | window.reactive = true; |
137 | } |
138 | |
139 | - foreach (Clutter.Actor actor in exposed_windows) |
140 | - restore_window_position (actor); |
141 | + foreach (ExposeClone actor in exposed_windows) |
142 | + actor.restore_window_position (Mutter.MetaScreen.get_active_workspace_index (owner.plugin.get_screen ())); |
143 | |
144 | if (this.last_selected_clone is ExposeClone && |
145 | this.last_selected_clone.source is Mutter.Window) |
146 | @@ -355,7 +351,7 @@ |
147 | return 0; |
148 | } |
149 | |
150 | - void position_windows_on_grid (List<Clutter.Actor> _windows) |
151 | + public void position_windows_on_grid (List<Clutter.Actor> _windows, int top_buffer, int left_buffer, int right_buffer, int bottom_buffer) |
152 | { |
153 | List<Clutter.Actor> windows = _windows.copy (); |
154 | windows.sort ((CompareFunc) direct_comparison); |
155 | @@ -426,34 +422,6 @@ |
156 | } |
157 | } |
158 | |
159 | - private void restore_window_position (Clutter.Actor actor) |
160 | - { |
161 | - if (!(actor is ExposeClone)) |
162 | - return; |
163 | - |
164 | - actor.set_anchor_point_from_gravity (Clutter.Gravity.NORTH_WEST); |
165 | - Clutter.Actor window = (actor as ExposeClone).source; |
166 | - |
167 | - uint8 opacity = 0; |
168 | - if ((window as Mutter.Window).showing_on_its_workspace () && |
169 | - (window as Mutter.Window).get_workspace () == Mutter.MetaScreen.get_active_workspace_index (owner.plugin.get_screen ())) |
170 | - opacity = 255; |
171 | - |
172 | - actor.set ("scale-gravity", Clutter.Gravity.CENTER); |
173 | - Clutter.Animation anim = actor.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, |
174 | - "scale-x", 1f, |
175 | - "scale-y", 1f, |
176 | - "opacity", opacity, |
177 | - "x", window.x, |
178 | - "y", window.y); |
179 | - |
180 | - window.opacity = 0; |
181 | - |
182 | - anim.completed.connect (() => { |
183 | - actor.destroy (); |
184 | - window.opacity = 255; |
185 | - }); |
186 | - } |
187 | |
188 | void handle_event_coverflow (Clutter.Event event) |
189 | { |
190 | @@ -524,23 +492,13 @@ |
191 | if (event.type == Clutter.EventType.ENTER || event.type == Clutter.EventType.LEAVE) |
192 | return false; |
193 | |
194 | - bool event_over_menu = false; |
195 | |
196 | float x, y; |
197 | event.get_coords (out x, out y); |
198 | |
199 | unowned Clutter.Actor actor = this.stage.get_actor_at_pos (Clutter.PickMode.REACTIVE, (int) x, (int) y); |
200 | |
201 | - Clutter.Actor? menu = null; |
202 | - if (Unity.Launcher.QuicklistController.get_current_menu ().is_menu_open ()) |
203 | - menu = Unity.Launcher.QuicklistController.get_current_menu ().get_view (); |
204 | - if (menu != null) |
205 | - { |
206 | - if (x > menu.x && x < menu.x + menu.width && y > menu.y && y < menu.y + menu.height) |
207 | - event_over_menu = true; |
208 | - } |
209 | - |
210 | - if (event.type == Clutter.EventType.BUTTON_PRESS && !event_over_menu) |
211 | + if (event.type == Clutter.EventType.BUTTON_PRESS) |
212 | pick_window (event, actor); |
213 | |
214 | if (coverflow) |
215 | @@ -548,7 +506,7 @@ |
216 | else |
217 | handle_event_expose (event, actor); |
218 | |
219 | - return !event_over_menu; |
220 | + return true; |
221 | } |
222 | } |
223 | } |
224 | |
225 | === modified file 'targets/mutter/plugin.vala' |
226 | --- targets/mutter/plugin.vala 2010-07-16 08:43:18 +0000 |
227 | +++ targets/mutter/plugin.vala 2010-07-22 16:19:42 +0000 |
228 | @@ -107,6 +107,8 @@ |
229 | set { _plugin = value; Idle.add (real_construct); } |
230 | } |
231 | |
232 | + public ExposeManager expose_manager { get; private set; } |
233 | + |
234 | public bool menus_swallow_events { get { return false; } } |
235 | |
236 | public bool expose_showing { get { return expose_manager.expose_showing; } } |
237 | @@ -121,7 +123,6 @@ |
238 | |
239 | /* Unity Components */ |
240 | private Background background; |
241 | - private ExposeManager expose_manager; |
242 | private SpacesManager spaces_manager; |
243 | private Launcher.Launcher launcher; |
244 | private Places.Controller places_controller; |
245 | @@ -243,6 +244,13 @@ |
246 | this.spaces_manager = new SpacesManager (this); |
247 | this.spaces_manager.set_padding (50, 50, 125, 50); |
248 | |
249 | + this.launcher.model.add (spaces_manager.button); |
250 | + this.launcher.model.order_changed.connect (() => { |
251 | + var index = launcher.model.index_of (spaces_manager.button); |
252 | + if (index < launcher.model.size) |
253 | + launcher.model.move (spaces_manager.button, launcher.model.size -1); |
254 | + }); |
255 | + |
256 | this.expose_manager = new ExposeManager (this, launcher); |
257 | this.expose_manager.hovered_opacity = 255; |
258 | this.expose_manager.unhovered_opacity = 255; |
259 | @@ -308,7 +316,6 @@ |
260 | |
261 | private void on_focus_window_fullscreen_changed () |
262 | { |
263 | - warning ("FOCUS WINDOW FULLSCREEN CHANGED"); |
264 | check_fullscreen_obstruction (); |
265 | } |
266 | |
267 | @@ -466,32 +473,6 @@ |
268 | /* |
269 | * SHELL IMPLEMENTATION |
270 | */ |
271 | - |
272 | - /* |
273 | - public void show_window_picker () |
274 | - { |
275 | - this.show_unity (); |
276 | - return; |
277 | - } |
278 | - |
279 | - if (expose_manager.expose_showing == true) |
280 | - { |
281 | - this.dexpose_windows (); |
282 | - return; |
283 | - } |
284 | - |
285 | - GLib.SList <Clutter.Actor> windows = null; |
286 | - |
287 | - unowned GLib.List<Mutter.Window> mutter_windows = this.plugin.get_windows (); |
288 | - foreach (Mutter.Window window in mutter_windows) |
289 | - { |
290 | - windows.append (window as Clutter.Actor); |
291 | - } |
292 | - |
293 | - this.expose_windows (windows, 80); |
294 | - } |
295 | - */ |
296 | - |
297 | public Clutter.Stage get_stage () |
298 | { |
299 | return this.stage; |
300 | @@ -539,7 +520,7 @@ |
301 | |
302 | public void stop_expose () |
303 | { |
304 | - dexpose_windows (); |
305 | + expose_manager.end_expose (); |
306 | } |
307 | |
308 | public void show_window (uint32 xid) |
309 | @@ -585,10 +566,6 @@ |
310 | expose_manager.start_expose (windows); |
311 | } |
312 | |
313 | - public void dexpose_windows () |
314 | - { |
315 | - expose_manager.end_expose (); |
316 | - } |
317 | |
318 | public void hide_unity () |
319 | { |
320 | |
321 | === modified file 'targets/mutter/spaces-manager.vala' |
322 | --- targets/mutter/spaces-manager.vala 2010-06-21 21:44:09 +0000 |
323 | +++ targets/mutter/spaces-manager.vala 2010-07-22 16:19:42 +0000 |
324 | @@ -17,14 +17,52 @@ |
325 | * |
326 | */ |
327 | |
328 | +using Unity.Launcher; |
329 | + |
330 | namespace Unity { |
331 | |
332 | + public class SpacesButtonController : ScrollerChildController |
333 | + { |
334 | + SpacesManager parent { get; set; } |
335 | + |
336 | + public SpacesButtonController (SpacesManager _parent, ScrollerChild _child) |
337 | + { |
338 | + Object (child: _child); |
339 | + this.parent = _parent; |
340 | + |
341 | + name = "Workspace Overview"; |
342 | + load_icon_from_icon_name ("workspace-switcher"); |
343 | + } |
344 | + |
345 | + construct |
346 | + { |
347 | + } |
348 | + |
349 | + public override void activate () |
350 | + { |
351 | + parent.show_spaces_picker (); |
352 | + } |
353 | + } |
354 | + |
355 | public class SpacesManager : GLib.Object |
356 | { |
357 | Clutter.Actor background; |
358 | List<Clutter.Actor> clones; |
359 | Plugin plugin; |
360 | unowned Mutter.MetaScreen screen; |
361 | + ScrollerChild _button; |
362 | + SpacesButtonController controller; |
363 | + |
364 | + public ScrollerChild button { |
365 | + get { |
366 | + if (!(_button is ScrollerChild)) |
367 | + { |
368 | + _button = new ScrollerChild (); |
369 | + controller = new SpacesButtonController (this, _button); |
370 | + } |
371 | + return _button; |
372 | + } |
373 | + } |
374 | |
375 | public uint top_padding { get; set; } |
376 | public uint right_padding { get; set; } |
377 | @@ -114,17 +152,29 @@ |
378 | |
379 | private Clutter.Actor workspace_clone (Mutter.MetaWorkspace workspace) { |
380 | Clutter.Group wsp; |
381 | - unowned GLib.List<Mutter.Window> windows = plugin.plugin.get_windows (); |
382 | + GLib.List<weak Mutter.Window> windows = (GLib.List<weak Mutter.Window>) plugin.plugin.get_windows ().copy (); |
383 | |
384 | wsp = new Clutter.Group (); |
385 | |
386 | + List<Clutter.Actor> toplevel_windows = new List<Clutter.Actor> (); |
387 | + |
388 | + int active_workspace = Mutter.MetaScreen.get_active_workspace_index (plugin.plugin.get_screen ()); |
389 | + |
390 | + Clutter.Actor last = null, wspclone = null; |
391 | + |
392 | foreach (Mutter.Window window in windows) |
393 | { |
394 | if (Mutter.MetaWindow.is_on_all_workspaces (window.get_meta_window ()) || |
395 | window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP || |
396 | window.get_workspace () == Mutter.MetaWorkspace.index (workspace)) |
397 | { |
398 | - Clutter.Actor clone = new Clutter.Clone (window); |
399 | + |
400 | + if (window.get_window_type () == Mutter.MetaCompWindowType.DOCK) |
401 | + continue; |
402 | + |
403 | + ExposeClone clone = new ExposeClone (window); |
404 | + clone.fade_on_close = false; |
405 | + |
406 | wsp.add_actor (clone); |
407 | |
408 | clone.set_size (window.width, window.height); |
409 | @@ -134,10 +184,21 @@ |
410 | |
411 | if (window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP) |
412 | { |
413 | + wspclone = clone; |
414 | clone.lower_bottom (); |
415 | } |
416 | + else |
417 | + { |
418 | + last = clone; |
419 | + toplevel_windows.prepend (clone); |
420 | + } |
421 | } |
422 | } |
423 | + |
424 | + if (last != null && wspclone != null && active_workspace != Mutter.MetaWorkspace.index (workspace)) |
425 | + last.raise (wspclone); |
426 | + |
427 | + plugin.expose_manager.position_windows_on_grid (toplevel_windows, 50, 50, 50, 50); |
428 | |
429 | return wsp; |
430 | } |
431 | @@ -170,6 +231,11 @@ |
432 | "scale-x", 1.0f, |
433 | "scale-y", 1.0f); |
434 | |
435 | + int active_workspace = Mutter.MetaScreen.get_active_workspace_index (plugin.plugin.get_screen ()); |
436 | + foreach (Clutter.Actor actor in (clone as Clutter.Group).get_children ()) |
437 | + if (actor is ExposeClone) |
438 | + (actor as ExposeClone).restore_window_position (active_workspace); |
439 | + |
440 | anim.completed.connect (() => { |
441 | clone.destroy (); |
442 | if (background != null) |
443 | |
444 | === modified file 'tests/unit/test-launcher.vala' |
445 | --- tests/unit/test-launcher.vala 2010-07-15 13:19:02 +0000 |
446 | +++ tests/unit/test-launcher.vala 2010-07-22 16:19:42 +0000 |
447 | @@ -141,9 +141,6 @@ |
448 | |
449 | public class TestScrollerChild : ScrollerChild |
450 | { |
451 | - public override void force_rotation_jump (float degrees) |
452 | - { |
453 | - } |
454 | } |
455 | |
456 | public class LauncherSuite |
457 | |
458 | === modified file 'unity-private/Makefile.am' |
459 | --- unity-private/Makefile.am 2010-07-16 08:43:18 +0000 |
460 | +++ unity-private/Makefile.am 2010-07-22 16:19:42 +0000 |
461 | @@ -105,7 +105,6 @@ |
462 | launcher_sources = \ |
463 | launcher/application-controller.vala \ |
464 | launcher/launcher.vala \ |
465 | - launcher/launcher-child.vala \ |
466 | launcher/quicklist-check-menu-item.vala \ |
467 | launcher/quicklist-controller.vala \ |
468 | launcher/quicklist-image-menu-item.vala \ |
469 | |
470 | === modified file 'unity-private/launcher/application-controller.vala' |
471 | --- unity-private/launcher/application-controller.vala 2010-07-22 09:06:10 +0000 |
472 | +++ unity-private/launcher/application-controller.vala 2010-07-22 16:19:42 +0000 |
473 | @@ -33,7 +33,6 @@ |
474 | |
475 | private KeyFile desktop_keyfile; |
476 | private string icon_name; |
477 | - private Unity.ThemeFilePath theme_file_path; |
478 | private Bamf.Application? app = null; |
479 | private Dbusmenu.Client menu_client; |
480 | private Dbusmenu.Menuitem cached_menu; |
481 | @@ -58,25 +57,16 @@ |
482 | |
483 | construct |
484 | { |
485 | - theme_file_path = new Unity.ThemeFilePath (); |
486 | var favorites = Unity.Favorites.get_default (); |
487 | favorites.favorite_added.connect (on_favorite_added); |
488 | favorites.favorite_removed.connect (on_favorite_removed); |
489 | |
490 | - // we need to figure out if we are a favorite |
491 | - is_favorite = true; |
492 | + // we need to figure out if we are a favoritem |
493 | + |
494 | + is_favorite = is_sticky (); |
495 | child.pin_type = PinType.UNPINNED; |
496 | - foreach (string uid in favorites.get_favorites ()) |
497 | - { |
498 | - if (favorites.get_string (uid, "desktop_file") == desktop_file) |
499 | - { |
500 | - is_favorite = true; |
501 | - child.pin_type = PinType.PINNED; |
502 | - break; |
503 | - } |
504 | - } |
505 | - |
506 | - notify["menu"].connect (on_notify_menu); |
507 | + if (is_sticky ()) |
508 | + child.pin_type = PinType.PINNED; |
509 | } |
510 | |
511 | public override QuicklistController get_menu_controller () |
512 | @@ -85,28 +75,19 @@ |
513 | return new_menu; |
514 | } |
515 | |
516 | - private void on_notify_menu () |
517 | - { |
518 | - menu.notify["state"].connect (() => { |
519 | - if (menu.state == QuicklistControllerState.MENU) |
520 | - { |
521 | - Unity.global_shell.expose_xids (app.get_xids ()); |
522 | - } |
523 | - else |
524 | - { |
525 | - Unity.global_shell.stop_expose (); |
526 | - } |
527 | - }); |
528 | - } |
529 | - |
530 | public void set_sticky (bool is_sticky = true) |
531 | { |
532 | if (desktop_file == "" || desktop_file == null) |
533 | return; |
534 | - //string uid = "app-" + Path.get_basename (desktop_file); |
535 | + |
536 | var favorites = Unity.Favorites.get_default (); |
537 | |
538 | string uid = favorites.find_uid_for_desktop_file (desktop_file); |
539 | + if (uid == "" || uid == null) |
540 | + { |
541 | + var filepath = desktop_file.split ("/"); |
542 | + uid = "app-" + filepath[filepath.length - 1]; |
543 | + } |
544 | |
545 | if (is_sticky) |
546 | { |
547 | @@ -127,10 +108,10 @@ |
548 | |
549 | var favorites = Unity.Favorites.get_default (); |
550 | string uid = favorites.find_uid_for_desktop_file (desktop_file); |
551 | - if (uid != null && uid != "") |
552 | + if (uid == null || uid == "") |
553 | + return false; |
554 | + else |
555 | return true; |
556 | - else |
557 | - return false; |
558 | } |
559 | |
560 | public void close_windows () |
561 | @@ -188,15 +169,17 @@ |
562 | } |
563 | } |
564 | |
565 | +/* |
566 | + private get_menu_for_client (ScrollerChildController.menu_cb callback, Dbusmenu.Client client) |
567 | + { |
568 | + |
569 | + } |
570 | +*/ |
571 | + |
572 | public override void get_menu_actions (ScrollerChildController.menu_cb callback) |
573 | { |
574 | |
575 | // first check to see if we have a cached client, if we do, just re-use that |
576 | - if (menu_client is Dbusmenu.Client && cached_menu is Dbusmenu.Menuitem) |
577 | - { |
578 | - callback (cached_menu); |
579 | - } |
580 | - |
581 | // check for a menu from bamf |
582 | if (app is Bamf.Application) |
583 | { |
584 | @@ -279,13 +262,19 @@ |
585 | Dbusmenu.Menuitem root = new Dbusmenu.Menuitem (); |
586 | root.set_root (true); |
587 | |
588 | - if (desktop_file != null) |
589 | + if (desktop_file != null && desktop_file != "") |
590 | { |
591 | Dbusmenu.Menuitem pinning_item = new Dbusmenu.Menuitem (); |
592 | - if (is_sticky ()) |
593 | - pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Remove from launcher")); |
594 | - else |
595 | - pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Add to launcher")); |
596 | + if (is_sticky () && app is Bamf.Application) |
597 | + { |
598 | + pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Keep in Launcher")); |
599 | + pinning_item.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_CHECK); |
600 | + pinning_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); |
601 | + } |
602 | + else if (is_sticky ()) |
603 | + { |
604 | + pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Remove from launcher")); |
605 | + } |
606 | |
607 | pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
608 | pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
609 | @@ -317,6 +306,8 @@ |
610 | } |
611 | |
612 | private static int order_app_windows (void* a, void* b) |
613 | + requires (a is Bamf.Window) |
614 | + requires (b is Bamf.Window) |
615 | { |
616 | if ((b as Bamf.Window).last_active () > (a as Bamf.Window).last_active ()) |
617 | { |
618 | @@ -337,7 +328,12 @@ |
619 | |
620 | if (app is Bamf.Application) |
621 | { |
622 | - if (app.is_running ()) |
623 | + if (app.is_active ()) |
624 | + { |
625 | + Array<uint32> xids = app.get_xids (); |
626 | + global_shell.expose_xids (xids); |
627 | + } |
628 | + else if (app.is_running ()) |
629 | { |
630 | unowned List<Bamf.Window> windows = app.get_windows (); |
631 | windows.sort ((CompareFunc)order_app_windows); |
632 | @@ -375,7 +371,7 @@ |
633 | public void attach_application (Bamf.Application application) |
634 | { |
635 | app = application; |
636 | - desktop_file = app.get_desktop_file (); |
637 | + desktop_file = app.get_desktop_file ().dup (); |
638 | child.running = app.is_running (); |
639 | child.active = app.is_active (); |
640 | child.activating = false; |
641 | @@ -384,12 +380,15 @@ |
642 | app.active_changed.connect (on_app_active_changed); |
643 | app.closed.connect (detach_application); |
644 | app.urgent_changed.connect (on_app_urgant_changed); |
645 | + app.user_visible_changed.connect ((value) => { |
646 | + hide = !value; |
647 | + }); |
648 | name = app.get_name (); |
649 | if (name == null || name == "") |
650 | warning (@"Bamf returned null for app.get_name (): $desktop_file"); |
651 | |
652 | icon_name = app.get_icon (); |
653 | - load_icon_from_icon_name (); |
654 | + load_icon_from_icon_name (icon_name); |
655 | } |
656 | |
657 | public void detach_application () |
658 | @@ -444,7 +443,7 @@ |
659 | try |
660 | { |
661 | icon_name = desktop_keyfile.get_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_ICON); |
662 | - load_icon_from_icon_name (); |
663 | + load_icon_from_icon_name (icon_name); |
664 | } |
665 | catch (Error e) |
666 | { |
667 | @@ -468,86 +467,5 @@ |
668 | { |
669 | } |
670 | } |
671 | - |
672 | - /* all this icon loading stuff can go when we switch from liblauncher to |
673 | - * bamf - please ignore any icon loading bugs :-) |
674 | - */ |
675 | - private void load_icon_from_icon_name () |
676 | - { |
677 | - // first try to load from a path; |
678 | - if (try_load_from_file (icon_name)) |
679 | - { |
680 | - return; |
681 | - } |
682 | - |
683 | - //try to load from a path that we augment |
684 | - if (try_load_from_file ("/usr/share/pixmaps/" + icon_name)) |
685 | - { |
686 | - return; |
687 | - } |
688 | - |
689 | - theme_file_path = new Unity.ThemeFilePath (); |
690 | - |
691 | - // add our searchable themes |
692 | - Gtk.IconTheme theme = Gtk.IconTheme.get_default (); |
693 | - theme_file_path.add_icon_theme (theme); |
694 | - theme = new Gtk.IconTheme (); |
695 | - |
696 | - theme.set_custom_theme ("unity-icon-theme"); |
697 | - theme_file_path.add_icon_theme (theme); |
698 | - theme.set_custom_theme ("Web"); |
699 | - theme_file_path.add_icon_theme (theme); |
700 | - |
701 | - theme_file_path.found_icon_path.connect ((theme, filepath) => { |
702 | - try |
703 | - { |
704 | - child.icon = new Gdk.Pixbuf.from_file (filepath); |
705 | - } |
706 | - catch (Error e) |
707 | - { |
708 | - warning (@"Could not load from $filepath"); |
709 | - } |
710 | - }); |
711 | - theme_file_path.failed.connect (() => { |
712 | - // we didn't get an icon, so just load the failcon |
713 | - try |
714 | - { |
715 | - var default_theme = Gtk.IconTheme.get_default (); |
716 | - child.icon = default_theme.load_icon(Gtk.STOCK_MISSING_IMAGE, 48, 0); |
717 | - } |
718 | - catch (Error e) |
719 | - { |
720 | - warning (@"Could not load any icon for %s", app.get_name ()); |
721 | - } |
722 | - }); |
723 | - |
724 | - theme_file_path.get_icon_filepath (icon_name); |
725 | - } |
726 | - |
727 | - private bool try_load_from_file (string filepath) |
728 | - { |
729 | - Gdk.Pixbuf pixbuf = null; |
730 | - if (FileUtils.test(filepath, FileTest.IS_REGULAR)) |
731 | - { |
732 | - try |
733 | - { |
734 | - pixbuf = new Gdk.Pixbuf.from_file_at_scale(filepath, |
735 | - 48, 48, true); |
736 | - } |
737 | - catch (Error e) |
738 | - { |
739 | - warning ("Unable to load image from file '%s': %s", |
740 | - filepath, |
741 | - e.message); |
742 | - } |
743 | - |
744 | - if (pixbuf is Gdk.Pixbuf) |
745 | - { |
746 | - child.icon = pixbuf; |
747 | - return true; |
748 | - } |
749 | - } |
750 | - return false; |
751 | - } |
752 | } |
753 | } |
754 | |
755 | === removed file 'unity-private/launcher/launcher-child.vala' |
756 | --- unity-private/launcher/launcher-child.vala 2010-06-22 13:18:52 +0000 |
757 | +++ unity-private/launcher/launcher-child.vala 1970-01-01 00:00:00 +0000 |
758 | @@ -1,571 +0,0 @@ |
759 | -/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ |
760 | -/* |
761 | - * Copyright (C) 2009 Canonical Ltd |
762 | - * |
763 | - * This program is free software: you can redistribute it and/or modify |
764 | - * it under the terms of the GNU General Public License version 3 as |
765 | - * published by the Free Software Foundation. |
766 | - * |
767 | - * This program is distributed in the hope that it will be useful, |
768 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
769 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
770 | - * GNU General Public License for more details. |
771 | - * |
772 | - * You should have received a copy of the GNU General Public License |
773 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
774 | - * |
775 | - * Authored by Gordon Allott <gord.allott@canonical.com> |
776 | - * |
777 | - */ |
778 | - |
779 | -namespace Unity.Launcher |
780 | -{ |
781 | - const string HONEYCOMB_MASK_FILE = Unity.PKGDATADIR |
782 | - + "/honeycomb-mask.png"; |
783 | - const string MENU_BG_FILE = Unity.PKGDATADIR |
784 | - + "/tight_check_4px.png"; |
785 | - |
786 | - const float WIGGLE_SIZE = 5; // how many degree's to wiggle on either side. |
787 | - const int WIGGLE_FREQUENCY = 5; // x times a second |
788 | - const int WIGGLE_RUN_LENGTH = 5000; // 5 seconds of wiggle |
789 | - const int WIGGLE_PAUSE_LENGTH = 20; // followed by 20 seconds of no wiggle |
790 | - |
791 | - private enum AnimState { |
792 | - RISING, |
793 | - LOOPING, |
794 | - FALLING, |
795 | - STOPPED |
796 | - } |
797 | - |
798 | - |
799 | - class LauncherChild : ScrollerChild |
800 | - { |
801 | - private UnityIcon processed_icon; |
802 | - private ThemeImage active_indicator; |
803 | - private ThemeImage running_indicator; |
804 | - private Gdk.Pixbuf honeycomb_mask; |
805 | - |
806 | - // effects |
807 | - private Ctk.EffectDropShadow effect_drop_shadow; |
808 | - private Ctk.EffectGlow effect_icon_glow; |
809 | - |
810 | - // animations |
811 | - private Clutter.Animation active_indicator_anim; |
812 | - private Clutter.Animation running_indicator_anim; |
813 | - private Clutter.Animation rotate_anim; |
814 | - private Clutter.Timeline wiggle_timeline; |
815 | - private Clutter.Timeline glow_timeline; |
816 | - private Clutter.Timeline rotate_timeline; |
817 | - private AnimState glow_state; |
818 | - private AnimState wiggle_state; |
819 | - private AnimState rotate_state; |
820 | - |
821 | - private float old_rotate_value = 0.0f; |
822 | - |
823 | - construct |
824 | - { |
825 | - load_textures (); |
826 | - position = 0.0f; |
827 | - |
828 | - //icon glow |
829 | - glow_timeline = new Clutter.Timeline (1); |
830 | - wiggle_timeline = new Clutter.Timeline (1); |
831 | - rotate_timeline = new Clutter.Timeline (1); |
832 | - |
833 | - glow_timeline.new_frame.connect (on_glow_timeline_new_frame); |
834 | - wiggle_timeline.new_frame.connect (on_wiggle_timeline_new_frame); |
835 | - rotate_timeline.new_frame.connect (on_rotate_timeline_new_frame); |
836 | - |
837 | - notify["rotation"].connect (on_rotation_changed); |
838 | - } |
839 | - |
840 | - ~LauncherChild () |
841 | - { |
842 | - running_indicator.unparent (); |
843 | - active_indicator.unparent (); |
844 | - } |
845 | - |
846 | - /* private methods */ |
847 | - private void load_textures () |
848 | - { |
849 | - active_indicator = new ThemeImage ("application-selected"); |
850 | - running_indicator = new ThemeImage ("application-running"); |
851 | - |
852 | - active_indicator.set_parent (this); |
853 | - running_indicator.set_parent (this); |
854 | - active_indicator.set_opacity (0); |
855 | - running_indicator.set_opacity (0); |
856 | - |
857 | - try |
858 | - { |
859 | - honeycomb_mask = new Gdk.Pixbuf.from_file(HONEYCOMB_MASK_FILE); |
860 | - } |
861 | - catch (Error e) |
862 | - { |
863 | - warning ("Unable to load asset %s: %s", |
864 | - HONEYCOMB_MASK_FILE, |
865 | - e.message); |
866 | - } |
867 | - |
868 | - processed_icon = new UnityIcon (null, null); |
869 | - processed_icon.set_size (48, 48); |
870 | - processed_icon.set_parent (this); |
871 | - |
872 | - notify["icon"].connect (on_icon_changed); |
873 | - notify["running"].connect (on_running_changed); |
874 | - notify["active"].connect (on_active_changed); |
875 | - notify["activating"].connect (on_activating_changed); |
876 | - notify["needs-attention"].connect (on_needs_attention_changed); |
877 | - |
878 | - // just trigger some notifications now to set inital state |
879 | - on_running_changed (); |
880 | - on_active_changed (); |
881 | - on_rotation_changed (); |
882 | - } |
883 | - |
884 | - /* alpha helpers */ |
885 | - private static float get_ease_out_sine (float alpha) |
886 | - { |
887 | - return (float)(Math.sin ((Math.PI_2 * alpha))); |
888 | - } |
889 | - |
890 | - private static float get_circular_alpha (float alpha) |
891 | - { |
892 | - //float sine = (float)(Math.sin (-Math.PI + (alpha * (Math.PI * 2)))); |
893 | - var sine = Math.sin ((alpha * (Math.PI * 2)) - Math.PI); |
894 | - return Math.fmaxf(((float)sine / 2.0f) + 0.5f, 0.0f);; |
895 | - } |
896 | - /* animation callbacks */ |
897 | - |
898 | - private void on_rotate_timeline_new_frame () |
899 | - { |
900 | - float progress = (float)rotate_timeline.get_progress (); |
901 | - switch (rotate_state) |
902 | - { |
903 | - case AnimState.RISING: |
904 | - rotate_anim_rising (progress); |
905 | - break; |
906 | - |
907 | - case AnimState.STOPPED: |
908 | - rotate_timeline.stop (); |
909 | - break; |
910 | - } |
911 | - processed_icon.do_queue_redraw (); |
912 | - } |
913 | - |
914 | - private void rotate_anim_rising (float progress) |
915 | - { |
916 | - progress = get_ease_out_sine (progress); |
917 | - var diff = rotation - old_rotate_value; |
918 | - float rotate_val = old_rotate_value + (progress * diff); |
919 | - |
920 | - processed_icon.rotation = rotate_val; |
921 | - if (progress >= 1.0) |
922 | - { |
923 | - rotate_state = AnimState.STOPPED; |
924 | - rotate_timeline.stop (); |
925 | - } |
926 | - } |
927 | - |
928 | - public override void force_rotation_jump (float degrees) |
929 | - { |
930 | - processed_icon.rotation = degrees; |
931 | - rotation = degrees; |
932 | - rotate_state = AnimState.STOPPED; |
933 | - rotate_timeline.stop (); |
934 | - do_queue_redraw (); |
935 | - } |
936 | - |
937 | - private void on_glow_timeline_new_frame () |
938 | - { |
939 | - float progress = (float)glow_timeline.get_progress (); |
940 | - switch (glow_state) |
941 | - { |
942 | - case AnimState.RISING: |
943 | - glow_anim_rising (progress); |
944 | - break; |
945 | - |
946 | - case AnimState.LOOPING: |
947 | - glow_anim_looping (progress); |
948 | - break; |
949 | - |
950 | - case AnimState.FALLING: |
951 | - glow_anim_falling (progress); |
952 | - break; |
953 | - |
954 | - default: |
955 | - glow_state = AnimState.STOPPED; |
956 | - glow_timeline.stop (); |
957 | - break; |
958 | - } |
959 | - |
960 | - processed_icon.do_queue_redraw (); |
961 | - } |
962 | - |
963 | - private float previous_glow_alpha = 0.0f; |
964 | - private void glow_anim_rising (float progress) |
965 | - { |
966 | - progress = get_ease_out_sine (progress); |
967 | - effect_icon_glow.set_opacity (progress); |
968 | - previous_glow_alpha = progress; |
969 | - if (progress >= 1.0) |
970 | - { |
971 | - glow_state = AnimState.LOOPING; |
972 | - glow_timeline.stop (); |
973 | - glow_timeline.set_duration (LONG_DELAY); |
974 | - glow_timeline.set_loop (true); |
975 | - glow_timeline.start (); |
976 | - return; |
977 | - } |
978 | - } |
979 | - |
980 | - private void glow_anim_looping (float progress) |
981 | - { |
982 | - progress = 1.0f - get_circular_alpha (progress); |
983 | - effect_icon_glow.set_opacity (progress); |
984 | - previous_glow_alpha = progress; |
985 | - processed_icon.do_queue_redraw (); |
986 | - } |
987 | - |
988 | - private void glow_anim_falling (float progress) |
989 | - { |
990 | - float alpha_length = previous_glow_alpha; |
991 | - effect_icon_glow.set_opacity (alpha_length - (progress * alpha_length)); |
992 | - |
993 | - if (progress >= 1.0) |
994 | - { |
995 | - glow_state = AnimState.STOPPED; |
996 | - glow_timeline.stop (); |
997 | - glow_timeline.set_loop (false); |
998 | - } |
999 | - } |
1000 | - |
1001 | - private void on_wiggle_timeline_new_frame () |
1002 | - { |
1003 | - float progress = (float)wiggle_timeline.get_progress (); |
1004 | - |
1005 | - switch (wiggle_state) |
1006 | - { |
1007 | - case AnimState.RISING: |
1008 | - wiggle_anim_rising (progress); |
1009 | - break; |
1010 | - |
1011 | - case AnimState.LOOPING: |
1012 | - wiggle_anim_looping (progress); |
1013 | - break; |
1014 | - |
1015 | - case AnimState.FALLING: |
1016 | - wiggle_anim_falling (progress); |
1017 | - break; |
1018 | - |
1019 | - default: |
1020 | - wiggle_state = AnimState.STOPPED; |
1021 | - wiggle_timeline.stop (); |
1022 | - break; |
1023 | - } |
1024 | - |
1025 | - processed_icon.do_queue_redraw (); |
1026 | - } |
1027 | - |
1028 | - private float previous_wiggle_alpha = 0.0f; |
1029 | - private void wiggle_anim_rising (float progress) |
1030 | - { |
1031 | - progress = get_ease_out_sine (progress); |
1032 | - processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, |
1033 | - 25.0f, 25.0f, 0.0f); |
1034 | - previous_wiggle_alpha = progress; |
1035 | - if (progress >= 1.0) |
1036 | - { |
1037 | - wiggle_state = AnimState.LOOPING; |
1038 | - wiggle_timeline.stop (); |
1039 | - wiggle_timeline.set_duration (WIGGLE_RUN_LENGTH); |
1040 | - wiggle_timeline.set_loop (true); |
1041 | - wiggle_timeline.start (); |
1042 | - return; |
1043 | - } |
1044 | - } |
1045 | - |
1046 | - private void wiggle_anim_looping (float progress) |
1047 | - { |
1048 | - if (progress >= 1.0) |
1049 | - { |
1050 | - wiggle_state = AnimState.FALLING; |
1051 | - wiggle_timeline.stop (); |
1052 | - wiggle_timeline.set_loop (false); |
1053 | - wiggle_timeline.start (); |
1054 | - } |
1055 | - |
1056 | - int frequency = WIGGLE_FREQUENCY * (WIGGLE_RUN_LENGTH / 1000); |
1057 | - progress = get_circular_alpha (Math.fmodf (progress * frequency, 1.0f)); |
1058 | - progress = (1.0f - progress) * 2.0f - 1.0f; |
1059 | - processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, |
1060 | - 25.0f, 25.0f, 0.0f); |
1061 | - processed_icon.do_queue_redraw (); |
1062 | - previous_wiggle_alpha = progress; |
1063 | - |
1064 | - |
1065 | - } |
1066 | - |
1067 | - private bool check_continue_wiggle () |
1068 | - { |
1069 | - if (needs_attention) |
1070 | - { |
1071 | - wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); |
1072 | - wiggle_state = AnimState.RISING; |
1073 | - wiggle_timeline.start (); |
1074 | - } |
1075 | - return false; |
1076 | - } |
1077 | - |
1078 | - private void wiggle_anim_falling (float progress) |
1079 | - { |
1080 | - float alpha_length = previous_wiggle_alpha; |
1081 | - float angle = alpha_length - (progress * alpha_length); |
1082 | - processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, angle, |
1083 | - 25.0f, 25.0f, 0.0f); |
1084 | - |
1085 | - if (progress >= 1.0) |
1086 | - { |
1087 | - wiggle_state = AnimState.STOPPED; |
1088 | - wiggle_timeline.stop (); |
1089 | - wiggle_timeline.set_loop (false); |
1090 | - GLib.Timeout.add_seconds (WIGGLE_PAUSE_LENGTH, check_continue_wiggle); |
1091 | - } |
1092 | - } |
1093 | - |
1094 | - /* notifications */ |
1095 | - private void on_icon_changed () |
1096 | - { |
1097 | - if (icon is Gdk.Pixbuf) |
1098 | - { |
1099 | - Gdk.Pixbuf scaled_buf; |
1100 | - int max_size = 48; |
1101 | - if (!Unity.pixbuf_is_tile (icon)) |
1102 | - max_size = 40; |
1103 | - |
1104 | - if (icon.get_width () > max_size || icon.get_height () > max_size) |
1105 | - { |
1106 | - scaled_buf = icon.scale_simple (max_size, max_size, Gdk.InterpType.HYPER); |
1107 | - } |
1108 | - else |
1109 | - { |
1110 | - scaled_buf = icon; |
1111 | - } |
1112 | - |
1113 | - Gdk.Pixbuf color_buf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 1, 1); |
1114 | - uint red, green, blue; |
1115 | - Unity.get_average_color (scaled_buf, out red, out green, out blue); |
1116 | - unowned uchar[] pixels = color_buf.get_pixels (); |
1117 | - pixels[0] = (uchar)red; |
1118 | - pixels[1] = (uchar)green; |
1119 | - pixels[2] = (uchar)blue; |
1120 | - pixels[3] = 255; |
1121 | - |
1122 | - var tex = GtkClutter.texture_new_from_pixbuf (scaled_buf); |
1123 | - var color = GtkClutter.texture_new_from_pixbuf (color_buf); |
1124 | - |
1125 | - processed_icon = new UnityIcon (tex as Clutter.Texture, color as Clutter.Texture); |
1126 | - processed_icon.set_parent (this); |
1127 | - processed_icon.rotation = rotation; |
1128 | - |
1129 | - this.effect_drop_shadow = new Ctk.EffectDropShadow (5.0f, 0, 2); |
1130 | - effect_drop_shadow.set_opacity (0.4f); |
1131 | - this.effect_drop_shadow.set_margin (5); |
1132 | - this.processed_icon.add_effect (effect_drop_shadow); |
1133 | - |
1134 | - do_queue_redraw (); |
1135 | - } |
1136 | - } |
1137 | - |
1138 | - private void on_running_changed () |
1139 | - { |
1140 | - uint target_opacity = 0; |
1141 | - if (running) |
1142 | - target_opacity = 255; |
1143 | - |
1144 | - if (running_indicator_anim is Clutter.Animation) |
1145 | - running_indicator_anim.completed (); |
1146 | - |
1147 | - running_indicator_anim = running_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, |
1148 | - SHORT_DELAY, |
1149 | - "opacity", target_opacity); |
1150 | - } |
1151 | - |
1152 | - private void on_active_changed () |
1153 | - { |
1154 | - uint target_opacity = 0; |
1155 | - if (active) |
1156 | - target_opacity = 255; |
1157 | - |
1158 | - if (active_indicator_anim is Clutter.Animation) |
1159 | - active_indicator_anim.completed (); |
1160 | - active_indicator_anim = active_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, |
1161 | - SHORT_DELAY, |
1162 | - "opacity", target_opacity); |
1163 | - } |
1164 | - |
1165 | - private void on_rotation_changed () |
1166 | - { |
1167 | - old_rotate_value = processed_icon.rotation; |
1168 | - |
1169 | - if (rotate_timeline is Clutter.Timeline == false) |
1170 | - return; |
1171 | - |
1172 | - if (rotate_timeline.is_playing ()) |
1173 | - { |
1174 | - rotate_timeline.stop (); |
1175 | - processed_icon.rotation = old_rotate_value; |
1176 | - } |
1177 | - |
1178 | - rotate_timeline.set_duration (300); |
1179 | - rotate_state = AnimState.RISING; |
1180 | - rotate_timeline.start (); |
1181 | - } |
1182 | - |
1183 | - private void on_activating_changed () |
1184 | - { |
1185 | - if (glow_timeline.is_playing () && activating == false) |
1186 | - { |
1187 | - glow_timeline.stop (); |
1188 | - glow_timeline.set_duration (SHORT_DELAY); |
1189 | - glow_state = AnimState.FALLING; |
1190 | - glow_timeline.start (); |
1191 | - } |
1192 | - else if (glow_timeline.is_playing () == false && activating) |
1193 | - { |
1194 | - effect_icon_glow = new Ctk.EffectGlow (); |
1195 | - Clutter.Color c = Clutter.Color () { |
1196 | - red = 255, |
1197 | - green = 255, |
1198 | - blue = 255, |
1199 | - alpha = 255 |
1200 | - }; |
1201 | - effect_icon_glow.set_background_texture (honeycomb_mask); |
1202 | - effect_icon_glow.set_color (c); |
1203 | - effect_icon_glow.set_opacity (1.0f); |
1204 | - processed_icon.add_effect (effect_icon_glow); |
1205 | - effect_icon_glow.set_margin (6); |
1206 | - |
1207 | - glow_timeline.set_duration (SHORT_DELAY); |
1208 | - glow_state = AnimState.RISING; |
1209 | - glow_timeline.start (); |
1210 | - } |
1211 | - } |
1212 | - |
1213 | - private void on_needs_attention_changed () |
1214 | - { |
1215 | - if (needs_attention && wiggle_timeline.is_playing () == false) |
1216 | - { |
1217 | - //start wiggling |
1218 | - wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); |
1219 | - wiggle_state = AnimState.RISING; |
1220 | - wiggle_timeline.start (); |
1221 | - } |
1222 | - else if (needs_attention == false && wiggle_timeline.is_playing ()) |
1223 | - { |
1224 | - //stop wiggling |
1225 | - wiggle_timeline.stop (); |
1226 | - wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); |
1227 | - wiggle_state = AnimState.FALLING; |
1228 | - wiggle_timeline.start (); |
1229 | - } |
1230 | - } |
1231 | - |
1232 | - /* clutter overrides */ |
1233 | - public override void get_preferred_width (float for_height, |
1234 | - out float minimum_width, |
1235 | - out float natural_width) |
1236 | - { |
1237 | - float nat, min; |
1238 | - processed_icon.get_preferred_width (for_height, out min, out nat); |
1239 | - natural_width = nat; |
1240 | - minimum_width = min; |
1241 | - |
1242 | - running_indicator.get_preferred_width (for_height, out min, out nat); |
1243 | - natural_width += nat; |
1244 | - |
1245 | - active_indicator.get_preferred_width (for_height, out min, out nat); |
1246 | - natural_width += nat; |
1247 | - } |
1248 | - |
1249 | - public override void get_preferred_height (float for_width, |
1250 | - out float minimum_height, |
1251 | - out float natural_height) |
1252 | - { |
1253 | - natural_height = 48; |
1254 | - minimum_height = 48; |
1255 | - } |
1256 | - |
1257 | - public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags) |
1258 | - { |
1259 | - float x, y; |
1260 | - x = 0; |
1261 | - y = 0; |
1262 | - base.allocate (box, flags); |
1263 | - |
1264 | - Clutter.ActorBox child_box = Clutter.ActorBox (); |
1265 | - |
1266 | - //allocate the running indicator first |
1267 | - float width, height, n_width, n_height; |
1268 | - running_indicator.get_preferred_width (58, out n_width, out width); |
1269 | - running_indicator.get_preferred_height (58, out n_height, out height); |
1270 | - child_box.x1 = 0; |
1271 | - child_box.y1 = (box.get_height () - height) / 2.0f; |
1272 | - child_box.x2 = child_box.x1 + width; |
1273 | - child_box.y2 = child_box.y1 + height; |
1274 | - running_indicator.allocate (child_box, flags); |
1275 | - x += child_box.get_width (); |
1276 | - |
1277 | - //allocate the icon |
1278 | - processed_icon.get_preferred_width (48, out width, out n_width); |
1279 | - processed_icon.get_preferred_height (48, out height, out n_height); |
1280 | - child_box.x1 = (box.get_width () - width) / 2.0f; |
1281 | - child_box.y1 = y; |
1282 | - child_box.x2 = child_box.x1 + 48; |
1283 | - child_box.y2 = child_box.y1 + height; |
1284 | - processed_icon.allocate (child_box, flags); |
1285 | - |
1286 | - //allocate the active indicator |
1287 | - active_indicator.get_preferred_width (48, out n_width, out width); |
1288 | - active_indicator.get_preferred_height (48, out n_height, out height); |
1289 | - child_box.x1 = box.get_width () - width; |
1290 | - child_box.y1 = (box.get_height () - height) / 2.0f; |
1291 | - child_box.x2 = child_box.x1 + width; |
1292 | - child_box.y2 = child_box.y1 + height; |
1293 | - active_indicator.allocate (child_box, flags); |
1294 | - |
1295 | - } |
1296 | - |
1297 | - public override void pick (Clutter.Color color) |
1298 | - { |
1299 | - base.pick (color); |
1300 | - } |
1301 | - |
1302 | - public override void paint () |
1303 | - { |
1304 | - active_indicator.paint (); |
1305 | - running_indicator.paint (); |
1306 | - |
1307 | - processed_icon.paint (); |
1308 | - } |
1309 | - |
1310 | - public override void map () |
1311 | - { |
1312 | - base.map (); |
1313 | - running_indicator.map (); |
1314 | - active_indicator.map (); |
1315 | - processed_icon.map (); |
1316 | - } |
1317 | - |
1318 | - public override void unmap () |
1319 | - { |
1320 | - base.unmap (); |
1321 | - running_indicator.unmap (); |
1322 | - active_indicator.unmap (); |
1323 | - processed_icon.unmap (); |
1324 | - } |
1325 | - } |
1326 | -} |
1327 | - |
1328 | - |
1329 | - |
1330 | |
1331 | === modified file 'unity-private/launcher/launcher.vala' |
1332 | --- unity-private/launcher/launcher.vala 2010-04-26 13:47:08 +0000 |
1333 | +++ unity-private/launcher/launcher.vala 2010-07-22 16:19:42 +0000 |
1334 | @@ -33,9 +33,10 @@ |
1335 | public class Launcher : Object |
1336 | { |
1337 | public Shell shell {get; construct;} |
1338 | + public ScrollerModel model { get; private set; } |
1339 | + |
1340 | private ScrollerController controller; |
1341 | private ScrollerView view; |
1342 | - private ScrollerModel model; |
1343 | |
1344 | public Launcher (Shell shell) |
1345 | { |
1346 | |
1347 | === modified file 'unity-private/launcher/quicklist-controller.vala' |
1348 | --- unity-private/launcher/quicklist-controller.vala 2010-07-16 15:50:39 +0000 |
1349 | +++ unity-private/launcher/quicklist-controller.vala 2010-07-22 16:19:42 +0000 |
1350 | @@ -36,6 +36,9 @@ |
1351 | get { return _state; } |
1352 | set |
1353 | { |
1354 | + var drag_controller = Unity.Drag.Controller.get_default (); |
1355 | + if (drag_controller.is_dragging) value = QuicklistControllerState.CLOSED; |
1356 | + |
1357 | if (value == QuicklistControllerState.LABEL || |
1358 | value == QuicklistControllerState.MENU) |
1359 | { |
1360 | @@ -95,7 +98,6 @@ |
1361 | |
1362 | } |
1363 | |
1364 | - |
1365 | public class ApplicationQuicklistController : QuicklistController |
1366 | { |
1367 | public ApplicationQuicklistController (ScrollerChildController scroller_child) |
1368 | @@ -111,6 +113,11 @@ |
1369 | new_menu (); |
1370 | notify["state"].connect (on_state_change); |
1371 | state = QuicklistControllerState.LABEL; |
1372 | + |
1373 | + var drag_controller = Unity.Drag.Controller.get_default (); |
1374 | + drag_controller.drag_start.connect (() => { |
1375 | + state = QuicklistControllerState.CLOSED; |
1376 | + }); |
1377 | } |
1378 | |
1379 | private void new_menu () |
1380 | |
1381 | === modified file 'unity-private/launcher/scroller-controller.vala' |
1382 | --- unity-private/launcher/scroller-controller.vala 2010-07-15 13:19:02 +0000 |
1383 | +++ unity-private/launcher/scroller-controller.vala 2010-07-22 16:19:42 +0000 |
1384 | @@ -76,37 +76,34 @@ |
1385 | Bamf.Application app = object as Bamf.Application; |
1386 | // need to hook up to its visible changed signals |
1387 | |
1388 | - // this is wrong as it will never re-hide a window |
1389 | - app.user_visible_changed.connect ((a, changed) => { |
1390 | - if (changed) |
1391 | - { |
1392 | - handle_bamf_view_opened (a as Object); |
1393 | - } |
1394 | - }); |
1395 | - |
1396 | - if (app.user_visible ()) |
1397 | - { |
1398 | - string desktop_file = app.get_desktop_file (); |
1399 | - |
1400 | - ScrollerChildController controller = null; |
1401 | - if (desktop_file != null && desktop_file != "") |
1402 | - { |
1403 | - controller = find_controller_by_desktop_file (desktop_file); |
1404 | - } |
1405 | - |
1406 | - if (controller is ApplicationController) |
1407 | - { |
1408 | - (controller as ApplicationController).attach_application (app); |
1409 | - } |
1410 | - else |
1411 | - { |
1412 | - LauncherChild child = new LauncherChild (); |
1413 | - controller = new ApplicationController (null, child); |
1414 | - (controller as ApplicationController).attach_application (app); |
1415 | - model.add (child); |
1416 | - childcontrollers.add (controller); |
1417 | - controller.closed.connect (on_scroller_controller_closed); |
1418 | - } |
1419 | + string desktop_file = app.get_desktop_file (); |
1420 | + |
1421 | + ScrollerChildController controller = null; |
1422 | + if (desktop_file != null && desktop_file != "") |
1423 | + { |
1424 | + controller = find_controller_by_desktop_file (desktop_file); |
1425 | + } |
1426 | + |
1427 | + if (controller is ApplicationController) |
1428 | + { |
1429 | + (controller as ApplicationController).attach_application (app); |
1430 | + } |
1431 | + else |
1432 | + { |
1433 | + ScrollerChild child = new ScrollerChild (); |
1434 | + controller = new ApplicationController (null, child); |
1435 | + (controller as ApplicationController).attach_application (app); |
1436 | + if (app.user_visible ()) |
1437 | + model.add (child); |
1438 | + |
1439 | + childcontrollers.add (controller); |
1440 | + controller.closed.connect (on_scroller_controller_closed); |
1441 | + controller.notify["hide"].connect (() => { |
1442 | + if (controller.hide && controller.child in model) |
1443 | + model.remove (controller.child); |
1444 | + if (!controller.hide && (controller.child in model) == false) |
1445 | + model.add (controller.child); |
1446 | + }); |
1447 | } |
1448 | } |
1449 | } |
1450 | @@ -115,7 +112,7 @@ |
1451 | { |
1452 | if (controller is ApplicationController) |
1453 | { |
1454 | - if (controller.child.pin_type == PinType.UNPINNED) |
1455 | + if (!(controller as ApplicationController).is_sticky ()) |
1456 | { |
1457 | model.remove (controller.child); |
1458 | childcontrollers.remove (controller); |
1459 | @@ -174,7 +171,7 @@ |
1460 | ApplicationController controller = find_controller_by_desktop_file (desktop_file); |
1461 | if (!(controller is ScrollerChildController)) |
1462 | { |
1463 | - LauncherChild child = new LauncherChild (); |
1464 | + ScrollerChild child = new ScrollerChild (); |
1465 | controller = new ApplicationController (desktop_file, child); |
1466 | model.add (child); |
1467 | childcontrollers.add (controller); |
1468 | @@ -199,7 +196,7 @@ |
1469 | ApplicationController controller = find_controller_by_desktop_file (desktop_file); |
1470 | if (!(controller is ScrollerChildController)) |
1471 | { |
1472 | - LauncherChild child = new LauncherChild (); |
1473 | + ScrollerChild child = new ScrollerChild (); |
1474 | controller = new ApplicationController (desktop_file, child); |
1475 | model.add (child); |
1476 | childcontrollers.add (controller); |
1477 | @@ -267,8 +264,17 @@ |
1478 | } |
1479 | } |
1480 | |
1481 | + float last_drag_x = 0.0f; |
1482 | + float last_drag_y = 0.0f; |
1483 | private void on_unity_drag_motion (Drag.Model drag_model, float x, float y) |
1484 | { |
1485 | + if (x == last_drag_x && y == last_drag_y) |
1486 | + return; |
1487 | + |
1488 | + last_drag_x = x; |
1489 | + last_drag_y = y; |
1490 | + |
1491 | + |
1492 | var drag_controller = Drag.Controller.get_default (); |
1493 | // check to see if the data matches any of our children |
1494 | if (!(drag_controller.get_drag_model () is ScrollerChildController)) |
1495 | @@ -286,13 +292,40 @@ |
1496 | { |
1497 | // if the actor is not in the model, add it. because its now in there! |
1498 | // find the index at this position |
1499 | - int model_index = view.get_model_index_at_y_pos (y); |
1500 | - if (retcont in model) |
1501 | - model.move (retcont, int.max (model_index, 0)); |
1502 | + int model_index = view.get_model_index_at_y_pos_no_anim (y, true); |
1503 | + if (model_index < 0) return; |
1504 | + |
1505 | + //we have to check to see if we would still be over the index |
1506 | + //if it was done animating |
1507 | +/* |
1508 | + GLib.Value value = Value (typeof (float)); |
1509 | + var child = model[model_index]; |
1510 | + Clutter.Animation anim = child.get_animation (); |
1511 | + if (anim is Clutter.Animation) |
1512 | + { |
1513 | + debug ("is animating"); |
1514 | + Clutter.Interval interval = anim.get_interval ("position"); |
1515 | + interval.get_final_value (value); |
1516 | + } |
1517 | else |
1518 | - model.insert (retcont, int.max (model_index, 0)); |
1519 | - |
1520 | - view.do_queue_redraw (); |
1521 | + { |
1522 | + debug ("is not animating"); |
1523 | + value.set_float (y); |
1524 | + } |
1525 | + |
1526 | + debug ("%f", Math.fabsf (value.get_float () - y)); |
1527 | + |
1528 | + if (Math.fabsf (value.get_float () - y) < 48) |
1529 | + { |
1530 | + debug ("moving things"); |
1531 | +*/ |
1532 | + if (retcont in model) |
1533 | + model.move (retcont, int.max (model_index, 0)); |
1534 | + else |
1535 | + model.insert (retcont, int.max (model_index, 0)); |
1536 | + |
1537 | + view.do_queue_redraw (); |
1538 | + //} |
1539 | } |
1540 | } |
1541 | |
1542 | |
1543 | === modified file 'unity-private/launcher/scroller-model.vala' |
1544 | --- unity-private/launcher/scroller-model.vala 2010-06-16 12:42:46 +0000 |
1545 | +++ unity-private/launcher/scroller-model.vala 2010-07-22 16:19:42 +0000 |
1546 | @@ -94,6 +94,7 @@ |
1547 | |
1548 | public void add (ScrollerChild child) |
1549 | { |
1550 | + warning ("Add Icon: %s", child.to_string ()); |
1551 | children.add (child); |
1552 | child_added (child); |
1553 | order_changed (); |
1554 | |
1555 | === modified file 'unity-private/launcher/scroller-view.vala' |
1556 | --- unity-private/launcher/scroller-view.vala 2010-07-19 13:06:02 +0000 |
1557 | +++ unity-private/launcher/scroller-view.vala 2010-07-22 16:19:42 +0000 |
1558 | @@ -156,7 +156,35 @@ |
1559 | }); |
1560 | } |
1561 | |
1562 | - public int get_model_index_at_y_pos (float y) |
1563 | + public int get_model_index_at_y_pos_no_anim (float y, bool return_minus_if_fail=false) |
1564 | + { |
1565 | + SList<float?> positions = new SList<float?> (); |
1566 | + foreach (ScrollerChild child in model) |
1567 | + { |
1568 | + positions.append (child.position); |
1569 | + GLib.Value value = Value (typeof (float)); |
1570 | + Clutter.Animation anim = child.get_animation (); |
1571 | + if (anim is Clutter.Animation) |
1572 | + { |
1573 | + Clutter.Interval interval = anim.get_interval ("position"); |
1574 | + interval.get_final_value (value); |
1575 | + child.position = value.get_float (); |
1576 | + } |
1577 | + } |
1578 | + |
1579 | + int value = get_model_index_at_y_pos (y, return_minus_if_fail); |
1580 | + |
1581 | + unowned SList<float?> list = positions; |
1582 | + foreach (ScrollerChild child in model) |
1583 | + { |
1584 | + child.position = (float)list.data; |
1585 | + list = list.next; |
1586 | + } |
1587 | + |
1588 | + return value; |
1589 | + } |
1590 | + |
1591 | + public int get_model_index_at_y_pos (float y, bool return_minus_if_fail=false) |
1592 | { |
1593 | |
1594 | // trying out a different method |
1595 | @@ -174,6 +202,8 @@ |
1596 | |
1597 | if (picked_actor is ScrollerChild == false) |
1598 | { |
1599 | + if (return_minus_if_fail) |
1600 | + return -1; |
1601 | // couldn't pick a single actor, return 0 |
1602 | return (y < padding.top + model[0].get_height () + spacing) ? 0 : model.size -1 ; |
1603 | } |
1604 | @@ -660,7 +690,7 @@ |
1605 | if (child.get_animation () is Clutter.Animation) |
1606 | { |
1607 | //GLib.Value value = GLib.Value (GLib.Type.from_name ("string")); |
1608 | - GLib.Value value = typeof (float); |
1609 | + GLib.Value value = Value (typeof (float)); |
1610 | Clutter.Interval interval = child.get_animation ().get_interval ("position"); |
1611 | interval.get_final_value (value); |
1612 | if (value.get_float () != transitions[index].position) |
1613 | @@ -892,17 +922,17 @@ |
1614 | for (int index = draw_btf.size-1; index >= 0; index--) |
1615 | { |
1616 | ScrollerChild child = draw_btf[index]; |
1617 | - if (child is LauncherChild && child.opacity > 0) |
1618 | + if (child is ScrollerChild && child.opacity > 0) |
1619 | { |
1620 | - (child as LauncherChild).paint (); |
1621 | + (child as ScrollerChild).paint (); |
1622 | } |
1623 | } |
1624 | |
1625 | foreach (ScrollerChild child in draw_ftb) |
1626 | { |
1627 | - if (child is LauncherChild && child.opacity > 0) |
1628 | + if (child is ScrollerChild && child.opacity > 0) |
1629 | { |
1630 | - (child as LauncherChild).paint (); |
1631 | + (child as ScrollerChild).paint (); |
1632 | } |
1633 | } |
1634 | |
1635 | @@ -919,17 +949,17 @@ |
1636 | for (int index = draw_btf.size-1; index >= 0; index--) |
1637 | { |
1638 | ScrollerChild child = draw_btf[index]; |
1639 | - if (child is LauncherChild && child.opacity > 0) |
1640 | + if (child is ScrollerChild && child.opacity > 0) |
1641 | { |
1642 | - (child as LauncherChild).paint (); |
1643 | + (child as ScrollerChild).paint (); |
1644 | } |
1645 | } |
1646 | |
1647 | foreach (ScrollerChild child in draw_ftb) |
1648 | { |
1649 | - if (child is LauncherChild && child.opacity > 0) |
1650 | + if (child is ScrollerChild && child.opacity > 0) |
1651 | { |
1652 | - (child as LauncherChild).paint (); |
1653 | + (child as ScrollerChild).paint (); |
1654 | } |
1655 | } |
1656 | |
1657 | |
1658 | === modified file 'unity-private/launcher/scrollerchild-controller.vala' |
1659 | --- unity-private/launcher/scrollerchild-controller.vala 2010-07-15 09:29:49 +0000 |
1660 | +++ unity-private/launcher/scrollerchild-controller.vala 2010-07-22 16:19:42 +0000 |
1661 | @@ -37,7 +37,10 @@ |
1662 | { |
1663 | public ScrollerChild child {get; construct;} |
1664 | public signal void request_removal (); //call when not needed anymore so we can unref |
1665 | - public string name = "If you can read this, file a bug!!"; |
1666 | + |
1667 | + public string name {get; set;} |
1668 | + public bool hide {get; set;} |
1669 | + |
1670 | |
1671 | public signal void closed (); |
1672 | |
1673 | @@ -46,6 +49,7 @@ |
1674 | protected bool button_down = false; |
1675 | protected float click_start_pos = 0.0f; |
1676 | protected int drag_sensitivity = 7; |
1677 | + private Unity.ThemeFilePath theme_file_path; |
1678 | |
1679 | protected QuicklistController? menu {get; set;} |
1680 | |
1681 | @@ -56,6 +60,8 @@ |
1682 | |
1683 | construct |
1684 | { |
1685 | + theme_file_path = new Unity.ThemeFilePath (); |
1686 | + name = "Bug Found, You Defeated Unity"; |
1687 | child.controller = this; |
1688 | child.button_press_event.connect (on_press_event); |
1689 | child.button_release_event.connect (on_release_event); |
1690 | @@ -71,11 +77,26 @@ |
1691 | } |
1692 | |
1693 | public delegate void menu_cb (Dbusmenu.Menuitem? menu); |
1694 | - public abstract void get_menu_actions (menu_cb callback); |
1695 | - public abstract void get_menu_navigation (menu_cb callback); |
1696 | - |
1697 | - public abstract void activate (); |
1698 | - public abstract QuicklistController get_menu_controller (); |
1699 | + |
1700 | + public virtual void get_menu_actions (menu_cb callback) |
1701 | + { |
1702 | + callback (null); |
1703 | + } |
1704 | + |
1705 | + public virtual void get_menu_navigation (menu_cb callback) |
1706 | + { |
1707 | + callback (null); |
1708 | + } |
1709 | + |
1710 | + public virtual void activate () |
1711 | + { |
1712 | + // do nothing! |
1713 | + } |
1714 | + |
1715 | + public virtual QuicklistController get_menu_controller () |
1716 | + { |
1717 | + return null; |
1718 | + } |
1719 | |
1720 | private bool on_leave_event (Clutter.Event event) |
1721 | { |
1722 | @@ -140,6 +161,7 @@ |
1723 | private void ensure_menu_state () |
1724 | { |
1725 | //no tooltips on drag |
1726 | + |
1727 | if (Unity.Drag.Controller.get_default ().is_dragging) return; |
1728 | |
1729 | if (menu is QuicklistController == false) |
1730 | @@ -177,7 +199,7 @@ |
1731 | // this is for our drag handling |
1732 | public Clutter.Actor get_icon () |
1733 | { |
1734 | - return child; |
1735 | + return child.get_content (); |
1736 | } |
1737 | |
1738 | public string get_drag_data () |
1739 | @@ -204,5 +226,85 @@ |
1740 | } |
1741 | return false; |
1742 | } |
1743 | + |
1744 | + /* all this icon loading stuff can go when we switch from liblauncher to |
1745 | + * bamf - please ignore any icon loading bugs :-) |
1746 | + */ |
1747 | + protected void load_icon_from_icon_name (string icon_name) |
1748 | + { |
1749 | + // first try to load from a path; |
1750 | + if (try_load_from_file (icon_name)) |
1751 | + { |
1752 | + return; |
1753 | + } |
1754 | + |
1755 | + //try to load from a path that we augment |
1756 | + if (try_load_from_file ("/usr/share/pixmaps/" + icon_name)) |
1757 | + { |
1758 | + return; |
1759 | + } |
1760 | + |
1761 | + theme_file_path = new Unity.ThemeFilePath (); |
1762 | + |
1763 | + // add our searchable themes |
1764 | + Gtk.IconTheme theme = Gtk.IconTheme.get_default (); |
1765 | + theme_file_path.add_icon_theme (theme); |
1766 | + theme = new Gtk.IconTheme (); |
1767 | + |
1768 | + theme.set_custom_theme ("unity-icon-theme"); |
1769 | + theme_file_path.add_icon_theme (theme); |
1770 | + theme.set_custom_theme ("Web"); |
1771 | + theme_file_path.add_icon_theme (theme); |
1772 | + |
1773 | + theme_file_path.found_icon_path.connect ((theme, filepath) => { |
1774 | + try |
1775 | + { |
1776 | + child.icon = new Gdk.Pixbuf.from_file (filepath); |
1777 | + } |
1778 | + catch (Error e) |
1779 | + { |
1780 | + warning (@"Could not load from $filepath"); |
1781 | + } |
1782 | + }); |
1783 | + theme_file_path.failed.connect (() => { |
1784 | + // we didn't get an icon, so just load the failcon |
1785 | + try |
1786 | + { |
1787 | + var default_theme = Gtk.IconTheme.get_default (); |
1788 | + child.icon = default_theme.load_icon(Gtk.STOCK_MISSING_IMAGE, 48, 0); |
1789 | + } |
1790 | + catch (Error e) |
1791 | + { |
1792 | + warning (@"Could not load any icon for %s", icon_name); |
1793 | + } |
1794 | + }); |
1795 | + theme_file_path.get_icon_filepath (icon_name); |
1796 | + } |
1797 | + |
1798 | + private bool try_load_from_file (string filepath) |
1799 | + { |
1800 | + Gdk.Pixbuf pixbuf = null; |
1801 | + if (FileUtils.test(filepath, FileTest.IS_REGULAR)) |
1802 | + { |
1803 | + try |
1804 | + { |
1805 | + pixbuf = new Gdk.Pixbuf.from_file_at_scale(filepath, |
1806 | + 48, 48, true); |
1807 | + } |
1808 | + catch (Error e) |
1809 | + { |
1810 | + warning ("Unable to load image from file '%s': %s", |
1811 | + filepath, |
1812 | + e.message); |
1813 | + } |
1814 | + |
1815 | + if (pixbuf is Gdk.Pixbuf) |
1816 | + { |
1817 | + child.icon = pixbuf; |
1818 | + return true; |
1819 | + } |
1820 | + } |
1821 | + return false; |
1822 | + } |
1823 | } |
1824 | } |
1825 | |
1826 | === modified file 'unity-private/launcher/scrollerchild.vala' |
1827 | --- unity-private/launcher/scrollerchild.vala 2010-06-24 11:22:50 +0000 |
1828 | +++ unity-private/launcher/scrollerchild.vala 2010-07-22 16:19:42 +0000 |
1829 | @@ -24,6 +24,23 @@ |
1830 | |
1831 | namespace Unity.Launcher |
1832 | { |
1833 | + const string HONEYCOMB_MASK_FILE = Unity.PKGDATADIR |
1834 | + + "/honeycomb-mask.png"; |
1835 | + const string MENU_BG_FILE = Unity.PKGDATADIR |
1836 | + + "/tight_check_4px.png"; |
1837 | + |
1838 | + const float WIGGLE_SIZE = 5; // how many degree's to wiggle on either side. |
1839 | + const int WIGGLE_FREQUENCY = 5; // x times a second |
1840 | + const int WIGGLE_RUN_LENGTH = 5000; // 5 seconds of wiggle |
1841 | + const int WIGGLE_PAUSE_LENGTH = 20; // followed by 20 seconds of no wiggle |
1842 | + |
1843 | + private enum AnimState { |
1844 | + RISING, |
1845 | + LOOPING, |
1846 | + FALLING, |
1847 | + STOPPED |
1848 | + } |
1849 | + |
1850 | public enum PinType { |
1851 | UNPINNED, |
1852 | PINNED, |
1853 | @@ -31,12 +48,8 @@ |
1854 | NEVER |
1855 | } |
1856 | |
1857 | - public abstract class ScrollerChild : Ctk.Actor |
1858 | + public class ScrollerChild : Ctk.Actor |
1859 | { |
1860 | - construct |
1861 | - { |
1862 | - } |
1863 | - |
1864 | public Gdk.Pixbuf icon {get; set;} |
1865 | public PinType pin_type; |
1866 | public float position {get; set;} |
1867 | @@ -47,8 +60,6 @@ |
1868 | public float rotation {get; set;} |
1869 | public ScrollerChildController controller; // this sucks. shouldn't be here, can't help it. |
1870 | |
1871 | - public abstract void force_rotation_jump (float degrees); |
1872 | - |
1873 | public string to_string () |
1874 | { |
1875 | return "A scroller child; running: %s, active: %s, position: %f, opacity %f".printf ( |
1876 | @@ -57,5 +68,535 @@ |
1877 | position, |
1878 | opacity); |
1879 | } |
1880 | + |
1881 | + private UnityIcon processed_icon; |
1882 | + private ThemeImage active_indicator; |
1883 | + private ThemeImage running_indicator; |
1884 | + private Gdk.Pixbuf honeycomb_mask; |
1885 | + |
1886 | + // effects |
1887 | + private Ctk.EffectDropShadow effect_drop_shadow; |
1888 | + private Ctk.EffectGlow effect_icon_glow; |
1889 | + |
1890 | + // animations |
1891 | + private Clutter.Animation active_indicator_anim; |
1892 | + private Clutter.Animation running_indicator_anim; |
1893 | + private Clutter.Animation rotate_anim; |
1894 | + private Clutter.Timeline wiggle_timeline; |
1895 | + private Clutter.Timeline glow_timeline; |
1896 | + private Clutter.Timeline rotate_timeline; |
1897 | + private AnimState glow_state; |
1898 | + private AnimState wiggle_state; |
1899 | + private AnimState rotate_state; |
1900 | + |
1901 | + private float old_rotate_value = 0.0f; |
1902 | + |
1903 | + construct |
1904 | + { |
1905 | + load_textures (); |
1906 | + position = 0.0f; |
1907 | + |
1908 | + //icon glow |
1909 | + glow_timeline = new Clutter.Timeline (1); |
1910 | + wiggle_timeline = new Clutter.Timeline (1); |
1911 | + rotate_timeline = new Clutter.Timeline (1); |
1912 | + |
1913 | + glow_timeline.new_frame.connect (on_glow_timeline_new_frame); |
1914 | + wiggle_timeline.new_frame.connect (on_wiggle_timeline_new_frame); |
1915 | + rotate_timeline.new_frame.connect (on_rotate_timeline_new_frame); |
1916 | + |
1917 | + notify["rotation"].connect (on_rotation_changed); |
1918 | + } |
1919 | + |
1920 | + ~ScrollerChild () |
1921 | + { |
1922 | + running_indicator.unparent (); |
1923 | + active_indicator.unparent (); |
1924 | + } |
1925 | + |
1926 | + /* private methods */ |
1927 | + private void load_textures () |
1928 | + { |
1929 | + active_indicator = new ThemeImage ("application-selected"); |
1930 | + running_indicator = new ThemeImage ("application-running"); |
1931 | + |
1932 | + active_indicator.set_parent (this); |
1933 | + running_indicator.set_parent (this); |
1934 | + active_indicator.set_opacity (0); |
1935 | + running_indicator.set_opacity (0); |
1936 | + |
1937 | + try |
1938 | + { |
1939 | + honeycomb_mask = new Gdk.Pixbuf.from_file(HONEYCOMB_MASK_FILE); |
1940 | + } |
1941 | + catch (Error e) |
1942 | + { |
1943 | + warning ("Unable to load asset %s: %s", |
1944 | + HONEYCOMB_MASK_FILE, |
1945 | + e.message); |
1946 | + } |
1947 | + |
1948 | + processed_icon = new UnityIcon (null, null); |
1949 | + processed_icon.set_size (48, 48); |
1950 | + processed_icon.set_parent (this); |
1951 | + |
1952 | + notify["icon"].connect (on_icon_changed); |
1953 | + notify["running"].connect (on_running_changed); |
1954 | + notify["active"].connect (on_active_changed); |
1955 | + notify["activating"].connect (on_activating_changed); |
1956 | + notify["needs-attention"].connect (on_needs_attention_changed); |
1957 | + |
1958 | + // just trigger some notifications now to set inital state |
1959 | + on_running_changed (); |
1960 | + on_active_changed (); |
1961 | + on_rotation_changed (); |
1962 | + } |
1963 | + |
1964 | + public Clutter.Actor get_content () |
1965 | + { |
1966 | + return processed_icon; |
1967 | + } |
1968 | + |
1969 | + /* alpha helpers */ |
1970 | + private static float get_ease_out_sine (float alpha) |
1971 | + { |
1972 | + return (float)(Math.sin ((Math.PI_2 * alpha))); |
1973 | + } |
1974 | + |
1975 | + private static float get_circular_alpha (float alpha) |
1976 | + { |
1977 | + //float sine = (float)(Math.sin (-Math.PI + (alpha * (Math.PI * 2)))); |
1978 | + var sine = Math.sin ((alpha * (Math.PI * 2)) - Math.PI); |
1979 | + return Math.fmaxf(((float)sine / 2.0f) + 0.5f, 0.0f);; |
1980 | + } |
1981 | + /* animation callbacks */ |
1982 | + |
1983 | + private void on_rotate_timeline_new_frame () |
1984 | + { |
1985 | + float progress = (float)rotate_timeline.get_progress (); |
1986 | + switch (rotate_state) |
1987 | + { |
1988 | + case AnimState.RISING: |
1989 | + rotate_anim_rising (progress); |
1990 | + break; |
1991 | + |
1992 | + case AnimState.STOPPED: |
1993 | + rotate_timeline.stop (); |
1994 | + break; |
1995 | + } |
1996 | + processed_icon.do_queue_redraw (); |
1997 | + } |
1998 | + |
1999 | + private void rotate_anim_rising (float progress) |
2000 | + { |
2001 | + progress = get_ease_out_sine (progress); |
2002 | + var diff = rotation - old_rotate_value; |
2003 | + float rotate_val = old_rotate_value + (progress * diff); |
2004 | + |
2005 | + processed_icon.rotation = rotate_val; |
2006 | + if (progress >= 1.0) |
2007 | + { |
2008 | + rotate_state = AnimState.STOPPED; |
2009 | + rotate_timeline.stop (); |
2010 | + } |
2011 | + } |
2012 | + |
2013 | + public void force_rotation_jump (float degrees) |
2014 | + { |
2015 | + processed_icon.rotation = degrees; |
2016 | + rotation = degrees; |
2017 | + rotate_state = AnimState.STOPPED; |
2018 | + rotate_timeline.stop (); |
2019 | + do_queue_redraw (); |
2020 | + } |
2021 | + |
2022 | + private void on_glow_timeline_new_frame () |
2023 | + { |
2024 | + float progress = (float)glow_timeline.get_progress (); |
2025 | + switch (glow_state) |
2026 | + { |
2027 | + case AnimState.RISING: |
2028 | + glow_anim_rising (progress); |
2029 | + break; |
2030 | + |
2031 | + case AnimState.LOOPING: |
2032 | + glow_anim_looping (progress); |
2033 | + break; |
2034 | + |
2035 | + case AnimState.FALLING: |
2036 | + glow_anim_falling (progress); |
2037 | + break; |
2038 | + |
2039 | + default: |
2040 | + glow_state = AnimState.STOPPED; |
2041 | + glow_timeline.stop (); |
2042 | + break; |
2043 | + } |
2044 | + |
2045 | + processed_icon.do_queue_redraw (); |
2046 | + } |
2047 | + |
2048 | + private float previous_glow_alpha = 0.0f; |
2049 | + private void glow_anim_rising (float progress) |
2050 | + { |
2051 | + progress = get_ease_out_sine (progress); |
2052 | + effect_icon_glow.set_opacity (progress); |
2053 | + previous_glow_alpha = progress; |
2054 | + if (progress >= 1.0) |
2055 | + { |
2056 | + glow_state = AnimState.LOOPING; |
2057 | + glow_timeline.stop (); |
2058 | + glow_timeline.set_duration (LONG_DELAY); |
2059 | + glow_timeline.set_loop (true); |
2060 | + glow_timeline.start (); |
2061 | + return; |
2062 | + } |
2063 | + } |
2064 | + |
2065 | + private void glow_anim_looping (float progress) |
2066 | + { |
2067 | + progress = 1.0f - get_circular_alpha (progress); |
2068 | + effect_icon_glow.set_opacity (progress); |
2069 | + previous_glow_alpha = progress; |
2070 | + processed_icon.do_queue_redraw (); |
2071 | + } |
2072 | + |
2073 | + private void glow_anim_falling (float progress) |
2074 | + { |
2075 | + float alpha_length = previous_glow_alpha; |
2076 | + effect_icon_glow.set_opacity (alpha_length - (progress * alpha_length)); |
2077 | + |
2078 | + if (progress >= 1.0) |
2079 | + { |
2080 | + glow_state = AnimState.STOPPED; |
2081 | + glow_timeline.stop (); |
2082 | + glow_timeline.set_loop (false); |
2083 | + } |
2084 | + } |
2085 | + |
2086 | + private void on_wiggle_timeline_new_frame () |
2087 | + { |
2088 | + float progress = (float)wiggle_timeline.get_progress (); |
2089 | + |
2090 | + switch (wiggle_state) |
2091 | + { |
2092 | + case AnimState.RISING: |
2093 | + wiggle_anim_rising (progress); |
2094 | + break; |
2095 | + |
2096 | + case AnimState.LOOPING: |
2097 | + wiggle_anim_looping (progress); |
2098 | + break; |
2099 | + |
2100 | + case AnimState.FALLING: |
2101 | + wiggle_anim_falling (progress); |
2102 | + break; |
2103 | + |
2104 | + default: |
2105 | + wiggle_state = AnimState.STOPPED; |
2106 | + wiggle_timeline.stop (); |
2107 | + break; |
2108 | + } |
2109 | + |
2110 | + processed_icon.do_queue_redraw (); |
2111 | + } |
2112 | + |
2113 | + private float previous_wiggle_alpha = 0.0f; |
2114 | + private void wiggle_anim_rising (float progress) |
2115 | + { |
2116 | + progress = get_ease_out_sine (progress); |
2117 | + processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, |
2118 | + 25.0f, 25.0f, 0.0f); |
2119 | + previous_wiggle_alpha = progress; |
2120 | + if (progress >= 1.0) |
2121 | + { |
2122 | + wiggle_state = AnimState.LOOPING; |
2123 | + wiggle_timeline.stop (); |
2124 | + wiggle_timeline.set_duration (WIGGLE_RUN_LENGTH); |
2125 | + wiggle_timeline.set_loop (true); |
2126 | + wiggle_timeline.start (); |
2127 | + return; |
2128 | + } |
2129 | + } |
2130 | + |
2131 | + private void wiggle_anim_looping (float progress) |
2132 | + { |
2133 | + if (progress >= 1.0) |
2134 | + { |
2135 | + wiggle_state = AnimState.FALLING; |
2136 | + wiggle_timeline.stop (); |
2137 | + wiggle_timeline.set_loop (false); |
2138 | + wiggle_timeline.start (); |
2139 | + } |
2140 | + |
2141 | + int frequency = WIGGLE_FREQUENCY * (WIGGLE_RUN_LENGTH / 1000); |
2142 | + progress = get_circular_alpha (Math.fmodf (progress * frequency, 1.0f)); |
2143 | + progress = (1.0f - progress) * 2.0f - 1.0f; |
2144 | + processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, |
2145 | + 25.0f, 25.0f, 0.0f); |
2146 | + processed_icon.do_queue_redraw (); |
2147 | + previous_wiggle_alpha = progress; |
2148 | + |
2149 | + |
2150 | + } |
2151 | + |
2152 | + private bool check_continue_wiggle () |
2153 | + { |
2154 | + if (needs_attention) |
2155 | + { |
2156 | + wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); |
2157 | + wiggle_state = AnimState.RISING; |
2158 | + wiggle_timeline.start (); |
2159 | + } |
2160 | + return false; |
2161 | + } |
2162 | + |
2163 | + private void wiggle_anim_falling (float progress) |
2164 | + { |
2165 | + float alpha_length = previous_wiggle_alpha; |
2166 | + float angle = alpha_length - (progress * alpha_length); |
2167 | + processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, angle, |
2168 | + 25.0f, 25.0f, 0.0f); |
2169 | + |
2170 | + if (progress >= 1.0) |
2171 | + { |
2172 | + wiggle_state = AnimState.STOPPED; |
2173 | + wiggle_timeline.stop (); |
2174 | + wiggle_timeline.set_loop (false); |
2175 | + GLib.Timeout.add_seconds (WIGGLE_PAUSE_LENGTH, check_continue_wiggle); |
2176 | + } |
2177 | + } |
2178 | + |
2179 | + /* notifications */ |
2180 | + private void on_icon_changed () |
2181 | + { |
2182 | + if (icon is Gdk.Pixbuf) |
2183 | + { |
2184 | + Gdk.Pixbuf scaled_buf; |
2185 | + int max_size = 48; |
2186 | + if (!Unity.pixbuf_is_tile (icon)) |
2187 | + max_size = 40; |
2188 | + |
2189 | + if (icon.get_width () > max_size || icon.get_height () > max_size) |
2190 | + { |
2191 | + scaled_buf = icon.scale_simple (max_size, max_size, Gdk.InterpType.HYPER); |
2192 | + } |
2193 | + else |
2194 | + { |
2195 | + scaled_buf = icon; |
2196 | + } |
2197 | + |
2198 | + Gdk.Pixbuf color_buf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 1, 1); |
2199 | + uint red, green, blue; |
2200 | + Unity.get_average_color (scaled_buf, out red, out green, out blue); |
2201 | + unowned uchar[] pixels = color_buf.get_pixels (); |
2202 | + pixels[0] = (uchar)red; |
2203 | + pixels[1] = (uchar)green; |
2204 | + pixels[2] = (uchar)blue; |
2205 | + pixels[3] = 255; |
2206 | + |
2207 | + var tex = GtkClutter.texture_new_from_pixbuf (scaled_buf); |
2208 | + var color = GtkClutter.texture_new_from_pixbuf (color_buf); |
2209 | + |
2210 | + processed_icon = new UnityIcon (tex as Clutter.Texture, color as Clutter.Texture); |
2211 | + processed_icon.set_parent (this); |
2212 | + processed_icon.rotation = rotation; |
2213 | + |
2214 | + this.effect_drop_shadow = new Ctk.EffectDropShadow (5.0f, 0, 2); |
2215 | + effect_drop_shadow.set_opacity (0.4f); |
2216 | + this.effect_drop_shadow.set_margin (5); |
2217 | + this.processed_icon.add_effect (effect_drop_shadow); |
2218 | + |
2219 | + do_queue_redraw (); |
2220 | + } |
2221 | + } |
2222 | + |
2223 | + private void on_running_changed () |
2224 | + { |
2225 | + uint target_opacity = 0; |
2226 | + if (running) |
2227 | + target_opacity = 255; |
2228 | + |
2229 | + if (running_indicator_anim is Clutter.Animation) |
2230 | + running_indicator_anim.completed (); |
2231 | + |
2232 | + running_indicator_anim = running_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, |
2233 | + SHORT_DELAY, |
2234 | + "opacity", target_opacity); |
2235 | + } |
2236 | + |
2237 | + private void on_active_changed () |
2238 | + { |
2239 | + uint target_opacity = 0; |
2240 | + if (active) |
2241 | + target_opacity = 255; |
2242 | + |
2243 | + if (active_indicator_anim is Clutter.Animation) |
2244 | + active_indicator_anim.completed (); |
2245 | + active_indicator_anim = active_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, |
2246 | + SHORT_DELAY, |
2247 | + "opacity", target_opacity); |
2248 | + } |
2249 | + |
2250 | + private void on_rotation_changed () |
2251 | + { |
2252 | + old_rotate_value = processed_icon.rotation; |
2253 | + |
2254 | + if (rotate_timeline is Clutter.Timeline == false) |
2255 | + return; |
2256 | + |
2257 | + if (rotate_timeline.is_playing ()) |
2258 | + { |
2259 | + rotate_timeline.stop (); |
2260 | + processed_icon.rotation = old_rotate_value; |
2261 | + } |
2262 | + |
2263 | + rotate_timeline.set_duration (300); |
2264 | + rotate_state = AnimState.RISING; |
2265 | + rotate_timeline.start (); |
2266 | + } |
2267 | + |
2268 | + private void on_activating_changed () |
2269 | + { |
2270 | + if (glow_timeline.is_playing () && activating == false) |
2271 | + { |
2272 | + glow_timeline.stop (); |
2273 | + glow_timeline.set_duration (SHORT_DELAY); |
2274 | + glow_state = AnimState.FALLING; |
2275 | + glow_timeline.start (); |
2276 | + } |
2277 | + else if (glow_timeline.is_playing () == false && activating) |
2278 | + { |
2279 | + effect_icon_glow = new Ctk.EffectGlow (); |
2280 | + Clutter.Color c = Clutter.Color () { |
2281 | + red = 255, |
2282 | + green = 255, |
2283 | + blue = 255, |
2284 | + alpha = 255 |
2285 | + }; |
2286 | + effect_icon_glow.set_background_texture (honeycomb_mask); |
2287 | + effect_icon_glow.set_color (c); |
2288 | + effect_icon_glow.set_opacity (1.0f); |
2289 | + processed_icon.add_effect (effect_icon_glow); |
2290 | + effect_icon_glow.set_margin (6); |
2291 | + |
2292 | + glow_timeline.set_duration (SHORT_DELAY); |
2293 | + glow_state = AnimState.RISING; |
2294 | + glow_timeline.start (); |
2295 | + } |
2296 | + } |
2297 | + |
2298 | + private void on_needs_attention_changed () |
2299 | + { |
2300 | + if (needs_attention && wiggle_timeline.is_playing () == false) |
2301 | + { |
2302 | + //start wiggling |
2303 | + wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); |
2304 | + wiggle_state = AnimState.RISING; |
2305 | + wiggle_timeline.start (); |
2306 | + } |
2307 | + else if (needs_attention == false && wiggle_timeline.is_playing ()) |
2308 | + { |
2309 | + //stop wiggling |
2310 | + wiggle_timeline.stop (); |
2311 | + wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); |
2312 | + wiggle_state = AnimState.FALLING; |
2313 | + wiggle_timeline.start (); |
2314 | + } |
2315 | + } |
2316 | + |
2317 | + /* clutter overrides */ |
2318 | + public override void get_preferred_width (float for_height, |
2319 | + out float minimum_width, |
2320 | + out float natural_width) |
2321 | + { |
2322 | + float nat, min; |
2323 | + processed_icon.get_preferred_width (for_height, out min, out nat); |
2324 | + natural_width = nat; |
2325 | + minimum_width = min; |
2326 | + |
2327 | + running_indicator.get_preferred_width (for_height, out min, out nat); |
2328 | + natural_width += nat; |
2329 | + |
2330 | + active_indicator.get_preferred_width (for_height, out min, out nat); |
2331 | + natural_width += nat; |
2332 | + } |
2333 | + |
2334 | + public override void get_preferred_height (float for_width, |
2335 | + out float minimum_height, |
2336 | + out float natural_height) |
2337 | + { |
2338 | + natural_height = 48; |
2339 | + minimum_height = 48; |
2340 | + } |
2341 | + |
2342 | + public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags) |
2343 | + { |
2344 | + float x, y; |
2345 | + x = 0; |
2346 | + y = 0; |
2347 | + base.allocate (box, flags); |
2348 | + |
2349 | + Clutter.ActorBox child_box = Clutter.ActorBox (); |
2350 | + |
2351 | + //allocate the running indicator first |
2352 | + float width, height, n_width, n_height; |
2353 | + running_indicator.get_preferred_width (58, out n_width, out width); |
2354 | + running_indicator.get_preferred_height (58, out n_height, out height); |
2355 | + child_box.x1 = 0; |
2356 | + child_box.y1 = (box.get_height () - height) / 2.0f; |
2357 | + child_box.x2 = child_box.x1 + width; |
2358 | + child_box.y2 = child_box.y1 + height; |
2359 | + running_indicator.allocate (child_box, flags); |
2360 | + x += child_box.get_width (); |
2361 | + |
2362 | + //allocate the icon |
2363 | + processed_icon.get_preferred_width (48, out width, out n_width); |
2364 | + processed_icon.get_preferred_height (48, out height, out n_height); |
2365 | + child_box.x1 = (box.get_width () - width) / 2.0f; |
2366 | + child_box.y1 = y; |
2367 | + child_box.x2 = child_box.x1 + 48; |
2368 | + child_box.y2 = child_box.y1 + height; |
2369 | + processed_icon.allocate (child_box, flags); |
2370 | + |
2371 | + //allocate the active indicator |
2372 | + active_indicator.get_preferred_width (48, out n_width, out width); |
2373 | + active_indicator.get_preferred_height (48, out n_height, out height); |
2374 | + child_box.x1 = box.get_width () - width; |
2375 | + child_box.y1 = (box.get_height () - height) / 2.0f; |
2376 | + child_box.x2 = child_box.x1 + width; |
2377 | + child_box.y2 = child_box.y1 + height; |
2378 | + active_indicator.allocate (child_box, flags); |
2379 | + |
2380 | + } |
2381 | + |
2382 | + public override void pick (Clutter.Color color) |
2383 | + { |
2384 | + base.pick (color); |
2385 | + } |
2386 | + |
2387 | + public override void paint () |
2388 | + { |
2389 | + active_indicator.paint (); |
2390 | + running_indicator.paint (); |
2391 | + |
2392 | + processed_icon.paint (); |
2393 | + } |
2394 | + |
2395 | + public override void map () |
2396 | + { |
2397 | + base.map (); |
2398 | + running_indicator.map (); |
2399 | + active_indicator.map (); |
2400 | + processed_icon.map (); |
2401 | + } |
2402 | + |
2403 | + public override void unmap () |
2404 | + { |
2405 | + base.unmap (); |
2406 | + running_indicator.unmap (); |
2407 | + active_indicator.unmap (); |
2408 | + processed_icon.unmap (); |
2409 | + } |
2410 | } |
2411 | } |
2412 | |
2413 | === modified file 'unity/drag-controller.vala' |
2414 | --- unity/drag-controller.vala 2010-06-08 09:43:43 +0000 |
2415 | +++ unity/drag-controller.vala 2010-07-22 16:19:42 +0000 |
2416 | @@ -63,10 +63,12 @@ |
2417 | |
2418 | public void start_drag (Unity.Drag.Model model, float offset_x, float offset_y) |
2419 | { |
2420 | + |
2421 | if (!(this.view is View)) { |
2422 | this.view = new View (model.get_icon ().get_stage () as Clutter.Stage); |
2423 | } |
2424 | this.view.hook_actor_to_cursor (model.get_icon (), offset_x, offset_y); |
2425 | + |
2426 | model.get_icon ().parent_set.connect (rehouse_orphaned_child); |
2427 | this.model = model; |
2428 | this.drag_start (model); |
2429 | @@ -88,7 +90,7 @@ |
2430 | // no parent. so set stage |
2431 | Clutter.Stage stage = old_parent.get_stage () as Clutter.Stage; |
2432 | actor.set_parent (stage); |
2433 | - actor.set_position (-10000, -10000); |
2434 | + actor.set_position (20000, 20000); |
2435 | } |
2436 | } |
2437 | |
2438 | |
2439 | === modified file 'unity/drag-view.vala' |
2440 | --- unity/drag-view.vala 2010-06-08 09:43:43 +0000 |
2441 | +++ unity/drag-view.vala 2010-07-22 16:19:42 +0000 |
2442 | @@ -50,7 +50,6 @@ |
2443 | this.offset_y = offset_y; |
2444 | |
2445 | this.hooked_actor = new Clutter.Clone (actor); |
2446 | - this.hooked_actor.unparent (); |
2447 | this.stage.add_actor (this.hooked_actor); |
2448 | |
2449 | actor.get_transformed_position (out x, out y); |
2450 | @@ -94,6 +93,8 @@ |
2451 | this.hooked_actor.set_position (event.motion.x - this.offset_x, |
2452 | event.motion.y - this.offset_y); |
2453 | this.motion (event.motion.x, event.motion.y); |
2454 | + this.hooked_actor.set_opacity (255); |
2455 | + this.hooked_actor.show (); |
2456 | return false; |
2457 | } |
2458 | |
2459 | |
2460 | === modified file 'unity/icon-postprocessor.vala' |
2461 | --- unity/icon-postprocessor.vala 2010-06-24 09:10:53 +0000 |
2462 | +++ unity/icon-postprocessor.vala 2010-07-22 16:19:42 +0000 |
2463 | @@ -254,6 +254,11 @@ |
2464 | g_total = g_total / uint.max (total_caught_pixels, 1); |
2465 | b_total = b_total / uint.max (total_caught_pixels, 1); |
2466 | |
2467 | + rs_total = rs_total / (width * height); |
2468 | + gs_total = gs_total / (width * height); |
2469 | + bs_total = bs_total / (width * height); |
2470 | + |
2471 | + |
2472 | // get a new super saturated value based on our totals |
2473 | if (total_caught_pixels <= 20) |
2474 | { |
2475 | @@ -491,7 +496,9 @@ |
2476 | } |
2477 | }; |
2478 | |
2479 | - uchar opacity = self.get_paint_opacity (); |
2480 | + uchar opacity = self.get_opacity (); |
2481 | + |
2482 | + //debug (@"opacity is set to $opacity"); |
2483 | |
2484 | self.bg_mat.set_color4ub (opacity, opacity, opacity, opacity); |
2485 | self.bgcol_material.set_color4ub (opacity, opacity, opacity, opacity); |
+1