Bug Summary

File:avers/gste-squares.c
Warning:line 231, column 3
Value stored to 'wanted' is never read

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 gste-squares.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/savers -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -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/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -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 -D LIBEXECDIR="/usr/local/libexec" -D CAFELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../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/savers -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/2023-12-20-101650-53368-1 -x c gste-squares.c
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
2 *
3 * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 *
20 */
21
22#include "config.h"
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <unistd.h>
27#include <string.h>
28
29#include <glib.h>
30#include <ctk/ctk.h>
31
32#include "gs-theme-engine.h"
33#include "gste-squares.h"
34
35static void gste_squares_finalize (GObject *object);
36static void draw_frame (GSTEPopsquares *pop,
37 cairo_t *cr);
38
39typedef struct _square
40{
41 int x, y, w, h;
42 int color;
43} square;
44
45struct GSTEPopsquaresPrivate
46{
47 guint timeout_id;
48
49 int ncolors;
50 int subdivision;
51
52 CdkRGBA *colors;
53 square *squares;
54};
55
56static GObjectClass *parent_class = NULL((void*)0);
57
58G_DEFINE_TYPE_WITH_PRIVATE (GSTEPopsquares, gste_squares, GS_TYPE_THEME_ENGINE)static void gste_squares_init (GSTEPopsquares *self); static void
gste_squares_class_init (GSTEPopsquaresClass *klass); static
GType gste_squares_get_type_once (void); static gpointer gste_squares_parent_class
= ((void*)0); static gint GSTEPopsquares_private_offset; static
void gste_squares_class_intern_init (gpointer klass) { gste_squares_parent_class
= g_type_class_peek_parent (klass); if (GSTEPopsquares_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &GSTEPopsquares_private_offset
); gste_squares_class_init ((GSTEPopsquaresClass*) klass); } __attribute__
((__unused__)) static inline gpointer gste_squares_get_instance_private
(GSTEPopsquares *self) { return (((gpointer) ((guint8*) (self
) + (glong) (GSTEPopsquares_private_offset)))); } GType gste_squares_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gste_squares_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gste_squares_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gs_theme_engine_get_type ()), g_intern_static_string ("GSTEPopsquares"
), sizeof (GSTEPopsquaresClass), (GClassInitFunc)(void (*)(void
)) gste_squares_class_intern_init, sizeof (GSTEPopsquares), (
GInstanceInitFunc)(void (*)(void)) gste_squares_init, (GTypeFlags
) 0); { {{ GSTEPopsquares_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSTEPopsquaresPrivate)); };} } return
g_define_type_id; }
59
60static void
61hsv_to_rgb (int h,
62 double s,
63 double v,
64 double *r,
65 double *g,
66 double *b)
67{
68 double H, S, V, R, G, B;
69 double p1, p2, p3;
70 double f;
71 int i;
72
73 if (s < 0)
74 {
75 s = 0;
76 }
77 if (v < 0)
78 {
79 v = 0;
80 }
81 if (s > 1)
82 {
83 s = 1;
84 }
85 if (v > 1)
86 {
87 v = 1;
88 }
89
90 S = s;
91 V = v;
92 H = (h % 360) / 60.0;
93 i = H;
94 f = H - i;
95 p1 = V * (1 - S);
96 p2 = V * (1 - (S * f));
97 p3 = V * (1 - (S * (1 - f)));
98
99 if (i == 0)
100 {
101 R = V;
102 G = p3;
103 B = p1;
104 }
105 else if (i == 1)
106 {
107 R = p2;
108 G = V;
109 B = p1;
110 }
111 else if (i == 2)
112 {
113 R = p1;
114 G = V;
115 B = p3;
116 }
117 else if (i == 3)
118 {
119 R = p1;
120 G = p2;
121 B = V;
122 }
123 else if (i == 4)
124 {
125 R = p3;
126 G = p1;
127 B = V;
128 }
129 else
130 {
131 R = V;
132 G = p1;
133 B = p2;
134 }
135
136 *r = R;
137 *g = G;
138 *b = B;
139}
140
141static void
142rgb_to_hsv (double r,
143 double g,
144 double b,
145 int *h,
146 double *s,
147 double *v)
148{
149 double R, G, B, H, S, V;
150 double cmax, cmin;
151 double cmm;
152 int imax;
153
154 R = r;
155 G = g;
156 B = b;
157 cmax = R;
158 cmin = G;
159 imax = 1;
160
161 if (cmax < G)
162 {
163 cmax = G;
164 cmin = R;
165 imax = 2;
166 }
167 if (cmax < B)
168 {
169 cmax = B;
170 imax = 3;
171 }
172 if (cmin > B)
173 {
174 cmin = B;
175 }
176
177 cmm = cmax - cmin;
178 V = cmax;
179
180 if (cmm == 0)
181 {
182 S = H = 0;
183 }
184 else
185 {
186 S = cmm / cmax;
187 if (imax == 1)
188 {
189 H = (G - B) / cmm;
190 }
191 else if (imax == 2)
192 {
193 H = 2.0 + (B - R) / cmm;
194 }
195 else
196 {
197 /*if (imax == 3)*/
198 H = 4.0 + (R - G) / cmm;
199 }
200
201 if (H < 0)
202 {
203 H += 6.0;
204 }
205 }
206
207 *h = (H * 60.0);
208 *s = S;
209 *v = V;
210}
211
212static void
213make_color_ramp (int h1,
214 double s1,
215 double v1,
216 int h2,
217 double s2,
218 double v2,
219 CdkRGBA *colors,
220 int n_colors,
221 gboolean closed)
222{
223 double dh, ds, dv; /* deltas */
224 int i;
225 int ncolors, wanted;
226 int total_ncolors = n_colors;
227
228 wanted = total_ncolors;
229 if (closed)
230 {
231 wanted = (wanted / 2) + 1;
Value stored to 'wanted' is never read
232 }
233
234 ncolors = total_ncolors;
235
236 memset (colors, 0, n_colors * sizeof (*colors));
237
238 if (closed)
239 {
240 ncolors = (ncolors / 2) + 1;
241 }
242
243 /* Note: unlike other routines in this module, this function assumes that
244 if h1 and h2 are more than 180 degrees apart, then the desired direction
245 is always from h1 to h2 (rather than the shorter path.) make_uniform
246 depends on this.
247 */
248 dh = ((double)h2 - (double)h1) / ncolors;
249 ds = (s2 - s1) / ncolors;
250 dv = (v2 - v1) / ncolors;
251
252 for (i = 0; i < ncolors; i++)
253 {
254 hsv_to_rgb ((int) (h1 + (i * dh)),
255 (s1 + (i * ds)),
256 (v1 + (i * dv)),
257 &colors [i].red,
258 &colors [i].green,
259 &colors [i].blue);
260 colors [i].alpha = 1.0;
261 }
262
263 if (closed)
264 {
265 for (i = ncolors; i < n_colors; i++)
266 {
267 colors [i] = colors [n_colors - i];
268 }
269 }
270
271}
272
273static void
274randomize_square_colors (square *squares,
275 int nsquares,
276 int ncolors)
277{
278 int i;
279 square *s;
280
281 s = squares;
282
283 for (i = 0; i < nsquares; i++)
284 {
285 s[i].color = g_random_int_range (0, ncolors);
286 }
287}
288
289static void
290set_colors (CtkWidget *widget,
291 CdkRGBA *fg,
292 CdkRGBA *bg)
293{
294 CtkStyleContext *style;
295
296 style = ctk_widget_get_style_context (widget);
297
298 ctk_style_context_save (style);
299 ctk_style_context_set_state (style, CTK_STATE_FLAG_SELECTED);
300 ctk_style_context_get_background_color (style,
301 ctk_style_context_get_state (style),
302 bg);
303 if (bg->alpha == 0.0)
304 {
305 ctk_style_context_add_class (style, CTK_STYLE_CLASS_VIEW"view");
306 ctk_style_context_get_background_color (style,
307 ctk_style_context_get_state (style),
308 bg);
309 }
310 ctk_style_context_restore (style);
311
312 fg->red = bg->red * 0.7;
313 fg->green = bg->green * 0.7;
314 fg->blue = bg->blue * 0.7;
315 fg->alpha = bg->alpha;
316}
317
318static void
319gste_squares_set_property (GObject *object,
320 guint prop_id,
321 const GValue *value,
322 GParamSpec *pspec)
323{
324 GSTE_POPSQUARES (object)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gste_squares_get_type ()))))))
;
325
326 switch (prop_id)
327 {
328 default:
329 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gste-squares.c", 329, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
330 break;
331 }
332}
333
334static void
335gste_squares_get_property (GObject *object,
336 guint prop_id,
337 GValue *value,
338 GParamSpec *pspec)
339{
340 GSTE_POPSQUARES (object)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gste_squares_get_type ()))))))
;
341
342 switch (prop_id)
343 {
344 default:
345 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gste-squares.c", 345, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
346 break;
347 }
348}
349
350static void
351setup_squares (GSTEPopsquares *pop)
352{
353 int window_width;
354 int window_height;
355 int nsquares;
356 int x, y;
357 int sw, sh, gw, gh;
358 CdkWindow *window;
359
360 window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
);
361
362 if (window == NULL((void*)0))
363 {
364 return;
365 }
366
367 gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
, &window_width, &window_height);
368
369 sw = window_width / pop->priv->subdivision;
370 sh = window_height / pop->priv->subdivision;
371
372 gw = pop->priv->subdivision;
373 gh = pop->priv->subdivision;
374 nsquares = gw * gh;
375
376 if (pop->priv->squares)
377 {
378 g_free (pop->priv->squares);
379 }
380 pop->priv->squares = g_new0 (square, nsquares)((square *) g_malloc0_n ((nsquares), sizeof (square)));
381
382 for (y = 0; y < gh; y++)
383 {
384 for (x = 0; x < gw; x++)
385 {
386 square *s = (square *) &pop->priv->squares [gw * y + x];
387 s->w = sw;
388 s->h = sh;
389 s->x = x * sw;
390 s->y = y * sh;
391 }
392 }
393}
394
395static void
396setup_colors (GSTEPopsquares *pop)
397{
398 double s1, v1, s2, v2 = 0;
399 int h1, h2 = 0;
400 int nsquares;
401 CdkRGBA fg;
402 CdkRGBA bg;
403 CdkWindow *window;
404
405 window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
);
406
407 if (window == NULL((void*)0))
408 {
409 return;
410 }
411
412 set_colors (CTK_WIDGET (pop)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((ctk_widget_get_type ()))))))
, &fg, &bg);
413
414 if (pop->priv->colors)
415 {
416 g_free (pop->priv->colors);
417 }
418 pop->priv->colors = g_new0 (CdkRGBA, pop->priv->ncolors)((CdkRGBA *) g_malloc0_n ((pop->priv->ncolors), sizeof (
CdkRGBA)))
;
419
420 rgb_to_hsv (fg.red, fg.green, fg.blue, &h1, &s1, &v1);
421 rgb_to_hsv (bg.red, bg.green, bg.blue, &h2, &s2, &v2);
422
423 make_color_ramp (h1, s1, v1,
424 h2, s2, v2,
425 pop->priv->colors,
426 pop->priv->ncolors,
427 TRUE(!(0)));
428
429 nsquares = pop->priv->subdivision * pop->priv->subdivision;
430
431 randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
432}
433
434static void
435gste_squares_real_show (CtkWidget *widget)
436{
437 GSTEPopsquares *pop = GSTE_POPSQUARES (widget)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gste_squares_get_type ()))))))
;
438
439 /* start */
440 setup_squares (pop);
441 setup_colors (pop);
442
443 if (CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->show)
444 {
445 CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->show (widget);
446 }
447}
448
449static gboolean
450gste_squares_real_draw (CtkWidget *widget,
451 cairo_t *cr)
452{
453 if (CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->draw) {
454 CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->draw (widget, cr);
455 }
456
457 draw_frame (GSTE_POPSQUARES (widget)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gste_squares_get_type ()))))))
, cr);
458
459 return TRUE(!(0));
460}
461
462static gboolean
463gste_squares_real_configure (CtkWidget *widget,
464 CdkEventConfigure *event)
465{
466 GSTEPopsquares *pop = GSTE_POPSQUARES (widget)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gste_squares_get_type ()))))))
;
467 gboolean handled = FALSE(0);
468
469 /* resize */
470
471 /* just reset everything */
472 setup_squares (pop);
473 setup_colors (pop);
474
475 /* schedule a redraw */
476 ctk_widget_queue_draw (widget);
477
478 if (CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->configure_event)
479 {
480 handled = CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->configure_event (widget, event);
481 }
482
483 return handled;
484}
485
486static void
487gste_squares_class_init (GSTEPopsquaresClass *klass)
488{
489 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
490 CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_widget_get_type ()))))))
;
491
492 parent_class = g_type_class_peek_parent (klass);
493
494 object_class->finalize = gste_squares_finalize;
495 object_class->get_property = gste_squares_get_property;
496 object_class->set_property = gste_squares_set_property;
497
498 widget_class->show = gste_squares_real_show;
499 widget_class->draw = gste_squares_real_draw;
500 widget_class->configure_event = gste_squares_real_configure;
501}
502
503static void
504draw_frame (GSTEPopsquares *pop,
505 cairo_t *cr)
506{
507 int border = 1;
508 gboolean twitch = FALSE(0);
509 int x, y;
510 int gw, gh;
511 int nsquares;
512 int window_width;
513 int window_height;
514 CdkWindow *window;
515
516 window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
);
517
518 if (window == NULL((void*)0))
519 {
520 return;
521 }
522
523 gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
,
524 &window_width,
525 &window_height);
526
527 gw = pop->priv->subdivision;
528 gh = pop->priv->subdivision;
529 nsquares = gw * gh;
530
531 for (y = 0; y < gh; y++)
532 {
533 for (x = 0; x < gw; x++)
534 {
535 square *s = (square *) &pop->priv->squares [gw * y + x];
536
537 cdk_cairo_set_source_rgba (cr, &(pop->priv->colors [s->color]));
538 cairo_rectangle (cr, s->x, s->y,
539 border ? s->w - border : s->w,
540 border ? s->h - border : s->h);
541 cairo_fill (cr);
542 s->color++;
543
544 if (s->color == pop->priv->ncolors)
545 {
546 if (twitch && ((g_random_int_range (0, 4)) == 0))
547 {
548 randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
549 }
550 else
551 {
552 s->color = g_random_int_range (0, pop->priv->ncolors);
553 }
554 }
555 }
556 }
557}
558
559static gboolean
560draw_iter (GSTEPopsquares *pop)
561{
562 ctk_widget_queue_draw (CTK_WIDGET (pop)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((ctk_widget_get_type ()))))))
);
563 return TRUE(!(0));
564}
565
566static void
567gste_squares_init (GSTEPopsquares *pop)
568{
569 int delay;
570
571 pop->priv = gste_squares_get_instance_private (pop);
572
573 pop->priv->ncolors = 128;
574 pop->priv->subdivision = 5;
575
576 delay = 25;
577 pop->priv->timeout_id = g_timeout_add (delay, (GSourceFunc)draw_iter, pop);
578}
579
580static void
581gste_squares_finalize (GObject *object)
582{
583 GSTEPopsquares *pop;
584
585 g_return_if_fail (object != NULL)do { if ((object != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "object != NULL")
; return; } } while (0)
;
586 g_return_if_fail (GSTE_IS_POPSQUARES (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((gste_squares_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GSTE_IS_POPSQUARES (object)"); return; } } while
(0)
;
587
588 pop = GSTE_POPSQUARES (object)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gste_squares_get_type ()))))))
;
589
590 g_return_if_fail (pop->priv != NULL)do { if ((pop->priv != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pop->priv != NULL"
); return; } } while (0)
;
591
592 if (pop->priv->timeout_id > 0)
593 {
594 g_source_remove (pop->priv->timeout_id);
595 pop->priv->timeout_id = 0;
596 }
597
598 g_free (pop->priv->squares);
599 g_free (pop->priv->colors);
600
601 G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), (((GType) ((20) << (2))))))))
->finalize (object);
602}