File: | ctk/a11y/ctktreeviewaccessible.c |
Warning: | line 948, column 9 Array access (from variable 'selected') results in a null pointer dereference |
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 <ctk/ctk.h> | |||
21 | #ifdef CDK_WINDOWING_X11 | |||
22 | #include <cdk/x11/cdkx.h> | |||
23 | #endif | |||
24 | ||||
25 | #include "ctktreeprivate.h" | |||
26 | #include "ctkwidgetprivate.h" | |||
27 | ||||
28 | #include "ctktreeviewaccessibleprivate.h" | |||
29 | ||||
30 | #include "ctkrenderercellaccessible.h" | |||
31 | #include "ctkbooleancellaccessible.h" | |||
32 | #include "ctkimagecellaccessible.h" | |||
33 | #include "ctkcontainercellaccessible.h" | |||
34 | #include "ctktextcellaccessible.h" | |||
35 | #include "ctkcellaccessibleparent.h" | |||
36 | #include "ctkcellaccessibleprivate.h" | |||
37 | ||||
38 | struct _CtkTreeViewAccessiblePrivate | |||
39 | { | |||
40 | GHashTable *cell_infos; | |||
41 | }; | |||
42 | ||||
43 | typedef struct _CtkTreeViewAccessibleCellInfo CtkTreeViewAccessibleCellInfo; | |||
44 | struct _CtkTreeViewAccessibleCellInfo | |||
45 | { | |||
46 | CtkCellAccessible *cell; | |||
47 | CtkRBTree *tree; | |||
48 | CtkRBNode *node; | |||
49 | CtkTreeViewColumn *cell_col_ref; | |||
50 | CtkTreeViewAccessible *view; | |||
51 | }; | |||
52 | ||||
53 | /* Misc */ | |||
54 | ||||
55 | static int cell_info_get_index (CtkTreeView *tree_view, | |||
56 | CtkTreeViewAccessibleCellInfo *info); | |||
57 | static gboolean is_cell_showing (CtkTreeView *tree_view, | |||
58 | CdkRectangle *cell_rect); | |||
59 | ||||
60 | static void cell_info_new (CtkTreeViewAccessible *accessible, | |||
61 | CtkRBTree *tree, | |||
62 | CtkRBNode *node, | |||
63 | CtkTreeViewColumn *tv_col, | |||
64 | CtkCellAccessible *cell); | |||
65 | static gint get_column_number (CtkTreeView *tree_view, | |||
66 | CtkTreeViewColumn *column); | |||
67 | ||||
68 | static gboolean get_rbtree_column_from_index (CtkTreeView *tree_view, | |||
69 | gint index, | |||
70 | CtkRBTree **tree, | |||
71 | CtkRBNode **node, | |||
72 | CtkTreeViewColumn **column); | |||
73 | ||||
74 | static CtkTreeViewAccessibleCellInfo* find_cell_info (CtkTreeViewAccessible *view, | |||
75 | CtkCellAccessible *cell); | |||
76 | static AtkObject * get_header_from_column (CtkTreeViewColumn *tv_col); | |||
77 | ||||
78 | ||||
79 | static void atk_table_interface_init (AtkTableIface *iface); | |||
80 | static void atk_selection_interface_init (AtkSelectionIface *iface); | |||
81 | static void atk_component_interface_init (AtkComponentIface *iface); | |||
82 | static void ctk_cell_accessible_parent_interface_init (CtkCellAccessibleParentIface *iface); | |||
83 | ||||
84 | G_DEFINE_TYPE_WITH_CODE (CtkTreeViewAccessible, ctk_tree_view_accessible, CTK_TYPE_CONTAINER_ACCESSIBLE,static void ctk_tree_view_accessible_init (CtkTreeViewAccessible *self); static void ctk_tree_view_accessible_class_init (CtkTreeViewAccessibleClass *klass); static GType ctk_tree_view_accessible_get_type_once (void); static gpointer ctk_tree_view_accessible_parent_class = ((void*)0); static gint CtkTreeViewAccessible_private_offset ; static void ctk_tree_view_accessible_class_intern_init (gpointer klass) { ctk_tree_view_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTreeViewAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTreeViewAccessible_private_offset); ctk_tree_view_accessible_class_init ((CtkTreeViewAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tree_view_accessible_get_instance_private (CtkTreeViewAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTreeViewAccessible_private_offset)))) ; } GType ctk_tree_view_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_tree_view_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_tree_view_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_accessible_get_type ()), g_intern_static_string ("CtkTreeViewAccessible"), sizeof (CtkTreeViewAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_tree_view_accessible_class_intern_init , sizeof (CtkTreeViewAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_tree_view_accessible_init, (GTypeFlags) 0); { {{ CtkTreeViewAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTreeViewAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_table_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_table_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_selection_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_selection_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_component_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_component_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_accessible_parent_interface_init, ((void*)0) , ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_accessible_parent_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
85 | G_ADD_PRIVATE (CtkTreeViewAccessible)static void ctk_tree_view_accessible_init (CtkTreeViewAccessible *self); static void ctk_tree_view_accessible_class_init (CtkTreeViewAccessibleClass *klass); static GType ctk_tree_view_accessible_get_type_once (void); static gpointer ctk_tree_view_accessible_parent_class = ((void*)0); static gint CtkTreeViewAccessible_private_offset ; static void ctk_tree_view_accessible_class_intern_init (gpointer klass) { ctk_tree_view_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTreeViewAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTreeViewAccessible_private_offset); ctk_tree_view_accessible_class_init ((CtkTreeViewAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tree_view_accessible_get_instance_private (CtkTreeViewAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTreeViewAccessible_private_offset)))) ; } GType ctk_tree_view_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_tree_view_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_tree_view_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_accessible_get_type ()), g_intern_static_string ("CtkTreeViewAccessible"), sizeof (CtkTreeViewAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_tree_view_accessible_class_intern_init , sizeof (CtkTreeViewAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_tree_view_accessible_init, (GTypeFlags) 0); { {{ CtkTreeViewAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTreeViewAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_table_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_table_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_selection_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_selection_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_component_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_component_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_accessible_parent_interface_init, ((void*)0) , ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_accessible_parent_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
86 | G_IMPLEMENT_INTERFACE (ATK_TYPE_TABLE, atk_table_interface_init)static void ctk_tree_view_accessible_init (CtkTreeViewAccessible *self); static void ctk_tree_view_accessible_class_init (CtkTreeViewAccessibleClass *klass); static GType ctk_tree_view_accessible_get_type_once (void); static gpointer ctk_tree_view_accessible_parent_class = ((void*)0); static gint CtkTreeViewAccessible_private_offset ; static void ctk_tree_view_accessible_class_intern_init (gpointer klass) { ctk_tree_view_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTreeViewAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTreeViewAccessible_private_offset); ctk_tree_view_accessible_class_init ((CtkTreeViewAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tree_view_accessible_get_instance_private (CtkTreeViewAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTreeViewAccessible_private_offset)))) ; } GType ctk_tree_view_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_tree_view_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_tree_view_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_accessible_get_type ()), g_intern_static_string ("CtkTreeViewAccessible"), sizeof (CtkTreeViewAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_tree_view_accessible_class_intern_init , sizeof (CtkTreeViewAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_tree_view_accessible_init, (GTypeFlags) 0); { {{ CtkTreeViewAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTreeViewAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_table_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_table_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_selection_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_selection_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_component_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_component_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_accessible_parent_interface_init, ((void*)0) , ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_accessible_parent_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
87 | G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)static void ctk_tree_view_accessible_init (CtkTreeViewAccessible *self); static void ctk_tree_view_accessible_class_init (CtkTreeViewAccessibleClass *klass); static GType ctk_tree_view_accessible_get_type_once (void); static gpointer ctk_tree_view_accessible_parent_class = ((void*)0); static gint CtkTreeViewAccessible_private_offset ; static void ctk_tree_view_accessible_class_intern_init (gpointer klass) { ctk_tree_view_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTreeViewAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTreeViewAccessible_private_offset); ctk_tree_view_accessible_class_init ((CtkTreeViewAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tree_view_accessible_get_instance_private (CtkTreeViewAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTreeViewAccessible_private_offset)))) ; } GType ctk_tree_view_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_tree_view_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_tree_view_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_accessible_get_type ()), g_intern_static_string ("CtkTreeViewAccessible"), sizeof (CtkTreeViewAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_tree_view_accessible_class_intern_init , sizeof (CtkTreeViewAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_tree_view_accessible_init, (GTypeFlags) 0); { {{ CtkTreeViewAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTreeViewAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_table_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_table_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_selection_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_selection_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_component_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_component_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_accessible_parent_interface_init, ((void*)0) , ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_accessible_parent_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
88 | G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init)static void ctk_tree_view_accessible_init (CtkTreeViewAccessible *self); static void ctk_tree_view_accessible_class_init (CtkTreeViewAccessibleClass *klass); static GType ctk_tree_view_accessible_get_type_once (void); static gpointer ctk_tree_view_accessible_parent_class = ((void*)0); static gint CtkTreeViewAccessible_private_offset ; static void ctk_tree_view_accessible_class_intern_init (gpointer klass) { ctk_tree_view_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTreeViewAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTreeViewAccessible_private_offset); ctk_tree_view_accessible_class_init ((CtkTreeViewAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tree_view_accessible_get_instance_private (CtkTreeViewAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTreeViewAccessible_private_offset)))) ; } GType ctk_tree_view_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_tree_view_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_tree_view_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_accessible_get_type ()), g_intern_static_string ("CtkTreeViewAccessible"), sizeof (CtkTreeViewAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_tree_view_accessible_class_intern_init , sizeof (CtkTreeViewAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_tree_view_accessible_init, (GTypeFlags) 0); { {{ CtkTreeViewAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTreeViewAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_table_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_table_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_selection_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_selection_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_component_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_component_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_accessible_parent_interface_init, ((void*)0) , ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_accessible_parent_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
89 | G_IMPLEMENT_INTERFACE (CTK_TYPE_CELL_ACCESSIBLE_PARENT, ctk_cell_accessible_parent_interface_init))static void ctk_tree_view_accessible_init (CtkTreeViewAccessible *self); static void ctk_tree_view_accessible_class_init (CtkTreeViewAccessibleClass *klass); static GType ctk_tree_view_accessible_get_type_once (void); static gpointer ctk_tree_view_accessible_parent_class = ((void*)0); static gint CtkTreeViewAccessible_private_offset ; static void ctk_tree_view_accessible_class_intern_init (gpointer klass) { ctk_tree_view_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTreeViewAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTreeViewAccessible_private_offset); ctk_tree_view_accessible_class_init ((CtkTreeViewAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_tree_view_accessible_get_instance_private (CtkTreeViewAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTreeViewAccessible_private_offset)))) ; } GType ctk_tree_view_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_tree_view_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_tree_view_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_container_accessible_get_type ()), g_intern_static_string ("CtkTreeViewAccessible"), sizeof (CtkTreeViewAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_tree_view_accessible_class_intern_init , sizeof (CtkTreeViewAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_tree_view_accessible_init, (GTypeFlags) 0); { {{ CtkTreeViewAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTreeViewAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_table_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_table_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_selection_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_selection_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) atk_component_interface_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (atk_component_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_accessible_parent_interface_init, ((void*)0) , ((void*)0) }; g_type_add_interface_static (g_define_type_id , (ctk_cell_accessible_parent_get_type ()), &g_implement_interface_info ); };} } return g_define_type_id; } | |||
90 | ||||
91 | ||||
92 | static GQuark | |||
93 | ctk_tree_view_accessible_get_data_quark (void) | |||
94 | { | |||
95 | static GQuark quark = 0; | |||
96 | ||||
97 | if (G_UNLIKELY (quark == 0)(quark == 0)) | |||
98 | quark = g_quark_from_static_string ("ctk-tree-view-accessible-data"); | |||
99 | ||||
100 | return quark; | |||
101 | } | |||
102 | ||||
103 | static void | |||
104 | cell_info_free (CtkTreeViewAccessibleCellInfo *cell_info) | |||
105 | { | |||
106 | ctk_accessible_set_widget (CTK_ACCESSIBLE (cell_info->cell)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_info->cell)), ((ctk_accessible_get_type ())))))), NULL((void*)0)); | |||
107 | g_object_unref (cell_info->cell); | |||
108 | ||||
109 | g_free (cell_info); | |||
110 | } | |||
111 | ||||
112 | static CtkTreePath * | |||
113 | cell_info_get_path (CtkTreeViewAccessibleCellInfo *cell_info) | |||
114 | { | |||
115 | return _ctk_tree_path_new_from_rbtree (cell_info->tree, cell_info->node); | |||
116 | } | |||
117 | ||||
118 | static guint | |||
119 | cell_info_hash (gconstpointer info) | |||
120 | { | |||
121 | const CtkTreeViewAccessibleCellInfo *cell_info = info; | |||
122 | guint node, col; | |||
123 | ||||
124 | node = GPOINTER_TO_UINT (cell_info->node)((guint) (gulong) (cell_info->node)); | |||
125 | col = GPOINTER_TO_UINT (cell_info->cell_col_ref)((guint) (gulong) (cell_info->cell_col_ref)); | |||
126 | ||||
127 | return ((node << sizeof (guint) / 2) | (node >> sizeof (guint) / 2)) ^ col; | |||
128 | } | |||
129 | ||||
130 | static gboolean | |||
131 | cell_info_equal (gconstpointer a, gconstpointer b) | |||
132 | { | |||
133 | const CtkTreeViewAccessibleCellInfo *cell_info_a = a; | |||
134 | const CtkTreeViewAccessibleCellInfo *cell_info_b = b; | |||
135 | ||||
136 | return cell_info_a->node == cell_info_b->node && | |||
137 | cell_info_a->cell_col_ref == cell_info_b->cell_col_ref; | |||
138 | } | |||
139 | ||||
140 | static void | |||
141 | ctk_tree_view_accessible_initialize (AtkObject *obj, | |||
142 | gpointer data) | |||
143 | { | |||
144 | CtkTreeViewAccessible *accessible; | |||
145 | CtkTreeView *tree_view; | |||
146 | CtkTreeModel *tree_model; | |||
147 | CtkWidget *widget; | |||
148 | ||||
149 | ATK_OBJECT_CLASS (ctk_tree_view_accessible_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tree_view_accessible_parent_class)), ((atk_object_get_type ()))))))->initialize (obj, data); | |||
150 | ||||
151 | accessible = CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))); | |||
152 | ||||
153 | accessible->priv->cell_infos = g_hash_table_new_full (cell_info_hash, | |||
154 | cell_info_equal, NULL((void*)0), (GDestroyNotify) cell_info_free); | |||
155 | ||||
156 | widget = CTK_WIDGET (data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_widget_get_type ())))))); | |||
157 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
158 | tree_model = ctk_tree_view_get_model (tree_view); | |||
159 | ||||
160 | if (tree_model) | |||
161 | { | |||
162 | if (ctk_tree_model_get_flags (tree_model) & CTK_TREE_MODEL_LIST_ONLY) | |||
163 | obj->role = ATK_ROLE_TABLE; | |||
164 | else | |||
165 | obj->role = ATK_ROLE_TREE_TABLE; | |||
166 | } | |||
167 | } | |||
168 | ||||
169 | static void | |||
170 | ctk_tree_view_accessible_finalize (GObject *object) | |||
171 | { | |||
172 | CtkTreeViewAccessible *accessible = CTK_TREE_VIEW_ACCESSIBLE (object)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ctk_tree_view_accessible_get_type ())))))); | |||
173 | ||||
174 | if (accessible->priv->cell_infos) | |||
175 | g_hash_table_destroy (accessible->priv->cell_infos); | |||
176 | ||||
177 | G_OBJECT_CLASS (ctk_tree_view_accessible_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tree_view_accessible_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); | |||
178 | } | |||
179 | ||||
180 | static void | |||
181 | ctk_tree_view_accessible_notify_ctk (GObject *obj, | |||
182 | GParamSpec *pspec) | |||
183 | { | |||
184 | CtkWidget *widget; | |||
185 | CtkTreeView *tree_view; | |||
186 | CtkTreeViewAccessible *accessible; | |||
187 | ||||
188 | widget = CTK_WIDGET (obj)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((obj)), ((ctk_widget_get_type ())))))); | |||
189 | accessible = CTK_TREE_VIEW_ACCESSIBLE (ctk_widget_get_accessible (widget))((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((ctk_widget_get_accessible (widget))), (( ctk_tree_view_accessible_get_type ())))))); | |||
190 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
191 | ||||
192 | if (g_strcmp0 (pspec->name, "model") == 0) | |||
193 | { | |||
194 | CtkTreeModel *tree_model; | |||
195 | AtkRole role; | |||
196 | ||||
197 | tree_model = ctk_tree_view_get_model (tree_view); | |||
198 | g_hash_table_remove_all (accessible->priv->cell_infos); | |||
199 | ||||
200 | if (tree_model) | |||
201 | { | |||
202 | if (ctk_tree_model_get_flags (tree_model) & CTK_TREE_MODEL_LIST_ONLY) | |||
203 | role = ATK_ROLE_TABLE; | |||
204 | else | |||
205 | role = ATK_ROLE_TREE_TABLE; | |||
206 | } | |||
207 | else | |||
208 | { | |||
209 | role = ATK_ROLE_UNKNOWN; | |||
210 | } | |||
211 | atk_object_set_role (ATK_OBJECT (accessible)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((accessible)), ((atk_object_get_type ())))))), role); | |||
212 | g_object_freeze_notify (G_OBJECT (accessible)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((accessible)), (((GType) ((20) << (2))))))))); | |||
213 | g_signal_emit_by_name (accessible, "model-changed"); | |||
214 | g_signal_emit_by_name (accessible, "visible-data-changed"); | |||
215 | g_object_thaw_notify (G_OBJECT (accessible)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((accessible)), (((GType) ((20) << (2))))))))); | |||
216 | } | |||
217 | else | |||
218 | CTK_WIDGET_ACCESSIBLE_CLASS (ctk_tree_view_accessible_parent_class)((((CtkWidgetAccessibleClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((ctk_tree_view_accessible_parent_class)), (( ctk_widget_accessible_get_type ()))))))->notify_ctk (obj, pspec); | |||
219 | } | |||
220 | ||||
221 | static void | |||
222 | ctk_tree_view_accessible_widget_unset (CtkAccessible *ctkaccessible) | |||
223 | { | |||
224 | CtkTreeViewAccessible *accessible = CTK_TREE_VIEW_ACCESSIBLE (ctkaccessible)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((ctkaccessible)), ((ctk_tree_view_accessible_get_type ())))))); | |||
225 | ||||
226 | g_hash_table_remove_all (accessible->priv->cell_infos); | |||
227 | ||||
228 | CTK_ACCESSIBLE_CLASS (ctk_tree_view_accessible_parent_class)((((CtkAccessibleClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tree_view_accessible_parent_class)), ((ctk_accessible_get_type ()))))))->widget_unset (ctkaccessible); | |||
229 | } | |||
230 | ||||
231 | static gint | |||
232 | get_n_rows (CtkTreeView *tree_view) | |||
233 | { | |||
234 | CtkRBTree *tree; | |||
235 | ||||
236 | tree = _ctk_tree_view_get_rbtree (tree_view); | |||
237 | ||||
238 | if (tree == NULL((void*)0)) | |||
239 | return 0; | |||
240 | ||||
241 | return tree->root->total_count; | |||
242 | } | |||
243 | ||||
244 | static gint | |||
245 | get_n_columns (CtkTreeView *tree_view) | |||
246 | { | |||
247 | guint i, visible_columns; | |||
248 | ||||
249 | visible_columns = 0; | |||
250 | ||||
251 | for (i = 0; i < ctk_tree_view_get_n_columns (tree_view); i++) | |||
252 | { | |||
253 | CtkTreeViewColumn *column = ctk_tree_view_get_column (tree_view, i); | |||
254 | ||||
255 | if (ctk_tree_view_column_get_visible (column)) | |||
256 | visible_columns++; | |||
257 | } | |||
258 | ||||
259 | return visible_columns; | |||
260 | } | |||
261 | ||||
262 | static gint | |||
263 | ctk_tree_view_accessible_get_n_children (AtkObject *obj) | |||
264 | { | |||
265 | CtkWidget *widget; | |||
266 | CtkTreeView *tree_view; | |||
267 | ||||
268 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (obj)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((obj)), ((ctk_accessible_get_type ()))))))); | |||
269 | if (widget == NULL((void*)0)) | |||
270 | return 0; | |||
271 | ||||
272 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
273 | return (get_n_rows (tree_view) + 1) * get_n_columns (tree_view); | |||
274 | } | |||
275 | ||||
276 | static CtkTreeViewColumn * | |||
277 | get_visible_column (CtkTreeView *tree_view, | |||
278 | guint id) | |||
279 | { | |||
280 | guint i; | |||
281 | ||||
282 | for (i = 0; i < ctk_tree_view_get_n_columns (tree_view); i++) | |||
283 | { | |||
284 | CtkTreeViewColumn *column = ctk_tree_view_get_column (tree_view, i); | |||
285 | ||||
286 | if (!ctk_tree_view_column_get_visible (column)) | |||
287 | continue; | |||
288 | ||||
289 | if (id == 0) | |||
290 | return column; | |||
291 | ||||
292 | id--; | |||
293 | } | |||
294 | ||||
295 | g_return_val_if_reached (NULL)do { g_log ("Ctk", G_LOG_LEVEL_CRITICAL, "file %s: line %d (%s): should not be reached" , "a11y/ctktreeviewaccessible.c", 295, ((const char*) (__func__ ))); return (((void*)0)); } while (0); | |||
296 | } | |||
297 | ||||
298 | static void | |||
299 | set_cell_data (CtkTreeView *treeview, | |||
300 | CtkTreeViewAccessible *accessible, | |||
301 | CtkCellAccessible *cell) | |||
302 | { | |||
303 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
304 | gboolean is_expander, is_expanded; | |||
305 | CtkTreeModel *model; | |||
306 | CtkTreeIter iter; | |||
307 | CtkTreePath *path; | |||
308 | ||||
309 | cell_info = find_cell_info (accessible, cell); | |||
310 | if (!cell_info) | |||
311 | return; | |||
312 | ||||
313 | model = ctk_tree_view_get_model (treeview); | |||
314 | ||||
315 | if (CTK_RBNODE_FLAG_SET (cell_info->node, CTK_RBNODE_IS_PARENT)(cell_info->node?(((cell_info->node->flags&CTK_RBNODE_IS_PARENT )==CTK_RBNODE_IS_PARENT)?(!(0)):(0)):(0)) && | |||
316 | cell_info->cell_col_ref == ctk_tree_view_get_expander_column (treeview)) | |||
317 | { | |||
318 | is_expander = TRUE(!(0)); | |||
319 | is_expanded = cell_info->node->children != NULL((void*)0); | |||
320 | } | |||
321 | else | |||
322 | { | |||
323 | is_expander = FALSE(0); | |||
324 | is_expanded = FALSE(0); | |||
325 | } | |||
326 | ||||
327 | path = cell_info_get_path (cell_info); | |||
328 | if (path == NULL((void*)0) || | |||
329 | !ctk_tree_model_get_iter (model, &iter, path)) | |||
330 | { | |||
331 | /* We only track valid cells, this should never happen */ | |||
332 | g_return_if_reached ()do { g_log ("Ctk", G_LOG_LEVEL_CRITICAL, "file %s: line %d (%s): should not be reached" , "a11y/ctktreeviewaccessible.c", 332, ((const char*) (__func__ ))); return; } while (0); | |||
333 | } | |||
334 | ctk_tree_path_free (path); | |||
335 | ||||
336 | ctk_tree_view_column_cell_set_cell_data (cell_info->cell_col_ref, | |||
337 | model, | |||
338 | &iter, | |||
339 | is_expander, | |||
340 | is_expanded); | |||
341 | } | |||
342 | ||||
343 | static CtkCellAccessible * | |||
344 | peek_cell (CtkTreeViewAccessible *accessible, | |||
345 | CtkRBTree *tree, | |||
346 | CtkRBNode *node, | |||
347 | CtkTreeViewColumn *column) | |||
348 | { | |||
349 | CtkTreeViewAccessibleCellInfo lookup, *cell_info; | |||
350 | ||||
351 | lookup.tree = tree; | |||
352 | lookup.node = node; | |||
353 | lookup.cell_col_ref = column; | |||
354 | ||||
355 | cell_info = g_hash_table_lookup (accessible->priv->cell_infos, &lookup); | |||
356 | if (cell_info == NULL((void*)0)) | |||
357 | return NULL((void*)0); | |||
358 | ||||
359 | return cell_info->cell; | |||
360 | } | |||
361 | ||||
362 | static CtkCellAccessible * | |||
363 | create_cell_accessible_for_renderer (CtkCellRenderer *renderer, | |||
364 | CtkWidget *widget, | |||
365 | AtkObject *parent) | |||
366 | { | |||
367 | CtkCellAccessible *cell; | |||
368 | ||||
369 | cell = CTK_CELL_ACCESSIBLE (ctk_renderer_cell_accessible_new (renderer))((((CtkCellAccessible*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((ctk_renderer_cell_accessible_new (renderer ))), ((ctk_cell_accessible_get_type ())))))); | |||
370 | ||||
371 | _ctk_cell_accessible_initialize (cell, widget, parent); | |||
372 | ||||
373 | return cell; | |||
374 | } | |||
375 | ||||
376 | static CtkCellAccessible * | |||
377 | create_cell_accessible (CtkTreeView *treeview, | |||
378 | CtkTreeViewAccessible *accessible, | |||
379 | CtkTreeViewColumn *column) | |||
380 | { | |||
381 | GList *renderer_list; | |||
382 | GList *l; | |||
383 | CtkCellAccessible *cell; | |||
384 | ||||
385 | renderer_list = ctk_cell_layout_get_cells (CTK_CELL_LAYOUT (column)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((column)), ((ctk_cell_layout_get_type ()))))))); | |||
386 | ||||
387 | /* If there is exactly one renderer in the list (which is a | |||
388 | * common case), shortcut and don't make a container | |||
389 | */ | |||
390 | if (g_list_length (renderer_list) == 1) | |||
391 | { | |||
392 | cell = create_cell_accessible_for_renderer (renderer_list->data, CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ())))))), ATK_OBJECT (accessible)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((accessible)), ((atk_object_get_type ()))))))); | |||
393 | } | |||
394 | else | |||
395 | { | |||
396 | CtkContainerCellAccessible *container; | |||
397 | ||||
398 | container = ctk_container_cell_accessible_new (); | |||
399 | _ctk_cell_accessible_initialize (CTK_CELL_ACCESSIBLE (container)((((CtkCellAccessible*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((container)), ((ctk_cell_accessible_get_type ())))))), CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ())))))), ATK_OBJECT (accessible)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((accessible)), ((atk_object_get_type ()))))))); | |||
400 | ||||
401 | for (l = renderer_list; l; l = l->next) | |||
402 | { | |||
403 | cell = create_cell_accessible_for_renderer (l->data, CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ())))))), ATK_OBJECT (container)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((atk_object_get_type ()))))))); | |||
404 | ctk_container_cell_accessible_add_child (container, cell); | |||
405 | } | |||
406 | ||||
407 | cell = CTK_CELL_ACCESSIBLE (container)((((CtkCellAccessible*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((container)), ((ctk_cell_accessible_get_type ())))))); | |||
408 | } | |||
409 | ||||
410 | g_list_free (renderer_list); | |||
411 | ||||
412 | return cell; | |||
413 | } | |||
414 | ||||
415 | static CtkCellAccessible * | |||
416 | create_cell (CtkTreeView *treeview, | |||
417 | CtkTreeViewAccessible *accessible, | |||
418 | CtkRBTree *tree, | |||
419 | CtkRBNode *node, | |||
420 | CtkTreeViewColumn *column) | |||
421 | { | |||
422 | CtkCellAccessible *cell; | |||
423 | ||||
424 | cell = create_cell_accessible (treeview, accessible, column); | |||
425 | cell_info_new (accessible, tree, node, column, cell); | |||
426 | ||||
427 | set_cell_data (treeview, accessible, cell); | |||
428 | _ctk_cell_accessible_update_cache (cell, FALSE(0)); | |||
429 | ||||
430 | return cell; | |||
431 | } | |||
432 | ||||
433 | static AtkObject * | |||
434 | ctk_tree_view_accessible_ref_child (AtkObject *obj, | |||
435 | gint i) | |||
436 | { | |||
437 | CtkWidget *widget; | |||
438 | CtkTreeViewAccessible *accessible; | |||
439 | CtkCellAccessible *cell; | |||
440 | CtkTreeView *tree_view; | |||
441 | CtkTreeViewColumn *tv_col; | |||
442 | CtkRBTree *tree; | |||
443 | CtkRBNode *node; | |||
444 | ||||
445 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (obj)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((obj)), ((ctk_accessible_get_type ()))))))); | |||
446 | if (widget == NULL((void*)0)) | |||
447 | return NULL((void*)0); | |||
448 | ||||
449 | if (i >= ctk_tree_view_accessible_get_n_children (obj)) | |||
450 | return NULL((void*)0); | |||
451 | ||||
452 | accessible = CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))); | |||
453 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
454 | if (i < get_n_columns (tree_view)) | |||
455 | { | |||
456 | AtkObject *child; | |||
457 | ||||
458 | tv_col = get_visible_column (tree_view, i); | |||
459 | child = get_header_from_column (tv_col); | |||
460 | if (child) | |||
461 | g_object_ref (child)((__typeof__ (child)) (g_object_ref) (child)); | |||
462 | return child; | |||
463 | } | |||
464 | ||||
465 | /* Find the RBTree and CtkTreeViewColumn for the index */ | |||
466 | if (!get_rbtree_column_from_index (tree_view, i, &tree, &node, &tv_col)) | |||
467 | return NULL((void*)0); | |||
468 | ||||
469 | cell = peek_cell (accessible, tree, node, tv_col); | |||
470 | if (cell == NULL((void*)0)) | |||
471 | cell = create_cell (tree_view, accessible, tree, node, tv_col); | |||
472 | ||||
473 | return ATK_OBJECT (g_object_ref (cell))((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((((__typeof__ (cell)) (g_object_ref) (cell)))), ((atk_object_get_type ())))))); | |||
474 | } | |||
475 | ||||
476 | static AtkStateSet* | |||
477 | ctk_tree_view_accessible_ref_state_set (AtkObject *obj) | |||
478 | { | |||
479 | AtkStateSet *state_set; | |||
480 | CtkWidget *widget; | |||
481 | ||||
482 | state_set = ATK_OBJECT_CLASS (ctk_tree_view_accessible_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_tree_view_accessible_parent_class)), ((atk_object_get_type ()))))))->ref_state_set (obj); | |||
483 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (obj)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((obj)), ((ctk_accessible_get_type ()))))))); | |||
484 | ||||
485 | if (widget != NULL((void*)0)) | |||
486 | atk_state_set_add_state (state_set, ATK_STATE_MANAGES_DESCENDANTS); | |||
487 | ||||
488 | return state_set; | |||
489 | } | |||
490 | ||||
491 | static void | |||
492 | ctk_tree_view_accessible_class_init (CtkTreeViewAccessibleClass *klass) | |||
493 | { | |||
494 | AtkObjectClass *class = ATK_OBJECT_CLASS (klass)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((atk_object_get_type ())))))); | |||
495 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); | |||
496 | CtkAccessibleClass *accessible_class = (CtkAccessibleClass*)klass; | |||
497 | CtkWidgetAccessibleClass *widget_class = (CtkWidgetAccessibleClass*)klass; | |||
498 | CtkContainerAccessibleClass *container_class = (CtkContainerAccessibleClass*)klass; | |||
499 | ||||
500 | class->get_n_children = ctk_tree_view_accessible_get_n_children; | |||
501 | class->ref_child = ctk_tree_view_accessible_ref_child; | |||
502 | class->ref_state_set = ctk_tree_view_accessible_ref_state_set; | |||
503 | class->initialize = ctk_tree_view_accessible_initialize; | |||
504 | ||||
505 | widget_class->notify_ctk = ctk_tree_view_accessible_notify_ctk; | |||
506 | ||||
507 | accessible_class->widget_unset = ctk_tree_view_accessible_widget_unset; | |||
508 | ||||
509 | /* The children of a CtkTreeView are the buttons at the top of the columns | |||
510 | * we do not represent these as children so we do not want to report | |||
511 | * children added or deleted when these changed. | |||
512 | */ | |||
513 | container_class->add_ctk = NULL((void*)0); | |||
514 | container_class->remove_ctk = NULL((void*)0); | |||
515 | ||||
516 | gobject_class->finalize = ctk_tree_view_accessible_finalize; | |||
517 | } | |||
518 | ||||
519 | static void | |||
520 | ctk_tree_view_accessible_init (CtkTreeViewAccessible *view) | |||
521 | { | |||
522 | view->priv = ctk_tree_view_accessible_get_instance_private (view); | |||
523 | } | |||
524 | ||||
525 | /* atkcomponent.h */ | |||
526 | ||||
527 | static AtkObject * | |||
528 | ctk_tree_view_accessible_ref_accessible_at_point (AtkComponent *component, | |||
529 | gint x, | |||
530 | gint y, | |||
531 | AtkCoordType coord_type) | |||
532 | { | |||
533 | CtkWidget *widget; | |||
534 | CtkTreeView *tree_view; | |||
535 | CtkTreePath *path; | |||
536 | CtkTreeViewColumn *column; | |||
537 | gint x_pos, y_pos; | |||
538 | gint bx, by; | |||
539 | CtkCellAccessible *cell; | |||
540 | CtkRBTree *tree; | |||
541 | CtkRBNode *node; | |||
542 | ||||
543 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (component)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((component)), ((ctk_accessible_get_type ()))))))); | |||
544 | if (widget == NULL((void*)0)) | |||
545 | return NULL((void*)0); | |||
546 | ||||
547 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
548 | ||||
549 | atk_component_get_extents (component, &x_pos, &y_pos, NULL((void*)0), NULL((void*)0), coord_type); | |||
550 | ctk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &bx, &by); | |||
551 | if (!ctk_tree_view_get_path_at_pos (tree_view, | |||
552 | bx - x_pos, by - y_pos, | |||
553 | &path, &column, NULL((void*)0), NULL((void*)0))) | |||
554 | return NULL((void*)0); | |||
555 | ||||
556 | if (_ctk_tree_view_find_node (tree_view, path, &tree, &node)) | |||
557 | { | |||
558 | ctk_tree_path_free (path); | |||
559 | return NULL((void*)0); | |||
560 | } | |||
561 | ||||
562 | cell = peek_cell (CTK_TREE_VIEW_ACCESSIBLE (component)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((component)), ((ctk_tree_view_accessible_get_type ())))))), tree, node, column); | |||
563 | if (cell == NULL((void*)0)) | |||
564 | cell = create_cell (tree_view, CTK_TREE_VIEW_ACCESSIBLE (component)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((component)), ((ctk_tree_view_accessible_get_type ())))))), tree, node, column); | |||
565 | ||||
566 | return ATK_OBJECT (g_object_ref (cell))((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((((__typeof__ (cell)) (g_object_ref) (cell)))), ((atk_object_get_type ())))))); | |||
567 | } | |||
568 | ||||
569 | static void | |||
570 | atk_component_interface_init (AtkComponentIface *iface) | |||
571 | { | |||
572 | iface->ref_accessible_at_point = ctk_tree_view_accessible_ref_accessible_at_point; | |||
573 | } | |||
574 | ||||
575 | /* atktable.h */ | |||
576 | ||||
577 | static gint | |||
578 | ctk_tree_view_accessible_get_index_at (AtkTable *table, | |||
579 | gint row, | |||
580 | gint column) | |||
581 | { | |||
582 | CtkWidget *widget; | |||
583 | gint n_cols, n_rows; | |||
584 | ||||
585 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
586 | if (widget == NULL((void*)0)) | |||
587 | return -1; | |||
588 | ||||
589 | n_cols = atk_table_get_n_columns (table); | |||
590 | n_rows = atk_table_get_n_rows (table); | |||
591 | ||||
592 | if (row >= n_rows || column >= n_cols) | |||
593 | return -1; | |||
594 | ||||
595 | return (row + 1) * n_cols + column; | |||
596 | } | |||
597 | ||||
598 | static gint | |||
599 | ctk_tree_view_accessible_get_column_at_index (AtkTable *table, | |||
600 | gint index) | |||
601 | { | |||
602 | CtkWidget *widget; | |||
603 | gint n_columns; | |||
604 | ||||
605 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
606 | if (widget == NULL((void*)0)) | |||
607 | return -1; | |||
608 | ||||
609 | if (index >= ctk_tree_view_accessible_get_n_children (ATK_OBJECT (table)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((atk_object_get_type ())))))))) | |||
610 | return -1; | |||
611 | ||||
612 | n_columns = get_n_columns (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ()))))))); | |||
613 | ||||
614 | /* checked by the n_children() check above */ | |||
615 | g_assert (n_columns > 0)do { if (n_columns > 0) ; else g_assertion_message_expr ("Ctk" , "a11y/ctktreeviewaccessible.c", 615, ((const char*) (__func__ )), "n_columns > 0"); } while (0); | |||
616 | ||||
617 | return index % n_columns; | |||
618 | } | |||
619 | ||||
620 | static gint | |||
621 | ctk_tree_view_accessible_get_row_at_index (AtkTable *table, | |||
622 | gint index) | |||
623 | { | |||
624 | CtkWidget *widget; | |||
625 | CtkTreeView *tree_view; | |||
626 | ||||
627 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
628 | if (widget == NULL((void*)0)) | |||
629 | return -1; | |||
630 | ||||
631 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
632 | ||||
633 | index /= get_n_columns (tree_view); | |||
634 | index--; | |||
635 | if (index >= get_n_rows (tree_view)) | |||
636 | return -1; | |||
637 | ||||
638 | return index; | |||
639 | } | |||
640 | ||||
641 | static AtkObject * | |||
642 | ctk_tree_view_accessible_table_ref_at (AtkTable *table, | |||
643 | gint row, | |||
644 | gint column) | |||
645 | { | |||
646 | gint index; | |||
647 | ||||
648 | index = ctk_tree_view_accessible_get_index_at (table, row, column); | |||
649 | if (index == -1) | |||
650 | return NULL((void*)0); | |||
651 | ||||
652 | return ctk_tree_view_accessible_ref_child (ATK_OBJECT (table)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((atk_object_get_type ())))))), index); | |||
653 | } | |||
654 | ||||
655 | static gint | |||
656 | ctk_tree_view_accessible_get_n_rows (AtkTable *table) | |||
657 | { | |||
658 | CtkWidget *widget; | |||
659 | ||||
660 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
661 | if (widget == NULL((void*)0)) | |||
662 | return 0; | |||
663 | ||||
664 | return get_n_rows (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ()))))))); | |||
665 | } | |||
666 | ||||
667 | static gint | |||
668 | ctk_tree_view_accessible_get_n_columns (AtkTable *table) | |||
669 | { | |||
670 | CtkWidget *widget; | |||
671 | ||||
672 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
673 | if (widget == NULL((void*)0)) | |||
674 | return 0; | |||
675 | ||||
676 | return get_n_columns (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ()))))))); | |||
677 | } | |||
678 | ||||
679 | static gboolean | |||
680 | ctk_tree_view_accessible_is_row_selected (AtkTable *table, | |||
681 | gint row) | |||
682 | { | |||
683 | CtkWidget *widget; | |||
684 | CtkRBTree *tree; | |||
685 | CtkRBNode *node; | |||
686 | ||||
687 | if (row < 0) | |||
688 | return FALSE(0); | |||
689 | ||||
690 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
691 | if (widget == NULL((void*)0)) | |||
692 | return FALSE(0); | |||
693 | ||||
694 | if (!_ctk_rbtree_find_index (_ctk_tree_view_get_rbtree (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ()))))))), | |||
695 | row, | |||
696 | &tree, | |||
697 | &node)) | |||
698 | return FALSE(0); | |||
699 | ||||
700 | return CTK_RBNODE_FLAG_SET (node, CTK_RBNODE_IS_SELECTED)(node?(((node->flags&CTK_RBNODE_IS_SELECTED)==CTK_RBNODE_IS_SELECTED )?(!(0)):(0)):(0)); | |||
701 | } | |||
702 | ||||
703 | static gboolean | |||
704 | ctk_tree_view_accessible_is_selected (AtkTable *table, | |||
705 | gint row, | |||
706 | gint column G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
707 | { | |||
708 | return ctk_tree_view_accessible_is_row_selected (table, row); | |||
709 | } | |||
710 | ||||
711 | typedef struct { | |||
712 | GArray *array; | |||
713 | CtkTreeView *treeview; | |||
714 | } SelectedRowsData; | |||
715 | ||||
716 | static void | |||
717 | get_selected_rows (CtkTreeModel *model G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
718 | CtkTreePath *path, | |||
719 | CtkTreeIter *iter G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
720 | gpointer datap) | |||
721 | { | |||
722 | SelectedRowsData *data = datap; | |||
723 | CtkRBTree *tree; | |||
724 | CtkRBNode *node; | |||
725 | int id; | |||
726 | ||||
727 | if (_ctk_tree_view_find_node (data->treeview, | |||
728 | path, | |||
729 | &tree, &node)) | |||
730 | { | |||
731 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "a11y/ctktreeviewaccessible.c" , 731, ((const char*) (__func__)), ((void*)0)); } while (0); | |||
732 | } | |||
733 | ||||
734 | id = _ctk_rbtree_node_get_index (tree, node); | |||
735 | ||||
736 | g_array_append_val (data->array, id)g_array_append_vals (data->array, &(id), 1); | |||
737 | } | |||
738 | ||||
739 | static gint | |||
740 | ctk_tree_view_accessible_get_selected_rows (AtkTable *table, | |||
741 | gint **rows_selected) | |||
742 | { | |||
743 | SelectedRowsData data; | |||
744 | CtkWidget *widget; | |||
745 | gint n_rows; | |||
746 | ||||
747 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
748 | if (widget == NULL((void*)0)) | |||
749 | { | |||
750 | if (rows_selected
| |||
751 | *rows_selected = NULL((void*)0); | |||
752 | return 0; | |||
753 | } | |||
754 | ||||
755 | data.treeview = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
756 | data.array = g_array_new (FALSE(0), FALSE(0), sizeof (gint)); | |||
757 | ||||
758 | ctk_tree_selection_selected_foreach (ctk_tree_view_get_selection (data.treeview), | |||
759 | get_selected_rows, | |||
760 | &data); | |||
761 | ||||
762 | n_rows = data.array->len; | |||
763 | if (rows_selected) | |||
764 | *rows_selected = (gint *) g_array_free (data.array, FALSE(0)); | |||
765 | else | |||
766 | g_array_free (data.array, TRUE(!(0))); | |||
767 | ||||
768 | return n_rows; | |||
769 | } | |||
770 | ||||
771 | static gboolean | |||
772 | ctk_tree_view_accessible_add_row_selection (AtkTable *table, | |||
773 | gint row) | |||
774 | { | |||
775 | CtkTreeView *treeview; | |||
776 | CtkTreePath *path; | |||
777 | CtkRBTree *tree; | |||
778 | CtkRBNode *node; | |||
779 | ||||
780 | if (row < 0) | |||
781 | return FALSE(0); | |||
782 | ||||
783 | treeview = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (table)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((table)), ((ctk_accessible_get_type ()))) )))))), ((ctk_tree_view_get_type ())))))); | |||
784 | if (treeview == NULL((void*)0)) | |||
785 | return FALSE(0); | |||
786 | ||||
787 | if (!_ctk_rbtree_find_index (_ctk_tree_view_get_rbtree (treeview), | |||
788 | row, | |||
789 | &tree, | |||
790 | &node)) | |||
791 | return FALSE(0); | |||
792 | ||||
793 | if (CTK_RBNODE_FLAG_SET (node, CTK_RBNODE_IS_SELECTED)(node?(((node->flags&CTK_RBNODE_IS_SELECTED)==CTK_RBNODE_IS_SELECTED )?(!(0)):(0)):(0))) | |||
794 | return FALSE(0); | |||
795 | ||||
796 | path = _ctk_tree_path_new_from_rbtree (tree, node); | |||
797 | ctk_tree_selection_select_path (ctk_tree_view_get_selection (treeview), path); | |||
798 | ctk_tree_path_free (path); | |||
799 | ||||
800 | return TRUE(!(0)); | |||
801 | } | |||
802 | ||||
803 | static gboolean | |||
804 | ctk_tree_view_accessible_remove_row_selection (AtkTable *table, | |||
805 | gint row) | |||
806 | { | |||
807 | CtkTreeView *treeview; | |||
808 | CtkTreePath *path; | |||
809 | CtkRBTree *tree; | |||
810 | CtkRBNode *node; | |||
811 | ||||
812 | if (row < 0) | |||
813 | return FALSE(0); | |||
814 | ||||
815 | treeview = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (table)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((table)), ((ctk_accessible_get_type ()))) )))))), ((ctk_tree_view_get_type ())))))); | |||
816 | if (treeview == NULL((void*)0)) | |||
817 | return FALSE(0); | |||
818 | ||||
819 | if (!_ctk_rbtree_find_index (_ctk_tree_view_get_rbtree (treeview), | |||
820 | row, | |||
821 | &tree, | |||
822 | &node)) | |||
823 | return FALSE(0); | |||
824 | ||||
825 | if (! CTK_RBNODE_FLAG_SET (node, CTK_RBNODE_IS_SELECTED)(node?(((node->flags&CTK_RBNODE_IS_SELECTED)==CTK_RBNODE_IS_SELECTED )?(!(0)):(0)):(0))) | |||
826 | return FALSE(0); | |||
827 | ||||
828 | path = _ctk_tree_path_new_from_rbtree (tree, node); | |||
829 | ctk_tree_selection_unselect_path (ctk_tree_view_get_selection (treeview), path); | |||
830 | ctk_tree_path_free (path); | |||
831 | ||||
832 | return TRUE(!(0)); | |||
833 | } | |||
834 | ||||
835 | static AtkObject * | |||
836 | ctk_tree_view_accessible_get_column_header (AtkTable *table, | |||
837 | gint in_col) | |||
838 | { | |||
839 | CtkWidget *widget; | |||
840 | CtkTreeView *tree_view; | |||
841 | CtkTreeViewColumn *tv_col; | |||
842 | ||||
843 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
844 | if (widget == NULL((void*)0)) | |||
845 | return NULL((void*)0); | |||
846 | ||||
847 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
848 | if (in_col < 0 || in_col >= get_n_columns (tree_view)) | |||
849 | return NULL((void*)0); | |||
850 | ||||
851 | tv_col = get_visible_column (tree_view, in_col); | |||
852 | return get_header_from_column (tv_col); | |||
853 | } | |||
854 | ||||
855 | static const gchar * | |||
856 | ctk_tree_view_accessible_get_column_description (AtkTable *table, | |||
857 | gint in_col) | |||
858 | { | |||
859 | CtkWidget *widget; | |||
860 | CtkTreeView *tree_view; | |||
861 | CtkTreeViewColumn *tv_col; | |||
862 | ||||
863 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (table)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((table)), ((ctk_accessible_get_type ()))))))); | |||
864 | if (widget == NULL((void*)0)) | |||
865 | return NULL((void*)0); | |||
866 | ||||
867 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
868 | if (in_col < 0 || in_col >= get_n_columns (tree_view)) | |||
869 | return NULL((void*)0); | |||
870 | ||||
871 | tv_col = get_visible_column (tree_view, in_col); | |||
872 | return ctk_tree_view_column_get_title (tv_col); | |||
873 | } | |||
874 | ||||
875 | static void | |||
876 | atk_table_interface_init (AtkTableIface *iface) | |||
877 | { | |||
878 | iface->ref_at = ctk_tree_view_accessible_table_ref_at; | |||
879 | iface->get_n_rows = ctk_tree_view_accessible_get_n_rows; | |||
880 | iface->get_n_columns = ctk_tree_view_accessible_get_n_columns; | |||
881 | iface->get_index_at = ctk_tree_view_accessible_get_index_at; | |||
882 | iface->get_column_at_index = ctk_tree_view_accessible_get_column_at_index; | |||
883 | iface->get_row_at_index = ctk_tree_view_accessible_get_row_at_index; | |||
884 | iface->is_row_selected = ctk_tree_view_accessible_is_row_selected; | |||
885 | iface->is_selected = ctk_tree_view_accessible_is_selected; | |||
886 | iface->get_selected_rows = ctk_tree_view_accessible_get_selected_rows; | |||
887 | iface->add_row_selection = ctk_tree_view_accessible_add_row_selection; | |||
888 | iface->remove_row_selection = ctk_tree_view_accessible_remove_row_selection; | |||
889 | iface->get_column_extent_at = NULL((void*)0); | |||
890 | iface->get_row_extent_at = NULL((void*)0); | |||
891 | iface->get_column_header = ctk_tree_view_accessible_get_column_header; | |||
892 | iface->get_column_description = ctk_tree_view_accessible_get_column_description; | |||
893 | } | |||
894 | ||||
895 | /* atkselection.h */ | |||
896 | ||||
897 | static gboolean | |||
898 | ctk_tree_view_accessible_add_selection (AtkSelection *selection, | |||
899 | gint i) | |||
900 | { | |||
901 | AtkTable *table; | |||
902 | gint n_columns; | |||
903 | gint row; | |||
904 | ||||
905 | table = ATK_TABLE (selection)(((AtkTable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection)), ((atk_table_get_type ()))))); | |||
906 | n_columns = ctk_tree_view_accessible_get_n_columns (table); | |||
907 | if (n_columns != 1) | |||
908 | return FALSE(0); | |||
909 | ||||
910 | row = ctk_tree_view_accessible_get_row_at_index (table, i); | |||
911 | return ctk_tree_view_accessible_add_row_selection (table, row); | |||
912 | } | |||
913 | ||||
914 | static gboolean | |||
915 | ctk_tree_view_accessible_clear_selection (AtkSelection *selection) | |||
916 | { | |||
917 | CtkWidget *widget; | |||
918 | CtkTreeView *tree_view; | |||
919 | CtkTreeSelection *tree_selection; | |||
920 | ||||
921 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (selection)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection)), ((ctk_accessible_get_type ()))))))); | |||
922 | if (widget == NULL((void*)0)) | |||
923 | return FALSE(0); | |||
924 | ||||
925 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
926 | tree_selection = ctk_tree_view_get_selection (tree_view); | |||
927 | ||||
928 | ctk_tree_selection_unselect_all (tree_selection); | |||
929 | return TRUE(!(0)); | |||
930 | } | |||
931 | ||||
932 | static AtkObject * | |||
933 | ctk_tree_view_accessible_ref_selection (AtkSelection *selection, | |||
934 | gint i) | |||
935 | { | |||
936 | AtkTable *table; | |||
937 | gint row; | |||
938 | gint n_selected; | |||
939 | gint n_columns; | |||
940 | gint *selected; | |||
941 | ||||
942 | table = ATK_TABLE (selection)(((AtkTable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection)), ((atk_table_get_type ()))))); | |||
943 | n_columns = ctk_tree_view_accessible_get_n_columns (table); | |||
944 | n_selected = ctk_tree_view_accessible_get_selected_rows (table, &selected); | |||
| ||||
945 | if (n_columns == 0 || i >= n_columns * n_selected) | |||
946 | return NULL((void*)0); | |||
947 | ||||
948 | row = selected[i / n_columns]; | |||
| ||||
949 | g_free (selected); | |||
950 | ||||
951 | return ctk_tree_view_accessible_table_ref_at (table, row, i % n_columns); | |||
952 | } | |||
953 | ||||
954 | static gint | |||
955 | ctk_tree_view_accessible_get_selection_count (AtkSelection *selection) | |||
956 | { | |||
957 | AtkTable *table; | |||
958 | gint n_selected; | |||
959 | ||||
960 | table = ATK_TABLE (selection)(((AtkTable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection)), ((atk_table_get_type ()))))); | |||
961 | n_selected = ctk_tree_view_accessible_get_selected_rows (table, NULL((void*)0)); | |||
962 | if (n_selected > 0) | |||
963 | n_selected *= ctk_tree_view_accessible_get_n_columns (table); | |||
964 | return n_selected; | |||
965 | } | |||
966 | ||||
967 | static gboolean | |||
968 | ctk_tree_view_accessible_is_child_selected (AtkSelection *selection, | |||
969 | gint i) | |||
970 | { | |||
971 | CtkWidget *widget; | |||
972 | gint row; | |||
973 | ||||
974 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (selection)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection)), ((ctk_accessible_get_type ()))))))); | |||
975 | if (widget == NULL((void*)0)) | |||
976 | return FALSE(0); | |||
977 | ||||
978 | row = ctk_tree_view_accessible_get_row_at_index (ATK_TABLE (selection)(((AtkTable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection)), ((atk_table_get_type ()))))), i); | |||
979 | ||||
980 | return ctk_tree_view_accessible_is_row_selected (ATK_TABLE (selection)(((AtkTable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection)), ((atk_table_get_type ()))))), row); | |||
981 | } | |||
982 | ||||
983 | static void atk_selection_interface_init (AtkSelectionIface *iface) | |||
984 | { | |||
985 | iface->add_selection = ctk_tree_view_accessible_add_selection; | |||
986 | iface->clear_selection = ctk_tree_view_accessible_clear_selection; | |||
987 | iface->ref_selection = ctk_tree_view_accessible_ref_selection; | |||
988 | iface->get_selection_count = ctk_tree_view_accessible_get_selection_count; | |||
989 | iface->is_child_selected = ctk_tree_view_accessible_is_child_selected; | |||
990 | } | |||
991 | ||||
992 | #define EXTRA_EXPANDER_PADDING4 4 | |||
993 | ||||
994 | static void | |||
995 | ctk_tree_view_accessible_get_cell_area (CtkCellAccessibleParent *parent, | |||
996 | CtkCellAccessible *cell, | |||
997 | CdkRectangle *cell_rect) | |||
998 | { | |||
999 | CtkWidget *widget; | |||
1000 | CtkTreeView *tree_view; | |||
1001 | CtkTreeViewColumn *tv_col; | |||
1002 | CtkTreePath *path; | |||
1003 | AtkObject *parent_cell; | |||
1004 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1005 | CtkCellAccessible *top_cell; | |||
1006 | ||||
1007 | /* Default value. */ | |||
1008 | cell_rect->x = 0; | |||
1009 | cell_rect->y = 0; | |||
1010 | cell_rect->width = 0; | |||
1011 | cell_rect->height = 0; | |||
1012 | ||||
1013 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); | |||
1014 | if (widget == NULL((void*)0)) | |||
1015 | return; | |||
1016 | ||||
1017 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
1018 | parent_cell = atk_object_get_parent (ATK_OBJECT (cell)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), ((atk_object_get_type ()))))))); | |||
1019 | if (parent_cell != ATK_OBJECT (parent)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((atk_object_get_type ()))))))) | |||
1020 | top_cell = CTK_CELL_ACCESSIBLE (parent_cell)((((CtkCellAccessible*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((parent_cell)), ((ctk_cell_accessible_get_type ())))))); | |||
1021 | else | |||
1022 | top_cell = cell; | |||
1023 | cell_info = find_cell_info (CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))), top_cell); | |||
1024 | if (!cell_info) | |||
1025 | return; | |||
1026 | path = cell_info_get_path (cell_info); | |||
1027 | tv_col = cell_info->cell_col_ref; | |||
1028 | if (path) | |||
1029 | { | |||
1030 | CtkTreeViewColumn *expander_column; | |||
1031 | ||||
1032 | ctk_tree_view_get_cell_area (tree_view, path, tv_col, cell_rect); | |||
1033 | expander_column = ctk_tree_view_get_expander_column (tree_view); | |||
1034 | if (expander_column == tv_col) | |||
1035 | { | |||
1036 | gint expander_size; | |||
1037 | ctk_widget_style_get (widget, | |||
1038 | "expander-size", &expander_size, | |||
1039 | NULL((void*)0)); | |||
1040 | cell_rect->x += expander_size + EXTRA_EXPANDER_PADDING4; | |||
1041 | cell_rect->width -= expander_size + EXTRA_EXPANDER_PADDING4; | |||
1042 | } | |||
1043 | ||||
1044 | ctk_tree_path_free (path); | |||
1045 | ||||
1046 | /* A column has more than one renderer so we find the position | |||
1047 | * and width of each | |||
1048 | */ | |||
1049 | if (top_cell != cell) | |||
1050 | { | |||
1051 | gint cell_index; | |||
1052 | gboolean found; | |||
1053 | gint cell_start; | |||
1054 | gint cell_width; | |||
1055 | GList *renderers; | |||
1056 | CtkCellRenderer *renderer; | |||
1057 | ||||
1058 | cell_index = atk_object_get_index_in_parent (ATK_OBJECT (cell)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), ((atk_object_get_type ()))))))); | |||
1059 | renderers = ctk_cell_layout_get_cells (CTK_CELL_LAYOUT (tv_col)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tv_col)), ((ctk_cell_layout_get_type ()))))))); | |||
1060 | renderer = g_list_nth_data (renderers, cell_index); | |||
1061 | ||||
1062 | found = ctk_tree_view_column_cell_get_position (tv_col, renderer, &cell_start, &cell_width); | |||
1063 | if (found) | |||
1064 | { | |||
1065 | cell_rect->x += cell_start; | |||
1066 | cell_rect->width = cell_width; | |||
1067 | } | |||
1068 | g_list_free (renderers); | |||
1069 | } | |||
1070 | ||||
1071 | } | |||
1072 | } | |||
1073 | ||||
1074 | static void | |||
1075 | ctk_tree_view_accessible_get_cell_extents (CtkCellAccessibleParent *parent, | |||
1076 | CtkCellAccessible *cell, | |||
1077 | gint *x, | |||
1078 | gint *y, | |||
1079 | gint *width, | |||
1080 | gint *height, | |||
1081 | AtkCoordType coord_type) | |||
1082 | { | |||
1083 | CtkWidget *widget; | |||
1084 | CtkTreeView *tree_view; | |||
1085 | CdkWindow *bin_window; | |||
1086 | CdkRectangle cell_rect; | |||
1087 | gint w_x, w_y; | |||
1088 | ||||
1089 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); | |||
1090 | if (widget == NULL((void*)0)) | |||
1091 | return; | |||
1092 | ||||
1093 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
1094 | ctk_tree_view_accessible_get_cell_area (parent, cell, &cell_rect); | |||
1095 | bin_window = ctk_tree_view_get_bin_window (tree_view); | |||
1096 | cdk_window_get_origin (bin_window, &w_x, &w_y); | |||
1097 | ||||
1098 | if (coord_type == ATK_XY_WINDOW) | |||
1099 | { | |||
1100 | CdkWindow *window; | |||
1101 | gint x_toplevel, y_toplevel; | |||
1102 | ||||
1103 | window = cdk_window_get_toplevel (bin_window); | |||
1104 | cdk_window_get_origin (window, &x_toplevel, &y_toplevel); | |||
1105 | ||||
1106 | w_x -= x_toplevel; | |||
1107 | w_y -= y_toplevel; | |||
1108 | } | |||
1109 | ||||
1110 | *width = cell_rect.width; | |||
1111 | *height = cell_rect.height; | |||
1112 | if (is_cell_showing (tree_view, &cell_rect)) | |||
1113 | { | |||
1114 | *x = cell_rect.x + w_x; | |||
1115 | *y = cell_rect.y + w_y; | |||
1116 | } | |||
1117 | else | |||
1118 | { | |||
1119 | *x = G_MININT(-2147483647 -1); | |||
1120 | *y = G_MININT(-2147483647 -1); | |||
1121 | } | |||
1122 | } | |||
1123 | ||||
1124 | static gboolean | |||
1125 | ctk_tree_view_accessible_grab_cell_focus (CtkCellAccessibleParent *parent, | |||
1126 | CtkCellAccessible *cell) | |||
1127 | { | |||
1128 | CtkWidget *widget; | |||
1129 | CtkTreeView *tree_view; | |||
1130 | CtkTreeViewColumn *tv_col; | |||
1131 | CtkTreePath *path; | |||
1132 | AtkObject *parent_cell; | |||
1133 | AtkObject *cell_object; | |||
1134 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1135 | CtkCellRenderer *renderer = NULL((void*)0); | |||
1136 | CtkWidget *toplevel; | |||
1137 | gint index; | |||
1138 | ||||
1139 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); | |||
1140 | if (widget == NULL((void*)0)) | |||
1141 | return FALSE(0); | |||
1142 | ||||
1143 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
1144 | ||||
1145 | cell_info = find_cell_info (CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))), cell); | |||
1146 | if (!cell_info) | |||
1147 | return FALSE(0); | |||
1148 | cell_object = ATK_OBJECT (cell)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), ((atk_object_get_type ())))))); | |||
1149 | parent_cell = atk_object_get_parent (cell_object); | |||
1150 | tv_col = cell_info->cell_col_ref; | |||
1151 | if (parent_cell != ATK_OBJECT (parent)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((atk_object_get_type ()))))))) | |||
1152 | { | |||
1153 | /* CtkCellAccessible is in a CtkContainerCellAccessible. | |||
1154 | * The CtkTreeViewColumn has multiple renderers; | |||
1155 | * find the corresponding one. | |||
1156 | */ | |||
1157 | GList *renderers; | |||
1158 | ||||
1159 | renderers = ctk_cell_layout_get_cells (CTK_CELL_LAYOUT (tv_col)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tv_col)), ((ctk_cell_layout_get_type ()))))))); | |||
1160 | index = atk_object_get_index_in_parent (cell_object); | |||
1161 | renderer = g_list_nth_data (renderers, index); | |||
1162 | g_list_free (renderers); | |||
1163 | } | |||
1164 | path = cell_info_get_path (cell_info); | |||
1165 | if (path) | |||
1166 | { | |||
1167 | if (renderer) | |||
1168 | ctk_tree_view_set_cursor_on_cell (tree_view, path, tv_col, renderer, FALSE(0)); | |||
1169 | else | |||
1170 | ctk_tree_view_set_cursor (tree_view, path, tv_col, FALSE(0)); | |||
1171 | ||||
1172 | ctk_tree_path_free (path); | |||
1173 | ctk_widget_grab_focus (widget); | |||
1174 | toplevel = ctk_widget_get_toplevel (widget); | |||
1175 | if (ctk_widget_is_toplevel (toplevel)) | |||
1176 | { | |||
1177 | #ifdef CDK_WINDOWING_X11 | |||
1178 | if (CDK_IS_X11_DISPLAY (ctk_widget_get_display (toplevel))(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (ctk_widget_get_display (toplevel))); GType __t = ((cdk_x11_display_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; }))))) | |||
1179 | ctk_window_present_with_time (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_window_get_type ())))))), | |||
1180 | cdk_x11_get_server_time (ctk_widget_get_window (widget))); | |||
1181 | else | |||
1182 | #endif | |||
1183 | { | |||
1184 | ctk_window_present (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_window_get_type ()))))))); | |||
1185 | } | |||
1186 | } | |||
1187 | ||||
1188 | return TRUE(!(0)); | |||
1189 | } | |||
1190 | else | |||
1191 | return FALSE(0); | |||
1192 | } | |||
1193 | ||||
1194 | static int | |||
1195 | ctk_tree_view_accessible_get_child_index (CtkCellAccessibleParent *parent, | |||
1196 | CtkCellAccessible *cell) | |||
1197 | { | |||
1198 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1199 | CtkTreeView *tree_view; | |||
1200 | ||||
1201 | cell_info = find_cell_info (CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))), cell); | |||
1202 | if (!cell_info) | |||
1203 | return -1; | |||
1204 | ||||
1205 | tree_view = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_accessible_get_type ())) ))))))), ((ctk_tree_view_get_type ())))))); | |||
1206 | ||||
1207 | return cell_info_get_index (tree_view, cell_info); | |||
1208 | } | |||
1209 | ||||
1210 | static CtkCellRendererState | |||
1211 | ctk_tree_view_accessible_get_renderer_state (CtkCellAccessibleParent *parent, | |||
1212 | CtkCellAccessible *cell) | |||
1213 | { | |||
1214 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1215 | CtkTreeView *treeview; | |||
1216 | CtkCellRendererState flags; | |||
1217 | ||||
1218 | cell_info = find_cell_info (CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))), cell); | |||
1219 | if (!cell_info) | |||
1220 | return 0; | |||
1221 | ||||
1222 | flags = 0; | |||
1223 | ||||
1224 | if (CTK_RBNODE_FLAG_SET (cell_info->node, CTK_RBNODE_IS_SELECTED)(cell_info->node?(((cell_info->node->flags&CTK_RBNODE_IS_SELECTED )==CTK_RBNODE_IS_SELECTED)?(!(0)):(0)):(0))) | |||
1225 | flags |= CTK_CELL_RENDERER_SELECTED; | |||
1226 | ||||
1227 | if (CTK_RBNODE_FLAG_SET (cell_info->node, CTK_RBNODE_IS_PRELIT)(cell_info->node?(((cell_info->node->flags&CTK_RBNODE_IS_PRELIT )==CTK_RBNODE_IS_PRELIT)?(!(0)):(0)):(0))) | |||
1228 | flags |= CTK_CELL_RENDERER_PRELIT; | |||
1229 | ||||
1230 | if (ctk_tree_view_column_get_sort_indicator (cell_info->cell_col_ref)) | |||
1231 | flags |= CTK_CELL_RENDERER_SORTED; | |||
1232 | ||||
1233 | treeview = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_accessible_get_type ())) ))))))), ((ctk_tree_view_get_type ())))))); | |||
1234 | ||||
1235 | if (cell_info->cell_col_ref == ctk_tree_view_get_expander_column (treeview)) | |||
1236 | { | |||
1237 | if (CTK_RBNODE_FLAG_SET (cell_info->node, CTK_RBNODE_IS_PARENT)(cell_info->node?(((cell_info->node->flags&CTK_RBNODE_IS_PARENT )==CTK_RBNODE_IS_PARENT)?(!(0)):(0)):(0))) | |||
1238 | flags |= CTK_CELL_RENDERER_EXPANDABLE; | |||
1239 | ||||
1240 | if (cell_info->node->children) | |||
1241 | flags |= CTK_CELL_RENDERER_EXPANDED; | |||
1242 | } | |||
1243 | ||||
1244 | if (ctk_widget_has_focus (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ())))))))) | |||
1245 | { | |||
1246 | CtkTreeViewColumn *column; | |||
1247 | CtkTreePath *path; | |||
1248 | CtkRBTree *tree; | |||
1249 | CtkRBNode *node = NULL((void*)0); | |||
1250 | ||||
1251 | ctk_tree_view_get_cursor (treeview, &path, &column); | |||
1252 | if (path) | |||
1253 | { | |||
1254 | _ctk_tree_view_find_node (treeview, path, &tree, &node); | |||
1255 | ctk_tree_path_free (path); | |||
1256 | } | |||
1257 | else | |||
1258 | tree = NULL((void*)0); | |||
1259 | ||||
1260 | if (cell_info->cell_col_ref == column | |||
1261 | && cell_info->tree == tree | |||
1262 | && cell_info->node == node) | |||
1263 | flags |= CTK_CELL_RENDERER_FOCUSED; | |||
1264 | } | |||
1265 | ||||
1266 | return flags; | |||
1267 | } | |||
1268 | ||||
1269 | static void | |||
1270 | ctk_tree_view_accessible_expand_collapse (CtkCellAccessibleParent *parent, | |||
1271 | CtkCellAccessible *cell) | |||
1272 | { | |||
1273 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1274 | CtkTreeView *treeview; | |||
1275 | CtkTreePath *path; | |||
1276 | ||||
1277 | treeview = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_accessible_get_type ())) ))))))), ((ctk_tree_view_get_type ())))))); | |||
1278 | ||||
1279 | cell_info = find_cell_info (CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))), cell); | |||
1280 | if (!cell_info || | |||
1281 | cell_info->cell_col_ref != ctk_tree_view_get_expander_column (treeview)) | |||
1282 | return; | |||
1283 | ||||
1284 | path = cell_info_get_path (cell_info); | |||
1285 | ||||
1286 | if (cell_info->node->children) | |||
1287 | ctk_tree_view_collapse_row (treeview, path); | |||
1288 | else | |||
1289 | ctk_tree_view_expand_row (treeview, path, FALSE(0)); | |||
1290 | ||||
1291 | ctk_tree_path_free (path); | |||
1292 | } | |||
1293 | ||||
1294 | static void | |||
1295 | ctk_tree_view_accessible_activate (CtkCellAccessibleParent *parent, | |||
1296 | CtkCellAccessible *cell) | |||
1297 | { | |||
1298 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1299 | CtkTreeView *treeview; | |||
1300 | CtkTreePath *path; | |||
1301 | ||||
1302 | treeview = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_accessible_get_type ())) ))))))), ((ctk_tree_view_get_type ())))))); | |||
1303 | ||||
1304 | cell_info = find_cell_info (CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))), cell); | |||
1305 | if (!cell_info) | |||
1306 | return; | |||
1307 | ||||
1308 | path = cell_info_get_path (cell_info); | |||
1309 | ||||
1310 | ctk_tree_view_row_activated (treeview, path, cell_info->cell_col_ref); | |||
1311 | ||||
1312 | ctk_tree_path_free (path); | |||
1313 | } | |||
1314 | ||||
1315 | static void | |||
1316 | ctk_tree_view_accessible_edit (CtkCellAccessibleParent *parent, | |||
1317 | CtkCellAccessible *cell) | |||
1318 | { | |||
1319 | CtkTreeView *treeview; | |||
1320 | ||||
1321 | if (!ctk_tree_view_accessible_grab_cell_focus (parent, cell)) | |||
1322 | return; | |||
1323 | ||||
1324 | treeview = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_accessible_get_type ())) ))))))), ((ctk_tree_view_get_type ())))))); | |||
1325 | ||||
1326 | g_signal_emit_by_name (treeview, | |||
1327 | "real-select-cursor-row", | |||
1328 | TRUE(!(0))); | |||
1329 | } | |||
1330 | ||||
1331 | static void | |||
1332 | ctk_tree_view_accessible_update_relationset (CtkCellAccessibleParent *parent, | |||
1333 | CtkCellAccessible *cell, | |||
1334 | AtkRelationSet *relationset) | |||
1335 | { | |||
1336 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1337 | CtkTreeViewAccessible *accessible; | |||
1338 | CtkTreeViewColumn *column; | |||
1339 | CtkTreeView *treeview; | |||
1340 | AtkRelation *relation; | |||
1341 | CtkRBTree *tree; | |||
1342 | AtkObject *object; | |||
1343 | ||||
1344 | /* Don't set relations on cells that aren't direct descendants of the treeview. | |||
1345 | * So only set it on the container, not on the renderer accessibles */ | |||
1346 | if (atk_object_get_parent (ATK_OBJECT (cell)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), ((atk_object_get_type ()))))))) != ATK_OBJECT (parent)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((atk_object_get_type ()))))))) | |||
1347 | return; | |||
1348 | ||||
1349 | accessible = CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))); | |||
1350 | cell_info = find_cell_info (accessible, cell); | |||
1351 | if (!cell_info) | |||
1352 | return; | |||
1353 | ||||
1354 | /* only set parent/child rows on the expander column */ | |||
1355 | treeview = CTK_TREE_VIEW (ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)))((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_accessible_get_widget (((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_accessible_get_type ())) ))))))), ((ctk_tree_view_get_type ())))))); | |||
1356 | column = ctk_tree_view_get_expander_column (treeview); | |||
1357 | if (column != cell_info->cell_col_ref) | |||
1358 | return; | |||
1359 | ||||
1360 | /* Update CHILD_OF relation to parent cell */ | |||
1361 | relation = atk_relation_set_get_relation_by_type (relationset, ATK_RELATION_NODE_CHILD_OF); | |||
1362 | if (relation) | |||
1363 | atk_relation_set_remove (relationset, relation); | |||
1364 | ||||
1365 | if (cell_info->tree->parent_tree) | |||
1366 | { | |||
1367 | object = ATK_OBJECT (peek_cell (accessible, cell_info->tree->parent_tree, cell_info->tree->parent_node, column))((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((peek_cell (accessible, cell_info->tree->parent_tree , cell_info->tree->parent_node, column))), ((atk_object_get_type ())))))); | |||
1368 | if (object == NULL((void*)0)) | |||
1369 | object = ATK_OBJECT (create_cell (treeview, accessible, cell_info->tree->parent_tree, cell_info->tree->parent_node, column))((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((create_cell (treeview, accessible, cell_info->tree-> parent_tree, cell_info->tree->parent_node, column))), ( (atk_object_get_type ())))))); | |||
1370 | } | |||
1371 | else | |||
1372 | object = ATK_OBJECT (accessible)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((accessible)), ((atk_object_get_type ())))))); | |||
1373 | ||||
1374 | atk_relation_set_add_relation_by_type (relationset, ATK_RELATION_NODE_CHILD_OF, object); | |||
1375 | ||||
1376 | /* Update PARENT_OF relation for all child cells */ | |||
1377 | relation = atk_relation_set_get_relation_by_type (relationset, ATK_RELATION_NODE_PARENT_OF); | |||
1378 | if (relation) | |||
1379 | atk_relation_set_remove (relationset, relation); | |||
1380 | ||||
1381 | tree = cell_info->node->children; | |||
1382 | if (tree) | |||
1383 | { | |||
1384 | CtkRBNode *node; | |||
1385 | ||||
1386 | for (node = _ctk_rbtree_first (tree); | |||
1387 | node != NULL((void*)0); | |||
1388 | node = _ctk_rbtree_next (tree, node)) | |||
1389 | { | |||
1390 | object = ATK_OBJECT (peek_cell (accessible, tree, node, column))((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((peek_cell (accessible, tree, node, column))), ((atk_object_get_type ())))))); | |||
1391 | if (object == NULL((void*)0)) | |||
1392 | object = ATK_OBJECT (create_cell (treeview, accessible, tree, node, column))((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((create_cell (treeview, accessible, tree, node, column))) , ((atk_object_get_type ())))))); | |||
1393 | ||||
1394 | atk_relation_set_add_relation_by_type (relationset, ATK_RELATION_NODE_PARENT_OF, ATK_OBJECT (object)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((atk_object_get_type ()))))))); | |||
1395 | } | |||
1396 | } | |||
1397 | } | |||
1398 | ||||
1399 | static void | |||
1400 | ctk_tree_view_accessible_get_cell_position (CtkCellAccessibleParent *parent, | |||
1401 | CtkCellAccessible *cell, | |||
1402 | gint *row, | |||
1403 | gint *column) | |||
1404 | { | |||
1405 | CtkWidget *widget; | |||
1406 | CtkTreeView *tree_view; | |||
1407 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1408 | CtkTreeViewAccessible *accessible; | |||
1409 | ||||
1410 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); | |||
1411 | if (widget == NULL((void*)0)) | |||
1412 | return; | |||
1413 | ||||
1414 | tree_view = CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ())))))); | |||
1415 | accessible = CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))); | |||
1416 | cell_info = find_cell_info (accessible, cell); | |||
1417 | if (!cell_info) | |||
1418 | return; | |||
1419 | ||||
1420 | if (row) | |||
1421 | (*row) = _ctk_rbtree_node_get_index (cell_info->tree, cell_info->node); | |||
1422 | if (column) | |||
1423 | (*column) = get_column_number (tree_view, cell_info->cell_col_ref); | |||
1424 | } | |||
1425 | ||||
1426 | static GPtrArray * | |||
1427 | ctk_tree_view_accessible_get_column_header_cells (CtkCellAccessibleParent *parent, | |||
1428 | CtkCellAccessible *cell) | |||
1429 | { | |||
1430 | CtkWidget *widget; | |||
1431 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1432 | CtkTreeViewAccessible *accessible; | |||
1433 | GPtrArray *array; | |||
1434 | ||||
1435 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); | |||
1436 | if (widget == NULL((void*)0)) | |||
1437 | return NULL((void*)0); | |||
1438 | ||||
1439 | accessible = CTK_TREE_VIEW_ACCESSIBLE (parent)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_tree_view_accessible_get_type ())))))); | |||
1440 | cell_info = find_cell_info (accessible, cell); | |||
1441 | if (!cell_info) | |||
1442 | return NULL((void*)0); | |||
1443 | ||||
1444 | array = g_ptr_array_new_full (1, g_object_unref); | |||
1445 | g_ptr_array_add (array, g_object_ref (get_header_from_column ( (cell_info->cell_col_ref)))((__typeof__ (get_header_from_column ( (cell_info->cell_col_ref )))) (g_object_ref) (get_header_from_column ( (cell_info-> cell_col_ref))))); | |||
1446 | return array; | |||
1447 | } | |||
1448 | ||||
1449 | static void | |||
1450 | ctk_cell_accessible_parent_interface_init (CtkCellAccessibleParentIface *iface) | |||
1451 | { | |||
1452 | iface->get_cell_extents = ctk_tree_view_accessible_get_cell_extents; | |||
1453 | iface->get_cell_area = ctk_tree_view_accessible_get_cell_area; | |||
1454 | iface->grab_focus = ctk_tree_view_accessible_grab_cell_focus; | |||
1455 | iface->get_child_index = ctk_tree_view_accessible_get_child_index; | |||
1456 | iface->get_renderer_state = ctk_tree_view_accessible_get_renderer_state; | |||
1457 | iface->expand_collapse = ctk_tree_view_accessible_expand_collapse; | |||
1458 | iface->activate = ctk_tree_view_accessible_activate; | |||
1459 | iface->edit = ctk_tree_view_accessible_edit; | |||
1460 | iface->update_relationset = ctk_tree_view_accessible_update_relationset; | |||
1461 | iface->get_cell_position = ctk_tree_view_accessible_get_cell_position; | |||
1462 | iface->get_column_header_cells = ctk_tree_view_accessible_get_column_header_cells; | |||
1463 | } | |||
1464 | ||||
1465 | void | |||
1466 | _ctk_tree_view_accessible_reorder (CtkTreeView *treeview) | |||
1467 | { | |||
1468 | CtkTreeViewAccessible *accessible; | |||
1469 | ||||
1470 | accessible = CTK_TREE_VIEW_ACCESSIBLE (_ctk_widget_peek_accessible (CTK_WIDGET (treeview)))((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((_ctk_widget_peek_accessible (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((treeview )), ((ctk_widget_get_type ()))))))))), ((ctk_tree_view_accessible_get_type ())))))); | |||
1471 | if (accessible == NULL((void*)0)) | |||
1472 | return; | |||
1473 | ||||
1474 | g_signal_emit_by_name (accessible, "row-reordered"); | |||
1475 | } | |||
1476 | ||||
1477 | static gboolean | |||
1478 | is_cell_showing (CtkTreeView *tree_view, | |||
1479 | CdkRectangle *cell_rect) | |||
1480 | { | |||
1481 | CdkRectangle rect, *visible_rect; | |||
1482 | CdkRectangle rect1, *tree_cell_rect; | |||
1483 | gint bx, by; | |||
1484 | gboolean is_showing; | |||
1485 | ||||
1486 | /* A cell is considered "SHOWING" if any part of the cell is | |||
1487 | * in the visible area. Other ways we could do this is by a | |||
1488 | * cell's midpoint or if the cell is fully in the visible range. | |||
1489 | * Since we have the cell_rect x, y, width, height of the cell, | |||
1490 | * any of these is easy to compute. | |||
1491 | * | |||
1492 | * It is assumed that cell's rectangle is in widget coordinates | |||
1493 | * so we must transform to tree cordinates. | |||
1494 | */ | |||
1495 | visible_rect = ▭ | |||
1496 | tree_cell_rect = &rect1; | |||
1497 | tree_cell_rect->x = cell_rect->x; | |||
1498 | tree_cell_rect->y = cell_rect->y; | |||
1499 | tree_cell_rect->width = cell_rect->width; | |||
1500 | tree_cell_rect->height = cell_rect->height; | |||
1501 | ||||
1502 | ctk_tree_view_get_visible_rect (tree_view, visible_rect); | |||
1503 | ctk_tree_view_convert_tree_to_bin_window_coords (tree_view, visible_rect->x, | |||
1504 | visible_rect->y, &bx, &by); | |||
1505 | ||||
1506 | if (((tree_cell_rect->x + tree_cell_rect->width) < bx) || | |||
1507 | ((tree_cell_rect->y + tree_cell_rect->height) < by) || | |||
1508 | (tree_cell_rect->x > (bx + visible_rect->width)) || | |||
1509 | (tree_cell_rect->y > (by + visible_rect->height))) | |||
1510 | is_showing = FALSE(0); | |||
1511 | else | |||
1512 | is_showing = TRUE(!(0)); | |||
1513 | ||||
1514 | return is_showing; | |||
1515 | } | |||
1516 | ||||
1517 | /* Misc Private */ | |||
1518 | ||||
1519 | static int | |||
1520 | cell_info_get_index (CtkTreeView *tree_view, | |||
1521 | CtkTreeViewAccessibleCellInfo *info) | |||
1522 | { | |||
1523 | int index; | |||
1524 | ||||
1525 | index = _ctk_rbtree_node_get_index (info->tree, info->node) + 1; | |||
1526 | index *= get_n_columns (tree_view); | |||
1527 | index += get_column_number (tree_view, info->cell_col_ref); | |||
1528 | ||||
1529 | return index; | |||
1530 | } | |||
1531 | ||||
1532 | static void | |||
1533 | cell_info_new (CtkTreeViewAccessible *accessible, | |||
1534 | CtkRBTree *tree, | |||
1535 | CtkRBNode *node, | |||
1536 | CtkTreeViewColumn *tv_col, | |||
1537 | CtkCellAccessible *cell) | |||
1538 | { | |||
1539 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1540 | ||||
1541 | cell_info = g_new (CtkTreeViewAccessibleCellInfo, 1)((CtkTreeViewAccessibleCellInfo *) g_malloc_n ((1), sizeof (CtkTreeViewAccessibleCellInfo ))); | |||
1542 | ||||
1543 | cell_info->tree = tree; | |||
1544 | cell_info->node = node; | |||
1545 | cell_info->cell_col_ref = tv_col; | |||
1546 | cell_info->cell = cell; | |||
1547 | cell_info->view = accessible; | |||
1548 | ||||
1549 | g_object_set_qdata (G_OBJECT (cell)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), (((GType) ((20) << (2)))))))), | |||
1550 | ctk_tree_view_accessible_get_data_quark (), | |||
1551 | cell_info); | |||
1552 | ||||
1553 | g_hash_table_replace (accessible->priv->cell_infos, cell_info, cell_info); | |||
1554 | } | |||
1555 | ||||
1556 | /* Returns the column number of the specified CtkTreeViewColumn | |||
1557 | * The column must be visible. | |||
1558 | */ | |||
1559 | static gint | |||
1560 | get_column_number (CtkTreeView *treeview, | |||
1561 | CtkTreeViewColumn *column) | |||
1562 | { | |||
1563 | guint i, number; | |||
1564 | ||||
1565 | number = 0; | |||
1566 | ||||
1567 | for (i = 0; i < ctk_tree_view_get_n_columns (treeview); i++) | |||
1568 | { | |||
1569 | CtkTreeViewColumn *cur; | |||
1570 | ||||
1571 | cur = ctk_tree_view_get_column (treeview, i); | |||
1572 | ||||
1573 | if (!ctk_tree_view_column_get_visible (cur)) | |||
1574 | continue; | |||
1575 | ||||
1576 | if (cur == column) | |||
1577 | break; | |||
1578 | ||||
1579 | number++; | |||
1580 | } | |||
1581 | ||||
1582 | g_return_val_if_fail (i < ctk_tree_view_get_n_columns (treeview), 0)do { if ((i < ctk_tree_view_get_n_columns (treeview))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "i < ctk_tree_view_get_n_columns (treeview)"); return ( 0); } } while (0); | |||
1583 | ||||
1584 | return number; | |||
1585 | } | |||
1586 | ||||
1587 | static gboolean | |||
1588 | get_rbtree_column_from_index (CtkTreeView *tree_view, | |||
1589 | gint index, | |||
1590 | CtkRBTree **tree, | |||
1591 | CtkRBNode **node, | |||
1592 | CtkTreeViewColumn **column) | |||
1593 | { | |||
1594 | guint n_columns = get_n_columns (tree_view); | |||
1595 | ||||
1596 | if (n_columns == 0) | |||
1597 | return FALSE(0); | |||
1598 | /* First row is the column headers */ | |||
1599 | index -= n_columns; | |||
1600 | if (index < 0) | |||
1601 | return FALSE(0); | |||
1602 | ||||
1603 | if (tree) | |||
1604 | { | |||
1605 | g_return_val_if_fail (node != NULL, FALSE)do { if ((node != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "node != NULL"); return ( (0)); } } while (0); | |||
1606 | ||||
1607 | if (!_ctk_rbtree_find_index (_ctk_tree_view_get_rbtree (tree_view), | |||
1608 | index / n_columns, | |||
1609 | tree, | |||
1610 | node)) | |||
1611 | return FALSE(0); | |||
1612 | } | |||
1613 | ||||
1614 | if (column) | |||
1615 | { | |||
1616 | *column = get_visible_column (tree_view, index % n_columns); | |||
1617 | if (*column == NULL((void*)0)) | |||
1618 | return FALSE(0); | |||
1619 | } | |||
1620 | return TRUE(!(0)); | |||
1621 | } | |||
1622 | ||||
1623 | static CtkTreeViewAccessibleCellInfo * | |||
1624 | find_cell_info (CtkTreeViewAccessible *accessible, | |||
1625 | CtkCellAccessible *cell) | |||
1626 | { | |||
1627 | AtkObject *parent; | |||
1628 | ||||
1629 | parent = atk_object_get_parent (ATK_OBJECT (cell)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), ((atk_object_get_type ()))))))); | |||
1630 | while (parent != ATK_OBJECT (accessible)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((accessible)), ((atk_object_get_type ()))))))) | |||
1631 | { | |||
1632 | cell = CTK_CELL_ACCESSIBLE (parent)((((CtkCellAccessible*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((parent)), ((ctk_cell_accessible_get_type ( ))))))); | |||
1633 | parent = atk_object_get_parent (ATK_OBJECT (cell)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), ((atk_object_get_type ()))))))); | |||
1634 | } | |||
1635 | ||||
1636 | return g_object_get_qdata (G_OBJECT (cell)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), (((GType) ((20) << (2)))))))), | |||
1637 | ctk_tree_view_accessible_get_data_quark ()); | |||
1638 | } | |||
1639 | ||||
1640 | static AtkObject * | |||
1641 | get_header_from_column (CtkTreeViewColumn *tv_col) | |||
1642 | { | |||
1643 | AtkObject *rc; | |||
1644 | CtkWidget *header_widget; | |||
1645 | ||||
1646 | if (tv_col == NULL((void*)0)) | |||
1647 | return NULL((void*)0); | |||
1648 | ||||
1649 | header_widget = ctk_tree_view_column_get_button (tv_col); | |||
1650 | ||||
1651 | if (header_widget) | |||
1652 | rc = ctk_widget_get_accessible (header_widget); | |||
1653 | else | |||
1654 | rc = NULL((void*)0); | |||
1655 | ||||
1656 | return rc; | |||
1657 | } | |||
1658 | ||||
1659 | void | |||
1660 | _ctk_tree_view_accessible_add (CtkTreeView *treeview, | |||
1661 | CtkRBTree *tree, | |||
1662 | CtkRBNode *node) | |||
1663 | { | |||
1664 | CtkTreeViewAccessible *accessible; | |||
1665 | guint row, n_rows, n_cols, i; | |||
1666 | ||||
1667 | accessible = CTK_TREE_VIEW_ACCESSIBLE (_ctk_widget_peek_accessible (CTK_WIDGET (treeview)))((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((_ctk_widget_peek_accessible (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((treeview )), ((ctk_widget_get_type ()))))))))), ((ctk_tree_view_accessible_get_type ())))))); | |||
1668 | if (accessible == NULL((void*)0)) | |||
1669 | return; | |||
1670 | ||||
1671 | if (node == NULL((void*)0)) | |||
1672 | { | |||
1673 | row = tree->parent_tree ? _ctk_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0; | |||
1674 | n_rows = tree->root->total_count; | |||
1675 | } | |||
1676 | else | |||
1677 | { | |||
1678 | row = _ctk_rbtree_node_get_index (tree, node); | |||
1679 | n_rows = 1 + (node->children ? node->children->root->total_count : 0); | |||
1680 | } | |||
1681 | ||||
1682 | g_signal_emit_by_name (accessible, "row-inserted", row, n_rows); | |||
1683 | ||||
1684 | n_cols = get_n_columns (treeview); | |||
1685 | if (n_cols) | |||
1686 | { | |||
1687 | for (i = (row + 1) * n_cols; i < (row + n_rows + 1) * n_cols; i++) | |||
1688 | { | |||
1689 | /* Pass NULL as the child object, i.e. 4th argument */ | |||
1690 | g_signal_emit_by_name (accessible, "children-changed::add", i, NULL((void*)0), NULL((void*)0)); | |||
1691 | } | |||
1692 | } | |||
1693 | } | |||
1694 | ||||
1695 | void | |||
1696 | _ctk_tree_view_accessible_remove (CtkTreeView *treeview, | |||
1697 | CtkRBTree *tree, | |||
1698 | CtkRBNode *node) | |||
1699 | { | |||
1700 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1701 | GHashTableIter iter; | |||
1702 | CtkTreeViewAccessible *accessible; | |||
1703 | guint row, n_rows, n_cols, i; | |||
1704 | ||||
1705 | accessible = CTK_TREE_VIEW_ACCESSIBLE (_ctk_widget_peek_accessible (CTK_WIDGET (treeview)))((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((_ctk_widget_peek_accessible (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((treeview )), ((ctk_widget_get_type ()))))))))), ((ctk_tree_view_accessible_get_type ())))))); | |||
1706 | if (accessible == NULL((void*)0)) | |||
1707 | return; | |||
1708 | ||||
1709 | /* if this shows up in profiles, special-case node->children == NULL */ | |||
1710 | ||||
1711 | if (node == NULL((void*)0)) | |||
1712 | { | |||
1713 | row = tree->parent_tree ? _ctk_rbtree_node_get_index (tree->parent_tree, tree->parent_node) : 0; | |||
1714 | n_rows = tree->root->total_count + 1; | |||
1715 | } | |||
1716 | else | |||
1717 | { | |||
1718 | row = _ctk_rbtree_node_get_index (tree, node); | |||
1719 | n_rows = 1 + (node->children ? node->children->root->total_count : 0); | |||
1720 | ||||
1721 | tree = node->children; | |||
1722 | } | |||
1723 | ||||
1724 | g_signal_emit_by_name (accessible, "row-deleted", row, n_rows); | |||
1725 | ||||
1726 | n_cols = get_n_columns (treeview); | |||
1727 | if (n_cols) | |||
1728 | { | |||
1729 | for (i = (n_rows + row + 1) * n_cols - 1; i >= (row + 1) * n_cols; i--) | |||
1730 | { | |||
1731 | /* Pass NULL as the child object, i.e. 4th argument */ | |||
1732 | g_signal_emit_by_name (accessible, "children-changed::remove", i, NULL((void*)0), NULL((void*)0)); | |||
1733 | } | |||
1734 | ||||
1735 | g_hash_table_iter_init (&iter, accessible->priv->cell_infos); | |||
1736 | while (g_hash_table_iter_next (&iter, NULL((void*)0), (gpointer *)&cell_info)) | |||
1737 | { | |||
1738 | if (node == cell_info->node || | |||
1739 | tree == cell_info->tree || | |||
1740 | (tree && _ctk_rbtree_contains (tree, cell_info->tree))) | |||
1741 | g_hash_table_iter_remove (&iter); | |||
1742 | } | |||
1743 | } | |||
1744 | } | |||
1745 | ||||
1746 | void | |||
1747 | _ctk_tree_view_accessible_changed (CtkTreeView *treeview, | |||
1748 | CtkRBTree *tree, | |||
1749 | CtkRBNode *node) | |||
1750 | { | |||
1751 | CtkTreeViewAccessible *accessible; | |||
1752 | guint i; | |||
1753 | ||||
1754 | accessible = CTK_TREE_VIEW_ACCESSIBLE (ctk_widget_get_accessible (CTK_WIDGET (treeview)))((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((ctk_widget_get_accessible (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((treeview )), ((ctk_widget_get_type ()))))))))), ((ctk_tree_view_accessible_get_type ())))))); | |||
1755 | ||||
1756 | for (i = 0; i < ctk_tree_view_get_n_columns (treeview); i++) | |||
1757 | { | |||
1758 | CtkCellAccessible *cell = peek_cell (accessible, | |||
1759 | tree, node, | |||
1760 | ctk_tree_view_get_column (treeview, i)); | |||
1761 | ||||
1762 | if (cell == NULL((void*)0)) | |||
1763 | continue; | |||
1764 | ||||
1765 | set_cell_data (treeview, accessible, cell); | |||
1766 | _ctk_cell_accessible_update_cache (cell, TRUE(!(0))); | |||
1767 | } | |||
1768 | ||||
1769 | g_signal_emit_by_name (accessible, "visible-data-changed"); | |||
1770 | } | |||
1771 | ||||
1772 | /* NB: id is not checked, only columns < id are. | |||
1773 | * This is important so the function works for notification of removal of a column */ | |||
1774 | static guint | |||
1775 | to_visible_column_id (CtkTreeView *treeview, | |||
1776 | guint id) | |||
1777 | { | |||
1778 | guint i; | |||
1779 | guint invisible; | |||
1780 | ||||
1781 | invisible = 0; | |||
1782 | ||||
1783 | for (i = 0; i < id; i++) | |||
1784 | { | |||
1785 | CtkTreeViewColumn *column = ctk_tree_view_get_column (treeview, i); | |||
1786 | ||||
1787 | if (!ctk_tree_view_column_get_visible (column)) | |||
1788 | invisible++; | |||
1789 | } | |||
1790 | ||||
1791 | return id - invisible; | |||
1792 | } | |||
1793 | ||||
1794 | static void | |||
1795 | ctk_tree_view_accessible_do_add_column (CtkTreeViewAccessible *accessible, | |||
1796 | CtkTreeView *treeview, | |||
1797 | CtkTreeViewColumn *column G_GNUC_UNUSED__attribute__ ((__unused__)), | |||
1798 | guint id) | |||
1799 | { | |||
1800 | guint row, n_rows, n_cols; | |||
1801 | ||||
1802 | /* Generate column-inserted signal */ | |||
1803 | g_signal_emit_by_name (accessible, "column-inserted", id, 1); | |||
1804 | ||||
1805 | n_rows = get_n_rows (treeview); | |||
1806 | n_cols = get_n_columns (treeview); | |||
1807 | ||||
1808 | /* Generate children-changed signals */ | |||
1809 | for (row = 0; row <= n_rows; row++) | |||
1810 | { | |||
1811 | /* Pass NULL as the child object, i.e. 4th argument */ | |||
1812 | g_signal_emit_by_name (accessible, "children-changed::add", | |||
1813 | (row * n_cols) + id, NULL((void*)0), NULL((void*)0)); | |||
1814 | } | |||
1815 | } | |||
1816 | ||||
1817 | void | |||
1818 | _ctk_tree_view_accessible_add_column (CtkTreeView *treeview, | |||
1819 | CtkTreeViewColumn *column, | |||
1820 | guint id) | |||
1821 | { | |||
1822 | AtkObject *obj; | |||
1823 | ||||
1824 | if (!ctk_tree_view_column_get_visible (column)) | |||
1825 | return; | |||
1826 | ||||
1827 | obj = _ctk_widget_peek_accessible (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ()))))))); | |||
1828 | if (obj == NULL((void*)0)) | |||
1829 | return; | |||
1830 | ||||
1831 | ctk_tree_view_accessible_do_add_column (CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))), | |||
1832 | treeview, | |||
1833 | column, | |||
1834 | to_visible_column_id (treeview, id)); | |||
1835 | } | |||
1836 | ||||
1837 | static void | |||
1838 | ctk_tree_view_accessible_do_remove_column (CtkTreeViewAccessible *accessible, | |||
1839 | CtkTreeView *treeview, | |||
1840 | CtkTreeViewColumn *column, | |||
1841 | guint id) | |||
1842 | { | |||
1843 | GHashTableIter iter; | |||
1844 | gpointer value; | |||
1845 | guint row, n_rows, n_cols; | |||
1846 | ||||
1847 | /* Clean column from cache */ | |||
1848 | g_hash_table_iter_init (&iter, accessible->priv->cell_infos); | |||
1849 | while (g_hash_table_iter_next (&iter, NULL((void*)0), &value)) | |||
1850 | { | |||
1851 | CtkTreeViewAccessibleCellInfo *cell_info; | |||
1852 | ||||
1853 | cell_info = value; | |||
1854 | if (cell_info->cell_col_ref == column) | |||
1855 | g_hash_table_iter_remove (&iter); | |||
1856 | } | |||
1857 | ||||
1858 | /* Generate column-deleted signal */ | |||
1859 | g_signal_emit_by_name (accessible, "column-deleted", id, 1); | |||
1860 | ||||
1861 | n_rows = get_n_rows (treeview); | |||
1862 | n_cols = get_n_columns (treeview); | |||
1863 | ||||
1864 | /* Generate children-changed signals */ | |||
1865 | for (row = 0; row <= n_rows; row++) | |||
1866 | { | |||
1867 | /* Pass NULL as the child object, 4th argument */ | |||
1868 | g_signal_emit_by_name (accessible, "children-changed::remove", | |||
1869 | (row * n_cols) + id, NULL((void*)0), NULL((void*)0)); | |||
1870 | } | |||
1871 | } | |||
1872 | ||||
1873 | void | |||
1874 | _ctk_tree_view_accessible_remove_column (CtkTreeView *treeview, | |||
1875 | CtkTreeViewColumn *column, | |||
1876 | guint id) | |||
1877 | { | |||
1878 | AtkObject *obj; | |||
1879 | ||||
1880 | if (!ctk_tree_view_column_get_visible (column)) | |||
1881 | return; | |||
1882 | ||||
1883 | obj = _ctk_widget_peek_accessible (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ()))))))); | |||
1884 | if (obj == NULL((void*)0)) | |||
1885 | return; | |||
1886 | ||||
1887 | ctk_tree_view_accessible_do_remove_column (CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))), | |||
1888 | treeview, | |||
1889 | column, | |||
1890 | to_visible_column_id (treeview, id)); | |||
1891 | } | |||
1892 | ||||
1893 | void | |||
1894 | _ctk_tree_view_accessible_reorder_column (CtkTreeView *treeview, | |||
1895 | CtkTreeViewColumn *column G_GNUC_UNUSED__attribute__ ((__unused__))) | |||
1896 | { | |||
1897 | AtkObject *obj; | |||
1898 | ||||
1899 | obj = _ctk_widget_peek_accessible (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ()))))))); | |||
1900 | if (obj == NULL((void*)0)) | |||
1901 | return; | |||
1902 | ||||
1903 | g_signal_emit_by_name (obj, "column-reordered"); | |||
1904 | } | |||
1905 | ||||
1906 | void | |||
1907 | _ctk_tree_view_accessible_toggle_visibility (CtkTreeView *treeview, | |||
1908 | CtkTreeViewColumn *column) | |||
1909 | { | |||
1910 | AtkObject *obj; | |||
1911 | guint i, id; | |||
1912 | ||||
1913 | obj = _ctk_widget_peek_accessible (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ()))))))); | |||
1914 | if (obj == NULL((void*)0)) | |||
1915 | return; | |||
1916 | ||||
1917 | if (ctk_tree_view_column_get_visible (column)) | |||
1918 | { | |||
1919 | id = get_column_number (treeview, column); | |||
1920 | ||||
1921 | ctk_tree_view_accessible_do_add_column (CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))), | |||
1922 | treeview, | |||
1923 | column, | |||
1924 | id); | |||
1925 | } | |||
1926 | else | |||
1927 | { | |||
1928 | id = 0; | |||
1929 | ||||
1930 | for (i = 0; i < ctk_tree_view_get_n_columns (treeview); i++) | |||
1931 | { | |||
1932 | CtkTreeViewColumn *cur = ctk_tree_view_get_column (treeview, i); | |||
1933 | ||||
1934 | if (ctk_tree_view_column_get_visible (cur)) | |||
1935 | id++; | |||
1936 | ||||
1937 | if (cur == column) | |||
1938 | break; | |||
1939 | } | |||
1940 | ||||
1941 | ctk_tree_view_accessible_do_remove_column (CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))), | |||
1942 | treeview, | |||
1943 | column, | |||
1944 | id); | |||
1945 | } | |||
1946 | } | |||
1947 | ||||
1948 | static CtkTreeViewColumn * | |||
1949 | get_effective_focus_column (CtkTreeView *treeview, | |||
1950 | CtkTreeViewColumn *column) | |||
1951 | { | |||
1952 | if (column == NULL((void*)0) && get_n_columns (treeview) > 0) | |||
1953 | column = get_visible_column (treeview, 0); | |||
1954 | ||||
1955 | return column; | |||
1956 | } | |||
1957 | ||||
1958 | void | |||
1959 | _ctk_tree_view_accessible_update_focus_column (CtkTreeView *treeview, | |||
1960 | CtkTreeViewColumn *old_focus, | |||
1961 | CtkTreeViewColumn *new_focus) | |||
1962 | { | |||
1963 | CtkTreeViewAccessible *accessible; | |||
1964 | AtkObject *obj; | |||
1965 | CtkRBTree *cursor_tree; | |||
1966 | CtkRBNode *cursor_node; | |||
1967 | CtkCellAccessible *cell; | |||
1968 | ||||
1969 | old_focus = get_effective_focus_column (treeview, old_focus); | |||
1970 | new_focus = get_effective_focus_column (treeview, new_focus); | |||
1971 | if (old_focus == new_focus) | |||
1972 | return; | |||
1973 | ||||
1974 | obj = _ctk_widget_peek_accessible (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ()))))))); | |||
1975 | if (obj == NULL((void*)0)) | |||
1976 | return; | |||
1977 | ||||
1978 | accessible = CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))); | |||
1979 | ||||
1980 | if (!_ctk_tree_view_get_cursor_node (treeview, &cursor_tree, &cursor_node)) | |||
1981 | return; | |||
1982 | ||||
1983 | if (old_focus) | |||
1984 | { | |||
1985 | cell = peek_cell (accessible, cursor_tree, cursor_node, old_focus); | |||
1986 | if (cell != NULL((void*)0)) | |||
1987 | _ctk_cell_accessible_state_changed (cell, CTK_CELL_RENDERER_FOCUSED, 0); | |||
1988 | } | |||
1989 | ||||
1990 | if (new_focus) | |||
1991 | { | |||
1992 | cell = peek_cell (accessible, cursor_tree, cursor_node, new_focus); | |||
1993 | if (cell != NULL((void*)0)) | |||
1994 | _ctk_cell_accessible_state_changed (cell, 0, CTK_CELL_RENDERER_FOCUSED); | |||
1995 | else | |||
1996 | cell = create_cell (treeview, accessible, cursor_tree, cursor_node, new_focus); | |||
1997 | ||||
1998 | g_signal_emit_by_name (accessible, "active-descendant-changed", cell); | |||
1999 | } | |||
2000 | } | |||
2001 | ||||
2002 | void | |||
2003 | _ctk_tree_view_accessible_add_state (CtkTreeView *treeview, | |||
2004 | CtkRBTree *tree, | |||
2005 | CtkRBNode *node, | |||
2006 | CtkCellRendererState state) | |||
2007 | { | |||
2008 | CtkTreeViewAccessible *accessible; | |||
2009 | CtkTreeViewColumn *single_column; | |||
2010 | AtkObject *obj; | |||
2011 | guint i; | |||
2012 | ||||
2013 | obj = _ctk_widget_peek_accessible (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ()))))))); | |||
2014 | if (obj == NULL((void*)0)) | |||
2015 | return; | |||
2016 | ||||
2017 | accessible = CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))); | |||
2018 | ||||
2019 | if (state == CTK_CELL_RENDERER_FOCUSED) | |||
2020 | { | |||
2021 | single_column = get_effective_focus_column (treeview, _ctk_tree_view_get_focus_column (treeview)); | |||
2022 | } | |||
2023 | else if (state == CTK_CELL_RENDERER_EXPANDED || | |||
2024 | state == CTK_CELL_RENDERER_EXPANDABLE) | |||
2025 | { | |||
2026 | single_column = ctk_tree_view_get_expander_column (treeview); | |||
2027 | } | |||
2028 | else | |||
2029 | single_column = NULL((void*)0); | |||
2030 | ||||
2031 | if (single_column) | |||
2032 | { | |||
2033 | CtkCellAccessible *cell = peek_cell (accessible, | |||
2034 | tree, node, | |||
2035 | single_column); | |||
2036 | ||||
2037 | if (cell != NULL((void*)0)) | |||
2038 | _ctk_cell_accessible_state_changed (cell, state, 0); | |||
2039 | ||||
2040 | if (state == CTK_CELL_RENDERER_FOCUSED) | |||
2041 | { | |||
2042 | if (cell == NULL((void*)0)) | |||
2043 | cell = create_cell (treeview, accessible, tree, node, single_column); | |||
2044 | ||||
2045 | g_signal_emit_by_name (accessible, "active-descendant-changed", cell); | |||
2046 | } | |||
2047 | } | |||
2048 | else | |||
2049 | { | |||
2050 | for (i = 0; i < ctk_tree_view_get_n_columns (treeview); i++) | |||
2051 | { | |||
2052 | CtkCellAccessible *cell = peek_cell (accessible, | |||
2053 | tree, node, | |||
2054 | ctk_tree_view_get_column (treeview, i)); | |||
2055 | ||||
2056 | if (cell == NULL((void*)0)) | |||
2057 | continue; | |||
2058 | ||||
2059 | _ctk_cell_accessible_state_changed (cell, state, 0); | |||
2060 | } | |||
2061 | } | |||
2062 | ||||
2063 | if (state == CTK_CELL_RENDERER_SELECTED) | |||
2064 | g_signal_emit_by_name (accessible, "selection-changed"); | |||
2065 | } | |||
2066 | ||||
2067 | void | |||
2068 | _ctk_tree_view_accessible_remove_state (CtkTreeView *treeview, | |||
2069 | CtkRBTree *tree, | |||
2070 | CtkRBNode *node, | |||
2071 | CtkCellRendererState state) | |||
2072 | { | |||
2073 | CtkTreeViewAccessible *accessible; | |||
2074 | CtkTreeViewColumn *single_column; | |||
2075 | AtkObject *obj; | |||
2076 | guint i; | |||
2077 | ||||
2078 | obj = _ctk_widget_peek_accessible (CTK_WIDGET (treeview)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_widget_get_type ()))))))); | |||
2079 | if (obj == NULL((void*)0)) | |||
2080 | return; | |||
2081 | ||||
2082 | accessible = CTK_TREE_VIEW_ACCESSIBLE (obj)((((CtkTreeViewAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((obj)), ((ctk_tree_view_accessible_get_type ())))))); | |||
2083 | ||||
2084 | if (state == CTK_CELL_RENDERER_FOCUSED) | |||
2085 | { | |||
2086 | single_column = get_effective_focus_column (treeview, _ctk_tree_view_get_focus_column (treeview)); | |||
2087 | } | |||
2088 | else if (state == CTK_CELL_RENDERER_EXPANDED || | |||
2089 | state == CTK_CELL_RENDERER_EXPANDABLE) | |||
2090 | { | |||
2091 | single_column = ctk_tree_view_get_expander_column (treeview); | |||
2092 | } | |||
2093 | else | |||
2094 | single_column = NULL((void*)0); | |||
2095 | ||||
2096 | if (single_column) | |||
2097 | { | |||
2098 | CtkCellAccessible *cell = peek_cell (accessible, | |||
2099 | tree, node, | |||
2100 | single_column); | |||
2101 | ||||
2102 | if (cell != NULL((void*)0)) | |||
2103 | _ctk_cell_accessible_state_changed (cell, 0, state); | |||
2104 | } | |||
2105 | else | |||
2106 | { | |||
2107 | for (i = 0; i < ctk_tree_view_get_n_columns (treeview); i++) | |||
2108 | { | |||
2109 | CtkCellAccessible *cell = peek_cell (accessible, | |||
2110 | tree, node, | |||
2111 | ctk_tree_view_get_column (treeview, i)); | |||
2112 | ||||
2113 | if (cell == NULL((void*)0)) | |||
2114 | continue; | |||
2115 | ||||
2116 | _ctk_cell_accessible_state_changed (cell, 0, state); | |||
2117 | } | |||
2118 | } | |||
2119 | ||||
2120 | if (state == CTK_CELL_RENDERER_SELECTED) | |||
2121 | g_signal_emit_by_name (accessible, "selection-changed"); | |||
2122 | } |