Also remove the now unused border parsing function for shorthands.
GtkCalendar.view {
border-width: 1px;
border-style: inset;
- padding: 1;
+ padding: 1px;
}
GtkCalendar.view:inconsistent {
.menu * {
border-width: 0;
- padding: 2;
+ padding: 2px;
}
.notebook tab:active {
background-image: -gtk-win32-theme-part(tab, 1 3, margins(0 0 -1 0));
- padding: 4;
+ padding: 4px;
}
.notebook tab:last-child {
_gtk_css_parser_begins_with (parser, '}');
}
-static gboolean
-parse_border_width (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_four_numbers (GtkCssShorthandProperty *shorthand,
GValue *values,
}
static gboolean
-parse_border_width_really (GtkCssShorthandProperty *shorthand,
- GValue *values,
- GtkCssParser *parser,
- GFile *base)
+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,
_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",
#include "gtkprivatetypebuiltins.h"
#include "gtkstylepropertiesprivate.h"
+#include <math.h>
#include <cairo-gobject.h>
#include "gtkcssimagegradientprivate.h"
#include "gtkcssimageprivate.h"
+/* this is in case round() is not provided by the compiler,
+ * such as in the case of C89 compilers, like MSVC
+ */
+#include "fallback-c89.c"
+
enum {
PROP_0,
PROP_ID,
g_value_take_boxed (value, pattern);
}
}
+ else if (G_VALUE_TYPE (val) == GTK_TYPE_CSS_NUMBER)
+ {
+ g_value_set_int (value, round (_gtk_css_number_get (g_value_get_boxed (val), 100)));
+ }
else
g_value_copy (val, value);
}
g_value_set_boxed (computed, &number);
}
+static gboolean
+parse_padding (GtkCssStyleProperty *property,
+ GValue *value,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ GtkCssNumber number;
+
+ if (!_gtk_css_parser_read_number (parser,
+ &number,
+ GTK_CSS_POSITIVE_ONLY
+ | GTK_CSS_NUMBER_AS_PIXELS
+ | GTK_CSS_PARSE_LENGTH))
+ return FALSE;
+
+ g_value_set_boxed (value, &number);
+ return TRUE;
+}
+
+static void
+compute_padding (GtkCssStyleProperty *property,
+ GValue *computed,
+ GtkStyleContext *context,
+ const GValue *specified)
+{
+ GtkCssNumber number;
+
+ _gtk_css_number_compute (&number,
+ g_value_get_boxed (specified),
+ context);
+ g_value_set_boxed (computed, &number);
+}
+
static gboolean
parse_border_width (GtkCssStyleProperty *property,
GValue *value,
compute_margin,
&number);
gtk_css_style_property_register ("padding-top",
- G_TYPE_INT,
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
0,
+ parse_padding,
NULL,
- NULL,
- NULL,
- 0);
+ compute_padding,
+ &number);
gtk_css_style_property_register ("padding-left",
- G_TYPE_INT,
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
0,
+ parse_padding,
NULL,
- NULL,
- NULL,
- 0);
+ compute_padding,
+ &number);
gtk_css_style_property_register ("padding-bottom",
- G_TYPE_INT,
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
0,
+ parse_padding,
NULL,
- NULL,
- NULL,
- 0);
+ compute_padding,
+ &number);
gtk_css_style_property_register ("padding-right",
- G_TYPE_INT,
- G_TYPE_INT,
+ GTK_TYPE_CSS_NUMBER,
+ GTK_TYPE_CSS_NUMBER,
G_TYPE_INT,
0,
+ parse_padding,
NULL,
- NULL,
- NULL,
- 0);
+ compute_padding,
+ &number);
/* IMPORTANT: compute_border_width() requires that the border-width
* properties be immeditaly followed by the border-style properties
*/
border-width: 5px;
border-style: solid;
border-color: rgba(255,0,0,0.6);
- padding: 10;
+ padding: 10px;
background-color: rgb(0,0,255);
/* Make sure children of button are only offset by padding */
border-width: 5px;
border-style: solid;
border-color: rgba(255,0,0,0.5);
- padding: 10;
+ padding: 10px;
background-color: rgb(0,0,255);
background-image: url("green-20x20.png");
}
#reference {
- padding: 20
+ padding: 20px
}
GtkEntry #padded {
-GtkWidget-interior-focus: true;
- padding: 10;
+ padding: 10px;
}
.progressbar {