gtkcssstylepropertyimpl.c 81.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* GTK - The GIMP Toolkit
 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardon's avatar
Javier Jardon committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21
 */

#include "config.h"

#include "gtkstylepropertyprivate.h"

22
#include <gobject/gvaluecollector.h>
23 24
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo-gobject.h>
25
#include <math.h>
26 27 28 29 30 31 32 33

#include "gtkcssparserprivate.h"
#include "gtkcssstylefuncsprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkintl.h"
#include "gtkprivatetypebuiltins.h"

34 35 36 37 38
/* 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"

39 40
/* the actual parsers we have */
#include "gtkbindings.h"
41
#include "gtkcssarrayvalueprivate.h"
42
#include "gtkcssbgsizevalueprivate.h"
43
#include "gtkcssbordervalueprivate.h"
44
#include "gtkcsscolorvalueprivate.h"
45
#include "gtkcsscornervalueprivate.h"
46
#include "gtkcsseasevalueprivate.h"
47
#include "gtkcssenginevalueprivate.h"
48
#include "gtkcssiconthemevalueprivate.h"
49
#include "gtkcssimageprivate.h"
50
#include "gtkcssimagebuiltinprivate.h"
51
#include "gtkcssimagegradientprivate.h"
52
#include "gtkcssimagevalueprivate.h"
53
#include "gtkcssinitialvalueprivate.h"
54
#include "gtkcssenumvalueprivate.h"
55
#include "gtkcssnumbervalueprivate.h"
56
#include "gtkcsspalettevalueprivate.h"
57
#include "gtkcsspositionvalueprivate.h"
58
#include "gtkcssrepeatvalueprivate.h"
59
#include "gtkcssrgbavalueprivate.h"
60
#include "gtkcssshadowsvalueprivate.h"
61
#include "gtkcssstringvalueprivate.h"
62
#include "gtkcsstransformvalueprivate.h"
63 64
#include "gtktypebuiltins.h"

65 66
#include "deprecated/gtkthemingengine.h"

67 68
/*** REGISTRATION ***/

69
typedef enum {
70
  GTK_STYLE_PROPERTY_INHERIT = (1 << 0),
71
  GTK_STYLE_PROPERTY_ANIMATED = (1 << 1),
72 73
} GtkStylePropertyFlags;

74
static void
75
gtk_css_style_property_register (const char *                   name,
76
                                 guint                          expected_id,
77 78
                                 GType                          value_type,
                                 GtkStylePropertyFlags          flags,
79
                                 GtkCssAffects                  affects,
80
                                 GtkCssStylePropertyParseFunc   parse_value,
81
                                 GtkCssStylePropertyQueryFunc   query_value,
82
                                 GtkCssStylePropertyAssignFunc  assign_value,
83
                                 GtkCssValue *                  initial_value)
84
{
85
  GtkCssStyleProperty *node;
86

87
  g_assert (initial_value != NULL);
88
  g_assert (parse_value != NULL);
89
  g_assert (value_type == G_TYPE_NONE || query_value != NULL);
90
  g_assert (assign_value == NULL || query_value != NULL);
91

92 93
  node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
                       "value-type", value_type,
94
                       "affects", affects,
95
                       "animated", (flags & GTK_STYLE_PROPERTY_ANIMATED) ? TRUE : FALSE,
96
                       "inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
97
                       "initial-value", initial_value,
98 99
                       "name", name,
                       NULL);
100

101
  node->parse_value = parse_value;
102
  node->query_value = query_value;
103
  node->assign_value = assign_value;
104

105
  _gtk_css_value_unref (initial_value);
106 107

  g_assert (_gtk_css_style_property_get_id (node) == expected_id);
108 109
}

110 111
/*** IMPLEMENTATIONS ***/

112 113 114 115 116 117
static void
query_length_as_int (GtkCssStyleProperty *property,
                     const GtkCssValue   *css_value,
                     GValue              *value)
{
  g_value_init (value, G_TYPE_INT);
118
  g_value_set_int (value, round (_gtk_css_number_value_get (css_value, 100)));
119 120
}

121 122 123 124 125 126 127
static GtkCssValue *
assign_length_from_int (GtkCssStyleProperty *property,
                        const GValue        *value)
{
  return _gtk_css_number_value_new (g_value_get_int (value), GTK_CSS_PX);
}

128
static void
Benjamin Otte's avatar
Benjamin Otte committed
129 130 131
query_font_size (GtkCssStyleProperty *property,
                 const GtkCssValue   *css_value,
                 GValue              *value)
132 133 134 135 136 137
{
  g_value_init (value, G_TYPE_DOUBLE);
  g_value_set_double (value, _gtk_css_number_value_get (css_value, 100));
}

static GtkCssValue *
Benjamin Otte's avatar
Benjamin Otte committed
138 139
assign_font_size (GtkCssStyleProperty *property,
                  const GValue        *value)
140 141 142 143
{
  return _gtk_css_number_value_new (g_value_get_double (value), GTK_CSS_PX);
}

144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
static void
query_border (GtkCssStyleProperty *property,
              const GtkCssValue   *css_value,
              GValue              *value)
{
  GtkBorder border;

  g_value_init (value, GTK_TYPE_BORDER);
  
  border.top = round (_gtk_css_number_value_get (_gtk_css_border_value_get_top (css_value), 100));
  border.right = round (_gtk_css_number_value_get (_gtk_css_border_value_get_right (css_value), 100));
  border.bottom = round (_gtk_css_number_value_get (_gtk_css_border_value_get_bottom (css_value), 100));
  border.left = round (_gtk_css_number_value_get (_gtk_css_border_value_get_left (css_value), 100));

  g_value_set_boxed (value, &border);
}

static GtkCssValue *
assign_border (GtkCssStyleProperty *property,
               const GValue        *value)
{
  const GtkBorder *border = g_value_get_boxed (value);

  if (border == NULL)
168
    return _gtk_css_initial_value_new ();
169 170 171 172 173 174 175
  else
    return _gtk_css_border_value_new (_gtk_css_number_value_new (border->top, GTK_CSS_PX),
                                      _gtk_css_number_value_new (border->right, GTK_CSS_PX),
                                      _gtk_css_number_value_new (border->bottom, GTK_CSS_PX),
                                      _gtk_css_number_value_new (border->left, GTK_CSS_PX));
}

176 177
static GtkCssValue *
color_parse (GtkCssStyleProperty *property,
178
             GtkCssParser        *parser)
179
{
180
  return _gtk_css_color_value_parse (parser);
181 182
}

183 184 185 186 187 188 189 190 191 192 193 194 195 196
static void
color_query (GtkCssStyleProperty *property,
             const GtkCssValue   *css_value,
             GValue              *value)
{
  g_value_init (value, GDK_TYPE_RGBA);
  g_value_set_boxed (value, _gtk_css_rgba_value_get_rgba (css_value));
}

static GtkCssValue *
color_assign (GtkCssStyleProperty *property,
              const GValue        *value)
{
  return _gtk_css_rgba_value_new_from_rgba (g_value_get_boxed (value));
197 198
}

199
static GtkCssValue *
200
font_family_parse_one (GtkCssParser *parser)
201 202 203
{
  char *name;

204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
  name = _gtk_css_parser_try_ident (parser, TRUE);
  if (name)
    {
      GString *string = g_string_new (name);
      g_free (name);
      while ((name = _gtk_css_parser_try_ident (parser, TRUE)))
        {
          g_string_append_c (string, ' ');
          g_string_append (string, name);
          g_free (name);
        }
      name = g_string_free (string, FALSE);
    }
  else 
    {
      name = _gtk_css_parser_read_string (parser);
      if (name == NULL)
        return NULL;
    }
223

224 225
  return _gtk_css_string_value_new_take (name);
}
226

227 228 229 230 231 232
GtkCssValue *
gtk_css_font_family_value_parse (GtkCssParser *parser)
{
  return _gtk_css_array_value_parse (parser, font_family_parse_one);
}

233 234
static GtkCssValue *
font_family_parse (GtkCssStyleProperty *property,
235
                   GtkCssParser        *parser)
236
{
237
  return gtk_css_font_family_value_parse (parser);
238 239 240
}

static void
241 242 243
font_family_query (GtkCssStyleProperty *property,
                   const GtkCssValue   *css_value,
                   GValue              *value)
244
{
245 246 247 248
  GPtrArray *array;
  guint i;

  array = g_ptr_array_new ();
249

250
  for (i = 0; i < _gtk_css_array_value_get_n_values (css_value); i++)
251
    {
252
      g_ptr_array_add (array, g_strdup (_gtk_css_string_value_get (_gtk_css_array_value_get_nth (css_value, i))));
253 254
    }

255 256 257 258 259 260 261 262 263 264 265
  /* NULL-terminate */
  g_ptr_array_add (array, NULL);

  g_value_init (value, G_TYPE_STRV);
  g_value_set_boxed (value, g_ptr_array_free (array, FALSE));
}

static GtkCssValue *
font_family_assign (GtkCssStyleProperty *property,
                    const GValue        *value)
{
266
  const char **names;
267 268 269 270 271 272
  GtkCssValue *result;
  GPtrArray *array;

  array = g_ptr_array_new ();

  for (names = g_value_get_boxed (value); *names; names++)
273
    {
274
      g_ptr_array_add (array, _gtk_css_string_value_new (*names));
275
    }
276

277
  result = _gtk_css_array_value_new_from_array ((GtkCssValue **) array->pdata, array->len);
278 279
  g_ptr_array_free (array, TRUE);
  return result;
280 281
}

282
static GtkCssValue *
283 284
font_style_parse (GtkCssStyleProperty *property,
                  GtkCssParser        *parser)
285
{
286 287 288 289
  GtkCssValue *value = _gtk_css_font_style_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");
290

291 292
  return value;
}
293

294
static void
295 296 297
font_style_query (GtkCssStyleProperty *property,
                  const GtkCssValue   *css_value,
                  GValue              *value)
298 299 300 301 302 303
{
  g_value_init (value, PANGO_TYPE_STYLE);
  g_value_set_enum (value, _gtk_css_font_style_value_get (css_value));
}

static GtkCssValue *
304 305
font_style_assign (GtkCssStyleProperty *property,
                   const GValue        *value)
306 307
{
  return _gtk_css_font_style_value_new (g_value_get_enum (value));
308 309 310
}

static GtkCssValue *
311 312
font_weight_parse (GtkCssStyleProperty *property,
                   GtkCssParser        *parser)
313
{
314 315 316 317
  GtkCssValue *value = _gtk_css_font_weight_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");
318

319 320
  return value;
}
321

322
static void
323 324 325
font_weight_query (GtkCssStyleProperty *property,
                   const GtkCssValue   *css_value,
                   GValue              *value)
326 327 328 329 330 331
{
  g_value_init (value, PANGO_TYPE_WEIGHT);
  g_value_set_enum (value, _gtk_css_font_weight_value_get (css_value));
}

static GtkCssValue *
332 333
font_weight_assign (GtkCssStyleProperty *property,
                    const GValue        *value)
334 335
{
  return _gtk_css_font_weight_value_new (g_value_get_enum (value));
336 337 338
}

static GtkCssValue *
339 340
font_variant_parse (GtkCssStyleProperty *property,
                    GtkCssParser        *parser)
341
{
342 343 344 345
  GtkCssValue *value = _gtk_css_font_variant_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");
346

347 348
  return value;
}
349

350
static void
351 352
font_variant_query (GtkCssStyleProperty *property,
                    const GtkCssValue   *css_value,
353 354 355 356 357 358 359
                     GValue              *value)
{
  g_value_init (value, PANGO_TYPE_VARIANT);
  g_value_set_enum (value, _gtk_css_font_variant_value_get (css_value));
}

static GtkCssValue *
360 361
font_variant_assign (GtkCssStyleProperty *property,
                     const GValue        *value)
362 363
{
  return _gtk_css_font_variant_value_new (g_value_get_enum (value));
364 365
}

366
static GtkCssValue *
367 368
font_stretch_parse (GtkCssStyleProperty *property,
                    GtkCssParser        *parser)
369 370 371 372 373 374 375 376 377 378
{
  GtkCssValue *value = _gtk_css_font_stretch_value_try_parse (parser);

  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

static void
379 380 381
font_stretch_query (GtkCssStyleProperty *property,
                    const GtkCssValue   *css_value,
                    GValue              *value)
382 383 384 385 386 387
{
  g_value_init (value, PANGO_TYPE_STRETCH);
  g_value_set_enum (value, _gtk_css_font_stretch_value_get (css_value));
}

static GtkCssValue *
388 389
font_stretch_assign (GtkCssStyleProperty *property,
                     const GValue        *value)
390 391 392 393
{
  return _gtk_css_font_stretch_value_new (g_value_get_enum (value));
}

394 395
static GtkCssValue *
parse_border_style (GtkCssStyleProperty *property,
396
                    GtkCssParser        *parser)
397
{
398 399 400 401
  GtkCssValue *value = _gtk_css_border_style_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");
402

403 404 405 406 407 408 409 410 411 412 413
  return value;
}

static void
query_border_style (GtkCssStyleProperty *property,
                    const GtkCssValue   *css_value,
                    GValue              *value)
{
  g_value_init (value, GTK_TYPE_BORDER_STYLE);
  g_value_set_enum (value, _gtk_css_border_style_value_get (css_value));
}
414

415 416 417 418 419
static GtkCssValue *
assign_border_style (GtkCssStyleProperty *property,
                     const GValue        *value)
{
  return _gtk_css_border_style_value_new (g_value_get_enum (value));
420 421 422
}

static GtkCssValue *
423
parse_css_area_one (GtkCssParser *parser)
424
{
425 426 427 428
  GtkCssValue *value = _gtk_css_area_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");
429

430
  return value;
431 432
}

433 434 435 436
static GtkCssValue *
parse_css_area (GtkCssStyleProperty *property,
                GtkCssParser        *parser)
{
437
  return _gtk_css_array_value_parse (parser, parse_css_area_one);
438 439
}

440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
static GtkCssValue *
parse_one_css_direction (GtkCssParser *parser)
{
  GtkCssValue *value = _gtk_css_direction_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

static GtkCssValue *
parse_css_direction (GtkCssStyleProperty *property,
                     GtkCssParser        *parser)
{
  return _gtk_css_array_value_parse (parser, parse_one_css_direction);
}

Alexander Larsson's avatar
Alexander Larsson committed
458 459 460 461 462 463 464
static GtkCssValue *
opacity_parse (GtkCssStyleProperty *property,
	       GtkCssParser        *parser)
{
  return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
}

465 466 467 468 469 470 471 472 473
static void
opacity_query (GtkCssStyleProperty *property,
               const GtkCssValue   *css_value,
               GValue              *value)
{
  g_value_init (value, G_TYPE_DOUBLE);
  g_value_set_double (value, _gtk_css_number_value_get (css_value, 100));
}

Alexander Larsson's avatar
Alexander Larsson committed
474

475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
static GtkCssValue *
parse_one_css_play_state (GtkCssParser *parser)
{
  GtkCssValue *value = _gtk_css_play_state_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

static GtkCssValue *
parse_css_play_state (GtkCssStyleProperty *property,
                      GtkCssParser        *parser)
{
  return _gtk_css_array_value_parse (parser, parse_one_css_play_state);
}

static GtkCssValue *
parse_one_css_fill_mode (GtkCssParser *parser)
{
  GtkCssValue *value = _gtk_css_fill_mode_value_try_parse (parser);
  
  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

static GtkCssValue *
parse_css_fill_mode (GtkCssStyleProperty *property,
                     GtkCssParser        *parser)
{
  return _gtk_css_array_value_parse (parser, parse_one_css_fill_mode);
}

511 512 513 514
static GtkCssValue *
image_effect_parse (GtkCssStyleProperty *property,
		    GtkCssParser        *parser)
{
515
  GtkCssValue *value = _gtk_css_icon_effect_value_try_parse (parser);
516 517 518 519 520 521 522

  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

523 524 525 526 527 528 529
static GtkCssValue *
icon_palette_parse (GtkCssStyleProperty *property,
		    GtkCssParser        *parser)
{
  return gtk_css_palette_value_parse (parser);
}

530 531 532 533 534 535 536 537 538 539 540 541
static GtkCssValue *
icon_style_parse (GtkCssStyleProperty *property,
		  GtkCssParser        *parser)
{
  GtkCssValue *value = _gtk_css_icon_style_value_try_parse (parser);

  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

542 543 544 545 546 547 548 549 550 551 552 553
static GtkCssValue *
bindings_value_parse_one (GtkCssParser *parser)
{
  char *name;

  name = _gtk_css_parser_try_ident (parser, TRUE);
  if (name == NULL)
    {
      _gtk_css_parser_error (parser, "Not a valid binding name");
      return NULL;
    }

554
  if (g_ascii_strcasecmp (name, "none") == 0)
555 556 557 558
    {
      name = NULL;
    }
  else if (!gtk_binding_set_find (name))
559 560 561 562 563 564 565 566 567
    {
      _gtk_css_parser_error (parser, "No binding set named '%s'", name);
      g_free (name);
      return NULL;
    }

  return _gtk_css_string_value_new_take (name);
}

568
static GtkCssValue *
569
bindings_value_parse (GtkCssStyleProperty *property,
570
                      GtkCssParser        *parser)
571
{
572
  return _gtk_css_array_value_parse (parser, bindings_value_parse_one);
573 574 575 576 577 578
}

static void
bindings_value_query (GtkCssStyleProperty *property,
                      const GtkCssValue   *css_value,
                      GValue              *value)
579 580
{
  GPtrArray *array;
581
  guint i;
582

583
  g_value_init (value, G_TYPE_PTR_ARRAY);
584

585 586
  if (_gtk_css_array_value_get_n_values (css_value) == 0)
    return;
587

588
  array = NULL;
589

590 591
  for (i = 0; i < _gtk_css_array_value_get_n_values (css_value); i++)
    {
592 593 594 595 596 597 598 599 600 601 602 603 604
      const char *name;
      GtkBindingSet *binding_set;
      
      name = _gtk_css_string_value_get (_gtk_css_array_value_get_nth (css_value, i));
      if (name == NULL)
        continue;

      binding_set = gtk_binding_set_find (name);
      if (binding_set == NULL)
        continue;
      
      if (array == NULL)
        array = g_ptr_array_new ();
605 606 607
      g_ptr_array_add (array, binding_set);
    }

608
  g_value_take_boxed (value, array);
609 610
}

611 612 613
static GtkCssValue *
bindings_value_assign (GtkCssStyleProperty *property,
                       const GValue        *value)
614
{
615 616
  GPtrArray *binding_sets = g_value_get_boxed (value);
  GtkCssValue **values, *result;
617 618
  guint i;

619
  if (binding_sets == NULL || binding_sets->len == 0)
620
    return _gtk_css_array_value_new (_gtk_css_string_value_new (NULL));
621

622
  values = g_new (GtkCssValue *, binding_sets->len);
623

624 625 626 627
  for (i = 0; i < binding_sets->len; i++)
    {
      GtkBindingSet *binding_set = g_ptr_array_index (binding_sets, i);
      values[i] = _gtk_css_string_value_new (binding_set->set_name);
628
    }
629 630 631 632

  result = _gtk_css_array_value_new_from_array (values, binding_sets->len);
  g_free (values);
  return result;
633 634
}

635 636 637 638 639 640 641
static GtkCssValue *
parse_letter_spacing (GtkCssStyleProperty *property,
                      GtkCssParser        *parser)
{
  return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH);
}

642 643 644 645 646 647 648 649 650 651 652 653
static GtkCssValue *
parse_text_decoration_line (GtkCssStyleProperty *property,
                            GtkCssParser        *parser)
{
  GtkCssValue *value = _gtk_css_text_decoration_line_value_try_parse (parser);

  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

654 655 656 657 658 659 660 661 662 663 664 665
static GtkCssValue *
parse_text_decoration_style (GtkCssStyleProperty *property,
                             GtkCssParser        *parser)
{
  GtkCssValue *value = _gtk_css_text_decoration_style_value_try_parse (parser);

  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

666 667 668 669 670 671 672
static GtkCssValue *
box_shadow_value_parse (GtkCssStyleProperty *property,
                        GtkCssParser        *parser)
{
  return _gtk_css_shadows_value_parse (parser, TRUE);
}

673 674
static GtkCssValue *
shadow_value_parse (GtkCssStyleProperty *property,
675
                    GtkCssParser        *parser)
676
{
677
  return _gtk_css_shadows_value_parse (parser, FALSE);
678 679
}

680 681 682 683 684 685 686
static GtkCssValue *
transform_value_parse (GtkCssStyleProperty *property,
                       GtkCssParser        *parser)
{
  return _gtk_css_transform_value_parse (parser);
}

687
static GtkCssValue *
688
border_corner_radius_value_parse (GtkCssStyleProperty *property,
689
                                  GtkCssParser        *parser)
690
{
691
  return _gtk_css_corner_value_parse (parser);
692 693
}

694
static GtkCssValue *
695
css_image_value_parse (GtkCssStyleProperty *property,
696
                       GtkCssParser        *parser)
697 698 699 700 701 702 703
{
  GtkCssImage *image;

  if (_gtk_css_parser_try (parser, "none", TRUE))
    image = NULL;
  else
    {
704
      image = _gtk_css_image_new_parse (parser);
705
      if (image == NULL)
706
        return NULL;
707 708
    }

709
  return _gtk_css_image_value_new (image);
710 711
}

712 713 714 715 716 717 718 719 720 721
static GtkCssValue *
css_image_value_parse_with_builtin (GtkCssStyleProperty *property,
                                    GtkCssParser        *parser)
{
  if (_gtk_css_parser_try (parser, "builtin", TRUE))
    return _gtk_css_image_value_new (gtk_css_image_builtin_new ());

  return css_image_value_parse (property, parser);
}

722 723 724 725 726
static void
css_image_value_query (GtkCssStyleProperty *property,
                       const GtkCssValue   *css_value,
                       GValue              *value)
{
727
  GtkCssImage *image = _gtk_css_image_value_get_image (css_value);
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
  cairo_pattern_t *pattern;
  cairo_surface_t *surface;
  cairo_matrix_t matrix;
  
  g_value_init (value, CAIRO_GOBJECT_TYPE_PATTERN);

  if (GTK_IS_CSS_IMAGE_GRADIENT (image))
    g_value_set_boxed (value, GTK_CSS_IMAGE_GRADIENT (image)->pattern);
  else if (image != NULL)
    {
      double width, height;

      /* the 100, 100 is rather random */
      _gtk_css_image_get_concrete_size (image, 0, 0, 100, 100, &width, &height);
      surface = _gtk_css_image_get_surface (image, NULL, width, height);
      pattern = cairo_pattern_create_for_surface (surface);
      cairo_matrix_init_scale (&matrix, width, height);
      cairo_pattern_set_matrix (pattern, &matrix);
      cairo_surface_destroy (surface);
      g_value_take_boxed (value, pattern);
    }
}

751 752 753 754 755
static GtkCssValue *
css_image_value_assign (GtkCssStyleProperty *property,
                        const GValue        *value)
{
  g_warning ("FIXME: assigning images is not implemented");
756
  return _gtk_css_image_value_new (NULL);
757 758
}

759 760 761 762 763 764 765 766 767 768
static GtkCssValue *
background_image_value_parse_one (GtkCssParser *parser)
{
  return css_image_value_parse (NULL, parser);
}

static GtkCssValue *
background_image_value_parse (GtkCssStyleProperty *property,
                              GtkCssParser        *parser)
{
769
  return _gtk_css_array_value_parse (parser, background_image_value_parse_one);
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
}

static void
background_image_value_query (GtkCssStyleProperty *property,
                              const GtkCssValue   *css_value,
                              GValue              *value)
{
  css_image_value_query (property, _gtk_css_array_value_get_nth (css_value, 0), value);
}

static GtkCssValue *
background_image_value_assign (GtkCssStyleProperty *property,
                               const GValue        *value)
{
  return _gtk_css_array_value_new (css_image_value_assign (property, value));
}

787 788 789 790 791 792 793
static GtkCssValue *
dpi_parse (GtkCssStyleProperty *property,
	   GtkCssParser        *parser)
{
  return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
}

794 795
GtkCssValue *
gtk_css_font_size_value_parse (GtkCssParser *parser)
796
{
797
  GtkCssValue *value;
798

799 800 801 802
  value = _gtk_css_font_size_value_try_parse (parser);
  if (value)
    return value;

803 804 805 806 807
  return _gtk_css_number_value_parse (parser,
                                      GTK_CSS_PARSE_LENGTH
                                      | GTK_CSS_PARSE_PERCENT
                                      | GTK_CSS_POSITIVE_ONLY
                                      | GTK_CSS_NUMBER_AS_PIXELS);
808 809
}

810 811 812 813 814 815 816
static GtkCssValue *
font_size_parse (GtkCssStyleProperty *property,
                 GtkCssParser        *parser)
{
  return gtk_css_font_size_value_parse (parser);
}

817 818
static GtkCssValue *
outline_parse (GtkCssStyleProperty *property,
819
               GtkCssParser        *parser)
820
{
821 822 823 824
  return _gtk_css_number_value_parse (parser,
                                      GTK_CSS_NUMBER_AS_PIXELS
                                      | GTK_CSS_PARSE_LENGTH);
}
825 826 827

static GtkCssValue *
border_image_repeat_parse (GtkCssStyleProperty *property,
828
                           GtkCssParser        *parser)
829
{
830
  GtkCssValue *value = _gtk_css_border_repeat_value_try_parse (parser);
831

832
  if (value == NULL)
833
    {
834
      _gtk_css_parser_error (parser, "Not a valid value");
835 836 837
      return NULL;
    }

838
  return value;
839 840 841 842
}

static GtkCssValue *
border_image_slice_parse (GtkCssStyleProperty *property,
843
                          GtkCssParser        *parser)
844
{
845 846 847 848 849 850
  return _gtk_css_border_value_parse (parser,
                                      GTK_CSS_PARSE_PERCENT
                                      | GTK_CSS_PARSE_NUMBER
                                      | GTK_CSS_POSITIVE_ONLY,
                                      FALSE,
                                      TRUE);
851 852 853 854
}

static GtkCssValue *
border_image_width_parse (GtkCssStyleProperty *property,
855
                          GtkCssParser        *parser)
856
{
857 858 859 860 861 862 863
  return _gtk_css_border_value_parse (parser,
                                      GTK_CSS_PARSE_PERCENT
                                      | GTK_CSS_PARSE_LENGTH
                                      | GTK_CSS_PARSE_NUMBER
                                      | GTK_CSS_POSITIVE_ONLY,
                                      TRUE,
                                      FALSE);
864 865
}

866 867 868 869 870 871 872 873 874
static GtkCssValue *
minmax_parse (GtkCssStyleProperty *property,
              GtkCssParser        *parser)
{
  return _gtk_css_number_value_parse (parser,
                                      GTK_CSS_PARSE_LENGTH
                                      | GTK_CSS_POSITIVE_ONLY);
}

875
static GtkCssValue *
876
transition_property_parse_one (GtkCssParser *parser)
877
{
878
  GtkCssValue *value;
879

880
  value = _gtk_css_ident_value_try_parse (parser);
881

882 883 884 885 886
  if (value == NULL)
    {
      _gtk_css_parser_error (parser, "Expected an identifier");
      return NULL;
    }
887

888 889
  return value;
}
890

891 892
static GtkCssValue *
transition_property_parse (GtkCssStyleProperty *property,
893
                           GtkCssParser        *parser)
894
{
895
  return _gtk_css_array_value_parse (parser, transition_property_parse_one);
896
}
897

898 899 900 901
static GtkCssValue *
transition_time_parse_one (GtkCssParser *parser)
{
  return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);
902 903 904 905
}

static GtkCssValue *
transition_time_parse (GtkCssStyleProperty *property,
906
                       GtkCssParser        *parser)
907
{
908
  return _gtk_css_array_value_parse (parser, transition_time_parse_one);
909 910 911 912
}

static GtkCssValue *
transition_timing_function_parse (GtkCssStyleProperty *property,
913
                                  GtkCssParser        *parser)
914
{
915
  return _gtk_css_array_value_parse (parser, _gtk_css_ease_value_parse);
916 917
}

918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
static GtkCssValue *
iteration_count_parse_one (GtkCssParser *parser)
{
  if (_gtk_css_parser_try (parser, "infinite", TRUE))
    return _gtk_css_number_value_new (HUGE_VAL, GTK_CSS_NUMBER);

  return _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER | GTK_CSS_POSITIVE_ONLY);
}

static GtkCssValue *
iteration_count_parse (GtkCssStyleProperty *property,
                       GtkCssParser        *parser)
{
  return _gtk_css_array_value_parse (parser, iteration_count_parse_one);
}

934 935
static GtkCssValue *
engine_parse (GtkCssStyleProperty *property,
936
              GtkCssParser        *parser)
937
{
938 939
  return _gtk_css_engine_value_parse (parser);
}
940

941 942 943 944 945
static void
engine_query (GtkCssStyleProperty *property,
              const GtkCssValue   *css_value,
              GValue              *value)
{
Benjamin Otte's avatar
Benjamin Otte committed
946
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
947 948
  g_value_init (value, GTK_TYPE_THEMING_ENGINE);
  g_value_set_object (value, _gtk_css_engine_value_get_engine (css_value));
Benjamin Otte's avatar
Benjamin Otte committed
949
G_GNUC_END_IGNORE_DEPRECATIONS
950
}
951

952 953 954 955 956
static GtkCssValue *
engine_assign (GtkCssStyleProperty *property,
               const GValue        *value)
{
  return _gtk_css_engine_value_new (g_value_get_object (value));
957 958
}

959
static GtkCssValue *
960
parse_margin (GtkCssStyleProperty *property,
961
              GtkCssParser        *parser)
962
{
963 964 965
  return _gtk_css_number_value_parse (parser,
                                      GTK_CSS_NUMBER_AS_PIXELS
                                      | GTK_CSS_PARSE_LENGTH);
966 967
}

968
static GtkCssValue *
969
parse_padding (GtkCssStyleProperty *property,
970
               GtkCssParser        *parser)
971
{
972 973 974 975
  return _gtk_css_number_value_parse (parser,
                                      GTK_CSS_POSITIVE_ONLY
                                      | GTK_CSS_NUMBER_AS_PIXELS
                                      | GTK_CSS_PARSE_LENGTH);
976 977
}

978
static GtkCssValue *
979
parse_border_width (GtkCssStyleProperty *property,
980
                    GtkCssParser        *parser)
981
{
982 983 984 985
  return _gtk_css_number_value_parse (parser,
                                      GTK_CSS_POSITIVE_ONLY
                                      | GTK_CSS_NUMBER_AS_PIXELS
                                      | GTK_CSS_PARSE_LENGTH);
986 987
}

988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005
static GtkCssValue *
blend_mode_value_parse_one (GtkCssParser        *parser)
{
  GtkCssValue *value = _gtk_css_blend_mode_value_try_parse (parser);

  if (value == NULL)
    _gtk_css_parser_error (parser, "unknown value for property");

  return value;
}

static GtkCssValue *
blend_mode_value_parse (GtkCssStyleProperty *property,
                        GtkCssParser        *parser)
{
  return _gtk_css_array_value_parse (parser, blend_mode_value_parse_one);
}

1006
static GtkCssValue *
1007
background_repeat_value_parse_one (GtkCssParser *parser)
1008
{
1009
  GtkCssValue *value = _gtk_css_background_repeat_value_try_parse (parser);
1010

1011
  if (value == NULL)
1012 1013
    {
      _gtk_css_parser_error (parser, "Not a valid value");
1014
      return NULL;
1015 1016
    }

1017
  return value;
1018 1019
}

1020 1021 1022 1023
static GtkCssValue *
background_repeat_value_parse (GtkCssStyleProperty *property,
                               GtkCssParser        *parser)
{
1024
  return _gtk_css_array_value_parse (parser, background_repeat_value_parse_one);
1025 1026
}

1027
static GtkCssValue *
1028
background_size_parse (GtkCssStyleProperty *property,
1029
                       GtkCssParser        *parser)
1030
{
1031
  return _gtk_css_array_value_parse (parser, _gtk_css_bg_size_value_parse);
1032 1033
}

1034
static GtkCssValue *
1035
background_position_parse (GtkCssStyleProperty *property,
1036
			   GtkCssParser        *parser)
1037
{
1038
  return _gtk_css_array_value_parse (parser, _gtk_css_position_value_parse);
1039 1040
}

1041 1042 1043 1044
static GtkCssValue *
icon_theme_value_parse (GtkCssStyleProperty *property,
		        GtkCssParser        *parser)
{
1045
  return gtk_css_icon_theme_value_parse (parser);
1046 1047
}

1048 1049 1050 1051 1052
/*** REGISTRATION ***/

void
_gtk_css_style_property_init_properties (void)
{
1053
  /* Initialize "color", "-gtk-dpi" and "font-size" first,
1054 1055 1056
   * so that when computing values later they are
   * done first. That way, 'currentColor' and font
   * sizes in em can be looked up properly */
1057
  gtk_css_style_property_register        ("color",
1058
                                          GTK_CSS_PROPERTY_COLOR,
1059
                                          GDK_TYPE_RGBA,
1060
                                          GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
1061
                                          GTK_CSS_AFFECTS_FOREGROUND | GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
1062
                                          color_parse,
1063 1064
                                          color_query,
                                          color_assign,
1065
                                          _gtk_css_color_value_new_rgba (1, 1, 1, 1));
1066 1067 1068 1069
  gtk_css_style_property_register        ("-gtk-dpi",
                                          GTK_CSS_PROPERTY_DPI,
                                          G_TYPE_NONE,
                                          GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
1070
                                          GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_SIZE,
1071 1072 1073 1074
                                          dpi_parse,
                                          NULL,
                                          NULL,
                                          _gtk_css_number_value_new (96.0, GTK_CSS_NUMBER));
1075
  gtk_css_style_property_register        ("font-size",
1076
                                          GTK_CSS_PROPERTY_FONT_SIZE,
1077
                                          G_TYPE_DOUBLE,
1078
                                          GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
1079
                                          GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_SIZE,
1080
                                          font_size_parse,
Benjamin Otte's avatar
Benjamin Otte committed
1081 1082
                                          query_font_size,
                                          assign_font_size,
1083
                                          _gtk_css_font_size_value_new (GTK_CSS_FONT_SIZE_MEDIUM));
1084 1085 1086 1087
  gtk_css_style_property_register        ("-gtk-icon-theme",
                                          GTK_CSS_PROPERTY_ICON_THEME,
                                          G_TYPE_NONE,
                                          GTK_STYLE_PROPERTY_INHERIT,
1088
                                          GTK_CSS_AFFECTS_ICON | GTK_CSS_AFFECTS_SYMBOLIC_ICON,
1089 1090 1091
                                          icon_theme_value_parse,
                                          NULL,
                                          NULL,
1092
                                          gtk_css_icon_theme_value_new (NULL));
1093 1094 1095 1096
  gtk_css_style_property_register        ("-gtk-icon-palette",
					  GTK_CSS_PROPERTY_ICON_PALETTE,
					  G_TYPE_NONE,
					  GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_INHERIT,
1097
                                          GTK_CSS_AFFECTS_SYMBOLIC_ICON,
1098 1099 1100 1101 1102
					  icon_palette_parse,
					  NULL,
					  NULL,
					  gtk_css_palette_value_new_default ());

1103 1104 1105

  /* properties that aren't referenced when computing values
   * start here */
1106
  gtk_css_style_property_register        ("background-color",
1107
                                          GTK_CSS_PROPERTY_BACKGROUND_COLOR,
1108
                                          GDK_TYPE_RGBA,
1109 1110
                                          GTK_STYLE_PROPERTY_ANIMATED,
                                          GTK_CSS_AFFECTS_BACKGROUND,
1111
                                          color_parse,
1112 1113
                                          color_query,
                                          color_assign,
1114
                                          _gtk_css_color_value_new_rgba (0, 0, 0, 0));
1115

1116
  gtk_css_style_property_register        ("font-family",
1117
                                          GTK_CSS_PROPERTY_FONT_FAMILY,
1118
                                          G_TYPE_STRV,
1119
                                          GTK_STYLE_PROPERTY_INHERIT,
1120
                                          GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
1121
                                          font_family_parse,
1122 1123
                                          font_family_query,
                                          font_family_assign,
1124
                                          _gtk_css_array_value_new (_gtk_css_string_value_new ("Sans")));
1125
  gtk_css_style_property_register        ("font-style",
1126
                                          GTK_CSS_PROPERTY_FONT_STYLE,
1127
                                          PANGO_TYPE_STYLE,
1128
                                          GTK_STYLE_PROPERTY_INHERIT,
1129
                                          GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
1130 1131 1132
                                          font_style_parse,
                                          font_style_query,
                                          font_style_assign,
1133
                                          _gtk_css_font_style_value_new (PANGO_STYLE_NORMAL));
1134
  gtk_css_style_property_register        ("font-variant",
1135
                                          GTK_CSS_PROPERTY_FONT_VARIANT,
1136
                                          PANGO_TYPE_VARIANT,
1137
                                          GTK_STYLE_PROPERTY_INHERIT,
1138
                                          GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
1139 1140 1141
                                          font_variant_parse,
                                          font_variant_query,
                                          font_variant_assign,
1142
                                          _gtk_css_font_variant_value_new (PANGO_VARIANT_NORMAL));
1143
  gtk_css_style_property_register        ("font-weight",
1144
                                          GTK_CSS_PROPERTY_FONT_WEIGHT,
1145
                                          PANGO_TYPE_WEIGHT,
1146
                                          GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
1147
                                          GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
1148 1149 1150
                                          font_weight_parse,
                                          font_weight_query,
                                          font_weight_assign,
1151
                                          _gtk_css_font_weight_value_new (PANGO_WEIGHT_NORMAL));
1152 1153 1154
  gtk_css_style_property_register        ("font-stretch",
                                          GTK_CSS_PROPERTY_FONT_STRETCH,
                                          PANGO_TYPE_STRETCH,
1155
                                          GTK_STYLE_PROPERTY_INHERIT,
1156
                                          GTK_CSS_AFFECTS_FONT | GTK_CSS_AFFECTS_TEXT,
1157 1158 1159
                                          font_stretch_parse,
                                          font_stretch_query,
                                          font_stretch_assign,
1160
                                          _gtk_css_font_stretch_value_new (PANGO_STRETCH_NORMAL));
1161

1162 1163 1164 1165
  gtk_css_style_property_register        ("letter-spacing",
                                          GTK_CSS_PROPERTY_LETTER_SPACING,
                                          G_TYPE_NONE,
                                          GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
1166
                                          GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
1167 1168 1169 1170 1171
                                          parse_letter_spacing,
                                          NULL,
                                          NULL,
                                          _gtk_css_number_value_new (0.0, GTK_CSS_PX));

1172 1173 1174 1175
  gtk_css_style_property_register        ("text-decoration-line",
                                          GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
                                          G_TYPE_NONE,
                                          0,
1176
                                          GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
1177 1178 1179 1180
                                          parse_text_decoration_line,
                                          NULL,
                                          NULL,
                                          _gtk_css_text_decoration_line_value_new (GTK_CSS_TEXT_DECORATION_LINE_NONE));
1181 1182 1183 1184
  gtk_css_style_property_register        ("text-decoration-color",
                                          GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
                                          G_TYPE_NONE,
                                          GTK_STYLE_PROPERTY_ANIMATED,
1185
                                          GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
1186 1187 1188 1189
                                          color_parse,
                                          NULL,
                                          NULL,
                                          _gtk_css_color_value_new_current_color ());
1190 1191 1192
  gtk_css_style_property_register        ("text-decoration-style",
                                          GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
                                          G_TYPE_NONE,
1193
                                          0,
1194
                                          GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
1195 1196 1197 1198 1199
                                          parse_text_decoration_style,
                                          NULL,
                                          NULL,
                                          _gtk_css_text_decoration_style_value_new (GTK_CSS_TEXT_DECORATION_STYLE_SOLID));

1200
  gtk_css_style_property_register        ("text-shadow",
1201
                                          GTK_CSS_PROPERTY_TEXT_SHADOW,
1202
                                          G_TYPE_NONE,
1203
                                          GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
1204
                                          GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_CLIP,
1205
                                          shadow_value_parse,
1206
                                          NULL,
1207
                                          NULL,
1208
                                          _gtk_css_shadows_value_new_none ());
1209

1210
  gtk_css_style_property_register        ("box-shadow",
1211
                                          GTK_CSS_PROPERTY_BOX_SHADOW,
1212
                                          G_TYPE_NONE,
1213
                                          GTK_STYLE_PROPERTY_ANIMATED,
1214
                                          GTK_CSS_AFFECTS_BACKGROUND | GTK_CSS_AFFECTS_CLIP,
1215
                                          box_shadow_value_parse,
1216
                                          NULL,
1217
                                          NULL,
1218
                                          _gtk_css_shadows_value_new_none ());
1219

1220
  gtk_css_style_property_register        ("margin-top",
1221
                                          GTK_CSS_PROPERTY_MARGIN_TOP,
1222
                                          G_TYPE_INT,
1223
                                          GTK_STYLE_PROPERTY_ANIMATED,
1224
                                          GTK_CSS_AFFECTS_SIZE,
1225
                                          parse_margin,
1226
                                          query_length_as_int,
1227
                                          assign_length_from_int,
1228
                                          _gtk_css_number_value_new (0.0, GTK_CSS_PX));
1229
  gtk_css_style_property_register        ("margin-left",
1230
                                          GTK_CSS_PROPERTY_MARGIN_LEFT,
1231
                                          G_TYPE_INT,
1232
                                          GTK_STYLE_PROPERTY_ANIMATED,
1233
                                          GTK_CSS_AFFECTS_SIZE,
1234
                                          parse_margin,
1235
                                          query_length_as_int,
1236
                                          assign_length_from_int,
1237
                                          _gtk_css_number_value_new (0.0, GTK_CSS_PX));
1238
  gtk_css_style_property_register        ("margin-bottom",
1239
                                          GTK_CSS_PROPERTY_MARGIN_BOTTOM,
1240
                                          G_TYPE_INT,
1241
                                          GTK_STYLE_PROPERTY_ANIMATED,
1242
                                          GTK_CSS_AFFECTS_SIZE,
1243
                                          parse_margin,
1244
                                          query_length_as_int,
1245
                                          assign_length_from_int,
1246
                                          _gtk_css_number_value_new (0.0, GTK_CSS_PX));
1247
  gtk_css_style_property_register        ("margin-right",
1248
                                          GTK_CSS_PROPERTY_MARGIN_RIGHT,
1249
                                          G_TYPE_INT,
1250
                                          GTK_STYLE_PROPERTY_ANIMATED,
1251
                                          GTK_CSS_AFFECTS_SIZE,
1252
                                          parse_margin,
1253
                                          query_length_as_int,
1254
                                          assign_length_from_int,
1255
                                          _gtk_css_number_value_new (0.0, GTK_CSS_PX));
1256
  gtk_css_style_property_register        ("padding-top",
1257
                                          GTK_CSS_PROPERTY_PADDING_TOP,
1258
                                          G_TYPE_INT,
1259
                                          GTK_STYLE_PROPERTY_ANIMATED,
1260
                                          GTK_CSS_AFFECTS_SIZE,
1261
                                          parse_padding,
1262
                                          query_length_as_int,
1263
                                          assign_length_from_int,
1264
                                          _gtk_css_number_value_new (0.0, GTK_CSS_PX));
1265
  gtk_css_style_property_register        ("padding-left",
1266
                                          GTK_CSS_PROPERTY_PADDING_LEFT,
1267
                                          G_TYPE_INT,
1268
                                          GTK_STYLE_PROPERTY_ANIMATED,
1269
                                          GTK_CSS_AFFECTS_SIZE,
1270
                                          parse_padding,
1271
                                          query_length_as_int,
1272
                                          assign_length_from_int,
1273
                                          _gtk_css_number_value_new (0.0, GTK_CSS_PX));
1274
  gtk_css_style_property_register        ("padding-bottom",
1275
                                          GTK_CSS_PROPERTY_PADDING_BOTTOM,
1276
                                          G_TYPE_INT,
Benjamin Otte's avatar