[gtk+/widget-padding: 70/71] Use gint16 for GtkBorder



commit 83008588e162b78f8f66ba371c3691a2ca759f3b
Author: Havoc Pennington <hp pobox com>
Date:   Sat Sep 11 19:25:57 2010 -0400

    Use gint16 for GtkBorder
    
    32K of border ought to be enough for any pixel dimensions. At least
    until screens are so huge we start using doubles.
    
    This saves a nice 64 bits of space when we have a GtkBorder
    stored somewhere.
    
    Signed integers are used to avoid surprising unsigned math
    issues. Just search GTK's whole git log from inception
    for "unsigned" if you want to find any number of commits
    fixing signed/unsigned bugs.

 gtk/gtksettings.c |   13 +++++++++----
 gtk/gtkstyle.h    |    8 ++++----
 2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 5818069..8690a9c 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -1941,6 +1941,7 @@ gtk_rc_property_parse_border (const GParamSpec *pspec,
   GtkBorder border;
   GScanner *scanner;
   gboolean success = FALSE;
+  int left, right, top, bottom;
 
   g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
   g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
@@ -1948,11 +1949,15 @@ gtk_rc_property_parse_border (const GParamSpec *pspec,
   scanner = gtk_rc_scanner_new ();
   g_scanner_input_text (scanner, gstring->str, gstring->len);
 
-  if (get_braced_int (scanner, TRUE, FALSE, &border.left) &&
-      get_braced_int (scanner, FALSE, FALSE, &border.right) &&
-      get_braced_int (scanner, FALSE, FALSE, &border.top) &&
-      get_braced_int (scanner, FALSE, TRUE, &border.bottom))
+  if (get_braced_int (scanner, TRUE, FALSE, &left) &&
+      get_braced_int (scanner, FALSE, FALSE, &right) &&
+      get_braced_int (scanner, FALSE, FALSE, &top) &&
+      get_braced_int (scanner, FALSE, TRUE, &bottom))
     {
+      border.left = left;
+      border.right = right;
+      border.top = top;
+      border.bottom = bottom;
       g_value_set_boxed (property_value, &border);
       success = TRUE;
     }
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index f3312ba..b425aa6 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -416,10 +416,10 @@ struct _GtkStyleClass
  */
 struct _GtkBorder
 {
-  gint left;
-  gint right;
-  gint top;
-  gint bottom;
+  gint16 left;
+  gint16 right;
+  gint16 top;
+  gint16 bottom;
 };
 
 GType     gtk_style_get_type                 (void) G_GNUC_CONST;



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