[gnome-shell/nbtk-introduction] Fix problems with 4-sided padding: specifiers



commit 8ffa161a7fd4289943f82688a3cf03a79f88f48d
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Sep 19 23:28:39 2009 -0400

    Fix problems with 4-sided padding: specifiers
    
    The test for identifying such a specifier was wrong, and the last
    value was assigned to the wrong sides.

 src/toolkit/shell-theme-node.c |   26 ++++++++++++++------------
 src/toolkit/test-theme.c       |   17 +++++++++++++++++
 src/toolkit/test-theme.css     |    1 +
 3 files changed, 32 insertions(+), 12 deletions(-)
---
diff --git a/src/toolkit/shell-theme-node.c b/src/toolkit/shell-theme-node.c
index fcf2dcc..abea899 100644
--- a/src/toolkit/shell-theme-node.c
+++ b/src/toolkit/shell-theme-node.c
@@ -863,26 +863,28 @@ do_padding_property (ShellThemeNode *node,
        */
       if (decl->value == NULL) /* 0 values */
         return;
-      else if (decl->value->next == NULL)
-        { /* 1 value */
+      else if (decl->value->next == NULL) /* 1 value */
+        {
           do_padding_property_term (node, decl->value, TRUE, TRUE, TRUE, TRUE); /* left/right/top/bottom */
           return;
-        }  else if (decl->value->next->next == NULL)
-        { /* 2 values */
+        }
+      else if (decl->value->next->next == NULL) /* 2 values */
+        {
           do_padding_property_term (node, decl->value,       FALSE, FALSE, TRUE,  TRUE);  /* top/bottom */
           do_padding_property_term (node, decl->value->next, TRUE, TRUE,   FALSE, FALSE); /* left/right */
-        }  else if (decl->value->next->next->next == NULL)
-        { /* 3 values */
+        }
+      else if (decl->value->next->next->next == NULL) /* 3 values */
+        {
           do_padding_property_term (node, decl->value,             FALSE, FALSE, TRUE,  FALSE); /* top */
           do_padding_property_term (node, decl->value->next,       TRUE,  TRUE,  FALSE, FALSE); /* left/right */
           do_padding_property_term (node, decl->value->next->next, FALSE, FALSE, FALSE, TRUE);  /* bottom */
         }
-      else  if (decl->value->next->next->next == NULL)
-        { /* 4 values */
-          do_padding_property_term (node, decl->value,                   FALSE, FALSE, TRUE,  FALSE);
-          do_padding_property_term (node, decl->value->next,             FALSE, TRUE, FALSE, FALSE); /* left */
-          do_padding_property_term (node, decl->value->next->next,       FALSE, FALSE, FALSE, TRUE);
-          do_padding_property_term (node, decl->value->next->next->next, TRUE,  FALSE, FALSE, TRUE); /* left */
+      else if (decl->value->next->next->next->next == NULL) /* 4 values */
+        {
+          do_padding_property_term (node, decl->value,                   FALSE, FALSE, TRUE,  FALSE); /* top */
+          do_padding_property_term (node, decl->value->next,             FALSE, TRUE,  FALSE, FALSE); /* right */
+          do_padding_property_term (node, decl->value->next->next,       FALSE, FALSE, FALSE, TRUE);  /* bottom */
+          do_padding_property_term (node, decl->value->next->next->next, TRUE,  FALSE, FALSE, FALSE); /* left */
         }
       else
         {
diff --git a/src/toolkit/test-theme.c b/src/toolkit/test-theme.c
index d163344..e4b1aeb 100644
--- a/src/toolkit/test-theme.c
+++ b/src/toolkit/test-theme.c
@@ -207,6 +207,22 @@ test_adjacent_selector (void)
 }
 
 static void
+test_padding (void)
+{
+  test = "padding";
+  /* Test that a 4-sided padding property assigns the right paddings to
+   * all sides */
+  assert_length ("group2", "padding-top", 1.,
+		 shell_theme_node_get_padding (group2, SHELL_SIDE_TOP));
+  assert_length ("group2", "padding-right", 2.,
+		 shell_theme_node_get_padding (group2, SHELL_SIDE_RIGHT));
+  assert_length ("group2", "padding-bottom", 3.,
+		 shell_theme_node_get_padding (group2, SHELL_SIDE_BOTTOM));
+  assert_length ("group2", "padding-left", 4.,
+		 shell_theme_node_get_padding (group2, SHELL_SIDE_LEFT));
+}
+
+static void
 test_background (void)
 {
   test = "background";
@@ -295,6 +311,7 @@ main (int argc, char **argv)
   test_classes ();
   test_type_inheritance ();
   test_adjacent_selector ();
+  test_padding ();
   test_background ();
   test_font ();
   test_pseudo_class ();
diff --git a/src/toolkit/test-theme.css b/src/toolkit/test-theme.css
index 5776e0f..be512d5 100644
--- a/src/toolkit/test-theme.css
+++ b/src/toolkit/test-theme.css
@@ -57,6 +57,7 @@ stage > #text2 {
 
 #group2 {
     background-image: url('other-background.png');
+    padding: 1px 2px 3px 4px;
 }
 
 ClutterText:hover {



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