[gtk+/gtk-style-context: 204/347] Add basic parser for GtkBorder properties.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 204/347] Add basic parser for GtkBorder properties.
- Date: Thu, 11 Nov 2010 01:21:40 +0000 (UTC)
commit 8dab2fcc1ebf493ee5b2fa48d06a38e5f8a9d24a
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Aug 30 22:34:31 2010 +0200
Add basic parser for GtkBorder properties.
Different units aren't supported, it takes 1 to 4 integers representing
pixel distances.
gtk/gtkcssprovider.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 058c1d3..9b257ca 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1403,6 +1403,43 @@ css_provider_parse_value (const gchar *value_str,
else
parsed = FALSE;
}
+ else if (type == GTK_TYPE_BORDER)
+ {
+ guint first, second, third, fourth;
+ GtkBorder border;
+
+ /* FIXME: no unit support */
+ if (sscanf (value_str, "%d %d %d %d",
+ &first, &second, &third, &fourth) == 4)
+ {
+ border.top = first;
+ border.right = second;
+ border.bottom = third;
+ border.left = fourth;
+ }
+ else if (sscanf (value_str, "%d %d %d",
+ &first, &second, &third) == 3)
+ {
+ border.top = first;
+ border.left = border.right = second;
+ border.bottom = third;
+ }
+ else if (sscanf (value_str, "%d %d", &first, &second) == 2)
+ {
+ border.top = border.bottom = first;
+ border.left = border.right = second;
+ }
+ else if (sscanf (value_str, "%d", &first) == 1)
+ {
+ border.top = border.bottom = first;
+ border.left = border.right = first;
+ }
+ else
+ parsed = FALSE;
+
+ if (parsed)
+ g_value_set_boxed (value, &border);
+ }
else
{
g_warning ("Cannot parse string '%s' for type %s", value_str, g_type_name (type));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]