Skip to content

Commit ef61a5e

Browse files
committed
Add done_callback
1 parent f4c9462 commit ef61a5e

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/Gestures/GesturePropertyTransition.vala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* with easing without a gesture. Respects the enable animation setting.
1111
*/
1212
public class Gala.GesturePropertyTransition : Object {
13+
public delegate void DoneCallback ();
14+
1315
/**
1416
* Emitted when all animations are finished that is when the property has reached the target value
1517
* either via gesture or via easing or combined.
@@ -74,10 +76,20 @@ public class Gala.GesturePropertyTransition : Object {
7476
* it will connect to the gesture trackers signals and animate according to the input finishing with an easing
7577
* to the final position. If with_gesture is false it will just ease to the {@link to_value}.
7678
* #this will keep itself alive until the animation finishes so it is safe to immediatly unref it after creation and calling start.
79+
*
80+
* @param done_callback a callback for when the transition finishes. It is guaranteed to be called exactly once.
7781
*/
78-
public void start (bool with_gesture) {
82+
public void start (bool with_gesture, owned DoneCallback? done_callback = null) {
7983
ref ();
8084

85+
if (done_callback != null) {
86+
ulong done_callback_handler = 0;
87+
done_callback_handler = done.connect (() => {
88+
done_callback ();
89+
disconnect (done_callback_handler);
90+
});
91+
}
92+
8193
Value current_value = {};
8294
actor.get_property (property, ref current_value);
8395

src/Widgets/WindowClone.vala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,7 @@ public class Gala.WindowClone : Clutter.Actor {
291291
new GesturePropertyTransition (this, gesture_tracker, "width", null, (float) outer_rect.width).start (with_gesture);
292292
new GesturePropertyTransition (this, gesture_tracker, "height", null, (float) outer_rect.height).start (with_gesture);
293293
new GesturePropertyTransition (this, gesture_tracker, "shadow-opacity", (uint8) 255, (uint8) 0).start (with_gesture);
294-
var opacity_transition = new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 255u, 0u);
295-
opacity_transition.start (with_gesture);
296-
opacity_transition.done.connect (() => {
294+
new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 255u, 0u).start (with_gesture, () => {
297295
in_slot_animation = false;
298296
place_widgets (outer_rect.width, outer_rect.height, target_scale);
299297
});
@@ -364,9 +362,7 @@ public class Gala.WindowClone : Clutter.Actor {
364362
new GesturePropertyTransition (this, gesture_tracker, "width", (float) initial_width, (float) rect.width).start (with_gesture);
365363
new GesturePropertyTransition (this, gesture_tracker, "height", (float) initial_height, (float) rect.height).start (with_gesture);
366364
new GesturePropertyTransition (this, gesture_tracker, "shadow-opacity", (uint8) 0, (uint8) 255).start (with_gesture);
367-
var opacity_transition = new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 0u, 255u);
368-
opacity_transition.start (with_gesture);
369-
opacity_transition.done.connect (() => {
365+
new GesturePropertyTransition (window_icon, gesture_tracker, "opacity", 0u, 255u).start (with_gesture, () => {
370366
in_slot_animation = false;
371367
place_widgets (rect.width, rect.height, scale);
372368
});

src/WindowManager.vala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,10 @@ namespace Gala {
644644
}
645645

646646
new GesturePropertyTransition (out_group, gesture_tracker, "x", 0f, 0f, dest).start (switch_workspace_with_gesture);
647-
var transition = new GesturePropertyTransition (wallpaper, gesture_tracker, "x", 0f, 0f, dest);
648-
transition.done.connect (() => {
647+
new GesturePropertyTransition (wallpaper, gesture_tracker, "x", 0f, 0f, dest).start (switch_workspace_with_gesture, () => {
649648
switch_workspace_animation_finished (direction, false, true);
650649
animating_switch_workspace = false;
651650
});
652-
transition.start (switch_workspace_with_gesture);
653651
}
654652

655653
private void update_input_area () {

0 commit comments

Comments
 (0)