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
1=== modified file 'os/os-animation.c'
2--- os/os-animation.c 2011-05-18 18:25:13 +0000
3+++ os/os-animation.c 2011-06-09 11:26:07 +0000
4@@ -210,11 +210,15 @@
5 /**
6 * os_animation_stop:
7 * @animation: a #OsAnimation
8+ * @stop_func: function to call at the stop
9 *
10- * Stops the animation
11+ * Stops the animation.
12+ * Before stopping, calls stop_func (if not NULL),
13+ * or end_func (if not NULL).
14 **/
15 void
16-os_animation_stop (OsAnimation* animation)
17+os_animation_stop (OsAnimation* animation,
18+ OsAnimationStopFunc stop_func)
19 {
20 OsAnimationPrivate* priv;
21
22@@ -224,7 +228,9 @@
23
24 if (priv->source_id != 0)
25 {
26- if (priv->end_func != NULL)
27+ if (stop_func != NULL)
28+ stop_func (priv->user_data);
29+ else if (priv->end_func != NULL)
30 priv->end_func (priv->user_data);
31
32 g_source_remove (priv->source_id);
33
34=== modified file 'os/os-pager.c'
35--- os/os-pager.c 2011-06-08 15:20:18 +0000
36+++ os/os-pager.c 2011-06-09 11:26:07 +0000
37@@ -142,7 +142,22 @@
38 if (priv->parent == NULL)
39 return;
40
41- draw_connection (pager);
42+ draw_pager (pager);
43+}
44+
45+/* stop_func called by the change-state animation */
46+static void
47+change_state_stop_cb (gpointer user_data)
48+{
49+ OsPager *pager;
50+ OsPagerPrivate *priv;
51+
52+ pager = OS_PAGER (user_data);
53+
54+ priv = pager->priv;
55+
56+ priv->weight = 1.0f;
57+
58 draw_pager (pager);
59 }
60
61@@ -163,7 +178,9 @@
62 priv->connection_window == NULL)
63 return;
64
65- draw_connection (pager);
66+ /* FIXME(Cimi) comment out draw_connection once it'll use gtk+ colors.
67+ * Right now, it's using static colors so redrawing is useless. */
68+// draw_connection (pager);
69 draw_pager (pager);
70 }
71
72@@ -366,7 +383,7 @@
73 return;
74
75 /* if there's an animation currently running, stop it. */
76- os_animation_stop (priv->animation);
77+ os_animation_stop (priv->animation, change_state_stop_cb);
78
79 gdk_window_hide (priv->connection_window);
80 gdk_window_hide (priv->pager_window);
81@@ -440,7 +457,7 @@
82 /* only start the animation if the pager is visible. */
83 if (gdk_window_is_visible (priv->pager_window))
84 {
85- os_animation_stop (priv->animation);
86+ os_animation_stop (priv->animation, NULL);
87
88 os_animation_set_duration (priv->animation, priv->active ? DURATION_FADE_IN :
89 DURATION_FADE_OUT);
90@@ -606,7 +623,7 @@
91
92 /* stop currently running animation. */
93 if (priv->animation != NULL)
94- os_animation_stop (priv->animation);
95+ os_animation_stop (priv->animation, NULL);
96
97 if (priv->parent != NULL)
98 {
99
100=== modified file 'os/os-private.h'
101--- os/os-private.h 2011-05-12 23:39:33 +0000
102+++ os/os-private.h 2011-06-09 11:26:07 +0000
103@@ -109,6 +109,7 @@
104
105 typedef void (*OsAnimationUpdateFunc) (gfloat weight, gpointer user_data);
106 typedef void (*OsAnimationEndFunc) (gpointer user_data);
107+typedef void (*OsAnimationStopFunc) (gpointer user_data);
108
109 typedef struct _OsAnimation OsAnimation;
110 typedef struct _OsAnimationPrivate OsAnimationPrivate;
111@@ -137,7 +138,8 @@
112
113 void os_animation_start (OsAnimation* animation);
114
115-void os_animation_stop (OsAnimation* animation);
116+void os_animation_stop (OsAnimation* animation,
117+ OsAnimationStopFunc stop_func);
118
119 /* os-thumb.c */
120
121
122=== modified file 'os/os-thumb.c'
123--- os/os-thumb.c 2011-06-07 11:35:29 +0000
124+++ os/os-thumb.c 2011-06-09 11:26:07 +0000
125@@ -100,6 +100,17 @@
126 gtk_widget_hide (GTK_WIDGET (thumb));
127 }
128
129+/* stop_func called by the fade-out animation */
130+static void
131+fade_out_stop_cb (gpointer user_data)
132+{
133+ OsThumb *thumb;
134+
135+ thumb = OS_THUMB (user_data);
136+
137+ gtk_window_set_opacity (GTK_WINDOW (thumb), 1.0f);
138+}
139+
140 /* timeout before starting the fade-out animation */
141 static gboolean
142 timeout_fade_out_cb (gpointer user_data)
143@@ -214,8 +225,7 @@
144
145 /* Stop the animation on user interaction,
146 * the button_press_event. */
147- os_animation_stop (priv->animation);
148- gtk_window_set_opacity (GTK_WINDOW (widget), 1.0f);
149+ os_animation_stop (priv->animation, fade_out_stop_cb);
150
151 if (event->type == GDK_BUTTON_PRESS)
152 {
153@@ -573,7 +583,7 @@
154 priv->source_id = 0;
155 }
156
157- os_animation_stop (priv->animation);
158+ os_animation_stop (priv->animation, NULL);
159 }
160
161 priv->use_tolerance = FALSE;
162@@ -624,8 +634,7 @@
163 }
164
165 /* On motion, stop the fade-out. */
166- os_animation_stop (priv->animation);
167- gtk_window_set_opacity (GTK_WINDOW (widget), 1.0f);
168+ os_animation_stop (priv->animation, fade_out_stop_cb);
169
170 /* If you're not dragging, and you're outside
171 * the tolerance pixels, enable the fade-out.
172@@ -698,8 +707,7 @@
173 }
174
175 /* if started, stop the fade-out. */
176- os_animation_stop (priv->animation);
177- gtk_window_set_opacity (GTK_WINDOW (widget), 1.0f);
178+ os_animation_stop (priv->animation, fade_out_stop_cb);
179
180 priv->source_id = g_timeout_add (TIMEOUT_FADE_OUT,
181 timeout_fade_out_cb,

Subscribers

People subscribed via source and target branches