Bug Summary

File:demos/ctk-demo/foreigndrawing.c
Warning:line 236, column 15
The left operand of '>' is a garbage value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name foreigndrawing.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/demos/ctk-demo -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I ../../cdk -D CDK_DISABLE_DEPRECATED -D CTK_DISABLE_DEPRECATED -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/demos/ctk-demo -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-171502-43637-1 -x c foreigndrawing.c
1/* Foreign drawing
2 *
3 * Many applications can't use CTK+ widgets, for a variety of reasons,
4 * but still want their user interface to appear integrated with the
5 * rest of the desktop, and follow CTK+ themes. This demo shows how to
6 * use CtkStyleContext and the ctk_render_ APIs to achieve this.
7 *
8 * Note that this is a very simple, non-interactive example.
9 */
10
11#include <ctk/ctk.h>
12#include <string.h>
13
14static void
15append_element (CtkWidgetPath *path,
16 const char *selector)
17{
18 static const struct {
19 const char *name;
20 CtkStateFlags state_flag;
21 } pseudo_classes[] = {
22 { "active", CTK_STATE_FLAG_ACTIVE },
23 { "hover", CTK_STATE_FLAG_PRELIGHT },
24 { "selected", CTK_STATE_FLAG_SELECTED },
25 { "disabled", CTK_STATE_FLAG_INSENSITIVE },
26 { "indeterminate", CTK_STATE_FLAG_INCONSISTENT },
27 { "focus", CTK_STATE_FLAG_FOCUSED },
28 { "backdrop", CTK_STATE_FLAG_BACKDROP },
29 { "dir(ltr)", CTK_STATE_FLAG_DIR_LTR },
30 { "dir(rtl)", CTK_STATE_FLAG_DIR_RTL },
31 { "link", CTK_STATE_FLAG_LINK },
32 { "visited", CTK_STATE_FLAG_VISITED },
33 { "checked", CTK_STATE_FLAG_CHECKED },
34 { "drop(active)", CTK_STATE_FLAG_DROP_ACTIVE }
35 };
36 const char *next;
37 char *name;
38 guint i;
39
40 next = strpbrk (selector, "#.:");
41 if (next == NULL((void*)0))
42 next = selector + strlen (selector);
43
44 name = g_strndup (selector, next - selector);
45 if (g_ascii_isupper (selector[0])((g_ascii_table[(guchar) (selector[0])] & G_ASCII_UPPER) !=
0)
)
46 {
47 GType gtype;
48 gtype = g_type_from_name (name);
49 if (gtype == G_TYPE_INVALID((GType) ((0) << (2))))
50 {
51 g_critical ("Unknown type name `%s'", name);
52 g_free (name);
53 return;
54 }
55 ctk_widget_path_append_type (path, gtype);
56 }
57 else
58 {
59 /* Omit type, we're using name */
60 ctk_widget_path_append_type (path, G_TYPE_NONE((GType) ((1) << (2))));
61 ctk_widget_path_iter_set_object_name (path, -1, name);
62 }
63 g_free (name);
64
65 while (*next != '\0')
66 {
67 char type;
68
69 type = *next;
70 selector = next + 1;
71 next = strpbrk (selector, "#.:");
72 if (next == NULL((void*)0))
73 next = selector + strlen (selector);
74 name = g_strndup (selector, next - selector);
75
76 switch (type)
77 {
78 case '#':
79 ctk_widget_path_iter_set_name (path, -1, name);
80 break;
81
82 case '.':
83 ctk_widget_path_iter_add_class (path, -1, name);
84 break;
85
86 case ':':
87 for (i = 0; i < G_N_ELEMENTS (pseudo_classes)(sizeof (pseudo_classes) / sizeof ((pseudo_classes)[0])); i++)
88 {
89 if (g_str_equal (pseudo_classes[i].name, name)(strcmp ((const char *) (pseudo_classes[i].name), (const char
*) (name)) == 0)
)
90 {
91 ctk_widget_path_iter_set_state (path,
92 -1,
93 ctk_widget_path_iter_get_state (path, -1)
94 | pseudo_classes[i].state_flag);
95 break;
96 }
97 }
98 if (i == G_N_ELEMENTS (pseudo_classes)(sizeof (pseudo_classes) / sizeof ((pseudo_classes)[0])))
99 g_critical ("Unknown pseudo-class :%s", name);
100 break;
101
102 default:
103 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "foreigndrawing.c"
, 103, ((const char*) (__func__)), ((void*)0)); } while (0)
;
104 break;
105 }
106
107 g_free (name);
108 }
109}
110
111static CtkStyleContext *
112create_context_for_path (CtkWidgetPath *path,
113 CtkStyleContext *parent)
114{
115 CtkStyleContext *context;
116
117 context = ctk_style_context_new ();
118 ctk_style_context_set_path (context, path);
119 ctk_style_context_set_parent (context, parent);
120 /* Unfortunately, we have to explicitly set the state again here
121 * for it to take effect
122 */
123 ctk_style_context_set_state (context, ctk_widget_path_iter_get_state (path, -1));
124 ctk_widget_path_unref (path);
125
126 return context;
127}
128
129static CtkStyleContext *
130get_style (CtkStyleContext *parent,
131 const char *selector)
132{
133 CtkWidgetPath *path;
134
135 if (parent)
136 path = ctk_widget_path_copy (ctk_style_context_get_path (parent));
137 else
138 path = ctk_widget_path_new ();
139
140 append_element (path, selector);
141
142 return create_context_for_path (path, parent);
143}
144
145static CtkStyleContext *
146get_style_with_siblings (CtkStyleContext *parent,
147 const char *selector G_GNUC_UNUSED__attribute__ ((__unused__)),
148 const char **siblings,
149 gint position)
150{
151 CtkWidgetPath *path, *siblings_path;
152 guint i;
153
154 if (parent)
155 path = ctk_widget_path_copy (ctk_style_context_get_path (parent));
156 else
157 path = ctk_widget_path_new ();
158
159 siblings_path = ctk_widget_path_new ();
160 for (i = 0; siblings[i]; i++)
161 append_element (siblings_path, siblings[i]);
162
163 ctk_widget_path_append_with_siblings (path, siblings_path, position);
164 ctk_widget_path_unref (siblings_path);
165
166 return create_context_for_path (path, parent);
167}
168
169static void
170draw_style_common (CtkStyleContext *context,
171 cairo_t *cr,
172 gint x,
173 gint y,
174 gint width,
175 gint height,
176 gint *contents_x,
177 gint *contents_y,
178 gint *contents_width,
179 gint *contents_height)
180{
181 CtkBorder margin, border, padding;
182 int min_width, min_height;
183
184 ctk_style_context_get_margin (context, ctk_style_context_get_state (context), &margin);
185 ctk_style_context_get_border (context, ctk_style_context_get_state (context), &border);
186 ctk_style_context_get_padding (context, ctk_style_context_get_state (context), &padding);
187
188 ctk_style_context_get (context, ctk_style_context_get_state (context),
189 "min-width", &min_width,
190 "min-height", &min_height,
191 NULL((void*)0));
192 x += margin.left;
193 y += margin.top;
194 width -= margin.left + margin.right;
195 height -= margin.top + margin.bottom;
196
197 width = MAX (width, min_width)(((width) > (min_width)) ? (width) : (min_width));
198 height = MAX (height, min_height)(((height) > (min_height)) ? (height) : (min_height));
199
200 ctk_render_background (context, cr, x, y, width, height);
201 ctk_render_frame (context, cr, x, y, width, height);
202
203 if (contents_x)
204 *contents_x = x + border.left + padding.left;
205 if (contents_y)
206 *contents_y = y + border.top + padding.top;
207 if (contents_width)
208 *contents_width = width - border.left - border.right - padding.left - padding.right;
209 if (contents_height)
210 *contents_height = height - border.top - border.bottom - padding.top - padding.bottom;
211}
212
213static void
214query_size (CtkStyleContext *context,
215 gint *width,
216 gint *height)
217{
218 CtkBorder margin, border, padding;
219 int min_width, min_height;
220
221 ctk_style_context_get_margin (context, ctk_style_context_get_state (context), &margin);
222 ctk_style_context_get_border (context, ctk_style_context_get_state (context), &border);
223 ctk_style_context_get_padding (context, ctk_style_context_get_state (context), &padding);
224
225 ctk_style_context_get (context, ctk_style_context_get_state (context),
226 "min-width", &min_width,
227 "min-height", &min_height,
228 NULL((void*)0));
229
230 min_width += margin.left + margin.right + border.left + border.right + padding.left + padding.right;
231 min_height += margin.top + margin.bottom + border.top + border.bottom + padding.top + padding.bottom;
232
233 if (width
3.1
'width' is null
)
4
Taking false branch
234 *width = MAX (*width, min_width)(((*width) > (min_width)) ? (*width) : (min_width));
235 if (height
4.1
'height' is non-null
)
236 *height = MAX (*height, min_height)(((*height) > (min_height)) ? (*height) : (min_height));
5
Taking true branch
6
The left operand of '>' is a garbage value
237}
238
239static void
240draw_menu (CtkWidget *widget,
241 cairo_t *cr,
242 gint x,
243 gint y,
244 gint width,
245 gint *height)
246{
247 CtkStyleContext *menu_context;
248 CtkStyleContext *menuitem_context;
249 CtkStyleContext *hovermenuitem_context;
250 CtkStyleContext *hoveredarrowmenuitem_context;
251 CtkStyleContext *arrowmenuitem_context;
252 CtkStyleContext *checkmenuitem_context;
253 CtkStyleContext *disabledarrowmenuitem_context;
254 CtkStyleContext *disabledcheckmenuitem_context;
255 CtkStyleContext *radiomenuitem_context;
256 CtkStyleContext *disablemenuitem_context;
257 CtkStyleContext *disabledradiomenuitem_context;
258 CtkStyleContext *separatormenuitem_context;
259 gint menuitem1_height, menuitem2_height, menuitem3_height, menuitem4_height, menuitem5_height;
2
'menuitem5_height' declared without an initial value
260 gint contents_x, contents_y, contents_width, contents_height;
261 gint menu_x, menu_y, menu_width, menu_height;
262 gint arrow_width, arrow_height, arrow_size;
263 gint toggle_x, toggle_y, toggle_width, toggle_height;
264
265 /* This information is taken from the CtkMenu docs, see "CSS nodes" */
266 menu_context = get_style (ctk_widget_get_style_context(widget), "menu");
267 hovermenuitem_context = get_style (menu_context, "menuitem:hover");
268 hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
269 menuitem_context = get_style (menu_context, "menuitem");
270 arrowmenuitem_context = get_style (menuitem_context, "arrow:dir(rtl)");
271 disablemenuitem_context = get_style (menu_context, "menuitem:disabled");
272 disabledarrowmenuitem_context = get_style (disablemenuitem_context, "arrow:dir(rtl)");
273 checkmenuitem_context = get_style (menuitem_context, "check:checked");
274 disabledcheckmenuitem_context = get_style (disablemenuitem_context, "check");
275 separatormenuitem_context = get_style (menu_context, "separator:disabled");
276 radiomenuitem_context = get_style (menuitem_context, "radio:checked");
277 disabledradiomenuitem_context = get_style (disablemenuitem_context, "radio");
278
279 *height = 0;
280 query_size (menu_context, NULL((void*)0), height);
281 menuitem1_height = 0;
282 query_size (hovermenuitem_context, NULL((void*)0), &menuitem1_height);
283 query_size (hoveredarrowmenuitem_context, NULL((void*)0), &menuitem1_height);
284 *height += menuitem1_height;
285 menuitem2_height = 0;
286 query_size (menu_context, NULL((void*)0), &menuitem5_height);
3
Calling 'query_size'
287 query_size (menuitem_context, NULL((void*)0), &menuitem2_height);
288 query_size (arrowmenuitem_context, NULL((void*)0), &menuitem2_height);
289 query_size (disabledarrowmenuitem_context, NULL((void*)0), &menuitem2_height);
290 *height += menuitem2_height;
291 menuitem3_height = 0;
292 query_size (menu_context, NULL((void*)0), &menuitem5_height);
293 query_size (menuitem_context, NULL((void*)0), &menuitem3_height);
294 query_size (checkmenuitem_context, NULL((void*)0), &menuitem3_height);
295 query_size (disabledcheckmenuitem_context, NULL((void*)0), &menuitem3_height);
296 *height += menuitem3_height;
297 menuitem4_height = 0;
298 query_size (menu_context, NULL((void*)0), &menuitem5_height);
299 query_size (separatormenuitem_context, NULL((void*)0), &menuitem4_height);
300 *height += menuitem4_height;
301 menuitem5_height = 0;
302 query_size (menu_context, NULL((void*)0), &menuitem5_height);
303 query_size (menuitem_context, NULL((void*)0), &menuitem5_height);
304 query_size (radiomenuitem_context, NULL((void*)0), &menuitem5_height);
305 query_size (disabledradiomenuitem_context, NULL((void*)0), &menuitem5_height);
306 *height += menuitem5_height;
307
308 draw_style_common (menu_context, cr, x, y, width, *height,
309 &menu_x, &menu_y, &menu_width, &menu_height);
310
311 /* Hovered with right arrow */
312 ctk_style_context_get (hoveredarrowmenuitem_context, ctk_style_context_get_state (hoveredarrowmenuitem_context),
313 "min-width", &arrow_width, "min-height", &arrow_height, NULL((void*)0));
314 arrow_size = MIN (arrow_width, arrow_height)(((arrow_width) < (arrow_height)) ? (arrow_width) : (arrow_height
))
;
315 draw_style_common (hovermenuitem_context, cr, menu_x, menu_y, menu_width, menuitem1_height,
316 &contents_x, &contents_y, &contents_width, &contents_height);
317 ctk_render_arrow (hoveredarrowmenuitem_context, cr, G_PI3.1415926535897932384626433832795028841971693993751 / 2,
318 contents_x + contents_width - arrow_size,
319 contents_y + (contents_height - arrow_size) / 2, arrow_size);
320
321 /* Left arrow sensitive, and right arrow insensitive */
322 draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height, menu_width, menuitem2_height,
323 &contents_x, &contents_y, &contents_width, &contents_height);
324 ctk_style_context_get (arrowmenuitem_context, ctk_style_context_get_state (arrowmenuitem_context),
325 "min-width", &arrow_width, "min-height", &arrow_height, NULL((void*)0));
326 arrow_size = MIN (arrow_width, arrow_height)(((arrow_width) < (arrow_height)) ? (arrow_width) : (arrow_height
))
;
327 ctk_render_arrow (arrowmenuitem_context, cr, G_PI3.1415926535897932384626433832795028841971693993751 / 2,
328 contents_x,
329 contents_y + (contents_height - arrow_size) / 2, arrow_size);
330 ctk_style_context_get (disabledarrowmenuitem_context, ctk_style_context_get_state (disabledarrowmenuitem_context),
331 "min-width", &arrow_width, "min-height", &arrow_height, NULL((void*)0));
332 arrow_size = MIN (arrow_width, arrow_height)(((arrow_width) < (arrow_height)) ? (arrow_width) : (arrow_height
))
;
333 ctk_render_arrow (disabledarrowmenuitem_context, cr, G_PI3.1415926535897932384626433832795028841971693993751 / 2,
334 contents_x + contents_width - arrow_size,
335 contents_y + (contents_height - arrow_size) / 2, arrow_size);
336
337
338 /* Left check enabled, sensitive, and right check unchecked, insensitive */
339 draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height, menu_width, menuitem3_height,
340 &contents_x, &contents_y, &contents_width, &contents_height);
341 ctk_style_context_get (checkmenuitem_context, ctk_style_context_get_state (checkmenuitem_context),
342 "min-width", &toggle_width, "min-height", &toggle_height, NULL((void*)0));
343 draw_style_common (checkmenuitem_context, cr,
344 contents_x,
345 contents_y,
346 toggle_width, toggle_height,
347 &toggle_x, &toggle_y, &toggle_width, &toggle_height);
348 ctk_render_check (checkmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
349 ctk_style_context_get (disabledcheckmenuitem_context, ctk_style_context_get_state (disabledcheckmenuitem_context),
350 "min-width", &toggle_width, "min-height", &toggle_height, NULL((void*)0));
351 draw_style_common (disabledcheckmenuitem_context, cr,
352 contents_x + contents_width - toggle_width,
353 contents_y,
354 toggle_width, toggle_height,
355 &toggle_x, &toggle_y, &toggle_width, &toggle_height);
356 ctk_render_check (disabledcheckmenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
357
358 /* Separator */
359 draw_style_common (separatormenuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height,
360 menu_width, menuitem4_height,
361 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
362
363 /* Left check enabled, sensitive, and right check unchecked, insensitive */
364 draw_style_common (menuitem_context, cr, menu_x, menu_y + menuitem1_height + menuitem2_height + menuitem3_height + menuitem4_height,
365 menu_width, menuitem5_height,
366 &contents_x, &contents_y, &contents_width, &contents_height);
367 ctk_style_context_get (radiomenuitem_context, ctk_style_context_get_state (radiomenuitem_context),
368 "min-width", &toggle_width, "min-height", &toggle_height, NULL((void*)0));
369 draw_style_common (radiomenuitem_context, cr,
370 contents_x,
371 contents_y,
372 toggle_width, toggle_height,
373 &toggle_x, &toggle_y, &toggle_width, &toggle_height);
374 ctk_render_check (radiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
375 ctk_style_context_get (disabledradiomenuitem_context, ctk_style_context_get_state (disabledradiomenuitem_context),
376 "min-width", &toggle_width, "min-height", &toggle_height, NULL((void*)0));
377 draw_style_common (disabledradiomenuitem_context, cr,
378 contents_x + contents_width - toggle_width,
379 contents_y,
380 toggle_width, toggle_height,
381 &toggle_x, &toggle_y, &toggle_width, &toggle_height);
382 ctk_render_check (disabledradiomenuitem_context, cr, toggle_x, toggle_y, toggle_width, toggle_height);
383
384 g_object_unref (menu_context);
385 g_object_unref (menuitem_context);
386 g_object_unref (hovermenuitem_context);
387 g_object_unref (hoveredarrowmenuitem_context);
388 g_object_unref (arrowmenuitem_context);
389 g_object_unref (checkmenuitem_context);
390 g_object_unref (disabledarrowmenuitem_context);
391 g_object_unref (disabledcheckmenuitem_context);
392 g_object_unref (radiomenuitem_context);
393 g_object_unref (disablemenuitem_context);
394 g_object_unref (disabledradiomenuitem_context);
395 g_object_unref (separatormenuitem_context);
396}
397
398static void
399draw_menubar (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
400 cairo_t *cr,
401 gint x,
402 gint y,
403 gint width,
404 gint *height)
405{
406 CtkStyleContext *frame_context;
407 CtkStyleContext *border_context;
408 CtkStyleContext *menubar_context;
409 CtkStyleContext *hovered_menuitem_context;
410 CtkStyleContext *menuitem_context;
411 gint contents_x, contents_y, contents_width, contents_height;
412 gint item_width;
413
414 /* Menubar background is the same color as our base background, so use a frame */
415 frame_context = get_style (NULL((void*)0), "frame");
416 border_context = get_style (frame_context, "border");
417
418 /* This information is taken from the CtkMenuBar docs, see "CSS nodes" */
419 menubar_context = get_style (NULL((void*)0), "menubar");
420 hovered_menuitem_context = get_style (menubar_context, "menuitem:hover");
421 menuitem_context = get_style (menubar_context, "menuitem");
422
423 *height = 0;
424 query_size (frame_context, NULL((void*)0), height);
425 query_size (border_context, NULL((void*)0), height);
426 query_size (menubar_context, NULL((void*)0), height);
427 query_size (hovered_menuitem_context, NULL((void*)0), height);
428 query_size (menuitem_context, NULL((void*)0), height);
429
430 draw_style_common (frame_context, cr, x, y, width, *height,
431 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
432 draw_style_common (border_context, cr, x, y, width, *height,
433 &contents_x, &contents_y, &contents_width, &contents_height);
434 draw_style_common (menubar_context, cr, contents_x, contents_y, contents_width, contents_height,
435 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
436 item_width = contents_width / 3;
437 draw_style_common (hovered_menuitem_context, cr, contents_x, contents_y, item_width, contents_height,
438 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
439 draw_style_common (menuitem_context, cr, contents_x + item_width * 2, contents_y, item_width, contents_height,
440 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
441
442 g_object_unref (menuitem_context);
443 g_object_unref (hovered_menuitem_context);
444 g_object_unref (menubar_context);
445 g_object_unref (border_context);
446 g_object_unref (frame_context);
447}
448
449static void
450draw_notebook (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
451 cairo_t *cr,
452 gint x,
453 gint y,
454 gint width,
455 gint height)
456{
457 CtkStyleContext *notebook_context;
458 CtkStyleContext *header_context;
459 CtkStyleContext *tabs_context;
460 CtkStyleContext *tab1_context, *tab2_context;
461 CtkStyleContext *stack_context;
462 gint header_height;
463 gint contents_x, contents_y, contents_width, contents_height;
464
465 /* This information is taken from the CtkNotebook docs, see "CSS nodes" */
466 notebook_context = get_style (NULL((void*)0), "notebook.frame");
467 header_context = get_style (notebook_context, "header.top");
468 tabs_context = get_style (header_context, "tabs");
469 tab1_context = get_style (tabs_context, "tab:checked");
470 tab2_context = get_style (tabs_context, "tab:hover");
471 stack_context = get_style (notebook_context, "stack");
472
473 header_height = 0;
474 query_size (notebook_context, NULL((void*)0), &header_height);
475 query_size (header_context, NULL((void*)0), &header_height);
476 query_size (tabs_context, NULL((void*)0), &header_height);
477 query_size (tab1_context, NULL((void*)0), &header_height);
478 query_size (tab2_context, NULL((void*)0), &header_height);
479
480 draw_style_common (notebook_context, cr, x, y, width, height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
481 draw_style_common (header_context, cr, x, y, width, header_height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
482 draw_style_common (tabs_context, cr, x, y, width, header_height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
483 draw_style_common (tab1_context, cr, x, y, width / 2, header_height,
484 &contents_x, &contents_y, &contents_width, &contents_height);
485 draw_style_common (tab2_context, cr, x + width / 2, y, width / 2, header_height,
486 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
487 draw_style_common (stack_context, cr, x, y + header_height, width,height - header_height,
488 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
489
490 g_object_unref (stack_context);
491 g_object_unref (tabs_context);
492 g_object_unref (tab1_context);
493 g_object_unref (tab2_context);
494 g_object_unref (header_context);
495 g_object_unref (notebook_context);
496}
497
498static void
499draw_horizontal_scrollbar (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
500 cairo_t *cr,
501 gint x,
502 gint y,
503 gint width,
504 gint position,
505 CtkStateFlags state,
506 gint *height)
507{
508 CtkStyleContext *scrollbar_context;
509 CtkStyleContext *contents_context;
510 CtkStyleContext *trough_context;
511 CtkStyleContext *slider_context;
512 gint slider_width;
513
514 /* This information is taken from the CtkScrollbar docs, see "CSS nodes" */
515 scrollbar_context = get_style (NULL((void*)0), "scrollbar.horizontal.bottom");
516 contents_context = get_style (scrollbar_context, "contents");
517 trough_context = get_style (contents_context, "trough");
518 slider_context = get_style (trough_context, "slider");
519
520 ctk_style_context_set_state (scrollbar_context, state);
521 ctk_style_context_set_state (contents_context, state);
522 ctk_style_context_set_state (trough_context, state);
523 ctk_style_context_set_state (slider_context, state);
524
525 *height = 0;
526 query_size (scrollbar_context, NULL((void*)0), height);
527 query_size (contents_context, NULL((void*)0), height);
528 query_size (trough_context, NULL((void*)0), height);
529 query_size (slider_context, NULL((void*)0), height);
530
531 ctk_style_context_get (slider_context, ctk_style_context_get_state (slider_context),
532 "min-width", &slider_width, NULL((void*)0));
533
534 draw_style_common (scrollbar_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
535 draw_style_common (contents_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
536 draw_style_common (trough_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
537 draw_style_common (slider_context, cr, x + position, y, slider_width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
538
539 g_object_unref (slider_context);
540 g_object_unref (trough_context);
541 g_object_unref (contents_context);
542 g_object_unref (scrollbar_context);
543}
544
545static void
546draw_text (CtkWidget *widget,
547 cairo_t *cr,
548 gint x,
549 gint y,
550 gint width,
551 gint height,
552 const gchar *text,
553 CtkStateFlags state)
554{
555 CtkStyleContext *label_context;
556 CtkStyleContext *selection_context;
557 CtkStyleContext *context;
558 PangoLayout *layout;
559
560 /* This information is taken from the CtkLabel docs, see "CSS nodes" */
561 label_context = get_style (NULL((void*)0), "label.view");
562 selection_context = get_style (label_context, "selection");
563
564 ctk_style_context_set_state (label_context, state);
565
566 if (state & CTK_STATE_FLAG_SELECTED)
567 context = selection_context;
568 else
569 context = label_context;
570
571 layout = ctk_widget_create_pango_layout (widget, text);
572
573 ctk_render_background (context, cr, x, y, width, height);
574 ctk_render_frame (context, cr, x, y, width, height);
575 ctk_render_layout (context, cr, x, y, layout);
576
577 g_object_unref (layout);
578
579 g_object_unref (selection_context);
580 g_object_unref (label_context);
581}
582
583static void
584draw_check (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
585 cairo_t *cr,
586 gint x,
587 gint y,
588 CtkStateFlags state,
589 gint *width,
590 gint *height)
591{
592 CtkStyleContext *button_context;
593 CtkStyleContext *check_context;
594 gint contents_x, contents_y, contents_width, contents_height;
595
596 /* This information is taken from the CtkCheckButton docs, see "CSS nodes" */
597 button_context = get_style (NULL((void*)0), "checkbutton");
598 check_context = get_style (button_context, "check");
599
600 ctk_style_context_set_state (check_context, state);
601
602 *width = *height = 0;
603 query_size (button_context, width, height);
604 query_size (check_context, width, height);
605
606 draw_style_common (button_context, cr, x, y, *width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
607 draw_style_common (check_context, cr, x, y, *width, *height,
608 &contents_x, &contents_y, &contents_width, &contents_height);
609 ctk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
610
611 g_object_unref (check_context);
612 g_object_unref (button_context);
613
614}
615
616static void
617draw_radio (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
618 cairo_t *cr,
619 gint x,
620 gint y,
621 CtkStateFlags state,
622 gint *width,
623 gint *height)
624{
625 CtkStyleContext *button_context;
626 CtkStyleContext *check_context;
627 gint contents_x, contents_y, contents_width, contents_height;
628
629 /* This information is taken from the CtkRadioButton docs, see "CSS nodes" */
630 button_context = get_style (NULL((void*)0), "radiobutton");
631 check_context = get_style (button_context, "radio");
632
633 ctk_style_context_set_state (check_context, state);
634
635 *width = *height = 0;
636 query_size (button_context, width, height);
637 query_size (check_context, width, height);
638
639 draw_style_common (button_context, cr, x, y, *width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
640 draw_style_common (check_context, cr, x, y, *width, *height,
641 &contents_x, &contents_y, &contents_width, &contents_height);
642 ctk_render_check (check_context, cr, contents_x, contents_y, contents_width, contents_height);
643
644 g_object_unref (check_context);
645 g_object_unref (button_context);
646
647}
648
649static void
650draw_progress (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
651 cairo_t *cr,
652 gint x,
653 gint y,
654 gint width,
655 gint position,
656 gint *height)
657{
658 CtkStyleContext *bar_context;
659 CtkStyleContext *trough_context;
660 CtkStyleContext *progress_context;
661
662 /* This information is taken from the CtkProgressBar docs, see "CSS nodes" */
663 bar_context = get_style (NULL((void*)0), "progressbar.horizontal");
664 trough_context = get_style (bar_context, "trough");
665 progress_context = get_style (trough_context, "progress.left");
666
667 *height = 0;
668 query_size (bar_context, NULL((void*)0), height);
669 query_size (trough_context, NULL((void*)0), height);
670 query_size (progress_context, NULL((void*)0), height);
671
672 draw_style_common (bar_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
673 draw_style_common (trough_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
674 draw_style_common (progress_context, cr, x, y, position, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
675
676 g_object_unref (progress_context);
677 g_object_unref (trough_context);
678 g_object_unref (bar_context);
679}
680
681static void
682draw_scale (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
683 cairo_t *cr,
684 gint x,
685 gint y,
686 gint width,
687 gint position,
688 gint *height)
689{
690 CtkStyleContext *scale_context;
691 CtkStyleContext *contents_context;
692 CtkStyleContext *trough_context;
693 CtkStyleContext *slider_context;
694 CtkStyleContext *highlight_context;
695 gint contents_x, contents_y, contents_width, contents_height;
696 gint trough_height, slider_height;
697
698 scale_context = get_style (NULL((void*)0), "scale.horizontal");
699 contents_context = get_style (scale_context, "contents");
700 trough_context = get_style (contents_context, "trough");
701 slider_context = get_style (trough_context, "slider");
702 highlight_context = get_style (trough_context, "highlight.top");
703
704 *height = 0;
705 query_size (scale_context, NULL((void*)0), height);
706 query_size (contents_context, NULL((void*)0), height);
707 query_size (trough_context, NULL((void*)0), height);
708 query_size (slider_context, NULL((void*)0), height);
709 query_size (highlight_context, NULL((void*)0), height);
710
711 draw_style_common (scale_context, cr, x, y, width, *height,
712 &contents_x, &contents_y, &contents_width, &contents_height);
713 draw_style_common (contents_context, cr, contents_x, contents_y, contents_width, contents_height,
714 &contents_x, &contents_y, &contents_width, &contents_height);
715 /* Scale trough defines its size querying slider and highlight */
716 trough_height = 0;
717 query_size (trough_context, NULL((void*)0), &trough_height);
718 slider_height = 0;
719 query_size (slider_context, NULL((void*)0), &slider_height);
720 query_size (highlight_context, NULL((void*)0), &slider_height);
721 trough_height += slider_height;
722 draw_style_common (trough_context, cr, contents_x, contents_y, contents_width, trough_height,
723 &contents_x, &contents_y, &contents_width, &contents_height);
724 draw_style_common (highlight_context, cr, contents_x, contents_y,
725 contents_width / 2, contents_height,
726 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
727 draw_style_common (slider_context, cr, contents_x + position, contents_y, contents_height, contents_height,
728 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
729
730 g_object_unref (scale_context);
731 g_object_unref (contents_context);
732 g_object_unref (trough_context);
733 g_object_unref (slider_context);
734 g_object_unref (highlight_context);
735}
736
737static void
738draw_combobox (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
739 cairo_t *cr,
740 gint x,
741 gint y,
742 gint width,
743 gboolean has_entry,
744 gint *height)
745{
746 CtkStyleContext *combo_context;
747 CtkStyleContext *box_context;
748 CtkStyleContext *button_context;
749 CtkStyleContext *button_box_context;
750 CtkStyleContext *entry_context;
751 CtkStyleContext *arrow_context;
752 gint contents_x, contents_y, contents_width, contents_height;
753 gint button_width;
754 gint arrow_width, arrow_height, arrow_size;
755
756 /* This information is taken from the CtkComboBox docs, see "CSS nodes" */
757 combo_context = get_style (NULL((void*)0), "combobox:focus");
758 box_context = get_style (combo_context, "box.horizontal.linked");
759 if (has_entry)
760 {
761 const char *siblings[3] = { "entry.combo:focus", "button.combo" , NULL((void*)0) };
762
763 entry_context = get_style_with_siblings (box_context, "entry.combo:focus", siblings, 0);
764 button_context = get_style_with_siblings (box_context, "button.combo", siblings, 1);
765 }
766 else
767 {
768 const char *siblings[2] = { "button.combo" , NULL((void*)0) };
769
770 button_context = get_style_with_siblings (box_context, "button.combo", siblings, 0);
771 }
772 button_box_context = get_style (button_context, "box.horizontal");
773 arrow_context = get_style (button_box_context, "arrow");
774
775 *height = 0;
776 query_size (combo_context, NULL((void*)0), height);
777 query_size (box_context, NULL((void*)0), height);
778 if (has_entry)
779 query_size (entry_context, NULL((void*)0), height);
780 query_size (button_context, NULL((void*)0), height);
781 query_size (button_box_context, NULL((void*)0), height);
782 query_size (arrow_context, NULL((void*)0), height);
783
784 ctk_style_context_get (arrow_context, ctk_style_context_get_state (arrow_context),
785 "min-width", &arrow_width, "min-height", &arrow_height, NULL((void*)0));
786 arrow_size = MIN (arrow_width, arrow_height)(((arrow_width) < (arrow_height)) ? (arrow_width) : (arrow_height
))
;
787
788 draw_style_common (combo_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
789 draw_style_common (box_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
790 if (has_entry)
791 {
792 button_width = *height;
793 draw_style_common (entry_context, cr, x, y, width - button_width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
794 draw_style_common (button_context, cr, x + width - button_width, y, button_width, *height,
795 &contents_x, &contents_y, &contents_width, &contents_height);
796 }
797 else
798 {
799 button_width = width;
800 draw_style_common (button_context, cr, x, y, width, *height,
801 &contents_x, &contents_y, &contents_width, &contents_height);
802 }
803
804 draw_style_common (button_box_context, cr, contents_x, contents_y, contents_width, contents_height,
805 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
806 draw_style_common (arrow_context, cr, contents_x, contents_y, contents_width, contents_height,
807 NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
808 ctk_render_arrow (arrow_context, cr, G_PI3.1415926535897932384626433832795028841971693993751 / 2,
809 contents_x + contents_width - arrow_size,
810 contents_y + (contents_height - arrow_size) / 2, arrow_size);
811
812 g_object_unref (arrow_context);
813 if (has_entry)
814 g_object_unref (entry_context);
815 g_object_unref (button_context);
816 g_object_unref (combo_context);
817}
818
819static void
820draw_spinbutton (CtkWidget *widget,
821 cairo_t *cr,
822 gint x,
823 gint y,
824 gint width,
825 gint *height)
826{
827 CtkStyleContext *spin_context;
828 CtkStyleContext *entry_context;
829 CtkStyleContext *up_context;
830 CtkStyleContext *down_context;
831 CtkIconTheme *icon_theme;
832 CtkIconInfo *icon_info;
833 GdkPixbuf *pixbuf;
834 gint icon_width, icon_height, icon_size;
835 gint button_width;
836 gint contents_x, contents_y, contents_width, contents_height;
837
838 /* This information is taken from the CtkSpinButton docs, see "CSS nodes" */
839 spin_context = get_style (NULL((void*)0), "spinbutton.horizontal:focus");
840 entry_context = get_style (spin_context, "entry:focus");
841 up_context = get_style (spin_context, "button.up:focus:active");
842 down_context = get_style (spin_context, "button.down:focus");
843
844 *height = 0;
845 query_size (spin_context, NULL((void*)0), height);
846 query_size (entry_context, NULL((void*)0), height);
847 query_size (up_context, NULL((void*)0), height);
848 query_size (down_context, NULL((void*)0), height);
849 button_width = *height;
850
851 draw_style_common (spin_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
852 draw_style_common (entry_context, cr, x, y, width, *height, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0));
853
854 icon_theme = ctk_icon_theme_get_for_screen (ctk_widget_get_screen (widget));
855
856 ctk_style_context_get (up_context, ctk_style_context_get_state (up_context),
857 "min-width", &icon_width, "min-height", &icon_height, NULL((void*)0));
858 icon_size = MIN (icon_width, icon_height)(((icon_width) < (icon_height)) ? (icon_width) : (icon_height
))
;
859 icon_info = ctk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", icon_size, 0);
860 pixbuf = ctk_icon_info_load_symbolic_for_context (icon_info, up_context, NULL((void*)0), NULL((void*)0));
861 g_object_unref (icon_info);
862 draw_style_common (up_context, cr, x + width - button_width, y, button_width, *height,
863 &contents_x, &contents_y, &contents_width, &contents_height);
864 ctk_render_icon (up_context, cr, pixbuf, contents_x, contents_y + (contents_height - icon_size) / 2);
865 g_object_unref (pixbuf);
866
867
868 ctk_style_context_get (down_context, ctk_style_context_get_state (down_context),
869 "min-width", &icon_width, "min-height", &icon_height, NULL((void*)0));
870 icon_size = MIN (icon_width, icon_height)(((icon_width) < (icon_height)) ? (icon_width) : (icon_height
))
;
871 icon_info = ctk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", icon_size, 0);
872 pixbuf = ctk_icon_info_load_symbolic_for_context (icon_info, down_context, NULL((void*)0), NULL((void*)0));
873 g_object_unref (icon_info);
874 draw_style_common (down_context, cr, x + width - 2 * button_width, y, button_width, *height,
875 &contents_x, &contents_y, &contents_width, &contents_height);
876 ctk_render_icon (down_context, cr, pixbuf, contents_x, contents_y + (contents_height - icon_size) / 2);
877 g_object_unref (pixbuf);
878
879 g_object_unref (down_context);
880 g_object_unref (up_context);
881 g_object_unref (entry_context);
882 g_object_unref (spin_context);
883}
884
885static gboolean
886draw_cb (CtkWidget *widget,
887 cairo_t *cr)
888{
889 gint panewidth, width, height;
890 gint x, y;
891
892 width = ctk_widget_get_allocated_width (widget);
893 panewidth = width / 2;
894 height = ctk_widget_get_allocated_height (widget);
895
896 cairo_rectangle (cr, 0, 0, width, height);
897 cairo_set_source_rgb (cr, 0.9, 0.9, 0.9);
898 cairo_fill (cr);
899
900 x = y = 10;
901 draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 30, CTK_STATE_FLAG_NORMAL, &height);
902 y += height + 8;
903 draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 40, CTK_STATE_FLAG_PRELIGHT, &height);
904 y += height + 8;
905 draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 50, CTK_STATE_FLAG_ACTIVE|CTK_STATE_FLAG_PRELIGHT, &height);
906
907 y += height + 8;
908 draw_text (widget, cr, x, y, panewidth - 20, 20, "Not selected", CTK_STATE_FLAG_NORMAL);
909 y += 20 + 10;
910 draw_text (widget, cr, x, y, panewidth - 20, 20, "Selected", CTK_STATE_FLAG_SELECTED);
911
912 x = 10;
913 y += 20 + 10;
914 draw_check (widget, cr, x, y, CTK_STATE_FLAG_NORMAL, &width, &height);
915 x += width + 10;
916 draw_check (widget, cr, x, y, CTK_STATE_FLAG_CHECKED, &width, &height);
917 x += width + 10;
918 draw_radio (widget, cr, x, y, CTK_STATE_FLAG_NORMAL, &width, &height);
919 x += width + 10;
920 draw_radio (widget, cr, x, y, CTK_STATE_FLAG_CHECKED, &width, &height);
921 x = 10;
922
923 y += height + 10;
924 draw_progress (widget, cr, x, y, panewidth - 20, 50, &height);
925
926 y += height + 10;
927 draw_scale (widget, cr, x, y, panewidth - 20, 75, &height);
928
929 y += height + 20;
930 draw_notebook (widget, cr, x, y, panewidth - 20, 160);
931
932 /* Second column */
933 x += panewidth;
934 y = 10;
935 draw_menu (widget, cr, x, y, panewidth - 20, &height);
1
Calling 'draw_menu'
936
937 y += height + 10;
938 draw_menubar (widget, cr, x, y, panewidth - 20, &height);
939
940 y += height + 20;
941 draw_spinbutton (widget, cr, x, y, panewidth - 20, &height);
942
943 y += height + 30;
944 draw_combobox (widget, cr, x, y, panewidth - 20, FALSE(0), &height);
945
946 y += height + 10;
947 draw_combobox (widget, cr, 10 + panewidth, y, panewidth - 20, TRUE(!(0)), &height);
948
949 return FALSE(0);
950}
951
952CtkWidget *
953do_foreigndrawing (CtkWidget *do_widget)
954{
955 static CtkWidget *window = NULL((void*)0);
956
957 if (!window)
958 {
959 CtkWidget *box;
960 CtkWidget *da;
961
962 window = ctk_window_new (CTK_WINDOW_TOPLEVEL);
963 ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, "Foreign drawing");
964 ctk_window_set_screen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
965 ctk_widget_get_screen (do_widget));
966 g_signal_connect (window, "destroy",g_signal_connect_data ((window), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&window), ((void*)0), (GConnectFlags
) 0)
967 G_CALLBACK (ctk_widget_destroyed), &window)g_signal_connect_data ((window), ("destroy"), (((GCallback) (
ctk_widget_destroyed))), (&window), ((void*)0), (GConnectFlags
) 0)
;
968
969 box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 10);
970 ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_container_get_type ()))))))
, box);
971 da = ctk_drawing_area_new ();
972 ctk_widget_set_size_request (da, 400, 400);
973 ctk_widget_set_hexpand (da, TRUE(!(0)));
974 ctk_widget_set_vexpand (da, TRUE(!(0)));
975 ctk_widget_set_app_paintable (da, TRUE(!(0)));
976 ctk_container_add (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, da);
977
978 g_signal_connect (da, "draw", G_CALLBACK (draw_cb), NULL)g_signal_connect_data ((da), ("draw"), (((GCallback) (draw_cb
))), (((void*)0)), ((void*)0), (GConnectFlags) 0)
;
979 }
980
981 if (!ctk_widget_get_visible (window))
982 ctk_widget_show_all (window);
983 else
984 ctk_widget_destroy (window);
985
986 return window;
987}