r983 - trunk/src/target/OM-2007/openmoko-libs/libmokoui

thomas at sita.openmoko.org thomas at sita.openmoko.org
Tue Feb 13 17:32:35 CET 2007


Author: thomas
Date: 2007-02-13 17:32:34 +0100 (Tue, 13 Feb 2007)
New Revision: 983

Modified:
   trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-alignment.c
Log:
* Remove need for accessing GtkAlignmentPrivate
* Fix compiler warnings


Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-alignment.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-alignment.c	2007-02-13 15:44:58 UTC (rev 982)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-alignment.c	2007-02-13 16:32:34 UTC (rev 983)
@@ -33,16 +33,6 @@
 
 static GtkAlignmentClass* parent_class = NULL;
 
-//FIXME this is a bit hackish
-#define GTK_ALIGNMENT_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_ALIGNMENT, GtkAlignmentPrivate))
-typedef struct _GtkAlignmentPrivate
-{
-  guint padding_top;
-  guint padding_bottom;
-  guint padding_left;
-  guint padding_right;
-};
-
 typedef struct _MokoAlignmentPrivate
 {
 } MokoAlignmentPrivate;
@@ -57,7 +47,6 @@
 moko_alignment_class_init (MokoAlignmentClass *klass)
 {
     /* hook parent */
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
     parent_class = g_type_class_peek_parent(klass);
     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
@@ -100,13 +89,9 @@
                          "padding", &padding,
                          NULL);
 
-    GtkAlignmentPrivate *priv = GTK_ALIGNMENT_GET_PRIVATE(widget);
     if ( padding )
     {
-        priv->padding_top = padding->top;
-        priv->padding_bottom = padding->bottom;
-        priv->padding_left = padding->left;
-        priv->padding_right = padding->right;
+      gtk_alignment_set_padding (GTK_ALIGNMENT (widget), padding->top, padding->bottom, padding->left, padding->right);
     }
 
     GtkBin* bin = GTK_BIN(widget);
@@ -124,8 +109,10 @@
         requisition->height += child_requisition.height;
 
         /* Request extra space for the padding: */
-        requisition->width += (priv->padding_left + priv->padding_right);
-        requisition->height += (priv->padding_top + priv->padding_bottom);
+        guint p_top, p_bottom, p_left, p_right;
+        gtk_alignment_get_padding (GTK_ALIGNMENT (widget), &p_top, &p_bottom, &p_left, &p_right);
+        requisition->width += (p_left + p_right);
+        requisition->height += (p_top + p_bottom);
     }
 }
 
@@ -140,7 +127,6 @@
     gint width, height;
     gint border_width;
     gint padding_horizontal, padding_vertical;
-    GtkAlignmentPrivate *priv;
 
     padding_horizontal = 0;
     padding_vertical = 0;
@@ -165,10 +151,12 @@
 
         border_width = GTK_CONTAINER (alignment)->border_width;
 
-        priv = GTK_ALIGNMENT_GET_PRIVATE (widget);
-        padding_horizontal = priv->padding_left + priv->padding_right;
-        padding_vertical = priv->padding_top + priv->padding_bottom;
+        guint p_top, p_bottom, p_left, p_right;
+        gtk_alignment_get_padding (GTK_ALIGNMENT (widget), &p_top, &p_bottom, &p_left, &p_right);
 
+        padding_horizontal = p_left + p_right;
+        padding_vertical = p_top + p_bottom;
+
         width = allocation->width - padding_horizontal - 2 * border_width;
         height = allocation->height - padding_vertical - 2 * border_width;
 
@@ -189,20 +177,20 @@
         if (GTK_WIDGET_NO_WINDOW (widget))
         {
             if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-                child_allocation.x = (1.0 - alignment->xalign) * (width - child_allocation.width) + allocation->x + border_width + priv->padding_right;
+                child_allocation.x = (1.0 - alignment->xalign) * (width - child_allocation.width) + allocation->x + border_width + p_right;
             else
-                child_allocation.x = alignment->xalign * (width - child_allocation.width) + allocation->x + border_width + priv->padding_left;
+                child_allocation.x = alignment->xalign * (width - child_allocation.width) + allocation->x + border_width + p_left;
 
-            child_allocation.y = alignment->yalign * (height - child_allocation.height) + allocation->y + border_width + priv->padding_top;
+            child_allocation.y = alignment->yalign * (height - child_allocation.height) + allocation->y + border_width + p_top;
         }
         else
         {
             if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
-                child_allocation.x = (1.0 - alignment->xalign) * (width - child_allocation.width) + border_width + priv->padding_right;
+                child_allocation.x = (1.0 - alignment->xalign) * (width - child_allocation.width) + border_width + p_right;
             else
-                child_allocation.x = alignment->xalign * (width - child_allocation.width) + border_width + priv->padding_left;
+                child_allocation.x = alignment->xalign * (width - child_allocation.width) + border_width + p_left;
 
-            child_allocation.y = alignment->yalign * (height - child_allocation.height) + border_width + priv->padding_top;
+            child_allocation.y = alignment->yalign * (height - child_allocation.height) + border_width + p_top;
         }
         gtk_widget_size_allocate (bin->child, &child_allocation);
     }





More information about the commitlog mailing list