1 /* LIBGTK - The GTK Library
2 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
4 * This library is free software: you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see
16 * <http://www.gnu.org/licenses/>.
20 #include "claws-features.h"
28 #include "gtkshruler.h"
31 #define ROUND(x) ((int) ((x) + 0.5))
36 * @short_description: Definitions of useful #GParamFlags.
38 * Definitions of useful #GParamFlags.
43 * GTK_PARAM_STATIC_STRINGS:
47 #define GTK_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | \
48 G_PARAM_STATIC_NICK | \
56 #define GTK_PARAM_READABLE (G_PARAM_READABLE | \
57 GTK_PARAM_STATIC_STRINGS)
64 #define GTK_PARAM_WRITABLE (G_PARAM_WRITABLE | \
65 GTK_PARAM_STATIC_STRINGS)
68 * GTK_PARAM_READWRITE:
72 #define GTK_PARAM_READWRITE (G_PARAM_READWRITE | \
73 GTK_PARAM_STATIC_STRINGS)
79 * @short_description: A ruler widget with configurable unit and orientation.
81 * A ruler widget with configurable unit and orientation.
85 #define DEFAULT_RULER_FONT_SCALE PANGO_SCALE_SMALL
86 #define MINIMUM_INCR 5
101 /* All distances below are in 1/72nd's of an inch. (According to
102 * Adobe that's a point, but points are really 1/72.27 in.)
106 GtkOrientation orientation;
113 GdkWindow *input_window;
114 cairo_surface_t *backing_store;
122 #define GTK_SHRULER_GET_PRIVATE(ruler) \
123 G_TYPE_INSTANCE_GET_PRIVATE (ruler, GTK_TYPE_SHRULER, GtkSHRulerPrivate)
128 const gdouble ruler_scale[16];
129 const gint subdivide[3];
132 { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000 },
137 static void gtk_shruler_dispose (GObject *object);
138 static void gtk_shruler_set_property (GObject *object,
142 static void gtk_shruler_get_property (GObject *object,
147 static void gtk_shruler_realize (GtkWidget *widget);
148 static void gtk_shruler_unrealize (GtkWidget *widget);
149 static void gtk_shruler_map (GtkWidget *widget);
150 static void gtk_shruler_unmap (GtkWidget *widget);
151 static void gtk_shruler_size_allocate (GtkWidget *widget,
152 GtkAllocation *allocation);
153 static void gtk_shruler_size_request (GtkWidget *widget,
154 GtkRequisition *requisition);
155 static void gtk_shruler_style_set (GtkWidget *widget,
156 GtkStyle *prev_style);
157 static gboolean gtk_shruler_motion_notify (GtkWidget *widget,
158 GdkEventMotion *event);
159 static gboolean gtk_shruler_expose (GtkWidget *widget,
160 GdkEventExpose *event);
162 static void gtk_shruler_draw_ticks (GtkSHRuler *ruler);
163 static void gtk_shruler_make_pixmap (GtkSHRuler *ruler);
165 static PangoLayout * gtk_shruler_get_layout (GtkWidget *widget,
169 G_DEFINE_TYPE (GtkSHRuler, gtk_shruler, GTK_TYPE_WIDGET)
171 #define parent_class gtk_shruler_parent_class
175 gtk_shruler_class_init (GtkSHRulerClass *klass)
177 GObjectClass *object_class = G_OBJECT_CLASS (klass);
178 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
180 object_class->dispose = gtk_shruler_dispose;
181 object_class->set_property = gtk_shruler_set_property;
182 object_class->get_property = gtk_shruler_get_property;
184 widget_class->realize = gtk_shruler_realize;
185 widget_class->unrealize = gtk_shruler_unrealize;
186 widget_class->map = gtk_shruler_map;
187 widget_class->unmap = gtk_shruler_unmap;
188 widget_class->size_allocate = gtk_shruler_size_allocate;
189 widget_class->size_request = gtk_shruler_size_request;
190 widget_class->style_set = gtk_shruler_style_set;
191 widget_class->motion_notify_event = gtk_shruler_motion_notify;
192 widget_class->expose_event = gtk_shruler_expose;
194 g_type_class_add_private (object_class, sizeof (GtkSHRulerPrivate));
196 g_object_class_install_property (object_class,
198 g_param_spec_enum ("orientation",
200 "The orientation of the ruler",
201 GTK_TYPE_ORIENTATION,
202 GTK_ORIENTATION_HORIZONTAL,
203 GTK_PARAM_READWRITE));
205 g_object_class_install_property (object_class,
207 gtk_param_spec_unit ("unit",
212 GTK_PARAM_READWRITE));
214 g_object_class_install_property (object_class,
216 g_param_spec_double ("lower",
218 "Lower limit of ruler",
222 GTK_PARAM_READWRITE));
224 g_object_class_install_property (object_class,
226 g_param_spec_double ("upper",
228 "Upper limit of ruler",
232 GTK_PARAM_READWRITE));
234 g_object_class_install_property (object_class,
236 g_param_spec_double ("position",
238 "Position of mark on the ruler",
242 GTK_PARAM_READWRITE));
244 g_object_class_install_property (object_class,
246 g_param_spec_double ("max-size",
248 "Maximum size of the ruler",
252 GTK_PARAM_READWRITE));
254 gtk_widget_class_install_style_property (widget_class,
255 g_param_spec_double ("font-scale",
259 DEFAULT_RULER_FONT_SCALE,
260 GTK_PARAM_READABLE));
264 gtk_shruler_init (GtkSHRuler *ruler)
266 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
268 gtkut_widget_set_has_window (GTK_WIDGET (ruler), FALSE);
270 priv->orientation = GTK_ORIENTATION_HORIZONTAL;
271 priv->unit = GTK_PIXELS;
276 priv->backing_store = NULL;
277 priv->font_scale = DEFAULT_RULER_FONT_SCALE;
281 gtk_shruler_dispose (GObject *object)
283 G_OBJECT_CLASS (parent_class)->dispose (object);
287 gtk_shruler_set_property (GObject *object,
292 GtkSHRuler *ruler = GTK_SHRULER (object);
293 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
297 case PROP_ORIENTATION:
298 priv->orientation = g_value_get_enum (value);
299 gtk_widget_queue_resize (GTK_WIDGET (ruler));
303 gtk_shruler_set_unit (ruler, g_value_get_int (value));
307 gtk_shruler_set_range (ruler,
308 g_value_get_double (value),
313 gtk_shruler_set_range (ruler,
315 g_value_get_double (value),
320 gtk_shruler_set_position (ruler, g_value_get_double (value));
324 gtk_shruler_set_range (ruler,
327 g_value_get_double (value));
331 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
337 gtk_shruler_get_property (GObject *object,
342 GtkSHRuler *ruler = GTK_SHRULER (object);
343 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
347 case PROP_ORIENTATION:
348 g_value_set_enum (value, priv->orientation);
352 g_value_set_int (value, priv->unit);
356 g_value_set_double (value, priv->lower);
360 g_value_set_double (value, priv->upper);
364 g_value_set_double (value, priv->position);
368 g_value_set_double (value, priv->max_size);
372 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
379 * @orientation: the ruler's orientation.
381 * Creates a new ruler.
383 * Return value: a new #GtkSHRuler widget.
388 gtk_shruler_new (GtkOrientation orientation)
390 return g_object_new (GTK_TYPE_SHRULER,
391 "orientation", orientation,
396 gtk_shruler_update_position (GtkSHRuler *ruler,
400 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
401 GtkAllocation allocation;
405 gtk_widget_get_allocation (GTK_WIDGET (ruler), &allocation);
406 gtk_shruler_get_range (ruler, &lower, &upper, NULL);
408 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
410 gtk_shruler_set_position (ruler,
412 (upper - lower) * x / allocation.width);
416 gtk_shruler_set_position (ruler,
418 (upper - lower) * y / allocation.height);
423 * gtk_shruler_set_unit:
424 * @ruler: a #GtkSHRuler
425 * @unit: the #GtkCMUnit to set the ruler to
427 * This sets the unit of the ruler.
432 gtk_shruler_set_unit (GtkSHRuler *ruler,
435 GtkSHRulerPrivate *priv;
437 g_return_if_fail (GTK_IS_SHRULER (ruler));
439 priv = GTK_SHRULER_GET_PRIVATE (ruler);
441 if (priv->unit != unit)
444 g_object_notify (G_OBJECT (ruler), "unit");
446 gtk_widget_queue_draw (GTK_WIDGET (ruler));
451 * gtk_shruler_get_unit:
452 * @ruler: a #GtkSHRuler
454 * Return value: the unit currently used in the @ruler widget.
459 gtk_shruler_get_unit (GtkSHRuler *ruler)
461 g_return_val_if_fail (GTK_IS_SHRULER (ruler), 0);
463 return GTK_SHRULER_GET_PRIVATE (ruler)->unit;
467 * gtk_shruler_set_position:
468 * @ruler: a #GtkSHRuler
469 * @position: the position to set the ruler to
471 * This sets the position of the ruler.
476 gtk_shruler_set_position (GtkSHRuler *ruler,
479 GtkSHRulerPrivate *priv;
481 g_return_if_fail (GTK_IS_SHRULER (ruler));
483 priv = GTK_SHRULER_GET_PRIVATE (ruler);
485 if (priv->position != position)
487 priv->position = position;
488 g_object_notify (G_OBJECT (ruler), "position");
493 * gtk_shruler_get_position:
494 * @ruler: a #GtkSHRuler
496 * Return value: the current position of the @ruler widget.
501 gtk_shruler_get_position (GtkSHRuler *ruler)
503 g_return_val_if_fail (GTK_IS_SHRULER (ruler), 0.0);
505 return GTK_SHRULER_GET_PRIVATE (ruler)->position;
509 * gtk_shruler_set_range:
510 * @ruler: a #GtkSHRuler
511 * @lower: the lower limit of the ruler
512 * @upper: the upper limit of the ruler
513 * @max_size: the maximum size of the ruler used when calculating the space to
516 * This sets the range of the ruler.
521 gtk_shruler_set_range (GtkSHRuler *ruler,
526 GtkSHRulerPrivate *priv;
528 g_return_if_fail (GTK_IS_SHRULER (ruler));
530 priv = GTK_SHRULER_GET_PRIVATE (ruler);
532 g_object_freeze_notify (G_OBJECT (ruler));
533 if (priv->lower != lower)
536 g_object_notify (G_OBJECT (ruler), "lower");
538 if (priv->upper != upper)
541 g_object_notify (G_OBJECT (ruler), "upper");
543 if (priv->max_size != max_size)
545 priv->max_size = max_size;
546 g_object_notify (G_OBJECT (ruler), "max-size");
548 g_object_thaw_notify (G_OBJECT (ruler));
550 gtk_widget_queue_draw (GTK_WIDGET (ruler));
554 * gtk_shruler_get_range:
555 * @ruler: a #GtkSHRuler
556 * @lower: location to store lower limit of the ruler, or %NULL
557 * @upper: location to store upper limit of the ruler, or %NULL
558 * @max_size: location to store the maximum size of the ruler used when
559 * calculating the space to leave for the text, or %NULL.
561 * Retrieves values indicating the range and current position of a #GtkSHRuler.
562 * See gtk_shruler_set_range().
567 gtk_shruler_get_range (GtkSHRuler *ruler,
572 GtkSHRulerPrivate *priv;
574 g_return_if_fail (GTK_IS_SHRULER (ruler));
576 priv = GTK_SHRULER_GET_PRIVATE (ruler);
579 *lower = priv->lower;
581 *upper = priv->upper;
583 *max_size = priv->max_size;
587 gtk_shruler_realize (GtkWidget *widget)
589 GtkSHRuler *ruler = GTK_SHRULER (widget);
590 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
591 GtkAllocation allocation;
592 GdkWindowAttr attributes;
593 gint attributes_mask;
595 GTK_WIDGET_CLASS (gtk_shruler_parent_class)->realize (widget);
597 gtk_widget_get_allocation (widget, &allocation);
599 attributes.window_type = GDK_WINDOW_CHILD;
600 attributes.x = allocation.x;
601 attributes.y = allocation.y;
602 attributes.width = allocation.width;
603 attributes.height = allocation.height;
604 attributes.wclass = GDK_INPUT_ONLY;
605 attributes.event_mask = (gtk_widget_get_events (widget) |
607 GDK_POINTER_MOTION_MASK |
608 GDK_POINTER_MOTION_HINT_MASK);
610 attributes_mask = GDK_WA_X | GDK_WA_Y;
612 priv->input_window = gdk_window_new (gtk_widget_get_window (widget),
613 &attributes, attributes_mask);
614 gdk_window_set_user_data (priv->input_window, ruler);
616 gtk_shruler_make_pixmap (ruler);
620 gtk_shruler_unrealize (GtkWidget *widget)
622 GtkSHRuler *ruler = GTK_SHRULER (widget);
623 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
625 if (priv->backing_store)
627 cairo_surface_destroy (priv->backing_store);
628 priv->backing_store = NULL;
633 g_object_unref (priv->layout);
637 if (priv->input_window)
639 gdk_window_destroy (priv->input_window);
640 priv->input_window = NULL;
643 GTK_WIDGET_CLASS (gtk_shruler_parent_class)->unrealize (widget);
647 gtk_shruler_map (GtkWidget *widget)
649 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (widget);
651 GTK_WIDGET_CLASS (parent_class)->map (widget);
653 if (priv->input_window)
654 gdk_window_show (priv->input_window);
658 gtk_shruler_unmap (GtkWidget *widget)
660 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (widget);
662 if (priv->input_window)
663 gdk_window_hide (priv->input_window);
665 GTK_WIDGET_CLASS (parent_class)->unmap (widget);
669 gtk_shruler_size_allocate (GtkWidget *widget,
670 GtkAllocation *allocation)
672 GtkSHRuler *ruler = GTK_SHRULER (widget);
673 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
675 gtk_widget_set_allocation (widget, allocation);
677 if (gtk_widget_get_realized (widget))
679 gdk_window_move_resize (priv->input_window,
680 allocation->x, allocation->y,
681 allocation->width, allocation->height);
683 gtk_shruler_make_pixmap (ruler);
688 gtk_shruler_size_request (GtkWidget *widget,
689 GtkRequisition *requisition)
691 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (widget);
692 GtkStyle *style = gtk_widget_get_style (widget);
694 PangoRectangle ink_rect;
697 layout = gtk_shruler_get_layout (widget, "0123456789");
698 pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
700 size = 2 + ink_rect.height * 1.7;
702 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
704 requisition->width = style->xthickness * 2 + 1;
705 requisition->height = style->ythickness * 2 + size;
709 requisition->width = style->xthickness * 2 + size;
710 requisition->height = style->ythickness * 2 + 1;
715 gtk_shruler_style_set (GtkWidget *widget,
716 GtkStyle *prev_style)
718 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (widget);
720 GTK_WIDGET_CLASS (gtk_shruler_parent_class)->style_set (widget, prev_style);
722 gtk_widget_style_get (widget,
723 "font-scale", &priv->font_scale,
728 g_object_unref (priv->layout);
734 gtk_shruler_motion_notify (GtkWidget *widget,
735 GdkEventMotion *event)
737 GtkSHRuler *ruler = GTK_SHRULER (widget);
739 gdk_event_request_motions (event);
741 gtk_shruler_update_position (ruler, event->x, event->y);
747 gtk_shruler_expose (GtkWidget *widget,
748 GdkEventExpose *event)
750 if (gtk_widget_is_drawable (widget))
752 GtkSHRuler *ruler = GTK_SHRULER (widget);
753 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
754 GtkAllocation allocation;
757 gtk_shruler_draw_ticks (ruler);
759 cr = gdk_cairo_create (gtk_widget_get_window (widget));
760 gdk_cairo_region (cr, event->region);
763 gtk_widget_get_allocation (widget, &allocation);
764 cairo_translate (cr, allocation.x, allocation.y);
766 cairo_set_source_surface (cr, priv->backing_store, 0, 0);
776 gtk_shruler_draw_ticks (GtkSHRuler *ruler)
778 GtkWidget *widget = GTK_WIDGET (ruler);
779 GtkStyle *style = gtk_widget_get_style (widget);
780 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
781 GtkStateType state = gtk_widget_get_state (widget);
782 GtkAllocation allocation;
789 gdouble lower, upper; /* Upper and lower limits, in ruler units */
790 gdouble increment; /* Number of pixels per unit */
791 gint scale; /* Number of units per major unit */
792 gdouble start, end, cur;
801 PangoRectangle logical_rect, ink_rect;
803 if (! gtk_widget_is_drawable (widget))
806 gtk_widget_get_allocation (widget, &allocation);
808 xthickness = style->xthickness;
809 ythickness = style->ythickness;
811 layout = gtk_shruler_get_layout (widget, "0123456789");
812 pango_layout_get_extents (layout, &ink_rect, &logical_rect);
814 digit_height = PANGO_PIXELS (ink_rect.height) + 2;
815 digit_offset = ink_rect.y;
817 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
819 width = allocation.width;
820 height = allocation.height - ythickness * 2;
824 width = allocation.height;
825 height = allocation.width - ythickness * 2;
828 cr = cairo_create (priv->backing_store);
829 gdk_cairo_set_source_color (cr, &style->bg[state]);
833 gdk_cairo_set_source_color (cr, &style->fg[state]);
835 gtk_shruler_get_range (ruler, &lower, &upper, &max_size);
837 if ((upper - lower) == 0)
840 increment = (gdouble) width / (upper - lower);
842 /* determine the scale
843 * use the maximum extents of the ruler to determine the largest
844 * possible number to be displayed. Calculate the height in pixels
845 * of this displayed text. Use this height to find a scale which
846 * leaves sufficient room for drawing the ruler.
848 * We calculate the text size as for the vruler instead of
849 * actually measuring the text width, so that the result for the
850 * scale looks consistent with an accompanying vruler.
852 scale = ceil (max_size);
853 g_snprintf (unit_str, sizeof (unit_str), "%d", scale);
854 text_size = strlen (unit_str) * digit_height + 1;
856 for (scale = 0; scale < G_N_ELEMENTS (ruler_metric.ruler_scale); scale++)
857 if (ruler_metric.ruler_scale[scale] * fabs (increment) > 2 * text_size)
860 if (scale == G_N_ELEMENTS (ruler_metric.ruler_scale))
861 scale = G_N_ELEMENTS (ruler_metric.ruler_scale) - 1;
863 unit = gtk_shruler_get_unit (ruler);
865 /* drawing starts here */
867 for (i = G_N_ELEMENTS (ruler_metric.subdivide) - 1; i >= 0; i--)
871 /* hack to get proper subdivisions at full pixels */
872 if (unit == CM_UNIT_PIXEL && scale == 1 && i == 1)
875 subd_incr = ((gdouble) ruler_metric.ruler_scale[scale] /
876 (gdouble) ruler_metric.subdivide[i]);
878 if (subd_incr * fabs (increment) <= MINIMUM_INCR)
881 /* don't subdivide pixels */
882 if (unit == CM_UNIT_PIXEL && subd_incr < 1.0)
887 start = floor (lower / subd_incr) * subd_incr;
888 end = ceil (upper / subd_incr) * subd_incr;
892 start = floor (upper / subd_incr) * subd_incr;
893 end = ceil (lower / subd_incr) * subd_incr;
896 for (cur = start; cur <= end; cur += subd_incr)
898 if (((int)cur) % 10 == 0)
899 length = height * 2 / 3;
900 else if (((int)cur) % 5 == 0)
905 pos = ROUND ((cur - lower) * increment);
907 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
910 pos, height + ythickness - length,
916 height + xthickness - length, pos,
921 if (i == 0 && ((int)cur) % 10 == 0)
923 g_snprintf (unit_str, sizeof (unit_str), "%d", (int) cur);
925 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
927 pango_layout_set_text (layout, unit_str, -1);
928 pango_layout_get_extents (layout, &logical_rect, NULL);
932 ythickness + PANGO_PIXELS (logical_rect.y - digit_offset));
933 pango_cairo_show_layout (cr, layout);
939 for (j = 0; j < (int) strlen (unit_str); j++)
941 pango_layout_set_text (layout, unit_str + j, 1);
942 pango_layout_get_extents (layout, NULL, &logical_rect);
946 pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset));
947 pango_cairo_show_layout (cr, layout);
959 static cairo_surface_t *
960 cm_gdk_window_create_similar_surface (GdkWindow * window,
961 cairo_content_t content,
965 #if !GTK_CHECK_VERSION(2, 22, 0)
966 cairo_surface_t *window_surface, *surface;
968 g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
970 window_surface = GDK_DRAWABLE_GET_CLASS(window)->ref_cairo_surface(window);
972 surface = cairo_surface_create_similar (window_surface,
976 cairo_surface_destroy (window_surface);
980 return gdk_window_create_similar_surface(window, content, width, height);
985 gtk_shruler_make_pixmap (GtkSHRuler *ruler)
987 GtkWidget *widget = GTK_WIDGET (ruler);
988 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (ruler);
989 GtkAllocation allocation;
991 gtk_widget_get_allocation (widget, &allocation);
993 if (priv->backing_store)
994 cairo_surface_destroy (priv->backing_store);
996 priv->backing_store =
997 cm_gdk_window_create_similar_surface (gtk_widget_get_window (widget),
1004 static PangoLayout *
1005 gtk_shruler_create_layout (GtkWidget *widget,
1008 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (widget);
1009 PangoLayout *layout;
1010 PangoAttrList *attrs;
1011 PangoAttribute *attr;
1013 layout = gtk_widget_create_pango_layout (widget, text);
1015 attrs = pango_attr_list_new ();
1017 attr = pango_attr_scale_new (priv->font_scale);
1018 attr->start_index = 0;
1019 attr->end_index = -1;
1020 pango_attr_list_insert (attrs, attr);
1022 pango_layout_set_attributes (layout, attrs);
1023 pango_attr_list_unref (attrs);
1028 static PangoLayout *
1029 gtk_shruler_get_layout (GtkWidget *widget,
1032 GtkSHRulerPrivate *priv = GTK_SHRULER_GET_PRIVATE (widget);
1036 pango_layout_set_text (priv->layout, text, -1);
1037 return priv->layout;
1040 priv->layout = gtk_shruler_create_layout (widget, text);
1042 return priv->layout;