1 | /* |
2 | * Copyright © 2019 Benjamin Otte |
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.1 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 | * Authors: Benjamin Otte <otte@gnome.org> |
18 | */ |
19 | |
20 | |
21 | #ifndef __GTK_EXPRESSION_H__ |
22 | #define __GTK_EXPRESSION_H__ |
23 | |
24 | #include <gtk/gtktypes.h> |
25 | |
26 | G_BEGIN_DECLS |
27 | |
28 | #define GTK_TYPE_EXPRESSION (gtk_expression_get_type ()) |
29 | #define GTK_TYPE_EXPRESSION_WATCH (gtk_expression_watch_get_type()) |
30 | |
31 | #define GTK_IS_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXPRESSION)) |
32 | #define GTK_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXPRESSION, GtkExpression)) |
33 | |
34 | typedef struct _GtkExpression GtkExpression; |
35 | typedef struct _GtkExpressionWatch GtkExpressionWatch; |
36 | |
37 | /** |
38 | * GtkExpressionNotify: |
39 | * @user_data: data passed to gtk_expression_watch() |
40 | * |
41 | * Callback called by gtk_expression_watch() when the |
42 | * expression value changes. |
43 | */ |
44 | typedef void (* GtkExpressionNotify) (gpointer user_data); |
45 | |
46 | GDK_AVAILABLE_IN_ALL |
47 | GType gtk_expression_get_type (void) G_GNUC_CONST; |
48 | |
49 | GDK_AVAILABLE_IN_ALL |
50 | GtkExpression * gtk_expression_ref (GtkExpression *self); |
51 | GDK_AVAILABLE_IN_ALL |
52 | void gtk_expression_unref (GtkExpression *self); |
53 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkExpression, gtk_expression_unref) |
54 | |
55 | GDK_AVAILABLE_IN_ALL |
56 | GType gtk_expression_get_value_type (GtkExpression *self); |
57 | GDK_AVAILABLE_IN_ALL |
58 | gboolean gtk_expression_is_static (GtkExpression *self); |
59 | GDK_AVAILABLE_IN_ALL |
60 | gboolean gtk_expression_evaluate (GtkExpression *self, |
61 | gpointer this_, |
62 | GValue *value); |
63 | GDK_AVAILABLE_IN_ALL |
64 | GtkExpressionWatch * gtk_expression_watch (GtkExpression *self, |
65 | gpointer this_, |
66 | GtkExpressionNotify notify, |
67 | gpointer user_data, |
68 | GDestroyNotify user_destroy); |
69 | GDK_AVAILABLE_IN_ALL |
70 | GtkExpressionWatch * gtk_expression_bind (GtkExpression *self, |
71 | gpointer target, |
72 | const char * property, |
73 | gpointer this_); |
74 | |
75 | GDK_AVAILABLE_IN_4_2 |
76 | GType gtk_expression_watch_get_type (void) G_GNUC_CONST; |
77 | GDK_AVAILABLE_IN_ALL |
78 | GtkExpressionWatch * gtk_expression_watch_ref (GtkExpressionWatch *watch); |
79 | GDK_AVAILABLE_IN_ALL |
80 | void gtk_expression_watch_unref (GtkExpressionWatch *watch); |
81 | GDK_AVAILABLE_IN_ALL |
82 | gboolean gtk_expression_watch_evaluate (GtkExpressionWatch *watch, |
83 | GValue *value); |
84 | GDK_AVAILABLE_IN_ALL |
85 | void gtk_expression_watch_unwatch (GtkExpressionWatch *watch); |
86 | |
87 | #define GTK_TYPE_PROPERTY_EXPRESSION (gtk_property_expression_get_type()) |
88 | typedef struct _GtkPropertyExpression GtkPropertyExpression; |
89 | |
90 | GDK_AVAILABLE_IN_ALL |
91 | GType gtk_property_expression_get_type (void) G_GNUC_CONST; |
92 | |
93 | GDK_AVAILABLE_IN_ALL |
94 | GtkExpression * gtk_property_expression_new (GType this_type, |
95 | GtkExpression *expression, |
96 | const char *property_name); |
97 | GDK_AVAILABLE_IN_ALL |
98 | GtkExpression * gtk_property_expression_new_for_pspec (GtkExpression *expression, |
99 | GParamSpec *pspec); |
100 | |
101 | GDK_AVAILABLE_IN_ALL |
102 | GtkExpression * gtk_property_expression_get_expression (GtkExpression *expression); |
103 | GDK_AVAILABLE_IN_ALL |
104 | GParamSpec * gtk_property_expression_get_pspec (GtkExpression *expression); |
105 | |
106 | #define GTK_TYPE_CONSTANT_EXPRESSION (gtk_constant_expression_get_type()) |
107 | typedef struct _GtkConstantExpression GtkConstantExpression; |
108 | |
109 | GDK_AVAILABLE_IN_ALL |
110 | GType gtk_constant_expression_get_type (void) G_GNUC_CONST; |
111 | |
112 | GDK_AVAILABLE_IN_ALL |
113 | GtkExpression * gtk_constant_expression_new (GType value_type, |
114 | ...); |
115 | GDK_AVAILABLE_IN_ALL |
116 | GtkExpression * gtk_constant_expression_new_for_value (const GValue *value); |
117 | |
118 | GDK_AVAILABLE_IN_ALL |
119 | const GValue * gtk_constant_expression_get_value (GtkExpression *expression); |
120 | |
121 | #define GTK_TYPE_OBJECT_EXPRESSION (gtk_object_expression_get_type()) |
122 | typedef struct _GtkObjectExpression GtkObjectExpression; |
123 | |
124 | GDK_AVAILABLE_IN_ALL |
125 | GType gtk_object_expression_get_type (void) G_GNUC_CONST; |
126 | |
127 | GDK_AVAILABLE_IN_ALL |
128 | GtkExpression * gtk_object_expression_new (GObject *object); |
129 | |
130 | GDK_AVAILABLE_IN_ALL |
131 | GObject * gtk_object_expression_get_object (GtkExpression *expression); |
132 | |
133 | #define GTK_TYPE_CLOSURE_EXPRESSION (gtk_closure_expression_get_type()) |
134 | typedef struct _GtkClosureExpression GtkClosureExpression; |
135 | |
136 | GDK_AVAILABLE_IN_ALL |
137 | GType gtk_closure_expression_get_type (void) G_GNUC_CONST; |
138 | |
139 | GDK_AVAILABLE_IN_ALL |
140 | GtkExpression * gtk_closure_expression_new (GType value_type, |
141 | GClosure *closure, |
142 | guint n_params, |
143 | GtkExpression **params); |
144 | |
145 | #define GTK_TYPE_CCLOSURE_EXPRESSION (gtk_cclosure_expression_get_type()) |
146 | typedef struct _GtkCClosureExpression GtkCClosureExpression; |
147 | |
148 | GDK_AVAILABLE_IN_ALL |
149 | GType gtk_cclosure_expression_get_type (void) G_GNUC_CONST; |
150 | |
151 | GDK_AVAILABLE_IN_ALL |
152 | GtkExpression * gtk_cclosure_expression_new (GType value_type, |
153 | GClosureMarshal marshal, |
154 | guint n_params, |
155 | GtkExpression **params, |
156 | GCallback callback_func, |
157 | gpointer user_data, |
158 | GClosureNotify user_destroy); |
159 | |
160 | /* GObject integration, so we can use GtkBuilder */ |
161 | |
162 | /** |
163 | * GTK_VALUE_HOLDS_EXPRESSION: |
164 | * @value: a `GValue` |
165 | * |
166 | * Evaluates to %TRUE if @value was initialized with %GTK_TYPE_EXPRESSION. |
167 | */ |
168 | #define GTK_VALUE_HOLDS_EXPRESSION(value) (G_VALUE_HOLDS ((value), GTK_TYPE_EXPRESSION)) |
169 | |
170 | GDK_AVAILABLE_IN_ALL |
171 | void gtk_value_set_expression (GValue *value, |
172 | GtkExpression *expression); |
173 | GDK_AVAILABLE_IN_ALL |
174 | void gtk_value_take_expression (GValue *value, |
175 | GtkExpression *expression); |
176 | GDK_AVAILABLE_IN_ALL |
177 | GtkExpression * gtk_value_get_expression (const GValue *value); |
178 | GDK_AVAILABLE_IN_ALL |
179 | GtkExpression * gtk_value_dup_expression (const GValue *value); |
180 | |
181 | #define GTK_TYPE_PARAM_SPEC_EXPRESSION (gtk_param_expression_get_type()) |
182 | #define GTK_PARAM_SPEC_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PARAM_SPEC_EXPRESSION, GtkParamSpecExpression)) |
183 | #define GTK_IS_PARAM_SPEC_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PARAM_SPEC_EXPRESSION)) |
184 | |
185 | /** |
186 | * GtkParamSpecExpression: |
187 | * |
188 | * A `GParamSpec` for properties holding a `GtkExpression`. |
189 | */ |
190 | typedef struct { |
191 | /*< private >*/ |
192 | GParamSpec parent_instance; |
193 | } GtkParamSpecExpression; |
194 | |
195 | GDK_AVAILABLE_IN_ALL |
196 | GType gtk_param_expression_get_type (void) G_GNUC_CONST; |
197 | GDK_AVAILABLE_IN_ALL |
198 | GParamSpec * gtk_param_spec_expression (const char *name, |
199 | const char *nick, |
200 | const char *blurb, |
201 | GParamFlags flags); |
202 | |
203 | G_END_DECLS |
204 | |
205 | #endif /* __GTK_EXPRESSION_H__ */ |
206 | |