Merge lp:~cimi/overlay-scrollbar/stop-func-on-os-animation-stop into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 245
Merged at revision: 245
Proposed branch: lp:~cimi/overlay-scrollbar/stop-func-on-os-animation-stop
Merge into: lp:overlay-scrollbar
Diff against target: 181 lines (+49/-16)
4 files modified
os/os-animation.c (+9/-3)
os/os-pager.c (+22/-5)
os/os-private.h (+3/-1)
os/os-thumb.c (+15/-7)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/stop-func-on-os-animation-stop
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+63989@code.launchpad.net

Description of the change

Simply add a stop_func callback to animation_stop

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'os/os-animation.c'
--- os/os-animation.c 2011-05-18 18:25:13 +0000
+++ os/os-animation.c 2011-06-09 11:26:07 +0000
@@ -210,11 +210,15 @@
210/**210/**
211 * os_animation_stop:211 * os_animation_stop:
212 * @animation: a #OsAnimation212 * @animation: a #OsAnimation
213 * @stop_func: function to call at the stop
213 *214 *
214 * Stops the animation215 * Stops the animation.
216 * Before stopping, calls stop_func (if not NULL),
217 * or end_func (if not NULL).
215 **/218 **/
216void219void
217os_animation_stop (OsAnimation* animation)220os_animation_stop (OsAnimation* animation,
221 OsAnimationStopFunc stop_func)
218{222{
219 OsAnimationPrivate* priv;223 OsAnimationPrivate* priv;
220224
@@ -224,7 +228,9 @@
224228
225 if (priv->source_id != 0)229 if (priv->source_id != 0)
226 {230 {
227 if (priv->end_func != NULL)231 if (stop_func != NULL)
232 stop_func (priv->user_data);
233 else if (priv->end_func != NULL)
228 priv->end_func (priv->user_data);234 priv->end_func (priv->user_data);
229235
230 g_source_remove (priv->source_id);236 g_source_remove (priv->source_id);
231237
=== modified file 'os/os-pager.c'
--- os/os-pager.c 2011-06-08 15:20:18 +0000
+++ os/os-pager.c 2011-06-09 11:26:07 +0000
@@ -142,7 +142,22 @@
142 if (priv->parent == NULL)142 if (priv->parent == NULL)
143 return;143 return;
144144
145 draw_connection (pager);145 draw_pager (pager);
146}
147
148/* stop_func called by the change-state animation */
149static void
150change_state_stop_cb (gpointer user_data)
151{
152 OsPager *pager;
153 OsPagerPrivate *priv;
154
155 pager = OS_PAGER (user_data);
156
157 priv = pager->priv;
158
159 priv->weight = 1.0f;
160
146 draw_pager (pager);161 draw_pager (pager);
147}162}
148163
@@ -163,7 +178,9 @@
163 priv->connection_window == NULL)178 priv->connection_window == NULL)
164 return;179 return;
165180
166 draw_connection (pager);181 /* FIXME(Cimi) comment out draw_connection once it'll use gtk+ colors.
182 * Right now, it's using static colors so redrawing is useless. */
183// draw_connection (pager);
167 draw_pager (pager);184 draw_pager (pager);
168}185}
169186
@@ -366,7 +383,7 @@
366 return;383 return;
367384
368 /* if there's an animation currently running, stop it. */385 /* if there's an animation currently running, stop it. */
369 os_animation_stop (priv->animation);386 os_animation_stop (priv->animation, change_state_stop_cb);
370387
371 gdk_window_hide (priv->connection_window);388 gdk_window_hide (priv->connection_window);
372 gdk_window_hide (priv->pager_window);389 gdk_window_hide (priv->pager_window);
@@ -440,7 +457,7 @@
440 /* only start the animation if the pager is visible. */457 /* only start the animation if the pager is visible. */
441 if (gdk_window_is_visible (priv->pager_window))458 if (gdk_window_is_visible (priv->pager_window))
442 {459 {
443 os_animation_stop (priv->animation);460 os_animation_stop (priv->animation, NULL);
444461
445 os_animation_set_duration (priv->animation, priv->active ? DURATION_FADE_IN :462 os_animation_set_duration (priv->animation, priv->active ? DURATION_FADE_IN :
446 DURATION_FADE_OUT);463 DURATION_FADE_OUT);
@@ -606,7 +623,7 @@
606623
607 /* stop currently running animation. */624 /* stop currently running animation. */
608 if (priv->animation != NULL)625 if (priv->animation != NULL)
609 os_animation_stop (priv->animation);626 os_animation_stop (priv->animation, NULL);
610627
611 if (priv->parent != NULL)628 if (priv->parent != NULL)
612 {629 {
613630
=== modified file 'os/os-private.h'
--- os/os-private.h 2011-05-12 23:39:33 +0000
+++ os/os-private.h 2011-06-09 11:26:07 +0000
@@ -109,6 +109,7 @@
109109
110typedef void (*OsAnimationUpdateFunc) (gfloat weight, gpointer user_data);110typedef void (*OsAnimationUpdateFunc) (gfloat weight, gpointer user_data);
111typedef void (*OsAnimationEndFunc) (gpointer user_data);111typedef void (*OsAnimationEndFunc) (gpointer user_data);
112typedef void (*OsAnimationStopFunc) (gpointer user_data);
112113
113typedef struct _OsAnimation OsAnimation;114typedef struct _OsAnimation OsAnimation;
114typedef struct _OsAnimationPrivate OsAnimationPrivate;115typedef struct _OsAnimationPrivate OsAnimationPrivate;
@@ -137,7 +138,8 @@
137138
138void os_animation_start (OsAnimation* animation);139void os_animation_start (OsAnimation* animation);
139140
140void os_animation_stop (OsAnimation* animation);141void os_animation_stop (OsAnimation* animation,
142 OsAnimationStopFunc stop_func);
141143
142/* os-thumb.c */144/* os-thumb.c */
143145
144146
=== modified file 'os/os-thumb.c'
--- os/os-thumb.c 2011-06-07 11:35:29 +0000
+++ os/os-thumb.c 2011-06-09 11:26:07 +0000
@@ -100,6 +100,17 @@
100 gtk_widget_hide (GTK_WIDGET (thumb));100 gtk_widget_hide (GTK_WIDGET (thumb));
101}101}
102102
103/* stop_func called by the fade-out animation */
104static void
105fade_out_stop_cb (gpointer user_data)
106{
107 OsThumb *thumb;
108
109 thumb = OS_THUMB (user_data);
110
111 gtk_window_set_opacity (GTK_WINDOW (thumb), 1.0f);
112}
113
103/* timeout before starting the fade-out animation */114/* timeout before starting the fade-out animation */
104static gboolean115static gboolean
105timeout_fade_out_cb (gpointer user_data)116timeout_fade_out_cb (gpointer user_data)
@@ -214,8 +225,7 @@
214225
215 /* Stop the animation on user interaction,226 /* Stop the animation on user interaction,
216 * the button_press_event. */227 * the button_press_event. */
217 os_animation_stop (priv->animation);228 os_animation_stop (priv->animation, fade_out_stop_cb);
218 gtk_window_set_opacity (GTK_WINDOW (widget), 1.0f);
219229
220 if (event->type == GDK_BUTTON_PRESS)230 if (event->type == GDK_BUTTON_PRESS)
221 {231 {
@@ -573,7 +583,7 @@
573 priv->source_id = 0;583 priv->source_id = 0;
574 }584 }
575585
576 os_animation_stop (priv->animation);586 os_animation_stop (priv->animation, NULL);
577 }587 }
578588
579 priv->use_tolerance = FALSE;589 priv->use_tolerance = FALSE;
@@ -624,8 +634,7 @@
624 }634 }
625635
626 /* On motion, stop the fade-out. */636 /* On motion, stop the fade-out. */
627 os_animation_stop (priv->animation);637 os_animation_stop (priv->animation, fade_out_stop_cb);
628 gtk_window_set_opacity (GTK_WINDOW (widget), 1.0f);
629638
630 /* If you're not dragging, and you're outside639 /* If you're not dragging, and you're outside
631 * the tolerance pixels, enable the fade-out.640 * the tolerance pixels, enable the fade-out.
@@ -698,8 +707,7 @@
698 }707 }
699708
700 /* if started, stop the fade-out. */709 /* if started, stop the fade-out. */
701 os_animation_stop (priv->animation);710 os_animation_stop (priv->animation, fade_out_stop_cb);
702 gtk_window_set_opacity (GTK_WINDOW (widget), 1.0f);
703711
704 priv->source_id = g_timeout_add (TIMEOUT_FADE_OUT,712 priv->source_id = g_timeout_add (TIMEOUT_FADE_OUT,
705 timeout_fade_out_cb,713 timeout_fade_out_cb,

Subscribers

People subscribed via source and target branches