Merge lp:~unity-team/unity/unity.sprint-fixes into lp:unity

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
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+30669@code.launchpad.net

This proposal supersedes a proposal from 2010-07-22.

Description of the change

bunch of fixes from the sprint

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'targets/mutter/expose-manager.vala'
--- targets/mutter/expose-manager.vala 2010-07-19 09:12:30 +0000
+++ targets/mutter/expose-manager.vala 2010-07-22 16:19:42 +0000
@@ -25,6 +25,8 @@
25 private Clutter.Clone clone;25 private Clutter.Clone clone;
26 private Clutter.Actor darken_box;26 private Clutter.Actor darken_box;
27 private bool hovered;27 private bool hovered;
28
29 public bool fade_on_close { get; set; }
2830
29 public unowned Clutter.Actor source { get; private set; }31 public unowned Clutter.Actor source { get; private set; }
3032
@@ -48,7 +50,7 @@
48 unhovered_opacity = 255;50 unhovered_opacity = 255;
4951
50 this.source = source;52 this.source = source;
51 53
52 if (source is Mutter.Window)54 if (source is Mutter.Window)
53 clone = new Clutter.Clone ((source as Mutter.Window).get_texture ());55 clone = new Clutter.Clone ((source as Mutter.Window).get_texture ());
54 else56 else
@@ -90,6 +92,33 @@
90 darken_box.opacity = darken;92 darken_box.opacity = darken;
91 return false;93 return false;
92 }94 }
95
96 public void restore_window_position (int active_workspace)
97 {
98 set_anchor_point_from_gravity (Clutter.Gravity.NORTH_WEST);
99 Clutter.Actor window = source;
100
101 uint8 opacity = 0;
102 if (!fade_on_close || (window is Mutter.Window && (window as Mutter.Window).showing_on_its_workspace () &&
103 (window as Mutter.Window).get_workspace () == active_workspace))
104 opacity = 255;
105
106
107 set ("scale-gravity", Clutter.Gravity.CENTER);
108 Clutter.Animation anim = animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, 250,
109 "scale-x", 1f,
110 "scale-y", 1f,
111 "opacity", opacity,
112 "x", window.x,
113 "y", window.y);
114
115 window.opacity = 0;
116
117 anim.completed.connect (() => {
118 destroy ();
119 window.opacity = 255;
120 });
121 }
93 }122 }
94123
95 public class ExposeManager : Object124 public class ExposeManager : Object
@@ -117,7 +146,6 @@
117146
118 private ExposeClone? last_selected_clone = null;147 private ExposeClone? last_selected_clone = null;
119148
120 private bool menu_in_hover_close_state = false;
121149
122 public ExposeManager (Plugin plugin, Launcher.Launcher launcher)150 public ExposeManager (Plugin plugin, Launcher.Launcher launcher)
123 {151 {
@@ -137,12 +165,6 @@
137165
138 public void start_expose (SList<Clutter.Actor> windows)166 public void start_expose (SList<Clutter.Actor> windows)
139 {167 {
140 var controller = Launcher.QuicklistController.get_current_menu ();
141 if (controller.is_menu_open ())
142 {
143 controller.get_view ().destroy.connect (this.end_expose);
144 this.menu_in_hover_close_state = controller.get_view ().get_close_on_leave ();
145 }
146 exposed_windows = new List<ExposeClone> ();168 exposed_windows = new List<ExposeClone> ();
147169
148 if (expose_group != null)170 if (expose_group != null)
@@ -164,6 +186,7 @@
164 continue;186 continue;
165187
166 ExposeClone clone = new ExposeClone (actor);188 ExposeClone clone = new ExposeClone (actor);
189 clone.fade_on_close = true;
167 clone.set_position (actor.x, actor.y);190 clone.set_position (actor.x, actor.y);
168 clone.set_size (actor.width, actor.height);191 clone.set_size (actor.width, actor.height);
169 exposed_windows.append (clone);192 exposed_windows.append (clone);
@@ -175,26 +198,6 @@
175 clone.unhovered_opacity = unhovered_opacity;198 clone.unhovered_opacity = unhovered_opacity;
176 clone.opacity = unhovered_opacity;199 clone.opacity = unhovered_opacity;
177 clone.darken = darken;200 clone.darken = darken;
178
179 clone.enter_event.connect (() => {
180 var ql_controller = Launcher.QuicklistController.get_current_menu ();
181 if (ql_controller.state == Launcher.QuicklistControllerState.MENU
182 && this.menu_in_hover_close_state)
183 {
184 ql_controller.get_view ().set_close_on_leave (false);
185 }
186 return false;
187 });
188
189 clone.leave_event.connect (() => {
190 var ql_controller = Launcher.QuicklistController.get_current_menu ();
191 if (ql_controller.state == Launcher.QuicklistControllerState.MENU
192 && this.menu_in_hover_close_state)
193 {
194 ql_controller.get_view ().set_close_on_leave (true);
195 }
196 return false;
197 });
198 }201 }
199202
200 unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows ();203 unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows ();
@@ -211,7 +214,7 @@
211 if (coverflow)214 if (coverflow)
212 position_windows_coverflow (exposed_windows, exposed_windows.nth_data (coverflow_index));215 position_windows_coverflow (exposed_windows, exposed_windows.nth_data (coverflow_index));
213 else216 else
214 position_windows_on_grid (exposed_windows);217 position_windows_on_grid (exposed_windows, top_buffer, left_buffer, right_buffer, bottom_buffer);
215218
216 expose_showing = true;219 expose_showing = true;
217220
@@ -223,13 +226,6 @@
223 {226 {
224 if (!expose_showing)227 if (!expose_showing)
225 return;228 return;
226
227 var controller = Launcher.QuicklistController.get_current_menu ();
228 if (controller.is_menu_open ())
229 {
230 controller.get_view ().destroy.disconnect (this.end_expose);
231 controller.state = Launcher.QuicklistControllerState.CLOSED;
232 }
233229
234 unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows ();230 unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows ();
235 foreach (Mutter.Window window in mutter_windows)231 foreach (Mutter.Window window in mutter_windows)
@@ -249,8 +245,8 @@
249 window.reactive = true;245 window.reactive = true;
250 }246 }
251247
252 foreach (Clutter.Actor actor in exposed_windows)248 foreach (ExposeClone actor in exposed_windows)
253 restore_window_position (actor);249 actor.restore_window_position (Mutter.MetaScreen.get_active_workspace_index (owner.plugin.get_screen ()));
254250
255 if (this.last_selected_clone is ExposeClone &&251 if (this.last_selected_clone is ExposeClone &&
256 this.last_selected_clone.source is Mutter.Window)252 this.last_selected_clone.source is Mutter.Window)
@@ -355,7 +351,7 @@
355 return 0;351 return 0;
356 }352 }
357353
358 void position_windows_on_grid (List<Clutter.Actor> _windows)354 public void position_windows_on_grid (List<Clutter.Actor> _windows, int top_buffer, int left_buffer, int right_buffer, int bottom_buffer)
359 {355 {
360 List<Clutter.Actor> windows = _windows.copy ();356 List<Clutter.Actor> windows = _windows.copy ();
361 windows.sort ((CompareFunc) direct_comparison);357 windows.sort ((CompareFunc) direct_comparison);
@@ -426,34 +422,6 @@
426 }422 }
427 }423 }
428424
429 private void restore_window_position (Clutter.Actor actor)
430 {
431 if (!(actor is ExposeClone))
432 return;
433
434 actor.set_anchor_point_from_gravity (Clutter.Gravity.NORTH_WEST);
435 Clutter.Actor window = (actor as ExposeClone).source;
436
437 uint8 opacity = 0;
438 if ((window as Mutter.Window).showing_on_its_workspace () &&
439 (window as Mutter.Window).get_workspace () == Mutter.MetaScreen.get_active_workspace_index (owner.plugin.get_screen ()))
440 opacity = 255;
441
442 actor.set ("scale-gravity", Clutter.Gravity.CENTER);
443 Clutter.Animation anim = actor.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, 250,
444 "scale-x", 1f,
445 "scale-y", 1f,
446 "opacity", opacity,
447 "x", window.x,
448 "y", window.y);
449
450 window.opacity = 0;
451
452 anim.completed.connect (() => {
453 actor.destroy ();
454 window.opacity = 255;
455 });
456 }
457425
458 void handle_event_coverflow (Clutter.Event event)426 void handle_event_coverflow (Clutter.Event event)
459 {427 {
@@ -524,23 +492,13 @@
524 if (event.type == Clutter.EventType.ENTER || event.type == Clutter.EventType.LEAVE)492 if (event.type == Clutter.EventType.ENTER || event.type == Clutter.EventType.LEAVE)
525 return false;493 return false;
526494
527 bool event_over_menu = false;
528495
529 float x, y;496 float x, y;
530 event.get_coords (out x, out y);497 event.get_coords (out x, out y);
531498
532 unowned Clutter.Actor actor = this.stage.get_actor_at_pos (Clutter.PickMode.REACTIVE, (int) x, (int) y);499 unowned Clutter.Actor actor = this.stage.get_actor_at_pos (Clutter.PickMode.REACTIVE, (int) x, (int) y);
533500
534 Clutter.Actor? menu = null;501 if (event.type == Clutter.EventType.BUTTON_PRESS)
535 if (Unity.Launcher.QuicklistController.get_current_menu ().is_menu_open ())
536 menu = Unity.Launcher.QuicklistController.get_current_menu ().get_view ();
537 if (menu != null)
538 {
539 if (x > menu.x && x < menu.x + menu.width && y > menu.y && y < menu.y + menu.height)
540 event_over_menu = true;
541 }
542
543 if (event.type == Clutter.EventType.BUTTON_PRESS && !event_over_menu)
544 pick_window (event, actor);502 pick_window (event, actor);
545503
546 if (coverflow)504 if (coverflow)
@@ -548,7 +506,7 @@
548 else506 else
549 handle_event_expose (event, actor);507 handle_event_expose (event, actor);
550508
551 return !event_over_menu;509 return true;
552 }510 }
553 }511 }
554}512}
555513
=== modified file 'targets/mutter/plugin.vala'
--- targets/mutter/plugin.vala 2010-07-16 08:43:18 +0000
+++ targets/mutter/plugin.vala 2010-07-22 16:19:42 +0000
@@ -107,6 +107,8 @@
107 set { _plugin = value; Idle.add (real_construct); }107 set { _plugin = value; Idle.add (real_construct); }
108 }108 }
109109
110 public ExposeManager expose_manager { get; private set; }
111
110 public bool menus_swallow_events { get { return false; } }112 public bool menus_swallow_events { get { return false; } }
111113
112 public bool expose_showing { get { return expose_manager.expose_showing; } }114 public bool expose_showing { get { return expose_manager.expose_showing; } }
@@ -121,7 +123,6 @@
121123
122 /* Unity Components */124 /* Unity Components */
123 private Background background;125 private Background background;
124 private ExposeManager expose_manager;
125 private SpacesManager spaces_manager;126 private SpacesManager spaces_manager;
126 private Launcher.Launcher launcher;127 private Launcher.Launcher launcher;
127 private Places.Controller places_controller;128 private Places.Controller places_controller;
@@ -243,6 +244,13 @@
243 this.spaces_manager = new SpacesManager (this);244 this.spaces_manager = new SpacesManager (this);
244 this.spaces_manager.set_padding (50, 50, 125, 50);245 this.spaces_manager.set_padding (50, 50, 125, 50);
245246
247 this.launcher.model.add (spaces_manager.button);
248 this.launcher.model.order_changed.connect (() => {
249 var index = launcher.model.index_of (spaces_manager.button);
250 if (index < launcher.model.size)
251 launcher.model.move (spaces_manager.button, launcher.model.size -1);
252 });
253
246 this.expose_manager = new ExposeManager (this, launcher);254 this.expose_manager = new ExposeManager (this, launcher);
247 this.expose_manager.hovered_opacity = 255;255 this.expose_manager.hovered_opacity = 255;
248 this.expose_manager.unhovered_opacity = 255;256 this.expose_manager.unhovered_opacity = 255;
@@ -308,7 +316,6 @@
308316
309 private void on_focus_window_fullscreen_changed ()317 private void on_focus_window_fullscreen_changed ()
310 {318 {
311 warning ("FOCUS WINDOW FULLSCREEN CHANGED");
312 check_fullscreen_obstruction ();319 check_fullscreen_obstruction ();
313 }320 }
314321
@@ -466,32 +473,6 @@
466 /*473 /*
467 * SHELL IMPLEMENTATION474 * SHELL IMPLEMENTATION
468 */475 */
469
470 /*
471 public void show_window_picker ()
472 {
473 this.show_unity ();
474 return;
475 }
476
477 if (expose_manager.expose_showing == true)
478 {
479 this.dexpose_windows ();
480 return;
481 }
482
483 GLib.SList <Clutter.Actor> windows = null;
484
485 unowned GLib.List<Mutter.Window> mutter_windows = this.plugin.get_windows ();
486 foreach (Mutter.Window window in mutter_windows)
487 {
488 windows.append (window as Clutter.Actor);
489 }
490
491 this.expose_windows (windows, 80);
492 }
493 */
494
495 public Clutter.Stage get_stage ()476 public Clutter.Stage get_stage ()
496 {477 {
497 return this.stage;478 return this.stage;
@@ -539,7 +520,7 @@
539520
540 public void stop_expose ()521 public void stop_expose ()
541 {522 {
542 dexpose_windows ();523 expose_manager.end_expose ();
543 }524 }
544525
545 public void show_window (uint32 xid)526 public void show_window (uint32 xid)
@@ -585,10 +566,6 @@
585 expose_manager.start_expose (windows);566 expose_manager.start_expose (windows);
586 }567 }
587568
588 public void dexpose_windows ()
589 {
590 expose_manager.end_expose ();
591 }
592569
593 public void hide_unity ()570 public void hide_unity ()
594 {571 {
595572
=== modified file 'targets/mutter/spaces-manager.vala'
--- targets/mutter/spaces-manager.vala 2010-06-21 21:44:09 +0000
+++ targets/mutter/spaces-manager.vala 2010-07-22 16:19:42 +0000
@@ -17,14 +17,52 @@
17 *17 *
18 */18 */
19 19
20using Unity.Launcher;
21
20namespace Unity {22namespace Unity {
21 23
24 public class SpacesButtonController : ScrollerChildController
25 {
26 SpacesManager parent { get; set; }
27
28 public SpacesButtonController (SpacesManager _parent, ScrollerChild _child)
29 {
30 Object (child: _child);
31 this.parent = _parent;
32
33 name = "Workspace Overview";
34 load_icon_from_icon_name ("workspace-switcher");
35 }
36
37 construct
38 {
39 }
40
41 public override void activate ()
42 {
43 parent.show_spaces_picker ();
44 }
45 }
46
22 public class SpacesManager : GLib.Object47 public class SpacesManager : GLib.Object
23 {48 {
24 Clutter.Actor background;49 Clutter.Actor background;
25 List<Clutter.Actor> clones;50 List<Clutter.Actor> clones;
26 Plugin plugin;51 Plugin plugin;
27 unowned Mutter.MetaScreen screen;52 unowned Mutter.MetaScreen screen;
53 ScrollerChild _button;
54 SpacesButtonController controller;
55
56 public ScrollerChild button {
57 get {
58 if (!(_button is ScrollerChild))
59 {
60 _button = new ScrollerChild ();
61 controller = new SpacesButtonController (this, _button);
62 }
63 return _button;
64 }
65 }
28 66
29 public uint top_padding { get; set; }67 public uint top_padding { get; set; }
30 public uint right_padding { get; set; }68 public uint right_padding { get; set; }
@@ -114,17 +152,29 @@
114 152
115 private Clutter.Actor workspace_clone (Mutter.MetaWorkspace workspace) {153 private Clutter.Actor workspace_clone (Mutter.MetaWorkspace workspace) {
116 Clutter.Group wsp;154 Clutter.Group wsp;
117 unowned GLib.List<Mutter.Window> windows = plugin.plugin.get_windows ();155 GLib.List<weak Mutter.Window> windows = (GLib.List<weak Mutter.Window>) plugin.plugin.get_windows ().copy ();
118 156
119 wsp = new Clutter.Group ();157 wsp = new Clutter.Group ();
120 158
159 List<Clutter.Actor> toplevel_windows = new List<Clutter.Actor> ();
160
161 int active_workspace = Mutter.MetaScreen.get_active_workspace_index (plugin.plugin.get_screen ());
162
163 Clutter.Actor last = null, wspclone = null;
164
121 foreach (Mutter.Window window in windows)165 foreach (Mutter.Window window in windows)
122 {166 {
123 if (Mutter.MetaWindow.is_on_all_workspaces (window.get_meta_window ()) ||167 if (Mutter.MetaWindow.is_on_all_workspaces (window.get_meta_window ()) ||
124 window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP ||168 window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP ||
125 window.get_workspace () == Mutter.MetaWorkspace.index (workspace))169 window.get_workspace () == Mutter.MetaWorkspace.index (workspace))
126 {170 {
127 Clutter.Actor clone = new Clutter.Clone (window);171
172 if (window.get_window_type () == Mutter.MetaCompWindowType.DOCK)
173 continue;
174
175 ExposeClone clone = new ExposeClone (window);
176 clone.fade_on_close = false;
177
128 wsp.add_actor (clone);178 wsp.add_actor (clone);
129 179
130 clone.set_size (window.width, window.height);180 clone.set_size (window.width, window.height);
@@ -134,10 +184,21 @@
134 184
135 if (window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP)185 if (window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP)
136 {186 {
187 wspclone = clone;
137 clone.lower_bottom ();188 clone.lower_bottom ();
138 }189 }
190 else
191 {
192 last = clone;
193 toplevel_windows.prepend (clone);
194 }
139 }195 }
140 }196 }
197
198 if (last != null && wspclone != null && active_workspace != Mutter.MetaWorkspace.index (workspace))
199 last.raise (wspclone);
200
201 plugin.expose_manager.position_windows_on_grid (toplevel_windows, 50, 50, 50, 50);
141 202
142 return wsp;203 return wsp;
143 }204 }
@@ -170,6 +231,11 @@
170 "scale-x", 1.0f,231 "scale-x", 1.0f,
171 "scale-y", 1.0f);232 "scale-y", 1.0f);
172 233
234 int active_workspace = Mutter.MetaScreen.get_active_workspace_index (plugin.plugin.get_screen ());
235 foreach (Clutter.Actor actor in (clone as Clutter.Group).get_children ())
236 if (actor is ExposeClone)
237 (actor as ExposeClone).restore_window_position (active_workspace);
238
173 anim.completed.connect (() => {239 anim.completed.connect (() => {
174 clone.destroy ();240 clone.destroy ();
175 if (background != null)241 if (background != null)
176242
=== modified file 'tests/unit/test-launcher.vala'
--- tests/unit/test-launcher.vala 2010-07-15 13:19:02 +0000
+++ tests/unit/test-launcher.vala 2010-07-22 16:19:42 +0000
@@ -141,9 +141,6 @@
141141
142 public class TestScrollerChild : ScrollerChild142 public class TestScrollerChild : ScrollerChild
143 {143 {
144 public override void force_rotation_jump (float degrees)
145 {
146 }
147 }144 }
148145
149 public class LauncherSuite146 public class LauncherSuite
150147
=== modified file 'unity-private/Makefile.am'
--- unity-private/Makefile.am 2010-07-16 08:43:18 +0000
+++ unity-private/Makefile.am 2010-07-22 16:19:42 +0000
@@ -105,7 +105,6 @@
105launcher_sources = \105launcher_sources = \
106 launcher/application-controller.vala \106 launcher/application-controller.vala \
107 launcher/launcher.vala \107 launcher/launcher.vala \
108 launcher/launcher-child.vala \
109 launcher/quicklist-check-menu-item.vala \108 launcher/quicklist-check-menu-item.vala \
110 launcher/quicklist-controller.vala \109 launcher/quicklist-controller.vala \
111 launcher/quicklist-image-menu-item.vala \110 launcher/quicklist-image-menu-item.vala \
112111
=== modified file 'unity-private/launcher/application-controller.vala'
--- unity-private/launcher/application-controller.vala 2010-07-22 09:06:10 +0000
+++ unity-private/launcher/application-controller.vala 2010-07-22 16:19:42 +0000
@@ -33,7 +33,6 @@
3333
34 private KeyFile desktop_keyfile;34 private KeyFile desktop_keyfile;
35 private string icon_name;35 private string icon_name;
36 private Unity.ThemeFilePath theme_file_path;
37 private Bamf.Application? app = null;36 private Bamf.Application? app = null;
38 private Dbusmenu.Client menu_client;37 private Dbusmenu.Client menu_client;
39 private Dbusmenu.Menuitem cached_menu;38 private Dbusmenu.Menuitem cached_menu;
@@ -58,25 +57,16 @@
5857
59 construct58 construct
60 {59 {
61 theme_file_path = new Unity.ThemeFilePath ();
62 var favorites = Unity.Favorites.get_default ();60 var favorites = Unity.Favorites.get_default ();
63 favorites.favorite_added.connect (on_favorite_added);61 favorites.favorite_added.connect (on_favorite_added);
64 favorites.favorite_removed.connect (on_favorite_removed);62 favorites.favorite_removed.connect (on_favorite_removed);
6563
66 // we need to figure out if we are a favorite64 // we need to figure out if we are a favoritem
67 is_favorite = true;65
66 is_favorite = is_sticky ();
68 child.pin_type = PinType.UNPINNED;67 child.pin_type = PinType.UNPINNED;
69 foreach (string uid in favorites.get_favorites ())68 if (is_sticky ())
70 {69 child.pin_type = PinType.PINNED;
71 if (favorites.get_string (uid, "desktop_file") == desktop_file)
72 {
73 is_favorite = true;
74 child.pin_type = PinType.PINNED;
75 break;
76 }
77 }
78
79 notify["menu"].connect (on_notify_menu);
80 }70 }
8171
82 public override QuicklistController get_menu_controller ()72 public override QuicklistController get_menu_controller ()
@@ -85,28 +75,19 @@
85 return new_menu;75 return new_menu;
86 }76 }
8777
88 private void on_notify_menu ()
89 {
90 menu.notify["state"].connect (() => {
91 if (menu.state == QuicklistControllerState.MENU)
92 {
93 Unity.global_shell.expose_xids (app.get_xids ());
94 }
95 else
96 {
97 Unity.global_shell.stop_expose ();
98 }
99 });
100 }
101
102 public void set_sticky (bool is_sticky = true)78 public void set_sticky (bool is_sticky = true)
103 {79 {
104 if (desktop_file == "" || desktop_file == null)80 if (desktop_file == "" || desktop_file == null)
105 return;81 return;
106 //string uid = "app-" + Path.get_basename (desktop_file);82
107 var favorites = Unity.Favorites.get_default ();83 var favorites = Unity.Favorites.get_default ();
10884
109 string uid = favorites.find_uid_for_desktop_file (desktop_file);85 string uid = favorites.find_uid_for_desktop_file (desktop_file);
86 if (uid == "" || uid == null)
87 {
88 var filepath = desktop_file.split ("/");
89 uid = "app-" + filepath[filepath.length - 1];
90 }
11091
111 if (is_sticky)92 if (is_sticky)
112 {93 {
@@ -127,10 +108,10 @@
127108
128 var favorites = Unity.Favorites.get_default ();109 var favorites = Unity.Favorites.get_default ();
129 string uid = favorites.find_uid_for_desktop_file (desktop_file);110 string uid = favorites.find_uid_for_desktop_file (desktop_file);
130 if (uid != null && uid != "")111 if (uid == null || uid == "")
112 return false;
113 else
131 return true;114 return true;
132 else
133 return false;
134 }115 }
135116
136 public void close_windows ()117 public void close_windows ()
@@ -188,15 +169,17 @@
188 }169 }
189 }170 }
190171
172/*
173 private get_menu_for_client (ScrollerChildController.menu_cb callback, Dbusmenu.Client client)
174 {
175
176 }
177*/
178
191 public override void get_menu_actions (ScrollerChildController.menu_cb callback)179 public override void get_menu_actions (ScrollerChildController.menu_cb callback)
192 {180 {
193181
194 // first check to see if we have a cached client, if we do, just re-use that182 // first check to see if we have a cached client, if we do, just re-use that
195 if (menu_client is Dbusmenu.Client && cached_menu is Dbusmenu.Menuitem)
196 {
197 callback (cached_menu);
198 }
199
200 // check for a menu from bamf183 // check for a menu from bamf
201 if (app is Bamf.Application)184 if (app is Bamf.Application)
202 {185 {
@@ -279,13 +262,19 @@
279 Dbusmenu.Menuitem root = new Dbusmenu.Menuitem ();262 Dbusmenu.Menuitem root = new Dbusmenu.Menuitem ();
280 root.set_root (true);263 root.set_root (true);
281264
282 if (desktop_file != null)265 if (desktop_file != null && desktop_file != "")
283 {266 {
284 Dbusmenu.Menuitem pinning_item = new Dbusmenu.Menuitem ();267 Dbusmenu.Menuitem pinning_item = new Dbusmenu.Menuitem ();
285 if (is_sticky ())268 if (is_sticky () && app is Bamf.Application)
286 pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Remove from launcher"));269 {
287 else270 pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Keep in Launcher"));
288 pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Add to launcher"));271 pinning_item.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_CHECK);
272 pinning_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED);
273 }
274 else if (is_sticky ())
275 {
276 pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Remove from launcher"));
277 }
289278
290 pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true);279 pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true);
291 pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true);280 pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true);
@@ -317,6 +306,8 @@
317 }306 }
318307
319 private static int order_app_windows (void* a, void* b)308 private static int order_app_windows (void* a, void* b)
309 requires (a is Bamf.Window)
310 requires (b is Bamf.Window)
320 {311 {
321 if ((b as Bamf.Window).last_active () > (a as Bamf.Window).last_active ())312 if ((b as Bamf.Window).last_active () > (a as Bamf.Window).last_active ())
322 {313 {
@@ -337,7 +328,12 @@
337328
338 if (app is Bamf.Application)329 if (app is Bamf.Application)
339 {330 {
340 if (app.is_running ())331 if (app.is_active ())
332 {
333 Array<uint32> xids = app.get_xids ();
334 global_shell.expose_xids (xids);
335 }
336 else if (app.is_running ())
341 {337 {
342 unowned List<Bamf.Window> windows = app.get_windows ();338 unowned List<Bamf.Window> windows = app.get_windows ();
343 windows.sort ((CompareFunc)order_app_windows);339 windows.sort ((CompareFunc)order_app_windows);
@@ -375,7 +371,7 @@
375 public void attach_application (Bamf.Application application)371 public void attach_application (Bamf.Application application)
376 {372 {
377 app = application;373 app = application;
378 desktop_file = app.get_desktop_file ();374 desktop_file = app.get_desktop_file ().dup ();
379 child.running = app.is_running ();375 child.running = app.is_running ();
380 child.active = app.is_active ();376 child.active = app.is_active ();
381 child.activating = false;377 child.activating = false;
@@ -384,12 +380,15 @@
384 app.active_changed.connect (on_app_active_changed);380 app.active_changed.connect (on_app_active_changed);
385 app.closed.connect (detach_application);381 app.closed.connect (detach_application);
386 app.urgent_changed.connect (on_app_urgant_changed);382 app.urgent_changed.connect (on_app_urgant_changed);
383 app.user_visible_changed.connect ((value) => {
384 hide = !value;
385 });
387 name = app.get_name ();386 name = app.get_name ();
388 if (name == null || name == "")387 if (name == null || name == "")
389 warning (@"Bamf returned null for app.get_name (): $desktop_file");388 warning (@"Bamf returned null for app.get_name (): $desktop_file");
390389
391 icon_name = app.get_icon ();390 icon_name = app.get_icon ();
392 load_icon_from_icon_name ();391 load_icon_from_icon_name (icon_name);
393 }392 }
394393
395 public void detach_application ()394 public void detach_application ()
@@ -444,7 +443,7 @@
444 try443 try
445 {444 {
446 icon_name = desktop_keyfile.get_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_ICON);445 icon_name = desktop_keyfile.get_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_ICON);
447 load_icon_from_icon_name ();446 load_icon_from_icon_name (icon_name);
448 }447 }
449 catch (Error e)448 catch (Error e)
450 {449 {
@@ -468,86 +467,5 @@
468 {467 {
469 }468 }
470 }469 }
471
472 /* all this icon loading stuff can go when we switch from liblauncher to
473 * bamf - please ignore any icon loading bugs :-)
474 */
475 private void load_icon_from_icon_name ()
476 {
477 // first try to load from a path;
478 if (try_load_from_file (icon_name))
479 {
480 return;
481 }
482
483 //try to load from a path that we augment
484 if (try_load_from_file ("/usr/share/pixmaps/" + icon_name))
485 {
486 return;
487 }
488
489 theme_file_path = new Unity.ThemeFilePath ();
490
491 // add our searchable themes
492 Gtk.IconTheme theme = Gtk.IconTheme.get_default ();
493 theme_file_path.add_icon_theme (theme);
494 theme = new Gtk.IconTheme ();
495
496 theme.set_custom_theme ("unity-icon-theme");
497 theme_file_path.add_icon_theme (theme);
498 theme.set_custom_theme ("Web");
499 theme_file_path.add_icon_theme (theme);
500
501 theme_file_path.found_icon_path.connect ((theme, filepath) => {
502 try
503 {
504 child.icon = new Gdk.Pixbuf.from_file (filepath);
505 }
506 catch (Error e)
507 {
508 warning (@"Could not load from $filepath");
509 }
510 });
511 theme_file_path.failed.connect (() => {
512 // we didn't get an icon, so just load the failcon
513 try
514 {
515 var default_theme = Gtk.IconTheme.get_default ();
516 child.icon = default_theme.load_icon(Gtk.STOCK_MISSING_IMAGE, 48, 0);
517 }
518 catch (Error e)
519 {
520 warning (@"Could not load any icon for %s", app.get_name ());
521 }
522 });
523
524 theme_file_path.get_icon_filepath (icon_name);
525 }
526
527 private bool try_load_from_file (string filepath)
528 {
529 Gdk.Pixbuf pixbuf = null;
530 if (FileUtils.test(filepath, FileTest.IS_REGULAR))
531 {
532 try
533 {
534 pixbuf = new Gdk.Pixbuf.from_file_at_scale(filepath,
535 48, 48, true);
536 }
537 catch (Error e)
538 {
539 warning ("Unable to load image from file '%s': %s",
540 filepath,
541 e.message);
542 }
543
544 if (pixbuf is Gdk.Pixbuf)
545 {
546 child.icon = pixbuf;
547 return true;
548 }
549 }
550 return false;
551 }
552 }470 }
553}471}
554472
=== removed file 'unity-private/launcher/launcher-child.vala'
--- unity-private/launcher/launcher-child.vala 2010-06-22 13:18:52 +0000
+++ unity-private/launcher/launcher-child.vala 1970-01-01 00:00:00 +0000
@@ -1,571 +0,0 @@
1/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
2/*
3 * Copyright (C) 2009 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by Gordon Allott <gord.allott@canonical.com>
18 *
19 */
20
21namespace Unity.Launcher
22{
23 const string HONEYCOMB_MASK_FILE = Unity.PKGDATADIR
24 + "/honeycomb-mask.png";
25 const string MENU_BG_FILE = Unity.PKGDATADIR
26 + "/tight_check_4px.png";
27
28 const float WIGGLE_SIZE = 5; // how many degree's to wiggle on either side.
29 const int WIGGLE_FREQUENCY = 5; // x times a second
30 const int WIGGLE_RUN_LENGTH = 5000; // 5 seconds of wiggle
31 const int WIGGLE_PAUSE_LENGTH = 20; // followed by 20 seconds of no wiggle
32
33 private enum AnimState {
34 RISING,
35 LOOPING,
36 FALLING,
37 STOPPED
38 }
39
40
41 class LauncherChild : ScrollerChild
42 {
43 private UnityIcon processed_icon;
44 private ThemeImage active_indicator;
45 private ThemeImage running_indicator;
46 private Gdk.Pixbuf honeycomb_mask;
47
48 // effects
49 private Ctk.EffectDropShadow effect_drop_shadow;
50 private Ctk.EffectGlow effect_icon_glow;
51
52 // animations
53 private Clutter.Animation active_indicator_anim;
54 private Clutter.Animation running_indicator_anim;
55 private Clutter.Animation rotate_anim;
56 private Clutter.Timeline wiggle_timeline;
57 private Clutter.Timeline glow_timeline;
58 private Clutter.Timeline rotate_timeline;
59 private AnimState glow_state;
60 private AnimState wiggle_state;
61 private AnimState rotate_state;
62
63 private float old_rotate_value = 0.0f;
64
65 construct
66 {
67 load_textures ();
68 position = 0.0f;
69
70 //icon glow
71 glow_timeline = new Clutter.Timeline (1);
72 wiggle_timeline = new Clutter.Timeline (1);
73 rotate_timeline = new Clutter.Timeline (1);
74
75 glow_timeline.new_frame.connect (on_glow_timeline_new_frame);
76 wiggle_timeline.new_frame.connect (on_wiggle_timeline_new_frame);
77 rotate_timeline.new_frame.connect (on_rotate_timeline_new_frame);
78
79 notify["rotation"].connect (on_rotation_changed);
80 }
81
82 ~LauncherChild ()
83 {
84 running_indicator.unparent ();
85 active_indicator.unparent ();
86 }
87
88 /* private methods */
89 private void load_textures ()
90 {
91 active_indicator = new ThemeImage ("application-selected");
92 running_indicator = new ThemeImage ("application-running");
93
94 active_indicator.set_parent (this);
95 running_indicator.set_parent (this);
96 active_indicator.set_opacity (0);
97 running_indicator.set_opacity (0);
98
99 try
100 {
101 honeycomb_mask = new Gdk.Pixbuf.from_file(HONEYCOMB_MASK_FILE);
102 }
103 catch (Error e)
104 {
105 warning ("Unable to load asset %s: %s",
106 HONEYCOMB_MASK_FILE,
107 e.message);
108 }
109
110 processed_icon = new UnityIcon (null, null);
111 processed_icon.set_size (48, 48);
112 processed_icon.set_parent (this);
113
114 notify["icon"].connect (on_icon_changed);
115 notify["running"].connect (on_running_changed);
116 notify["active"].connect (on_active_changed);
117 notify["activating"].connect (on_activating_changed);
118 notify["needs-attention"].connect (on_needs_attention_changed);
119
120 // just trigger some notifications now to set inital state
121 on_running_changed ();
122 on_active_changed ();
123 on_rotation_changed ();
124 }
125
126 /* alpha helpers */
127 private static float get_ease_out_sine (float alpha)
128 {
129 return (float)(Math.sin ((Math.PI_2 * alpha)));
130 }
131
132 private static float get_circular_alpha (float alpha)
133 {
134 //float sine = (float)(Math.sin (-Math.PI + (alpha * (Math.PI * 2))));
135 var sine = Math.sin ((alpha * (Math.PI * 2)) - Math.PI);
136 return Math.fmaxf(((float)sine / 2.0f) + 0.5f, 0.0f);;
137 }
138 /* animation callbacks */
139
140 private void on_rotate_timeline_new_frame ()
141 {
142 float progress = (float)rotate_timeline.get_progress ();
143 switch (rotate_state)
144 {
145 case AnimState.RISING:
146 rotate_anim_rising (progress);
147 break;
148
149 case AnimState.STOPPED:
150 rotate_timeline.stop ();
151 break;
152 }
153 processed_icon.do_queue_redraw ();
154 }
155
156 private void rotate_anim_rising (float progress)
157 {
158 progress = get_ease_out_sine (progress);
159 var diff = rotation - old_rotate_value;
160 float rotate_val = old_rotate_value + (progress * diff);
161
162 processed_icon.rotation = rotate_val;
163 if (progress >= 1.0)
164 {
165 rotate_state = AnimState.STOPPED;
166 rotate_timeline.stop ();
167 }
168 }
169
170 public override void force_rotation_jump (float degrees)
171 {
172 processed_icon.rotation = degrees;
173 rotation = degrees;
174 rotate_state = AnimState.STOPPED;
175 rotate_timeline.stop ();
176 do_queue_redraw ();
177 }
178
179 private void on_glow_timeline_new_frame ()
180 {
181 float progress = (float)glow_timeline.get_progress ();
182 switch (glow_state)
183 {
184 case AnimState.RISING:
185 glow_anim_rising (progress);
186 break;
187
188 case AnimState.LOOPING:
189 glow_anim_looping (progress);
190 break;
191
192 case AnimState.FALLING:
193 glow_anim_falling (progress);
194 break;
195
196 default:
197 glow_state = AnimState.STOPPED;
198 glow_timeline.stop ();
199 break;
200 }
201
202 processed_icon.do_queue_redraw ();
203 }
204
205 private float previous_glow_alpha = 0.0f;
206 private void glow_anim_rising (float progress)
207 {
208 progress = get_ease_out_sine (progress);
209 effect_icon_glow.set_opacity (progress);
210 previous_glow_alpha = progress;
211 if (progress >= 1.0)
212 {
213 glow_state = AnimState.LOOPING;
214 glow_timeline.stop ();
215 glow_timeline.set_duration (LONG_DELAY);
216 glow_timeline.set_loop (true);
217 glow_timeline.start ();
218 return;
219 }
220 }
221
222 private void glow_anim_looping (float progress)
223 {
224 progress = 1.0f - get_circular_alpha (progress);
225 effect_icon_glow.set_opacity (progress);
226 previous_glow_alpha = progress;
227 processed_icon.do_queue_redraw ();
228 }
229
230 private void glow_anim_falling (float progress)
231 {
232 float alpha_length = previous_glow_alpha;
233 effect_icon_glow.set_opacity (alpha_length - (progress * alpha_length));
234
235 if (progress >= 1.0)
236 {
237 glow_state = AnimState.STOPPED;
238 glow_timeline.stop ();
239 glow_timeline.set_loop (false);
240 }
241 }
242
243 private void on_wiggle_timeline_new_frame ()
244 {
245 float progress = (float)wiggle_timeline.get_progress ();
246
247 switch (wiggle_state)
248 {
249 case AnimState.RISING:
250 wiggle_anim_rising (progress);
251 break;
252
253 case AnimState.LOOPING:
254 wiggle_anim_looping (progress);
255 break;
256
257 case AnimState.FALLING:
258 wiggle_anim_falling (progress);
259 break;
260
261 default:
262 wiggle_state = AnimState.STOPPED;
263 wiggle_timeline.stop ();
264 break;
265 }
266
267 processed_icon.do_queue_redraw ();
268 }
269
270 private float previous_wiggle_alpha = 0.0f;
271 private void wiggle_anim_rising (float progress)
272 {
273 progress = get_ease_out_sine (progress);
274 processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE,
275 25.0f, 25.0f, 0.0f);
276 previous_wiggle_alpha = progress;
277 if (progress >= 1.0)
278 {
279 wiggle_state = AnimState.LOOPING;
280 wiggle_timeline.stop ();
281 wiggle_timeline.set_duration (WIGGLE_RUN_LENGTH);
282 wiggle_timeline.set_loop (true);
283 wiggle_timeline.start ();
284 return;
285 }
286 }
287
288 private void wiggle_anim_looping (float progress)
289 {
290 if (progress >= 1.0)
291 {
292 wiggle_state = AnimState.FALLING;
293 wiggle_timeline.stop ();
294 wiggle_timeline.set_loop (false);
295 wiggle_timeline.start ();
296 }
297
298 int frequency = WIGGLE_FREQUENCY * (WIGGLE_RUN_LENGTH / 1000);
299 progress = get_circular_alpha (Math.fmodf (progress * frequency, 1.0f));
300 progress = (1.0f - progress) * 2.0f - 1.0f;
301 processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE,
302 25.0f, 25.0f, 0.0f);
303 processed_icon.do_queue_redraw ();
304 previous_wiggle_alpha = progress;
305
306
307 }
308
309 private bool check_continue_wiggle ()
310 {
311 if (needs_attention)
312 {
313 wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY);
314 wiggle_state = AnimState.RISING;
315 wiggle_timeline.start ();
316 }
317 return false;
318 }
319
320 private void wiggle_anim_falling (float progress)
321 {
322 float alpha_length = previous_wiggle_alpha;
323 float angle = alpha_length - (progress * alpha_length);
324 processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, angle,
325 25.0f, 25.0f, 0.0f);
326
327 if (progress >= 1.0)
328 {
329 wiggle_state = AnimState.STOPPED;
330 wiggle_timeline.stop ();
331 wiggle_timeline.set_loop (false);
332 GLib.Timeout.add_seconds (WIGGLE_PAUSE_LENGTH, check_continue_wiggle);
333 }
334 }
335
336 /* notifications */
337 private void on_icon_changed ()
338 {
339 if (icon is Gdk.Pixbuf)
340 {
341 Gdk.Pixbuf scaled_buf;
342 int max_size = 48;
343 if (!Unity.pixbuf_is_tile (icon))
344 max_size = 40;
345
346 if (icon.get_width () > max_size || icon.get_height () > max_size)
347 {
348 scaled_buf = icon.scale_simple (max_size, max_size, Gdk.InterpType.HYPER);
349 }
350 else
351 {
352 scaled_buf = icon;
353 }
354
355 Gdk.Pixbuf color_buf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 1, 1);
356 uint red, green, blue;
357 Unity.get_average_color (scaled_buf, out red, out green, out blue);
358 unowned uchar[] pixels = color_buf.get_pixels ();
359 pixels[0] = (uchar)red;
360 pixels[1] = (uchar)green;
361 pixels[2] = (uchar)blue;
362 pixels[3] = 255;
363
364 var tex = GtkClutter.texture_new_from_pixbuf (scaled_buf);
365 var color = GtkClutter.texture_new_from_pixbuf (color_buf);
366
367 processed_icon = new UnityIcon (tex as Clutter.Texture, color as Clutter.Texture);
368 processed_icon.set_parent (this);
369 processed_icon.rotation = rotation;
370
371 this.effect_drop_shadow = new Ctk.EffectDropShadow (5.0f, 0, 2);
372 effect_drop_shadow.set_opacity (0.4f);
373 this.effect_drop_shadow.set_margin (5);
374 this.processed_icon.add_effect (effect_drop_shadow);
375
376 do_queue_redraw ();
377 }
378 }
379
380 private void on_running_changed ()
381 {
382 uint target_opacity = 0;
383 if (running)
384 target_opacity = 255;
385
386 if (running_indicator_anim is Clutter.Animation)
387 running_indicator_anim.completed ();
388
389 running_indicator_anim = running_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE,
390 SHORT_DELAY,
391 "opacity", target_opacity);
392 }
393
394 private void on_active_changed ()
395 {
396 uint target_opacity = 0;
397 if (active)
398 target_opacity = 255;
399
400 if (active_indicator_anim is Clutter.Animation)
401 active_indicator_anim.completed ();
402 active_indicator_anim = active_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE,
403 SHORT_DELAY,
404 "opacity", target_opacity);
405 }
406
407 private void on_rotation_changed ()
408 {
409 old_rotate_value = processed_icon.rotation;
410
411 if (rotate_timeline is Clutter.Timeline == false)
412 return;
413
414 if (rotate_timeline.is_playing ())
415 {
416 rotate_timeline.stop ();
417 processed_icon.rotation = old_rotate_value;
418 }
419
420 rotate_timeline.set_duration (300);
421 rotate_state = AnimState.RISING;
422 rotate_timeline.start ();
423 }
424
425 private void on_activating_changed ()
426 {
427 if (glow_timeline.is_playing () && activating == false)
428 {
429 glow_timeline.stop ();
430 glow_timeline.set_duration (SHORT_DELAY);
431 glow_state = AnimState.FALLING;
432 glow_timeline.start ();
433 }
434 else if (glow_timeline.is_playing () == false && activating)
435 {
436 effect_icon_glow = new Ctk.EffectGlow ();
437 Clutter.Color c = Clutter.Color () {
438 red = 255,
439 green = 255,
440 blue = 255,
441 alpha = 255
442 };
443 effect_icon_glow.set_background_texture (honeycomb_mask);
444 effect_icon_glow.set_color (c);
445 effect_icon_glow.set_opacity (1.0f);
446 processed_icon.add_effect (effect_icon_glow);
447 effect_icon_glow.set_margin (6);
448
449 glow_timeline.set_duration (SHORT_DELAY);
450 glow_state = AnimState.RISING;
451 glow_timeline.start ();
452 }
453 }
454
455 private void on_needs_attention_changed ()
456 {
457 if (needs_attention && wiggle_timeline.is_playing () == false)
458 {
459 //start wiggling
460 wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY);
461 wiggle_state = AnimState.RISING;
462 wiggle_timeline.start ();
463 }
464 else if (needs_attention == false && wiggle_timeline.is_playing ())
465 {
466 //stop wiggling
467 wiggle_timeline.stop ();
468 wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY);
469 wiggle_state = AnimState.FALLING;
470 wiggle_timeline.start ();
471 }
472 }
473
474 /* clutter overrides */
475 public override void get_preferred_width (float for_height,
476 out float minimum_width,
477 out float natural_width)
478 {
479 float nat, min;
480 processed_icon.get_preferred_width (for_height, out min, out nat);
481 natural_width = nat;
482 minimum_width = min;
483
484 running_indicator.get_preferred_width (for_height, out min, out nat);
485 natural_width += nat;
486
487 active_indicator.get_preferred_width (for_height, out min, out nat);
488 natural_width += nat;
489 }
490
491 public override void get_preferred_height (float for_width,
492 out float minimum_height,
493 out float natural_height)
494 {
495 natural_height = 48;
496 minimum_height = 48;
497 }
498
499 public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags)
500 {
501 float x, y;
502 x = 0;
503 y = 0;
504 base.allocate (box, flags);
505
506 Clutter.ActorBox child_box = Clutter.ActorBox ();
507
508 //allocate the running indicator first
509 float width, height, n_width, n_height;
510 running_indicator.get_preferred_width (58, out n_width, out width);
511 running_indicator.get_preferred_height (58, out n_height, out height);
512 child_box.x1 = 0;
513 child_box.y1 = (box.get_height () - height) / 2.0f;
514 child_box.x2 = child_box.x1 + width;
515 child_box.y2 = child_box.y1 + height;
516 running_indicator.allocate (child_box, flags);
517 x += child_box.get_width ();
518
519 //allocate the icon
520 processed_icon.get_preferred_width (48, out width, out n_width);
521 processed_icon.get_preferred_height (48, out height, out n_height);
522 child_box.x1 = (box.get_width () - width) / 2.0f;
523 child_box.y1 = y;
524 child_box.x2 = child_box.x1 + 48;
525 child_box.y2 = child_box.y1 + height;
526 processed_icon.allocate (child_box, flags);
527
528 //allocate the active indicator
529 active_indicator.get_preferred_width (48, out n_width, out width);
530 active_indicator.get_preferred_height (48, out n_height, out height);
531 child_box.x1 = box.get_width () - width;
532 child_box.y1 = (box.get_height () - height) / 2.0f;
533 child_box.x2 = child_box.x1 + width;
534 child_box.y2 = child_box.y1 + height;
535 active_indicator.allocate (child_box, flags);
536
537 }
538
539 public override void pick (Clutter.Color color)
540 {
541 base.pick (color);
542 }
543
544 public override void paint ()
545 {
546 active_indicator.paint ();
547 running_indicator.paint ();
548
549 processed_icon.paint ();
550 }
551
552 public override void map ()
553 {
554 base.map ();
555 running_indicator.map ();
556 active_indicator.map ();
557 processed_icon.map ();
558 }
559
560 public override void unmap ()
561 {
562 base.unmap ();
563 running_indicator.unmap ();
564 active_indicator.unmap ();
565 processed_icon.unmap ();
566 }
567 }
568}
569
570
571
5720
=== modified file 'unity-private/launcher/launcher.vala'
--- unity-private/launcher/launcher.vala 2010-04-26 13:47:08 +0000
+++ unity-private/launcher/launcher.vala 2010-07-22 16:19:42 +0000
@@ -33,9 +33,10 @@
33 public class Launcher : Object33 public class Launcher : Object
34 {34 {
35 public Shell shell {get; construct;}35 public Shell shell {get; construct;}
36 public ScrollerModel model { get; private set; }
37
36 private ScrollerController controller;38 private ScrollerController controller;
37 private ScrollerView view;39 private ScrollerView view;
38 private ScrollerModel model;
3940
40 public Launcher (Shell shell)41 public Launcher (Shell shell)
41 {42 {
4243
=== modified file 'unity-private/launcher/quicklist-controller.vala'
--- unity-private/launcher/quicklist-controller.vala 2010-07-16 15:50:39 +0000
+++ unity-private/launcher/quicklist-controller.vala 2010-07-22 16:19:42 +0000
@@ -36,6 +36,9 @@
36 get { return _state; }36 get { return _state; }
37 set37 set
38 {38 {
39 var drag_controller = Unity.Drag.Controller.get_default ();
40 if (drag_controller.is_dragging) value = QuicklistControllerState.CLOSED;
41
39 if (value == QuicklistControllerState.LABEL ||42 if (value == QuicklistControllerState.LABEL ||
40 value == QuicklistControllerState.MENU)43 value == QuicklistControllerState.MENU)
41 {44 {
@@ -95,7 +98,6 @@
9598
96 }99 }
97100
98
99 public class ApplicationQuicklistController : QuicklistController101 public class ApplicationQuicklistController : QuicklistController
100 {102 {
101 public ApplicationQuicklistController (ScrollerChildController scroller_child)103 public ApplicationQuicklistController (ScrollerChildController scroller_child)
@@ -111,6 +113,11 @@
111 new_menu ();113 new_menu ();
112 notify["state"].connect (on_state_change);114 notify["state"].connect (on_state_change);
113 state = QuicklistControllerState.LABEL;115 state = QuicklistControllerState.LABEL;
116
117 var drag_controller = Unity.Drag.Controller.get_default ();
118 drag_controller.drag_start.connect (() => {
119 state = QuicklistControllerState.CLOSED;
120 });
114 }121 }
115122
116 private void new_menu ()123 private void new_menu ()
117124
=== modified file 'unity-private/launcher/scroller-controller.vala'
--- unity-private/launcher/scroller-controller.vala 2010-07-15 13:19:02 +0000
+++ unity-private/launcher/scroller-controller.vala 2010-07-22 16:19:42 +0000
@@ -76,37 +76,34 @@
76 Bamf.Application app = object as Bamf.Application;76 Bamf.Application app = object as Bamf.Application;
77 // need to hook up to its visible changed signals77 // need to hook up to its visible changed signals
7878
79 // this is wrong as it will never re-hide a window79 string desktop_file = app.get_desktop_file ();
80 app.user_visible_changed.connect ((a, changed) => {80
81 if (changed)81 ScrollerChildController controller = null;
82 {82 if (desktop_file != null && desktop_file != "")
83 handle_bamf_view_opened (a as Object);83 {
84 }84 controller = find_controller_by_desktop_file (desktop_file);
85 });85 }
8686
87 if (app.user_visible ())87 if (controller is ApplicationController)
88 {88 {
89 string desktop_file = app.get_desktop_file ();89 (controller as ApplicationController).attach_application (app);
9090 }
91 ScrollerChildController controller = null;91 else
92 if (desktop_file != null && desktop_file != "")92 {
93 {93 ScrollerChild child = new ScrollerChild ();
94 controller = find_controller_by_desktop_file (desktop_file);94 controller = new ApplicationController (null, child);
95 }95 (controller as ApplicationController).attach_application (app);
9696 if (app.user_visible ())
97 if (controller is ApplicationController)97 model.add (child);
98 {98
99 (controller as ApplicationController).attach_application (app);99 childcontrollers.add (controller);
100 }100 controller.closed.connect (on_scroller_controller_closed);
101 else101 controller.notify["hide"].connect (() => {
102 {102 if (controller.hide && controller.child in model)
103 LauncherChild child = new LauncherChild ();103 model.remove (controller.child);
104 controller = new ApplicationController (null, child);104 if (!controller.hide && (controller.child in model) == false)
105 (controller as ApplicationController).attach_application (app);105 model.add (controller.child);
106 model.add (child);106 });
107 childcontrollers.add (controller);
108 controller.closed.connect (on_scroller_controller_closed);
109 }
110 }107 }
111 }108 }
112 }109 }
@@ -115,7 +112,7 @@
115 {112 {
116 if (controller is ApplicationController)113 if (controller is ApplicationController)
117 {114 {
118 if (controller.child.pin_type == PinType.UNPINNED)115 if (!(controller as ApplicationController).is_sticky ())
119 {116 {
120 model.remove (controller.child);117 model.remove (controller.child);
121 childcontrollers.remove (controller);118 childcontrollers.remove (controller);
@@ -174,7 +171,7 @@
174 ApplicationController controller = find_controller_by_desktop_file (desktop_file);171 ApplicationController controller = find_controller_by_desktop_file (desktop_file);
175 if (!(controller is ScrollerChildController))172 if (!(controller is ScrollerChildController))
176 {173 {
177 LauncherChild child = new LauncherChild ();174 ScrollerChild child = new ScrollerChild ();
178 controller = new ApplicationController (desktop_file, child);175 controller = new ApplicationController (desktop_file, child);
179 model.add (child);176 model.add (child);
180 childcontrollers.add (controller);177 childcontrollers.add (controller);
@@ -199,7 +196,7 @@
199 ApplicationController controller = find_controller_by_desktop_file (desktop_file);196 ApplicationController controller = find_controller_by_desktop_file (desktop_file);
200 if (!(controller is ScrollerChildController))197 if (!(controller is ScrollerChildController))
201 {198 {
202 LauncherChild child = new LauncherChild ();199 ScrollerChild child = new ScrollerChild ();
203 controller = new ApplicationController (desktop_file, child);200 controller = new ApplicationController (desktop_file, child);
204 model.add (child);201 model.add (child);
205 childcontrollers.add (controller);202 childcontrollers.add (controller);
@@ -267,8 +264,17 @@
267 }264 }
268 }265 }
269266
267 float last_drag_x = 0.0f;
268 float last_drag_y = 0.0f;
270 private void on_unity_drag_motion (Drag.Model drag_model, float x, float y)269 private void on_unity_drag_motion (Drag.Model drag_model, float x, float y)
271 {270 {
271 if (x == last_drag_x && y == last_drag_y)
272 return;
273
274 last_drag_x = x;
275 last_drag_y = y;
276
277
272 var drag_controller = Drag.Controller.get_default ();278 var drag_controller = Drag.Controller.get_default ();
273 // check to see if the data matches any of our children279 // check to see if the data matches any of our children
274 if (!(drag_controller.get_drag_model () is ScrollerChildController))280 if (!(drag_controller.get_drag_model () is ScrollerChildController))
@@ -286,13 +292,40 @@
286 {292 {
287 // if the actor is not in the model, add it. because its now in there!293 // if the actor is not in the model, add it. because its now in there!
288 // find the index at this position294 // find the index at this position
289 int model_index = view.get_model_index_at_y_pos (y);295 int model_index = view.get_model_index_at_y_pos_no_anim (y, true);
290 if (retcont in model)296 if (model_index < 0) return;
291 model.move (retcont, int.max (model_index, 0));297
298 //we have to check to see if we would still be over the index
299 //if it was done animating
300/*
301 GLib.Value value = Value (typeof (float));
302 var child = model[model_index];
303 Clutter.Animation anim = child.get_animation ();
304 if (anim is Clutter.Animation)
305 {
306 debug ("is animating");
307 Clutter.Interval interval = anim.get_interval ("position");
308 interval.get_final_value (value);
309 }
292 else310 else
293 model.insert (retcont, int.max (model_index, 0));311 {
294312 debug ("is not animating");
295 view.do_queue_redraw ();313 value.set_float (y);
314 }
315
316 debug ("%f", Math.fabsf (value.get_float () - y));
317
318 if (Math.fabsf (value.get_float () - y) < 48)
319 {
320 debug ("moving things");
321*/
322 if (retcont in model)
323 model.move (retcont, int.max (model_index, 0));
324 else
325 model.insert (retcont, int.max (model_index, 0));
326
327 view.do_queue_redraw ();
328 //}
296 }329 }
297 }330 }
298331
299332
=== modified file 'unity-private/launcher/scroller-model.vala'
--- unity-private/launcher/scroller-model.vala 2010-06-16 12:42:46 +0000
+++ unity-private/launcher/scroller-model.vala 2010-07-22 16:19:42 +0000
@@ -94,6 +94,7 @@
9494
95 public void add (ScrollerChild child)95 public void add (ScrollerChild child)
96 {96 {
97 warning ("Add Icon: %s", child.to_string ());
97 children.add (child);98 children.add (child);
98 child_added (child);99 child_added (child);
99 order_changed ();100 order_changed ();
100101
=== modified file 'unity-private/launcher/scroller-view.vala'
--- unity-private/launcher/scroller-view.vala 2010-07-19 13:06:02 +0000
+++ unity-private/launcher/scroller-view.vala 2010-07-22 16:19:42 +0000
@@ -156,7 +156,35 @@
156 });156 });
157 }157 }
158158
159 public int get_model_index_at_y_pos (float y)159 public int get_model_index_at_y_pos_no_anim (float y, bool return_minus_if_fail=false)
160 {
161 SList<float?> positions = new SList<float?> ();
162 foreach (ScrollerChild child in model)
163 {
164 positions.append (child.position);
165 GLib.Value value = Value (typeof (float));
166 Clutter.Animation anim = child.get_animation ();
167 if (anim is Clutter.Animation)
168 {
169 Clutter.Interval interval = anim.get_interval ("position");
170 interval.get_final_value (value);
171 child.position = value.get_float ();
172 }
173 }
174
175 int value = get_model_index_at_y_pos (y, return_minus_if_fail);
176
177 unowned SList<float?> list = positions;
178 foreach (ScrollerChild child in model)
179 {
180 child.position = (float)list.data;
181 list = list.next;
182 }
183
184 return value;
185 }
186
187 public int get_model_index_at_y_pos (float y, bool return_minus_if_fail=false)
160 {188 {
161189
162 // trying out a different method190 // trying out a different method
@@ -174,6 +202,8 @@
174202
175 if (picked_actor is ScrollerChild == false)203 if (picked_actor is ScrollerChild == false)
176 {204 {
205 if (return_minus_if_fail)
206 return -1;
177 // couldn't pick a single actor, return 0207 // couldn't pick a single actor, return 0
178 return (y < padding.top + model[0].get_height () + spacing) ? 0 : model.size -1 ;208 return (y < padding.top + model[0].get_height () + spacing) ? 0 : model.size -1 ;
179 }209 }
@@ -660,7 +690,7 @@
660 if (child.get_animation () is Clutter.Animation)690 if (child.get_animation () is Clutter.Animation)
661 {691 {
662 //GLib.Value value = GLib.Value (GLib.Type.from_name ("string"));692 //GLib.Value value = GLib.Value (GLib.Type.from_name ("string"));
663 GLib.Value value = typeof (float);693 GLib.Value value = Value (typeof (float));
664 Clutter.Interval interval = child.get_animation ().get_interval ("position");694 Clutter.Interval interval = child.get_animation ().get_interval ("position");
665 interval.get_final_value (value);695 interval.get_final_value (value);
666 if (value.get_float () != transitions[index].position)696 if (value.get_float () != transitions[index].position)
@@ -892,17 +922,17 @@
892 for (int index = draw_btf.size-1; index >= 0; index--)922 for (int index = draw_btf.size-1; index >= 0; index--)
893 {923 {
894 ScrollerChild child = draw_btf[index];924 ScrollerChild child = draw_btf[index];
895 if (child is LauncherChild && child.opacity > 0)925 if (child is ScrollerChild && child.opacity > 0)
896 {926 {
897 (child as LauncherChild).paint ();927 (child as ScrollerChild).paint ();
898 }928 }
899 }929 }
900930
901 foreach (ScrollerChild child in draw_ftb)931 foreach (ScrollerChild child in draw_ftb)
902 {932 {
903 if (child is LauncherChild && child.opacity > 0)933 if (child is ScrollerChild && child.opacity > 0)
904 {934 {
905 (child as LauncherChild).paint ();935 (child as ScrollerChild).paint ();
906 }936 }
907 }937 }
908938
@@ -919,17 +949,17 @@
919 for (int index = draw_btf.size-1; index >= 0; index--)949 for (int index = draw_btf.size-1; index >= 0; index--)
920 {950 {
921 ScrollerChild child = draw_btf[index];951 ScrollerChild child = draw_btf[index];
922 if (child is LauncherChild && child.opacity > 0)952 if (child is ScrollerChild && child.opacity > 0)
923 {953 {
924 (child as LauncherChild).paint ();954 (child as ScrollerChild).paint ();
925 }955 }
926 }956 }
927957
928 foreach (ScrollerChild child in draw_ftb)958 foreach (ScrollerChild child in draw_ftb)
929 {959 {
930 if (child is LauncherChild && child.opacity > 0)960 if (child is ScrollerChild && child.opacity > 0)
931 {961 {
932 (child as LauncherChild).paint ();962 (child as ScrollerChild).paint ();
933 }963 }
934 }964 }
935965
936966
=== modified file 'unity-private/launcher/scrollerchild-controller.vala'
--- unity-private/launcher/scrollerchild-controller.vala 2010-07-15 09:29:49 +0000
+++ unity-private/launcher/scrollerchild-controller.vala 2010-07-22 16:19:42 +0000
@@ -37,7 +37,10 @@
37 {37 {
38 public ScrollerChild child {get; construct;}38 public ScrollerChild child {get; construct;}
39 public signal void request_removal (); //call when not needed anymore so we can unref39 public signal void request_removal (); //call when not needed anymore so we can unref
40 public string name = "If you can read this, file a bug!!";40
41 public string name {get; set;}
42 public bool hide {get; set;}
43
4144
42 public signal void closed ();45 public signal void closed ();
4346
@@ -46,6 +49,7 @@
46 protected bool button_down = false;49 protected bool button_down = false;
47 protected float click_start_pos = 0.0f;50 protected float click_start_pos = 0.0f;
48 protected int drag_sensitivity = 7;51 protected int drag_sensitivity = 7;
52 private Unity.ThemeFilePath theme_file_path;
4953
50 protected QuicklistController? menu {get; set;}54 protected QuicklistController? menu {get; set;}
5155
@@ -56,6 +60,8 @@
5660
57 construct61 construct
58 {62 {
63 theme_file_path = new Unity.ThemeFilePath ();
64 name = "Bug Found, You Defeated Unity";
59 child.controller = this;65 child.controller = this;
60 child.button_press_event.connect (on_press_event);66 child.button_press_event.connect (on_press_event);
61 child.button_release_event.connect (on_release_event);67 child.button_release_event.connect (on_release_event);
@@ -71,11 +77,26 @@
71 }77 }
7278
73 public delegate void menu_cb (Dbusmenu.Menuitem? menu);79 public delegate void menu_cb (Dbusmenu.Menuitem? menu);
74 public abstract void get_menu_actions (menu_cb callback);80
75 public abstract void get_menu_navigation (menu_cb callback);81 public virtual void get_menu_actions (menu_cb callback)
7682 {
77 public abstract void activate ();83 callback (null);
78 public abstract QuicklistController get_menu_controller ();84 }
85
86 public virtual void get_menu_navigation (menu_cb callback)
87 {
88 callback (null);
89 }
90
91 public virtual void activate ()
92 {
93 // do nothing!
94 }
95
96 public virtual QuicklistController get_menu_controller ()
97 {
98 return null;
99 }
79100
80 private bool on_leave_event (Clutter.Event event)101 private bool on_leave_event (Clutter.Event event)
81 {102 {
@@ -140,6 +161,7 @@
140 private void ensure_menu_state ()161 private void ensure_menu_state ()
141 {162 {
142 //no tooltips on drag163 //no tooltips on drag
164
143 if (Unity.Drag.Controller.get_default ().is_dragging) return;165 if (Unity.Drag.Controller.get_default ().is_dragging) return;
144166
145 if (menu is QuicklistController == false)167 if (menu is QuicklistController == false)
@@ -177,7 +199,7 @@
177 // this is for our drag handling199 // this is for our drag handling
178 public Clutter.Actor get_icon ()200 public Clutter.Actor get_icon ()
179 {201 {
180 return child;202 return child.get_content ();
181 }203 }
182204
183 public string get_drag_data ()205 public string get_drag_data ()
@@ -204,5 +226,85 @@
204 }226 }
205 return false;227 return false;
206 }228 }
229
230 /* all this icon loading stuff can go when we switch from liblauncher to
231 * bamf - please ignore any icon loading bugs :-)
232 */
233 protected void load_icon_from_icon_name (string icon_name)
234 {
235 // first try to load from a path;
236 if (try_load_from_file (icon_name))
237 {
238 return;
239 }
240
241 //try to load from a path that we augment
242 if (try_load_from_file ("/usr/share/pixmaps/" + icon_name))
243 {
244 return;
245 }
246
247 theme_file_path = new Unity.ThemeFilePath ();
248
249 // add our searchable themes
250 Gtk.IconTheme theme = Gtk.IconTheme.get_default ();
251 theme_file_path.add_icon_theme (theme);
252 theme = new Gtk.IconTheme ();
253
254 theme.set_custom_theme ("unity-icon-theme");
255 theme_file_path.add_icon_theme (theme);
256 theme.set_custom_theme ("Web");
257 theme_file_path.add_icon_theme (theme);
258
259 theme_file_path.found_icon_path.connect ((theme, filepath) => {
260 try
261 {
262 child.icon = new Gdk.Pixbuf.from_file (filepath);
263 }
264 catch (Error e)
265 {
266 warning (@"Could not load from $filepath");
267 }
268 });
269 theme_file_path.failed.connect (() => {
270 // we didn't get an icon, so just load the failcon
271 try
272 {
273 var default_theme = Gtk.IconTheme.get_default ();
274 child.icon = default_theme.load_icon(Gtk.STOCK_MISSING_IMAGE, 48, 0);
275 }
276 catch (Error e)
277 {
278 warning (@"Could not load any icon for %s", icon_name);
279 }
280 });
281 theme_file_path.get_icon_filepath (icon_name);
282 }
283
284 private bool try_load_from_file (string filepath)
285 {
286 Gdk.Pixbuf pixbuf = null;
287 if (FileUtils.test(filepath, FileTest.IS_REGULAR))
288 {
289 try
290 {
291 pixbuf = new Gdk.Pixbuf.from_file_at_scale(filepath,
292 48, 48, true);
293 }
294 catch (Error e)
295 {
296 warning ("Unable to load image from file '%s': %s",
297 filepath,
298 e.message);
299 }
300
301 if (pixbuf is Gdk.Pixbuf)
302 {
303 child.icon = pixbuf;
304 return true;
305 }
306 }
307 return false;
308 }
207 }309 }
208}310}
209311
=== modified file 'unity-private/launcher/scrollerchild.vala'
--- unity-private/launcher/scrollerchild.vala 2010-06-24 11:22:50 +0000
+++ unity-private/launcher/scrollerchild.vala 2010-07-22 16:19:42 +0000
@@ -24,6 +24,23 @@
2424
25namespace Unity.Launcher25namespace Unity.Launcher
26{26{
27 const string HONEYCOMB_MASK_FILE = Unity.PKGDATADIR
28 + "/honeycomb-mask.png";
29 const string MENU_BG_FILE = Unity.PKGDATADIR
30 + "/tight_check_4px.png";
31
32 const float WIGGLE_SIZE = 5; // how many degree's to wiggle on either side.
33 const int WIGGLE_FREQUENCY = 5; // x times a second
34 const int WIGGLE_RUN_LENGTH = 5000; // 5 seconds of wiggle
35 const int WIGGLE_PAUSE_LENGTH = 20; // followed by 20 seconds of no wiggle
36
37 private enum AnimState {
38 RISING,
39 LOOPING,
40 FALLING,
41 STOPPED
42 }
43
27 public enum PinType {44 public enum PinType {
28 UNPINNED,45 UNPINNED,
29 PINNED,46 PINNED,
@@ -31,12 +48,8 @@
31 NEVER48 NEVER
32 }49 }
3350
34 public abstract class ScrollerChild : Ctk.Actor51 public class ScrollerChild : Ctk.Actor
35 {52 {
36 construct
37 {
38 }
39
40 public Gdk.Pixbuf icon {get; set;}53 public Gdk.Pixbuf icon {get; set;}
41 public PinType pin_type;54 public PinType pin_type;
42 public float position {get; set;}55 public float position {get; set;}
@@ -47,8 +60,6 @@
47 public float rotation {get; set;}60 public float rotation {get; set;}
48 public ScrollerChildController controller; // this sucks. shouldn't be here, can't help it.61 public ScrollerChildController controller; // this sucks. shouldn't be here, can't help it.
4962
50 public abstract void force_rotation_jump (float degrees);
51
52 public string to_string ()63 public string to_string ()
53 {64 {
54 return "A scroller child; running: %s, active: %s, position: %f, opacity %f".printf (65 return "A scroller child; running: %s, active: %s, position: %f, opacity %f".printf (
@@ -57,5 +68,535 @@
57 position,68 position,
58 opacity);69 opacity);
59 }70 }
71
72 private UnityIcon processed_icon;
73 private ThemeImage active_indicator;
74 private ThemeImage running_indicator;
75 private Gdk.Pixbuf honeycomb_mask;
76
77 // effects
78 private Ctk.EffectDropShadow effect_drop_shadow;
79 private Ctk.EffectGlow effect_icon_glow;
80
81 // animations
82 private Clutter.Animation active_indicator_anim;
83 private Clutter.Animation running_indicator_anim;
84 private Clutter.Animation rotate_anim;
85 private Clutter.Timeline wiggle_timeline;
86 private Clutter.Timeline glow_timeline;
87 private Clutter.Timeline rotate_timeline;
88 private AnimState glow_state;
89 private AnimState wiggle_state;
90 private AnimState rotate_state;
91
92 private float old_rotate_value = 0.0f;
93
94 construct
95 {
96 load_textures ();
97 position = 0.0f;
98
99 //icon glow
100 glow_timeline = new Clutter.Timeline (1);
101 wiggle_timeline = new Clutter.Timeline (1);
102 rotate_timeline = new Clutter.Timeline (1);
103
104 glow_timeline.new_frame.connect (on_glow_timeline_new_frame);
105 wiggle_timeline.new_frame.connect (on_wiggle_timeline_new_frame);
106 rotate_timeline.new_frame.connect (on_rotate_timeline_new_frame);
107
108 notify["rotation"].connect (on_rotation_changed);
109 }
110
111 ~ScrollerChild ()
112 {
113 running_indicator.unparent ();
114 active_indicator.unparent ();
115 }
116
117 /* private methods */
118 private void load_textures ()
119 {
120 active_indicator = new ThemeImage ("application-selected");
121 running_indicator = new ThemeImage ("application-running");
122
123 active_indicator.set_parent (this);
124 running_indicator.set_parent (this);
125 active_indicator.set_opacity (0);
126 running_indicator.set_opacity (0);
127
128 try
129 {
130 honeycomb_mask = new Gdk.Pixbuf.from_file(HONEYCOMB_MASK_FILE);
131 }
132 catch (Error e)
133 {
134 warning ("Unable to load asset %s: %s",
135 HONEYCOMB_MASK_FILE,
136 e.message);
137 }
138
139 processed_icon = new UnityIcon (null, null);
140 processed_icon.set_size (48, 48);
141 processed_icon.set_parent (this);
142
143 notify["icon"].connect (on_icon_changed);
144 notify["running"].connect (on_running_changed);
145 notify["active"].connect (on_active_changed);
146 notify["activating"].connect (on_activating_changed);
147 notify["needs-attention"].connect (on_needs_attention_changed);
148
149 // just trigger some notifications now to set inital state
150 on_running_changed ();
151 on_active_changed ();
152 on_rotation_changed ();
153 }
154
155 public Clutter.Actor get_content ()
156 {
157 return processed_icon;
158 }
159
160 /* alpha helpers */
161 private static float get_ease_out_sine (float alpha)
162 {
163 return (float)(Math.sin ((Math.PI_2 * alpha)));
164 }
165
166 private static float get_circular_alpha (float alpha)
167 {
168 //float sine = (float)(Math.sin (-Math.PI + (alpha * (Math.PI * 2))));
169 var sine = Math.sin ((alpha * (Math.PI * 2)) - Math.PI);
170 return Math.fmaxf(((float)sine / 2.0f) + 0.5f, 0.0f);;
171 }
172 /* animation callbacks */
173
174 private void on_rotate_timeline_new_frame ()
175 {
176 float progress = (float)rotate_timeline.get_progress ();
177 switch (rotate_state)
178 {
179 case AnimState.RISING:
180 rotate_anim_rising (progress);
181 break;
182
183 case AnimState.STOPPED:
184 rotate_timeline.stop ();
185 break;
186 }
187 processed_icon.do_queue_redraw ();
188 }
189
190 private void rotate_anim_rising (float progress)
191 {
192 progress = get_ease_out_sine (progress);
193 var diff = rotation - old_rotate_value;
194 float rotate_val = old_rotate_value + (progress * diff);
195
196 processed_icon.rotation = rotate_val;
197 if (progress >= 1.0)
198 {
199 rotate_state = AnimState.STOPPED;
200 rotate_timeline.stop ();
201 }
202 }
203
204 public void force_rotation_jump (float degrees)
205 {
206 processed_icon.rotation = degrees;
207 rotation = degrees;
208 rotate_state = AnimState.STOPPED;
209 rotate_timeline.stop ();
210 do_queue_redraw ();
211 }
212
213 private void on_glow_timeline_new_frame ()
214 {
215 float progress = (float)glow_timeline.get_progress ();
216 switch (glow_state)
217 {
218 case AnimState.RISING:
219 glow_anim_rising (progress);
220 break;
221
222 case AnimState.LOOPING:
223 glow_anim_looping (progress);
224 break;
225
226 case AnimState.FALLING:
227 glow_anim_falling (progress);
228 break;
229
230 default:
231 glow_state = AnimState.STOPPED;
232 glow_timeline.stop ();
233 break;
234 }
235
236 processed_icon.do_queue_redraw ();
237 }
238
239 private float previous_glow_alpha = 0.0f;
240 private void glow_anim_rising (float progress)
241 {
242 progress = get_ease_out_sine (progress);
243 effect_icon_glow.set_opacity (progress);
244 previous_glow_alpha = progress;
245 if (progress >= 1.0)
246 {
247 glow_state = AnimState.LOOPING;
248 glow_timeline.stop ();
249 glow_timeline.set_duration (LONG_DELAY);
250 glow_timeline.set_loop (true);
251 glow_timeline.start ();
252 return;
253 }
254 }
255
256 private void glow_anim_looping (float progress)
257 {
258 progress = 1.0f - get_circular_alpha (progress);
259 effect_icon_glow.set_opacity (progress);
260 previous_glow_alpha = progress;
261 processed_icon.do_queue_redraw ();
262 }
263
264 private void glow_anim_falling (float progress)
265 {
266 float alpha_length = previous_glow_alpha;
267 effect_icon_glow.set_opacity (alpha_length - (progress * alpha_length));
268
269 if (progress >= 1.0)
270 {
271 glow_state = AnimState.STOPPED;
272 glow_timeline.stop ();
273 glow_timeline.set_loop (false);
274 }
275 }
276
277 private void on_wiggle_timeline_new_frame ()
278 {
279 float progress = (float)wiggle_timeline.get_progress ();
280
281 switch (wiggle_state)
282 {
283 case AnimState.RISING:
284 wiggle_anim_rising (progress);
285 break;
286
287 case AnimState.LOOPING:
288 wiggle_anim_looping (progress);
289 break;
290
291 case AnimState.FALLING:
292 wiggle_anim_falling (progress);
293 break;
294
295 default:
296 wiggle_state = AnimState.STOPPED;
297 wiggle_timeline.stop ();
298 break;
299 }
300
301 processed_icon.do_queue_redraw ();
302 }
303
304 private float previous_wiggle_alpha = 0.0f;
305 private void wiggle_anim_rising (float progress)
306 {
307 progress = get_ease_out_sine (progress);
308 processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE,
309 25.0f, 25.0f, 0.0f);
310 previous_wiggle_alpha = progress;
311 if (progress >= 1.0)
312 {
313 wiggle_state = AnimState.LOOPING;
314 wiggle_timeline.stop ();
315 wiggle_timeline.set_duration (WIGGLE_RUN_LENGTH);
316 wiggle_timeline.set_loop (true);
317 wiggle_timeline.start ();
318 return;
319 }
320 }
321
322 private void wiggle_anim_looping (float progress)
323 {
324 if (progress >= 1.0)
325 {
326 wiggle_state = AnimState.FALLING;
327 wiggle_timeline.stop ();
328 wiggle_timeline.set_loop (false);
329 wiggle_timeline.start ();
330 }
331
332 int frequency = WIGGLE_FREQUENCY * (WIGGLE_RUN_LENGTH / 1000);
333 progress = get_circular_alpha (Math.fmodf (progress * frequency, 1.0f));
334 progress = (1.0f - progress) * 2.0f - 1.0f;
335 processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE,
336 25.0f, 25.0f, 0.0f);
337 processed_icon.do_queue_redraw ();
338 previous_wiggle_alpha = progress;
339
340
341 }
342
343 private bool check_continue_wiggle ()
344 {
345 if (needs_attention)
346 {
347 wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY);
348 wiggle_state = AnimState.RISING;
349 wiggle_timeline.start ();
350 }
351 return false;
352 }
353
354 private void wiggle_anim_falling (float progress)
355 {
356 float alpha_length = previous_wiggle_alpha;
357 float angle = alpha_length - (progress * alpha_length);
358 processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, angle,
359 25.0f, 25.0f, 0.0f);
360
361 if (progress >= 1.0)
362 {
363 wiggle_state = AnimState.STOPPED;
364 wiggle_timeline.stop ();
365 wiggle_timeline.set_loop (false);
366 GLib.Timeout.add_seconds (WIGGLE_PAUSE_LENGTH, check_continue_wiggle);
367 }
368 }
369
370 /* notifications */
371 private void on_icon_changed ()
372 {
373 if (icon is Gdk.Pixbuf)
374 {
375 Gdk.Pixbuf scaled_buf;
376 int max_size = 48;
377 if (!Unity.pixbuf_is_tile (icon))
378 max_size = 40;
379
380 if (icon.get_width () > max_size || icon.get_height () > max_size)
381 {
382 scaled_buf = icon.scale_simple (max_size, max_size, Gdk.InterpType.HYPER);
383 }
384 else
385 {
386 scaled_buf = icon;
387 }
388
389 Gdk.Pixbuf color_buf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 1, 1);
390 uint red, green, blue;
391 Unity.get_average_color (scaled_buf, out red, out green, out blue);
392 unowned uchar[] pixels = color_buf.get_pixels ();
393 pixels[0] = (uchar)red;
394 pixels[1] = (uchar)green;
395 pixels[2] = (uchar)blue;
396 pixels[3] = 255;
397
398 var tex = GtkClutter.texture_new_from_pixbuf (scaled_buf);
399 var color = GtkClutter.texture_new_from_pixbuf (color_buf);
400
401 processed_icon = new UnityIcon (tex as Clutter.Texture, color as Clutter.Texture);
402 processed_icon.set_parent (this);
403 processed_icon.rotation = rotation;
404
405 this.effect_drop_shadow = new Ctk.EffectDropShadow (5.0f, 0, 2);
406 effect_drop_shadow.set_opacity (0.4f);
407 this.effect_drop_shadow.set_margin (5);
408 this.processed_icon.add_effect (effect_drop_shadow);
409
410 do_queue_redraw ();
411 }
412 }
413
414 private void on_running_changed ()
415 {
416 uint target_opacity = 0;
417 if (running)
418 target_opacity = 255;
419
420 if (running_indicator_anim is Clutter.Animation)
421 running_indicator_anim.completed ();
422
423 running_indicator_anim = running_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE,
424 SHORT_DELAY,
425 "opacity", target_opacity);
426 }
427
428 private void on_active_changed ()
429 {
430 uint target_opacity = 0;
431 if (active)
432 target_opacity = 255;
433
434 if (active_indicator_anim is Clutter.Animation)
435 active_indicator_anim.completed ();
436 active_indicator_anim = active_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE,
437 SHORT_DELAY,
438 "opacity", target_opacity);
439 }
440
441 private void on_rotation_changed ()
442 {
443 old_rotate_value = processed_icon.rotation;
444
445 if (rotate_timeline is Clutter.Timeline == false)
446 return;
447
448 if (rotate_timeline.is_playing ())
449 {
450 rotate_timeline.stop ();
451 processed_icon.rotation = old_rotate_value;
452 }
453
454 rotate_timeline.set_duration (300);
455 rotate_state = AnimState.RISING;
456 rotate_timeline.start ();
457 }
458
459 private void on_activating_changed ()
460 {
461 if (glow_timeline.is_playing () && activating == false)
462 {
463 glow_timeline.stop ();
464 glow_timeline.set_duration (SHORT_DELAY);
465 glow_state = AnimState.FALLING;
466 glow_timeline.start ();
467 }
468 else if (glow_timeline.is_playing () == false && activating)
469 {
470 effect_icon_glow = new Ctk.EffectGlow ();
471 Clutter.Color c = Clutter.Color () {
472 red = 255,
473 green = 255,
474 blue = 255,
475 alpha = 255
476 };
477 effect_icon_glow.set_background_texture (honeycomb_mask);
478 effect_icon_glow.set_color (c);
479 effect_icon_glow.set_opacity (1.0f);
480 processed_icon.add_effect (effect_icon_glow);
481 effect_icon_glow.set_margin (6);
482
483 glow_timeline.set_duration (SHORT_DELAY);
484 glow_state = AnimState.RISING;
485 glow_timeline.start ();
486 }
487 }
488
489 private void on_needs_attention_changed ()
490 {
491 if (needs_attention && wiggle_timeline.is_playing () == false)
492 {
493 //start wiggling
494 wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY);
495 wiggle_state = AnimState.RISING;
496 wiggle_timeline.start ();
497 }
498 else if (needs_attention == false && wiggle_timeline.is_playing ())
499 {
500 //stop wiggling
501 wiggle_timeline.stop ();
502 wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY);
503 wiggle_state = AnimState.FALLING;
504 wiggle_timeline.start ();
505 }
506 }
507
508 /* clutter overrides */
509 public override void get_preferred_width (float for_height,
510 out float minimum_width,
511 out float natural_width)
512 {
513 float nat, min;
514 processed_icon.get_preferred_width (for_height, out min, out nat);
515 natural_width = nat;
516 minimum_width = min;
517
518 running_indicator.get_preferred_width (for_height, out min, out nat);
519 natural_width += nat;
520
521 active_indicator.get_preferred_width (for_height, out min, out nat);
522 natural_width += nat;
523 }
524
525 public override void get_preferred_height (float for_width,
526 out float minimum_height,
527 out float natural_height)
528 {
529 natural_height = 48;
530 minimum_height = 48;
531 }
532
533 public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags)
534 {
535 float x, y;
536 x = 0;
537 y = 0;
538 base.allocate (box, flags);
539
540 Clutter.ActorBox child_box = Clutter.ActorBox ();
541
542 //allocate the running indicator first
543 float width, height, n_width, n_height;
544 running_indicator.get_preferred_width (58, out n_width, out width);
545 running_indicator.get_preferred_height (58, out n_height, out height);
546 child_box.x1 = 0;
547 child_box.y1 = (box.get_height () - height) / 2.0f;
548 child_box.x2 = child_box.x1 + width;
549 child_box.y2 = child_box.y1 + height;
550 running_indicator.allocate (child_box, flags);
551 x += child_box.get_width ();
552
553 //allocate the icon
554 processed_icon.get_preferred_width (48, out width, out n_width);
555 processed_icon.get_preferred_height (48, out height, out n_height);
556 child_box.x1 = (box.get_width () - width) / 2.0f;
557 child_box.y1 = y;
558 child_box.x2 = child_box.x1 + 48;
559 child_box.y2 = child_box.y1 + height;
560 processed_icon.allocate (child_box, flags);
561
562 //allocate the active indicator
563 active_indicator.get_preferred_width (48, out n_width, out width);
564 active_indicator.get_preferred_height (48, out n_height, out height);
565 child_box.x1 = box.get_width () - width;
566 child_box.y1 = (box.get_height () - height) / 2.0f;
567 child_box.x2 = child_box.x1 + width;
568 child_box.y2 = child_box.y1 + height;
569 active_indicator.allocate (child_box, flags);
570
571 }
572
573 public override void pick (Clutter.Color color)
574 {
575 base.pick (color);
576 }
577
578 public override void paint ()
579 {
580 active_indicator.paint ();
581 running_indicator.paint ();
582
583 processed_icon.paint ();
584 }
585
586 public override void map ()
587 {
588 base.map ();
589 running_indicator.map ();
590 active_indicator.map ();
591 processed_icon.map ();
592 }
593
594 public override void unmap ()
595 {
596 base.unmap ();
597 running_indicator.unmap ();
598 active_indicator.unmap ();
599 processed_icon.unmap ();
600 }
60 }601 }
61}602}
62603
=== modified file 'unity/drag-controller.vala'
--- unity/drag-controller.vala 2010-06-08 09:43:43 +0000
+++ unity/drag-controller.vala 2010-07-22 16:19:42 +0000
@@ -63,10 +63,12 @@
6363
64 public void start_drag (Unity.Drag.Model model, float offset_x, float offset_y)64 public void start_drag (Unity.Drag.Model model, float offset_x, float offset_y)
65 {65 {
66
66 if (!(this.view is View)) {67 if (!(this.view is View)) {
67 this.view = new View (model.get_icon ().get_stage () as Clutter.Stage);68 this.view = new View (model.get_icon ().get_stage () as Clutter.Stage);
68 }69 }
69 this.view.hook_actor_to_cursor (model.get_icon (), offset_x, offset_y);70 this.view.hook_actor_to_cursor (model.get_icon (), offset_x, offset_y);
71
70 model.get_icon ().parent_set.connect (rehouse_orphaned_child);72 model.get_icon ().parent_set.connect (rehouse_orphaned_child);
71 this.model = model;73 this.model = model;
72 this.drag_start (model);74 this.drag_start (model);
@@ -88,7 +90,7 @@
88 // no parent. so set stage90 // no parent. so set stage
89 Clutter.Stage stage = old_parent.get_stage () as Clutter.Stage;91 Clutter.Stage stage = old_parent.get_stage () as Clutter.Stage;
90 actor.set_parent (stage);92 actor.set_parent (stage);
91 actor.set_position (-10000, -10000);93 actor.set_position (20000, 20000);
92 }94 }
93 }95 }
9496
9597
=== modified file 'unity/drag-view.vala'
--- unity/drag-view.vala 2010-06-08 09:43:43 +0000
+++ unity/drag-view.vala 2010-07-22 16:19:42 +0000
@@ -50,7 +50,6 @@
50 this.offset_y = offset_y;50 this.offset_y = offset_y;
5151
52 this.hooked_actor = new Clutter.Clone (actor);52 this.hooked_actor = new Clutter.Clone (actor);
53 this.hooked_actor.unparent ();
54 this.stage.add_actor (this.hooked_actor);53 this.stage.add_actor (this.hooked_actor);
5554
56 actor.get_transformed_position (out x, out y);55 actor.get_transformed_position (out x, out y);
@@ -94,6 +93,8 @@
94 this.hooked_actor.set_position (event.motion.x - this.offset_x,93 this.hooked_actor.set_position (event.motion.x - this.offset_x,
95 event.motion.y - this.offset_y);94 event.motion.y - this.offset_y);
96 this.motion (event.motion.x, event.motion.y);95 this.motion (event.motion.x, event.motion.y);
96 this.hooked_actor.set_opacity (255);
97 this.hooked_actor.show ();
97 return false;98 return false;
98 }99 }
99100
100101
=== modified file 'unity/icon-postprocessor.vala'
--- unity/icon-postprocessor.vala 2010-06-24 09:10:53 +0000
+++ unity/icon-postprocessor.vala 2010-07-22 16:19:42 +0000
@@ -254,6 +254,11 @@
254 g_total = g_total / uint.max (total_caught_pixels, 1);254 g_total = g_total / uint.max (total_caught_pixels, 1);
255 b_total = b_total / uint.max (total_caught_pixels, 1);255 b_total = b_total / uint.max (total_caught_pixels, 1);
256256
257 rs_total = rs_total / (width * height);
258 gs_total = gs_total / (width * height);
259 bs_total = bs_total / (width * height);
260
261
257 // get a new super saturated value based on our totals262 // get a new super saturated value based on our totals
258 if (total_caught_pixels <= 20)263 if (total_caught_pixels <= 20)
259 {264 {
@@ -491,7 +496,9 @@
491 }496 }
492 };497 };
493498
494 uchar opacity = self.get_paint_opacity ();499 uchar opacity = self.get_opacity ();
500
501 //debug (@"opacity is set to $opacity");
495502
496 self.bg_mat.set_color4ub (opacity, opacity, opacity, opacity);503 self.bg_mat.set_color4ub (opacity, opacity, opacity, opacity);
497 self.bgcol_material.set_color4ub (opacity, opacity, opacity, opacity);504 self.bgcol_material.set_color4ub (opacity, opacity, opacity, opacity);