2011-04-08 14:08:28 +00:00
|
|
|
/* 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
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-05-21 01:30:36 +00:00
|
|
|
#include "gtkstylepropertyprivate.h"
|
2011-04-08 14:08:28 +00:00
|
|
|
|
|
|
|
#include <errno.h>
|
2011-05-29 05:03:59 +00:00
|
|
|
#include <math.h>
|
2011-04-08 14:08:28 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
|
|
|
#include <cairo-gobject.h>
|
|
|
|
|
|
|
|
#include "gtkcssprovider.h"
|
2011-04-14 02:47:18 +00:00
|
|
|
#include "gtkcssparserprivate.h"
|
2011-12-31 12:43:31 +00:00
|
|
|
#include "gtkcssshorthandpropertyprivate.h"
|
2012-01-01 17:14:51 +00:00
|
|
|
#include "gtkcssstylefuncsprivate.h"
|
2011-12-31 12:43:31 +00:00
|
|
|
#include "gtkcssstylepropertyprivate.h"
|
2011-05-26 01:50:53 +00:00
|
|
|
#include "gtkcsstypesprivate.h"
|
2011-12-31 13:34:42 +00:00
|
|
|
#include "gtkintl.h"
|
2011-11-25 13:36:27 +00:00
|
|
|
#include "gtkprivatetypebuiltins.h"
|
2011-12-31 00:14:47 +00:00
|
|
|
#include "gtkstylepropertiesprivate.h"
|
2011-04-08 14:08:28 +00:00
|
|
|
|
|
|
|
/* the actual parsers we have */
|
|
|
|
#include "gtkanimationdescription.h"
|
2011-05-18 16:03:23 +00:00
|
|
|
#include "gtkbindings.h"
|
2011-04-08 14:08:28 +00:00
|
|
|
#include "gtkgradient.h"
|
2011-05-19 18:48:22 +00:00
|
|
|
#include "gtkshadowprivate.h"
|
2011-04-08 14:08:28 +00:00
|
|
|
#include "gtkthemingengine.h"
|
2011-05-21 02:17:28 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
2011-11-15 19:52:45 +00:00
|
|
|
#include "gtkwin32themeprivate.h"
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2011-08-19 06:26:52 +00:00
|
|
|
/* 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"
|
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
2011-12-31 16:36:22 +00:00
|
|
|
PROP_NAME,
|
|
|
|
PROP_VALUE_TYPE
|
2011-12-31 13:34:42 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 12:43:31 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GtkStyleProperty, _gtk_style_property, G_TYPE_OBJECT)
|
2011-12-31 02:54:17 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_style_property_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkStyleProperty *property = GTK_STYLE_PROPERTY (object);
|
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
g_warning ("finalizing %s `%s', how could this happen?", G_OBJECT_TYPE_NAME (object), property->name);
|
2011-12-31 02:54:17 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (_gtk_style_property_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
static void
|
|
|
|
gtk_style_property_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkStyleProperty *property = GTK_STYLE_PROPERTY (object);
|
|
|
|
GtkStylePropertyClass *klass = GTK_STYLE_PROPERTY_GET_CLASS (property);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_NAME:
|
|
|
|
property->name = g_value_dup_string (value);
|
|
|
|
g_assert (property->name);
|
|
|
|
g_assert (g_hash_table_lookup (klass->properties, property->name) == NULL);
|
|
|
|
g_hash_table_insert (klass->properties, property->name, property);
|
|
|
|
break;
|
2011-12-31 16:36:22 +00:00
|
|
|
case PROP_VALUE_TYPE:
|
|
|
|
property->value_type = g_value_get_gtype (value);
|
|
|
|
break;
|
2011-12-31 13:34:42 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_style_property_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkStyleProperty *property = GTK_STYLE_PROPERTY (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_NAME:
|
|
|
|
g_value_set_string (value, property->name);
|
|
|
|
break;
|
2011-12-31 16:36:22 +00:00
|
|
|
case PROP_VALUE_TYPE:
|
|
|
|
g_value_set_gtype (value, property->value_type);
|
|
|
|
break;
|
2011-12-31 13:34:42 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-31 02:54:17 +00:00
|
|
|
static void
|
|
|
|
_gtk_style_property_class_init (GtkStylePropertyClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gtk_style_property_finalize;
|
2011-12-31 13:34:42 +00:00
|
|
|
object_class->set_property = gtk_style_property_set_property;
|
|
|
|
object_class->get_property = gtk_style_property_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_NAME,
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
P_("Property name"),
|
|
|
|
P_("The name of the property"),
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2011-12-31 16:36:22 +00:00
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_VALUE_TYPE,
|
|
|
|
g_param_spec_gtype ("value-type",
|
|
|
|
P_("Value type"),
|
|
|
|
P_("The value type returned by GtkStyleContext"),
|
|
|
|
G_TYPE_NONE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
2011-12-31 13:34:42 +00:00
|
|
|
|
|
|
|
klass->properties = g_hash_table_new (g_str_hash, g_str_equal);
|
2011-12-31 02:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_style_property_init (GtkStyleProperty *property)
|
|
|
|
{
|
2011-12-31 16:36:22 +00:00
|
|
|
property->value_type = G_TYPE_NONE;
|
2011-12-31 02:54:17 +00:00
|
|
|
}
|
|
|
|
|
2011-05-29 03:25:05 +00:00
|
|
|
static void
|
|
|
|
string_append_double (GString *string,
|
|
|
|
double d)
|
|
|
|
{
|
|
|
|
char buf[G_ASCII_DTOSTR_BUF_SIZE];
|
|
|
|
|
|
|
|
g_ascii_dtostr (buf, sizeof (buf), d);
|
|
|
|
g_string_append (string, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
string_append_string (GString *str,
|
|
|
|
const char *string)
|
|
|
|
{
|
|
|
|
gsize len;
|
|
|
|
|
|
|
|
g_string_append_c (str, '"');
|
|
|
|
|
|
|
|
do {
|
|
|
|
len = strcspn (string, "\"\n\r\f");
|
|
|
|
g_string_append (str, string);
|
|
|
|
string += len;
|
|
|
|
switch (*string)
|
|
|
|
{
|
|
|
|
case '\0':
|
|
|
|
break;
|
|
|
|
case '\n':
|
|
|
|
g_string_append (str, "\\A ");
|
|
|
|
break;
|
|
|
|
case '\r':
|
|
|
|
g_string_append (str, "\\D ");
|
|
|
|
break;
|
|
|
|
case '\f':
|
|
|
|
g_string_append (str, "\\C ");
|
|
|
|
break;
|
|
|
|
case '\"':
|
|
|
|
g_string_append (str, "\\\"");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (*string);
|
|
|
|
|
|
|
|
g_string_append_c (str, '"');
|
|
|
|
}
|
|
|
|
|
2011-04-08 14:08:28 +00:00
|
|
|
/*** IMPLEMENTATIONS ***/
|
|
|
|
|
2011-05-29 05:03:59 +00:00
|
|
|
static gboolean
|
|
|
|
font_family_parse (GtkCssParser *parser,
|
|
|
|
GFile *base,
|
|
|
|
GValue *value)
|
|
|
|
{
|
|
|
|
GPtrArray *names;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
/* We don't special case generic families. Pango should do
|
|
|
|
* that for us */
|
|
|
|
|
|
|
|
names = g_ptr_array_new ();
|
|
|
|
|
|
|
|
do {
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
g_ptr_array_free (names, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_ptr_array_add (names, name);
|
|
|
|
} while (_gtk_css_parser_try (parser, ",", TRUE));
|
|
|
|
|
|
|
|
/* NULL-terminate array */
|
|
|
|
g_ptr_array_add (names, NULL);
|
|
|
|
g_value_set_boxed (value, g_ptr_array_free (names, FALSE));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
font_family_value_print (const GValue *value,
|
|
|
|
GString *string)
|
|
|
|
{
|
|
|
|
const char **names = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
if (names == NULL || *names == NULL)
|
|
|
|
{
|
|
|
|
g_string_append (string, "none");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
string_append_string (string, *names);
|
|
|
|
names++;
|
|
|
|
while (*names)
|
|
|
|
{
|
|
|
|
g_string_append (string, ", ");
|
|
|
|
string_append_string (string, *names);
|
|
|
|
names++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-08 14:08:28 +00:00
|
|
|
static gboolean
|
2012-01-01 17:14:51 +00:00
|
|
|
bindings_value_parse (GtkCssParser *parser,
|
|
|
|
GFile *base,
|
|
|
|
GValue *value)
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2012-01-01 17:14:51 +00:00
|
|
|
GPtrArray *array;
|
|
|
|
GtkBindingSet *binding_set;
|
|
|
|
char *name;
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
array = g_ptr_array_new ();
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
do {
|
|
|
|
name = _gtk_css_parser_try_ident (parser, TRUE);
|
|
|
|
if (name == NULL)
|
|
|
|
{
|
|
|
|
_gtk_css_parser_error (parser, "Not a valid binding name");
|
|
|
|
g_ptr_array_free (array, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
binding_set = gtk_binding_set_find (name);
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
if (!binding_set)
|
|
|
|
{
|
|
|
|
_gtk_css_parser_error (parser, "No binding set named '%s'", name);
|
|
|
|
g_free (name);
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
g_ptr_array_add (array, binding_set);
|
|
|
|
g_free (name);
|
2011-11-16 11:19:20 +00:00
|
|
|
}
|
2012-01-01 17:14:51 +00:00
|
|
|
while (_gtk_css_parser_try (parser, ",", TRUE));
|
2011-11-16 11:19:20 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
g_value_take_boxed (value, array);
|
2011-04-08 14:08:28 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-05-23 05:02:36 +00:00
|
|
|
static void
|
2012-01-01 17:14:51 +00:00
|
|
|
bindings_value_print (const GValue *value,
|
|
|
|
GString *string)
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2012-01-01 17:14:51 +00:00
|
|
|
GPtrArray *array;
|
|
|
|
guint i;
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
array = g_value_get_boxed (value);
|
2011-04-14 02:47:18 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
for (i = 0; i < array->len; i++)
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2012-01-01 17:14:51 +00:00
|
|
|
GtkBindingSet *binding_set = g_ptr_array_index (array, i);
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
if (i > 0)
|
|
|
|
g_string_append (string, ", ");
|
|
|
|
g_string_append (string, binding_set->set_name);
|
2011-04-08 14:08:28 +00:00
|
|
|
}
|
2011-05-26 01:44:09 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 14:08:28 +00:00
|
|
|
static gboolean
|
2012-01-01 17:14:51 +00:00
|
|
|
border_corner_radius_value_parse (GtkCssParser *parser,
|
|
|
|
GFile *base,
|
|
|
|
GValue *value)
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2012-01-01 17:14:51 +00:00
|
|
|
GtkCssBorderCornerRadius corner;
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
if (!_gtk_css_parser_try_double (parser, &corner.horizontal))
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2011-05-18 16:32:22 +00:00
|
|
|
_gtk_css_parser_error (parser, "Expected a number");
|
2011-04-08 14:08:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-01-01 17:14:51 +00:00
|
|
|
else if (corner.horizontal < 0)
|
|
|
|
goto negative;
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
if (!_gtk_css_parser_try_double (parser, &corner.vertical))
|
|
|
|
corner.vertical = corner.horizontal;
|
|
|
|
else if (corner.vertical < 0)
|
|
|
|
goto negative;
|
2011-04-12 02:26:10 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
g_value_set_boxed (value, &corner);
|
2011-04-12 02:26:10 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
negative:
|
|
|
|
_gtk_css_parser_error (parser, "Border radius values cannot be negative");
|
|
|
|
return FALSE;
|
2011-04-12 02:26:10 +00:00
|
|
|
}
|
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
static void
|
|
|
|
border_corner_radius_value_print (const GValue *value,
|
|
|
|
GString *string)
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2012-01-01 17:14:51 +00:00
|
|
|
GtkCssBorderCornerRadius *corner;
|
2011-05-18 16:32:22 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
corner = g_value_get_boxed (value);
|
2011-12-30 11:44:16 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
if (corner == NULL)
|
2011-05-18 16:32:22 +00:00
|
|
|
{
|
2012-01-01 17:14:51 +00:00
|
|
|
g_string_append (string, "none");
|
|
|
|
return;
|
2011-05-18 16:32:22 +00:00
|
|
|
}
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
string_append_double (string, corner->horizontal);
|
|
|
|
if (corner->horizontal != corner->vertical)
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2012-01-01 17:14:51 +00:00
|
|
|
g_string_append_c (string, ' ');
|
|
|
|
string_append_double (string, corner->vertical);
|
2011-04-08 14:08:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-01 17:14:51 +00:00
|
|
|
/*** API ***/
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-02 09:06:47 +00:00
|
|
|
/**
|
|
|
|
* _gtk_style_property_parse_value:
|
|
|
|
* @property: the property
|
|
|
|
* @value: an uninitialized value
|
|
|
|
* @parser: the parser to parse from
|
|
|
|
* @base: the base file for @aprser
|
|
|
|
*
|
|
|
|
* Tries to parse the given @property from the given @parser into
|
|
|
|
* @value. The type that @value will be assigned is dependant on
|
|
|
|
* the parser and no assumptions must be made about it. If the
|
|
|
|
* parsing fails, %FALSE will be returned and @value will be
|
|
|
|
* left uninitialized.
|
|
|
|
*
|
|
|
|
* Only if @property is a #GtkCssShorthandProperty, the @value will
|
|
|
|
* always contain a #GValueArray with the values to be used for
|
|
|
|
* the subproperties.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE on success
|
|
|
|
**/
|
2012-01-01 17:14:51 +00:00
|
|
|
gboolean
|
|
|
|
_gtk_style_property_parse_value (GtkStyleProperty *property,
|
|
|
|
GValue *value,
|
|
|
|
GtkCssParser *parser,
|
|
|
|
GFile *base)
|
2011-04-08 14:08:28 +00:00
|
|
|
{
|
2012-01-01 23:45:29 +00:00
|
|
|
GtkStylePropertyClass *klass;
|
|
|
|
|
2012-01-01 23:14:23 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_STYLE_PROPERTY (property), FALSE);
|
2012-01-01 17:14:51 +00:00
|
|
|
g_return_val_if_fail (value != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (parser != NULL, FALSE);
|
2011-04-08 14:08:28 +00:00
|
|
|
|
2012-01-01 23:45:29 +00:00
|
|
|
klass = GTK_STYLE_PROPERTY_GET_CLASS (property);
|
|
|
|
|
|
|
|
return klass->parse_value (property, value, parser, base);
|
|
|
|
}
|
|
|
|
|
2012-01-01 20:58:45 +00:00
|
|
|
/**
|
|
|
|
* _gtk_style_property_assign:
|
|
|
|
* @property: the property
|
|
|
|
* @props: The properties to assign to
|
|
|
|
* @state: The state to assign
|
|
|
|
* @value: (out): the #GValue with the value to be
|
|
|
|
* assigned
|
|
|
|
*
|
|
|
|
* This function is called by gtk_style_properties_set() and in
|
|
|
|
* turn gtk_style_context_set() and similar functions to set the
|
|
|
|
* value from code using old APIs.
|
|
|
|
**/
|
2011-12-31 18:03:53 +00:00
|
|
|
void
|
|
|
|
_gtk_style_property_assign (GtkStyleProperty *property,
|
|
|
|
GtkStyleProperties *props,
|
|
|
|
GtkStateFlags state,
|
|
|
|
const GValue *value)
|
|
|
|
{
|
2012-01-01 20:58:45 +00:00
|
|
|
GtkStylePropertyClass *klass;
|
|
|
|
|
2011-12-31 18:03:53 +00:00
|
|
|
g_return_if_fail (GTK_IS_STYLE_PROPERTY (property));
|
|
|
|
g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
|
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
|
2012-01-01 20:58:45 +00:00
|
|
|
klass = GTK_STYLE_PROPERTY_GET_CLASS (property);
|
2011-12-31 18:03:53 +00:00
|
|
|
|
2012-01-01 20:58:45 +00:00
|
|
|
klass->assign (property, props, state, value);
|
2011-12-31 18:03:53 +00:00
|
|
|
}
|
|
|
|
|
2012-01-01 20:58:45 +00:00
|
|
|
/**
|
|
|
|
* _gtk_style_property_query:
|
|
|
|
* @property: the property
|
|
|
|
* @props: The properties to query
|
|
|
|
* @state: The state to query
|
|
|
|
* @value: (out): an uninitialized #GValue to be filled with the
|
|
|
|
* contents of the lookup
|
|
|
|
*
|
|
|
|
* This function is called by gtk_style_properties_get() and in
|
|
|
|
* turn gtk_style_context_get() and similar functions to get the
|
|
|
|
* value to return to code using old APIs.
|
|
|
|
**/
|
2011-12-31 00:14:47 +00:00
|
|
|
void
|
2011-12-31 15:08:23 +00:00
|
|
|
_gtk_style_property_query (GtkStyleProperty *property,
|
2011-12-31 00:14:47 +00:00
|
|
|
GtkStyleProperties *props,
|
|
|
|
GtkStateFlags state,
|
|
|
|
GtkStylePropertyContext *context,
|
|
|
|
GValue *value)
|
|
|
|
{
|
2012-01-01 20:58:45 +00:00
|
|
|
GtkStylePropertyClass *klass;
|
2011-12-31 00:14:47 +00:00
|
|
|
|
|
|
|
g_return_if_fail (property != NULL);
|
|
|
|
g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
|
|
|
|
g_return_if_fail (context != NULL);
|
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
|
2012-01-01 20:58:45 +00:00
|
|
|
klass = GTK_STYLE_PROPERTY_GET_CLASS (property);
|
2011-12-31 00:14:47 +00:00
|
|
|
|
2012-01-01 20:58:45 +00:00
|
|
|
g_value_init (value, property->value_type);
|
|
|
|
|
|
|
|
klass->query (property, props, state, context, value);
|
2011-12-31 00:14:47 +00:00
|
|
|
}
|
|
|
|
|
2011-12-29 01:28:32 +00:00
|
|
|
#define rgba_init(rgba, r, g, b, a) G_STMT_START{ \
|
|
|
|
(rgba)->red = (r); \
|
|
|
|
(rgba)->green = (g); \
|
|
|
|
(rgba)->blue = (b); \
|
|
|
|
(rgba)->alpha = (a); \
|
|
|
|
}G_STMT_END
|
2011-05-21 02:17:28 +00:00
|
|
|
static void
|
2011-12-31 13:34:42 +00:00
|
|
|
gtk_style_property_init_properties (void)
|
2011-05-21 02:17:28 +00:00
|
|
|
{
|
2011-12-31 13:34:42 +00:00
|
|
|
static gboolean initialized = FALSE;
|
2011-12-29 01:28:32 +00:00
|
|
|
GValue value = { 0, };
|
|
|
|
char *default_font_family[] = { "Sans", NULL };
|
|
|
|
GdkRGBA rgba;
|
2012-01-02 01:45:52 +00:00
|
|
|
GtkCssBorderCornerRadius no_corner_radius = { 0, };
|
2011-12-29 01:28:32 +00:00
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
if (G_LIKELY (initialized))
|
2011-05-21 02:17:28 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
initialized = TRUE;
|
2011-05-21 02:17:28 +00:00
|
|
|
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_init (&value, GDK_TYPE_RGBA);
|
|
|
|
rgba_init (&rgba, 1, 1, 1, 1);
|
|
|
|
g_value_set_boxed (&value, &rgba);
|
2011-05-31 10:35:42 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("color",
|
|
|
|
"Foreground color",
|
|
|
|
"Foreground color",
|
|
|
|
GDK_TYPE_RGBA, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-12-29 01:28:32 +00:00
|
|
|
rgba_init (&rgba, 0, 0, 0, 0);
|
|
|
|
g_value_set_boxed (&value, &rgba);
|
2011-09-26 13:48:53 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("background-color",
|
|
|
|
"Background color",
|
|
|
|
"Background color",
|
|
|
|
GDK_TYPE_RGBA, 0),
|
|
|
|
0,
|
|
|
|
NULL,
|
2011-12-31 22:20:44 +00:00
|
|
|
NULL,
|
2011-09-26 13:48:53 +00:00
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_unset (&value);
|
2011-05-21 02:17:28 +00:00
|
|
|
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_init (&value, G_TYPE_STRV);
|
|
|
|
g_value_set_boxed (&value, default_font_family);
|
2011-05-29 05:03:59 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("font-family",
|
|
|
|
"Font family",
|
|
|
|
"Font family",
|
|
|
|
G_TYPE_STRV, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
font_family_parse,
|
|
|
|
font_family_value_print,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_unset (&value);
|
2011-05-29 05:03:59 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_enum ("font-style",
|
|
|
|
"Font style",
|
|
|
|
"Font style",
|
|
|
|
PANGO_TYPE_STYLE,
|
|
|
|
PANGO_STYLE_NORMAL, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
_gtk_style_property_register (g_param_spec_enum ("font-variant",
|
|
|
|
"Font variant",
|
|
|
|
"Font variant",
|
|
|
|
PANGO_TYPE_VARIANT,
|
|
|
|
PANGO_VARIANT_NORMAL, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
/* xxx: need to parse this properly, ie parse the numbers */
|
|
|
|
_gtk_style_property_register (g_param_spec_enum ("font-weight",
|
|
|
|
"Font weight",
|
|
|
|
"Font weight",
|
|
|
|
PANGO_TYPE_WEIGHT,
|
|
|
|
PANGO_WEIGHT_NORMAL, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_init (&value, G_TYPE_DOUBLE);
|
|
|
|
g_value_set_double (&value, 10);
|
2011-05-29 05:03:59 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_double ("font-size",
|
|
|
|
"Font size",
|
|
|
|
"Font size",
|
|
|
|
0, G_MAXDOUBLE, 0, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_unset (&value);
|
2011-05-21 02:17:28 +00:00
|
|
|
|
2011-05-31 10:35:42 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("text-shadow",
|
|
|
|
"Text shadow",
|
|
|
|
"Text shadow",
|
|
|
|
GTK_TYPE_SHADOW, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2011-05-21 03:48:36 +00:00
|
|
|
|
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("icon-shadow",
|
|
|
|
"Icon shadow",
|
|
|
|
"Icon shadow",
|
|
|
|
GTK_TYPE_SHADOW, 0),
|
|
|
|
GTK_STYLE_PROPERTY_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2011-05-21 02:17:28 +00:00
|
|
|
|
2011-06-02 00:59:14 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_boxed ("box-shadow",
|
|
|
|
"Box shadow",
|
|
|
|
"Box shadow",
|
|
|
|
GTK_TYPE_SHADOW, 0));
|
2011-05-21 02:17:28 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
2011-05-22 03:55:12 +00:00
|
|
|
g_param_spec_int ("margin-top",
|
|
|
|
"margin top",
|
|
|
|
"Margin at top",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("margin-left",
|
|
|
|
"margin left",
|
|
|
|
"Margin at left",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("margin-bottom",
|
|
|
|
"margin bottom",
|
|
|
|
"Margin at bottom",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("margin-right",
|
|
|
|
"margin right",
|
|
|
|
"Margin at right",
|
|
|
|
0, G_MAXINT, 0, 0));
|
2011-05-21 02:17:28 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
2011-05-22 03:42:17 +00:00
|
|
|
g_param_spec_int ("padding-top",
|
|
|
|
"padding top",
|
|
|
|
"Padding at top",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("padding-left",
|
|
|
|
"padding left",
|
|
|
|
"Padding at left",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("padding-bottom",
|
|
|
|
"padding bottom",
|
|
|
|
"Padding at bottom",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("padding-right",
|
|
|
|
"padding right",
|
|
|
|
"Padding at right",
|
|
|
|
0, G_MAXINT, 0, 0));
|
2011-05-21 02:17:28 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
2011-05-21 22:10:43 +00:00
|
|
|
g_param_spec_int ("border-top-width",
|
|
|
|
"border top width",
|
|
|
|
"Border width at top",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("border-left-width",
|
|
|
|
"border left width",
|
|
|
|
"Border width at left",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("border-bottom-width",
|
|
|
|
"border bottom width",
|
|
|
|
"Border width at bottom",
|
|
|
|
0, G_MAXINT, 0, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_int ("border-right-width",
|
|
|
|
"border right width",
|
|
|
|
"Border width at right",
|
|
|
|
0, G_MAXINT, 0, 0));
|
2011-05-26 01:50:53 +00:00
|
|
|
|
2012-01-02 01:45:52 +00:00
|
|
|
g_value_init (&value, GTK_TYPE_CSS_BORDER_CORNER_RADIUS);
|
|
|
|
g_value_set_boxed (&value, &no_corner_radius);
|
2011-05-26 01:50:53 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-top-left-radius",
|
|
|
|
"Border top left radius",
|
|
|
|
"Border radius of top left corner, in pixels",
|
|
|
|
GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
|
2011-05-31 10:20:47 +00:00
|
|
|
0,
|
2011-05-26 01:50:53 +00:00
|
|
|
NULL,
|
|
|
|
border_corner_radius_value_parse,
|
2011-05-28 03:43:07 +00:00
|
|
|
border_corner_radius_value_print,
|
2012-01-02 01:45:52 +00:00
|
|
|
&value);
|
2011-05-26 01:50:53 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-top-right-radius",
|
|
|
|
"Border top right radius",
|
|
|
|
"Border radius of top right corner, in pixels",
|
|
|
|
GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
|
2011-05-31 10:20:47 +00:00
|
|
|
0,
|
2011-05-26 01:50:53 +00:00
|
|
|
NULL,
|
|
|
|
border_corner_radius_value_parse,
|
2011-05-28 03:43:07 +00:00
|
|
|
border_corner_radius_value_print,
|
2012-01-02 01:45:52 +00:00
|
|
|
&value);
|
2011-05-26 01:50:53 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-bottom-right-radius",
|
|
|
|
"Border bottom right radius",
|
|
|
|
"Border radius of bottom right corner, in pixels",
|
|
|
|
GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
|
2011-05-31 10:20:47 +00:00
|
|
|
0,
|
2011-05-26 01:50:53 +00:00
|
|
|
NULL,
|
|
|
|
border_corner_radius_value_parse,
|
2011-05-28 03:43:07 +00:00
|
|
|
border_corner_radius_value_print,
|
2012-01-02 01:45:52 +00:00
|
|
|
&value);
|
2011-05-26 01:50:53 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-bottom-left-radius",
|
|
|
|
"Border bottom left radius",
|
|
|
|
"Border radius of bottom left corner, in pixels",
|
|
|
|
GTK_TYPE_CSS_BORDER_CORNER_RADIUS, 0),
|
2011-05-31 10:20:47 +00:00
|
|
|
0,
|
2011-05-26 01:50:53 +00:00
|
|
|
NULL,
|
|
|
|
border_corner_radius_value_parse,
|
2011-05-28 03:43:07 +00:00
|
|
|
border_corner_radius_value_print,
|
2012-01-02 01:45:52 +00:00
|
|
|
&value);
|
|
|
|
g_value_unset (&value);
|
2011-05-26 01:50:53 +00:00
|
|
|
|
2011-05-21 02:17:28 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_enum ("border-style",
|
|
|
|
"Border style",
|
|
|
|
"Border style",
|
|
|
|
GTK_TYPE_BORDER_STYLE,
|
|
|
|
GTK_BORDER_STYLE_NONE, 0));
|
2011-11-24 20:00:57 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_enum ("background-clip",
|
|
|
|
"Background clip",
|
|
|
|
"Background clip",
|
|
|
|
GTK_TYPE_CSS_AREA,
|
|
|
|
GTK_CSS_AREA_BORDER_BOX, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_enum ("background-origin",
|
|
|
|
"Background origin",
|
|
|
|
"Background origin",
|
|
|
|
GTK_TYPE_CSS_AREA,
|
|
|
|
GTK_CSS_AREA_PADDING_BOX, 0));
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_init (&value, GTK_TYPE_CSS_SPECIAL_VALUE);
|
|
|
|
g_value_set_enum (&value, GTK_CSS_CURRENT_COLOR);
|
2011-06-13 01:45:18 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-top-color",
|
|
|
|
"Border top color",
|
|
|
|
"Border top color",
|
|
|
|
GDK_TYPE_RGBA, 0),
|
|
|
|
0,
|
|
|
|
NULL,
|
2011-12-31 22:20:44 +00:00
|
|
|
NULL,
|
2011-06-13 01:45:18 +00:00
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-06-13 01:45:18 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-right-color",
|
|
|
|
"Border right color",
|
|
|
|
"Border right color",
|
|
|
|
GDK_TYPE_RGBA, 0),
|
|
|
|
0,
|
|
|
|
NULL,
|
2011-12-31 22:20:44 +00:00
|
|
|
NULL,
|
2011-06-13 01:45:18 +00:00
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-06-13 01:45:18 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-bottom-color",
|
|
|
|
"Border bottom color",
|
|
|
|
"Border bottom color",
|
2011-06-12 23:50:06 +00:00
|
|
|
GDK_TYPE_RGBA, 0),
|
|
|
|
0,
|
|
|
|
NULL,
|
2011-12-31 22:20:44 +00:00
|
|
|
NULL,
|
2011-06-13 01:45:18 +00:00
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-06-13 01:45:18 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-left-color",
|
|
|
|
"Border left color",
|
|
|
|
"Border left color",
|
|
|
|
GDK_TYPE_RGBA, 0),
|
|
|
|
0,
|
|
|
|
NULL,
|
2011-12-31 22:20:44 +00:00
|
|
|
NULL,
|
2011-06-13 01:45:18 +00:00
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_unset (&value);
|
2011-06-12 23:50:06 +00:00
|
|
|
|
2011-05-21 02:17:28 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_boxed ("background-image",
|
|
|
|
"Background Image",
|
|
|
|
"Background Image",
|
|
|
|
CAIRO_GOBJECT_TYPE_PATTERN, 0));
|
2011-11-06 18:33:05 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_boxed ("background-repeat",
|
|
|
|
"Background repeat",
|
|
|
|
"Background repeat",
|
|
|
|
GTK_TYPE_CSS_BACKGROUND_REPEAT, 0));
|
|
|
|
|
2011-05-21 02:17:28 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
2011-05-26 19:54:38 +00:00
|
|
|
g_param_spec_boxed ("border-image-source",
|
|
|
|
"Border image source",
|
|
|
|
"Border image source",
|
|
|
|
CAIRO_GOBJECT_TYPE_PATTERN, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_boxed ("border-image-repeat",
|
|
|
|
"Border image repeat",
|
|
|
|
"Border image repeat",
|
2011-06-05 20:49:54 +00:00
|
|
|
GTK_TYPE_CSS_BORDER_IMAGE_REPEAT, 0));
|
2011-05-26 19:54:38 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_boxed ("border-image-slice",
|
|
|
|
"Border image slice",
|
|
|
|
"Border image slice",
|
|
|
|
GTK_TYPE_BORDER, 0));
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_init (&value, GTK_TYPE_BORDER);
|
2011-06-11 07:23:34 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("border-image-width",
|
2011-06-09 23:59:14 +00:00
|
|
|
"Border image width",
|
|
|
|
"Border image width",
|
2011-06-11 07:23:34 +00:00
|
|
|
GTK_TYPE_BORDER, 0),
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2011-12-31 14:50:56 +00:00
|
|
|
&value);
|
2011-12-29 01:28:32 +00:00
|
|
|
g_value_unset (&value);
|
2011-05-21 02:17:28 +00:00
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_object ("engine",
|
|
|
|
"Theming Engine",
|
|
|
|
"Theming Engine",
|
|
|
|
GTK_TYPE_THEMING_ENGINE, 0));
|
|
|
|
gtk_style_properties_register_property (NULL,
|
|
|
|
g_param_spec_boxed ("transition",
|
|
|
|
"Transition animation description",
|
|
|
|
"Transition animation description",
|
|
|
|
GTK_TYPE_ANIMATION_DESCRIPTION, 0));
|
|
|
|
|
|
|
|
/* Private property holding the binding sets */
|
2011-05-25 23:50:41 +00:00
|
|
|
_gtk_style_property_register (g_param_spec_boxed ("gtk-key-bindings",
|
2011-05-21 02:17:28 +00:00
|
|
|
"Key bindings",
|
|
|
|
"Key bindings",
|
2011-05-25 23:50:41 +00:00
|
|
|
G_TYPE_PTR_ARRAY, 0),
|
2011-05-31 10:20:47 +00:00
|
|
|
0,
|
2011-05-25 23:50:41 +00:00
|
|
|
NULL,
|
|
|
|
bindings_value_parse,
|
2011-05-28 03:43:07 +00:00
|
|
|
bindings_value_print,
|
|
|
|
NULL);
|
2011-12-31 14:05:09 +00:00
|
|
|
|
|
|
|
/* initialize shorthands last, they depend on the real properties existing */
|
|
|
|
_gtk_css_shorthand_property_init_properties ();
|
2011-05-21 02:17:28 +00:00
|
|
|
}
|
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
/**
|
|
|
|
* _gtk_style_property_lookup:
|
|
|
|
* @name: name of the property to lookup
|
|
|
|
*
|
|
|
|
* Looks up the CSS property with the given @name. If no such
|
|
|
|
* property exists, %NULL is returned.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): The property or %NULL if no
|
|
|
|
* property with the given name exists.
|
|
|
|
**/
|
2011-12-31 15:08:23 +00:00
|
|
|
GtkStyleProperty *
|
2011-05-21 02:17:28 +00:00
|
|
|
_gtk_style_property_lookup (const char *name)
|
|
|
|
{
|
2011-12-31 13:34:42 +00:00
|
|
|
GtkStylePropertyClass *klass;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
gtk_style_property_init_properties ();
|
|
|
|
|
|
|
|
klass = g_type_class_peek (GTK_TYPE_STYLE_PROPERTY);
|
|
|
|
|
|
|
|
return g_hash_table_lookup (klass->properties, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _gtk_style_property_get_name:
|
|
|
|
* @property: the property to query
|
|
|
|
*
|
|
|
|
* Gets the name of the given property.
|
|
|
|
*
|
|
|
|
* Returns: the name of the property
|
|
|
|
**/
|
|
|
|
const char *
|
|
|
|
_gtk_style_property_get_name (GtkStyleProperty *property)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_STYLE_PROPERTY (property), NULL);
|
2011-05-21 02:17:28 +00:00
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
return property->name;
|
2011-05-21 02:17:28 +00:00
|
|
|
}
|
|
|
|
|
2011-12-31 16:36:22 +00:00
|
|
|
/**
|
|
|
|
* _gtk_style_property_get_value_type:
|
|
|
|
* @property: the property to query
|
|
|
|
*
|
|
|
|
* Gets the value type of the @property, if the property is usable
|
|
|
|
* in public API via _gtk_style_property_assign() and
|
|
|
|
* _gtk_style_property_query(). If the @property is not usable in that
|
|
|
|
* way, %G_TYPE_NONE is returned.
|
|
|
|
*
|
|
|
|
* Returns: the value type in use or %G_TYPE_NONE if none.
|
|
|
|
**/
|
|
|
|
GType
|
|
|
|
_gtk_style_property_get_value_type (GtkStyleProperty *property)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_STYLE_PROPERTY (property), G_TYPE_NONE);
|
|
|
|
|
|
|
|
return property->value_type;
|
|
|
|
}
|
|
|
|
|
2011-12-31 13:34:42 +00:00
|
|
|
|
2011-05-21 02:17:28 +00:00
|
|
|
void
|
2011-05-28 03:43:07 +00:00
|
|
|
_gtk_style_property_register (GParamSpec *pspec,
|
2011-05-31 10:20:47 +00:00
|
|
|
GtkStylePropertyFlags flags,
|
2011-05-28 03:43:07 +00:00
|
|
|
GtkStylePropertyParser property_parse_func,
|
|
|
|
GtkStyleParseFunc parse_func,
|
|
|
|
GtkStylePrintFunc print_func,
|
2011-12-31 14:50:56 +00:00
|
|
|
const GValue * initial_value)
|
2011-05-21 02:17:28 +00:00
|
|
|
{
|
|
|
|
GtkStyleProperty *node;
|
2011-12-31 18:59:16 +00:00
|
|
|
GValue initial_fallback = { 0, };
|
2011-05-21 02:17:28 +00:00
|
|
|
|
2011-12-31 18:59:16 +00:00
|
|
|
if (initial_value == NULL)
|
2011-12-31 14:50:56 +00:00
|
|
|
{
|
2011-12-31 18:59:16 +00:00
|
|
|
g_value_init (&initial_fallback, pspec->value_type);
|
2011-12-31 14:50:56 +00:00
|
|
|
if (pspec->value_type == GTK_TYPE_THEMING_ENGINE)
|
2011-12-31 18:59:16 +00:00
|
|
|
g_value_set_object (&initial_fallback, gtk_theming_engine_load (NULL));
|
2011-12-31 14:50:56 +00:00
|
|
|
else if (pspec->value_type == PANGO_TYPE_FONT_DESCRIPTION)
|
2011-12-31 18:59:16 +00:00
|
|
|
g_value_take_boxed (&initial_fallback, pango_font_description_from_string ("Sans 10"));
|
2011-12-31 14:50:56 +00:00
|
|
|
else if (pspec->value_type == GDK_TYPE_RGBA)
|
2011-12-29 01:28:32 +00:00
|
|
|
{
|
2011-12-31 14:50:56 +00:00
|
|
|
GdkRGBA color;
|
|
|
|
gdk_rgba_parse (&color, "pink");
|
2011-12-31 18:59:16 +00:00
|
|
|
g_value_set_boxed (&initial_fallback, &color);
|
2011-12-29 01:28:32 +00:00
|
|
|
}
|
2011-12-31 14:50:56 +00:00
|
|
|
else if (pspec->value_type == GTK_TYPE_BORDER)
|
2011-12-29 01:28:32 +00:00
|
|
|
{
|
2011-12-31 18:59:16 +00:00
|
|
|
g_value_take_boxed (&initial_fallback, gtk_border_new ());
|
2011-12-29 01:28:32 +00:00
|
|
|
}
|
2011-12-31 14:50:56 +00:00
|
|
|
else
|
2011-12-31 18:59:16 +00:00
|
|
|
g_param_value_set_default (pspec, &initial_fallback);
|
|
|
|
|
|
|
|
initial_value = &initial_fallback;
|
2011-12-29 01:28:32 +00:00
|
|
|
}
|
2011-12-31 18:59:16 +00:00
|
|
|
|
|
|
|
node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
|
|
|
|
"inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
|
|
|
|
"initial-value", initial_value,
|
|
|
|
"name", pspec->name,
|
|
|
|
"value-type", pspec->value_type,
|
|
|
|
NULL);
|
2012-01-01 20:58:45 +00:00
|
|
|
g_assert (node->value_type == pspec->value_type);
|
2012-01-01 23:28:56 +00:00
|
|
|
GTK_CSS_STYLE_PROPERTY (node)->pspec = pspec;
|
2011-12-31 18:59:16 +00:00
|
|
|
node->property_parse_func = property_parse_func;
|
|
|
|
node->parse_func = parse_func;
|
|
|
|
node->print_func = print_func;
|
|
|
|
|
|
|
|
if (G_IS_VALUE (&initial_fallback))
|
|
|
|
g_value_unset (&initial_fallback);
|
2011-05-21 02:17:28 +00:00
|
|
|
}
|