]> Pileus Git - ~andy/gtk/blob - gtk/gtkalignment.c
docs: Add gtk-doc notation
[~andy/gtk] / gtk / gtkalignment.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
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 2 of the License, or (at your option) any later version.
8  *
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.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 /**
28  * SECTION:gtkalignment
29  * @Short_description: A widget which controls the alignment and size of its child
30  * @Title: GtkAlignment
31  *
32  * The #GtkAlignment widget controls the alignment and size of its child widget.
33  * It has four settings: xscale, yscale, xalign, and yalign.
34  *
35  * The scale settings are used to specify how much the child widget should
36  * expand to fill the space allocated to the #GtkAlignment.
37  * The values can range from 0 (meaning the child doesn't expand at all) to
38  * 1 (meaning the child expands to fill all of the available space).
39  *
40  * The align settings are used to place the child widget within the available
41  * area. The values range from 0 (top or left) to 1 (bottom or right).
42  * Of course, if the scale settings are both set to 1, the alignment settings
43  * have no effect.
44  *
45  * <note>
46  * <para>
47  * Note that the desired effect can in most cases be achieved by using the
48  * #GtkWidget:halign, #GtkWidget:valign and #GtkWidget:margin properties
49  * on the child widget, so #GtkAlignment should not be used in new code.
50  * </para>
51  * </note>
52  */
53
54 #include "config.h"
55 #include "gtkalignment.h"
56 #include "gtksizerequest.h"
57 #include "gtkprivate.h"
58 #include "gtkintl.h"
59
60
61 struct _GtkAlignmentPrivate
62 {
63   gfloat        xalign;
64   gfloat        yalign;
65   gfloat        xscale;
66   gfloat        yscale;
67
68   guint         padding_bottom;
69   guint         padding_top;
70   guint         padding_left;
71   guint         padding_right;
72 };
73
74 enum {
75   PROP_0,
76
77   PROP_XALIGN,
78   PROP_YALIGN,
79   PROP_XSCALE,
80   PROP_YSCALE,
81
82   PROP_TOP_PADDING,
83   PROP_BOTTOM_PADDING,
84   PROP_LEFT_PADDING,
85   PROP_RIGHT_PADDING
86 };
87
88 static void gtk_alignment_size_allocate (GtkWidget         *widget,
89                                          GtkAllocation     *allocation);
90 static void gtk_alignment_set_property (GObject         *object,
91                                         guint            prop_id,
92                                         const GValue    *value,
93                                         GParamSpec      *pspec);
94 static void gtk_alignment_get_property (GObject         *object,
95                                         guint            prop_id,
96                                         GValue          *value,
97                                         GParamSpec      *pspec);
98
99 static void gtk_alignment_get_preferred_width          (GtkWidget           *widget,
100                                                         gint                *minimum_size,
101                                                         gint                *natural_size);
102 static void gtk_alignment_get_preferred_height         (GtkWidget           *widget,
103                                                         gint                *minimum_size,
104                                                         gint                *natural_size);
105
106 G_DEFINE_TYPE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN)
107
108 static void
109 gtk_alignment_class_init (GtkAlignmentClass *class)
110 {
111   GObjectClass *gobject_class;
112   GtkWidgetClass *widget_class;
113
114   gobject_class = (GObjectClass*) class;
115   widget_class = (GtkWidgetClass*) class;
116   
117   gobject_class->set_property = gtk_alignment_set_property;
118   gobject_class->get_property = gtk_alignment_get_property;
119
120   widget_class->size_allocate        = gtk_alignment_size_allocate;
121   widget_class->get_preferred_width  = gtk_alignment_get_preferred_width;
122   widget_class->get_preferred_height = gtk_alignment_get_preferred_height;
123
124   g_object_class_install_property (gobject_class,
125                                    PROP_XALIGN,
126                                    g_param_spec_float("xalign",
127                                                       P_("Horizontal alignment"),
128                                                       P_("Horizontal position of child in available space. 0.0 is left aligned, 1.0 is right aligned"),
129                                                       0.0,
130                                                       1.0,
131                                                       0.5,
132                                                       GTK_PARAM_READWRITE));
133    
134   g_object_class_install_property (gobject_class,
135                                    PROP_YALIGN,
136                                    g_param_spec_float("yalign",
137                                                       P_("Vertical alignment"),
138                                                       P_("Vertical position of child in available space. 0.0 is top aligned, 1.0 is bottom aligned"),
139                                                       0.0,
140                                                       1.0,
141                                                       0.5,
142                                                       GTK_PARAM_READWRITE));
143   g_object_class_install_property (gobject_class,
144                                    PROP_XSCALE,
145                                    g_param_spec_float("xscale",
146                                                       P_("Horizontal scale"),
147                                                       P_("If available horizontal space is bigger than needed for the child, how much of it to use for the child. 0.0 means none, 1.0 means all"),
148                                                       0.0,
149                                                       1.0,
150                                                       1.0,
151                                                       GTK_PARAM_READWRITE));
152   g_object_class_install_property (gobject_class,
153                                    PROP_YSCALE,
154                                    g_param_spec_float("yscale",
155                                                       P_("Vertical scale"),
156                                                       P_("If available vertical space is bigger than needed for the child, how much of it to use for the child. 0.0 means none, 1.0 means all"),
157                                                       0.0,
158                                                       1.0,
159                                                       1.0,
160                                                       GTK_PARAM_READWRITE));
161
162
163 /**
164  * GtkAlignment:top-padding:
165  *
166  * The padding to insert at the top of the widget.
167  *
168  * Since: 2.4
169  */
170   g_object_class_install_property (gobject_class,
171                                    PROP_TOP_PADDING,
172                                    g_param_spec_uint("top-padding",
173                                                       P_("Top Padding"),
174                                                       P_("The padding to insert at the top of the widget."),
175                                                       0,
176                                                       G_MAXINT,
177                                                       0,
178                                                       GTK_PARAM_READWRITE));
179
180 /**
181  * GtkAlignment:bottom-padding:
182  *
183  * The padding to insert at the bottom of the widget.
184  *
185  * Since: 2.4
186  */
187   g_object_class_install_property (gobject_class,
188                                    PROP_BOTTOM_PADDING,
189                                    g_param_spec_uint("bottom-padding",
190                                                       P_("Bottom Padding"),
191                                                       P_("The padding to insert at the bottom of the widget."),
192                                                       0,
193                                                       G_MAXINT,
194                                                       0,
195                                                       GTK_PARAM_READWRITE));
196
197 /**
198  * GtkAlignment:left-padding:
199  *
200  * The padding to insert at the left of the widget.
201  *
202  * Since: 2.4
203  */
204   g_object_class_install_property (gobject_class,
205                                    PROP_LEFT_PADDING,
206                                    g_param_spec_uint("left-padding",
207                                                       P_("Left Padding"),
208                                                       P_("The padding to insert at the left of the widget."),
209                                                       0,
210                                                       G_MAXINT,
211                                                       0,
212                                                       GTK_PARAM_READWRITE));
213
214 /**
215  * GtkAlignment:right-padding:
216  *
217  * The padding to insert at the right of the widget.
218  *
219  * Since: 2.4
220  */
221   g_object_class_install_property (gobject_class,
222                                    PROP_RIGHT_PADDING,
223                                    g_param_spec_uint("right-padding",
224                                                       P_("Right Padding"),
225                                                       P_("The padding to insert at the right of the widget."),
226                                                       0,
227                                                       G_MAXINT,
228                                                       0,
229                                                       GTK_PARAM_READWRITE));
230
231   g_type_class_add_private (gobject_class, sizeof (GtkAlignmentPrivate));
232 }
233
234 static void
235 gtk_alignment_init (GtkAlignment *alignment)
236 {
237   GtkAlignmentPrivate *priv;
238
239   alignment->priv = G_TYPE_INSTANCE_GET_PRIVATE (alignment,
240                                                  GTK_TYPE_ALIGNMENT,
241                                                  GtkAlignmentPrivate);
242   priv = alignment->priv;
243
244   gtk_widget_set_has_window (GTK_WIDGET (alignment), FALSE);
245   gtk_widget_set_redraw_on_allocate (GTK_WIDGET (alignment), FALSE);
246
247   priv->xalign = 0.5;
248   priv->yalign = 0.5;
249   priv->xscale = 1.0;
250   priv->yscale = 1.0;
251
252   /* Initialize padding with default values: */
253   priv->padding_top = 0;
254   priv->padding_bottom = 0;
255   priv->padding_left = 0;
256   priv->padding_right = 0;
257 }
258
259 /**
260  * gtk_alignment_new:
261  * @xalign: the horizontal alignment of the child widget, from 0 (left) to 1
262  *  (right).
263  * @yalign: the vertical alignment of the child widget, from 0 (top) to 1
264  *  (bottom).
265  * @xscale: the amount that the child widget expands horizontally to fill up
266  *  unused space, from 0 to 1.
267  *  A value of 0 indicates that the child widget should never expand.
268  *  A value of 1 indicates that the child widget will expand to fill all of the
269  *  space allocated for the #GtkAlignment.
270  * @yscale: the amount that the child widget expands vertically to fill up
271  *  unused space, from 0 to 1. The values are similar to @xscale.
272  *
273  * Creates a new #GtkAlignment.
274  *
275  * Returns: the new #GtkAlignment.
276  */
277 GtkWidget*
278 gtk_alignment_new (gfloat xalign,
279                    gfloat yalign,
280                    gfloat xscale,
281                    gfloat yscale)
282 {
283   GtkAlignment *alignment;
284   GtkAlignmentPrivate *priv;
285
286   alignment = g_object_new (GTK_TYPE_ALIGNMENT, NULL);
287
288   priv = alignment->priv;
289
290   priv->xalign = CLAMP (xalign, 0.0, 1.0);
291   priv->yalign = CLAMP (yalign, 0.0, 1.0);
292   priv->xscale = CLAMP (xscale, 0.0, 1.0);
293   priv->yscale = CLAMP (yscale, 0.0, 1.0);
294
295   return GTK_WIDGET (alignment);
296 }
297
298 static void
299 gtk_alignment_set_property (GObject         *object,
300                             guint            prop_id,
301                             const GValue    *value,
302                             GParamSpec      *pspec)
303 {
304   GtkAlignment *alignment = GTK_ALIGNMENT (object);
305   GtkAlignmentPrivate *priv = alignment->priv;
306
307   switch (prop_id)
308     {
309     case PROP_XALIGN:
310       gtk_alignment_set (alignment,
311                          g_value_get_float (value),
312                          priv->yalign,
313                          priv->xscale,
314                          priv->yscale);
315       break;
316     case PROP_YALIGN:
317       gtk_alignment_set (alignment,
318                          priv->xalign,
319                          g_value_get_float (value),
320                          priv->xscale,
321                          priv->yscale);
322       break;
323     case PROP_XSCALE:
324       gtk_alignment_set (alignment,
325                          priv->xalign,
326                          priv->yalign,
327                          g_value_get_float (value),
328                          priv->yscale);
329       break;
330     case PROP_YSCALE:
331       gtk_alignment_set (alignment,
332                          priv->xalign,
333                          priv->yalign,
334                          priv->xscale,
335                          g_value_get_float (value));
336       break;
337       
338     /* Padding: */
339     case PROP_TOP_PADDING:
340       gtk_alignment_set_padding (alignment,
341                          g_value_get_uint (value),
342                          priv->padding_bottom,
343                          priv->padding_left,
344                          priv->padding_right);
345       break;
346     case PROP_BOTTOM_PADDING:
347       gtk_alignment_set_padding (alignment,
348                          priv->padding_top,
349                          g_value_get_uint (value),
350                          priv->padding_left,
351                          priv->padding_right);
352       break;
353     case PROP_LEFT_PADDING:
354       gtk_alignment_set_padding (alignment,
355                          priv->padding_top,
356                          priv->padding_bottom,
357                          g_value_get_uint (value),
358                          priv->padding_right);
359       break;
360     case PROP_RIGHT_PADDING:
361       gtk_alignment_set_padding (alignment,
362                          priv->padding_top,
363                          priv->padding_bottom,
364                          priv->padding_left,
365                          g_value_get_uint (value));
366       break;
367     
368     default:
369       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
370       break;
371     }
372 }
373
374 static void
375 gtk_alignment_get_property (GObject         *object,
376                             guint            prop_id,
377                             GValue          *value,
378                             GParamSpec      *pspec)
379 {
380   GtkAlignment *alignment = GTK_ALIGNMENT (object);
381   GtkAlignmentPrivate *priv = alignment->priv;
382
383   switch (prop_id)
384     {
385     case PROP_XALIGN:
386       g_value_set_float(value, priv->xalign);
387       break;
388     case PROP_YALIGN:
389       g_value_set_float(value, priv->yalign);
390       break;
391     case PROP_XSCALE:
392       g_value_set_float(value, priv->xscale);
393       break;
394     case PROP_YSCALE:
395       g_value_set_float(value, priv->yscale);
396       break;
397
398     /* Padding: */
399     case PROP_TOP_PADDING:
400       g_value_set_uint (value, priv->padding_top);
401       break;
402     case PROP_BOTTOM_PADDING:
403       g_value_set_uint (value, priv->padding_bottom);
404       break;
405     case PROP_LEFT_PADDING:
406       g_value_set_uint (value, priv->padding_left);
407       break;
408     case PROP_RIGHT_PADDING:
409       g_value_set_uint (value, priv->padding_right);
410       break;
411       
412     default:
413       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
414       break;
415     }
416 }
417
418 /**
419  * gtk_alignment_set:
420  * @alignment: a #GtkAlignment.
421  * @xalign: the horizontal alignment of the child widget, from 0 (left) to 1
422  *  (right).
423  * @yalign: the vertical alignment of the child widget, from 0 (top) to 1
424  *  (bottom).
425  * @xscale: the amount that the child widget expands horizontally to fill up
426  *  unused space, from 0 to 1.
427  *  A value of 0 indicates that the child widget should never expand.
428  *  A value of 1 indicates that the child widget will expand to fill all of the
429  *  space allocated for the #GtkAlignment.
430  * @yscale: the amount that the child widget expands vertically to fill up
431  *  unused space, from 0 to 1. The values are similar to @xscale.
432  *
433  * Sets the #GtkAlignment values.
434  */
435 void
436 gtk_alignment_set (GtkAlignment *alignment,
437                    gfloat        xalign,
438                    gfloat        yalign,
439                    gfloat        xscale,
440                    gfloat        yscale)
441 {
442   GtkAlignmentPrivate *priv;
443   GtkWidget *child;
444
445   g_return_if_fail (GTK_IS_ALIGNMENT (alignment));
446
447   priv = alignment->priv;
448
449   xalign = CLAMP (xalign, 0.0, 1.0);
450   yalign = CLAMP (yalign, 0.0, 1.0);
451   xscale = CLAMP (xscale, 0.0, 1.0);
452   yscale = CLAMP (yscale, 0.0, 1.0);
453
454   if (   (priv->xalign != xalign)
455       || (priv->yalign != yalign)
456       || (priv->xscale != xscale)
457       || (priv->yscale != yscale))
458     {
459       g_object_freeze_notify (G_OBJECT (alignment));
460       if (priv->xalign != xalign)
461         {
462            priv->xalign = xalign;
463            g_object_notify (G_OBJECT (alignment), "xalign");
464         }
465       if (priv->yalign != yalign)
466         {
467            priv->yalign = yalign;
468            g_object_notify (G_OBJECT (alignment), "yalign");
469         }
470       if (priv->xscale != xscale)
471         {
472            priv->xscale = xscale;
473            g_object_notify (G_OBJECT (alignment), "xscale");
474         }
475       if (priv->yscale != yscale)
476         {
477            priv->yscale = yscale;
478            g_object_notify (G_OBJECT (alignment), "yscale");
479         }
480       g_object_thaw_notify (G_OBJECT (alignment));
481
482       child = gtk_bin_get_child (GTK_BIN (alignment));
483       if (child)
484         gtk_widget_queue_resize (child);
485       gtk_widget_queue_draw (GTK_WIDGET (alignment));
486     }
487 }
488
489
490 static void
491 gtk_alignment_size_allocate (GtkWidget     *widget,
492                              GtkAllocation *allocation)
493 {
494   GtkAlignment *alignment = GTK_ALIGNMENT (widget);
495   GtkAlignmentPrivate *priv = alignment->priv;
496   GtkBin *bin;
497   GtkAllocation child_allocation;
498   GtkWidget *child;
499   gint width, height;
500   guint border_width;
501   gint padding_horizontal, padding_vertical;
502
503   padding_horizontal = 0;
504   padding_vertical = 0;
505
506   gtk_widget_set_allocation (widget, allocation);
507   bin = GTK_BIN (widget);
508
509   child = gtk_bin_get_child (bin);
510   if (child && gtk_widget_get_visible (child))
511     {
512       gint child_nat_width;
513       gint child_nat_height;
514       gint child_width, child_height;
515
516       border_width = gtk_container_get_border_width (GTK_CONTAINER (alignment));
517
518       padding_horizontal = priv->padding_left + priv->padding_right;
519       padding_vertical = priv->padding_top + priv->padding_bottom;
520
521       width  = MAX (1, allocation->width - padding_horizontal - 2 * border_width);
522       height = MAX (1, allocation->height - padding_vertical - 2 * border_width);
523
524       if (gtk_widget_get_request_mode (child) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
525         {
526           gtk_widget_get_preferred_width (child, NULL, &child_nat_width);
527
528           child_width = MIN (width, child_nat_width);
529
530           gtk_widget_get_preferred_height_for_width (child, child_width, NULL, &child_nat_height);
531
532           child_height = MIN (height, child_nat_height);
533         }
534       else
535         {
536           gtk_widget_get_preferred_height (child, NULL, &child_nat_height);
537
538           child_height = MIN (height, child_nat_height);
539
540           gtk_widget_get_preferred_width_for_height (child, child_height, NULL, &child_nat_width);
541
542           child_width = MIN (width, child_nat_width);
543         }
544
545       if (width > child_width)
546         child_allocation.width = (child_width *
547                                   (1.0 - priv->xscale) +
548                                   width * priv->xscale);
549       else
550         child_allocation.width = width;
551
552       if (height > child_height)
553         child_allocation.height = (child_height *
554                                    (1.0 - priv->yscale) +
555                                    height * priv->yscale);
556       else
557         child_allocation.height = height;
558
559       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
560         child_allocation.x = (1.0 - priv->xalign) * (width - child_allocation.width) + allocation->x + border_width + priv->padding_right;
561       else 
562         child_allocation.x = priv->xalign * (width - child_allocation.width) + allocation->x + border_width + priv->padding_left;
563
564       child_allocation.y = priv->yalign * (height - child_allocation.height) + allocation->y + border_width + priv->padding_top;
565
566       gtk_widget_size_allocate (child, &child_allocation);
567     }
568 }
569
570
571 static void
572 gtk_alignment_get_preferred_size (GtkWidget      *widget,
573                                   GtkOrientation  orientation,
574                                   gint           *minimum_size,
575                                   gint           *natural_size)
576 {
577   GtkAlignment *alignment = GTK_ALIGNMENT (widget);
578   GtkAlignmentPrivate *priv = alignment->priv;
579   GtkWidget *child;
580   guint minimum, natural;
581
582   natural = minimum = gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2;
583
584   if ((child = gtk_bin_get_child (GTK_BIN (widget))) && gtk_widget_get_visible (child))
585     {
586       gint child_min, child_nat;
587
588       /* Request extra space for the padding: */
589       if (orientation == GTK_ORIENTATION_HORIZONTAL)
590         {
591           minimum += (priv->padding_left + priv->padding_right);
592           gtk_widget_get_preferred_width (child, &child_min, &child_nat);
593         }
594       else
595         {
596           minimum += (priv->padding_top + priv->padding_bottom);
597           gtk_widget_get_preferred_height (child, &child_min, &child_nat);
598         }
599
600       natural = minimum;
601
602       minimum += child_min;
603       natural += child_nat;
604     }
605
606   if (minimum_size)
607     *minimum_size = minimum;
608
609   if (natural_size)
610     *natural_size = natural;
611 }
612
613 static void
614 gtk_alignment_get_preferred_width (GtkWidget      *widget,
615                                    gint           *minimum_size,
616                                    gint           *natural_size)
617 {
618   gtk_alignment_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
619 }
620
621 static void
622 gtk_alignment_get_preferred_height (GtkWidget      *widget,
623                                     gint           *minimum_size,
624                                     gint           *natural_size)
625 {
626   gtk_alignment_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
627 }
628
629 /**
630  * gtk_alignment_set_padding:
631  * @alignment: a #GtkAlignment
632  * @padding_top: the padding at the top of the widget
633  * @padding_bottom: the padding at the bottom of the widget
634  * @padding_left: the padding at the left of the widget
635  * @padding_right: the padding at the right of the widget.
636  *
637  * Sets the padding on the different sides of the widget.
638  * The padding adds blank space to the sides of the widget. For instance,
639  * this can be used to indent the child widget towards the right by adding
640  * padding on the left.
641  *
642  * Since: 2.4
643  */
644 void
645 gtk_alignment_set_padding (GtkAlignment    *alignment,
646                            guint            padding_top,
647                            guint            padding_bottom,
648                            guint            padding_left,
649                            guint            padding_right)
650 {
651   GtkAlignmentPrivate *priv;
652   GtkWidget *child;
653   
654   g_return_if_fail (GTK_IS_ALIGNMENT (alignment));
655
656   priv = alignment->priv;
657
658   g_object_freeze_notify (G_OBJECT (alignment));
659
660   if (priv->padding_top != padding_top)
661     {
662       priv->padding_top = padding_top;
663       g_object_notify (G_OBJECT (alignment), "top-padding");
664     }
665   if (priv->padding_bottom != padding_bottom)
666     {
667       priv->padding_bottom = padding_bottom;
668       g_object_notify (G_OBJECT (alignment), "bottom-padding");
669     }
670   if (priv->padding_left != padding_left)
671     {
672       priv->padding_left = padding_left;
673       g_object_notify (G_OBJECT (alignment), "left-padding");
674     }
675   if (priv->padding_right != padding_right)
676     {
677       priv->padding_right = padding_right;
678       g_object_notify (G_OBJECT (alignment), "right-padding");
679     }
680
681   g_object_thaw_notify (G_OBJECT (alignment));
682   
683   /* Make sure that the widget and children are redrawn with the new setting: */
684   child = gtk_bin_get_child (GTK_BIN (alignment));
685   if (child)
686     gtk_widget_queue_resize (child);
687
688   gtk_widget_queue_draw (GTK_WIDGET (alignment));
689 }
690
691 /**
692  * gtk_alignment_get_padding:
693  * @alignment: a #GtkAlignment
694  * @padding_top: (allow-none): location to store the padding for the top of the widget, or %NULL
695  * @padding_bottom: (allow-none): location to store the padding for the bottom of the widget, or %NULL
696  * @padding_left: (allow-none): location to store the padding for the left of the widget, or %NULL
697  * @padding_right: (allow-none): location to store the padding for the right of the widget, or %NULL
698  *
699  * Gets the padding on the different sides of the widget.
700  * See gtk_alignment_set_padding ().
701  *
702  * Since: 2.4
703  */
704 void
705 gtk_alignment_get_padding (GtkAlignment    *alignment,
706                            guint           *padding_top,
707                            guint           *padding_bottom,
708                            guint           *padding_left,
709                            guint           *padding_right)
710 {
711   GtkAlignmentPrivate *priv;
712
713   g_return_if_fail (GTK_IS_ALIGNMENT (alignment));
714
715   priv = alignment->priv;
716
717   if(padding_top)
718     *padding_top = priv->padding_top;
719   if(padding_bottom)
720     *padding_bottom = priv->padding_bottom;
721   if(padding_left)
722     *padding_left = priv->padding_left;
723   if(padding_right)
724     *padding_right = priv->padding_right;
725 }