]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssshorthandpropertyimpl.c
Change FSF Address
[~andy/gtk] / gtk / gtkcssshorthandpropertyimpl.c
index 3f01074239f98cb3586b7e3ccce468d06e0902b7..74e75ffd2cd477f8d7a5bfc88a6bfc29b1bafaaf 100644 (file)
@@ -12,8 +12,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  * Authors: Benjamin Otte <otte@gnome.org>
  */
@@ -49,42 +48,10 @@ value_is_done_parsing (GtkCssParser *parser)
 }
 
 static gboolean
-parse_border_width (GtkCssShorthandProperty *shorthand,
+parse_four_numbers (GtkCssShorthandProperty *shorthand,
                     GValue                  *values,
                     GtkCssParser            *parser,
-                    GFile                   *base)
-{
-  GValue temp = G_VALUE_INIT;
-  GtkBorder *border;
-
-  g_value_init (&temp, GTK_TYPE_BORDER);
-  if (!_gtk_css_style_parse_value (&temp, parser, base))
-    {
-      g_value_unset (&temp);
-      return FALSE;
-    }
-
-  border = g_value_get_boxed (&temp);
-
-  g_value_init (&values[0], G_TYPE_INT);
-  g_value_init (&values[1], G_TYPE_INT);
-  g_value_init (&values[2], G_TYPE_INT);
-  g_value_init (&values[3], G_TYPE_INT);
-  g_value_set_int (&values[0], border->top);
-  g_value_set_int (&values[1], border->right);
-  g_value_set_int (&values[2], border->bottom);
-  g_value_set_int (&values[3], border->left);
-
-  g_value_unset (&temp);
-
-  return TRUE;
-}
-
-static gboolean
-parse_border_width_really (GtkCssShorthandProperty *shorthand,
-                           GValue                  *values,
-                           GtkCssParser            *parser,
-                           GFile                   *base)
+                    GtkCssNumberParseFlags   flags)
 {
   GtkCssNumber numbers[4];
   guint i;
@@ -96,9 +63,7 @@ parse_border_width_really (GtkCssShorthandProperty *shorthand,
 
       if (!_gtk_css_parser_read_number (parser,
                                         &numbers[i], 
-                                        GTK_CSS_POSITIVE_ONLY
-                                        | GTK_CSS_NUMBER_AS_PIXELS
-                                        | GTK_CSS_PARSE_LENGTH))
+                                        flags))
         return FALSE;
     }
 
@@ -122,6 +87,47 @@ parse_border_width_really (GtkCssShorthandProperty *shorthand,
   return TRUE;
 }
 
+static gboolean
+parse_margin (GtkCssShorthandProperty *shorthand,
+              GValue                  *values,
+              GtkCssParser            *parser,
+              GFile                   *base)
+{
+  return parse_four_numbers (shorthand,
+                             values,
+                             parser,
+                             GTK_CSS_NUMBER_AS_PIXELS
+                             | GTK_CSS_PARSE_LENGTH);
+}
+
+static gboolean
+parse_padding (GtkCssShorthandProperty *shorthand,
+               GValue                  *values,
+               GtkCssParser            *parser,
+               GFile                   *base)
+{
+  return parse_four_numbers (shorthand,
+                             values,
+                             parser,
+                             GTK_CSS_POSITIVE_ONLY
+                             | GTK_CSS_NUMBER_AS_PIXELS
+                             | GTK_CSS_PARSE_LENGTH);
+}
+
+static gboolean
+parse_border_width (GtkCssShorthandProperty *shorthand,
+                    GValue                  *values,
+                    GtkCssParser            *parser,
+                    GFile                   *base)
+{
+  return parse_four_numbers (shorthand,
+                             values,
+                             parser,
+                             GTK_CSS_POSITIVE_ONLY
+                             | GTK_CSS_NUMBER_AS_PIXELS
+                             | GTK_CSS_PARSE_LENGTH);
+}
+
 static gboolean 
 parse_border_radius (GtkCssShorthandProperty *shorthand,
                      GValue                  *values,
@@ -892,19 +898,19 @@ _gtk_css_shorthand_property_init_properties (void)
   _gtk_css_shorthand_property_register   ("margin",
                                           GTK_TYPE_BORDER,
                                           margin_subproperties,
-                                          parse_border_width,
+                                          parse_margin,
                                           unpack_border,
                                           pack_border);
   _gtk_css_shorthand_property_register   ("padding",
                                           GTK_TYPE_BORDER,
                                           padding_subproperties,
-                                          parse_border_width,
+                                          parse_padding,
                                           unpack_border,
                                           pack_border);
   _gtk_css_shorthand_property_register   ("border-width",
                                           GTK_TYPE_BORDER,
                                           border_width_subproperties,
-                                          parse_border_width_really,
+                                          parse_border_width,
                                           unpack_border,
                                           pack_border);
   _gtk_css_shorthand_property_register   ("border-radius",