[gtk+/wip/baseline2: 1/9] Add GTK_ALIGN_BASELINE to GtkAlign



commit df6dcfb511596d45ced2bbe2a038b76f963cfbe4
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Mar 5 15:06:12 2013 +0100

    Add GTK_ALIGN_BASELINE to GtkAlign
    
    Setting this means baseline aware containers should align the widget
    according to the baseline. For other containers this behaves like
    FILL.
    
    In order to not suprise old code with a new enum value we always
    return _FILL for _BASELINE unless you specifically request it via
    gtk_widget_get_valign_with_baseline().

 gtk/gtkenums.h  |    3 ++-
 gtk/gtkwidget.c |   16 ++++++++++++++--
 gtk/gtkwidget.h |    1 +
 3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index 1789d98..b4f0844 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -70,7 +70,8 @@ typedef enum
   GTK_ALIGN_FILL,
   GTK_ALIGN_START,
   GTK_ALIGN_END,
-  GTK_ALIGN_CENTER
+  GTK_ALIGN_CENTER,
+  GTK_ALIGN_BASELINE
 } GtkAlign;
 
 
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 44755b6..02fcc5a 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5604,6 +5604,7 @@ adjust_for_align (GtkAlign  align,
 {
   switch (align)
     {
+    case GTK_ALIGN_BASELINE:
     case GTK_ALIGN_FILL:
       /* change nothing */
       break;
@@ -13206,6 +13207,13 @@ gtk_widget_set_halign (GtkWidget *widget,
   g_object_notify (G_OBJECT (widget), "halign");
 }
 
+GtkAlign
+gtk_widget_get_valign_with_baseline (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
+  return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
+}
+
 /**
  * gtk_widget_get_valign:
  * @widget: a #GtkWidget
@@ -13217,8 +13225,12 @@ gtk_widget_set_halign (GtkWidget *widget,
 GtkAlign
 gtk_widget_get_valign (GtkWidget *widget)
 {
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
-  return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
+  GtkAlign align;
+
+  align = gtk_widget_get_valign_with_baseline (widget);
+  if (align == GTK_ALIGN_BASELINE)
+    return GTK_ALIGN_FILL;
+  return align;
 }
 
 /**
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index bdf8e5e..c0ff853 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -756,6 +756,7 @@ GtkAlign gtk_widget_get_halign        (GtkWidget *widget);
 void     gtk_widget_set_halign        (GtkWidget *widget,
                                        GtkAlign   align);
 GtkAlign gtk_widget_get_valign        (GtkWidget *widget);
+GtkAlign gtk_widget_get_valign_with_baseline (GtkWidget *widget);
 void     gtk_widget_set_valign        (GtkWidget *widget,
                                        GtkAlign   align);
 gint     gtk_widget_get_margin_left   (GtkWidget *widget);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]