File: | ctk/a11y/ctktoplevelaccessible.c |
Warning: | line 118, column 3 Value stored to 'obj' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* CTK+ - accessibility implementations |
2 | * Copyright 2001, 2002, 2003 Sun Microsystems Inc. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #include "config.h" |
19 | |
20 | #include <stdlib.h> |
21 | #include <string.h> |
22 | |
23 | #include <ctk/ctkeventbox.h> |
24 | #include <ctk/ctkscrolledwindow.h> |
25 | #include <ctk/ctkframe.h> |
26 | #include <ctk/ctkmenu.h> |
27 | #include <ctk/ctkmenuitem.h> |
28 | #include <ctk/ctkbutton.h> |
29 | #include <ctk/ctkplug.h> |
30 | #include <ctk/ctkwindow.h> |
31 | |
32 | #include "ctktoplevelaccessible.h" |
33 | |
34 | struct _CtkToplevelAccessiblePrivate |
35 | { |
36 | GList *window_list; |
37 | }; |
38 | |
39 | G_DEFINE_TYPE_WITH_PRIVATE (CtkToplevelAccessible, ctk_toplevel_accessible, ATK_TYPE_OBJECT)static void ctk_toplevel_accessible_init (CtkToplevelAccessible *self); static void ctk_toplevel_accessible_class_init (CtkToplevelAccessibleClass *klass); static GType ctk_toplevel_accessible_get_type_once ( void); static gpointer ctk_toplevel_accessible_parent_class = ((void*)0); static gint CtkToplevelAccessible_private_offset ; static void ctk_toplevel_accessible_class_intern_init (gpointer klass) { ctk_toplevel_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkToplevelAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkToplevelAccessible_private_offset); ctk_toplevel_accessible_class_init ((CtkToplevelAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_toplevel_accessible_get_instance_private (CtkToplevelAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkToplevelAccessible_private_offset)))) ; } GType ctk_toplevel_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 = ctk_toplevel_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 ctk_toplevel_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((atk_object_get_type ()), g_intern_static_string ("CtkToplevelAccessible" ), sizeof (CtkToplevelAccessibleClass), (GClassInitFunc)(void (*)(void)) ctk_toplevel_accessible_class_intern_init, sizeof (CtkToplevelAccessible), (GInstanceInitFunc)(void (*)(void)) ctk_toplevel_accessible_init, (GTypeFlags) 0); { {{ CtkToplevelAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkToplevelAccessiblePrivate )); };} } return g_define_type_id; } |
40 | |
41 | static void |
42 | ctk_toplevel_accessible_initialize (AtkObject *accessible, |
43 | gpointer data) |
44 | { |
45 | ATK_OBJECT_CLASS (ctk_toplevel_accessible_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_toplevel_accessible_parent_class)), ((atk_object_get_type ()))))))->initialize (accessible, data); |
46 | |
47 | accessible->role = ATK_ROLE_APPLICATION; |
48 | accessible->accessible_parent = NULL((void*)0); |
49 | } |
50 | |
51 | static void |
52 | ctk_toplevel_accessible_object_finalize (GObject *obj) |
53 | { |
54 | CtkToplevelAccessible *toplevel = CTK_TOPLEVEL_ACCESSIBLE (obj)((((CtkToplevelAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_toplevel_accessible_get_type ())))))); |
55 | |
56 | if (toplevel->priv->window_list) |
57 | g_list_free (toplevel->priv->window_list); |
58 | |
59 | G_OBJECT_CLASS (ctk_toplevel_accessible_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_toplevel_accessible_parent_class)), (((GType) ((20) << (2))))))))->finalize (obj); |
60 | } |
61 | |
62 | static gint |
63 | ctk_toplevel_accessible_get_n_children (AtkObject *obj) |
64 | { |
65 | CtkToplevelAccessible *toplevel = CTK_TOPLEVEL_ACCESSIBLE (obj)((((CtkToplevelAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_toplevel_accessible_get_type ())))))); |
66 | |
67 | return g_list_length (toplevel->priv->window_list); |
68 | } |
69 | |
70 | static AtkObject * |
71 | ctk_toplevel_accessible_ref_child (AtkObject *obj, |
72 | gint i) |
73 | { |
74 | CtkToplevelAccessible *toplevel; |
75 | CtkWidget *widget; |
76 | AtkObject *atk_obj; |
77 | |
78 | toplevel = CTK_TOPLEVEL_ACCESSIBLE (obj)((((CtkToplevelAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_toplevel_accessible_get_type ())))))); |
79 | widget = g_list_nth_data (toplevel->priv->window_list, i); |
80 | if (!widget) |
81 | return NULL((void*)0); |
82 | |
83 | atk_obj = ctk_widget_get_accessible (widget); |
84 | |
85 | g_object_ref (atk_obj)((__typeof__ (atk_obj)) (g_object_ref) (atk_obj)); |
86 | |
87 | return atk_obj; |
88 | } |
89 | |
90 | static const char * |
91 | ctk_toplevel_accessible_get_name (AtkObject *obj G_GNUC_UNUSED__attribute__ ((__unused__))) |
92 | { |
93 | return g_get_prgname (); |
94 | } |
95 | |
96 | static gboolean |
97 | is_combo_window (CtkWidget *widget) |
98 | { |
99 | CtkWidget *child; |
100 | AtkObject *obj; |
101 | |
102 | child = ctk_bin_get_child (CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_bin_get_type ()))))))); |
103 | |
104 | if (!CTK_IS_EVENT_BOX (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_event_box_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; }))))) |
105 | return FALSE(0); |
106 | |
107 | child = ctk_bin_get_child (CTK_BIN (child)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_bin_get_type ()))))))); |
108 | |
109 | if (!CTK_IS_FRAME (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_frame_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; }))))) |
110 | return FALSE(0); |
111 | |
112 | child = ctk_bin_get_child (CTK_BIN (child)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_bin_get_type ()))))))); |
113 | |
114 | if (!CTK_IS_SCROLLED_WINDOW (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_scrolled_window_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; }))))) |
115 | return FALSE(0); |
116 | |
117 | obj = ctk_widget_get_accessible (child); |
118 | obj = atk_object_get_parent (obj); |
Value stored to 'obj' is never read | |
119 | |
120 | return FALSE(0); |
121 | } |
122 | |
123 | static gboolean |
124 | is_attached_menu_window (CtkWidget *widget) |
125 | { |
126 | CtkWidget *child; |
127 | |
128 | child = ctk_bin_get_child (CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_bin_get_type ()))))))); |
129 | if (CTK_IS_MENU (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (child)); GType __t = ((ctk_menu_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; }))))) |
130 | { |
131 | CtkWidget *attach; |
132 | |
133 | attach = ctk_menu_get_attach_widget (CTK_MENU (child)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_menu_get_type ()))))))); |
134 | /* Allow for menu belonging to the Panel Menu, which is a CtkButton */ |
135 | if (CTK_IS_MENU_ITEM (attach)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (attach)); GType __t = ((ctk_menu_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; })))) || CTK_IS_BUTTON (attach)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (attach)); GType __t = ((ctk_button_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; }))))) |
136 | return TRUE(!(0)); |
137 | } |
138 | |
139 | return FALSE(0); |
140 | } |
141 | |
142 | static void |
143 | ctk_toplevel_accessible_class_init (CtkToplevelAccessibleClass *klass) |
144 | { |
145 | AtkObjectClass *class = ATK_OBJECT_CLASS(klass)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((atk_object_get_type ())))))); |
146 | GObjectClass *g_object_class = G_OBJECT_CLASS(klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
147 | |
148 | class->initialize = ctk_toplevel_accessible_initialize; |
149 | class->get_n_children = ctk_toplevel_accessible_get_n_children; |
150 | class->ref_child = ctk_toplevel_accessible_ref_child; |
151 | class->get_parent = NULL((void*)0); |
152 | class->get_name = ctk_toplevel_accessible_get_name; |
153 | |
154 | g_object_class->finalize = ctk_toplevel_accessible_object_finalize; |
155 | } |
156 | |
157 | static void |
158 | remove_child (CtkToplevelAccessible *toplevel, |
159 | CtkWindow *window) |
160 | { |
161 | AtkObject *atk_obj = ATK_OBJECT (toplevel)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((atk_object_get_type ())))))); |
162 | GList *l; |
163 | guint window_count = 0; |
164 | |
165 | if (toplevel->priv->window_list) |
166 | { |
167 | for (l = toplevel->priv->window_list; l; l = l->next) |
168 | { |
169 | CtkWindow *tmp_window; |
170 | |
171 | tmp_window = CTK_WINDOW (l->data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_window_get_type ())))))); |
172 | |
173 | if (window == tmp_window) |
174 | { |
175 | AtkObject *child; |
176 | |
177 | /* Remove the window from the window_list & emit the signal */ |
178 | toplevel->priv->window_list = g_list_delete_link (toplevel->priv->window_list, l); |
179 | child = ctk_widget_get_accessible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); |
180 | g_signal_emit_by_name (atk_obj, "children-changed::remove", |
181 | window_count, child, NULL((void*)0)); |
182 | atk_object_set_parent (child, NULL((void*)0)); |
183 | break; |
184 | } |
185 | |
186 | window_count++; |
187 | } |
188 | } |
189 | } |
190 | |
191 | static gboolean |
192 | show_event_watcher (GSignalInvocationHint *ihint G_GNUC_UNUSED__attribute__ ((__unused__)), |
193 | guint n_param_values G_GNUC_UNUSED__attribute__ ((__unused__)), |
194 | const GValue *param_values, |
195 | gpointer data) |
196 | { |
197 | CtkToplevelAccessible *toplevel = CTK_TOPLEVEL_ACCESSIBLE (data)((((CtkToplevelAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data)), ((ctk_toplevel_accessible_get_type ())))))); |
198 | AtkObject *atk_obj = ATK_OBJECT (toplevel)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((atk_object_get_type ())))))); |
199 | GObject *object; |
200 | CtkWidget *widget; |
201 | gint n_children; |
202 | AtkObject *child; |
203 | |
204 | object = g_value_get_object (param_values + 0); |
205 | |
206 | if (!CTK_IS_WINDOW (object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ctk_window_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; }))))) |
207 | return TRUE(!(0)); |
208 | |
209 | widget = CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_widget_get_type ())))))); |
210 | if (ctk_widget_get_parent (widget) || |
211 | is_attached_menu_window (widget) || |
212 | #ifdef CDK_WINDOWING_X11 |
213 | CTK_IS_PLUG (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_plug_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; })))) || |
214 | #endif |
215 | is_combo_window (widget)) |
216 | return TRUE(!(0)); |
217 | |
218 | child = ctk_widget_get_accessible (widget); |
219 | if (atk_object_get_role (child) == ATK_ROLE_REDUNDANT_OBJECT || |
220 | atk_object_get_role (child) == ATK_ROLE_TOOL_TIP) |
221 | return TRUE(!(0)); |
222 | |
223 | /* Add the window to the list & emit the signal */ |
224 | toplevel->priv->window_list = g_list_append (toplevel->priv->window_list, widget); |
225 | n_children = g_list_length (toplevel->priv->window_list); |
226 | |
227 | atk_object_set_parent (child, atk_obj); |
228 | g_signal_emit_by_name (atk_obj, "children-changed::add", |
229 | n_children - 1, child, NULL((void*)0)); |
230 | |
231 | g_signal_connect_swapped (G_OBJECT(object), "destroy",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), (((GType) ((20) << (2))) )))))), ("destroy"), (((GCallback) (remove_child))), (toplevel ), ((void*)0), G_CONNECT_SWAPPED) |
232 | G_CALLBACK (remove_child), toplevel)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), (((GType) ((20) << (2))) )))))), ("destroy"), (((GCallback) (remove_child))), (toplevel ), ((void*)0), G_CONNECT_SWAPPED); |
233 | |
234 | return TRUE(!(0)); |
235 | } |
236 | |
237 | static gboolean |
238 | hide_event_watcher (GSignalInvocationHint *ihint G_GNUC_UNUSED__attribute__ ((__unused__)), |
239 | guint n_param_values G_GNUC_UNUSED__attribute__ ((__unused__)), |
240 | const GValue *param_values, |
241 | gpointer data) |
242 | { |
243 | CtkToplevelAccessible *toplevel = CTK_TOPLEVEL_ACCESSIBLE (data)((((CtkToplevelAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data)), ((ctk_toplevel_accessible_get_type ())))))); |
244 | GObject *object; |
245 | |
246 | object = g_value_get_object (param_values + 0); |
247 | |
248 | if (!CTK_IS_WINDOW (object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ctk_window_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; }))))) |
249 | return TRUE(!(0)); |
250 | |
251 | remove_child (toplevel, CTK_WINDOW (object)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_window_get_type ()))))))); |
252 | return TRUE(!(0)); |
253 | } |
254 | |
255 | static void |
256 | ctk_toplevel_accessible_init (CtkToplevelAccessible *toplevel) |
257 | { |
258 | CtkWindow *window; |
259 | CtkWidget *widget; |
260 | GList *l; |
261 | guint signal_id; |
262 | |
263 | toplevel->priv = ctk_toplevel_accessible_get_instance_private (toplevel); |
264 | |
265 | l = toplevel->priv->window_list = ctk_window_list_toplevels (); |
266 | |
267 | while (l) |
268 | { |
269 | window = CTK_WINDOW (l->data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_window_get_type ())))))); |
270 | widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))); |
271 | if (!window || |
272 | !ctk_widget_get_visible (widget) || |
273 | is_attached_menu_window (widget) || |
274 | #ifdef CDK_WINDOWING_X11 |
275 | CTK_IS_PLUG (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (window)); GType __t = ((ctk_plug_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; })))) || |
276 | #endif |
277 | ctk_widget_get_parent (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) |
278 | { |
279 | GList *temp_l = l->next; |
280 | |
281 | toplevel->priv->window_list = g_list_delete_link (toplevel->priv->window_list, l); |
282 | l = temp_l; |
283 | } |
284 | else |
285 | { |
286 | g_signal_connect_swapped (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("destroy"), (((GCallback) (remove_child))), (toplevel ), ((void*)0), G_CONNECT_SWAPPED) |
287 | G_CALLBACK (remove_child), toplevel)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (((GType) ((20) << (2))) )))))), ("destroy"), (((GCallback) (remove_child))), (toplevel ), ((void*)0), G_CONNECT_SWAPPED); |
288 | l = l->next; |
289 | } |
290 | } |
291 | |
292 | g_type_class_ref (CTK_TYPE_WINDOW(ctk_window_get_type ())); |
293 | |
294 | signal_id = g_signal_lookup ("show", CTK_TYPE_WINDOW(ctk_window_get_type ())); |
295 | g_signal_add_emission_hook (signal_id, 0, |
296 | show_event_watcher, toplevel, (GDestroyNotify) NULL((void*)0)); |
297 | |
298 | signal_id = g_signal_lookup ("hide", CTK_TYPE_WINDOW(ctk_window_get_type ())); |
299 | g_signal_add_emission_hook (signal_id, 0, |
300 | hide_event_watcher, toplevel, (GDestroyNotify) NULL((void*)0)); |
301 | } |
302 | |
303 | /** |
304 | * ctk_toplevel_accessible_get_children: |
305 | * |
306 | * Returns: (transfer none) (element-type Ctk.Window): List of |
307 | * children. |
308 | */ |
309 | GList * |
310 | ctk_toplevel_accessible_get_children (CtkToplevelAccessible *accessible) |
311 | { |
312 | return accessible->priv->window_list; |
313 | } |