forked from AuroraMiddleware/gtk
Add GtkSpinner::animation-duration style property
This commit is contained in:
parent
9112194791
commit
e9a240cd52
@ -275,8 +275,10 @@ do_list_store (GtkWidget *do_widget)
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
{
|
||||
gtk_widget_show_all (window);
|
||||
if (timeout == 0)
|
||||
if (timeout == 0) {
|
||||
//FIXME this should use the animation-duration instead
|
||||
timeout = g_timeout_add (80, spinner_timeout, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -130,9 +130,10 @@ gtk_cell_renderer_spinner_class_init (GtkCellRendererSpinnerClass *klass)
|
||||
* Pulse of the spinner. Increment this value to draw the next frame of the
|
||||
* spinner animation. Usually, you would update this value in a timeout.
|
||||
*
|
||||
* The #GtkSpinner widget draws one full cycle of the animation per second.
|
||||
* The #GtkSpinner widget draws one full cycle of the animation per second by default.
|
||||
* You can learn about the number of frames used by the theme
|
||||
* by looking at the #GtkSpinner:num-steps style property
|
||||
* by looking at the #GtkSpinner:num-steps style property and the duration
|
||||
* of the cycle by looking at #GtkSpinner:cycle-duration.
|
||||
*
|
||||
* Since 2.20
|
||||
*/
|
||||
|
@ -67,6 +67,7 @@ struct _GtkSpinnerPrivate
|
||||
{
|
||||
guint current;
|
||||
guint num_steps;
|
||||
guint cycle_duration;
|
||||
guint timeout;
|
||||
};
|
||||
|
||||
@ -128,18 +129,35 @@ gtk_spinner_class_init (GtkSpinnerClass *klass)
|
||||
* GtkSpinner:num-steps:
|
||||
*
|
||||
* The number of steps for the spinner to complete a full loop.
|
||||
* The animation will complete a full cycle in one second.
|
||||
* The animation will complete a full cycle in one second by default
|
||||
* (see the #GtkSpinner:cycle-duration style property).
|
||||
*
|
||||
* Since: 2.20
|
||||
*/
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_uint ("num-steps",
|
||||
P_("Number of steps"),
|
||||
P_("The number of steps for the spinner to complete a full loop. The animation will complete a full cycle in one second."),
|
||||
P_("The number of steps for the spinner to complete a full loop. The animation will complete a full cycle in one second by default (see #GtkSpinner::cycle-duration)."),
|
||||
1,
|
||||
G_MAXUINT,
|
||||
12,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* GtkSpinner::cycle-duration:
|
||||
*
|
||||
* The duration in milliseconds for the spinner to complete a full cycle.
|
||||
*
|
||||
* Since: 2.20
|
||||
*/
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_uint ("cycle-duration",
|
||||
P_("Animation duration"),
|
||||
P_("The length of time in milliseconds for the spinner to complete a full loop"),
|
||||
500,
|
||||
G_MAXUINT,
|
||||
1000,
|
||||
G_PARAM_READABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -252,6 +270,7 @@ gtk_spinner_style_set (GtkWidget *widget,
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (widget),
|
||||
"num-steps", &(priv->num_steps),
|
||||
"cycle-duration", &(priv->cycle_duration),
|
||||
NULL);
|
||||
|
||||
if (priv->current > priv->num_steps)
|
||||
@ -515,7 +534,7 @@ gtk_spinner_start (GtkSpinner *spinner)
|
||||
if (priv->timeout != 0)
|
||||
return;
|
||||
|
||||
priv->timeout = gdk_threads_add_timeout (1000 / priv->num_steps, gtk_spinner_timeout, spinner);
|
||||
priv->timeout = gdk_threads_add_timeout (priv->cycle_duration / priv->num_steps, gtk_spinner_timeout, spinner);
|
||||
g_object_notify (G_OBJECT (spinner), "active");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user