class->paint = NULL;
class->update = NULL;
class->act_mode_enter = NULL;
-
+
g_object_class_install_property (gobject_class,
PROP_ACTIVITY_MODE,
g_param_spec_boolean ("activity-mode",
P_("Activity mode"),
- P_("If TRUE, the GtkProgress is in activity mode, meaning that it signals something is happening, but not how much of the activity is finished. This is used when you're doing something that you don't know how long it will take"),
+ P_("If TRUE, the GtkProgress is in activity mode, meaning that it signals "
+ "something is happening, but not how much of the activity is finished. "
+ "This is used when you're doing something but don't know how long it will take."),
FALSE,
GTK_PARAM_READWRITE));
-
g_object_class_install_property (gobject_class,
PROP_SHOW_TEXT,
g_param_spec_boolean ("show-text",
P_("Show text"),
- P_("Whether the progress is shown as text"),
+ P_("Whether the progress is shown as text."),
FALSE,
GTK_PARAM_READWRITE));
-
g_object_class_install_property (gobject_class,
PROP_TEXT_XALIGN,
g_param_spec_float ("text-xalign",
P_("Text x alignment"),
- P_("A number between 0.0 and 1.0 specifying the horizontal alignment of the text in the progress widget"),
- 0.0,
- 1.0,
- 0.5,
+ P_("The horizontal text alignment, from 0 (left) to 1 (right). Reversed for RTL layouts."),
+ 0.0, 1.0, 0.5,
GTK_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
+ g_object_class_install_property (gobject_class,
PROP_TEXT_YALIGN,
g_param_spec_float ("text-yalign",
P_("Text y alignment"),
- P_("A number between 0.0 and 1.0 specifying the vertical alignment of the text in the progress widget"),
- 0.0,
- 1.0,
- 0.5,
+ P_("The vertical text alignment, from 0 (top) to 1 (bottom)."),
+ 0.0, 1.0, 0.5,
GTK_PARAM_READWRITE));
}
#define MIN_VERTICAL_BAR_WIDTH 22
#define MIN_VERTICAL_BAR_HEIGHT 80
#define MAX_TEXT_LENGTH 80
-#define TEXT_SPACING 2
enum {
PROP_0,
g_param_spec_uint ("activity-step",
P_("Activity Step"),
P_("The increment used for each iteration in activity mode (Deprecated)"),
- 0,
- G_MAXUINT,
- 3,
+ 0, G_MAXUINT, 3,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
g_param_spec_uint ("activity-blocks",
P_("Activity Blocks"),
P_("The number of blocks which can fit in the progress bar area in activity mode (Deprecated)"),
- 2,
- G_MAXUINT,
- 5,
+ 2, G_MAXUINT, 5,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
g_param_spec_uint ("discrete-blocks",
P_("Discrete Blocks"),
P_("The number of discrete blocks in a progress bar (when shown in the discrete style)"),
- 2,
- G_MAXUINT,
- 10,
+ 2, G_MAXUINT, 10,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
g_param_spec_double ("fraction",
P_("Fraction"),
P_("The fraction of total work that has been completed"),
- 0.0,
- 1.0,
- 0.0,
+ 0.0, 1.0, 0.0,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
g_param_spec_double ("pulse-step",
P_("Pulse Step"),
P_("The fraction of total progress to move the bouncing block when pulsed"),
- 0.0,
- 1.0,
- 0.1,
+ 0.0, 1.0, 0.1,
GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_ELLIPSIZE,
g_param_spec_enum ("ellipsize",
P_("Ellipsize"),
- P_("The preferred place to ellipsize the string, if the progressbar does not have enough room to display the entire string, if at all"),
+ P_("The preferred place to ellipsize the string, if the progress bar "
+ "does not have enough room to display the entire string, if at all."),
PANGO_TYPE_ELLIPSIZE_MODE,
PANGO_ELLIPSIZE_NONE,
GTK_PARAM_READWRITE));
-
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("xspacing",
+ P_("XSpacing"),
+ P_("Extra spacing applied to the width of a progress bar."),
+ 0, G_MAXINT, 7,
+ G_PARAM_READWRITE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("yspacing",
+ "YSpacing",
+ "Extra spacing applied to the height of a progress bar.",
+ 0, G_MAXINT, 7,
+ G_PARAM_READWRITE));
}
static void
PangoRectangle logical_rect;
PangoLayout *layout;
gint width, height;
+ gint xspacing, yspacing;
g_return_if_fail (GTK_IS_PROGRESS_BAR (widget));
g_return_if_fail (requisition != NULL);
+ gtk_widget_style_get (widget,
+ "xspacing", &xspacing,
+ "yspacing", &yspacing,
+ NULL);
+
progress = GTK_PROGRESS (widget);
pbar = GTK_PROGRESS_BAR (widget);
- width = 2 * widget->style->xthickness + 3 + 2 * TEXT_SPACING;
- height = 2 * widget->style->ythickness + 3 + 2 * TEXT_SPACING;
+ width = 2 * widget->style->xthickness + xspacing;
+ height = 2 * widget->style->ythickness + yspacing;
if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
{
{
GtkProgress *progress = GTK_PROGRESS (pbar);
GtkWidget *widget = GTK_WIDGET (pbar);
-
gint x;
gint y;
gchar *buf;
PangoLayout *layout;
PangoRectangle logical_rect;
GdkRectangle prelight_clip, normal_clip;
-
+ gfloat text_xalign = progress->x_align;
+ gfloat text_yalign = progress->y_align;
+
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
+ text_xalign = 1.0 - text_xalign;
+
buf = gtk_progress_get_current_text (progress);
layout = gtk_widget_create_pango_layout (widget, buf);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- x = widget->style->xthickness + 1 +
- (widget->allocation.width - 2 * widget->style->xthickness -
- 2 - logical_rect.width)
- * progress->x_align;
-
- y = widget->style->ythickness + 1 +
- (widget->allocation.height - 2 * widget->style->ythickness -
- 2 - logical_rect.height)
- * progress->y_align;
+ x = widget->style->xthickness + 1 + text_xalign *
+ (widget->allocation.width - 2 * widget->style->xthickness -
+ 2 - logical_rect.width);
+
+ y = widget->style->ythickness + 1 + text_yalign *
+ (widget->allocation.height - 2 * widget->style->ythickness -
+ 2 - logical_rect.height);
rect.x = widget->style->xthickness;
rect.y = widget->style->ythickness;