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