File: | ctk/a11y/ctktextcellaccessible.c |
Warning: | line 340, column 3 Value stored to 'attrib_set' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* CTK+ - accessibility implementations |
2 | * Copyright 2001 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 | #include "../ctkpango.h" |
22 | #include "ctktextcellaccessible.h" |
23 | #include "ctkcontainercellaccessible.h" |
24 | #include "ctkcellaccessibleparent.h" |
25 | #include "ctkstylecontextprivate.h" |
26 | |
27 | struct _CtkTextCellAccessiblePrivate |
28 | { |
29 | gchar *cell_text; |
30 | gint caret_pos; |
31 | gint cell_length; |
32 | PangoLayout *layout; |
33 | }; |
34 | |
35 | static const gchar* ctk_text_cell_accessible_get_name (AtkObject *atk_obj); |
36 | |
37 | |
38 | /* atktext.h */ |
39 | |
40 | static gchar* ctk_text_cell_accessible_get_text (AtkText *text, |
41 | gint start_pos, |
42 | gint end_pos); |
43 | static gunichar ctk_text_cell_accessible_get_character_at_offset (AtkText *text, |
44 | gint offset); |
45 | static gchar* ctk_text_cell_accessible_get_text_before_offset (AtkText *text, |
46 | gint offset, |
47 | AtkTextBoundary boundary_type, |
48 | gint *start_offset, |
49 | gint *end_offset); |
50 | static gchar* ctk_text_cell_accessible_get_text_at_offset (AtkText *text, |
51 | gint offset, |
52 | AtkTextBoundary boundary_type, |
53 | gint *start_offset, |
54 | gint *end_offset); |
55 | static gchar* ctk_text_cell_accessible_get_text_after_offset (AtkText *text, |
56 | gint offset, |
57 | AtkTextBoundary boundary_type, |
58 | gint *start_offset, |
59 | gint *end_offset); |
60 | static gint ctk_text_cell_accessible_get_character_count (AtkText *text); |
61 | static gint ctk_text_cell_accessible_get_caret_offset (AtkText *text); |
62 | static gboolean ctk_text_cell_accessible_set_caret_offset (AtkText *text, |
63 | gint offset); |
64 | static void ctk_text_cell_accessible_get_character_extents (AtkText *text, |
65 | gint offset, |
66 | gint *x, |
67 | gint *y, |
68 | gint *width, |
69 | gint *height, |
70 | AtkCoordType coords); |
71 | static gint ctk_text_cell_accessible_get_offset_at_point (AtkText *text, |
72 | gint x, |
73 | gint y, |
74 | AtkCoordType coords); |
75 | static AtkAttributeSet* ctk_text_cell_accessible_get_run_attributes |
76 | (AtkText *text, |
77 | gint offset, |
78 | gint *start_offset, |
79 | gint *end_offset); |
80 | static AtkAttributeSet* ctk_text_cell_accessible_get_default_attributes |
81 | (AtkText *text); |
82 | |
83 | static CtkWidget* get_widget (CtkTextCellAccessible *cell); |
84 | static PangoLayout* create_pango_layout (CtkTextCellAccessible *cell); |
85 | static void add_attr (PangoAttrList *attr_list, |
86 | PangoAttribute *attr); |
87 | |
88 | /* Misc */ |
89 | |
90 | static void ctk_text_cell_accessible_update_cache (CtkCellAccessible *cell, |
91 | gboolean emit_signal); |
92 | |
93 | static void atk_text_interface_init (AtkTextIface *iface); |
94 | |
95 | G_DEFINE_TYPE_WITH_CODE (CtkTextCellAccessible, ctk_text_cell_accessible, CTK_TYPE_RENDERER_CELL_ACCESSIBLE,static void ctk_text_cell_accessible_init (CtkTextCellAccessible *self); static void ctk_text_cell_accessible_class_init (CtkTextCellAccessibleClass *klass); static GType ctk_text_cell_accessible_get_type_once (void); static gpointer ctk_text_cell_accessible_parent_class = ((void*)0); static gint CtkTextCellAccessible_private_offset ; static void ctk_text_cell_accessible_class_intern_init (gpointer klass) { ctk_text_cell_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTextCellAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTextCellAccessible_private_offset); ctk_text_cell_accessible_class_init ((CtkTextCellAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_text_cell_accessible_get_instance_private (CtkTextCellAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTextCellAccessible_private_offset)))) ; } GType ctk_text_cell_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_text_cell_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_text_cell_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_renderer_cell_accessible_get_type ()), g_intern_static_string ("CtkTextCellAccessible"), sizeof (CtkTextCellAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_text_cell_accessible_class_intern_init , sizeof (CtkTextCellAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_text_cell_accessible_init, (GTypeFlags) 0); { {{ CtkTextCellAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTextCellAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_text_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_text_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
96 | G_ADD_PRIVATE (CtkTextCellAccessible)static void ctk_text_cell_accessible_init (CtkTextCellAccessible *self); static void ctk_text_cell_accessible_class_init (CtkTextCellAccessibleClass *klass); static GType ctk_text_cell_accessible_get_type_once (void); static gpointer ctk_text_cell_accessible_parent_class = ((void*)0); static gint CtkTextCellAccessible_private_offset ; static void ctk_text_cell_accessible_class_intern_init (gpointer klass) { ctk_text_cell_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTextCellAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTextCellAccessible_private_offset); ctk_text_cell_accessible_class_init ((CtkTextCellAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_text_cell_accessible_get_instance_private (CtkTextCellAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTextCellAccessible_private_offset)))) ; } GType ctk_text_cell_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_text_cell_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_text_cell_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_renderer_cell_accessible_get_type ()), g_intern_static_string ("CtkTextCellAccessible"), sizeof (CtkTextCellAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_text_cell_accessible_class_intern_init , sizeof (CtkTextCellAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_text_cell_accessible_init, (GTypeFlags) 0); { {{ CtkTextCellAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTextCellAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_text_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_text_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
97 | G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))static void ctk_text_cell_accessible_init (CtkTextCellAccessible *self); static void ctk_text_cell_accessible_class_init (CtkTextCellAccessibleClass *klass); static GType ctk_text_cell_accessible_get_type_once (void); static gpointer ctk_text_cell_accessible_parent_class = ((void*)0); static gint CtkTextCellAccessible_private_offset ; static void ctk_text_cell_accessible_class_intern_init (gpointer klass) { ctk_text_cell_accessible_parent_class = g_type_class_peek_parent (klass); if (CtkTextCellAccessible_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkTextCellAccessible_private_offset); ctk_text_cell_accessible_class_init ((CtkTextCellAccessibleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_text_cell_accessible_get_instance_private (CtkTextCellAccessible *self) { return (((gpointer) ((guint8 *) (self) + (glong) (CtkTextCellAccessible_private_offset)))) ; } GType ctk_text_cell_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_text_cell_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_text_cell_accessible_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_renderer_cell_accessible_get_type ()), g_intern_static_string ("CtkTextCellAccessible"), sizeof (CtkTextCellAccessibleClass ), (GClassInitFunc)(void (*)(void)) ctk_text_cell_accessible_class_intern_init , sizeof (CtkTextCellAccessible), (GInstanceInitFunc)(void (* )(void)) ctk_text_cell_accessible_init, (GTypeFlags) 0); { {{ CtkTextCellAccessible_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkTextCellAccessiblePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc )(void (*)(void)) atk_text_interface_init, ((void*)0), ((void *)0) }; g_type_add_interface_static (g_define_type_id, (atk_text_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
98 | |
99 | static AtkStateSet * |
100 | ctk_text_cell_accessible_ref_state_set (AtkObject *accessible) |
101 | { |
102 | AtkStateSet *state_set; |
103 | |
104 | state_set = ATK_OBJECT_CLASS (ctk_text_cell_accessible_parent_class)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_text_cell_accessible_parent_class)), ((atk_object_get_type ()))))))->ref_state_set (accessible); |
105 | |
106 | atk_state_set_add_state (state_set, ATK_STATE_SINGLE_LINE); |
107 | |
108 | return state_set; |
109 | } |
110 | |
111 | static void |
112 | ctk_text_cell_accessible_finalize (GObject *object) |
113 | { |
114 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (object)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ctk_text_cell_accessible_get_type ())))))); |
115 | |
116 | g_free (text_cell->priv->cell_text); |
117 | |
118 | if (text_cell->priv->layout) |
119 | g_object_unref (text_cell->priv->layout); |
120 | |
121 | G_OBJECT_CLASS (ctk_text_cell_accessible_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_text_cell_accessible_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); |
122 | } |
123 | |
124 | static const gchar * |
125 | ctk_text_cell_accessible_get_name (AtkObject *atk_obj) |
126 | { |
127 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (atk_obj)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((atk_obj)), ((ctk_text_cell_accessible_get_type ())))))); |
128 | |
129 | if (atk_obj->name) |
130 | return atk_obj->name; |
131 | |
132 | return text_cell->priv->cell_text; |
133 | } |
134 | |
135 | static void |
136 | ctk_text_cell_accessible_update_cache (CtkCellAccessible *cell, |
137 | gboolean emit_signal) |
138 | { |
139 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (cell)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((cell)), ((ctk_text_cell_accessible_get_type ())))))); |
140 | AtkObject *obj = ATK_OBJECT (cell)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell)), ((atk_object_get_type ())))))); |
141 | gint text_length; |
142 | gchar *text; |
143 | CtkCellRenderer *renderer; |
144 | |
145 | if (text_cell->priv->layout) |
146 | g_object_unref (text_cell->priv->layout); |
147 | text_cell->priv->layout = create_pango_layout (text_cell); |
148 | |
149 | g_object_get (cell, "renderer", &renderer, NULL((void*)0)); |
150 | g_object_get (renderer, "text", &text, NULL((void*)0)); |
151 | g_object_unref (renderer); |
152 | |
153 | if (text == NULL((void*)0)) |
154 | text = g_strdup ("")g_strdup_inline (""); |
155 | text_length = g_utf8_strlen (text, -1); |
156 | |
157 | if (g_strcmp0 (text_cell->priv->cell_text, text) != 0) |
158 | { |
159 | if (text_cell->priv->cell_length && emit_signal) |
160 | { |
161 | g_signal_emit_by_name (cell, "text-changed::delete", |
162 | 0, text_cell->priv->cell_length); |
163 | } |
164 | |
165 | g_free (text_cell->priv->cell_text); |
166 | text_cell->priv->cell_text = g_strdup (text)g_strdup_inline (text); |
167 | text_cell->priv->cell_length = text_length; |
168 | |
169 | if (text_length && emit_signal) |
170 | { |
171 | g_signal_emit_by_name (cell, "text-changed::insert", |
172 | 0, text_cell->priv->cell_length); |
173 | } |
174 | |
175 | if (obj->name == NULL((void*)0) && emit_signal) |
176 | g_object_notify (G_OBJECT (obj)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((obj)), (((GType) ((20) << (2)))))))), "accessible-name"); |
177 | } |
178 | |
179 | g_free (text); |
180 | } |
181 | |
182 | static void |
183 | ctk_text_cell_accessible_class_init (CtkTextCellAccessibleClass *klass) |
184 | { |
185 | GObjectClass *gobject_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
186 | AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass)((((AtkObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((atk_object_get_type ())))))); |
187 | CtkCellAccessibleClass *cell_class = CTK_CELL_ACCESSIBLE_CLASS (klass)((((CtkCellAccessibleClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ctk_cell_accessible_get_type ()) ))))); |
188 | |
189 | cell_class->update_cache = ctk_text_cell_accessible_update_cache; |
190 | |
191 | atk_object_class->get_name = ctk_text_cell_accessible_get_name; |
192 | atk_object_class->ref_state_set = ctk_text_cell_accessible_ref_state_set; |
193 | |
194 | gobject_class->finalize = ctk_text_cell_accessible_finalize; |
195 | } |
196 | |
197 | static void |
198 | ctk_text_cell_accessible_init (CtkTextCellAccessible *text_cell) |
199 | { |
200 | text_cell->priv = ctk_text_cell_accessible_get_instance_private (text_cell); |
201 | } |
202 | |
203 | static gchar * |
204 | ctk_text_cell_accessible_get_text (AtkText *atk_text, |
205 | gint start_pos, |
206 | gint end_pos) |
207 | { |
208 | gchar *text; |
209 | |
210 | text = CTK_TEXT_CELL_ACCESSIBLE (atk_text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((atk_text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->cell_text; |
211 | if (text) |
212 | return g_utf8_substring (text, start_pos, end_pos > -1 ? end_pos : g_utf8_strlen (text, -1)); |
213 | else |
214 | return g_strdup ("")g_strdup_inline (""); |
215 | } |
216 | |
217 | static gchar * |
218 | ctk_text_cell_accessible_get_text_before_offset (AtkText *atk_text, |
219 | gint offset, |
220 | AtkTextBoundary boundary_type, |
221 | gint *start_offset, |
222 | gint *end_offset) |
223 | { |
224 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (atk_text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((atk_text)), ((ctk_text_cell_accessible_get_type ())))))); |
225 | gchar *text; |
226 | |
227 | text = _ctk_pango_get_text_before (text_cell->priv->layout, boundary_type, offset, start_offset, end_offset); |
228 | |
229 | return text; |
230 | } |
231 | |
232 | static gchar * |
233 | ctk_text_cell_accessible_get_text_at_offset (AtkText *atk_text, |
234 | gint offset, |
235 | AtkTextBoundary boundary_type, |
236 | gint *start_offset, |
237 | gint *end_offset) |
238 | { |
239 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (atk_text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((atk_text)), ((ctk_text_cell_accessible_get_type ())))))); |
240 | gchar *text; |
241 | |
242 | text = _ctk_pango_get_text_at (text_cell->priv->layout, boundary_type, offset, start_offset, end_offset); |
243 | |
244 | return text; |
245 | } |
246 | |
247 | static gchar * |
248 | ctk_text_cell_accessible_get_text_after_offset (AtkText *atk_text, |
249 | gint offset, |
250 | AtkTextBoundary boundary_type, |
251 | gint *start_offset, |
252 | gint *end_offset) |
253 | { |
254 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (atk_text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((atk_text)), ((ctk_text_cell_accessible_get_type ())))))); |
255 | gchar *text; |
256 | |
257 | text = _ctk_pango_get_text_after (text_cell->priv->layout, boundary_type, offset, start_offset, end_offset); |
258 | |
259 | return text; |
260 | } |
261 | |
262 | static gint |
263 | ctk_text_cell_accessible_get_character_count (AtkText *text) |
264 | { |
265 | if (CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->cell_text != NULL((void*)0)) |
266 | return CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->cell_length; |
267 | else |
268 | return 0; |
269 | } |
270 | |
271 | static gint |
272 | ctk_text_cell_accessible_get_caret_offset (AtkText *text) |
273 | { |
274 | return CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->caret_pos; |
275 | } |
276 | |
277 | static gboolean |
278 | ctk_text_cell_accessible_set_caret_offset (AtkText *text, |
279 | gint offset) |
280 | { |
281 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ())))))); |
282 | |
283 | if (text_cell->priv->cell_text == NULL((void*)0)) |
284 | return FALSE(0); |
285 | else |
286 | { |
287 | /* Only set the caret within the bounds and if it is to a new position. */ |
288 | if (offset >= 0 && |
289 | offset <= text_cell->priv->cell_length && |
290 | offset != text_cell->priv->caret_pos) |
291 | { |
292 | text_cell->priv->caret_pos = offset; |
293 | |
294 | /* emit the signal */ |
295 | g_signal_emit_by_name (text, "text-caret-moved", offset); |
296 | return TRUE(!(0)); |
297 | } |
298 | else |
299 | return FALSE(0); |
300 | } |
301 | } |
302 | |
303 | static AtkAttributeSet * |
304 | ctk_text_cell_accessible_get_run_attributes (AtkText *text, |
305 | gint offset, |
306 | gint *start_offset, |
307 | gint *end_offset) |
308 | { |
309 | AtkAttributeSet *attrib_set = NULL((void*)0); |
310 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ())))))); |
311 | |
312 | attrib_set = _ctk_pango_get_run_attributes (NULL((void*)0), text_cell->priv->layout, offset, start_offset, end_offset); |
313 | |
314 | return attrib_set; |
315 | } |
316 | |
317 | static AtkAttributeSet * |
318 | add_attribute (AtkAttributeSet *attributes, |
319 | AtkTextAttribute attr, |
320 | const gchar *value) |
321 | { |
322 | AtkAttribute *at; |
323 | |
324 | at = g_new (AtkAttribute, 1)((AtkAttribute *) g_malloc_n ((1), sizeof (AtkAttribute))); |
325 | at->name = g_strdup (atk_text_attribute_get_name (attr))g_strdup_inline (atk_text_attribute_get_name (attr)); |
326 | at->value = g_strdup (value)g_strdup_inline (value); |
327 | |
328 | return g_slist_prepend (attributes, at); |
329 | } |
330 | |
331 | static AtkAttributeSet * |
332 | ctk_text_cell_accessible_get_default_attributes (AtkText *text) |
333 | { |
334 | AtkAttributeSet *attrib_set = NULL((void*)0); |
335 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ())))))); |
336 | CtkWidget *widget; |
337 | |
338 | widget = get_widget (CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))); |
339 | |
340 | attrib_set = add_attribute (attrib_set, ATK_TEXT_ATTR_DIRECTION, |
Value stored to 'attrib_set' is never read | |
341 | atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, |
342 | ctk_widget_get_direction (widget))); |
343 | attrib_set = _ctk_pango_get_default_attributes (NULL((void*)0), text_cell->priv->layout); |
344 | |
345 | attrib_set = _ctk_style_context_get_attributes (attrib_set, |
346 | ctk_widget_get_style_context (widget), |
347 | ctk_widget_get_state_flags (widget)); |
348 | |
349 | return attrib_set; |
350 | } |
351 | |
352 | CtkWidget * |
353 | get_widget (CtkTextCellAccessible *text) |
354 | { |
355 | AtkObject *parent; |
356 | |
357 | parent = atk_object_get_parent (ATK_OBJECT (text)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((text)), ((atk_object_get_type ()))))))); |
358 | if (CTK_IS_CONTAINER_CELL_ACCESSIBLE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (parent)); GType __t = ((ctk_container_cell_accessible_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; }))))) |
359 | parent = atk_object_get_parent (parent); |
360 | |
361 | return ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); |
362 | } |
363 | |
364 | /* This function is used by ctk_text_cell_accessible_get_offset_at_point() |
365 | * and ctk_text_cell_accessible_get_character_extents(). There is no |
366 | * cached PangoLayout so we must create a temporary one using this function. |
367 | */ |
368 | static PangoLayout * |
369 | create_pango_layout (CtkTextCellAccessible *text) |
370 | { |
371 | CdkRGBA *foreground_rgba; |
372 | PangoAttrList *attr_list, *attributes; |
373 | PangoLayout *layout; |
374 | PangoUnderline uline, underline; |
375 | PangoFontMask mask; |
376 | PangoFontDescription *font_desc; |
377 | gboolean foreground_set, strikethrough_set, strikethrough; |
378 | gboolean scale_set, underline_set, rise_set; |
379 | gchar *renderer_text; |
380 | gdouble scale; |
381 | gint rise; |
382 | CtkRendererCellAccessible *cail_renderer; |
383 | CtkCellRendererText *ctk_renderer; |
384 | |
385 | cail_renderer = CTK_RENDERER_CELL_ACCESSIBLE (text)((((CtkRendererCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_renderer_cell_accessible_get_type ())))))); |
386 | g_object_get (cail_renderer, "renderer", &ctk_renderer, NULL((void*)0)); |
387 | |
388 | g_object_get (ctk_renderer, |
389 | "text", &renderer_text, |
390 | "attributes", &attributes, |
391 | "foreground-set", &foreground_set, |
392 | "foreground-rgba", &foreground_rgba, |
393 | "strikethrough-set", &strikethrough_set, |
394 | "strikethrough", &strikethrough, |
395 | "font-desc", &font_desc, |
396 | "scale-set", &scale_set, |
397 | "scale", &scale, |
398 | "underline-set", &underline_set, |
399 | "underline", &underline, |
400 | "rise-set", &rise_set, |
401 | "rise", &rise, |
402 | NULL((void*)0)); |
403 | g_object_unref (ctk_renderer); |
404 | |
405 | layout = ctk_widget_create_pango_layout (get_widget (text), renderer_text); |
406 | |
407 | if (attributes) |
408 | attr_list = pango_attr_list_copy (attributes); |
409 | else |
410 | attr_list = pango_attr_list_new (); |
411 | |
412 | if (foreground_set) |
413 | { |
414 | add_attr (attr_list, pango_attr_foreground_new (foreground_rgba->red * 65535, |
415 | foreground_rgba->green * 65535, |
416 | foreground_rgba->blue * 65535)); |
417 | } |
418 | |
419 | if (strikethrough_set) |
420 | add_attr (attr_list, |
421 | pango_attr_strikethrough_new (strikethrough)); |
422 | |
423 | mask = pango_font_description_get_set_fields (font_desc); |
424 | |
425 | if (mask & PANGO_FONT_MASK_FAMILY) |
426 | add_attr (attr_list, |
427 | pango_attr_family_new (pango_font_description_get_family (font_desc))); |
428 | |
429 | if (mask & PANGO_FONT_MASK_STYLE) |
430 | add_attr (attr_list, pango_attr_style_new (pango_font_description_get_style (font_desc))); |
431 | |
432 | if (mask & PANGO_FONT_MASK_VARIANT) |
433 | add_attr (attr_list, pango_attr_variant_new (pango_font_description_get_variant (font_desc))); |
434 | |
435 | if (mask & PANGO_FONT_MASK_WEIGHT) |
436 | add_attr (attr_list, pango_attr_weight_new (pango_font_description_get_weight (font_desc))); |
437 | |
438 | if (mask & PANGO_FONT_MASK_STRETCH) |
439 | add_attr (attr_list, pango_attr_stretch_new (pango_font_description_get_stretch (font_desc))); |
440 | |
441 | if (mask & PANGO_FONT_MASK_SIZE) |
442 | add_attr (attr_list, pango_attr_size_new (pango_font_description_get_size (font_desc))); |
443 | |
444 | if (scale_set && scale != 1.0) |
445 | add_attr (attr_list, pango_attr_scale_new (scale)); |
446 | |
447 | if (underline_set) |
448 | uline = underline; |
449 | else |
450 | uline = PANGO_UNDERLINE_NONE; |
451 | |
452 | if (uline != PANGO_UNDERLINE_NONE) |
453 | add_attr (attr_list, |
454 | pango_attr_underline_new (underline)); |
455 | |
456 | if (rise_set) |
457 | add_attr (attr_list, pango_attr_rise_new (rise)); |
458 | |
459 | pango_layout_set_attributes (layout, attr_list); |
460 | pango_layout_set_width (layout, -1); |
461 | pango_attr_list_unref (attr_list); |
462 | |
463 | pango_font_description_free (font_desc); |
464 | pango_attr_list_unref (attributes); |
465 | g_free (renderer_text); |
466 | cdk_rgba_free (foreground_rgba); |
467 | |
468 | return layout; |
469 | } |
470 | |
471 | static void |
472 | add_attr (PangoAttrList *attr_list, |
473 | PangoAttribute *attr) |
474 | { |
475 | attr->start_index = 0; |
476 | attr->end_index = G_MAXINT2147483647; |
477 | pango_attr_list_insert (attr_list, attr); |
478 | } |
479 | |
480 | |
481 | static void |
482 | get_origins (CtkWidget *widget, |
483 | gint *x_window, |
484 | gint *y_window, |
485 | gint *x_toplevel, |
486 | gint *y_toplevel) |
487 | { |
488 | CdkWindow *window; |
489 | |
490 | if (CTK_IS_TREE_VIEW (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (widget)); GType __t = ((ctk_tree_view_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; }))))) |
491 | window = ctk_tree_view_get_bin_window (CTK_TREE_VIEW (widget)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_tree_view_get_type ()))))))); |
492 | else |
493 | window = ctk_widget_get_window (widget); |
494 | |
495 | cdk_window_get_origin (window, x_window, y_window); |
496 | window = cdk_window_get_toplevel (ctk_widget_get_window (widget)); |
497 | cdk_window_get_origin (window, x_toplevel, y_toplevel); |
498 | } |
499 | |
500 | static void |
501 | ctk_text_cell_accessible_get_character_extents (AtkText *text, |
502 | gint offset, |
503 | gint *x, |
504 | gint *y, |
505 | gint *width, |
506 | gint *height, |
507 | AtkCoordType coords) |
508 | { |
509 | CtkRendererCellAccessible *cail_renderer; |
510 | CtkRequisition min_size; |
511 | CtkCellRendererText *ctk_renderer; |
512 | CdkRectangle rendered_rect; |
513 | CtkWidget *widget; |
514 | AtkObject *parent; |
515 | PangoRectangle char_rect; |
516 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ())))))); |
517 | gchar *renderer_text; |
518 | gfloat xalign, yalign; |
519 | gint x_offset, y_offset, index; |
520 | gint xpad, ypad; |
521 | gint x_window, y_window, x_toplevel, y_toplevel; |
522 | |
523 | if (!CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->cell_text) |
524 | { |
525 | *x = *y = *height = *width = 0; |
526 | return; |
527 | } |
528 | if (offset < 0 || offset >= CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->cell_length) |
529 | { |
530 | *x = *y = *height = *width = 0; |
531 | return; |
532 | } |
533 | cail_renderer = CTK_RENDERER_CELL_ACCESSIBLE (text)((((CtkRendererCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_renderer_cell_accessible_get_type ())))))); |
534 | g_object_get (cail_renderer, "renderer", &ctk_renderer, NULL((void*)0)); |
535 | g_object_get (ctk_renderer, "text", &renderer_text, NULL((void*)0)); |
536 | if (renderer_text == NULL((void*)0)) |
537 | { |
538 | g_object_unref (ctk_renderer); |
539 | return; |
540 | } |
541 | |
542 | parent = atk_object_get_parent (ATK_OBJECT (text)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((text)), ((atk_object_get_type ()))))))); |
543 | if (CTK_IS_CONTAINER_CELL_ACCESSIBLE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (parent)); GType __t = ((ctk_container_cell_accessible_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; }))))) |
544 | parent = atk_object_get_parent (parent); |
545 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); |
546 | g_return_if_fail (CTK_IS_CELL_ACCESSIBLE_PARENT (parent))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((parent)); GType __t = ((ctk_cell_accessible_parent_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_CELL_ACCESSIBLE_PARENT (parent)" ); return; } } while (0); |
547 | ctk_cell_accessible_parent_get_cell_area (CTK_CELL_ACCESSIBLE_PARENT (parent)(((CtkCellAccessibleParent*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_cell_accessible_parent_get_type ()))))), |
548 | CTK_CELL_ACCESSIBLE (text)((((CtkCellAccessible*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((text)), ((ctk_cell_accessible_get_type ()) ))))), |
549 | &rendered_rect); |
550 | |
551 | ctk_cell_renderer_get_preferred_size (CTK_CELL_RENDERER (ctk_renderer)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_renderer)), ((ctk_cell_renderer_get_type ())))))), |
552 | widget, |
553 | &min_size, NULL((void*)0)); |
554 | |
555 | ctk_cell_renderer_get_alignment (CTK_CELL_RENDERER (ctk_renderer)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_renderer)), ((ctk_cell_renderer_get_type ())))))), &xalign, &yalign); |
556 | if (ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL) |
557 | xalign = 1.0 - xalign; |
558 | x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width))(((0) > (xalign * (rendered_rect.width - min_size.width))) ? (0) : (xalign * (rendered_rect.width - min_size.width))); |
559 | y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height))(((0) > (yalign * (rendered_rect.height - min_size.height) )) ? (0) : (yalign * (rendered_rect.height - min_size.height) )); |
560 | |
561 | index = g_utf8_offset_to_pointer (renderer_text, offset) - renderer_text; |
562 | pango_layout_index_to_pos (text_cell->priv->layout, index, &char_rect); |
563 | |
564 | ctk_cell_renderer_get_padding (CTK_CELL_RENDERER (ctk_renderer)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_renderer)), ((ctk_cell_renderer_get_type ())))))), &xpad, &ypad); |
565 | |
566 | get_origins (widget, &x_window, &y_window, &x_toplevel, &y_toplevel); |
567 | |
568 | *x = (char_rect.x / PANGO_SCALE1024) + x_offset + rendered_rect.x + xpad + x_window; |
569 | *y = (char_rect.y / PANGO_SCALE1024) + y_offset + rendered_rect.y + ypad + y_window; |
570 | *height = char_rect.height / PANGO_SCALE1024; |
571 | *width = char_rect.width / PANGO_SCALE1024; |
572 | |
573 | if (coords == ATK_XY_WINDOW) |
574 | { |
575 | *x -= x_toplevel; |
576 | *y -= y_toplevel; |
577 | } |
578 | else if (coords != ATK_XY_SCREEN) |
579 | { |
580 | *x = 0; |
581 | *y = 0; |
582 | *height = 0; |
583 | *width = 0; |
584 | } |
585 | |
586 | g_free (renderer_text); |
587 | g_object_unref (ctk_renderer); |
588 | } |
589 | |
590 | static gint |
591 | ctk_text_cell_accessible_get_offset_at_point (AtkText *text, |
592 | gint x, |
593 | gint y, |
594 | AtkCoordType coords) |
595 | { |
596 | AtkObject *parent; |
597 | CtkRendererCellAccessible *cail_renderer; |
598 | CtkCellRendererText *ctk_renderer; |
599 | CtkRequisition min_size; |
600 | CtkWidget *widget; |
601 | CdkRectangle rendered_rect; |
602 | CtkTextCellAccessible *text_cell = CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ())))))); |
603 | gchar *renderer_text; |
604 | gfloat xalign, yalign; |
605 | gint x_offset, y_offset, index; |
606 | gint xpad, ypad; |
607 | gint x_window, y_window, x_toplevel, y_toplevel; |
608 | gint x_temp, y_temp; |
609 | gboolean ret; |
610 | |
611 | if (!CTK_TEXT_CELL_ACCESSIBLE (text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->cell_text) |
612 | return -1; |
613 | |
614 | cail_renderer = CTK_RENDERER_CELL_ACCESSIBLE (text)((((CtkRendererCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_renderer_cell_accessible_get_type ())))))); |
615 | g_object_get (cail_renderer, "renderer", &ctk_renderer, NULL((void*)0)); |
616 | parent = atk_object_get_parent (ATK_OBJECT (text)((((AtkObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((text)), ((atk_object_get_type ()))))))); |
617 | |
618 | g_object_get (ctk_renderer, "text", &renderer_text, NULL((void*)0)); |
619 | if (text == NULL((void*)0)) |
620 | { |
621 | g_object_unref (ctk_renderer); |
622 | g_free (renderer_text); |
623 | return -1; |
624 | } |
625 | |
626 | if (CTK_IS_CONTAINER_CELL_ACCESSIBLE (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (parent)); GType __t = ((ctk_container_cell_accessible_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; }))))) |
627 | parent = atk_object_get_parent (parent); |
628 | |
629 | widget = ctk_accessible_get_widget (CTK_ACCESSIBLE (parent)((((CtkAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_accessible_get_type ()))))))); |
630 | |
631 | g_return_val_if_fail (CTK_IS_CELL_ACCESSIBLE_PARENT (parent), -1)do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((parent)); GType __t = ((ctk_cell_accessible_parent_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "CTK_IS_CELL_ACCESSIBLE_PARENT (parent)" ); return (-1); } } while (0); |
632 | ctk_cell_accessible_parent_get_cell_area (CTK_CELL_ACCESSIBLE_PARENT (parent)(((CtkCellAccessibleParent*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_cell_accessible_parent_get_type ()))))), |
633 | CTK_CELL_ACCESSIBLE (text)((((CtkCellAccessible*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((text)), ((ctk_cell_accessible_get_type ()) ))))), |
634 | &rendered_rect); |
635 | |
636 | ctk_cell_renderer_get_preferred_size (CTK_CELL_RENDERER (ctk_renderer)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_renderer)), ((ctk_cell_renderer_get_type ())))))), |
637 | widget, |
638 | &min_size, NULL((void*)0)); |
639 | ctk_cell_renderer_get_alignment (CTK_CELL_RENDERER (ctk_renderer)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_renderer)), ((ctk_cell_renderer_get_type ())))))), &xalign, &yalign); |
640 | if (ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL) |
641 | xalign = 1.0 - xalign; |
642 | x_offset = MAX (0, xalign * (rendered_rect.width - min_size.width))(((0) > (xalign * (rendered_rect.width - min_size.width))) ? (0) : (xalign * (rendered_rect.width - min_size.width))); |
643 | y_offset = MAX (0, yalign * (rendered_rect.height - min_size.height))(((0) > (yalign * (rendered_rect.height - min_size.height) )) ? (0) : (yalign * (rendered_rect.height - min_size.height) )); |
644 | |
645 | ctk_cell_renderer_get_padding (CTK_CELL_RENDERER (ctk_renderer)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_renderer)), ((ctk_cell_renderer_get_type ())))))), &xpad, &ypad); |
646 | |
647 | get_origins (widget, &x_window, &y_window, &x_toplevel, &y_toplevel); |
648 | |
649 | x_temp = x - (x_offset + rendered_rect.x + xpad) - x_window; |
650 | y_temp = y - (y_offset + rendered_rect.y + ypad) - y_window; |
651 | if (coords == ATK_XY_WINDOW) |
652 | { |
653 | x_temp += x_toplevel; |
654 | y_temp += y_toplevel; |
655 | } |
656 | else if (coords != ATK_XY_SCREEN) |
657 | index = -1; |
658 | |
659 | ret = pango_layout_xy_to_index (text_cell->priv->layout, |
660 | x_temp * PANGO_SCALE1024, |
661 | y_temp * PANGO_SCALE1024, |
662 | &index, NULL((void*)0)); |
663 | if (!ret) |
664 | { |
665 | if (x_temp < 0 || y_temp < 0) |
666 | index = 0; |
667 | else |
668 | index = -1; |
669 | } |
670 | |
671 | g_object_unref (ctk_renderer); |
672 | |
673 | if (index == -1) |
674 | { |
675 | if (coords == ATK_XY_WINDOW || coords == ATK_XY_SCREEN) |
676 | { |
677 | glong length; |
678 | |
679 | length = g_utf8_strlen (renderer_text, -1); |
680 | g_free (renderer_text); |
681 | |
682 | return length; |
683 | } |
684 | |
685 | g_free (renderer_text); |
686 | |
687 | return index; |
688 | } |
689 | else |
690 | { |
691 | glong offset; |
692 | |
693 | offset = g_utf8_pointer_to_offset (renderer_text, |
694 | renderer_text + index); |
695 | g_free (renderer_text); |
696 | |
697 | return offset; |
698 | } |
699 | } |
700 | |
701 | static gunichar |
702 | ctk_text_cell_accessible_get_character_at_offset (AtkText *text, |
703 | gint offset) |
704 | { |
705 | gchar *index; |
706 | gchar *string; |
707 | |
708 | string = CTK_TEXT_CELL_ACCESSIBLE(text)((((CtkTextCellAccessible*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((text)), ((ctk_text_cell_accessible_get_type ()))))))->priv->cell_text; |
709 | |
710 | if (!string) |
711 | return '\0'; |
712 | |
713 | if (offset >= g_utf8_strlen (string, -1)) |
714 | return '\0'; |
715 | |
716 | index = g_utf8_offset_to_pointer (string, offset); |
717 | |
718 | return g_utf8_get_char (index); |
719 | } |
720 | |
721 | static void |
722 | atk_text_interface_init (AtkTextIface *iface) |
723 | { |
724 | iface->get_text = ctk_text_cell_accessible_get_text; |
725 | iface->get_character_at_offset = ctk_text_cell_accessible_get_character_at_offset; |
726 | iface->get_text_before_offset = ctk_text_cell_accessible_get_text_before_offset; |
727 | iface->get_text_at_offset = ctk_text_cell_accessible_get_text_at_offset; |
728 | iface->get_text_after_offset = ctk_text_cell_accessible_get_text_after_offset; |
729 | iface->get_character_count = ctk_text_cell_accessible_get_character_count; |
730 | iface->get_caret_offset = ctk_text_cell_accessible_get_caret_offset; |
731 | iface->set_caret_offset = ctk_text_cell_accessible_set_caret_offset; |
732 | iface->get_run_attributes = ctk_text_cell_accessible_get_run_attributes; |
733 | iface->get_default_attributes = ctk_text_cell_accessible_get_default_attributes; |
734 | iface->get_character_extents = ctk_text_cell_accessible_get_character_extents; |
735 | iface->get_offset_at_point = ctk_text_cell_accessible_get_offset_at_point; |
736 | } |