]> Pileus Git - ~andy/gtk/blob - gtk/gtkcsstypedvalue.c
Updated Serbian translation
[~andy/gtk] / gtk / gtkcsstypedvalue.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2011 Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "config.h"
19
20 #include "gtkcsstypedvalueprivate.h"
21
22 #include "gtkcssstylefuncsprivate.h"
23
24 struct _GtkCssValue {
25   GTK_CSS_VALUE_BASE
26   GValue value;
27 };
28
29 static void
30 gtk_css_value_typed_free (GtkCssValue *value)
31 {
32   g_value_unset (&value->value);
33   g_slice_free (GtkCssValue, value);
34 }
35
36 static gboolean
37 gtk_css_value_typed_equal (const GtkCssValue *value1,
38                            const GtkCssValue *value2)
39 {
40   return FALSE;
41 }
42
43 static GtkCssValue *
44 gtk_css_value_typed_transition (GtkCssValue *start,
45                                 GtkCssValue *end,
46                                 double       progress)
47 {
48   return NULL;
49 }
50
51 static void
52 gtk_css_value_typed_print (const GtkCssValue *value,
53                            GString           *string)
54 {
55   _gtk_css_style_print_value (&value->value, string);
56 }
57
58 static const GtkCssValueClass GTK_CSS_VALUE_TYPED = {
59   gtk_css_value_typed_free,
60   gtk_css_value_typed_equal,
61   gtk_css_value_typed_transition,
62   gtk_css_value_typed_print
63 };
64
65 static GtkCssValue *
66 gtk_css_typed_value_new_for_type (GType type)
67 {
68   GtkCssValue *result;
69
70   result = _gtk_css_value_new (GtkCssValue, &GTK_CSS_VALUE_TYPED);
71
72   g_value_init (&result->value, type);
73
74   return result;
75 }
76
77 GtkCssValue *
78 _gtk_css_typed_value_new (const GValue *value)
79 {
80   GtkCssValue *result;
81
82   g_return_val_if_fail (G_IS_VALUE (value), NULL);
83
84   result = gtk_css_typed_value_new_for_type (G_VALUE_TYPE (value));
85
86   g_value_copy (value, &result->value);
87
88   return result;
89 }
90
91 GtkCssValue *
92 _gtk_css_typed_value_new_take (GValue *value)
93 {
94   GtkCssValue *result;
95
96   g_return_val_if_fail (G_IS_VALUE (value), NULL);
97
98   result = _gtk_css_typed_value_new (value);
99   g_value_unset (value);
100
101   return result;
102 }
103
104 gboolean
105 _gtk_is_css_typed_value_of_type (const GtkCssValue *value,
106                                  GType              type)
107 {
108   if (value->class != &GTK_CSS_VALUE_TYPED)
109     return FALSE;
110
111   return G_VALUE_HOLDS (&value->value, type);
112 }
113
114 const GValue *
115 _gtk_css_typed_value_get (const GtkCssValue *value)
116 {
117   g_return_val_if_fail (value->class == &GTK_CSS_VALUE_TYPED, NULL);
118
119   return &value->value;
120 }