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
26G_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
34typedef struct _GtkExpression GtkExpression;
35typedef 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 */
44typedef void (* GtkExpressionNotify) (gpointer user_data);
45
46GDK_AVAILABLE_IN_ALL
47GType gtk_expression_get_type (void) G_GNUC_CONST;
48
49GDK_AVAILABLE_IN_ALL
50GtkExpression * gtk_expression_ref (GtkExpression *self);
51GDK_AVAILABLE_IN_ALL
52void gtk_expression_unref (GtkExpression *self);
53G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkExpression, gtk_expression_unref)
54
55GDK_AVAILABLE_IN_ALL
56GType gtk_expression_get_value_type (GtkExpression *self);
57GDK_AVAILABLE_IN_ALL
58gboolean gtk_expression_is_static (GtkExpression *self);
59GDK_AVAILABLE_IN_ALL
60gboolean gtk_expression_evaluate (GtkExpression *self,
61 gpointer this_,
62 GValue *value);
63GDK_AVAILABLE_IN_ALL
64GtkExpressionWatch * gtk_expression_watch (GtkExpression *self,
65 gpointer this_,
66 GtkExpressionNotify notify,
67 gpointer user_data,
68 GDestroyNotify user_destroy);
69GDK_AVAILABLE_IN_ALL
70GtkExpressionWatch * gtk_expression_bind (GtkExpression *self,
71 gpointer target,
72 const char * property,
73 gpointer this_);
74
75GDK_AVAILABLE_IN_4_2
76GType gtk_expression_watch_get_type (void) G_GNUC_CONST;
77GDK_AVAILABLE_IN_ALL
78GtkExpressionWatch * gtk_expression_watch_ref (GtkExpressionWatch *watch);
79GDK_AVAILABLE_IN_ALL
80void gtk_expression_watch_unref (GtkExpressionWatch *watch);
81GDK_AVAILABLE_IN_ALL
82gboolean gtk_expression_watch_evaluate (GtkExpressionWatch *watch,
83 GValue *value);
84GDK_AVAILABLE_IN_ALL
85void gtk_expression_watch_unwatch (GtkExpressionWatch *watch);
86
87#define GTK_TYPE_PROPERTY_EXPRESSION (gtk_property_expression_get_type())
88typedef struct _GtkPropertyExpression GtkPropertyExpression;
89
90GDK_AVAILABLE_IN_ALL
91GType gtk_property_expression_get_type (void) G_GNUC_CONST;
92
93GDK_AVAILABLE_IN_ALL
94GtkExpression * gtk_property_expression_new (GType this_type,
95 GtkExpression *expression,
96 const char *property_name);
97GDK_AVAILABLE_IN_ALL
98GtkExpression * gtk_property_expression_new_for_pspec (GtkExpression *expression,
99 GParamSpec *pspec);
100
101GDK_AVAILABLE_IN_ALL
102GtkExpression * gtk_property_expression_get_expression (GtkExpression *expression);
103GDK_AVAILABLE_IN_ALL
104GParamSpec * gtk_property_expression_get_pspec (GtkExpression *expression);
105
106#define GTK_TYPE_CONSTANT_EXPRESSION (gtk_constant_expression_get_type())
107typedef struct _GtkConstantExpression GtkConstantExpression;
108
109GDK_AVAILABLE_IN_ALL
110GType gtk_constant_expression_get_type (void) G_GNUC_CONST;
111
112GDK_AVAILABLE_IN_ALL
113GtkExpression * gtk_constant_expression_new (GType value_type,
114 ...);
115GDK_AVAILABLE_IN_ALL
116GtkExpression * gtk_constant_expression_new_for_value (const GValue *value);
117
118GDK_AVAILABLE_IN_ALL
119const GValue * gtk_constant_expression_get_value (GtkExpression *expression);
120
121#define GTK_TYPE_OBJECT_EXPRESSION (gtk_object_expression_get_type())
122typedef struct _GtkObjectExpression GtkObjectExpression;
123
124GDK_AVAILABLE_IN_ALL
125GType gtk_object_expression_get_type (void) G_GNUC_CONST;
126
127GDK_AVAILABLE_IN_ALL
128GtkExpression * gtk_object_expression_new (GObject *object);
129
130GDK_AVAILABLE_IN_ALL
131GObject * gtk_object_expression_get_object (GtkExpression *expression);
132
133#define GTK_TYPE_CLOSURE_EXPRESSION (gtk_closure_expression_get_type())
134typedef struct _GtkClosureExpression GtkClosureExpression;
135
136GDK_AVAILABLE_IN_ALL
137GType gtk_closure_expression_get_type (void) G_GNUC_CONST;
138
139GDK_AVAILABLE_IN_ALL
140GtkExpression * 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())
146typedef struct _GtkCClosureExpression GtkCClosureExpression;
147
148GDK_AVAILABLE_IN_ALL
149GType gtk_cclosure_expression_get_type (void) G_GNUC_CONST;
150
151GDK_AVAILABLE_IN_ALL
152GtkExpression * 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
170GDK_AVAILABLE_IN_ALL
171void gtk_value_set_expression (GValue *value,
172 GtkExpression *expression);
173GDK_AVAILABLE_IN_ALL
174void gtk_value_take_expression (GValue *value,
175 GtkExpression *expression);
176GDK_AVAILABLE_IN_ALL
177GtkExpression * gtk_value_get_expression (const GValue *value);
178GDK_AVAILABLE_IN_ALL
179GtkExpression * 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 */
190typedef struct {
191 /*< private >*/
192 GParamSpec parent_instance;
193} GtkParamSpecExpression;
194
195GDK_AVAILABLE_IN_ALL
196GType gtk_param_expression_get_type (void) G_GNUC_CONST;
197GDK_AVAILABLE_IN_ALL
198GParamSpec * gtk_param_spec_expression (const char *name,
199 const char *nick,
200 const char *blurb,
201 GParamFlags flags);
202
203G_END_DECLS
204
205#endif /* __GTK_EXPRESSION_H__ */
206

source code of gtk/gtk/gtkexpression.h