gdouble fraction;
gdouble pulse_fraction;
- gint activity_pos;
+ double activity_pos;
guint activity_blocks;
- guint activity_step;
GtkOrientation orientation;
priv->pulse_fraction = 0.1;
priv->activity_pos = 0;
priv->activity_dir = 1;
- priv->activity_step = 3;
priv->activity_blocks = 5;
priv->ellipsize = PANGO_ELLIPSIZE_NONE;
priv->show_text = FALSE;
if (priv->activity_mode)
{
- GtkAllocation allocation;
- GtkStyleContext *context;
- GtkStateFlags state;
- GtkBorder padding;
- gint size;
-
- gtk_widget_get_allocation (widget, &allocation);
- context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
- gtk_style_context_get_padding (context, state, &padding);
-
/* advance the block */
- if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ if (priv->activity_dir == 0)
{
- /* Update our activity step. */
- priv->activity_step = allocation.width * priv->pulse_fraction;
-
- size = MAX (2, allocation.width / priv->activity_blocks);
-
- if (priv->activity_dir == 0)
- {
- priv->activity_pos += priv->activity_step;
- if (priv->activity_pos + size >= allocation.width - padding.left)
- {
- priv->activity_pos = allocation.width - padding.left - size;
- priv->activity_dir = 1;
- }
- }
- else
+ priv->activity_pos += priv->pulse_fraction;
+ if (priv->activity_pos > 1.0)
{
- priv->activity_pos -= priv->activity_step;
- if (priv->activity_pos <= padding.left)
- {
- priv->activity_pos = padding.left;
- priv->activity_dir = 0;
- }
+ priv->activity_pos = 1.0;
+ priv->activity_dir = 1;
}
}
else
{
- /* Update our activity step. */
- priv->activity_step = allocation.height * priv->pulse_fraction;
-
- size = MAX (2, allocation.height / priv->activity_blocks);
-
- if (priv->activity_dir == 0)
+ priv->activity_pos -= priv->pulse_fraction;
+ if (priv->activity_pos <= 0)
{
- priv->activity_pos += priv->activity_step;
- if (priv->activity_pos + size >= allocation.height - padding.top)
- {
- priv->activity_pos = allocation.height - padding.top - size;
- priv->activity_dir = 1;
- }
- }
- else
- {
- priv->activity_pos -= priv->activity_step;
- if (priv->activity_pos <= padding.top)
- {
- priv->activity_pos = padding.top;
- priv->activity_dir = 0;
- }
+ priv->activity_pos = 0;
+ priv->activity_dir = 0;
}
}
}
gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
{
GtkProgressBarPrivate *priv = pbar->priv;
- GtkAllocation allocation;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
{
if (!inverted)
{
- priv->activity_pos = padding.left;
+ priv->activity_pos = 0.0;
priv->activity_dir = 0;
}
else
{
- gtk_widget_get_allocation (widget, &allocation);
- priv->activity_pos = allocation.width - padding.left -
- (allocation.height - padding.top - padding.bottom);
+ priv->activity_pos = 1.0;
priv->activity_dir = 1;
}
}
{
if (!inverted)
{
- priv->activity_pos = padding.top;
+ priv->activity_pos = 0.0;
priv->activity_dir = 0;
}
else
{
- gtk_widget_get_allocation (widget, &allocation);
- priv->activity_pos = allocation.height - padding.top -
- (allocation.width - padding.left - padding.right);
+ priv->activity_pos = 1.0;
priv->activity_dir = 1;
}
}
gint *amount)
{
GtkProgressBarPrivate *priv = pbar->priv;
- GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (pbar);
+ GtkStyleContext *context;
+ GtkAllocation allocation;
+ GtkStateFlags state;
+ GtkBorder padding;
+ int size;
- *offset = priv->activity_pos;
-
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_style_context_get_state (context);
gtk_widget_get_allocation (widget, &allocation);
+ gtk_style_context_get_padding (context, state, &padding);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- *amount = MAX (2, allocation.width / priv->activity_blocks);
+ size = allocation.width - padding.left - padding.top;
else
- *amount = MAX (2, allocation.height / priv->activity_blocks);
+ size = allocation.height - padding.left - padding.top;
+
+ *amount = MAX (2, size / priv->activity_blocks);
+ *offset = priv->activity_pos * (size - *amount);
}
static void