]> Pileus Git - ~andy/gtk/commitdiff
introduced ::xspacing and ::yspacing style properties which make all
authorTim Janik <timj@gtk.org>
Tue, 29 Aug 2006 10:22:27 +0000 (10:22 +0000)
committerTim Janik <timj@src.gnome.org>
Tue, 29 Aug 2006 10:22:27 +0000 (10:22 +0000)
Fri Jul 14 16:13:37 2006  Tim Janik  <timj@gtk.org>

        * gtk/gtkprogressbar.c: introduced ::xspacing and ::yspacing style
        properties which make all hardcoded padding and spacing values
        configurable. properly swap ::text-xalign treatment for RTL widgets.

        * gtk/gtkprogress.c: fixed style property blurbs. made alignment
        proeprty more consistent with GtkMisc alignment blurbs. mention
        RTL treatment for text-xalign.

ChangeLog
gtk/gtkprogress.c
gtk/gtkprogressbar.c

index 3b50db1747d9c135bf3ff179a56677e7bd892804..8f69e52d68160c431fe312cfb8e3920c53287ec4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Jul 14 16:13:37 2006  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkprogressbar.c: introduced ::xspacing and ::yspacing style 
+       properties which make all hardcoded padding and spacing values
+       configurable. properly swap ::text-xalign treatment for RTL widgets.
+
+       * gtk/gtkprogress.c: fixed style property blurbs. made alignment 
+       proeprty more consistent with GtkMisc alignment blurbs. mention
+       RTL treatment for text-xalign.
+
 Tue Aug 29 11:57:40 2006  Tim Janik  <timj@imendio.com>
 
        * tests/testgtk.c: allow (most) windows to be resizable.
index a9b88525652cb9ad45a77f81cfbb4449e0be01ee..09a89dfab8474aeb59ee2b6995112f4196cb435d 100644 (file)
@@ -93,40 +93,36 @@ gtk_progress_class_init (GtkProgressClass *class)
   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));
 }
 
index b35d82ac9169ee763f0f37a4ff21cfd827820c48..295f4143a1244c80f980f173bd497bb3a4fb925f 100644 (file)
@@ -45,7 +45,6 @@
 #define MIN_VERTICAL_BAR_WIDTH     22
 #define MIN_VERTICAL_BAR_HEIGHT    80
 #define MAX_TEXT_LENGTH            80
-#define TEXT_SPACING               2
 
 enum {
   PROP_0,
@@ -145,9 +144,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                    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,
@@ -155,9 +152,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *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,
@@ -165,9 +160,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *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,
@@ -175,9 +168,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *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,
@@ -185,9 +176,7 @@ gtk_progress_bar_class_init (GtkProgressBarClass *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,
@@ -216,11 +205,23 @@ gtk_progress_bar_class_init (GtkProgressBarClass *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
@@ -486,15 +487,21 @@ gtk_progress_bar_size_request (GtkWidget      *widget,
   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)
     {
@@ -766,7 +773,6 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
 {
   GtkProgress *progress = GTK_PROGRESS (pbar);
   GtkWidget *widget = GTK_WIDGET (pbar);
-  
   gint x;
   gint y;
   gchar *buf;
@@ -774,7 +780,12 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
   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);
@@ -784,15 +795,13 @@ gtk_progress_bar_paint_text (GtkProgressBar            *pbar,
 
   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;