Bug Summary

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

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