[maemo-commits] [maemo-commits] r9275 - in projects/haf/branches/gtk+/maemo-gtk-2-10: . gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Jan 23 19:31:27 EET 2007
Author: mitch
Date: 2007-01-23 19:31:24 +0200 (Tue, 23 Jan 2007)
New Revision: 9275

Modified:
   projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog
   projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogress.c
   projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogressbar.c
Log:
2007-01-23  Michael Natterer  <mitch at imendio.com>

	Backport new GtkProgressBar style properties from upstream trunk:

    Fri Jul 14 16:13:37 2006  Tim Janik  <timj at 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.



Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog
===================================================================
--- projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog	2007-01-23 16:04:11 UTC (rev 9274)
+++ projects/haf/branches/gtk+/maemo-gtk-2-10/ChangeLog	2007-01-23 17:31:24 UTC (rev 9275)
@@ -1,5 +1,19 @@
 2007-01-23  Michael Natterer  <mitch at imendio.com>
 
+	Backport new GtkProgressBar style properties from upstream trunk:
+
+    Fri Jul 14 16:13:37 2006  Tim Janik  <timj at 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.
+
+2007-01-23  Michael Natterer  <mitch at imendio.com>
+
 	* gtk/gtktextview.c (gtk_text_view_size_allocate): keep cursor
 	visible when the size changes (like when IM opens).
 

Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogress.c
===================================================================
--- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogress.c	2007-01-23 16:04:11 UTC (rev 9274)
+++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogress.c	2007-01-23 17:31:24 UTC (rev 9275)
@@ -92,40 +92,36 @@
   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));
 }
 

Modified: projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogressbar.c
===================================================================
--- projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogressbar.c	2007-01-23 16:04:11 UTC (rev 9274)
+++ projects/haf/branches/gtk+/maemo-gtk-2-10/gtk/gtkprogressbar.c	2007-01-23 17:31:24 UTC (rev 9275)
@@ -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 @@
                                    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 @@
                                    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 @@
                                    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 @@
 				   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 @@
 				   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 @@
 				   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 @@
   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 @@
 {
   GtkProgress *progress = GTK_PROGRESS (pbar);
   GtkWidget *widget = GTK_WIDGET (pbar);
-  
   gint x;
   gint y;
   gchar *buf;
@@ -774,7 +780,12 @@
   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 @@
 
   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; 
+  x = widget->style->xthickness + 1 + text_xalign *
+      (widget->allocation.width - 2 * widget->style->xthickness -
+       2 - logical_rect.width);
 
-  y = widget->style->ythickness + 1 +
-    (widget->allocation.height - 2 * widget->style->ythickness -
-     2 - logical_rect.height)
-    * progress->y_align;
+  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;


More information about the maemo-commits mailing list