Bug Summary

File:eel/eel-canvas.c
Warning:line 609, column 37
Access to field 'prev' results in a dereference of a null pointer (loaded from field 'item_list')

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 eel-canvas.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 -fhalf-no-semantic-interposition -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 -fdebug-compilation-dir=/rootdir/eel -fcoverage-compilation-dir=/rootdir/eel -resource-dir /usr/lib/llvm-19/lib/clang/19 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Eel" -I .. -I .. -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/cafe-desktop-2.0 -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 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cail-3.0 -I /usr/include/libxml2 -D G_DISABLE_DEPRECATED -D GDK_PIXBUF_DISABLE_DEPRECATED -D DATADIR="/usr/share" -D SOURCE_DATADIR="../data" -D CAFELOCALEDIR="/usr//locale" -D PIC -internal-isystem /usr/lib/llvm-19/lib/clang/19/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 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -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.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/2025-01-24-094037-27604-1 -x c eel-canvas.c
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
4 * All rights reserved.
5 *
6 * This file is part of the Cafe Library.
7 *
8 * The Cafe Library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * The Cafe Library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with the Cafe Library; see the file COPYING.LIB. If not,
20 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23/*
24 @NOTATION@
25 */
26/*
27 * EelCanvas widget - Tk-like canvas widget for Cafe
28 *
29 * EelCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
30 * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
31 *
32 *
33 * Authors: Federico Mena <federico@nuclecu.unam.mx>
34 * Raph Levien <raph@gimp.org>
35 */
36
37/*
38 * TO-DO list for the canvas:
39 *
40 * - Allow to specify whether EelCanvasImage sizes are in units or pixels (scale or don't scale).
41 *
42 * - Implement a flag for eel_canvas_item_reparent() that tells the function to keep the item
43 * visually in the same place, that is, to keep it in the same place with respect to the canvas
44 * origin.
45 *
46 * - GC put functions for items.
47 *
48 * - Widget item (finish it).
49 *
50 * - GList *eel_canvas_gimme_all_items_contained_in_this_area (EelCanvas *canvas, Rectangle area);
51 *
52 * - Retrofit all the primitive items with microtile support.
53 *
54 * - Curve support for line item.
55 *
56 * - Arc item (Havoc has it; to be integrated in EelCanvasEllipse).
57 *
58 * - Sane font handling API.
59 *
60 * - Get_arg methods for items:
61 * - How to fetch the outline width and know whether it is in pixels or units?
62 */
63
64#include <config.h>
65
66#include <math.h>
67#include <string.h>
68#include <stdio.h>
69#include <cdk/cdkprivate.h>
70#include <ctk/ctk.h>
71#include <ctk/ctk-a11y.h>
72#include <glib/gi18n-lib.h>
73#include <cairo/cairo-gobject.h>
74#include "eel-canvas.h"
75
76#include "eel-marshal.h"
77
78static void eel_canvas_request_update (EelCanvas *canvas);
79static void group_add (EelCanvasGroup *group,
80 EelCanvasItem *item);
81static void group_remove (EelCanvasGroup *group,
82 EelCanvasItem *item);
83static void redraw_and_repick_if_mapped (EelCanvasItem *item);
84
85/*** EelCanvasItem ***/
86
87/* Some convenience stuff */
88#define GCI_UPDATE_MASK(EEL_CANVAS_UPDATE_REQUESTED | EEL_CANVAS_UPDATE_DEEP) (EEL_CANVAS_UPDATE_REQUESTED | EEL_CANVAS_UPDATE_DEEP)
89#define GCI_EPSILON1e-18 1e-18
90
91enum
92{
93 ITEM_PROP_0,
94 ITEM_PROP_PARENT,
95 ITEM_PROP_VISIBLE
96};
97
98enum
99{
100 ITEM_DESTROY,
101 ITEM_EVENT,
102 ITEM_LAST_SIGNAL
103};
104
105static void eel_canvas_item_class_init (EelCanvasItemClass *klass);
106static void eel_canvas_item_init (EelCanvasItem *item);
107static int emit_event (EelCanvas *canvas, CdkEvent *event);
108
109static guint item_signals[ITEM_LAST_SIGNAL] = { 0 };
110
111static GObjectClass *item_parent_class;
112
113static gpointer accessible_item_parent_class;
114static gpointer accessible_parent_class;
115
116
117/**
118 * eel_canvas_item_get_type:
119 *
120 * Registers the &EelCanvasItem class if necessary, and returns the type ID
121 * associated to it.
122 *
123 * Return value: The type ID of the &EelCanvasItem class.
124 **/
125GType
126eel_canvas_item_get_type (void)
127{
128 static GType canvas_item_type = 0;
129
130 if (!canvas_item_type)
131 {
132 static const GTypeInfo canvas_item_info =
133 {
134 sizeof (EelCanvasItemClass),
135 (GBaseInitFunc) NULL((void*)0),
136 (GBaseFinalizeFunc) NULL((void*)0),
137 (GClassInitFunc) eel_canvas_item_class_init,
138 NULL((void*)0), /* class_finalize */
139 NULL((void*)0), /* class_data */
140 sizeof (EelCanvasItem),
141 0, /* n_preallocs */
142 (GInstanceInitFunc) eel_canvas_item_init
143 };
144
145 canvas_item_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED(g_initially_unowned_get_type()),
146 "EelCanvasItem",
147 &canvas_item_info,
148 0);
149 }
150
151 return canvas_item_type;
152}
153
154/* Object initialization function for EelCanvasItem */
155static void
156eel_canvas_item_init (EelCanvasItem *item)
157{
158 item->flags |= EEL_CANVAS_ITEM_VISIBLE;
159}
160
161/**
162 * eel_canvas_item_new:
163 * @parent: The parent group for the new item.
164 * @type: The object type of the item.
165 * @first_arg_name: A list of object argument name/value pairs, NULL-terminated,
166 * used to configure the item. For example, "fill_color", "black",
167 * "width_units", 5.0, NULL.
168 * @Varargs:
169 *
170 * Creates a new canvas item with @parent as its parent group. The item is
171 * created at the top of its parent's stack, and starts up as visible. The item
172 * is of the specified @type, for example, it can be
173 * eel_canvas_rect_get_type(). The list of object arguments/value pairs is
174 * used to configure the item.
175 *
176 * Return value: The newly-created item.
177 **/
178EelCanvasItem *
179eel_canvas_item_new (EelCanvasGroup *parent, GType type, const gchar *first_arg_name, ...)
180{
181 EelCanvasItem *item;
182 va_list args;
183
184 g_return_val_if_fail (EEL_IS_CANVAS_GROUP (parent), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((parent)); GType __t = ((eel_canvas_group_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_GROUP (parent)"); return (((void*)0)); } }
while (0)
;
185 g_return_val_if_fail (g_type_is_a (type, eel_canvas_item_get_type ()), NULL)do { if ((((type) == (eel_canvas_item_get_type ()) || (g_type_is_a
) ((type), (eel_canvas_item_get_type ()))))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "g_type_is_a (type, eel_canvas_item_get_type ())"
); return (((void*)0)); } } while (0)
;
186
187 item = EEL_CANVAS_ITEM (g_object_new (type, NULL))((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new (type, ((void*)0)))), ((eel_canvas_item_get_type
()))))))
;
188
189 va_start (args, first_arg_name)__builtin_va_start(args, first_arg_name);
190 eel_canvas_item_construct (item, parent, first_arg_name, args);
191 va_end (args)__builtin_va_end(args);
192
193 return item;
194}
195
196
197/* Performs post-creation operations on a canvas item (adding it to its parent
198 * group, etc.)
199 */
200static void
201item_post_create_setup (EelCanvasItem *item)
202{
203 group_add (EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
, item);
204
205 redraw_and_repick_if_mapped (item);
206}
207
208/* Set_property handler for canvas items */
209static void
210eel_canvas_item_set_property (GObject *gobject, guint param_id,
211 const GValue *value, GParamSpec *pspec)
212{
213 EelCanvasItem *item;
214
215 g_return_if_fail (EEL_IS_CANVAS_ITEM (gobject))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gobject)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (gobject)"); return; } } while (0)
;
216
217 item = EEL_CANVAS_ITEM (gobject)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gobject)), ((eel_canvas_item_get_type ()))))))
;
218
219 switch (param_id)
220 {
221 case ITEM_PROP_PARENT:
222 if (item->parent != NULL((void*)0))
223 {
224 g_warning ("Cannot set `parent' argument after item has "
225 "already been constructed.");
226 }
227 else if (g_value_get_object (value))
228 {
229 item->parent = EEL_CANVAS_ITEM (g_value_get_object (value))((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_value_get_object (value))), ((eel_canvas_item_get_type
()))))))
;
230 item->canvas = item->parent->canvas;
231 item_post_create_setup (item);
232 }
233 break;
234 case ITEM_PROP_VISIBLE:
235 if (g_value_get_boolean (value))
236 {
237 eel_canvas_item_show (item);
238 }
239 else
240 {
241 eel_canvas_item_hide (item);
242 }
243 break;
244 default:
245 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, param_id, pspec)do { GObject *_glib__object = (GObject*) ((gobject)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((param_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eel-canvas.c", 245, ("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)
;
246 break;
247 }
248}
249
250/* Get_property handler for canvas items */
251static void
252eel_canvas_item_get_property (GObject *gobject, guint param_id,
253 GValue *value, GParamSpec *pspec)
254{
255 EelCanvasItem *item;
256
257 g_return_if_fail (EEL_IS_CANVAS_ITEM (gobject))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gobject)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (gobject)"); return; } } while (0)
;
258
259 item = EEL_CANVAS_ITEM (gobject)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gobject)), ((eel_canvas_item_get_type ()))))))
;
260
261 switch (param_id)
262 {
263 case ITEM_PROP_VISIBLE:
264 g_value_set_boolean (value, item->flags & EEL_CANVAS_ITEM_VISIBLE);
265 break;
266 default:
267 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, param_id, pspec)do { GObject *_glib__object = (GObject*) ((gobject)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((param_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eel-canvas.c", 267, ("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)
;
268 break;
269 }
270}
271
272/**
273 * eel_canvas_item_construct:
274 * @item: An unconstructed canvas item.
275 * @parent: The parent group for the item.
276 * @first_arg_name: The name of the first argument for configuring the item.
277 * @args: The list of arguments used to configure the item.
278 *
279 * Constructs a canvas item; meant for use only by item implementations.
280 **/
281void
282eel_canvas_item_construct (EelCanvasItem *item, EelCanvasGroup *parent,
283 const gchar *first_arg_name, va_list args)
284{
285 g_return_if_fail (EEL_IS_CANVAS_GROUP (parent))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((parent)); GType __t = ((eel_canvas_group_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_GROUP (parent)"); return; } } while (0)
;
286 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
287
288 item->parent = EEL_CANVAS_ITEM (parent)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((parent)), ((eel_canvas_item_get_type ()))))))
;
289 item->canvas = item->parent->canvas;
290
291 g_object_set_valist (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
, first_arg_name, args);
292
293 item_post_create_setup (item);
294}
295
296
297static void
298redraw_and_repick_if_mapped (EelCanvasItem *item)
299{
300 if (item->flags & EEL_CANVAS_ITEM_MAPPED)
301 {
302 eel_canvas_item_request_redraw (item);
303 item->canvas->need_repick = TRUE(!(0));
304 }
305}
306
307/* Dispose handler for canvas items */
308static void
309eel_canvas_item_dispose (GObject *object)
310{
311 EelCanvasItem *item;
312
313 g_return_if_fail (EEL_IS_CANVAS_ITEM (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (object)"); return; } } while (0)
;
314
315 item = EEL_CANVAS_ITEM (object)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eel_canvas_item_get_type ()))))))
;
316
317 if (item->canvas)
318 {
319 eel_canvas_item_request_redraw (item);
320
321 /* Make the canvas forget about us */
322
323 if (item == item->canvas->current_item)
324 {
325 item->canvas->current_item = NULL((void*)0);
326 item->canvas->need_repick = TRUE(!(0));
327 }
328
329 if (item == item->canvas->new_current_item)
330 {
331 item->canvas->new_current_item = NULL((void*)0);
332 item->canvas->need_repick = TRUE(!(0));
333 }
334
335 eel_canvas_item_ungrab (item);
336
337 if (item == item->canvas->focused_item)
338 item->canvas->focused_item = NULL((void*)0);
339
340 /* Normal destroy stuff */
341
342 if (item->flags & EEL_CANVAS_ITEM_MAPPED)
343 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->unmap) (item);
344
345 if (item->flags & EEL_CANVAS_ITEM_REALIZED)
346 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->unrealize) (item);
347
348 if (item->parent)
349 group_remove (EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
, item);
350
351 item->canvas = NULL((void*)0);
352 }
353
354 g_object_set_data (object, "in-destruction", GINT_TO_POINTER (1)((gpointer) (glong) (1)));
355 g_signal_emit (object, item_signals[ITEM_DESTROY], 0);
356
357 g_object_set_data (object, "in-destruction", NULL((void*)0));
358
359 G_OBJECT_CLASS (item_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((item_parent_class)), (((GType) ((20) << (2))))))))
->dispose (object);
360}
361
362void
363eel_canvas_item_destroy (EelCanvasItem *item)
364{
365 if (g_object_get_data (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
, "in-destruction") == NULL((void*)0)) {
366 g_object_run_dispose (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
);
367 }
368}
369
370/* Realize handler for canvas items */
371static void
372eel_canvas_item_realize (EelCanvasItem *item)
373{
374 if (item->parent && !(item->parent->flags & EEL_CANVAS_ITEM_REALIZED))
375 (* EEL_CANVAS_ITEM_GET_CLASS (item->parent)((((EelCanvasItemClass*) (((GTypeInstance*) ((item->parent
)))->g_class))))
->realize) (item->parent);
376
377 if (item->parent == NULL((void*)0) && !ctk_widget_get_realized (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
))
378 ctk_widget_realize (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
);
379
380 item->flags |= EEL_CANVAS_ITEM_REALIZED;
381
382 eel_canvas_item_request_update (item);
383}
384
385/* Unrealize handler for canvas items */
386static void
387eel_canvas_item_unrealize (EelCanvasItem *item)
388{
389 if (item->flags & EEL_CANVAS_ITEM_MAPPED)
390 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->unmap) (item);
391
392 item->flags &= ~(EEL_CANVAS_ITEM_REALIZED);
393}
394
395/* Map handler for canvas items */
396static void
397eel_canvas_item_map (EelCanvasItem *item)
398{
399 item->flags |= EEL_CANVAS_ITEM_MAPPED;
400}
401
402/* Unmap handler for canvas items */
403static void
404eel_canvas_item_unmap (EelCanvasItem *item)
405{
406 item->flags &= ~(EEL_CANVAS_ITEM_MAPPED);
407}
408
409/* Update handler for canvas items */
410static void
411eel_canvas_item_update (EelCanvasItem *item,
412 double i2w_dx G_GNUC_UNUSED__attribute__ ((__unused__)),
413 double i2w_dy G_GNUC_UNUSED__attribute__ ((__unused__)),
414 int flags G_GNUC_UNUSED__attribute__ ((__unused__)))
415{
416 item->flags &= ~(EEL_CANVAS_ITEM_NEED_UPDATE);
417 item->flags &= ~(EEL_CANVAS_ITEM_NEED_DEEP_UPDATE);
418}
419
420/*
421 * This routine invokes the update method of the item
422 * Please notice, that we take parent to canvas pixel matrix as argument
423 * unlike virtual method ::update, whose argument is item 2 canvas pixel
424 * matrix
425 *
426 * I will try to force somewhat meaningful naming for affines (Lauris)
427 * General naming rule is FROM2TO, where FROM and TO are abbreviations
428 * So p2cpx is Parent2CanvasPixel and i2cpx is Item2CanvasPixel
429 * I hope that this helps to keep track of what really happens
430 *
431 */
432
433static void
434eel_canvas_item_invoke_update (EelCanvasItem *item,
435 double i2w_dx,
436 double i2w_dy,
437 int flags)
438{
439 int child_flags;
440
441 child_flags = flags;
442
443 /* apply object flags to child flags */
444 child_flags &= ~EEL_CANVAS_UPDATE_REQUESTED;
445
446 if (item->flags & EEL_CANVAS_ITEM_NEED_UPDATE)
447 child_flags |= EEL_CANVAS_UPDATE_REQUESTED;
448
449 if (item->flags & EEL_CANVAS_ITEM_NEED_DEEP_UPDATE)
450 child_flags |= EEL_CANVAS_UPDATE_DEEP;
451
452 if (child_flags & GCI_UPDATE_MASK(EEL_CANVAS_UPDATE_REQUESTED | EEL_CANVAS_UPDATE_DEEP))
453 {
454 if (EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->update)
455 EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->update (item, i2w_dx, i2w_dy, child_flags);
456 }
457
458 /* If this fail you probably forgot to chain up to
459 * EelCanvasItem::update from a derived class */
460 g_return_if_fail (!(item->flags & EEL_CANVAS_ITEM_NEED_UPDATE))do { if ((!(item->flags & EEL_CANVAS_ITEM_NEED_UPDATE)
)) { } else { g_return_if_fail_warning ("Eel", ((const char*)
(__func__)), "!(item->flags & EEL_CANVAS_ITEM_NEED_UPDATE)"
); return; } } while (0)
;
461}
462
463/*
464 * This routine invokes the point method of the item.
465 * The arguments x, y should be in the parent item local coordinates.
466 */
467
468static double
469eel_canvas_item_invoke_point (EelCanvasItem *item, double x, double y, int cx, int cy, EelCanvasItem **actual_item)
470{
471 /* Calculate x & y in item local coordinates */
472
473 if (EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->point)
474 return EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->point (item, x, y, cx, cy, actual_item);
475
476 return 1e18;
477}
478
479/**
480 * eel_canvas_item_set:
481 * @item: A canvas item.
482 * @first_arg_name: The list of object argument name/value pairs used to configure the item.
483 * @Varargs:
484 *
485 * Configures a canvas item. The arguments in the item are set to the specified
486 * values, and the item is repainted as appropriate.
487 **/
488void
489eel_canvas_item_set (EelCanvasItem *item, const gchar *first_arg_name, ...)
490{
491 va_list args;
492
493 va_start (args, first_arg_name)__builtin_va_start(args, first_arg_name);
494 eel_canvas_item_set_valist (item, first_arg_name, args);
495 va_end (args)__builtin_va_end(args);
496}
497
498
499/**
500 * eel_canvas_item_set_valist:
501 * @item: A canvas item.
502 * @first_arg_name: The name of the first argument used to configure the item.
503 * @args: The list of object argument name/value pairs used to configure the item.
504 *
505 * Configures a canvas item. The arguments in the item are set to the specified
506 * values, and the item is repainted as appropriate.
507 **/
508void
509eel_canvas_item_set_valist (EelCanvasItem *item, const gchar *first_arg_name, va_list args)
510{
511 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
512
513 g_object_set_valist (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
, first_arg_name, args);
514
515 item->canvas->need_repick = TRUE(!(0));
516}
517
518
519/**
520 * eel_canvas_item_move:
521 * @item: A canvas item.
522 * @dx: Horizontal offset.
523 * @dy: Vertical offset.
524 *
525 * Moves a canvas item by creating an affine transformation matrix for
526 * translation by using the specified values. This happens in item
527 * local coordinate system, so if you have nontrivial transform, it
528 * most probably does not do, what you want.
529 **/
530void
531eel_canvas_item_move (EelCanvasItem *item, double dx, double dy)
532{
533 g_return_if_fail (item != NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "item != NULL"); return;
} } while (0)
;
534 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
535
536 if (!EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->translate)
537 {
538 g_warning ("Item type %s does not implement translate method.\n",
539 g_type_name (G_OBJECT_TYPE (item)(((((GTypeClass*) (((GTypeInstance*) (item))->g_class))->
g_type)))
));
540 return;
541 }
542
543 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->translate) (item, dx, dy);
544
545 if (item->flags & EEL_CANVAS_ITEM_MAPPED)
546 item->canvas->need_repick = TRUE(!(0));
547
548 if (!(item->flags & EEL_CANVAS_ITEM_NEED_DEEP_UPDATE))
549 {
550 item->flags |= EEL_CANVAS_ITEM_NEED_DEEP_UPDATE;
551 if (item->parent != NULL((void*)0))
552 eel_canvas_item_request_update (item->parent);
553 else
554 eel_canvas_request_update (item->canvas);
555 }
556
557}
558
559static void
560eel_canvas_queue_resize (EelCanvas *canvas)
561{
562 if (ctk_widget_is_drawable (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
))
563 ctk_widget_queue_resize (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
);
564}
565
566/* Convenience function to reorder items in a group's child list. This puts the
567 * specified link after the "before" link. Returns TRUE if the list was changed.
568 */
569static gboolean
570put_item_after (GList *link, GList *before)
571{
572 EelCanvasGroup *parent;
573
574 if (link == before)
20
Assuming 'link' is not equal to 'before'
21
Taking false branch
575 return FALSE(0);
576
577 parent = EEL_CANVAS_GROUP (EEL_CANVAS_ITEM (link->data)->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((EelCanvasItem*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((link->data)), ((eel_canvas_item_get_type
()))))))->parent)), ((eel_canvas_group_get_type ()))))))
;
578
579 if (before == NULL((void*)0))
22
Assuming 'before' is not equal to NULL
580 {
581 if (link == parent->item_list)
582 return FALSE(0);
583
584 link->prev->next = link->next;
585
586 if (link->next)
587 link->next->prev = link->prev;
588 else
589 parent->item_list_end = link->prev;
590
591 link->prev = before;
592 link->next = parent->item_list;
593 link->next->prev = link;
594 parent->item_list = link;
595 }
596 else
597 {
598 if ((link == parent->item_list_end) && (before == parent->item_list_end->prev))
23
Assuming 'link' is not equal to field 'item_list_end'
599 return FALSE(0);
600
601 if (link->next)
24
Assuming field 'next' is null
25
Taking false branch
602 link->next->prev = link->prev;
603
604 if (link->prev)
26
Assuming field 'prev' is null
27
Taking false branch
605 link->prev->next = link->next;
606 else
607 {
608 parent->item_list = link->next;
28
Null pointer value stored to field 'item_list'
609 parent->item_list->prev = NULL((void*)0);
29
Access to field 'prev' results in a dereference of a null pointer (loaded from field 'item_list')
610 }
611
612 link->prev = before;
613 link->next = before->next;
614
615 link->prev->next = link;
616
617 if (link->next)
618 link->next->prev = link;
619 else
620 parent->item_list_end = link;
621 }
622 return TRUE(!(0));
623}
624
625
626/**
627 * eel_canvas_item_raise:
628 * @item: A canvas item.
629 * @positions: Number of steps to raise the item.
630 *
631 * Raises the item in its parent's stack by the specified number of positions.
632 * If the number of positions is greater than the distance to the top of the
633 * stack, then the item is put at the top.
634 **/
635void
636eel_canvas_item_raise (EelCanvasItem *item, int positions)
637{
638 GList *link, *before;
639 EelCanvasGroup *parent;
640
641 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
642 g_return_if_fail (positions >= 0)do { if ((positions >= 0)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "positions >= 0"); return
; } } while (0)
;
643
644 if (!item->parent || positions == 0)
645 return;
646
647 parent = EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
;
648 link = g_list_find (parent->item_list, item);
649 g_assert (link != NULL)do { if (link != ((void*)0)) ; else g_assertion_message_expr (
"Eel", "eel-canvas.c", 649, ((const char*) (__func__)), "link != NULL"
); } while (0)
;
650
651 for (before = link; positions && before; positions--)
652 before = before->next;
653
654 if (!before)
655 before = parent->item_list_end;
656
657 if (put_item_after (link, before))
658 {
659 redraw_and_repick_if_mapped (item);
660 }
661}
662
663
664/**
665 * eel_canvas_item_lower:
666 * @item: A canvas item.
667 * @positions: Number of steps to lower the item.
668 *
669 * Lowers the item in its parent's stack by the specified number of positions.
670 * If the number of positions is greater than the distance to the bottom of the
671 * stack, then the item is put at the bottom.
672 **/
673void
674eel_canvas_item_lower (EelCanvasItem *item, int positions)
675{
676 GList *link, *before;
677 EelCanvasGroup *parent;
678
679 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
680 g_return_if_fail (positions >= 1)do { if ((positions >= 1)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "positions >= 1"); return
; } } while (0)
;
681
682 if (!item->parent || positions == 0)
683 return;
684
685 parent = EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
;
686 link = g_list_find (parent->item_list, item);
687 g_assert (link != NULL)do { if (link != ((void*)0)) ; else g_assertion_message_expr (
"Eel", "eel-canvas.c", 687, ((const char*) (__func__)), "link != NULL"
); } while (0)
;
688
689 if (link->prev)
690 for (before = link->prev; positions && before; positions--)
691 before = before->prev;
692 else
693 before = NULL((void*)0);
694
695 if (put_item_after (link, before))
696 {
697 redraw_and_repick_if_mapped (item);
698 }
699}
700
701
702/**
703 * eel_canvas_item_raise_to_top:
704 * @item: A canvas item.
705 *
706 * Raises an item to the top of its parent's stack.
707 **/
708void
709eel_canvas_item_raise_to_top (EelCanvasItem *item)
710{
711 GList *link;
712 EelCanvasGroup *parent;
713
714 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
10
Taking false branch
11
Assuming the condition is true
12
Taking true branch
13
Loop condition is false. Exiting loop
715
716 if (!item->parent)
14
Assuming field 'parent' is non-null
15
Taking false branch
717 return;
718
719 parent = EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
;
720 link = g_list_find (parent->item_list, item);
721 g_assert (link != NULL)do { if (link != ((void*)0)) ; else g_assertion_message_expr (
"Eel", "eel-canvas.c", 721, ((const char*) (__func__)), "link != NULL"
); } while (0)
;
16
Assuming 'link' is not equal to null
17
Taking true branch
18
Loop condition is false. Exiting loop
722
723 if (put_item_after (link, parent->item_list_end))
19
Calling 'put_item_after'
724 {
725 redraw_and_repick_if_mapped (item);
726 }
727}
728
729
730/**
731 * eel_canvas_item_lower_to_bottom:
732 * @item: A canvas item.
733 *
734 * Lowers an item to the bottom of its parent's stack.
735 **/
736void
737eel_canvas_item_lower_to_bottom (EelCanvasItem *item)
738{
739 GList *link;
740 EelCanvasGroup *parent;
741
742 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
743
744 if (!item->parent)
745 return;
746
747 parent = EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
;
748 link = g_list_find (parent->item_list, item);
749 g_assert (link != NULL)do { if (link != ((void*)0)) ; else g_assertion_message_expr (
"Eel", "eel-canvas.c", 749, ((const char*) (__func__)), "link != NULL"
); } while (0)
;
750
751 if (put_item_after (link, NULL((void*)0)))
752 {
753 redraw_and_repick_if_mapped (item);
754 }
755}
756
757/**
758 * eel_canvas_item_send_behind:
759 * @item: A canvas item.
760 * @behind_item: The canvas item to put item behind, or NULL
761 *
762 * Moves item to a in the position in the stacking order so that
763 * it is placed immediately below behind_item, or at the top if
764 * behind_item is NULL.
765 **/
766void
767eel_canvas_item_send_behind (EelCanvasItem *item,
768 EelCanvasItem *behind_item)
769{
770 GList *item_list;
771 int item_position, behind_position;
772
773 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
1
Assuming '__inst' is non-null
2
Taking false branch
3
Assuming field 'g_class' is null
4
Assuming the condition is true
5
Taking true branch
6
Loop condition is false. Exiting loop
774
775 if (behind_item == NULL((void*)0))
7
Assuming 'behind_item' is equal to NULL
8
Taking true branch
776 {
777 eel_canvas_item_raise_to_top (item);
9
Calling 'eel_canvas_item_raise_to_top'
778 return;
779 }
780
781 g_return_if_fail (EEL_IS_CANVAS_ITEM (behind_item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((behind_item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const
char*) (__func__)), "EEL_IS_CANVAS_ITEM (behind_item)"); return
; } } while (0)
;
782 g_return_if_fail (item->parent == behind_item->parent)do { if ((item->parent == behind_item->parent)) { } else
{ g_return_if_fail_warning ("Eel", ((const char*) (__func__)
), "item->parent == behind_item->parent"); return; } } while
(0)
;
783
784 item_list = EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
->item_list;
785
786 item_position = g_list_index (item_list, item);
787 g_assert (item_position != -1)do { if (item_position != -1) ; else g_assertion_message_expr
("Eel", "eel-canvas.c", 787, ((const char*) (__func__)), "item_position != -1"
); } while (0)
;
788 behind_position = g_list_index (item_list, behind_item);
789 g_assert (behind_position != -1)do { if (behind_position != -1) ; else g_assertion_message_expr
("Eel", "eel-canvas.c", 789, ((const char*) (__func__)), "behind_position != -1"
); } while (0)
;
790 g_assert (item_position != behind_position)do { if (item_position != behind_position) ; else g_assertion_message_expr
("Eel", "eel-canvas.c", 790, ((const char*) (__func__)), "item_position != behind_position"
); } while (0)
;
791
792 if (item_position == behind_position - 1)
793 {
794 return;
795 }
796
797 if (item_position < behind_position)
798 {
799 eel_canvas_item_raise (item, (behind_position - 1) - item_position);
800 }
801 else
802 {
803 eel_canvas_item_lower (item, item_position - behind_position);
804 }
805}
806
807/**
808 * eel_canvas_item_show:
809 * @item: A canvas item.
810 *
811 * Shows a canvas item. If the item was already shown, then no action is taken.
812 **/
813void
814eel_canvas_item_show (EelCanvasItem *item)
815{
816 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
817
818 if (!(item->flags & EEL_CANVAS_ITEM_VISIBLE))
819 {
820 item->flags |= EEL_CANVAS_ITEM_VISIBLE;
821
822 if (!(item->flags & EEL_CANVAS_ITEM_REALIZED))
823 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->realize) (item);
824
825 if (item->parent != NULL((void*)0))
826 {
827 if (!(item->flags & EEL_CANVAS_ITEM_MAPPED) &&
828 item->parent->flags & EEL_CANVAS_ITEM_MAPPED)
829 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->map) (item);
830 }
831 else
832 {
833 if (!(item->flags & EEL_CANVAS_ITEM_MAPPED) &&
834 ctk_widget_get_mapped (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
))
835 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->map) (item);
836 }
837
838 redraw_and_repick_if_mapped (item);
839 eel_canvas_queue_resize (item->canvas);
840 }
841}
842
843
844/**
845 * eel_canvas_item_hide:
846 * @item: A canvas item.
847 *
848 * Hides a canvas item. If the item was already hidden, then no action is
849 * taken.
850 **/
851void
852eel_canvas_item_hide (EelCanvasItem *item)
853{
854 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
855
856 if (item->flags & EEL_CANVAS_ITEM_VISIBLE)
857 {
858 item->flags &= ~EEL_CANVAS_ITEM_VISIBLE;
859
860 redraw_and_repick_if_mapped (item);
861
862 if (item->flags & EEL_CANVAS_ITEM_MAPPED)
863 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->unmap) (item);
864
865 eel_canvas_queue_resize (item->canvas);
866
867 /* No need to unrealize when we just want to hide */
868 }
869}
870
871/*
872 * Prepare the window for grabbing, i.e. show it.
873 */
874static void
875seat_grab_prepare_window (CdkSeat *seat G_GNUC_UNUSED__attribute__ ((__unused__)),
876 CdkWindow *window,
877 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
878{
879 cdk_window_show (window);
880}
881
882/**
883 * eel_canvas_item_grab:
884 * @item: A canvas item.
885 * @event_mask: Mask of events that will be sent to this item.
886 * @cursor: If non-NULL, the cursor that will be used while the grab is active.
887 * @event: The event, triggering the grab, if any.
888 *
889 * Specifies that all events that match the specified event mask should be sent
890 * to the specified item, and also grabs the seat by calling cdk_seat_grab().
891 * If @cursor is not NULL, then that cursor is used while the grab is active.
892 *
893 * Return value: If an item was already grabbed, it returns %CDK_GRAB_ALREADY_GRABBED. If
894 * the specified item was hidden by calling eel_canvas_item_hide(), then it
895 * returns %CDK_GRAB_NOT_VIEWABLE. Else, it returns the result of calling
896 * cdk_seat_grab().
897 **/
898CdkGrabStatus
899eel_canvas_item_grab (EelCanvasItem *item,
900 CdkEventMask event_mask,
901 CdkCursor *cursor,
902 const CdkEvent *event)
903{
904 CdkGrabStatus retval;
905 CdkDisplay *display;
906 CdkSeat *seat;
907
908 g_return_val_if_fail (EEL_IS_CANVAS_ITEM (item), CDK_GRAB_NOT_VIEWABLE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return (CDK_GRAB_NOT_VIEWABLE
); } } while (0)
;
909 g_return_val_if_fail (ctk_widget_get_mapped (CTK_WIDGET (item->canvas)),do { if ((ctk_widget_get_mapped (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((item->canvas)), ((ctk_widget_get_type
()))))))))) { } else { g_return_if_fail_warning ("Eel", ((const
char*) (__func__)), "ctk_widget_get_mapped (CTK_WIDGET (item->canvas))"
); return (CDK_GRAB_NOT_VIEWABLE); } } while (0)
910 CDK_GRAB_NOT_VIEWABLE)do { if ((ctk_widget_get_mapped (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((item->canvas)), ((ctk_widget_get_type
()))))))))) { } else { g_return_if_fail_warning ("Eel", ((const
char*) (__func__)), "ctk_widget_get_mapped (CTK_WIDGET (item->canvas))"
); return (CDK_GRAB_NOT_VIEWABLE); } } while (0)
;
911
912 if (item->canvas->grabbed_item)
913 return CDK_GRAB_ALREADY_GRABBED;
914
915 if (!(item->flags & EEL_CANVAS_ITEM_MAPPED))
916 return CDK_GRAB_NOT_VIEWABLE;
917
918 display = ctk_widget_get_display (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
);
919 seat = cdk_display_get_default_seat (display);
920
921 retval = cdk_seat_grab (seat,
922 ctk_layout_get_bin_window (CTK_LAYOUT (item->canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_layout_get_type ()))))))
),
923 CDK_SEAT_CAPABILITY_ALL_POINTING,
924 FALSE(0),
925 cursor,
926 event,
927 seat_grab_prepare_window,
928 NULL((void*)0));
929
930 if (retval != CDK_GRAB_SUCCESS)
931 return retval;
932
933 item->canvas->grabbed_item = item;
934 item->canvas->grabbed_event_mask = event_mask;
935 item->canvas->current_item = item; /* So that events go to the grabbed item */
936
937 return retval;
938}
939
940/**
941 * eel_canvas_item_ungrab:
942 * @item: A canvas item that holds a grab.
943 *
944 * Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the
945 * seat.
946 **/
947void
948eel_canvas_item_ungrab (EelCanvasItem *item)
949{
950 CdkDisplay *display;
951 CdkSeat *seat;
952
953 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
954
955 if (item->canvas->grabbed_item != item)
956 return;
957
958 display = ctk_widget_get_display (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
);
959 seat = cdk_display_get_default_seat (display);
960
961 item->canvas->grabbed_item = NULL((void*)0);
962 cdk_seat_ungrab (seat);
963}
964
965/**
966 * eel_canvas_item_w2i:
967 * @item: A canvas item.
968 * @x: X coordinate to convert (input/output value).
969 * @y: Y coordinate to convert (input/output value).
970 *
971 * Converts a coordinate pair from world coordinates to item-relative
972 * coordinates.
973 **/
974void
975eel_canvas_item_w2i (EelCanvasItem *item, double *x, double *y)
976{
977 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
978 g_return_if_fail (x != NULL)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "x != NULL"); return; } }
while (0)
;
979 g_return_if_fail (y != NULL)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "y != NULL"); return; } }
while (0)
;
980
981 item = item->parent;
982 while (item)
983 {
984 if (EEL_IS_CANVAS_GROUP (item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((eel_canvas_group_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; }))))
)
985 {
986 *x -= EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
->xpos;
987 *y -= EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
->ypos;
988 }
989
990 item = item->parent;
991 }
992}
993
994
995/**
996 * eel_canvas_item_i2w:
997 * @item: A canvas item.
998 * @x: X coordinate to convert (input/output value).
999 * @y: Y coordinate to convert (input/output value).
1000 *
1001 * Converts a coordinate pair from item-relative coordinates to world
1002 * coordinates.
1003 **/
1004void
1005eel_canvas_item_i2w (EelCanvasItem *item, double *x, double *y)
1006{
1007 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
1008 g_return_if_fail (x != NULL)do { if ((x != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "x != NULL"); return; } }
while (0)
;
1009 g_return_if_fail (y != NULL)do { if ((y != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "y != NULL"); return; } }
while (0)
;
1010
1011 item = item->parent;
1012 while (item)
1013 {
1014 if (EEL_IS_CANVAS_GROUP (item)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(item)); GType __t = ((eel_canvas_group_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; }))))
)
1015 {
1016 *x += EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
->xpos;
1017 *y += EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
->ypos;
1018 }
1019
1020 item = item->parent;
1021 }
1022}
1023
1024/* Returns whether the item is an inferior of or is equal to the parent. */
1025static int
1026is_descendant (EelCanvasItem *item, EelCanvasItem *parent)
1027{
1028 for (; item; item = item->parent)
1029 if (item == parent)
1030 return TRUE(!(0));
1031
1032 return FALSE(0);
1033}
1034
1035/**
1036 * eel_canvas_item_reparent:
1037 * @item: A canvas item.
1038 * @new_group: A canvas group.
1039 *
1040 * Changes the parent of the specified item to be the new group. The item keeps
1041 * its group-relative coordinates as for its old parent, so the item may change
1042 * its absolute position within the canvas.
1043 **/
1044void
1045eel_canvas_item_reparent (EelCanvasItem *item, EelCanvasGroup *new_group)
1046{
1047 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
1048 g_return_if_fail (EEL_IS_CANVAS_GROUP (new_group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((new_group)); GType __t = ((eel_canvas_group_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 ("Eel", ((const
char*) (__func__)), "EEL_IS_CANVAS_GROUP (new_group)"); return
; } } while (0)
;
1049
1050 /* Both items need to be in the same canvas */
1051 g_return_if_fail (item->canvas == EEL_CANVAS_ITEM (new_group)->canvas)do { if ((item->canvas == ((((EelCanvasItem*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((new_group)), ((eel_canvas_item_get_type (
)))))))->canvas)) { } else { g_return_if_fail_warning ("Eel"
, ((const char*) (__func__)), "item->canvas == EEL_CANVAS_ITEM (new_group)->canvas"
); return; } } while (0)
;
1052
1053 /* The group cannot be an inferior of the item or be the item itself --
1054 * this also takes care of the case where the item is the root item of
1055 * the canvas. */
1056 g_return_if_fail (!is_descendant (EEL_CANVAS_ITEM (new_group), item))do { if ((!is_descendant (((((EelCanvasItem*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((new_group)), ((eel_canvas_item_get_type (
))))))), item))) { } else { g_return_if_fail_warning ("Eel", (
(const char*) (__func__)), "!is_descendant (EEL_CANVAS_ITEM (new_group), item)"
); return; } } while (0)
;
1057
1058 /* Everything is ok, now actually reparent the item */
1059
1060 g_object_ref (G_OBJECT (item))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((item)), (((GType) ((20) << (2)))))
))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((item)), (((GType) ((20) << (2)))))
)))))
; /* protect it from the unref in group_remove */
1061
1062 eel_canvas_item_request_redraw (item);
1063
1064 group_remove (EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
, item);
1065 item->parent = EEL_CANVAS_ITEM (new_group)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_group)), ((eel_canvas_item_get_type ()))))))
;
1066 /* item->canvas is unchanged. */
1067 group_add (new_group, item);
1068
1069 /* Redraw and repick */
1070
1071 redraw_and_repick_if_mapped (item);
1072
1073 g_object_unref (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
);
1074}
1075
1076/**
1077 * eel_canvas_item_grab_focus:
1078 * @item: A canvas item.
1079 *
1080 * Makes the specified item take the keyboard focus, so all keyboard events will
1081 * be sent to it. If the canvas widget itself did not have the focus, it grabs
1082 * it as well.
1083 **/
1084void
1085eel_canvas_item_grab_focus (EelCanvasItem *item)
1086{
1087 EelCanvasItem *focused_item;
1088 CdkEvent ev;
1089
1090 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
1091 g_return_if_fail (ctk_widget_get_can_focus (CTK_WIDGET (item->canvas)))do { if ((ctk_widget_get_can_focus (((((CtkWidget*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((item->canvas)), ((ctk_widget_get_type
()))))))))) { } else { g_return_if_fail_warning ("Eel", ((const
char*) (__func__)), "ctk_widget_get_can_focus (CTK_WIDGET (item->canvas))"
); return; } } while (0)
;
1092
1093 focused_item = item->canvas->focused_item;
1094
1095 if (focused_item)
1096 {
1097 ev.focus_change.type = CDK_FOCUS_CHANGE;
1098 ev.focus_change.window = ctk_layout_get_bin_window (CTK_LAYOUT (item->canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_layout_get_type ()))))))
);
1099 ev.focus_change.send_event = FALSE(0);
1100 ev.focus_change.in = FALSE(0);
1101
1102 emit_event (item->canvas, &ev);
1103 }
1104
1105 item->canvas->focused_item = item;
1106 ctk_widget_grab_focus (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
);
1107
1108 if (focused_item)
1109 {
1110 ev.focus_change.type = CDK_FOCUS_CHANGE;
1111 ev.focus_change.window = ctk_layout_get_bin_window (CTK_LAYOUT (item->canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_layout_get_type ()))))))
);
1112 ev.focus_change.send_event = FALSE(0);
1113 ev.focus_change.in = TRUE(!(0));
1114
1115 emit_event (item->canvas, &ev);
1116 }
1117}
1118
1119
1120/**
1121 * eel_canvas_item_get_bounds:
1122 * @item: A canvas item.
1123 * @x1: Leftmost edge of the bounding box (return value).
1124 * @y1: Upper edge of the bounding box (return value).
1125 * @x2: Rightmost edge of the bounding box (return value).
1126 * @y2: Lower edge of the bounding box (return value).
1127 *
1128 * Queries the bounding box of a canvas item. The bounds are returned in the
1129 * coordinate system of the item's parent.
1130 **/
1131void
1132eel_canvas_item_get_bounds (EelCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
1133{
1134 double tx1, ty1, tx2, ty2;
1135
1136 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
1137
1138 tx1 = ty1 = tx2 = ty2 = 0.0;
1139
1140 /* Get the item's bounds in its coordinate system */
1141
1142 if (EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->bounds)
1143 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->bounds) (item, &tx1, &ty1, &tx2, &ty2);
1144
1145 /* Return the values */
1146
1147 if (x1)
1148 *x1 = tx1;
1149
1150 if (y1)
1151 *y1 = ty1;
1152
1153 if (x2)
1154 *x2 = tx2;
1155
1156 if (y2)
1157 *y2 = ty2;
1158}
1159
1160
1161/**
1162 * eel_canvas_item_request_update
1163 * @item: A canvas item.
1164 *
1165 * To be used only by item implementations. Requests that the canvas queue an
1166 * update for the specified item.
1167 **/
1168void
1169eel_canvas_item_request_update (EelCanvasItem *item)
1170{
1171 if (NULL((void*)0) == item->canvas)
1172 return;
1173
1174 g_return_if_fail (!item->canvas->doing_update)do { if ((!item->canvas->doing_update)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "!item->canvas->doing_update"
); return; } } while (0)
;
1175
1176 if (item->flags & EEL_CANVAS_ITEM_NEED_UPDATE)
1177 return;
1178
1179 item->flags |= EEL_CANVAS_ITEM_NEED_UPDATE;
1180
1181 if (item->parent != NULL((void*)0))
1182 {
1183 /* Recurse up the tree */
1184 eel_canvas_item_request_update (item->parent);
1185 }
1186 else
1187 {
1188 /* Have reached the top of the tree, make sure the update call gets scheduled. */
1189 eel_canvas_request_update (item->canvas);
1190 }
1191}
1192
1193/**
1194 * eel_canvas_item_request_update
1195 * @item: A canvas item.
1196 *
1197 * Convenience function that informs a canvas that the specified item needs
1198 * to be repainted. To be used by item implementations
1199 **/
1200void
1201eel_canvas_item_request_redraw (EelCanvasItem *item)
1202{
1203 if (item->flags & EEL_CANVAS_ITEM_MAPPED)
1204 eel_canvas_request_redraw (item->canvas,
1205 item->x1, item->y1,
1206 item->x2 + 1, item->y2 + 1);
1207}
1208
1209
1210
1211/*** EelCanvasGroup ***/
1212
1213
1214enum
1215{
1216 GROUP_PROP_0,
1217 GROUP_PROP_X,
1218 GROUP_PROP_Y
1219};
1220
1221
1222static void eel_canvas_group_class_init (EelCanvasGroupClass *klass);
1223static void eel_canvas_group_init (EelCanvasGroup *group);
1224static void eel_canvas_group_set_property(GObject *object,
1225 guint param_id,
1226 const GValue *value,
1227 GParamSpec *pspec);
1228static void eel_canvas_group_get_property(GObject *object,
1229 guint param_id,
1230 GValue *value,
1231 GParamSpec *pspec);
1232
1233static void eel_canvas_group_destroy (EelCanvasItem *object);
1234
1235static void eel_canvas_group_update (EelCanvasItem *item,
1236 double i2w_dx,
1237 double i2w_dy,
1238 int flags);
1239static void eel_canvas_group_unrealize (EelCanvasItem *item);
1240static void eel_canvas_group_map (EelCanvasItem *item);
1241static void eel_canvas_group_unmap (EelCanvasItem *item);
1242static void eel_canvas_group_draw (EelCanvasItem *item,
1243 cairo_t *cr,
1244 cairo_region_t *region);
1245static double eel_canvas_group_point (EelCanvasItem *item, double x, double y,
1246 int cx, int cy,
1247 EelCanvasItem **actual_item);
1248static void eel_canvas_group_translate (EelCanvasItem *item, double dx, double dy);
1249static void eel_canvas_group_bounds (EelCanvasItem *item, double *x1, double *y1,
1250 double *x2, double *y2);
1251
1252
1253static EelCanvasItemClass *group_parent_class;
1254
1255
1256/**
1257 * eel_canvas_group_get_type:
1258 *
1259 * Registers the &EelCanvasGroup class if necessary, and returns the type ID
1260 * associated to it.
1261 *
1262 * Return value: The type ID of the &EelCanvasGroup class.
1263 **/
1264GType
1265eel_canvas_group_get_type (void)
1266{
1267 static GType group_type = 0;
1268
1269 if (!group_type)
1270 {
1271 static const GTypeInfo group_info =
1272 {
1273 sizeof (EelCanvasGroupClass),
1274 (GBaseInitFunc) NULL((void*)0),
1275 (GBaseFinalizeFunc) NULL((void*)0),
1276 (GClassInitFunc) eel_canvas_group_class_init,
1277 NULL((void*)0), /* class_finalize */
1278 NULL((void*)0), /* class_data */
1279 sizeof (EelCanvasGroup),
1280 0, /* n_preallocs */
1281 (GInstanceInitFunc) eel_canvas_group_init
1282
1283
1284 };
1285
1286 group_type = g_type_register_static (eel_canvas_item_get_type (),
1287 "EelCanvasGroup",
1288 &group_info,
1289 0);
1290 }
1291
1292 return group_type;
1293}
1294
1295/* Class initialization function for EelCanvasGroupClass */
1296static void
1297eel_canvas_group_class_init (EelCanvasGroupClass *klass)
1298{
1299 GObjectClass *gobject_class;
1300 EelCanvasItemClass *item_class;
1301
1302 gobject_class = (GObjectClass *) klass;
1303 item_class = (EelCanvasItemClass *) klass;
1304
1305 group_parent_class = g_type_class_peek_parent (klass);
1306
1307 gobject_class->set_property = eel_canvas_group_set_property;
1308 gobject_class->get_property = eel_canvas_group_get_property;
1309
1310 g_object_class_install_property
1311 (gobject_class, GROUP_PROP_X,
1312 g_param_spec_double ("x",
1313 _("X")((char *) g_dgettext ("baul", "X")),
1314 _("X")((char *) g_dgettext ("baul", "X")),
1315 -G_MAXDOUBLE1.7976931348623157e+308, G_MAXDOUBLE1.7976931348623157e+308, 0.0,
1316 G_PARAM_READWRITE));
1317 g_object_class_install_property
1318 (gobject_class, GROUP_PROP_Y,
1319 g_param_spec_double ("y",
1320 _("Y")((char *) g_dgettext ("baul", "Y")),
1321 _("Y")((char *) g_dgettext ("baul", "Y")),
1322 -G_MAXDOUBLE1.7976931348623157e+308, G_MAXDOUBLE1.7976931348623157e+308, 0.0,
1323 G_PARAM_READWRITE));
1324
1325 item_class->destroy = eel_canvas_group_destroy;
1326 item_class->update = eel_canvas_group_update;
1327 item_class->unrealize = eel_canvas_group_unrealize;
1328 item_class->map = eel_canvas_group_map;
1329 item_class->unmap = eel_canvas_group_unmap;
1330 item_class->draw = eel_canvas_group_draw;
1331 item_class->point = eel_canvas_group_point;
1332 item_class->translate = eel_canvas_group_translate;
1333 item_class->bounds = eel_canvas_group_bounds;
1334}
1335
1336/* Object initialization function for EelCanvasGroup */
1337static void
1338eel_canvas_group_init (EelCanvasGroup *group)
1339{
1340 group->xpos = 0.0;
1341 group->ypos = 0.0;
1342}
1343
1344/* Set_property handler for canvas groups */
1345static void
1346eel_canvas_group_set_property (GObject *gobject, guint param_id,
1347 const GValue *value, GParamSpec *pspec)
1348{
1349 EelCanvasItem *item;
1350 EelCanvasGroup *group;
1351 double old;
1352 gboolean moved;
1353
1354 g_return_if_fail (EEL_IS_CANVAS_GROUP (gobject))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gobject)); GType __t = ((eel_canvas_group_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 ("Eel", ((const char
*) (__func__)), "EEL_IS_CANVAS_GROUP (gobject)"); return; } }
while (0)
;
1355
1356 item = EEL_CANVAS_ITEM (gobject)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gobject)), ((eel_canvas_item_get_type ()))))))
;
1357 group = EEL_CANVAS_GROUP (gobject)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gobject)), ((eel_canvas_group_get_type ()))))))
;
1358
1359 moved = FALSE(0);
1360 switch (param_id)
1361 {
1362 case GROUP_PROP_X:
1363 old = group->xpos;
1364 group->xpos = g_value_get_double (value);
1365 if (old != group->xpos)
1366 moved = TRUE(!(0));
1367 break;
1368
1369 case GROUP_PROP_Y:
1370 old = group->ypos;
1371 group->ypos = g_value_get_double (value);
1372 if (old != group->ypos)
1373 moved = TRUE(!(0));
1374 break;
1375
1376 default:
1377 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, param_id, pspec)do { GObject *_glib__object = (GObject*) ((gobject)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((param_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eel-canvas.c", 1377, ("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)
;
1378 break;
1379 }
1380
1381 if (moved)
1382 {
1383 item->flags |= EEL_CANVAS_ITEM_NEED_DEEP_UPDATE;
1384 if (item->parent != NULL((void*)0))
1385 eel_canvas_item_request_update (item->parent);
1386 else
1387 eel_canvas_request_update (item->canvas);
1388 }
1389}
1390
1391/* Get_property handler for canvas groups */
1392static void
1393eel_canvas_group_get_property (GObject *gobject, guint param_id,
1394 GValue *value, GParamSpec *pspec)
1395{
1396 EelCanvasGroup *group;
1397
1398 g_return_if_fail (EEL_IS_CANVAS_GROUP (gobject))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((gobject)); GType __t = ((eel_canvas_group_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 ("Eel", ((const char
*) (__func__)), "EEL_IS_CANVAS_GROUP (gobject)"); return; } }
while (0)
;
1399
1400 group = EEL_CANVAS_GROUP (gobject)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((gobject)), ((eel_canvas_group_get_type ()))))))
;
1401
1402 switch (param_id)
1403 {
1404 case GROUP_PROP_X:
1405 g_value_set_double (value, group->xpos);
1406 break;
1407
1408 case GROUP_PROP_Y:
1409 g_value_set_double (value, group->ypos);
1410 break;
1411
1412 default:
1413 G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, param_id, pspec)do { GObject *_glib__object = (GObject*) ((gobject)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((param_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "eel-canvas.c", 1413, ("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)
;
1414 break;
1415 }
1416}
1417
1418/* Destroy handler for canvas groups */
1419static void
1420eel_canvas_group_destroy (EelCanvasItem *object)
1421{
1422 EelCanvasGroup *group;
1423 GList *list;
1424 EelCanvasItem *child = NULL((void*)0);
1425
1426 g_return_if_fail (EEL_IS_CANVAS_GROUP (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eel_canvas_group_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_GROUP (object)"); return; } } while (0)
;
1427
1428 group = EEL_CANVAS_GROUP (object)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eel_canvas_group_get_type ()))))))
;
1429
1430 list = group->item_list;
1431 while (list)
1432 {
1433 child = list->data;
1434 list = list->next;
1435
1436 eel_canvas_item_destroy (child);
1437 }
1438
1439 if (EEL_CANVAS_ITEM_CLASS (group_parent_class)((((EelCanvasItemClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((group_parent_class)), ((eel_canvas_item_get_type ())))))
)
->destroy)
1440 (* EEL_CANVAS_ITEM_CLASS (group_parent_class)((((EelCanvasItemClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((group_parent_class)), ((eel_canvas_item_get_type ())))))
)
->destroy) (object);
1441}
1442
1443/* Update handler for canvas groups */
1444static void
1445eel_canvas_group_update (EelCanvasItem *item, double i2w_dx, double i2w_dy, int flags)
1446{
1447 EelCanvasGroup *group;
1448 GList *list;
1449 EelCanvasItem *i;
1450 double bbox_x0, bbox_y0, bbox_x1, bbox_y1;
1451 gboolean first = TRUE(!(0));
1452
1453 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1454
1455 (* group_parent_class->update) (item, i2w_dx, i2w_dy, flags);
1456
1457 bbox_x0 = 0;
1458 bbox_y0 = 0;
1459 bbox_x1 = 0;
1460 bbox_y1 = 0;
1461
1462 for (list = group->item_list; list; list = list->next)
1463 {
1464 i = list->data;
1465
1466 eel_canvas_item_invoke_update (i, i2w_dx + group->xpos, i2w_dy + group->ypos, flags);
1467
1468 if (first)
1469 {
1470 first = FALSE(0);
1471 bbox_x0 = i->x1;
1472 bbox_y0 = i->y1;
1473 bbox_x1 = i->x2;
1474 bbox_y1 = i->y2;
1475 }
1476 else
1477 {
1478 bbox_x0 = MIN (bbox_x0, i->x1)(((bbox_x0) < (i->x1)) ? (bbox_x0) : (i->x1));
1479 bbox_y0 = MIN (bbox_y0, i->y1)(((bbox_y0) < (i->y1)) ? (bbox_y0) : (i->y1));
1480 bbox_x1 = MAX (bbox_x1, i->x2)(((bbox_x1) > (i->x2)) ? (bbox_x1) : (i->x2));
1481 bbox_y1 = MAX (bbox_y1, i->y2)(((bbox_y1) > (i->y2)) ? (bbox_y1) : (i->y2));
1482 }
1483 }
1484 item->x1 = bbox_x0;
1485 item->y1 = bbox_y0;
1486 item->x2 = bbox_x1;
1487 item->y2 = bbox_y1;
1488}
1489
1490/* Unrealize handler for canvas groups */
1491static void
1492eel_canvas_group_unrealize (EelCanvasItem *item)
1493{
1494 EelCanvasGroup *group;
1495 GList *list;
1496 EelCanvasItem *i = NULL((void*)0);
1497
1498 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1499
1500 /* Unmap group before children to avoid flash */
1501 if (item->flags & EEL_CANVAS_ITEM_MAPPED)
1502 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->unmap) (item);
1503
1504 for (list = group->item_list; list; list = list->next)
1505 {
1506 i = list->data;
1507
1508 if (i->flags & EEL_CANVAS_ITEM_REALIZED)
1509 (* EEL_CANVAS_ITEM_GET_CLASS (i)((((EelCanvasItemClass*) (((GTypeInstance*) ((i)))->g_class
))))
->unrealize) (i);
1510 }
1511
1512 (* group_parent_class->unrealize) (item);
1513}
1514
1515/* Map handler for canvas groups */
1516static void
1517eel_canvas_group_map (EelCanvasItem *item)
1518{
1519 EelCanvasGroup *group;
1520 GList *list;
1521 EelCanvasItem *i = NULL((void*)0);
1522
1523 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1524
1525 for (list = group->item_list; list; list = list->next)
1526 {
1527 i = list->data;
1528
1529 if (i->flags & EEL_CANVAS_ITEM_VISIBLE &&
1530 !(i->flags & EEL_CANVAS_ITEM_MAPPED))
1531 {
1532 if (!(i->flags & EEL_CANVAS_ITEM_REALIZED))
1533 (* EEL_CANVAS_ITEM_GET_CLASS (i)((((EelCanvasItemClass*) (((GTypeInstance*) ((i)))->g_class
))))
->realize) (i);
1534
1535 (* EEL_CANVAS_ITEM_GET_CLASS (i)((((EelCanvasItemClass*) (((GTypeInstance*) ((i)))->g_class
))))
->map) (i);
1536 }
1537 }
1538
1539 (* group_parent_class->map) (item);
1540}
1541
1542/* Unmap handler for canvas groups */
1543static void
1544eel_canvas_group_unmap (EelCanvasItem *item)
1545{
1546 EelCanvasGroup *group;
1547 GList *list;
1548 EelCanvasItem *i = NULL((void*)0);
1549
1550 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1551
1552 for (list = group->item_list; list; list = list->next)
1553 {
1554 i = list->data;
1555
1556 if (i->flags & EEL_CANVAS_ITEM_MAPPED)
1557 (* EEL_CANVAS_ITEM_GET_CLASS (i)((((EelCanvasItemClass*) (((GTypeInstance*) ((i)))->g_class
))))
->unmap) (i);
1558 }
1559
1560 (* group_parent_class->unmap) (item);
1561}
1562
1563/* Draw handler for canvas groups */
1564static void
1565eel_canvas_group_draw (EelCanvasItem *item,
1566 cairo_t *cr,
1567 cairo_region_t *region)
1568{
1569 EelCanvasGroup *group;
1570 GList *list;
1571 EelCanvasItem *child = NULL((void*)0);
1572
1573 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1574
1575 for (list = group->item_list; list; list = list->next)
1576 {
1577 child = list->data;
1578
1579 if ((child->flags & EEL_CANVAS_ITEM_MAPPED) &&
1580 (EEL_CANVAS_ITEM_GET_CLASS (child)((((EelCanvasItemClass*) (((GTypeInstance*) ((child)))->g_class
))))
->draw))
1581 {
1582 CdkRectangle child_rect;
1583
1584 child_rect.x = child->x1;
1585 child_rect.y = child->y1;
1586 child_rect.width = child->x2 - child->x1 + 1;
1587 child_rect.height = child->y2 - child->y1 + 1;
1588
1589 if (cairo_region_contains_rectangle (region, &child_rect) != CAIRO_REGION_OVERLAP_OUT)
1590 EEL_CANVAS_ITEM_GET_CLASS (child)((((EelCanvasItemClass*) (((GTypeInstance*) ((child)))->g_class
))))
->draw (child, cr, region);
1591 }
1592 }
1593}
1594
1595/* Point handler for canvas groups */
1596static double
1597eel_canvas_group_point (EelCanvasItem *item, double x, double y, int cx, int cy,
1598 EelCanvasItem **actual_item)
1599{
1600 int x1, y1, x2, y2;
1601 double gx, gy;
1602 double dist, best;
1603 int has_point;
1604 EelCanvasGroup *group;
1605 GList *list;
1606 EelCanvasItem *point_item;
1607 EelCanvasItem *child = NULL((void*)0);
1608
1609 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1610
1611 x1 = cx - item->canvas->close_enough;
1612 y1 = cy - item->canvas->close_enough;
1613 x2 = cx + item->canvas->close_enough;
1614 y2 = cy + item->canvas->close_enough;
1615
1616 best = 0.0;
1617 *actual_item = NULL((void*)0);
1618
1619 gx = x - group->xpos;
1620 gy = y - group->ypos;
1621
1622 dist = 0.0; /* keep gcc happy */
1623
1624 for (list = group->item_list; list; list = list->next)
1625 {
1626 child = list->data;
1627
1628 if ((child->x1 > x2) || (child->y1 > y2) || (child->x2 < x1) || (child->y2 < y1))
1629 continue;
1630
1631 point_item = NULL((void*)0); /* cater for incomplete item implementations */
1632
1633 if ((child->flags & EEL_CANVAS_ITEM_MAPPED)
1634 && EEL_CANVAS_ITEM_GET_CLASS (child)((((EelCanvasItemClass*) (((GTypeInstance*) ((child)))->g_class
))))
->point)
1635 {
1636 dist = eel_canvas_item_invoke_point (child, gx, gy, cx, cy, &point_item);
1637 has_point = TRUE(!(0));
1638 }
1639 else
1640 has_point = FALSE(0);
1641
1642 if (has_point
1643 && point_item
1644 && ((int) (dist * item->canvas->pixels_per_unit + 0.5)
1645 <= item->canvas->close_enough))
1646 {
1647 best = dist;
1648 *actual_item = point_item;
1649 }
1650 }
1651
1652 return best;
1653}
1654
1655void
1656eel_canvas_group_translate (EelCanvasItem *item, double dx, double dy)
1657{
1658 EelCanvasGroup *group;
1659
1660 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1661
1662 group->xpos += dx;
1663 group->ypos += dy;
1664}
1665
1666/* Bounds handler for canvas groups */
1667static void
1668eel_canvas_group_bounds (EelCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
1669{
1670 EelCanvasGroup *group;
1671 EelCanvasItem *child;
1672 GList *list;
1673 double tx1, ty1, tx2, ty2;
1674 double minx, miny, maxx, maxy;
1675 int set;
1676
1677 group = EEL_CANVAS_GROUP (item)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), ((eel_canvas_group_get_type ()))))))
;
1678
1679 /* Get the bounds of the first visible item */
1680
1681 child = NULL((void*)0); /* Unnecessary but eliminates a warning. */
1682
1683 set = FALSE(0);
1684
1685 for (list = group->item_list; list; list = list->next)
1686 {
1687 child = list->data;
1688
1689 if (child->flags & EEL_CANVAS_ITEM_MAPPED)
1690 {
1691 set = TRUE(!(0));
1692 eel_canvas_item_get_bounds (child, &minx, &miny, &maxx, &maxy);
1693 break;
1694 }
1695 }
1696
1697 /* If there were no visible items, return an empty bounding box */
1698
1699 if (!set)
1700 {
1701 *x1 = *y1 = *x2 = *y2 = 0.0;
1702 return;
1703 }
1704
1705 /* Now we can grow the bounds using the rest of the items */
1706
1707 list = list->next;
1708
1709 for (; list; list = list->next)
1710 {
1711 child = list->data;
1712
1713 if (!(child->flags & EEL_CANVAS_ITEM_MAPPED))
1714 continue;
1715
1716 eel_canvas_item_get_bounds (child, &tx1, &ty1, &tx2, &ty2);
1717
1718 if (tx1 < minx)
1719 minx = tx1;
1720
1721 if (ty1 < miny)
1722 miny = ty1;
1723
1724 if (tx2 > maxx)
1725 maxx = tx2;
1726
1727 if (ty2 > maxy)
1728 maxy = ty2;
1729 }
1730
1731 /* Make the bounds be relative to our parent's coordinate system */
1732
1733 if (item->parent)
1734 {
1735 minx += group->xpos;
1736 miny += group->ypos;
1737 maxx += group->xpos;
1738 maxy += group->ypos;
1739 }
1740
1741 *x1 = minx;
1742 *y1 = miny;
1743 *x2 = maxx;
1744 *y2 = maxy;
1745}
1746
1747/* Adds an item to a group */
1748static void
1749group_add (EelCanvasGroup *group, EelCanvasItem *item)
1750{
1751 g_object_ref_sink (item)((__typeof__ (item)) (g_object_ref_sink) (item));
1752
1753 if (!group->item_list)
1754 {
1755 group->item_list = g_list_append (group->item_list, item);
1756 group->item_list_end = group->item_list;
1757 }
1758 else
1759 group->item_list_end = g_list_append (group->item_list_end, item)->next;
1760
1761 if (item->flags & EEL_CANVAS_ITEM_VISIBLE &&
1762 group->item.flags & EEL_CANVAS_ITEM_MAPPED)
1763 {
1764 if (!(item->flags & EEL_CANVAS_ITEM_REALIZED))
1765 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->realize) (item);
1766
1767 if (!(item->flags & EEL_CANVAS_ITEM_MAPPED))
1768 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->map) (item);
1769 }
1770
1771 if (item->flags & EEL_CANVAS_ITEM_VISIBLE)
1772 eel_canvas_queue_resize (EEL_CANVAS_ITEM (group)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((group)), ((eel_canvas_item_get_type ()))))))
->canvas);
1773}
1774
1775/* Removes an item from a group */
1776static void
1777group_remove (EelCanvasGroup *group, EelCanvasItem *item)
1778{
1779 GList *children;
1780
1781 g_return_if_fail (EEL_IS_CANVAS_GROUP (group))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((group)); GType __t = ((eel_canvas_group_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_GROUP (group)"); return; } } while (0)
;
1782 g_return_if_fail (EEL_IS_CANVAS_ITEM (item))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item)); GType __t = ((eel_canvas_item_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS_ITEM (item)"); return; } } while (0)
;
1783
1784 for (children = group->item_list; children; children = children->next)
1785 if (children->data == item)
1786 {
1787 if (item->flags & EEL_CANVAS_ITEM_MAPPED) {
1788 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->unmap) (item);
1789 }
1790
1791 if (item->flags & EEL_CANVAS_ITEM_REALIZED)
1792 (* EEL_CANVAS_ITEM_GET_CLASS (item)((((EelCanvasItemClass*) (((GTypeInstance*) ((item)))->g_class
))))
->unrealize) (item);
1793
1794 if (item->flags & EEL_CANVAS_ITEM_VISIBLE)
1795 eel_canvas_queue_resize (item->canvas);
1796
1797 /* Unparent the child */
1798
1799 item->parent = NULL((void*)0);
1800 /* item->canvas = NULL; */
1801 g_object_unref (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
);
1802
1803 /* Remove it from the list */
1804
1805 if (children == group->item_list_end)
1806 group->item_list_end = children->prev;
1807
1808 group->item_list = g_list_remove_link (group->item_list, children);
1809 g_list_free (children);
1810 break;
1811 }
1812}
1813
1814
1815/*** EelCanvas ***/
1816
1817
1818enum
1819{
1820 DRAW_BACKGROUND,
1821 LAST_SIGNAL
1822};
1823
1824static void eel_canvas_class_init (EelCanvasClass *klass);
1825static void eel_canvas_init (EelCanvas *canvas);
1826static void eel_canvas_destroy (CtkWidget *object);
1827static void eel_canvas_map (CtkWidget *widget);
1828static void eel_canvas_unmap (CtkWidget *widget);
1829static void eel_canvas_realize (CtkWidget *widget);
1830static void eel_canvas_unrealize (CtkWidget *widget);
1831static void eel_canvas_size_allocate (CtkWidget *widget,
1832 CtkAllocation *allocation);
1833static gint eel_canvas_button (CtkWidget *widget,
1834 CdkEventButton *event);
1835static gint eel_canvas_motion (CtkWidget *widget,
1836 CdkEventMotion *event);
1837static gint eel_canvas_draw (CtkWidget *widget,
1838 cairo_t *cr);
1839static gint eel_canvas_key (CtkWidget *widget,
1840 CdkEventKey *event);
1841static gint eel_canvas_crossing (CtkWidget *widget,
1842 CdkEventCrossing *event);
1843static gint eel_canvas_focus_in (CtkWidget *widget,
1844 CdkEventFocus *event);
1845static gint eel_canvas_focus_out (CtkWidget *widget,
1846 CdkEventFocus *event);
1847static void eel_canvas_request_update_real (EelCanvas *canvas);
1848static void eel_canvas_draw_background (EelCanvas *canvas,
1849 cairo_t *cr);
1850
1851static CtkLayoutClass *canvas_parent_class;
1852
1853static guint canvas_signals[LAST_SIGNAL] = { 0 };
1854
1855/**
1856 * eel_canvas_get_type:
1857 *
1858 * Registers the &EelCanvas class if necessary, and returns the type ID
1859 * associated to it.
1860 *
1861 * Return value: The type ID of the &EelCanvas class.
1862 **/
1863GType
1864eel_canvas_get_type (void)
1865{
1866 static GType canvas_type = 0;
1867
1868 if (!canvas_type)
1869 {
1870 static const GTypeInfo canvas_info =
1871 {
1872 sizeof (EelCanvasClass),
1873 (GBaseInitFunc) NULL((void*)0),
1874 (GBaseFinalizeFunc) NULL((void*)0),
1875 (GClassInitFunc) eel_canvas_class_init,
1876 NULL((void*)0), /* class_finalize */
1877 NULL((void*)0), /* class_data */
1878 sizeof (EelCanvas),
1879 0, /* n_preallocs */
1880 (GInstanceInitFunc) eel_canvas_init
1881 };
1882
1883 canvas_type = g_type_register_static (ctk_layout_get_type (),
1884 "EelCanvas",
1885 &canvas_info,
1886 0);
1887 }
1888
1889 return canvas_type;
1890}
1891
1892static void
1893eel_canvas_get_property (GObject *object,
1894 guint prop_id,
1895 GValue *value G_GNUC_UNUSED__attribute__ ((__unused__)),
1896 GParamSpec *pspec)
1897{
1898 switch (prop_id)
1899 {
1900 default:
1901 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'"
, "eel-canvas.c", 1901, ("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)
;
1902 break;
1903 }
1904}
1905
1906static void
1907eel_canvas_set_property (GObject *object,
1908 guint prop_id,
1909 const GValue *value G_GNUC_UNUSED__attribute__ ((__unused__)),
1910 GParamSpec *pspec)
1911{
1912 switch (prop_id)
1913 {
1914 default:
1915 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'"
, "eel-canvas.c", 1915, ("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)
;
1916 break;
1917 }
1918}
1919
1920static void
1921eel_canvas_accessible_adjustment_changed (CtkAdjustment *adjustment G_GNUC_UNUSED__attribute__ ((__unused__)),
1922 gpointer data)
1923{
1924 AtkObject *atk_obj;
1925
1926 /* The scrollbars have changed */
1927 atk_obj = ATK_OBJECT (data)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((atk_object_get_type ()))))))
;
1928
1929 g_signal_emit_by_name (atk_obj, "visible_data_changed");
1930}
1931
1932static void
1933eel_canvas_accessible_initialize (AtkObject *obj,
1934 gpointer data)
1935{
1936 EelCanvas *canvas;
1937
1938 if (ATK_OBJECT_CLASS (accessible_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((accessible_parent_class)), ((atk_object_get_type ())))))
)
->initialize != NULL((void*)0))
1939 ATK_OBJECT_CLASS (accessible_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((accessible_parent_class)), ((atk_object_get_type ())))))
)
->initialize (obj, data);
1940
1941 canvas = EEL_CANVAS (data)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eel_canvas_get_type ()))))))
;
1942 g_signal_connect (ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (canvas)),g_signal_connect_data ((ctk_scrollable_get_hadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
1943 "value_changed",g_signal_connect_data ((ctk_scrollable_get_hadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
1944 G_CALLBACK (eel_canvas_accessible_adjustment_changed),g_signal_connect_data ((ctk_scrollable_get_hadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
1945 obj)g_signal_connect_data ((ctk_scrollable_get_hadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
;
1946 g_signal_connect (ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (canvas)),g_signal_connect_data ((ctk_scrollable_get_vadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
1947 "value_changed",g_signal_connect_data ((ctk_scrollable_get_vadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
1948 G_CALLBACK (eel_canvas_accessible_adjustment_changed),g_signal_connect_data ((ctk_scrollable_get_vadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
1949 obj)g_signal_connect_data ((ctk_scrollable_get_vadjustment (((((CtkScrollable
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((canvas
)), ((ctk_scrollable_get_type ())))))))), ("value_changed"), (
((GCallback) (eel_canvas_accessible_adjustment_changed))), (obj
), ((void*)0), (GConnectFlags) 0)
;
1950
1951 obj->role = ATK_ROLE_LAYERED_PANE;
1952}
1953
1954static gint
1955eel_canvas_accessible_get_n_children (AtkObject* obj)
1956{
1957 CtkAccessible *accessible;
1958 CtkWidget *widget;
1959 EelCanvas *canvas;
1960 EelCanvasGroup *root_group;
1961
1962 accessible = CTK_ACCESSIBLE (obj)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_accessible_get_type ()))))))
;
1963 widget = ctk_accessible_get_widget (accessible);
1964 if (widget == NULL((void*)0))
1965 {
1966 /* State is defunct */
1967 return 0;
1968 }
1969
1970 g_return_val_if_fail (EEL_IS_CANVAS (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return (0); } } while (0)
;
1971
1972 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
1973 root_group = eel_canvas_root (canvas);
1974 g_return_val_if_fail (root_group, 0)do { if ((root_group)) { } else { g_return_if_fail_warning ("Eel"
, ((const char*) (__func__)), "root_group"); return (0); } } while
(0)
;
1975 return 1;
1976}
1977
1978static AtkObject*
1979eel_canvas_accessible_ref_child (AtkObject *obj,
1980 gint i)
1981{
1982 CtkAccessible *accessible;
1983 CtkWidget *widget;
1984 EelCanvas *canvas;
1985 EelCanvasGroup *root_group;
1986 AtkObject *atk_object;
1987
1988 /* Canvas only has one child, so return NULL if index is non zero */
1989 if (i != 0)
1990 {
1991 return NULL((void*)0);
1992 }
1993
1994 accessible = CTK_ACCESSIBLE (obj)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((ctk_accessible_get_type ()))))))
;
1995 widget = ctk_accessible_get_widget (accessible);
1996 if (widget == NULL((void*)0))
1997 {
1998 /* State is defunct */
1999 return NULL((void*)0);
2000 }
2001
2002 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2003 root_group = eel_canvas_root (canvas);
2004 g_return_val_if_fail (root_group, NULL)do { if ((root_group)) { } else { g_return_if_fail_warning ("Eel"
, ((const char*) (__func__)), "root_group"); return (((void*)
0)); } } while (0)
;
2005 atk_object = atk_gobject_accessible_for_object (G_OBJECT (root_group)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((root_group)), (((GType) ((20) << (2))))))))
);
2006 g_object_ref (atk_object)((__typeof__ (atk_object)) (g_object_ref) (atk_object));
2007
2008 g_warning ("Accessible support for FooGroup needs to be implemented");
2009
2010 return atk_object;
2011}
2012
2013G_DEFINE_TYPE (EelCanvasAccessible, eel_canvas_accessible, CTK_TYPE_CONTAINER_ACCESSIBLE)static void eel_canvas_accessible_init (EelCanvasAccessible *
self); static void eel_canvas_accessible_class_init (EelCanvasAccessibleClass
*klass); static GType eel_canvas_accessible_get_type_once (void
); static gpointer eel_canvas_accessible_parent_class = ((void
*)0); static gint EelCanvasAccessible_private_offset; static void
eel_canvas_accessible_class_intern_init (gpointer klass) { eel_canvas_accessible_parent_class
= g_type_class_peek_parent (klass); if (EelCanvasAccessible_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EelCanvasAccessible_private_offset
); eel_canvas_accessible_class_init ((EelCanvasAccessibleClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
eel_canvas_accessible_get_instance_private (EelCanvasAccessible
*self) { return (((gpointer) ((guint8*) (self) + (glong) (EelCanvasAccessible_private_offset
)))); } GType eel_canvas_accessible_get_type (void) { static GType
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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_accessible_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_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType eel_canvas_accessible_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((ctk_container_accessible_get_type ()), g_intern_static_string
("EelCanvasAccessible"), sizeof (EelCanvasAccessibleClass), (
GClassInitFunc)(void (*)(void)) eel_canvas_accessible_class_intern_init
, sizeof (EelCanvasAccessible), (GInstanceInitFunc)(void (*)(
void)) eel_canvas_accessible_init, (GTypeFlags) 0); { {{};} }
return g_define_type_id; }
2014
2015static void
2016eel_canvas_accessible_class_init (EelCanvasAccessibleClass *klass)
2017{
2018 AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((atk_object_get_type ()))))))
;
2019 accessible_parent_class = g_type_class_peek_parent (atk_class);
2020
2021 atk_class->initialize = eel_canvas_accessible_initialize;
2022 atk_class->get_n_children = eel_canvas_accessible_get_n_children;
2023 atk_class->ref_child = eel_canvas_accessible_ref_child;
2024}
2025
2026static void
2027eel_canvas_accessible_init (EelCanvasAccessible *accessible G_GNUC_UNUSED__attribute__ ((__unused__)))
2028{
2029}
2030
2031/* Class initialization function for EelCanvasClass */
2032static void
2033eel_canvas_class_init (EelCanvasClass *klass)
2034{
2035 GObjectClass *gobject_class;
2036 CtkWidgetClass *widget_class;
2037
2038 gobject_class = (GObjectClass *)klass;
2039 widget_class = (CtkWidgetClass *) klass;
2040
2041 canvas_parent_class = g_type_class_peek_parent (klass);
2042
2043 gobject_class->set_property = eel_canvas_set_property;
2044 gobject_class->get_property = eel_canvas_get_property;
2045
2046 widget_class->destroy = eel_canvas_destroy;
2047 widget_class->map = eel_canvas_map;
2048 widget_class->unmap = eel_canvas_unmap;
2049 widget_class->realize = eel_canvas_realize;
2050 widget_class->unrealize = eel_canvas_unrealize;
2051 widget_class->size_allocate = eel_canvas_size_allocate;
2052 widget_class->button_press_event = eel_canvas_button;
2053 widget_class->button_release_event = eel_canvas_button;
2054 widget_class->motion_notify_event = eel_canvas_motion;
2055 widget_class->draw = eel_canvas_draw;
2056 widget_class->key_press_event = eel_canvas_key;
2057 widget_class->key_release_event = eel_canvas_key;
2058 widget_class->enter_notify_event = eel_canvas_crossing;
2059 widget_class->leave_notify_event = eel_canvas_crossing;
2060 widget_class->focus_in_event = eel_canvas_focus_in;
2061 widget_class->focus_out_event = eel_canvas_focus_out;
2062
2063 klass->draw_background = eel_canvas_draw_background;
2064 klass->request_update = eel_canvas_request_update_real;
2065
2066 canvas_signals[DRAW_BACKGROUND] =
2067 g_signal_new ("draw_background",
2068 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
2069 G_SIGNAL_RUN_LAST,
2070 G_STRUCT_OFFSET (EelCanvasClass, draw_background)((glong) __builtin_offsetof(EelCanvasClass, draw_background)),
2071 NULL((void*)0), NULL((void*)0),
2072 g_cclosure_marshal_VOID__BOXED,
2073 G_TYPE_NONE((GType) ((1) << (2))), 1,
2074 CAIRO_GOBJECT_TYPE_CONTEXTcairo_gobject_context_get_type ());
2075
2076 ctk_widget_class_set_accessible_type (widget_class, eel_canvas_accessible_get_type ());
2077}
2078
2079/* Callback used when the root item of a canvas is destroyed. The user should
2080 * never ever do this, so we panic if this happens.
2081 */
2082static void
2083panic_root_destroyed (CtkWidget *object, gpointer data)
2084{
2085 g_error ("Eeeek, root item %p of canvas %p was destroyed!", object, data);
2086}
2087
2088/* Object initialization function for EelCanvas */
2089static void
2090eel_canvas_init (EelCanvas *canvas)
2091{
2092 guint width, height;
2093 ctk_widget_set_can_focus (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
, TRUE(!(0)));
2094
2095 ctk_widget_set_redraw_on_allocate (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
, FALSE(0));
2096
2097 canvas->scroll_x1 = 0.0;
2098 canvas->scroll_y1 = 0.0;
2099 ctk_layout_get_size (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
,
2100 &width, &height);
2101 canvas->scroll_x2 = width;
2102 canvas->scroll_y2 = height;
2103
2104 canvas->pixels_per_unit = 1.0;
2105
2106 canvas->pick_event.type = CDK_LEAVE_NOTIFY;
2107 canvas->pick_event.crossing.x = 0;
2108 canvas->pick_event.crossing.y = 0;
2109
2110 ctk_scrollable_set_hadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
, NULL((void*)0));
2111 ctk_scrollable_set_vadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
, NULL((void*)0));
2112
2113 /* Create the root item as a special case */
2114
2115 canvas->root = EEL_CANVAS_ITEM (g_object_new (eel_canvas_group_get_type (), NULL))((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new (eel_canvas_group_get_type (), ((void*)0)))
), ((eel_canvas_item_get_type ()))))))
;
2116 canvas->root->canvas = canvas;
2117
2118 g_object_ref_sink (canvas->root)((__typeof__ (canvas->root)) (g_object_ref_sink) (canvas->
root))
;
2119
2120 canvas->root_destroy_id = g_signal_connect (G_OBJECT (canvas->root),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((canvas->root)), (((GType) ((20) <<
(2))))))))), ("destroy"), (((GCallback) (panic_root_destroyed
))), (canvas), ((void*)0), (GConnectFlags) 0)
2121 "destroy", G_CALLBACK (panic_root_destroyed), canvas)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((canvas->root)), (((GType) ((20) <<
(2))))))))), ("destroy"), (((GCallback) (panic_root_destroyed
))), (canvas), ((void*)0), (GConnectFlags) 0)
;
2122
2123 canvas->need_repick = TRUE(!(0));
2124 canvas->doing_update = FALSE(0);
2125}
2126
2127/* Convenience function to remove the idle handler of a canvas */
2128static void
2129remove_idle (EelCanvas *canvas)
2130{
2131 if (canvas->idle_id == 0)
2132 return;
2133
2134 g_source_remove (canvas->idle_id);
2135 canvas->idle_id = 0;
2136}
2137
2138/* Removes the transient state of the canvas (idle handler, grabs). */
2139static void
2140shutdown_transients (EelCanvas *canvas)
2141{
2142 /* We turn off the need_redraw flag, since if the canvas is mapped again
2143 * it will request a redraw anyways. We do not turn off the need_update
2144 * flag, though, because updates are not queued when the canvas remaps
2145 * itself.
2146 */
2147 if (canvas->need_redraw)
2148 {
2149 canvas->need_redraw = FALSE(0);
2150 }
2151
2152 if (canvas->grabbed_item)
2153 {
2154 eel_canvas_item_ungrab (canvas->grabbed_item);
2155 }
2156
2157 remove_idle (canvas);
2158}
2159
2160/* Destroy handler for EelCanvas */
2161static void
2162eel_canvas_destroy (CtkWidget *object)
2163{
2164 EelCanvas *canvas;
2165
2166 g_return_if_fail (EEL_IS_CANVAS (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (object)"); return; } } while (0)
;
2167
2168 /* remember, destroy can be run multiple times! */
2169
2170 canvas = EEL_CANVAS (object)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((eel_canvas_get_type ()))))))
;
2171
2172 if (canvas->root_destroy_id)
2173 {
2174 g_signal_handler_disconnect (G_OBJECT (canvas->root)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas->root)), (((GType) ((20) << (2))))))))
, canvas->root_destroy_id);
2175 canvas->root_destroy_id = 0;
2176 }
2177 if (canvas->root)
2178 {
2179 EelCanvasItem *root = canvas->root;
2180 canvas->root = NULL((void*)0);
2181 eel_canvas_item_destroy (root);
2182 g_object_unref (root);
2183 }
2184
2185 shutdown_transients (canvas);
2186
2187 if (CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->destroy)
2188 (* CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->destroy) (object);
2189}
2190
2191/**
2192 * eel_canvas_new:
2193 * @void:
2194 *
2195 * Creates a new empty canvas. If you wish to use the
2196 * &EelCanvasImage item inside this canvas, then you must push the cdk_imlib
2197 * visual and colormap before calling this function, and they can be popped
2198 * afterwards.
2199 *
2200 * Return value: A newly-created canvas.
2201 **/
2202CtkWidget *
2203eel_canvas_new (void)
2204{
2205 return CTK_WIDGET (g_object_new (eel_canvas_get_type (), NULL))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_object_new (eel_canvas_get_type (), ((void*)0)))), ((ctk_widget_get_type
()))))))
;
2206}
2207
2208/* Map handler for the canvas */
2209static void
2210eel_canvas_map (CtkWidget *widget)
2211{
2212 EelCanvas *canvas;
2213
2214 g_return_if_fail (EEL_IS_CANVAS (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return; } } while (0)
;
2215
2216 /* Normal widget mapping stuff */
2217
2218 if (CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->map)
2219 (* CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->map) (widget);
2220
2221 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2222
2223 /* Map items */
2224
2225 if (canvas->root->flags & EEL_CANVAS_ITEM_VISIBLE &&
2226 !(canvas->root->flags & EEL_CANVAS_ITEM_MAPPED) &&
2227 EEL_CANVAS_ITEM_GET_CLASS (canvas->root)((((EelCanvasItemClass*) (((GTypeInstance*) ((canvas->root
)))->g_class))))
->map)
2228 (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)((((EelCanvasItemClass*) (((GTypeInstance*) ((canvas->root
)))->g_class))))
->map) (canvas->root);
2229}
2230
2231/* Unmap handler for the canvas */
2232static void
2233eel_canvas_unmap (CtkWidget *widget)
2234{
2235 EelCanvas *canvas;
2236
2237 g_return_if_fail (EEL_IS_CANVAS (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return; } } while (0)
;
2238
2239 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2240
2241 shutdown_transients (canvas);
2242
2243 /* Unmap items */
2244
2245 if (EEL_CANVAS_ITEM_GET_CLASS (canvas->root)((((EelCanvasItemClass*) (((GTypeInstance*) ((canvas->root
)))->g_class))))
->unmap)
2246 (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)((((EelCanvasItemClass*) (((GTypeInstance*) ((canvas->root
)))->g_class))))
->unmap) (canvas->root);
2247
2248 /* Normal widget unmapping stuff */
2249
2250 if (CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->unmap)
2251 (* CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->unmap) (widget);
2252}
2253
2254/* Realize handler for the canvas */
2255static void
2256eel_canvas_realize (CtkWidget *widget)
2257{
2258 EelCanvas *canvas;
2259
2260 g_return_if_fail (EEL_IS_CANVAS (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return; } } while (0)
;
2261
2262 /* Normal widget realization stuff */
2263
2264 if (CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->realize)
2265 (* CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->realize) (widget);
2266
2267 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2268
2269 cdk_window_set_events (ctk_layout_get_bin_window (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
),
2270 (cdk_window_get_events (ctk_layout_get_bin_window (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
))
2271 | CDK_EXPOSURE_MASK
2272 | CDK_BUTTON_PRESS_MASK
2273 | CDK_BUTTON_RELEASE_MASK
2274 | CDK_POINTER_MOTION_MASK
2275 | CDK_KEY_PRESS_MASK
2276 | CDK_KEY_RELEASE_MASK
2277 | CDK_ENTER_NOTIFY_MASK
2278 | CDK_LEAVE_NOTIFY_MASK
2279 | CDK_FOCUS_CHANGE_MASK));
2280
2281 /* Create our own temporary pixmap gc and realize all the items */
2282
2283 (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)((((EelCanvasItemClass*) (((GTypeInstance*) ((canvas->root
)))->g_class))))
->realize) (canvas->root);
2284}
2285
2286/* Unrealize handler for the canvas */
2287static void
2288eel_canvas_unrealize (CtkWidget *widget)
2289{
2290 EelCanvas *canvas;
2291
2292 g_return_if_fail (EEL_IS_CANVAS (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return; } } while (0)
;
2293
2294 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2295
2296 shutdown_transients (canvas);
2297
2298 /* Unrealize items and parent widget */
2299
2300 (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)((((EelCanvasItemClass*) (((GTypeInstance*) ((canvas->root
)))->g_class))))
->unrealize) (canvas->root);
2301
2302 if (CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->unrealize)
2303 (* CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->unrealize) (widget);
2304}
2305
2306/* Handles scrolling of the canvas. Adjusts the scrolling and zooming offset to
2307 * keep as much as possible of the canvas scrolling region in view.
2308 */
2309static void
2310scroll_to (EelCanvas *canvas, int cx, int cy)
2311{
2312 int scroll_width, scroll_height;
2313 int right_limit, bottom_limit;
2314 int old_zoom_xofs, old_zoom_yofs;
2315 int changed_x = FALSE(0), changed_y = FALSE(0);
2316 int canvas_width, canvas_height;
2317 CtkAllocation allocation;
2318 CtkAdjustment *vadjustment, *hadjustment;
2319 guint width, height;
2320
2321 ctk_widget_get_allocation (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
, &allocation);
2322 canvas_width = allocation.width;
2323 canvas_height = allocation.height;
2324
2325 scroll_width = floor ((canvas->scroll_x2 - canvas->scroll_x1) * canvas->pixels_per_unit + 0.5);
2326 scroll_height = floor ((canvas->scroll_y2 - canvas->scroll_y1) * canvas->pixels_per_unit + 0.5);
2327
2328 right_limit = scroll_width - canvas_width;
2329 bottom_limit = scroll_height - canvas_height;
2330
2331 old_zoom_xofs = canvas->zoom_xofs;
2332 old_zoom_yofs = canvas->zoom_yofs;
2333
2334 if (right_limit < 0)
2335 {
2336 cx = 0;
2337 if (canvas->center_scroll_region)
2338 {
2339 canvas->zoom_xofs = (canvas_width - scroll_width) / 2;
2340 scroll_width = canvas_width;
2341 }
2342 else
2343 {
2344 canvas->zoom_xofs = 0;
2345 }
2346 }
2347 else if (cx < 0)
2348 {
2349 cx = 0;
2350 canvas->zoom_xofs = 0;
2351 }
2352 else if (cx > right_limit)
2353 {
2354 cx = right_limit;
2355 canvas->zoom_xofs = 0;
2356 }
2357 else
2358 canvas->zoom_xofs = 0;
2359
2360 if (bottom_limit < 0)
2361 {
2362 cy = 0;
2363 if (canvas->center_scroll_region)
2364 {
2365 canvas->zoom_yofs = (canvas_height - scroll_height) / 2;
2366 scroll_height = canvas_height;
2367 }
2368 else
2369 {
2370 canvas->zoom_yofs = 0;
2371 }
2372 }
2373 else if (cy < 0)
2374 {
2375 cy = 0;
2376 canvas->zoom_yofs = 0;
2377 }
2378 else if (cy > bottom_limit)
2379 {
2380 cy = bottom_limit;
2381 canvas->zoom_yofs = 0;
2382 }
2383 else
2384 canvas->zoom_yofs = 0;
2385
2386 if ((canvas->zoom_xofs != old_zoom_xofs) || (canvas->zoom_yofs != old_zoom_yofs))
2387 {
2388 /* This can only occur, if either canvas size or widget size changes */
2389 /* So I think we can request full redraw here */
2390 /* More stuff - we have to mark root as needing fresh affine (Lauris) */
2391 if (!(canvas->root->flags & EEL_CANVAS_ITEM_NEED_DEEP_UPDATE))
2392 {
2393 canvas->root->flags |= EEL_CANVAS_ITEM_NEED_DEEP_UPDATE;
2394 eel_canvas_request_update (canvas);
2395 }
2396 ctk_widget_queue_draw (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
);
2397 }
2398
2399 hadjustment = ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
2400 vadjustment = ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
2401
2402 if (((int) ctk_adjustment_get_value (hadjustment)) != cx)
2403 {
2404 ctk_adjustment_set_value (hadjustment, cx);
2405 changed_x = TRUE(!(0));
2406 }
2407
2408 if (((int) ctk_adjustment_get_value (vadjustment)) != cy)
2409 {
2410 ctk_adjustment_set_value (vadjustment, cy);
2411 changed_y = TRUE(!(0));
2412 }
2413
2414 ctk_layout_get_size (&canvas->layout, &width, &height);
2415 if ((scroll_width != (int) width )|| (scroll_height != (int) height))
2416 {
2417 ctk_layout_set_size (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
, scroll_width, scroll_height);
2418 }
2419
2420 /* Signal CtkLayout that it should do a redraw. */
2421 if (changed_x)
2422 g_signal_emit_by_name (hadjustment, "value_changed");
2423 if (changed_y)
2424 g_signal_emit_by_name (vadjustment, "value_changed");
2425}
2426
2427/* Size allocation handler for the canvas */
2428static void
2429eel_canvas_size_allocate (CtkWidget *widget, CtkAllocation *allocation)
2430{
2431 EelCanvas *canvas;
2432 CtkAdjustment *vadjustment, *hadjustment;
2433
2434 g_return_if_fail (EEL_IS_CANVAS (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return; } } while (0)
;
2435 g_return_if_fail (allocation != NULL)do { if ((allocation != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "allocation != NULL"); return
; } } while (0)
;
2436
2437 if (CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->size_allocate)
2438 (* CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->size_allocate) (widget, allocation);
2439
2440 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2441
2442 /* Recenter the view, if appropriate */
2443
2444 hadjustment = ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
2445 vadjustment = ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
2446
2447 ctk_adjustment_set_page_size (hadjustment, allocation->width);
2448 ctk_adjustment_set_page_increment (hadjustment, allocation->width / 2);
2449
2450 ctk_adjustment_set_page_size (vadjustment, allocation->height);
2451 ctk_adjustment_set_page_increment (vadjustment, allocation->height / 2);
2452
2453 scroll_to (canvas,
2454 ctk_adjustment_get_value (hadjustment),
2455 ctk_adjustment_get_value (vadjustment));
2456
2457 g_signal_emit_by_name (hadjustment, "changed");
2458 g_signal_emit_by_name (vadjustment, "changed");
2459}
2460
2461/* Emits an event for an item in the canvas, be it the current item, grabbed
2462 * item, or focused item, as appropriate.
2463 */
2464
2465static int
2466emit_event (EelCanvas *canvas, CdkEvent *event)
2467{
2468 CdkEvent ev;
2469 gint finished;
2470 EelCanvasItem *item;
2471 EelCanvasItem *parent;
2472 guint mask;
2473
2474 /* Could be an old pick event */
2475 if (!ctk_widget_get_realized (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
))
2476 {
2477 return FALSE(0);
2478 }
2479
2480 /* Perform checks for grabbed items */
2481
2482 if (canvas->grabbed_item &&
2483 !is_descendant (canvas->current_item, canvas->grabbed_item))
2484 {
2485 return FALSE(0);
2486 }
2487
2488 if (canvas->grabbed_item)
2489 {
2490 switch (event->type)
2491 {
2492 case CDK_ENTER_NOTIFY:
2493 mask = CDK_ENTER_NOTIFY_MASK;
2494 break;
2495
2496 case CDK_LEAVE_NOTIFY:
2497 mask = CDK_LEAVE_NOTIFY_MASK;
2498 break;
2499
2500 case CDK_MOTION_NOTIFY:
2501 mask = CDK_POINTER_MOTION_MASK;
2502 break;
2503
2504 case CDK_BUTTON_PRESS:
2505 case CDK_2BUTTON_PRESS:
2506 case CDK_3BUTTON_PRESS:
2507 mask = CDK_BUTTON_PRESS_MASK;
2508 break;
2509
2510 case CDK_BUTTON_RELEASE:
2511 mask = CDK_BUTTON_RELEASE_MASK;
2512 break;
2513
2514 case CDK_KEY_PRESS:
2515 mask = CDK_KEY_PRESS_MASK;
2516 break;
2517
2518 case CDK_KEY_RELEASE:
2519 mask = CDK_KEY_RELEASE_MASK;
2520 break;
2521
2522 default:
2523 mask = 0;
2524 break;
2525 }
2526
2527 if (!(mask & canvas->grabbed_event_mask))
2528 return FALSE(0);
2529 }
2530
2531 /* Convert to world coordinates -- we have two cases because of diferent
2532 * offsets of the fields in the event structures.
2533 */
2534
2535 ev = *event;
2536
2537 switch (ev.type)
2538 {
2539 case CDK_ENTER_NOTIFY:
2540 case CDK_LEAVE_NOTIFY:
2541 eel_canvas_window_to_world (canvas,
2542 ev.crossing.x, ev.crossing.y,
2543 &ev.crossing.x, &ev.crossing.y);
2544 break;
2545
2546 case CDK_MOTION_NOTIFY:
2547 case CDK_BUTTON_PRESS:
2548 case CDK_2BUTTON_PRESS:
2549 case CDK_3BUTTON_PRESS:
2550 case CDK_BUTTON_RELEASE:
2551 eel_canvas_window_to_world (canvas,
2552 ev.motion.x, ev.motion.y,
2553 &ev.motion.x, &ev.motion.y);
2554 break;
2555
2556 default:
2557 break;
2558 }
2559
2560 /* Choose where we send the event */
2561
2562 item = canvas->current_item;
2563
2564 if (canvas->focused_item
2565 && ((event->type == CDK_KEY_PRESS) ||
2566 (event->type == CDK_KEY_RELEASE) ||
2567 (event->type == CDK_FOCUS_CHANGE)))
2568 item = canvas->focused_item;
2569
2570 /* The event is propagated up the hierarchy (for if someone connected to
2571 * a group instead of a leaf event), and emission is stopped if a
2572 * handler returns TRUE, just like for CtkWidget events.
2573 */
2574
2575 finished = FALSE(0);
2576
2577 while (item && !finished)
2578 {
2579 g_object_ref (item)((__typeof__ (item)) (g_object_ref) (item));
2580
2581 g_signal_emit (
2582 G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
, item_signals[ITEM_EVENT], 0,
2583 &ev, &finished);
2584
2585 parent = item->parent;
2586 g_object_unref (item);
2587
2588 item = parent;
2589 }
2590
2591 return finished;
2592}
2593
2594/* Re-picks the current item in the canvas, based on the event's coordinates.
2595 * Also emits enter/leave events for items as appropriate.
2596 */
2597static int
2598pick_current_item (EelCanvas *canvas, CdkEvent *event)
2599{
2600 int button_down;
2601 double x, y;
2602 int retval;
2603
2604 retval = FALSE(0);
2605
2606 /* If a button is down, we'll perform enter and leave events on the
2607 * current item, but not enter on any other item. This is more or less
2608 * like X pointer grabbing for canvas items.
2609 */
2610 button_down = canvas->state & (CDK_BUTTON1_MASK
2611 | CDK_BUTTON2_MASK
2612 | CDK_BUTTON3_MASK
2613 | CDK_BUTTON4_MASK
2614 | CDK_BUTTON5_MASK);
2615 if (!button_down)
2616 canvas->left_grabbed_item = FALSE(0);
2617
2618 /* Save the event in the canvas. This is used to synthesize enter and
2619 * leave events in case the current item changes. It is also used to
2620 * re-pick the current item if the current one gets deleted. Also,
2621 * synthesize an enter event.
2622 */
2623 if (event != &canvas->pick_event)
2624 {
2625 if ((event->type == CDK_MOTION_NOTIFY) || (event->type == CDK_BUTTON_RELEASE))
2626 {
2627 /* these fields have the same offsets in both types of events */
2628
2629 canvas->pick_event.crossing.type = CDK_ENTER_NOTIFY;
2630 canvas->pick_event.crossing.window = event->motion.window;
2631 canvas->pick_event.crossing.send_event = event->motion.send_event;
2632 canvas->pick_event.crossing.subwindow = NULL((void*)0);
2633 canvas->pick_event.crossing.x = event->motion.x;
2634 canvas->pick_event.crossing.y = event->motion.y;
2635 canvas->pick_event.crossing.mode = CDK_CROSSING_NORMAL;
2636 canvas->pick_event.crossing.detail = CDK_NOTIFY_NONLINEAR;
2637 canvas->pick_event.crossing.focus = FALSE(0);
2638 canvas->pick_event.crossing.state = event->motion.state;
2639
2640 /* these fields don't have the same offsets in both types of events */
2641
2642 if (event->type == CDK_MOTION_NOTIFY)
2643 {
2644 canvas->pick_event.crossing.x_root = event->motion.x_root;
2645 canvas->pick_event.crossing.y_root = event->motion.y_root;
2646 }
2647 else
2648 {
2649 canvas->pick_event.crossing.x_root = event->button.x_root;
2650 canvas->pick_event.crossing.y_root = event->button.y_root;
2651 }
2652 }
2653 else
2654 canvas->pick_event = *event;
2655 }
2656
2657 /* Don't do anything else if this is a recursive call */
2658
2659 if (canvas->in_repick)
2660 return retval;
2661
2662 /* LeaveNotify means that there is no current item, so we don't look for one */
2663
2664 if (canvas->pick_event.type != CDK_LEAVE_NOTIFY)
2665 {
2666 /* these fields don't have the same offsets in both types of events */
2667
2668 if (canvas->pick_event.type == CDK_ENTER_NOTIFY)
2669 {
2670 x = canvas->pick_event.crossing.x;
2671 y = canvas->pick_event.crossing.y;
2672 }
2673 else
2674 {
2675 x = canvas->pick_event.motion.x;
2676 y = canvas->pick_event.motion.y;
2677 }
2678
2679 /* canvas pixel coords */
2680 int cx, cy;
2681
2682 cx = (int) (x + 0.5);
2683 cy = (int) (y + 0.5);
2684
2685 /* world coords */
2686 eel_canvas_c2w (canvas, cx, cy, &x, &y);
2687
2688 /* find the closest item */
2689 if (canvas->root->flags & EEL_CANVAS_ITEM_MAPPED)
2690 eel_canvas_item_invoke_point (canvas->root, x, y, cx, cy,
2691 &canvas->new_current_item);
2692 else
2693 canvas->new_current_item = NULL((void*)0);
2694 }
2695 else
2696 canvas->new_current_item = NULL((void*)0);
2697
2698 if ((canvas->new_current_item == canvas->current_item) && !canvas->left_grabbed_item)
2699 return retval; /* current item did not change */
2700
2701 /* Synthesize events for old and new current items */
2702
2703 if ((canvas->new_current_item != canvas->current_item)
2704 && (canvas->current_item != NULL((void*)0))
2705 && !canvas->left_grabbed_item)
2706 {
2707 CdkEvent new_event;
2708
2709 new_event = canvas->pick_event;
2710 new_event.type = CDK_LEAVE_NOTIFY;
2711
2712 new_event.crossing.detail = CDK_NOTIFY_ANCESTOR;
2713 new_event.crossing.subwindow = NULL((void*)0);
2714 canvas->in_repick = TRUE(!(0));
2715 retval = emit_event (canvas, &new_event);
2716 canvas->in_repick = FALSE(0);
2717 }
2718
2719 /* new_current_item may have been set to NULL during the call to emit_event() above */
2720
2721 if ((canvas->new_current_item != canvas->current_item) && button_down)
2722 {
2723 canvas->current_item = canvas->new_current_item;
2724 canvas->left_grabbed_item = TRUE(!(0));
2725 return retval;
2726 }
2727
2728 /* Handle the rest of cases */
2729
2730 canvas->left_grabbed_item = FALSE(0);
2731 canvas->current_item = canvas->new_current_item;
2732
2733 if (canvas->current_item != NULL((void*)0))
2734 {
2735 CdkEvent new_event;
2736
2737 new_event = canvas->pick_event;
2738 new_event.type = CDK_ENTER_NOTIFY;
2739 new_event.crossing.detail = CDK_NOTIFY_ANCESTOR;
2740 new_event.crossing.subwindow = NULL((void*)0);
2741 retval = emit_event (canvas, &new_event);
2742 }
2743
2744 return retval;
2745}
2746
2747/* Button event handler for the canvas */
2748static gint
2749eel_canvas_button (CtkWidget *widget, CdkEventButton *event)
2750{
2751 EelCanvas *canvas;
2752 int mask;
2753 int retval;
2754
2755 g_return_val_if_fail (EEL_IS_CANVAS (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return ((0)); } } while (0)
;
2756 g_return_val_if_fail (event != NULL, FALSE)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "event != NULL"); return
((0)); } } while (0)
;
2757
2758 retval = FALSE(0);
2759
2760 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2761
2762 /* Don't handle extra mouse button events */
2763 if (event->button > 5)
2764 return FALSE(0);
2765
2766 /*
2767 * dispatch normally regardless of the event's window if an item has
2768 * has a pointer grab in effect
2769 */
2770 if (!canvas->grabbed_item && event->window != ctk_layout_get_bin_window (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
))
2771 return retval;
2772
2773 switch (event->button)
2774 {
2775 case 1:
2776 mask = CDK_BUTTON1_MASK;
2777 break;
2778 case 2:
2779 mask = CDK_BUTTON2_MASK;
2780 break;
2781 case 3:
2782 mask = CDK_BUTTON3_MASK;
2783 break;
2784 case 4:
2785 mask = CDK_BUTTON4_MASK;
2786 break;
2787 case 5:
2788 mask = CDK_BUTTON5_MASK;
2789 break;
2790 default:
2791 mask = 0;
2792 }
2793
2794 switch (event->type)
2795 {
2796 case CDK_BUTTON_PRESS:
2797 case CDK_2BUTTON_PRESS:
2798 case CDK_3BUTTON_PRESS:
2799 /* Pick the current item as if the button were not pressed, and
2800 * then process the event.
2801 */
2802 event->state ^= mask;
2803 canvas->state = event->state;
2804 pick_current_item (canvas, (CdkEvent *) event);
2805 event->state ^= mask;
2806 canvas->state = event->state;
2807 retval = emit_event (canvas, (CdkEvent *) event);
2808 break;
2809
2810 case CDK_BUTTON_RELEASE:
2811 /* Process the event as if the button were pressed, then repick
2812 * after the button has been released
2813 */
2814 canvas->state = event->state;
2815 retval = emit_event (canvas, (CdkEvent *) event);
2816 event->state ^= mask;
2817 canvas->state = event->state;
2818 pick_current_item (canvas, (CdkEvent *) event);
2819 event->state ^= mask;
2820 break;
2821
2822 default:
2823 g_assert_not_reached ()do { g_assertion_message_expr ("Eel", "eel-canvas.c", 2823, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
2824 }
2825
2826 return retval;
2827}
2828
2829/* Motion event handler for the canvas */
2830static gint
2831eel_canvas_motion (CtkWidget *widget, CdkEventMotion *event)
2832{
2833 EelCanvas *canvas;
2834
2835 g_return_val_if_fail (EEL_IS_CANVAS (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return ((0)); } } while (0)
;
2836 g_return_val_if_fail (event != NULL, FALSE)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "event != NULL"); return
((0)); } } while (0)
;
2837
2838 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2839
2840 if (event->window != ctk_layout_get_bin_window (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
))
2841 return FALSE(0);
2842
2843 canvas->state = event->state;
2844 pick_current_item (canvas, (CdkEvent *) event);
2845 return emit_event (canvas, (CdkEvent *) event);
2846}
2847
2848/* Key event handler for the canvas */
2849static gint
2850eel_canvas_key (CtkWidget *widget, CdkEventKey *event)
2851{
2852 EelCanvas *canvas;
2853
2854 g_return_val_if_fail (EEL_IS_CANVAS (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return ((0)); } } while (0)
;
2855 g_return_val_if_fail (event != NULL, FALSE)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "event != NULL"); return
((0)); } } while (0)
;
2856
2857 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2858
2859 if (emit_event (canvas, (CdkEvent *) event))
2860 return TRUE(!(0));
2861 if (event->type == CDK_KEY_RELEASE)
2862 return CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->key_release_event (widget, event);
2863 else
2864 return CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->key_press_event (widget, event);
2865}
2866
2867
2868/* Crossing event handler for the canvas */
2869static gint
2870eel_canvas_crossing (CtkWidget *widget, CdkEventCrossing *event)
2871{
2872 EelCanvas *canvas;
2873
2874 g_return_val_if_fail (EEL_IS_CANVAS (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((widget)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (widget)"); return ((0)); } } while (0)
;
2875 g_return_val_if_fail (event != NULL, FALSE)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "event != NULL"); return
((0)); } } while (0)
;
2876
2877 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2878
2879 if (event->window != ctk_layout_get_bin_window (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
))
2880 return FALSE(0);
2881
2882 canvas->state = event->state;
2883 return pick_current_item (canvas, (CdkEvent *) event);
2884}
2885
2886/* Focus in handler for the canvas */
2887static gint
2888eel_canvas_focus_in (CtkWidget *widget, CdkEventFocus *event)
2889{
2890 EelCanvas *canvas;
2891
2892 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2893
2894 if (canvas->focused_item)
2895 return emit_event (canvas, (CdkEvent *) event);
2896 else
2897 return FALSE(0);
2898}
2899
2900/* Focus out handler for the canvas */
2901static gint
2902eel_canvas_focus_out (CtkWidget *widget, CdkEventFocus *event)
2903{
2904 EelCanvas *canvas;
2905
2906 canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2907
2908 if (canvas->focused_item)
2909 return emit_event (canvas, (CdkEvent *) event);
2910 else
2911 return FALSE(0);
2912}
2913
2914static cairo_region_t *
2915eel_cairo_get_clip_region (cairo_t *cr)
2916{
2917 cairo_rectangle_list_t *list;
2918 cairo_region_t *region;
2919 int i;
2920
2921 list = cairo_copy_clip_rectangle_list (cr);
2922 if (list->status == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE) {
2923 cairo_rectangle_int_t clip_rect;
2924
2925 cairo_rectangle_list_destroy (list);
2926
2927 if (!cdk_cairo_get_clip_rectangle (cr, &clip_rect))
2928 return NULL((void*)0);
2929 return cairo_region_create_rectangle (&clip_rect);
2930 }
2931
2932
2933 region = cairo_region_create ();
2934 for (i = list->num_rectangles - 1; i >= 0; --i) {
2935 cairo_rectangle_t *rect = &list->rectangles[i];
2936 cairo_rectangle_int_t clip_rect;
2937
2938 clip_rect.x = floor (rect->x);
2939 clip_rect.y = floor (rect->y);
2940 clip_rect.width = ceil (rect->x + rect->width) - clip_rect.x;
2941 clip_rect.height = ceil (rect->y + rect->height) - clip_rect.y;
2942
2943 if (cairo_region_union_rectangle (region, &clip_rect) != CAIRO_STATUS_SUCCESS) {
2944 cairo_region_destroy (region);
2945 region = NULL((void*)0);
2946 break;
2947 }
2948 }
2949
2950 cairo_rectangle_list_destroy (list);
2951 return region;
2952}
2953
2954/* Expose handler for the canvas */
2955static gboolean
2956eel_canvas_draw (CtkWidget *widget, cairo_t *cr)
2957{
2958 EelCanvas *canvas = EEL_CANVAS (widget)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((eel_canvas_get_type ()))))))
;
2959 CdkWindow *bin_window;
2960 cairo_region_t *region;
2961
2962 if (!cdk_cairo_get_clip_rectangle (cr, NULL((void*)0)))
2963 return FALSE(0);
2964
2965 bin_window = ctk_layout_get_bin_window (CTK_LAYOUT (widget)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_layout_get_type ()))))))
);
2966
2967 if (!ctk_cairo_should_draw_window (cr, bin_window))
2968 return FALSE(0);
2969
2970 cairo_save (cr);
2971
2972 ctk_cairo_transform_to_window (cr, widget, bin_window);
2973
2974 region = eel_cairo_get_clip_region (cr);
2975 if (region == NULL((void*)0)) {
2976 cairo_restore (cr);
2977 return FALSE(0);
2978 }
2979
2980#if defined VERBOSE
2981 g_print ("Draw\n");
2982#endif
2983 /* If there are any outstanding items that need updating, do them now */
2984 if (canvas->idle_id)
2985 {
2986 g_source_remove (canvas->idle_id);
2987 canvas->idle_id = 0;
2988 }
2989 if (canvas->need_update)
2990 {
2991 g_return_val_if_fail (!canvas->doing_update, FALSE)do { if ((!canvas->doing_update)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "!canvas->doing_update"
); return ((0)); } } while (0)
;
2992
2993 canvas->doing_update = TRUE(!(0));
2994 eel_canvas_item_invoke_update (canvas->root, 0, 0, 0);
2995
2996 g_return_val_if_fail (canvas->doing_update, FALSE)do { if ((canvas->doing_update)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "canvas->doing_update"
); return ((0)); } } while (0)
;
2997
2998 canvas->doing_update = FALSE(0);
2999
3000 canvas->need_update = FALSE(0);
3001 }
3002
3003 /* Hmmm. Would like to queue antiexposes if the update marked
3004 anything that is gonna get redrawn as invalid */
3005
3006 g_signal_emit (G_OBJECT (canvas)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), (((GType) ((20) << (2))))))))
, canvas_signals[DRAW_BACKGROUND], 0,
3007 cr);
3008
3009 if (canvas->root->flags & EEL_CANVAS_ITEM_MAPPED)
3010 EEL_CANVAS_ITEM_GET_CLASS (canvas->root)((((EelCanvasItemClass*) (((GTypeInstance*) ((canvas->root
)))->g_class))))
->draw (canvas->root,
3011 cr, region);
3012
3013 /* Chain up to get exposes on child widgets */
3014 cairo_restore (cr);
3015
3016 if (CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->draw)
3017 CTK_WIDGET_CLASS (canvas_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((canvas_parent_class)), ((ctk_widget_get_type ()))))))
->draw (widget, cr);
3018
3019 cairo_region_destroy (region);
3020
3021 return FALSE(0);
3022}
3023
3024static void
3025eel_canvas_draw_background (EelCanvas *canvas,
3026 cairo_t *cr)
3027{
3028 cairo_rectangle_int_t rect;
3029 CtkStyleContext *style_context;
3030 CdkRGBA color;
3031 CdkRGBA *c;
3032
3033 if (!cdk_cairo_get_clip_rectangle (cr, &rect))
3034 return;
3035
3036 cairo_save (cr);
3037 /* By default, we use the style background. */
3038 style_context = ctk_widget_get_style_context (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
);
3039
3040 ctk_style_context_get (style_context, CTK_STATE_FLAG_NORMAL,
3041 CTK_STYLE_PROPERTY_BACKGROUND_COLOR"background-color",
3042 &c, NULL((void*)0));
3043 color = *c;
3044 cdk_rgba_free (c);
3045
3046 cdk_cairo_set_source_rgba (cr, &color);
3047 cdk_cairo_rectangle (cr, &rect);
3048 cairo_fill (cr);
3049 cairo_restore (cr);
3050}
3051
3052static void
3053do_update (EelCanvas *canvas)
3054{
3055 /* Cause the update if necessary */
3056
3057update_again:
3058 if (canvas->need_update)
3059 {
3060 g_return_if_fail (!canvas->doing_update)do { if ((!canvas->doing_update)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "!canvas->doing_update"
); return; } } while (0)
;
3061
3062 canvas->doing_update = TRUE(!(0));
3063 eel_canvas_item_invoke_update (canvas->root, 0, 0, 0);
3064
3065 g_return_if_fail (canvas->doing_update)do { if ((canvas->doing_update)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "canvas->doing_update"
); return; } } while (0)
;
3066
3067 canvas->doing_update = FALSE(0);
3068
3069 canvas->need_update = FALSE(0);
3070 }
3071
3072 /* Pick new current item */
3073
3074 while (canvas->need_repick)
3075 {
3076 canvas->need_repick = FALSE(0);
3077 pick_current_item (canvas, &canvas->pick_event);
3078 }
3079
3080 /* it is possible that during picking we emitted an event in which
3081 the user then called some function which then requested update
3082 of something. Without this we'd be left in a state where
3083 need_update would have been left TRUE and the canvas would have
3084 been left unpainted. */
3085 if (canvas->need_update)
3086 {
3087 goto update_again;
3088 }
3089}
3090
3091/* Idle handler for the canvas. It deals with pending updates and redraws. */
3092static gint
3093idle_handler (gpointer data)
3094{
3095 EelCanvas *canvas;
3096
3097 canvas = EEL_CANVAS (data)((((EelCanvas*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((eel_canvas_get_type ()))))))
;
3098 do_update (canvas);
3099
3100 /* Reset idle id */
3101 canvas->idle_id = 0;
3102
3103 return FALSE(0);
3104}
3105
3106/* Convenience function to add an idle handler to a canvas */
3107static void
3108add_idle (EelCanvas *canvas)
3109{
3110 if (!canvas->idle_id)
3111 {
3112 /* We let the update idle handler have higher priority
3113 * than the redraw idle handler so the canvas state
3114 * will be updated during the expose event. canvas in
3115 * expose_event.
3116 */
3117 canvas->idle_id = g_idle_add_full (CDK_PRIORITY_REDRAW(100 + 20) - 20,
3118 idle_handler, canvas, NULL((void*)0));
3119 }
3120}
3121
3122/**
3123 * eel_canvas_root:
3124 * @canvas: A canvas.
3125 *
3126 * Queries the root group of a canvas.
3127 *
3128 * Return value: The root group of the specified canvas.
3129 **/
3130EelCanvasGroup *
3131eel_canvas_root (EelCanvas *canvas)
3132{
3133 g_return_val_if_fail (EEL_IS_CANVAS (canvas), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return (((void*)0)); } } while
(0)
;
3134
3135 return EEL_CANVAS_GROUP (canvas->root)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas->root)), ((eel_canvas_group_get_type ()))))))
;
3136}
3137
3138
3139/**
3140 * eel_canvas_set_scroll_region:
3141 * @canvas: A canvas.
3142 * @x1: Leftmost limit of the scrolling region.
3143 * @y1: Upper limit of the scrolling region.
3144 * @x2: Rightmost limit of the scrolling region.
3145 * @y2: Lower limit of the scrolling region.
3146 *
3147 * Sets the scrolling region of a canvas to the specified rectangle. The canvas
3148 * will then be able to scroll only within this region. The view of the canvas
3149 * is adjusted as appropriate to display as much of the new region as possible.
3150 **/
3151void
3152eel_canvas_set_scroll_region (EelCanvas *canvas, double x1, double y1, double x2, double y2)
3153{
3154 double wxofs, wyofs;
3155 int xofs, yofs;
3156 CtkAdjustment *vadjustment, *hadjustment;
3157
3158 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3159
3160 if ((canvas->scroll_x1 == x1) && (canvas->scroll_y1 == y1) &&
3161 (canvas->scroll_x2 == x2) && (canvas->scroll_y2 == y2))
3162 {
3163 return;
3164 }
3165
3166 /*
3167 * Set the new scrolling region. If possible, do not move the visible contents of the
3168 * canvas.
3169 */
3170 hadjustment = ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
3171 vadjustment = ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
3172
3173 eel_canvas_c2w (canvas,
3174 ctk_adjustment_get_value (hadjustment) + canvas->zoom_xofs,
3175 ctk_adjustment_get_value (vadjustment) + canvas->zoom_yofs,
3176 /*canvas->zoom_xofs,
3177 canvas->zoom_yofs,*/
3178 &wxofs, &wyofs);
3179
3180 canvas->scroll_x1 = x1;
3181 canvas->scroll_y1 = y1;
3182 canvas->scroll_x2 = x2;
3183 canvas->scroll_y2 = y2;
3184
3185 eel_canvas_w2c (canvas, wxofs, wyofs, &xofs, &yofs);
3186
3187 scroll_to (canvas, xofs, yofs);
3188
3189 canvas->need_repick = TRUE(!(0));
3190
3191 if (!(canvas->root->flags & EEL_CANVAS_ITEM_NEED_DEEP_UPDATE))
3192 {
3193 canvas->root->flags |= EEL_CANVAS_ITEM_NEED_DEEP_UPDATE;
3194 eel_canvas_request_update (canvas);
3195 }
3196}
3197
3198
3199/**
3200 * eel_canvas_get_scroll_region:
3201 * @canvas: A canvas.
3202 * @x1: Leftmost limit of the scrolling region (return value).
3203 * @y1: Upper limit of the scrolling region (return value).
3204 * @x2: Rightmost limit of the scrolling region (return value).
3205 * @y2: Lower limit of the scrolling region (return value).
3206 *
3207 * Queries the scrolling region of a canvas.
3208 **/
3209void
3210eel_canvas_get_scroll_region (EelCanvas *canvas, double *x1, double *y1, double *x2, double *y2)
3211{
3212 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3213
3214 if (x1)
3215 *x1 = canvas->scroll_x1;
3216
3217 if (y1)
3218 *y1 = canvas->scroll_y1;
3219
3220 if (x2)
3221 *x2 = canvas->scroll_x2;
3222
3223 if (y2)
3224 *y2 = canvas->scroll_y2;
3225}
3226
3227void
3228eel_canvas_set_center_scroll_region (EelCanvas *canvas,
3229 gboolean center_scroll_region)
3230{
3231 CtkAdjustment *vadjustment, *hadjustment;
3232
3233 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3234
3235 canvas->center_scroll_region = center_scroll_region != 0;
3236
3237 hadjustment = ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (&canvas->layout)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((&canvas->layout)), ((ctk_scrollable_get_type ()))
))))
);
3238 vadjustment = ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (&canvas->layout)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((&canvas->layout)), ((ctk_scrollable_get_type ()))
))))
);
3239
3240 scroll_to (canvas,
3241 ctk_adjustment_get_value (hadjustment),
3242 ctk_adjustment_get_value (vadjustment));
3243}
3244
3245
3246/**
3247 * eel_canvas_set_pixels_per_unit:
3248 * @canvas: A canvas.
3249 * @n: The number of pixels that correspond to one canvas unit.
3250 *
3251 * Sets the zooming factor of a canvas by specifying the number of pixels that
3252 * correspond to one canvas unit.
3253 **/
3254void
3255eel_canvas_set_pixels_per_unit (EelCanvas *canvas, double n)
3256{
3257 CtkWidget *widget;
3258 double cx, cy;
3259 int x1, y1;
3260 int center_x, center_y;
3261 CdkWindow *window;
3262 CdkWindowAttr attributes;
3263 gint attributes_mask;
3264 CtkAllocation allocation;
3265 CtkAdjustment *vadjustment, *hadjustment;
3266
3267 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3268 g_return_if_fail (n > EEL_CANVAS_EPSILON)do { if ((n > 1e-10)) { } else { g_return_if_fail_warning (
"Eel", ((const char*) (__func__)), "n > EEL_CANVAS_EPSILON"
); return; } } while (0)
;
3269
3270 widget = CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
;
3271
3272 ctk_widget_get_allocation (widget, &allocation);
3273 center_x = allocation.width / 2;
3274 center_y = allocation.height / 2;
3275
3276 /* Find the coordinates of the screen center in units. */
3277 hadjustment = ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
3278 vadjustment = ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
3279 cx = (ctk_adjustment_get_value (hadjustment) + center_x) / canvas->pixels_per_unit + canvas->scroll_x1 + canvas->zoom_xofs;
3280 cy = (ctk_adjustment_get_value (vadjustment) + center_y) / canvas->pixels_per_unit + canvas->scroll_y1 + canvas->zoom_yofs;
3281
3282 /* Now calculate the new offset of the upper left corner. (round not truncate) */
3283 x1 = ((cx - canvas->scroll_x1) * n) - center_x + .5;
3284 y1 = ((cy - canvas->scroll_y1) * n) - center_y + .5;
3285
3286 canvas->pixels_per_unit = n;
3287
3288 if (!(canvas->root->flags & EEL_CANVAS_ITEM_NEED_DEEP_UPDATE))
3289 {
3290 canvas->root->flags |= EEL_CANVAS_ITEM_NEED_DEEP_UPDATE;
3291 eel_canvas_request_update (canvas);
3292 }
3293
3294 /* Map a background None window over the bin_window to avoid
3295 * scrolling the window scroll causing exposes.
3296 */
3297 window = NULL((void*)0);
3298 if (ctk_widget_get_mapped (widget))
3299 {
3300 attributes.window_type = CDK_WINDOW_CHILD;
3301 ctk_widget_get_allocation (widget, &allocation);
3302 attributes.x = allocation.x;
3303 attributes.y = allocation.y;
3304 attributes.width = allocation.width;
3305 attributes.height = allocation.height;
3306 attributes.wclass = CDK_INPUT_OUTPUT;
3307 attributes.visual = ctk_widget_get_visual (widget);
3308 attributes.event_mask = CDK_VISIBILITY_NOTIFY_MASK;
3309
3310 attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL;
3311
3312 window = cdk_window_new (ctk_widget_get_parent_window (widget),
3313 &attributes, attributes_mask);
3314
3315 cdk_window_set_user_data (window, widget);
3316
3317 cdk_window_show (window);
3318 }
3319
3320 scroll_to (canvas, x1, y1);
3321
3322 /* If we created a an overlapping background None window, remove it how.
3323 *
3324 * TODO: We would like to temporarily set the bin_window background to
3325 * None to avoid clearing the bin_window to the background, but cdk doesn't
3326 * expose enought to let us do this, so we get a flash-effect here. At least
3327 * it looks better than scroll + expose.
3328 */
3329 if (window != NULL((void*)0))
3330 {
3331 cdk_window_hide (window);
3332 cdk_window_set_user_data (window, NULL((void*)0));
3333 cdk_window_destroy (window);
3334 }
3335
3336 canvas->need_repick = TRUE(!(0));
3337}
3338
3339/**
3340 * eel_canvas_scroll_to:
3341 * @canvas: A canvas.
3342 * @cx: Horizontal scrolling offset in canvas pixel units.
3343 * @cy: Vertical scrolling offset in canvas pixel units.
3344 *
3345 * Makes a canvas scroll to the specified offsets, given in canvas pixel units.
3346 * The canvas will adjust the view so that it is not outside the scrolling
3347 * region. This function is typically not used, as it is better to hook
3348 * scrollbars to the canvas layout's scrolling adjusments.
3349 **/
3350void
3351eel_canvas_scroll_to (EelCanvas *canvas, int cx, int cy)
3352{
3353 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3354
3355 scroll_to (canvas, cx, cy);
3356}
3357
3358/**
3359 * eel_canvas_get_scroll_offsets:
3360 * @canvas: A canvas.
3361 * @cx: Horizontal scrolling offset (return value).
3362 * @cy: Vertical scrolling offset (return value).
3363 *
3364 * Queries the scrolling offsets of a canvas. The values are returned in canvas
3365 * pixel units.
3366 **/
3367void
3368eel_canvas_get_scroll_offsets (EelCanvas *canvas, int *cx, int *cy)
3369{
3370 CtkAdjustment *vadjustment, *hadjustment;
3371
3372 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3373
3374 hadjustment = ctk_scrollable_get_hadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
3375 vadjustment = ctk_scrollable_get_vadjustment (CTK_SCROLLABLE (canvas)((((CtkScrollable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_scrollable_get_type ()))))))
);
3376
3377 if (cx)
3378 *cx = ctk_adjustment_get_value (hadjustment);
3379
3380 if (cy)
3381 *cy = ctk_adjustment_get_value (vadjustment);
3382}
3383
3384/**
3385 * eel_canvas_update_now:
3386 * @canvas: A canvas.
3387 *
3388 * Forces an immediate update and redraw of a canvas. If the canvas does not
3389 * have any pending update or redraw requests, then no action is taken. This is
3390 * typically only used by applications that need explicit control of when the
3391 * display is updated, like games. It is not needed by normal applications.
3392 */
3393void
3394eel_canvas_update_now (EelCanvas *canvas)
3395{
3396 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3397
3398 if (!(canvas->need_update || canvas->need_redraw))
3399 return;
3400 remove_idle (canvas);
3401 do_update (canvas);
3402}
3403
3404/**
3405 * eel_canvas_get_item_at:
3406 * @canvas: A canvas.
3407 * @x: X position in world coordinates.
3408 * @y: Y position in world coordinates.
3409 *
3410 * Looks for the item that is under the specified position, which must be
3411 * specified in world coordinates.
3412 *
3413 * Return value: The sought item, or NULL if no item is at the specified
3414 * coordinates.
3415 **/
3416EelCanvasItem *
3417eel_canvas_get_item_at (EelCanvas *canvas, double x, double y)
3418{
3419 EelCanvasItem *item = NULL((void*)0);
3420 double dist;
3421 int cx, cy;
3422
3423 g_return_val_if_fail (EEL_IS_CANVAS (canvas), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return (((void*)0)); } } while
(0)
;
3424
3425 eel_canvas_w2c (canvas, x, y, &cx, &cy);
3426
3427 dist = eel_canvas_item_invoke_point (canvas->root, x, y, cx, cy, &item);
3428 if ((int) (dist * canvas->pixels_per_unit + 0.5) <= canvas->close_enough)
3429 return item;
3430 else
3431 return NULL((void*)0);
3432}
3433
3434/* Queues an update of the canvas */
3435static void
3436eel_canvas_request_update (EelCanvas *canvas)
3437{
3438 EEL_CANVAS_GET_CLASS (canvas)((((EelCanvasClass*) (((GTypeInstance*) ((canvas)))->g_class
))))
->request_update (canvas);
3439}
3440
3441static void
3442eel_canvas_request_update_real (EelCanvas *canvas)
3443{
3444 canvas->need_update = TRUE(!(0));
3445 add_idle (canvas);
3446}
3447
3448/**
3449 * eel_canvas_request_redraw:
3450 * @canvas: A canvas.
3451 * @x1: Leftmost coordinate of the rectangle to be redrawn.
3452 * @y1: Upper coordinate of the rectangle to be redrawn.
3453 * @x2: Rightmost coordinate of the rectangle to be redrawn, plus 1.
3454 * @y2: Lower coordinate of the rectangle to be redrawn, plus 1.
3455 *
3456 * Convenience function that informs a canvas that the specified rectangle needs
3457 * to be repainted. The rectangle includes @x1 and @y1, but not @x2 and @y2.
3458 * To be used only by item implementations.
3459 **/
3460void
3461eel_canvas_request_redraw (EelCanvas *canvas, int x1, int y1, int x2, int y2)
3462{
3463 CdkRectangle bbox;
3464
3465 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3466
3467 if (!ctk_widget_is_drawable (CTK_WIDGET (canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_widget_get_type ()))))))
)
3468 || (x1 >= x2) || (y1 >= y2)) return;
3469
3470 bbox.x = x1;
3471 bbox.y = y1;
3472 bbox.width = x2 - x1;
3473 bbox.height = y2 - y1;
3474
3475 cdk_window_invalidate_rect (ctk_layout_get_bin_window (CTK_LAYOUT (canvas)((((CtkLayout*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((canvas)), ((ctk_layout_get_type ()))))))
),
3476 &bbox, FALSE(0));
3477}
3478
3479/**
3480 * eel_canvas_w2c:
3481 * @canvas: A canvas.
3482 * @wx: World X coordinate.
3483 * @wy: World Y coordinate.
3484 * @cx: X pixel coordinate (return value).
3485 * @cy: Y pixel coordinate (return value).
3486 *
3487 * Converts world coordinates into canvas pixel coordinates.
3488 **/
3489void
3490eel_canvas_w2c (EelCanvas *canvas, double wx, double wy, int *cx, int *cy)
3491{
3492 double zoom;
3493
3494 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3495
3496 zoom = canvas->pixels_per_unit;
3497
3498 if (cx)
3499 *cx = floor ((wx - canvas->scroll_x1)*zoom + canvas->zoom_xofs + 0.5);
3500 if (cy)
3501 *cy = floor ((wy - canvas->scroll_y1)*zoom + canvas->zoom_yofs + 0.5);
3502}
3503
3504/**
3505 * eel_canvas_w2c:
3506 * @canvas: A canvas.
3507 * @world: rectangle in world coordinates.
3508 * @canvas: rectangle in canvase coordinates.
3509 *
3510 * Converts rectangles in world coordinates into canvas pixel coordinates.
3511 **/
3512void
3513eel_canvas_w2c_rect_d (EelCanvas *canvas,
3514 double *x1, double *y1,
3515 double *x2, double *y2)
3516{
3517 eel_canvas_w2c_d (canvas,
3518 *x1, *y1,
3519 x1, y1);
3520 eel_canvas_w2c_d (canvas,
3521 *x2, *y2,
3522 x2, y2);
3523}
3524
3525
3526
3527/**
3528 * eel_canvas_w2c_d:
3529 * @canvas: A canvas.
3530 * @wx: World X coordinate.
3531 * @wy: World Y coordinate.
3532 * @cx: X pixel coordinate (return value).
3533 * @cy: Y pixel coordinate (return value).
3534 *
3535 * Converts world coordinates into canvas pixel coordinates. This version
3536 * produces coordinates in floating point coordinates, for greater precision.
3537 **/
3538void
3539eel_canvas_w2c_d (EelCanvas *canvas, double wx, double wy, double *cx, double *cy)
3540{
3541 double zoom;
3542
3543 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3544
3545 zoom = canvas->pixels_per_unit;
3546
3547 if (cx)
3548 *cx = (wx - canvas->scroll_x1)*zoom + canvas->zoom_xofs;
3549 if (cy)
3550 *cy = (wy - canvas->scroll_y1)*zoom + canvas->zoom_yofs;
3551}
3552
3553
3554/**
3555 * eel_canvas_c2w:
3556 * @canvas: A canvas.
3557 * @cx: Canvas pixel X coordinate.
3558 * @cy: Canvas pixel Y coordinate.
3559 * @wx: X world coordinate (return value).
3560 * @wy: Y world coordinate (return value).
3561 *
3562 * Converts canvas pixel coordinates to world coordinates.
3563 **/
3564void
3565eel_canvas_c2w (EelCanvas *canvas, int cx, int cy, double *wx, double *wy)
3566{
3567 double zoom;
3568
3569 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3570
3571 zoom = canvas->pixels_per_unit;
3572
3573 if (wx)
3574 *wx = (cx - canvas->zoom_xofs)/zoom + canvas->scroll_x1;
3575 if (wy)
3576 *wy = (cy - canvas->zoom_yofs)/zoom + canvas->scroll_y1;
3577}
3578
3579
3580/**
3581 * eel_canvas_window_to_world:
3582 * @canvas: A canvas.
3583 * @winx: Window-relative X coordinate.
3584 * @winy: Window-relative Y coordinate.
3585 * @worldx: X world coordinate (return value).
3586 * @worldy: Y world coordinate (return value).
3587 *
3588 * Converts window-relative coordinates into world coordinates. You can use
3589 * this when you need to convert mouse coordinates into world coordinates, for
3590 * example.
3591 * Window coordinates are really the same as canvas coordinates now, but this
3592 * function is here for backwards compatibility reasons.
3593 **/
3594void
3595eel_canvas_window_to_world (EelCanvas *canvas, double winx, double winy,
3596 double *worldx, double *worldy)
3597{
3598 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3599
3600 if (worldx)
3601 *worldx = canvas->scroll_x1 + ((winx - canvas->zoom_xofs)
3602 / canvas->pixels_per_unit);
3603
3604 if (worldy)
3605 *worldy = canvas->scroll_y1 + ((winy - canvas->zoom_yofs)
3606 / canvas->pixels_per_unit);
3607}
3608
3609
3610/**
3611 * eel_canvas_world_to_window:
3612 * @canvas: A canvas.
3613 * @worldx: World X coordinate.
3614 * @worldy: World Y coordinate.
3615 * @winx: X window-relative coordinate.
3616 * @winy: Y window-relative coordinate.
3617 *
3618 * Converts world coordinates into window-relative coordinates.
3619 * Window coordinates are really the same as canvas coordinates now, but this
3620 * function is here for backwards compatibility reasons.
3621 **/
3622void
3623eel_canvas_world_to_window (EelCanvas *canvas, double worldx, double worldy,
3624 double *winx, double *winy)
3625{
3626 g_return_if_fail (EEL_IS_CANVAS (canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((canvas)); GType __t = ((eel_canvas_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 ("Eel", ((const char*) (__func__
)), "EEL_IS_CANVAS (canvas)"); return; } } while (0)
;
3627
3628 if (winx)
3629 *winx = (canvas->pixels_per_unit)*(worldx - canvas->scroll_x1) + canvas->zoom_xofs;
3630
3631 if (winy)
3632 *winy = (canvas->pixels_per_unit)*(worldy - canvas->scroll_y1) + canvas->zoom_yofs;
3633}
3634
3635static gboolean
3636boolean_handled_accumulator (GSignalInvocationHint *ihint G_GNUC_UNUSED__attribute__ ((__unused__)),
3637 GValue *return_accu,
3638 const GValue *handler_return,
3639 gpointer dummy G_GNUC_UNUSED__attribute__ ((__unused__)))
3640{
3641 gboolean continue_emission;
3642 gboolean signal_handled;
3643
3644 signal_handled = g_value_get_boolean (handler_return);
3645 g_value_set_boolean (return_accu, signal_handled);
3646 continue_emission = !signal_handled;
3647
3648 return continue_emission;
3649}
3650
3651static guint
3652eel_canvas_item_accessible_add_focus_handler (AtkComponent *component,
3653 AtkFocusHandler handler)
3654{
3655 GSignalMatchType match_type;
3656 guint signal_id;
3657
3658 match_type = G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC;
3659 signal_id = g_signal_lookup ("focus-event", ATK_TYPE_OBJECT(atk_object_get_type ()));
3660
3661 if (!g_signal_handler_find (component, match_type, signal_id, 0, NULL((void*)0),
3662 (gpointer) handler, NULL((void*)0)))
3663 {
3664 return g_signal_connect_closure_by_id (component,
3665 signal_id, 0,
3666 g_cclosure_new (
3667 G_CALLBACK (handler)((GCallback) (handler)), NULL((void*)0),
3668 (GClosureNotify) NULL((void*)0)),
3669 FALSE(0));
3670 }
3671 return 0;
3672}
3673
3674static void
3675eel_canvas_item_accessible_get_item_extents (EelCanvasItem *item,
3676 CdkRectangle *rect)
3677{
3678 double bx1, bx2, by1, by2;
3679 gint scroll_x, scroll_y;
3680 gint x1, x2, y1, y2;
3681
3682 eel_canvas_item_get_bounds (item, &bx1, &by1, &bx2, &by2);
3683 eel_canvas_w2c_rect_d (item->canvas, &bx1, &by1, &bx2, &by2);
3684 eel_canvas_get_scroll_offsets (item->canvas, &scroll_x, &scroll_y);
3685 x1 = floor (bx1 + .5);
3686 y1 = floor (by1 + .5);
3687 x2 = floor (bx2 + .5);
3688 y2 = floor (by2 + .5);
3689 rect->x = x1 - scroll_x;
3690 rect->y = y1 - scroll_y;
3691 rect->width = x2 - x1;
3692 rect->height = y2 - y1;
3693}
3694
3695static gboolean
3696eel_canvas_item_accessible_is_item_in_window (EelCanvasItem *item,
3697 CdkRectangle *rect)
3698{
3699 CtkWidget *widget;
3700 gboolean retval;
3701
3702 widget = CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
;
3703 if (ctk_widget_get_window (widget))
3704 {
3705 int window_width, window_height;
3706
3707 cdk_window_get_geometry (ctk_widget_get_window (widget), NULL((void*)0), NULL((void*)0),
3708 &window_width, &window_height);
3709 /*
3710 * Check whether rectangles intersect
3711 */
3712 if (rect->x + rect->width < 0 ||
3713 rect->y + rect->height < 0 ||
3714 rect->x > window_width ||
3715 rect->y > window_height)
3716 {
3717 retval = FALSE(0);
3718 }
3719 else
3720 {
3721 retval = TRUE(!(0));
3722 }
3723 }
3724 else
3725 {
3726 retval = FALSE(0);
3727 }
3728 return retval;
3729}
3730
3731
3732static void
3733eel_canvas_item_accessible_get_extents (AtkComponent *component,
3734 gint *x,
3735 gint *y,
3736 gint *width,
3737 gint *height,
3738 AtkCoordType coord_type)
3739{
3740 AtkGObjectAccessible *atk_gobj;
3741 GObject *obj;
3742 EelCanvasItem *item;
3743 gint window_x, window_y;
3744 gint toplevel_x, toplevel_y;
3745 CdkRectangle rect;
3746 CdkWindow *window;
3747 CtkWidget *canvas;
3748
3749 atk_gobj = ATK_GOBJECT_ACCESSIBLE (component)((((AtkGObjectAccessible*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((component)), ((atk_gobject_accessible_get_type
()))))))
;
3750 obj = atk_gobject_accessible_get_object (atk_gobj);
3751
3752 if (obj == NULL((void*)0))
3753 {
3754 /* item is defunct */
3755 return;
3756 }
3757
3758 /* Get the CanvasItem */
3759 item = EEL_CANVAS_ITEM (obj)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((eel_canvas_item_get_type ()))))))
;
3760
3761 /* If this item has no parent canvas, something's broken */
3762 g_return_if_fail (CTK_IS_WIDGET (item->canvas))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((item->canvas)); GType __t = ((ctk_widget_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 ("Eel", ((const
char*) (__func__)), "CTK_IS_WIDGET (item->canvas)"); return
; } } while (0)
;
3763
3764 eel_canvas_item_accessible_get_item_extents (item, &rect);
3765 *width = rect.width;
3766 *height = rect.height;
3767 if (!eel_canvas_item_accessible_is_item_in_window (item, &rect))
3768 {
3769 *x = G_MININT(-2147483647 -1);
3770 *y = G_MININT(-2147483647 -1);
3771 return;
3772 }
3773
3774 canvas = CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
;
3775 window = ctk_widget_get_parent_window (canvas);
3776 cdk_window_get_origin (window, &window_x, &window_y);
3777 *x = rect.x + window_x;
3778 *y = rect.y + window_y;
3779 if (coord_type == ATK_XY_WINDOW)
3780 {
3781 window = cdk_window_get_toplevel (ctk_widget_get_window (canvas));
3782 cdk_window_get_origin (window, &toplevel_x, &toplevel_y);
3783 *x -= toplevel_x;
3784 *y -= toplevel_y;
3785 }
3786 return;
3787}
3788
3789static gint
3790eel_canvas_item_accessible_get_mdi_zorder (AtkComponent *component)
3791{
3792 AtkGObjectAccessible *atk_gobj;
3793 GObject *g_obj;
3794 EelCanvasItem *item;
3795
3796 atk_gobj = ATK_GOBJECT_ACCESSIBLE (component)((((AtkGObjectAccessible*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((component)), ((atk_gobject_accessible_get_type
()))))))
;
3797 g_obj = atk_gobject_accessible_get_object (atk_gobj);
3798 if (g_obj == NULL((void*)0))
3799 {
3800 /* Object is defunct */
3801 return -1;
3802 }
3803
3804 item = EEL_CANVAS_ITEM (g_obj)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_obj)), ((eel_canvas_item_get_type ()))))))
;
3805 if (item->parent)
3806 {
3807 return g_list_index (EEL_CANVAS_GROUP (item->parent)((((EelCanvasGroup*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->parent)), ((eel_canvas_group_get_type ()))))))
->item_list, item);
3808 }
3809 else
3810 {
3811 g_return_val_if_fail (item->canvas->root == item, -1)do { if ((item->canvas->root == item)) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "item->canvas->root == item"
); return (-1); } } while (0)
;
3812 return 0;
3813 }
3814}
3815
3816static gboolean
3817eel_canvas_item_accessible_grab_focus (AtkComponent *component)
3818{
3819 AtkGObjectAccessible *atk_gobj;
3820 GObject *obj;
3821 EelCanvasItem *item;
3822 CtkWidget *toplevel;
3823
3824 atk_gobj = ATK_GOBJECT_ACCESSIBLE (component)((((AtkGObjectAccessible*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((component)), ((atk_gobject_accessible_get_type
()))))))
;
3825 obj = atk_gobject_accessible_get_object (atk_gobj);
3826
3827 item = EEL_CANVAS_ITEM (obj)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((eel_canvas_item_get_type ()))))))
;
3828 if (item == NULL((void*)0))
3829 {
3830 /* item is defunct */
3831 return FALSE(0);
3832 }
3833
3834 eel_canvas_item_grab_focus (item);
3835 toplevel = ctk_widget_get_toplevel (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
);
3836 if (ctk_widget_is_toplevel (toplevel))
3837 {
3838 ctk_window_present (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
);
3839 }
3840
3841 return TRUE(!(0));
3842}
3843
3844static void
3845eel_canvas_item_accessible_remove_focus_handler (AtkComponent *component,
3846 guint handler_id)
3847{
3848 g_signal_handler_disconnect (component, handler_id);
3849}
3850
3851static void
3852eel_canvas_item_accessible_component_interface_init (AtkComponentIface *iface)
3853{
3854 g_return_if_fail (iface != NULL)do { if ((iface != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "iface != NULL"); return
; } } while (0)
;
3855
3856 iface->add_focus_handler = eel_canvas_item_accessible_add_focus_handler;
3857 iface->get_extents = eel_canvas_item_accessible_get_extents;
3858 iface->get_mdi_zorder = eel_canvas_item_accessible_get_mdi_zorder;
3859 iface->grab_focus = eel_canvas_item_accessible_grab_focus;
3860 iface->remove_focus_handler = eel_canvas_item_accessible_remove_focus_handler;
3861}
3862
3863static gboolean
3864eel_canvas_item_accessible_is_item_on_screen (EelCanvasItem *item)
3865{
3866 CdkRectangle rect;
3867
3868 eel_canvas_item_accessible_get_item_extents (item, &rect);
3869 return eel_canvas_item_accessible_is_item_in_window (item, &rect);
3870}
3871
3872static void
3873eel_canvas_item_accessible_initialize (AtkObject *obj, gpointer data)
3874{
3875 if (ATK_OBJECT_CLASS (accessible_item_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((accessible_item_parent_class)), ((atk_object_get_type ()
))))))
->initialize != NULL((void*)0))
3876 ATK_OBJECT_CLASS (accessible_item_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((accessible_item_parent_class)), ((atk_object_get_type ()
))))))
->initialize (obj, data);
3877 g_object_set_data (G_OBJECT (obj)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), (((GType) ((20) << (2))))))))
, "atk-component-layer",
3878 GINT_TO_POINTER (ATK_LAYER_MDI)((gpointer) (glong) (ATK_LAYER_MDI)));
3879}
3880
3881static AtkStateSet*
3882eel_canvas_item_accessible_ref_state_set (AtkObject *accessible)
3883{
3884 AtkGObjectAccessible *atk_gobj;
3885 GObject *obj;
3886 EelCanvasItem *item;
3887 AtkStateSet *state_set;
3888
3889 state_set = ATK_OBJECT_CLASS (accessible_item_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((accessible_item_parent_class)), ((atk_object_get_type ()
))))))
->ref_state_set (accessible);
3890 atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible)((((AtkGObjectAccessible*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((accessible)), ((atk_gobject_accessible_get_type
()))))))
;
3891 obj = atk_gobject_accessible_get_object (atk_gobj);
3892
3893 item = EEL_CANVAS_ITEM (obj)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((obj)), ((eel_canvas_item_get_type ()))))))
;
3894 if (item == NULL((void*)0))
3895 {
3896 atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
3897 }
3898 else
3899 {
3900 if (item->flags & EEL_CANVAS_ITEM_VISIBLE)
3901 {
3902 atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
3903
3904 if (eel_canvas_item_accessible_is_item_on_screen (item))
3905 {
3906 atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
3907 }
3908 }
3909 if (ctk_widget_get_can_focus (CTK_WIDGET (item->canvas)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item->canvas)), ((ctk_widget_get_type ()))))))
))
3910 {
3911 atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
3912
3913 if (item->canvas->focused_item == item)
3914 {
3915 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
3916 }
3917 }
3918 }
3919
3920 return state_set;
3921}
3922
3923G_DEFINE_TYPE_WITH_CODE (EelCanvasItemAccessible,static void eel_canvas_item_accessible_init (EelCanvasItemAccessible
*self); static void eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass
*klass); static GType eel_canvas_item_accessible_get_type_once
(void); static gpointer eel_canvas_item_accessible_parent_class
= ((void*)0); static gint EelCanvasItemAccessible_private_offset
; static void eel_canvas_item_accessible_class_intern_init (gpointer
klass) { eel_canvas_item_accessible_parent_class = g_type_class_peek_parent
(klass); if (EelCanvasItemAccessible_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EelCanvasItemAccessible_private_offset); eel_canvas_item_accessible_class_init
((EelCanvasItemAccessibleClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer eel_canvas_item_accessible_get_instance_private
(EelCanvasItemAccessible *self) { return (((gpointer) ((guint8
*) (self) + (glong) (EelCanvasItemAccessible_private_offset))
)); } GType eel_canvas_item_accessible_get_type (void) { static
GType 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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_item_accessible_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_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType eel_canvas_item_accessible_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((atk_gobject_accessible_get_type ()), g_intern_static_string
("EelCanvasItemAccessible"), sizeof (EelCanvasItemAccessibleClass
), (GClassInitFunc)(void (*)(void)) eel_canvas_item_accessible_class_intern_init
, sizeof (EelCanvasItemAccessible), (GInstanceInitFunc)(void (
*)(void)) eel_canvas_item_accessible_init, (GTypeFlags) 0); {
{{ const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) eel_canvas_item_accessible_component_interface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (atk_component_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
3924 eel_canvas_item_accessible,static void eel_canvas_item_accessible_init (EelCanvasItemAccessible
*self); static void eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass
*klass); static GType eel_canvas_item_accessible_get_type_once
(void); static gpointer eel_canvas_item_accessible_parent_class
= ((void*)0); static gint EelCanvasItemAccessible_private_offset
; static void eel_canvas_item_accessible_class_intern_init (gpointer
klass) { eel_canvas_item_accessible_parent_class = g_type_class_peek_parent
(klass); if (EelCanvasItemAccessible_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EelCanvasItemAccessible_private_offset); eel_canvas_item_accessible_class_init
((EelCanvasItemAccessibleClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer eel_canvas_item_accessible_get_instance_private
(EelCanvasItemAccessible *self) { return (((gpointer) ((guint8
*) (self) + (glong) (EelCanvasItemAccessible_private_offset))
)); } GType eel_canvas_item_accessible_get_type (void) { static
GType 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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_item_accessible_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_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType eel_canvas_item_accessible_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((atk_gobject_accessible_get_type ()), g_intern_static_string
("EelCanvasItemAccessible"), sizeof (EelCanvasItemAccessibleClass
), (GClassInitFunc)(void (*)(void)) eel_canvas_item_accessible_class_intern_init
, sizeof (EelCanvasItemAccessible), (GInstanceInitFunc)(void (
*)(void)) eel_canvas_item_accessible_init, (GTypeFlags) 0); {
{{ const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) eel_canvas_item_accessible_component_interface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (atk_component_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
3925 ATK_TYPE_GOBJECT_ACCESSIBLE,static void eel_canvas_item_accessible_init (EelCanvasItemAccessible
*self); static void eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass
*klass); static GType eel_canvas_item_accessible_get_type_once
(void); static gpointer eel_canvas_item_accessible_parent_class
= ((void*)0); static gint EelCanvasItemAccessible_private_offset
; static void eel_canvas_item_accessible_class_intern_init (gpointer
klass) { eel_canvas_item_accessible_parent_class = g_type_class_peek_parent
(klass); if (EelCanvasItemAccessible_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EelCanvasItemAccessible_private_offset); eel_canvas_item_accessible_class_init
((EelCanvasItemAccessibleClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer eel_canvas_item_accessible_get_instance_private
(EelCanvasItemAccessible *self) { return (((gpointer) ((guint8
*) (self) + (glong) (EelCanvasItemAccessible_private_offset))
)); } GType eel_canvas_item_accessible_get_type (void) { static
GType 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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_item_accessible_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_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType eel_canvas_item_accessible_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((atk_gobject_accessible_get_type ()), g_intern_static_string
("EelCanvasItemAccessible"), sizeof (EelCanvasItemAccessibleClass
), (GClassInitFunc)(void (*)(void)) eel_canvas_item_accessible_class_intern_init
, sizeof (EelCanvasItemAccessible), (GInstanceInitFunc)(void (
*)(void)) eel_canvas_item_accessible_init, (GTypeFlags) 0); {
{{ const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) eel_canvas_item_accessible_component_interface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (atk_component_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
3926 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT,static void eel_canvas_item_accessible_init (EelCanvasItemAccessible
*self); static void eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass
*klass); static GType eel_canvas_item_accessible_get_type_once
(void); static gpointer eel_canvas_item_accessible_parent_class
= ((void*)0); static gint EelCanvasItemAccessible_private_offset
; static void eel_canvas_item_accessible_class_intern_init (gpointer
klass) { eel_canvas_item_accessible_parent_class = g_type_class_peek_parent
(klass); if (EelCanvasItemAccessible_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EelCanvasItemAccessible_private_offset); eel_canvas_item_accessible_class_init
((EelCanvasItemAccessibleClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer eel_canvas_item_accessible_get_instance_private
(EelCanvasItemAccessible *self) { return (((gpointer) ((guint8
*) (self) + (glong) (EelCanvasItemAccessible_private_offset))
)); } GType eel_canvas_item_accessible_get_type (void) { static
GType 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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_item_accessible_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_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType eel_canvas_item_accessible_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((atk_gobject_accessible_get_type ()), g_intern_static_string
("EelCanvasItemAccessible"), sizeof (EelCanvasItemAccessibleClass
), (GClassInitFunc)(void (*)(void)) eel_canvas_item_accessible_class_intern_init
, sizeof (EelCanvasItemAccessible), (GInstanceInitFunc)(void (
*)(void)) eel_canvas_item_accessible_init, (GTypeFlags) 0); {
{{ const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) eel_canvas_item_accessible_component_interface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (atk_component_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
3927 eel_canvas_item_accessible_component_interface_init))static void eel_canvas_item_accessible_init (EelCanvasItemAccessible
*self); static void eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass
*klass); static GType eel_canvas_item_accessible_get_type_once
(void); static gpointer eel_canvas_item_accessible_parent_class
= ((void*)0); static gint EelCanvasItemAccessible_private_offset
; static void eel_canvas_item_accessible_class_intern_init (gpointer
klass) { eel_canvas_item_accessible_parent_class = g_type_class_peek_parent
(klass); if (EelCanvasItemAccessible_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EelCanvasItemAccessible_private_offset); eel_canvas_item_accessible_class_init
((EelCanvasItemAccessibleClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer eel_canvas_item_accessible_get_instance_private
(EelCanvasItemAccessible *self) { return (((gpointer) ((guint8
*) (self) + (glong) (EelCanvasItemAccessible_private_offset))
)); } GType eel_canvas_item_accessible_get_type (void) { static
GType 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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_item_accessible_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_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType eel_canvas_item_accessible_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((atk_gobject_accessible_get_type ()), g_intern_static_string
("EelCanvasItemAccessible"), sizeof (EelCanvasItemAccessibleClass
), (GClassInitFunc)(void (*)(void)) eel_canvas_item_accessible_class_intern_init
, sizeof (EelCanvasItemAccessible), (GInstanceInitFunc)(void (
*)(void)) eel_canvas_item_accessible_init, (GTypeFlags) 0); {
{{ const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) eel_canvas_item_accessible_component_interface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (atk_component_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
;
3928
3929static void
3930eel_canvas_item_accessible_class_init (EelCanvasItemAccessibleClass *klass)
3931{
3932 AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((atk_object_get_type ()))))))
;
3933 accessible_item_parent_class = g_type_class_peek_parent (atk_class);
3934
3935 atk_class->initialize = eel_canvas_item_accessible_initialize;
3936 atk_class->ref_state_set = eel_canvas_item_accessible_ref_state_set;
3937}
3938
3939static void
3940eel_canvas_item_accessible_init (EelCanvasItemAccessible *accessible G_GNUC_UNUSED__attribute__ ((__unused__)))
3941{
3942}
3943
3944static AtkObject *
3945eel_canvas_item_accessible_create (GObject *for_object)
3946{
3947 GType type;
3948 AtkObject *accessible;
3949 EelCanvasItem *item;
3950
3951 item = EEL_CANVAS_ITEM (for_object)((((EelCanvasItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((for_object)), ((eel_canvas_item_get_type ()))))))
;
3952 g_return_val_if_fail (item != NULL, NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "item != NULL"); return (
((void*)0)); } } while (0)
;
3953
3954 type = eel_canvas_item_accessible_get_type ();
3955 if (type == G_TYPE_INVALID((GType) ((0) << (2))))
3956 {
3957 return atk_no_op_object_new (for_object);
3958 }
3959
3960 accessible = g_object_new (type, NULL((void*)0));
3961 atk_object_initialize (accessible, for_object);
3962 return accessible;
3963}
3964
3965static GType
3966eel_canvas_item_accessible_factory_get_accessible_type (void)
3967{
3968 return eel_canvas_item_accessible_get_type ();
3969}
3970
3971static AtkObject*
3972eel_canvas_item_accessible_factory_create_accessible (GObject *obj)
3973{
3974 AtkObject *accessible;
3975
3976 g_return_val_if_fail (G_IS_OBJECT (obj), NULL)do { if (((((g_type_check_instance_is_fundamentally_a ((GTypeInstance
*) ((obj)), (((GType) ((20) << (2)))))))))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "G_IS_OBJECT (obj)"); return
(((void*)0)); } } while (0)
;
3977
3978 accessible = eel_canvas_item_accessible_create (obj);
3979
3980 return accessible;
3981}
3982
3983static GType eel_canvas_item_accessible_factory_get_type (void);
3984
3985typedef AtkObjectFactory EelCanvasItemAccessibleFactory;
3986typedef AtkObjectFactoryClass EelCanvasItemAccessibleFactoryClass;
3987G_DEFINE_TYPE (EelCanvasItemAccessibleFactory, eel_canvas_item_accessible_factory,static void eel_canvas_item_accessible_factory_init (EelCanvasItemAccessibleFactory
*self); static void eel_canvas_item_accessible_factory_class_init
(EelCanvasItemAccessibleFactoryClass *klass); static GType eel_canvas_item_accessible_factory_get_type_once
(void); static gpointer eel_canvas_item_accessible_factory_parent_class
= ((void*)0); static gint EelCanvasItemAccessibleFactory_private_offset
; static void eel_canvas_item_accessible_factory_class_intern_init
(gpointer klass) { eel_canvas_item_accessible_factory_parent_class
= g_type_class_peek_parent (klass); if (EelCanvasItemAccessibleFactory_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EelCanvasItemAccessibleFactory_private_offset
); eel_canvas_item_accessible_factory_class_init ((EelCanvasItemAccessibleFactoryClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
eel_canvas_item_accessible_factory_get_instance_private (EelCanvasItemAccessibleFactory
*self) { return (((gpointer) ((guint8*) (self) + (glong) (EelCanvasItemAccessibleFactory_private_offset
)))); } GType eel_canvas_item_accessible_factory_get_type (void
) { static GType 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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_item_accessible_factory_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_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType eel_canvas_item_accessible_factory_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((atk_object_factory_get_type ()), g_intern_static_string ("EelCanvasItemAccessibleFactory"
), sizeof (EelCanvasItemAccessibleFactoryClass), (GClassInitFunc
)(void (*)(void)) eel_canvas_item_accessible_factory_class_intern_init
, sizeof (EelCanvasItemAccessibleFactory), (GInstanceInitFunc
)(void (*)(void)) eel_canvas_item_accessible_factory_init, (GTypeFlags
) 0); { {{};} } return g_define_type_id; }
3988 ATK_TYPE_OBJECT_FACTORY)static void eel_canvas_item_accessible_factory_init (EelCanvasItemAccessibleFactory
*self); static void eel_canvas_item_accessible_factory_class_init
(EelCanvasItemAccessibleFactoryClass *klass); static GType eel_canvas_item_accessible_factory_get_type_once
(void); static gpointer eel_canvas_item_accessible_factory_parent_class
= ((void*)0); static gint EelCanvasItemAccessibleFactory_private_offset
; static void eel_canvas_item_accessible_factory_class_intern_init
(gpointer klass) { eel_canvas_item_accessible_factory_parent_class
= g_type_class_peek_parent (klass); if (EelCanvasItemAccessibleFactory_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &EelCanvasItemAccessibleFactory_private_offset
); eel_canvas_item_accessible_factory_class_init ((EelCanvasItemAccessibleFactoryClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
eel_canvas_item_accessible_factory_get_instance_private (EelCanvasItemAccessibleFactory
*self) { return (((gpointer) ((guint8*) (self) + (glong) (EelCanvasItemAccessibleFactory_private_offset
)))); } GType eel_canvas_item_accessible_factory_get_type (void
) { static GType 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_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= eel_canvas_item_accessible_factory_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_pointer ((&static_g_define_type_id
), (gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType eel_canvas_item_accessible_factory_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((atk_object_factory_get_type ()), g_intern_static_string ("EelCanvasItemAccessibleFactory"
), sizeof (EelCanvasItemAccessibleFactoryClass), (GClassInitFunc
)(void (*)(void)) eel_canvas_item_accessible_factory_class_intern_init
, sizeof (EelCanvasItemAccessibleFactory), (GInstanceInitFunc
)(void (*)(void)) eel_canvas_item_accessible_factory_init, (GTypeFlags
) 0); { {{};} } return g_define_type_id; }
3989
3990static void
3991eel_canvas_item_accessible_factory_class_init (AtkObjectFactoryClass *klass)
3992{
3993 klass->create_accessible = eel_canvas_item_accessible_factory_create_accessible;
3994 klass->get_accessible_type = eel_canvas_item_accessible_factory_get_accessible_type;
3995}
3996
3997static void
3998eel_canvas_item_accessible_factory_init (EelCanvasItemAccessibleFactory *accessible G_GNUC_UNUSED__attribute__ ((__unused__)))
3999{
4000}
4001
4002/* Class initialization function for EelCanvasItemClass */
4003static void
4004eel_canvas_item_class_init (EelCanvasItemClass *klass)
4005{
4006 GObjectClass *gobject_class = (GObjectClass *) klass;
4007
4008 item_parent_class = g_type_class_peek_parent (klass);
4009
4010 gobject_class->set_property = eel_canvas_item_set_property;
4011 gobject_class->get_property = eel_canvas_item_get_property;
4012 gobject_class->dispose = eel_canvas_item_dispose;
4013
4014 g_object_class_install_property
4015 (gobject_class, ITEM_PROP_PARENT,
4016 g_param_spec_object ("parent", NULL((void*)0), NULL((void*)0),
4017 EEL_TYPE_CANVAS_ITEM(eel_canvas_item_get_type ()),
4018 G_PARAM_READWRITE));
4019
4020 g_object_class_install_property
4021 (gobject_class, ITEM_PROP_VISIBLE,
4022 g_param_spec_boolean ("visible", NULL((void*)0), NULL((void*)0),
4023 TRUE(!(0)),
4024 G_PARAM_READWRITE));
4025
4026 item_signals[ITEM_EVENT] =
4027 g_signal_new ("event",
4028 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
4029 G_SIGNAL_RUN_LAST,
4030 G_STRUCT_OFFSET (EelCanvasItemClass, event)((glong) __builtin_offsetof(EelCanvasItemClass, event)),
4031 boolean_handled_accumulator, NULL((void*)0),
4032 eel_marshal_BOOLEAN__BOXED,
4033 G_TYPE_BOOLEAN((GType) ((5) << (2))), 1,
4034 CDK_TYPE_EVENT(cdk_event_get_type ()) | G_SIGNAL_TYPE_STATIC_SCOPE(((GType) (1 << 0))));
4035
4036 item_signals[ITEM_DESTROY] =
4037 g_signal_new ("destroy",
4038 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
4039 G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
4040 G_STRUCT_OFFSET (EelCanvasItemClass, destroy)((glong) __builtin_offsetof(EelCanvasItemClass, destroy)),
4041 NULL((void*)0), NULL((void*)0),
4042 g_cclosure_marshal_VOID__VOID,
4043 G_TYPE_NONE((GType) ((1) << (2))), 0);
4044
4045 klass->realize = eel_canvas_item_realize;
4046 klass->unrealize = eel_canvas_item_unrealize;
4047 klass->map = eel_canvas_item_map;
4048 klass->unmap = eel_canvas_item_unmap;
4049 klass->update = eel_canvas_item_update;
4050
4051 atk_registry_set_factory_type (atk_get_default_registry (),
4052 EEL_TYPE_CANVAS_ITEM(eel_canvas_item_get_type ()),
4053 eel_canvas_item_accessible_factory_get_type ());
4054}