2012-03-06 13:16:08 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 2011 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gtkcssvalueprivate.h"
|
2012-03-26 04:46:29 +00:00
|
|
|
#include "gtkcssstylefuncsprivate.h"
|
2012-03-06 13:16:08 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
|
|
|
#include "gtkgradient.h"
|
|
|
|
#include <cairo-gobject.h>
|
|
|
|
#include "gtkprivatetypebuiltins.h"
|
|
|
|
|
2012-03-08 10:01:22 +00:00
|
|
|
#include "fallback-c89.c"
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
struct _GtkCssValue
|
|
|
|
{
|
2012-03-26 04:13:57 +00:00
|
|
|
GTK_CSS_VALUE_BASE
|
2012-03-08 15:20:03 +00:00
|
|
|
GType type;
|
|
|
|
union {
|
|
|
|
gpointer ptr;
|
|
|
|
gint gint;
|
2012-03-08 15:49:13 +00:00
|
|
|
guint guint;
|
2012-03-08 15:20:03 +00:00
|
|
|
double dbl;
|
2012-03-08 15:49:13 +00:00
|
|
|
float flt;
|
2012-03-08 15:20:03 +00:00
|
|
|
} u;
|
2012-03-06 13:16:08 +00:00
|
|
|
};
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
static void
|
|
|
|
gtk_css_value_default_free (GtkCssValue *value)
|
|
|
|
{
|
|
|
|
GType type = value->type;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, G_TYPE_OBJECT))
|
|
|
|
{
|
|
|
|
if (value->u.ptr != NULL)
|
|
|
|
g_object_unref (value->u.ptr);
|
|
|
|
}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_BOXED))
|
|
|
|
{
|
|
|
|
if (value->u.ptr != NULL)
|
|
|
|
g_boxed_free (type, value->u.ptr);
|
|
|
|
}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_STRING))
|
|
|
|
g_free (value->u.ptr);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_INT))
|
|
|
|
{}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_UINT))
|
|
|
|
{}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_BOOLEAN))
|
|
|
|
{}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_ENUM))
|
|
|
|
{}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_FLAGS))
|
|
|
|
{}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_DOUBLE))
|
|
|
|
{}
|
|
|
|
else if (g_type_is_a (type, G_TYPE_FLOAT))
|
|
|
|
{}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_value_unset (value->u.ptr);
|
|
|
|
g_slice_free (GValue, value->u.ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slice_free (GtkCssValue, value);
|
|
|
|
}
|
|
|
|
|
cssvalue: Add _gtk_css_value_equal()
For now, we return FALSE for all default css values, so this is not very
useful.
I also think of this as an optimization equal, not a guaranteed equal,
because we don't even have a notion of what "equal" means.
For example, for background-repeat, "repeat, repeat" and "repeat"
are functionally equivalent. But the cssvalue has no idea that it's used
for background-repeat.
As a more complicated example, "repeat, no-repeat" and "repeat" are
equal to what one sees as long as there's only one image listed
background-image-source. But once you start transition'ing to an image
with 2 sources, it's different...
2012-03-26 23:43:12 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_css_value_default_equal (const GtkCssValue *value1,
|
|
|
|
const GtkCssValue *value2)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-03-30 15:47:26 +00:00
|
|
|
static GtkCssValue *
|
|
|
|
gtk_css_value_default_transition (GtkCssValue *start,
|
|
|
|
GtkCssValue *end,
|
|
|
|
double progress)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-26 04:46:29 +00:00
|
|
|
static void
|
|
|
|
gtk_css_value_default_print (const GtkCssValue *value,
|
|
|
|
GString *string)
|
|
|
|
{
|
|
|
|
GValue g_value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
_gtk_css_value_init_gvalue (value, &g_value);
|
|
|
|
_gtk_css_style_print_value (&g_value, string);
|
|
|
|
g_value_unset (&g_value);
|
|
|
|
}
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
static const GtkCssValueClass GTK_CSS_VALUE_DEFAULT = {
|
2012-03-26 04:46:29 +00:00
|
|
|
gtk_css_value_default_free,
|
cssvalue: Add _gtk_css_value_equal()
For now, we return FALSE for all default css values, so this is not very
useful.
I also think of this as an optimization equal, not a guaranteed equal,
because we don't even have a notion of what "equal" means.
For example, for background-repeat, "repeat, repeat" and "repeat"
are functionally equivalent. But the cssvalue has no idea that it's used
for background-repeat.
As a more complicated example, "repeat, no-repeat" and "repeat" are
equal to what one sees as long as there's only one image listed
background-image-source. But once you start transition'ing to an image
with 2 sources, it's different...
2012-03-26 23:43:12 +00:00
|
|
|
gtk_css_value_default_equal,
|
2012-03-30 15:47:26 +00:00
|
|
|
gtk_css_value_default_transition,
|
2012-03-26 04:46:29 +00:00
|
|
|
gtk_css_value_default_print
|
2012-03-26 04:13:57 +00:00
|
|
|
};
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
G_DEFINE_BOXED_TYPE (GtkCssValue, _gtk_css_value, _gtk_css_value_ref, _gtk_css_value_unref)
|
|
|
|
|
|
|
|
static GtkCssValue *
|
2012-03-26 04:13:57 +00:00
|
|
|
gtk_css_value_new (GType type)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_DEFAULT);
|
2012-03-06 13:16:08 +00:00
|
|
|
|
2012-03-08 15:20:03 +00:00
|
|
|
value->type = type;
|
2012-03-06 13:16:08 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_from_gvalue (const GValue *g_value)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
2012-03-08 10:01:22 +00:00
|
|
|
GType type;
|
2012-03-06 13:16:08 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (g_value != NULL, NULL);
|
|
|
|
|
2012-03-08 10:01:22 +00:00
|
|
|
type = G_VALUE_TYPE (g_value);
|
2012-03-06 13:16:08 +00:00
|
|
|
|
2012-03-08 10:01:22 +00:00
|
|
|
/* Make sure we reuse the int/number singletons */
|
|
|
|
if (type == G_TYPE_INT)
|
|
|
|
value = _gtk_css_value_new_from_int (g_value_get_int (g_value));
|
|
|
|
else
|
|
|
|
{
|
2012-03-26 04:13:57 +00:00
|
|
|
value = gtk_css_value_new (type);
|
2012-03-08 15:20:03 +00:00
|
|
|
|
|
|
|
if (g_type_is_a (type, G_TYPE_OBJECT))
|
|
|
|
value->u.ptr = g_value_dup_object (g_value);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_BOXED))
|
|
|
|
value->u.ptr = g_value_dup_boxed (g_value);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_INT))
|
|
|
|
value->u.gint = g_value_get_int (g_value);
|
2012-03-08 15:49:13 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_UINT))
|
|
|
|
value->u.guint = g_value_get_uint (g_value);
|
2012-03-08 15:20:03 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_BOOLEAN))
|
|
|
|
value->u.gint = g_value_get_boolean (g_value);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_ENUM))
|
|
|
|
value->u.gint = g_value_get_enum (g_value);
|
2012-03-08 15:49:13 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_FLAGS))
|
|
|
|
value->u.guint = g_value_get_flags (g_value);
|
2012-03-08 15:20:03 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_STRING))
|
|
|
|
value->u.ptr = g_value_dup_string (g_value);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_DOUBLE))
|
|
|
|
value->u.dbl = g_value_get_double (g_value);
|
2012-03-08 15:49:13 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_FLOAT))
|
|
|
|
value->u.flt = g_value_get_float (g_value);
|
2012-03-08 15:20:03 +00:00
|
|
|
else
|
2012-04-09 00:51:07 +00:00
|
|
|
{
|
|
|
|
value->u.ptr = g_slice_new0 (GValue);
|
|
|
|
g_value_init (value->u.ptr, G_VALUE_TYPE (g_value));
|
|
|
|
g_value_copy (g_value, value->u.ptr);
|
|
|
|
}
|
2012-03-08 10:01:22 +00:00
|
|
|
}
|
2012-03-06 13:16:08 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_from_int (gint val)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
2012-03-08 10:01:22 +00:00
|
|
|
static GtkCssValue *singletons[4] = {NULL};
|
|
|
|
|
|
|
|
if (val >= 0 && val < G_N_ELEMENTS (singletons))
|
|
|
|
{
|
|
|
|
if (singletons[val] == NULL)
|
|
|
|
{
|
2012-03-26 04:13:57 +00:00
|
|
|
value = gtk_css_value_new (G_TYPE_INT);
|
2012-03-08 15:20:03 +00:00
|
|
|
value->u.gint = val;
|
2012-03-08 10:01:22 +00:00
|
|
|
singletons[val] = value;
|
|
|
|
}
|
|
|
|
return _gtk_css_value_ref (singletons[val]);
|
|
|
|
}
|
2012-03-06 13:16:08 +00:00
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
value = gtk_css_value_new (G_TYPE_INT);
|
2012-03-08 15:20:03 +00:00
|
|
|
value->u.gint = val;
|
2012-03-06 13:16:08 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-26 15:24:02 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_from_enum (GType type,
|
|
|
|
gint val)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_type_is_a (type, G_TYPE_ENUM), NULL);
|
|
|
|
|
|
|
|
value = gtk_css_value_new (type);
|
|
|
|
value->u.gint = val;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_take_strv (char **strv)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
|
|
|
value = gtk_css_value_new (G_TYPE_STRV);
|
|
|
|
value->u.ptr = strv;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-08 15:20:03 +00:00
|
|
|
static gpointer
|
|
|
|
g_boxed_copy0 (GType boxed_type,
|
|
|
|
gconstpointer src_boxed)
|
|
|
|
{
|
|
|
|
if (src_boxed == NULL)
|
|
|
|
return NULL;
|
|
|
|
return g_boxed_copy (boxed_type, src_boxed);
|
|
|
|
}
|
|
|
|
|
2012-03-27 02:58:15 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_from_boxed (GType type,
|
|
|
|
gpointer boxed)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_type_is_a (type, G_TYPE_BOXED), NULL);
|
|
|
|
|
|
|
|
value = gtk_css_value_new (type);
|
|
|
|
value->u.ptr = g_boxed_copy0 (type, boxed);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_take_pattern (cairo_pattern_t *v)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
value = gtk_css_value_new (CAIRO_GOBJECT_TYPE_PATTERN);
|
2012-03-08 15:20:03 +00:00
|
|
|
value->u.ptr = v;
|
2012-03-06 13:16:08 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-26 15:24:02 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_take_binding_sets (GPtrArray *array)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
|
|
|
value = gtk_css_value_new (G_TYPE_PTR_ARRAY);
|
|
|
|
value->u.ptr = array;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_from_color (const GdkColor *v)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
value = gtk_css_value_new (GDK_TYPE_COLOR);
|
2012-03-08 15:20:03 +00:00
|
|
|
value->u.ptr = g_boxed_copy0 (GDK_TYPE_COLOR, v);
|
2012-03-06 13:16:08 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-26 15:24:02 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_from_border_style (GtkBorderStyle style)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
|
|
|
value = gtk_css_value_new (GTK_TYPE_BORDER_STYLE);
|
|
|
|
value->u.gint = style;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_new_take_symbolic_color (GtkSymbolicColor *v)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
value = gtk_css_value_new (GTK_TYPE_SYMBOLIC_COLOR);
|
2012-03-08 15:20:03 +00:00
|
|
|
value->u.ptr = v;
|
2012-03-06 13:16:08 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_alloc (const GtkCssValueClass *klass,
|
|
|
|
gsize size)
|
|
|
|
{
|
|
|
|
GtkCssValue *value;
|
|
|
|
|
|
|
|
value = g_slice_alloc0 (size);
|
|
|
|
|
|
|
|
value->class = klass;
|
|
|
|
value->ref_count = 1;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_ref (GtkCssValue *value)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (value != NULL, NULL);
|
|
|
|
|
|
|
|
g_atomic_int_add (&value->ref_count, 1);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_gtk_css_value_unref (GtkCssValue *value)
|
|
|
|
{
|
|
|
|
if (value == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!g_atomic_int_dec_and_test (&value->ref_count))
|
|
|
|
return;
|
|
|
|
|
2012-03-26 04:13:57 +00:00
|
|
|
value->class->free (value);
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
cssvalue: Add _gtk_css_value_equal()
For now, we return FALSE for all default css values, so this is not very
useful.
I also think of this as an optimization equal, not a guaranteed equal,
because we don't even have a notion of what "equal" means.
For example, for background-repeat, "repeat, repeat" and "repeat"
are functionally equivalent. But the cssvalue has no idea that it's used
for background-repeat.
As a more complicated example, "repeat, no-repeat" and "repeat" are
equal to what one sees as long as there's only one image listed
background-image-source. But once you start transition'ing to an image
with 2 sources, it's different...
2012-03-26 23:43:12 +00:00
|
|
|
gboolean
|
|
|
|
_gtk_css_value_equal (const GtkCssValue *value1,
|
|
|
|
const GtkCssValue *value2)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (value1 != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (value2 != NULL, FALSE);
|
|
|
|
|
|
|
|
if (value1->class != value2->class)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return value1->class->equal (value1, value2);
|
|
|
|
}
|
|
|
|
|
2012-04-04 14:15:41 +00:00
|
|
|
gboolean
|
|
|
|
_gtk_css_value_equal0 (const GtkCssValue *value1,
|
|
|
|
const GtkCssValue *value2)
|
|
|
|
{
|
|
|
|
if (value1 == NULL && value2 == NULL)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (value1 == NULL || value2 == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return _gtk_css_value_equal (value1, value2);
|
|
|
|
}
|
|
|
|
|
2012-03-30 15:47:26 +00:00
|
|
|
GtkCssValue *
|
|
|
|
_gtk_css_value_transition (GtkCssValue *start,
|
|
|
|
GtkCssValue *end,
|
|
|
|
double progress)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (start != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (end != NULL, FALSE);
|
|
|
|
|
|
|
|
if (start->class != end->class)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return start->class->transition (start, end, progress);
|
|
|
|
}
|
|
|
|
|
2012-04-01 05:28:35 +00:00
|
|
|
char *
|
|
|
|
_gtk_css_value_to_string (const GtkCssValue *value)
|
|
|
|
{
|
|
|
|
GString *string;
|
|
|
|
|
|
|
|
g_return_val_if_fail (value != NULL, NULL);
|
|
|
|
|
|
|
|
string = g_string_new (NULL);
|
|
|
|
_gtk_css_value_print (value, string);
|
|
|
|
return g_string_free (string, FALSE);
|
|
|
|
}
|
|
|
|
|
2012-03-26 04:46:29 +00:00
|
|
|
void
|
|
|
|
_gtk_css_value_print (const GtkCssValue *value,
|
|
|
|
GString *string)
|
|
|
|
{
|
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
g_return_if_fail (string != NULL);
|
|
|
|
|
|
|
|
value->class->print (value, string);
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
GType
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_content_type (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
2012-03-28 04:28:13 +00:00
|
|
|
g_return_val_if_fail (value->class == >K_CSS_VALUE_DEFAULT, G_TYPE_NONE);
|
|
|
|
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->type;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_holds (const GtkCssValue *value, GType type)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
2012-03-28 04:28:13 +00:00
|
|
|
g_return_val_if_fail (value->class == >K_CSS_VALUE_DEFAULT, FALSE);
|
|
|
|
|
2012-03-08 15:20:03 +00:00
|
|
|
return g_type_is_a (value->type, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-03-26 04:46:29 +00:00
|
|
|
fill_gvalue (const GtkCssValue *value,
|
|
|
|
GValue *g_value)
|
2012-03-08 15:20:03 +00:00
|
|
|
{
|
|
|
|
GType type;
|
|
|
|
|
|
|
|
type = value->type;
|
|
|
|
|
|
|
|
if (g_type_is_a (type, G_TYPE_OBJECT))
|
|
|
|
g_value_set_object (g_value, value->u.ptr);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_BOXED))
|
|
|
|
g_value_set_boxed (g_value, value->u.ptr);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_INT))
|
|
|
|
g_value_set_int (g_value, value->u.gint);
|
2012-03-08 15:49:13 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_UINT))
|
|
|
|
g_value_set_uint (g_value, value->u.guint);
|
2012-03-08 15:20:03 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_BOOLEAN))
|
|
|
|
g_value_set_boolean (g_value, value->u.gint);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_ENUM))
|
|
|
|
g_value_set_enum (g_value, value->u.gint);
|
2012-03-08 15:49:13 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_FLAGS))
|
|
|
|
g_value_set_flags (g_value, value->u.guint);
|
2012-03-08 15:20:03 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_STRING))
|
|
|
|
g_value_set_string (g_value, value->u.ptr);
|
|
|
|
else if (g_type_is_a (type, G_TYPE_DOUBLE))
|
|
|
|
g_value_set_double (g_value, value->u.dbl);
|
2012-03-08 15:49:13 +00:00
|
|
|
else if (g_type_is_a (type, G_TYPE_FLOAT))
|
|
|
|
g_value_set_float (g_value, value->u.flt);
|
2012-03-08 15:20:03 +00:00
|
|
|
else
|
2012-04-09 00:51:07 +00:00
|
|
|
g_value_copy (value->u.ptr, g_value);
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_init_gvalue (const GtkCssValue *value,
|
|
|
|
GValue *g_value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
if (value != NULL)
|
|
|
|
{
|
2012-03-28 04:28:13 +00:00
|
|
|
g_return_if_fail (value->class == >K_CSS_VALUE_DEFAULT);
|
2012-03-08 15:20:03 +00:00
|
|
|
g_value_init (g_value, value->type);
|
|
|
|
fill_gvalue (value, g_value);
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkSymbolicColor *
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_symbolic_color (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_SYMBOLIC_COLOR), NULL);
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->u.ptr;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_int (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_INT), 0);
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->u.gint;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 04:46:29 +00:00
|
|
|
int
|
|
|
|
_gtk_css_value_get_enum (const GtkCssValue *value)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_ENUM), 0);
|
|
|
|
return value->u.gint;
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:16:08 +00:00
|
|
|
gpointer
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_dup_object (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_OBJECT), NULL);
|
2012-03-08 15:20:03 +00:00
|
|
|
if (value->u.ptr)
|
|
|
|
return g_object_ref (value->u.ptr);
|
|
|
|
return NULL;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gpointer
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_object (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_OBJECT), NULL);
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->u.ptr;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gpointer
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_boxed (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_BOXED), NULL);
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->u.ptr;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char **
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_strv (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, G_TYPE_STRV), NULL);
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->u.ptr;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkBorderStyle
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_border_style (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_BORDER_STYLE), 0);
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->u.gint;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkGradient *
|
2012-03-26 04:46:29 +00:00
|
|
|
_gtk_css_value_get_gradient (const GtkCssValue *value)
|
2012-03-06 13:16:08 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (_gtk_css_value_holds (value, GTK_TYPE_GRADIENT), NULL);
|
2012-03-08 15:20:03 +00:00
|
|
|
return value->u.ptr;
|
2012-03-06 13:16:08 +00:00
|
|
|
}
|
|
|
|
|