File: | ctk/ctkcelllayout.c |
Warning: | line 966, column 22 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* ctkcelllayout.c |
2 | * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library 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 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | /** |
19 | * SECTION:ctkcelllayout |
20 | * @Short_Description: An interface for packing cells |
21 | * @Title: CtkCellLayout |
22 | * |
23 | * #CtkCellLayout is an interface to be implemented by all objects which |
24 | * want to provide a #CtkTreeViewColumn like API for packing cells, |
25 | * setting attributes and data funcs. |
26 | * |
27 | * One of the notable features provided by implementations of |
28 | * CtkCellLayout are attributes. Attributes let you set the properties |
29 | * in flexible ways. They can just be set to constant values like regular |
30 | * properties. But they can also be mapped to a column of the underlying |
31 | * tree model with ctk_cell_layout_set_attributes(), which means that the value |
32 | * of the attribute can change from cell to cell as they are rendered by |
33 | * the cell renderer. Finally, it is possible to specify a function with |
34 | * ctk_cell_layout_set_cell_data_func() that is called to determine the |
35 | * value of the attribute for each cell that is rendered. |
36 | * |
37 | * # CtkCellLayouts as CtkBuildable |
38 | * |
39 | * Implementations of CtkCellLayout which also implement the CtkBuildable |
40 | * interface (#CtkCellView, #CtkIconView, #CtkComboBox, |
41 | * #CtkEntryCompletion, #CtkTreeViewColumn) accept CtkCellRenderer objects |
42 | * as <child> elements in UI definitions. They support a custom <attributes> |
43 | * element for their children, which can contain multiple <attribute> |
44 | * elements. Each <attribute> element has a name attribute which specifies |
45 | * a property of the cell renderer; the content of the element is the |
46 | * attribute value. |
47 | * |
48 | * This is an example of a UI definition fragment specifying attributes: |
49 | * |[ |
50 | * <object class="CtkCellView"> |
51 | * <child> |
52 | * <object class="CtkCellRendererText"/> |
53 | * <attributes> |
54 | * <attribute name="text">0</attribute> |
55 | * </attributes> |
56 | * </child>" |
57 | * </object> |
58 | * ]| |
59 | * |
60 | * Furthermore for implementations of CtkCellLayout that use a #CtkCellArea |
61 | * to lay out cells (all CtkCellLayouts in CTK+ use a CtkCellArea) |
62 | * [cell properties][cell-properties] can also be defined in the format by |
63 | * specifying the custom <cell-packing> attribute which can contain multiple |
64 | * <property> elements defined in the normal way. |
65 | * |
66 | * Here is a UI definition fragment specifying cell properties: |
67 | * |
68 | * |[ |
69 | * <object class="CtkTreeViewColumn"> |
70 | * <child> |
71 | * <object class="CtkCellRendererText"/> |
72 | * <cell-packing> |
73 | * <property name="align">True</property> |
74 | * <property name="expand">False</property> |
75 | * </cell-packing> |
76 | * </child>" |
77 | * </object> |
78 | * ]| |
79 | * |
80 | * # Subclassing CtkCellLayout implementations |
81 | * |
82 | * When subclassing a widget that implements #CtkCellLayout like |
83 | * #CtkIconView or #CtkComboBox, there are some considerations related |
84 | * to the fact that these widgets internally use a #CtkCellArea. |
85 | * The cell area is exposed as a construct-only property by these |
86 | * widgets. This means that it is possible to e.g. do |
87 | * |
88 | * |[<!-- language="C" --> |
89 | * combo = g_object_new (CTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL); |
90 | * ]| |
91 | * |
92 | * to use a custom cell area with a combo box. But construct properties |
93 | * are only initialized after instance init() |
94 | * functions have run, which means that using functions which rely on |
95 | * the existence of the cell area in your subclass’ init() function will |
96 | * cause the default cell area to be instantiated. In this case, a provided |
97 | * construct property value will be ignored (with a warning, to alert |
98 | * you to the problem). |
99 | * |
100 | * |[<!-- language="C" --> |
101 | * static void |
102 | * my_combo_box_init (MyComboBox *b) |
103 | * { |
104 | * CtkCellRenderer *cell; |
105 | * |
106 | * cell = ctk_cell_renderer_pixbuf_new (); |
107 | * // The following call causes the default cell area for combo boxes, |
108 | * // a CtkCellAreaBox, to be instantiated |
109 | * ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (b), cell, FALSE); |
110 | * ... |
111 | * } |
112 | * |
113 | * CtkWidget * |
114 | * my_combo_box_new (CtkCellArea *area) |
115 | * { |
116 | * // This call is going to cause a warning about area being ignored |
117 | * return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL); |
118 | * } |
119 | * ]| |
120 | * |
121 | * If supporting alternative cell areas with your derived widget is |
122 | * not important, then this does not have to concern you. If you want |
123 | * to support alternative cell areas, you can do so by moving the |
124 | * problematic calls out of init() and into a constructor() |
125 | * for your class. |
126 | */ |
127 | |
128 | #include "config.h" |
129 | #include <string.h> |
130 | #include <stdlib.h> |
131 | #include <errno(*__errno_location ()).h> |
132 | #include "ctkcelllayout.h" |
133 | #include "ctkbuilderprivate.h" |
134 | #include "ctkintl.h" |
135 | |
136 | #define warn_no_cell_area(func)g_critical ("%s: Called but no CtkCellArea is available yet", func) \ |
137 | g_critical ("%s: Called but no CtkCellArea is available yet", func) |
138 | |
139 | typedef CtkCellLayoutIface CtkCellLayoutInterface; |
140 | G_DEFINE_INTERFACE (CtkCellLayout, ctk_cell_layout, G_TYPE_OBJECT)static void ctk_cell_layout_default_init (CtkCellLayoutInterface *klass); GType ctk_cell_layout_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 = g_type_register_static_simple (((GType) ((2) << (2)) ), g_intern_static_string ("CtkCellLayout"), sizeof (CtkCellLayoutInterface ), (GClassInitFunc)(void (*)(void)) ctk_cell_layout_default_init , 0, (GInstanceInitFunc)((void*)0), (GTypeFlags) 0); if (((GType ) ((20) << (2))) != ((GType) ((0) << (2)))) g_type_interface_add_prerequisite (g_define_type_id, ((GType) ((20) << (2)))); { {;;} } ( __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 ; }; |
141 | |
142 | static void ctk_cell_layout_default_pack_start (CtkCellLayout *cell_layout, |
143 | CtkCellRenderer *cell, |
144 | gboolean expand); |
145 | static void ctk_cell_layout_default_pack_end (CtkCellLayout *cell_layout, |
146 | CtkCellRenderer *cell, |
147 | gboolean expand); |
148 | static void ctk_cell_layout_default_clear (CtkCellLayout *cell_layout); |
149 | static void ctk_cell_layout_default_add_attribute (CtkCellLayout *cell_layout, |
150 | CtkCellRenderer *cell, |
151 | const gchar *attribute, |
152 | gint column); |
153 | static void ctk_cell_layout_default_set_cell_data_func (CtkCellLayout *cell_layout, |
154 | CtkCellRenderer *cell, |
155 | CtkCellLayoutDataFunc func, |
156 | gpointer func_data, |
157 | GDestroyNotify destroy); |
158 | static void ctk_cell_layout_default_clear_attributes (CtkCellLayout *cell_layout, |
159 | CtkCellRenderer *cell); |
160 | static void ctk_cell_layout_default_reorder (CtkCellLayout *cell_layout, |
161 | CtkCellRenderer *cell, |
162 | gint position); |
163 | static GList *ctk_cell_layout_default_get_cells (CtkCellLayout *cell_layout); |
164 | |
165 | |
166 | static void |
167 | ctk_cell_layout_default_init (CtkCellLayoutIface *iface) |
168 | { |
169 | iface->pack_start = ctk_cell_layout_default_pack_start; |
170 | iface->pack_end = ctk_cell_layout_default_pack_end; |
171 | iface->clear = ctk_cell_layout_default_clear; |
172 | iface->add_attribute = ctk_cell_layout_default_add_attribute; |
173 | iface->set_cell_data_func = ctk_cell_layout_default_set_cell_data_func; |
174 | iface->clear_attributes = ctk_cell_layout_default_clear_attributes; |
175 | iface->reorder = ctk_cell_layout_default_reorder; |
176 | iface->get_cells = ctk_cell_layout_default_get_cells; |
177 | } |
178 | |
179 | /* Default implementation is to fall back on an underlying cell area */ |
180 | static void |
181 | ctk_cell_layout_default_pack_start (CtkCellLayout *cell_layout, |
182 | CtkCellRenderer *cell, |
183 | gboolean expand) |
184 | { |
185 | CtkCellLayoutIface *iface; |
186 | |
187 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
188 | |
189 | if (iface->get_area) |
190 | { |
191 | CtkCellArea *area; |
192 | |
193 | area = iface->get_area (cell_layout); |
194 | |
195 | if (area) |
196 | ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ())))))), cell, expand); |
197 | else |
198 | warn_no_cell_area ("CtkCellLayoutIface->pack_start()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->pack_start()"); |
199 | } |
200 | } |
201 | |
202 | static void |
203 | ctk_cell_layout_default_pack_end (CtkCellLayout *cell_layout, |
204 | CtkCellRenderer *cell, |
205 | gboolean expand) |
206 | { |
207 | CtkCellLayoutIface *iface; |
208 | |
209 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
210 | |
211 | if (iface->get_area) |
212 | { |
213 | CtkCellArea *area; |
214 | |
215 | area = iface->get_area (cell_layout); |
216 | |
217 | if (area) |
218 | ctk_cell_layout_pack_end (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ())))))), cell, expand); |
219 | else |
220 | warn_no_cell_area ("CtkCellLayoutIface->pack_end()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->pack_end()"); |
221 | } |
222 | } |
223 | |
224 | static void |
225 | ctk_cell_layout_default_clear (CtkCellLayout *cell_layout) |
226 | { |
227 | CtkCellLayoutIface *iface; |
228 | |
229 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
230 | |
231 | if (iface->get_area) |
232 | { |
233 | CtkCellArea *area; |
234 | |
235 | area = iface->get_area (cell_layout); |
236 | |
237 | if (area) |
238 | ctk_cell_layout_clear (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ()))))))); |
239 | else |
240 | warn_no_cell_area ("CtkCellLayoutIface->clear()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->clear()"); |
241 | } |
242 | } |
243 | |
244 | static void |
245 | ctk_cell_layout_default_add_attribute (CtkCellLayout *cell_layout, |
246 | CtkCellRenderer *cell, |
247 | const gchar *attribute, |
248 | gint column) |
249 | { |
250 | CtkCellLayoutIface *iface; |
251 | |
252 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
253 | |
254 | if (iface->get_area) |
255 | { |
256 | CtkCellArea *area; |
257 | |
258 | area = iface->get_area (cell_layout); |
259 | |
260 | if (area) |
261 | ctk_cell_layout_add_attribute (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ())))))), cell, attribute, column); |
262 | else |
263 | warn_no_cell_area ("CtkCellLayoutIface->add_attribute()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->add_attribute()"); |
264 | } |
265 | } |
266 | |
267 | static void |
268 | ctk_cell_layout_default_set_cell_data_func (CtkCellLayout *cell_layout, |
269 | CtkCellRenderer *cell, |
270 | CtkCellLayoutDataFunc func, |
271 | gpointer func_data, |
272 | GDestroyNotify destroy) |
273 | { |
274 | CtkCellLayoutIface *iface; |
275 | |
276 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
277 | |
278 | if (iface->get_area) |
279 | { |
280 | CtkCellArea *area; |
281 | |
282 | area = iface->get_area (cell_layout); |
283 | |
284 | if (area) |
285 | _ctk_cell_area_set_cell_data_func_with_proxy (area, cell, |
286 | (GFunc)func, func_data, destroy, |
287 | cell_layout); |
288 | else |
289 | warn_no_cell_area ("CtkCellLayoutIface->set_cell_data_func()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->set_cell_data_func()"); |
290 | } |
291 | } |
292 | |
293 | static void |
294 | ctk_cell_layout_default_clear_attributes (CtkCellLayout *cell_layout, |
295 | CtkCellRenderer *cell) |
296 | { |
297 | CtkCellLayoutIface *iface; |
298 | |
299 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
300 | |
301 | if (iface->get_area) |
302 | { |
303 | CtkCellArea *area; |
304 | |
305 | area = iface->get_area (cell_layout); |
306 | |
307 | if (area) |
308 | ctk_cell_layout_clear_attributes (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ())))))), cell); |
309 | else |
310 | warn_no_cell_area ("CtkCellLayoutIface->clear_attributes()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->clear_attributes()"); |
311 | } |
312 | } |
313 | |
314 | static void |
315 | ctk_cell_layout_default_reorder (CtkCellLayout *cell_layout, |
316 | CtkCellRenderer *cell, |
317 | gint position) |
318 | { |
319 | CtkCellLayoutIface *iface; |
320 | |
321 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
322 | |
323 | if (iface->get_area) |
324 | { |
325 | CtkCellArea *area; |
326 | |
327 | area = iface->get_area (cell_layout); |
328 | |
329 | if (area) |
330 | ctk_cell_layout_reorder (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ())))))), cell, position); |
331 | else |
332 | warn_no_cell_area ("CtkCellLayoutIface->reorder()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->reorder()"); |
333 | } |
334 | } |
335 | |
336 | static GList * |
337 | ctk_cell_layout_default_get_cells (CtkCellLayout *cell_layout) |
338 | { |
339 | CtkCellLayoutIface *iface; |
340 | |
341 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
342 | |
343 | if (iface->get_area) |
344 | { |
345 | CtkCellArea *area; |
346 | |
347 | area = iface->get_area (cell_layout); |
348 | |
349 | if (area) |
350 | return ctk_cell_layout_get_cells (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ()))))))); |
351 | else |
352 | warn_no_cell_area ("CtkCellLayoutIface->get_cells()")g_critical ("%s: Called but no CtkCellArea is available yet", "CtkCellLayoutIface->get_cells()"); |
353 | } |
354 | return NULL((void*)0); |
355 | } |
356 | |
357 | |
358 | /** |
359 | * ctk_cell_layout_pack_start: |
360 | * @cell_layout: a #CtkCellLayout |
361 | * @cell: a #CtkCellRenderer |
362 | * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout |
363 | * |
364 | * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE, |
365 | * then the @cell is allocated no more space than it needs. Any unused space |
366 | * is divided evenly between cells for which @expand is %TRUE. |
367 | * |
368 | * Note that reusing the same cell renderer is not supported. |
369 | * |
370 | * Since: 2.4 |
371 | */ |
372 | void |
373 | ctk_cell_layout_pack_start (CtkCellLayout *cell_layout, |
374 | CtkCellRenderer *cell, |
375 | gboolean expand) |
376 | { |
377 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
378 | g_return_if_fail (CTK_IS_CELL_RENDERER (cell))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell)); GType __t = ((ctk_cell_renderer_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_RENDERER (cell)"); return; } } while (0); |
379 | |
380 | CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->pack_start (cell_layout, cell, expand); |
381 | } |
382 | |
383 | /** |
384 | * ctk_cell_layout_pack_end: |
385 | * @cell_layout: a #CtkCellLayout |
386 | * @cell: a #CtkCellRenderer |
387 | * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout |
388 | * |
389 | * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the |
390 | * @cell is allocated no more space than it needs. Any unused space is |
391 | * divided evenly between cells for which @expand is %TRUE. |
392 | * |
393 | * Note that reusing the same cell renderer is not supported. |
394 | * |
395 | * Since: 2.4 |
396 | */ |
397 | void |
398 | ctk_cell_layout_pack_end (CtkCellLayout *cell_layout, |
399 | CtkCellRenderer *cell, |
400 | gboolean expand) |
401 | { |
402 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
403 | g_return_if_fail (CTK_IS_CELL_RENDERER (cell))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell)); GType __t = ((ctk_cell_renderer_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_RENDERER (cell)"); return; } } while (0); |
404 | |
405 | CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->pack_end (cell_layout, cell, expand); |
406 | } |
407 | |
408 | /** |
409 | * ctk_cell_layout_clear: |
410 | * @cell_layout: a #CtkCellLayout |
411 | * |
412 | * Unsets all the mappings on all renderers on @cell_layout and |
413 | * removes all renderers from @cell_layout. |
414 | * |
415 | * Since: 2.4 |
416 | */ |
417 | void |
418 | ctk_cell_layout_clear (CtkCellLayout *cell_layout) |
419 | { |
420 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
421 | |
422 | CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->clear (cell_layout); |
423 | } |
424 | |
425 | static void |
426 | ctk_cell_layout_set_attributesv (CtkCellLayout *cell_layout, |
427 | CtkCellRenderer *cell, |
428 | va_list args) |
429 | { |
430 | gchar *attribute; |
431 | gint column; |
432 | |
433 | attribute = va_arg (args, gchar *)__builtin_va_arg(args, gchar *); |
434 | |
435 | ctk_cell_layout_clear_attributes (cell_layout, cell); |
436 | |
437 | while (attribute != NULL((void*)0)) |
438 | { |
439 | column = va_arg (args, gint)__builtin_va_arg(args, gint); |
440 | |
441 | ctk_cell_layout_add_attribute (cell_layout, cell, attribute, column); |
442 | |
443 | attribute = va_arg (args, gchar *)__builtin_va_arg(args, gchar *); |
444 | } |
445 | } |
446 | |
447 | /** |
448 | * ctk_cell_layout_set_attributes: |
449 | * @cell_layout: a #CtkCellLayout |
450 | * @cell: a #CtkCellRenderer |
451 | * @...: a %NULL-terminated list of attributes |
452 | * |
453 | * Sets the attributes in list as the attributes of @cell_layout. |
454 | * |
455 | * The attributes should be in attribute/column order, as in |
456 | * ctk_cell_layout_add_attribute(). All existing attributes are |
457 | * removed, and replaced with the new attributes. |
458 | * |
459 | * Since: 2.4 |
460 | */ |
461 | void |
462 | ctk_cell_layout_set_attributes (CtkCellLayout *cell_layout, |
463 | CtkCellRenderer *cell, |
464 | ...) |
465 | { |
466 | va_list args; |
467 | |
468 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
469 | g_return_if_fail (CTK_IS_CELL_RENDERER (cell))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell)); GType __t = ((ctk_cell_renderer_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_RENDERER (cell)"); return; } } while (0); |
470 | |
471 | va_start (args, cell)__builtin_va_start(args, cell); |
472 | ctk_cell_layout_set_attributesv (cell_layout, cell, args); |
473 | va_end (args)__builtin_va_end(args); |
474 | } |
475 | |
476 | /** |
477 | * ctk_cell_layout_add_attribute: |
478 | * @cell_layout: a #CtkCellLayout |
479 | * @cell: a #CtkCellRenderer |
480 | * @attribute: an attribute on the renderer |
481 | * @column: the column position on the model to get the attribute from |
482 | * |
483 | * Adds an attribute mapping to the list in @cell_layout. |
484 | * |
485 | * The @column is the column of the model to get a value from, and the |
486 | * @attribute is the parameter on @cell to be set from the value. So for |
487 | * example if column 2 of the model contains strings, you could have the |
488 | * “text” attribute of a #CtkCellRendererText get its values from column 2. |
489 | * |
490 | * Since: 2.4 |
491 | */ |
492 | void |
493 | ctk_cell_layout_add_attribute (CtkCellLayout *cell_layout, |
494 | CtkCellRenderer *cell, |
495 | const gchar *attribute, |
496 | gint column) |
497 | { |
498 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
499 | g_return_if_fail (CTK_IS_CELL_RENDERER (cell))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell)); GType __t = ((ctk_cell_renderer_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_RENDERER (cell)"); return; } } while (0); |
500 | g_return_if_fail (attribute != NULL)do { if ((attribute != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "attribute != NULL"); return ; } } while (0); |
501 | g_return_if_fail (column >= 0)do { if ((column >= 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "column >= 0"); return ; } } while (0); |
502 | |
503 | CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->add_attribute (cell_layout, cell, attribute, column); |
504 | } |
505 | |
506 | /** |
507 | * ctk_cell_layout_set_cell_data_func: |
508 | * @cell_layout: a #CtkCellLayout |
509 | * @cell: a #CtkCellRenderer |
510 | * @func: (allow-none): the #CtkCellLayoutDataFunc to use, or %NULL |
511 | * @func_data: (closure): user data for @func |
512 | * @destroy: destroy notify for @func_data |
513 | * |
514 | * Sets the #CtkCellLayoutDataFunc to use for @cell_layout. |
515 | * |
516 | * This function is used instead of the standard attributes mapping |
517 | * for setting the column value, and should set the value of @cell_layout’s |
518 | * cell renderer(s) as appropriate. |
519 | * |
520 | * @func may be %NULL to remove a previously set function. |
521 | * |
522 | * Since: 2.4 |
523 | */ |
524 | void |
525 | ctk_cell_layout_set_cell_data_func (CtkCellLayout *cell_layout, |
526 | CtkCellRenderer *cell, |
527 | CtkCellLayoutDataFunc func, |
528 | gpointer func_data, |
529 | GDestroyNotify destroy) |
530 | { |
531 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
532 | g_return_if_fail (CTK_IS_CELL_RENDERER (cell))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell)); GType __t = ((ctk_cell_renderer_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_RENDERER (cell)"); return; } } while (0); |
533 | |
534 | CTK_CELL_LAYOUT_GET_IFACE((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))) |
535 | (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->set_cell_data_func (cell_layout, cell, func, func_data, destroy); |
536 | } |
537 | |
538 | /** |
539 | * ctk_cell_layout_clear_attributes: |
540 | * @cell_layout: a #CtkCellLayout |
541 | * @cell: a #CtkCellRenderer to clear the attribute mapping on |
542 | * |
543 | * Clears all existing attributes previously set with |
544 | * ctk_cell_layout_set_attributes(). |
545 | * |
546 | * Since: 2.4 |
547 | */ |
548 | void |
549 | ctk_cell_layout_clear_attributes (CtkCellLayout *cell_layout, |
550 | CtkCellRenderer *cell) |
551 | { |
552 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
553 | g_return_if_fail (CTK_IS_CELL_RENDERER (cell))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell)); GType __t = ((ctk_cell_renderer_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_RENDERER (cell)"); return; } } while (0); |
554 | |
555 | CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->clear_attributes (cell_layout, cell); |
556 | } |
557 | |
558 | /** |
559 | * ctk_cell_layout_reorder: |
560 | * @cell_layout: a #CtkCellLayout |
561 | * @cell: a #CtkCellRenderer to reorder |
562 | * @position: new position to insert @cell at |
563 | * |
564 | * Re-inserts @cell at @position. |
565 | * |
566 | * Note that @cell has already to be packed into @cell_layout |
567 | * for this to function properly. |
568 | * |
569 | * Since: 2.4 |
570 | */ |
571 | void |
572 | ctk_cell_layout_reorder (CtkCellLayout *cell_layout, |
573 | CtkCellRenderer *cell, |
574 | gint position) |
575 | { |
576 | g_return_if_fail (CTK_IS_CELL_LAYOUT (cell_layout))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return ; } } while (0); |
577 | g_return_if_fail (CTK_IS_CELL_RENDERER (cell))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell)); GType __t = ((ctk_cell_renderer_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_RENDERER (cell)"); return; } } while (0); |
578 | |
579 | CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->reorder (cell_layout, cell, position); |
580 | } |
581 | |
582 | /** |
583 | * ctk_cell_layout_get_cells: |
584 | * @cell_layout: a #CtkCellLayout |
585 | * |
586 | * Returns the cell renderers which have been added to @cell_layout. |
587 | * |
588 | * Returns: (element-type CtkCellRenderer) (transfer container): |
589 | * a list of cell renderers. The list, but not the renderers has |
590 | * been newly allocated and should be freed with g_list_free() |
591 | * when no longer needed. |
592 | * |
593 | * Since: 2.12 |
594 | */ |
595 | GList * |
596 | ctk_cell_layout_get_cells (CtkCellLayout *cell_layout) |
597 | { |
598 | g_return_val_if_fail (CTK_IS_CELL_LAYOUT (cell_layout), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return (((void*)0)); } } while (0); |
599 | |
600 | return CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( )))))))->get_cells (cell_layout); |
601 | } |
602 | |
603 | /** |
604 | * ctk_cell_layout_get_area: |
605 | * @cell_layout: a #CtkCellLayout |
606 | * |
607 | * Returns the underlying #CtkCellArea which might be @cell_layout |
608 | * if called on a #CtkCellArea or might be %NULL if no #CtkCellArea |
609 | * is used by @cell_layout. |
610 | * |
611 | * Returns: (transfer none) (nullable): the cell area used by @cell_layout, |
612 | * or %NULL in case no cell area is used. |
613 | * |
614 | * Since: 3.0 |
615 | */ |
616 | CtkCellArea * |
617 | ctk_cell_layout_get_area (CtkCellLayout *cell_layout) |
618 | { |
619 | CtkCellLayoutIface *iface; |
620 | |
621 | g_return_val_if_fail (CTK_IS_CELL_LAYOUT (cell_layout), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((cell_layout)); GType __t = ((ctk_cell_layout_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_LAYOUT (cell_layout)"); return (((void*)0)); } } while (0); |
622 | |
623 | iface = CTK_CELL_LAYOUT_GET_IFACE (cell_layout)((((CtkCellLayoutIface*) g_type_interface_peek (((GTypeInstance *) ((cell_layout)))->g_class, ((ctk_cell_layout_get_type ( ))))))); |
624 | if (iface->get_area) |
625 | return iface->get_area (cell_layout); |
626 | |
627 | return NULL((void*)0); |
628 | } |
629 | |
630 | /* Attribute parsing */ |
631 | typedef struct { |
632 | CtkCellLayout *cell_layout; |
633 | CtkCellRenderer *renderer; |
634 | CtkBuilder *builder; |
635 | gchar *attr_name; |
636 | GString *string; |
637 | } AttributesSubParserData; |
638 | |
639 | static void |
640 | attributes_start_element (GMarkupParseContext *context, |
641 | const gchar *element_name, |
642 | const gchar **names, |
643 | const gchar **values, |
644 | gpointer user_data, |
645 | GError **error) |
646 | { |
647 | AttributesSubParserData *data = (AttributesSubParserData*)user_data; |
648 | |
649 | if (strcmp (element_name, "attribute") == 0) |
650 | { |
651 | const gchar *name; |
652 | |
653 | if (!_ctk_builder_check_parent (data->builder, context, "attributes", error)) |
654 | return; |
655 | |
656 | if (!g_markup_collect_attributes (element_name, names, values, error, |
657 | G_MARKUP_COLLECT_STRING, "name", &name, |
658 | G_MARKUP_COLLECT_INVALID)) |
659 | { |
660 | _ctk_builder_prefix_error (data->builder, context, error); |
661 | return; |
662 | } |
663 | |
664 | data->attr_name = g_strdup (name)g_strdup_inline (name); |
665 | } |
666 | else if (strcmp (element_name, "attributes") == 0) |
667 | { |
668 | if (!_ctk_builder_check_parent (data->builder, context, "child", error)) |
669 | return; |
670 | |
671 | if (!g_markup_collect_attributes (element_name, names, values, error, |
672 | G_MARKUP_COLLECT_INVALID, NULL((void*)0), NULL((void*)0), |
673 | G_MARKUP_COLLECT_INVALID)) |
674 | _ctk_builder_prefix_error (data->builder, context, error); |
675 | } |
676 | else |
677 | { |
678 | _ctk_builder_error_unhandled_tag (data->builder, context, |
679 | "CtkCellLayout", element_name, |
680 | error); |
681 | } |
682 | } |
683 | |
684 | static void |
685 | attributes_text_element (GMarkupParseContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
686 | const gchar *text, |
687 | gsize text_len, |
688 | gpointer user_data, |
689 | GError **error G_GNUC_UNUSED__attribute__ ((__unused__))) |
690 | { |
691 | AttributesSubParserData *data = (AttributesSubParserData*)user_data; |
692 | |
693 | if (data->attr_name) |
694 | g_string_append_len (data->string, text, text_len)g_string_append_len_inline (data->string, text, text_len); |
695 | } |
696 | |
697 | static void |
698 | attributes_end_element (GMarkupParseContext *context, |
699 | const gchar *element_name G_GNUC_UNUSED__attribute__ ((__unused__)), |
700 | gpointer user_data, |
701 | GError **error) |
702 | { |
703 | AttributesSubParserData *data = (AttributesSubParserData*)user_data; |
704 | GValue val = G_VALUE_INIT{ 0, { { 0 } } }; |
705 | |
706 | if (!data->attr_name) |
707 | return; |
708 | |
709 | if (!ctk_builder_value_from_string_type (data->builder, G_TYPE_INT((GType) ((6) << (2))), data->string->str, &val, error)) |
710 | { |
711 | _ctk_builder_prefix_error (data->builder, context, error); |
712 | return; |
713 | } |
714 | |
715 | ctk_cell_layout_add_attribute (data->cell_layout, |
716 | data->renderer, |
717 | data->attr_name, |
718 | g_value_get_int (&val)); |
719 | |
720 | g_free (data->attr_name); |
721 | data->attr_name = NULL((void*)0); |
722 | |
723 | g_string_set_size (data->string, 0); |
724 | } |
725 | |
726 | static const GMarkupParser attributes_parser = |
727 | { |
728 | .start_element = attributes_start_element, |
729 | .end_element = attributes_end_element, |
730 | .text = attributes_text_element |
731 | }; |
732 | |
733 | |
734 | /* Cell packing parsing */ |
735 | static void |
736 | ctk_cell_layout_buildable_set_cell_property (CtkCellArea *area, |
737 | CtkBuilder *builder, |
738 | CtkCellRenderer *cell, |
739 | gchar *name, |
740 | const gchar *value) |
741 | { |
742 | GParamSpec *pspec; |
743 | GValue gvalue = G_VALUE_INIT{ 0, { { 0 } } }; |
744 | GError *error = NULL((void*)0); |
745 | |
746 | pspec = ctk_cell_area_class_find_cell_property (CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class )))), name); |
747 | if (!pspec) |
748 | { |
749 | g_warning ("%s does not have a property called %s", |
750 | g_type_name (G_OBJECT_TYPE (area)(((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))), name); |
751 | return; |
752 | } |
753 | |
754 | if (!ctk_builder_value_from_string (builder, pspec, value, &gvalue, &error)) |
755 | { |
756 | g_warning ("Could not read property %s:%s with value %s of type %s: %s", |
757 | g_type_name (G_OBJECT_TYPE (area)(((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))), |
758 | name, |
759 | value, |
760 | g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type )), |
761 | error->message); |
762 | g_error_free (error); |
763 | return; |
764 | } |
765 | |
766 | ctk_cell_area_cell_set_property (area, cell, name, &gvalue); |
767 | g_value_unset (&gvalue); |
768 | } |
769 | |
770 | typedef struct { |
771 | CtkBuilder *builder; |
772 | CtkCellLayout *cell_layout; |
773 | CtkCellRenderer *renderer; |
774 | GString *string; |
775 | gchar *cell_prop_name; |
776 | gchar *context; |
777 | gboolean translatable; |
778 | } CellPackingSubParserData; |
779 | |
780 | static void |
781 | cell_packing_start_element (GMarkupParseContext *context, |
782 | const gchar *element_name, |
783 | const gchar **names, |
784 | const gchar **values, |
785 | gpointer user_data, |
786 | GError **error) |
787 | { |
788 | CellPackingSubParserData *data = (CellPackingSubParserData*)user_data; |
789 | |
790 | if (strcmp (element_name, "property") == 0) |
791 | { |
792 | const gchar *name; |
793 | gboolean translatable = FALSE(0); |
794 | const gchar *ctx = NULL((void*)0); |
795 | |
796 | if (!_ctk_builder_check_parent (data->builder, context, "cell-packing", error)) |
797 | return; |
798 | |
799 | if (!g_markup_collect_attributes (element_name, names, values, error, |
800 | G_MARKUP_COLLECT_STRING, "name", &name, |
801 | G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable", &translatable, |
802 | G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "comments", NULL((void*)0), |
803 | G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &ctx, |
804 | G_MARKUP_COLLECT_INVALID)) |
805 | { |
806 | _ctk_builder_prefix_error (data->builder, context, error); |
807 | return; |
808 | } |
809 | |
810 | data->cell_prop_name = g_strdup (name)g_strdup_inline (name); |
811 | data->translatable = translatable; |
812 | data->context = g_strdup (ctx)g_strdup_inline (ctx); |
813 | } |
814 | else if (strcmp (element_name, "cell-packing") == 0) |
815 | { |
816 | if (!_ctk_builder_check_parent (data->builder, context, "child", error)) |
817 | return; |
818 | |
819 | if (!g_markup_collect_attributes (element_name, names, values, error, |
820 | G_MARKUP_COLLECT_INVALID, NULL((void*)0), NULL((void*)0), |
821 | G_MARKUP_COLLECT_INVALID)) |
822 | _ctk_builder_prefix_error (data->builder, context, error); |
823 | } |
824 | else |
825 | { |
826 | _ctk_builder_error_unhandled_tag (data->builder, context, |
827 | "CtkCellLayout", element_name, |
828 | error); |
829 | } |
830 | } |
831 | |
832 | static void |
833 | cell_packing_text_element (GMarkupParseContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
834 | const gchar *text, |
835 | gsize text_len, |
836 | gpointer user_data, |
837 | GError **error G_GNUC_UNUSED__attribute__ ((__unused__))) |
838 | { |
839 | CellPackingSubParserData *data = (CellPackingSubParserData*)user_data; |
840 | |
841 | if (data->cell_prop_name) |
842 | g_string_append_len (data->string, text, text_len)g_string_append_len_inline (data->string, text, text_len); |
843 | } |
844 | |
845 | static void |
846 | cell_packing_end_element (GMarkupParseContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
847 | const gchar *element_name G_GNUC_UNUSED__attribute__ ((__unused__)), |
848 | gpointer user_data, |
849 | GError **error G_GNUC_UNUSED__attribute__ ((__unused__))) |
850 | { |
851 | CellPackingSubParserData *data = (CellPackingSubParserData*)user_data; |
852 | CtkCellArea *area; |
853 | |
854 | area = ctk_cell_layout_get_area (data->cell_layout); |
855 | |
856 | if (area) |
857 | { |
858 | /* translate the string */ |
859 | if (data->string->len && data->translatable) |
860 | { |
861 | const gchar *translated; |
862 | const gchar* domain; |
863 | |
864 | domain = ctk_builder_get_translation_domain (data->builder); |
865 | |
866 | translated = _ctk_builder_parser_translate (domain, |
867 | data->context, |
868 | data->string->str); |
869 | g_string_assign (data->string, translated); |
870 | } |
871 | |
872 | if (data->cell_prop_name) |
873 | ctk_cell_layout_buildable_set_cell_property (area, |
874 | data->builder, |
875 | data->renderer, |
876 | data->cell_prop_name, |
877 | data->string->str); |
878 | } |
879 | else |
880 | g_warning ("%s does not have an internal CtkCellArea class and cannot apply child cell properties", |
881 | g_type_name (G_OBJECT_TYPE (data->cell_layout)(((((GTypeClass*) (((GTypeInstance*) (data->cell_layout))-> g_class))->g_type))))); |
882 | |
883 | g_string_set_size (data->string, 0); |
884 | g_free (data->cell_prop_name); |
885 | g_free (data->context); |
886 | data->cell_prop_name = NULL((void*)0); |
887 | data->context = NULL((void*)0); |
888 | data->translatable = FALSE(0); |
889 | } |
890 | |
891 | |
892 | static const GMarkupParser cell_packing_parser = |
893 | { |
894 | .start_element = cell_packing_start_element, |
895 | .end_element = cell_packing_end_element, |
896 | .text = cell_packing_text_element |
897 | }; |
898 | |
899 | gboolean |
900 | _ctk_cell_layout_buildable_custom_tag_start (CtkBuildable *buildable, |
901 | CtkBuilder *builder, |
902 | GObject *child, |
903 | const gchar *tagname, |
904 | GMarkupParser *parser, |
905 | gpointer *data) |
906 | { |
907 | AttributesSubParserData *attr_data; |
908 | CellPackingSubParserData *packing_data; |
909 | |
910 | if (!child) |
911 | return FALSE(0); |
912 | |
913 | if (strcmp (tagname, "attributes") == 0) |
914 | { |
915 | attr_data = g_slice_new0 (AttributesSubParserData)((AttributesSubParserData*) g_slice_alloc0 (sizeof (AttributesSubParserData ))); |
916 | attr_data->cell_layout = CTK_CELL_LAYOUT (buildable)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_cell_layout_get_type ())))))); |
917 | attr_data->renderer = CTK_CELL_RENDERER (child)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_cell_renderer_get_type ())))))); |
918 | attr_data->builder = builder; |
919 | attr_data->attr_name = NULL((void*)0); |
920 | attr_data->string = g_string_new (""); |
921 | |
922 | *parser = attributes_parser; |
923 | *data = attr_data; |
924 | |
925 | return TRUE(!(0)); |
926 | } |
927 | else if (strcmp (tagname, "cell-packing") == 0) |
928 | { |
929 | packing_data = g_slice_new0 (CellPackingSubParserData)((CellPackingSubParserData*) g_slice_alloc0 (sizeof (CellPackingSubParserData ))); |
930 | packing_data->string = g_string_new (""); |
931 | packing_data->builder = builder; |
932 | packing_data->cell_layout = CTK_CELL_LAYOUT (buildable)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_cell_layout_get_type ())))))); |
933 | packing_data->renderer = CTK_CELL_RENDERER (child)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_cell_renderer_get_type ())))))); |
934 | |
935 | *parser = cell_packing_parser; |
936 | *data = packing_data; |
937 | |
938 | return TRUE(!(0)); |
939 | } |
940 | |
941 | return FALSE(0); |
942 | } |
943 | |
944 | gboolean |
945 | _ctk_cell_layout_buildable_custom_tag_end (CtkBuildable *buildable G_GNUC_UNUSED__attribute__ ((__unused__)), |
946 | CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)), |
947 | GObject *child G_GNUC_UNUSED__attribute__ ((__unused__)), |
948 | const gchar *tagname, |
949 | gpointer *data) |
950 | { |
951 | CellPackingSubParserData *packing_data; |
952 | |
953 | if (strcmp (tagname, "attributes") == 0) |
954 | { |
955 | AttributesSubParserData *attr_data; |
956 | |
957 | attr_data = (AttributesSubParserData*)data; |
958 | g_assert (!attr_data->attr_name)do { if (!attr_data->attr_name) ; else g_assertion_message_expr ("Ctk", "ctkcelllayout.c", 958, ((const char*) (__func__)), "!attr_data->attr_name" ); } while (0); |
959 | g_string_free (attr_data->string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) ( (attr_data->string), ((!(0)))) : g_string_free_and_steal ( attr_data->string)) : (g_string_free) ((attr_data->string ), ((!(0))))); |
960 | g_slice_free (AttributesSubParserData, attr_data)do { if (1) g_slice_free1 (sizeof (AttributesSubParserData), ( attr_data)); else (void) ((AttributesSubParserData*) 0 == (attr_data )); } while (0); |
961 | |
962 | return TRUE(!(0)); |
963 | } |
964 | else if (strcmp (tagname, "cell-packing") == 0) |
965 | { |
966 | packing_data = (CellPackingSubParserData *)data; |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
967 | g_string_free (packing_data->string, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) ( (packing_data->string), ((!(0)))) : g_string_free_and_steal (packing_data->string)) : (g_string_free) ((packing_data-> string), ((!(0))))); |
968 | g_slice_free (CellPackingSubParserData, packing_data)do { if (1) g_slice_free1 (sizeof (CellPackingSubParserData), (packing_data)); else (void) ((CellPackingSubParserData*) 0 == (packing_data)); } while (0); |
969 | |
970 | return TRUE(!(0)); |
971 | } |
972 | return FALSE(0); |
973 | } |
974 | |
975 | void |
976 | _ctk_cell_layout_buildable_add_child (CtkBuildable *buildable, |
977 | CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)), |
978 | GObject *child, |
979 | const gchar *type G_GNUC_UNUSED__attribute__ ((__unused__))) |
980 | { |
981 | g_return_if_fail (CTK_IS_CELL_LAYOUT (buildable))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((buildable)); GType __t = ((ctk_cell_layout_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_LAYOUT (buildable)"); return; } } while (0); |
982 | g_return_if_fail (CTK_IS_CELL_RENDERER (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); GType __t = ((ctk_cell_renderer_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_RENDERER (child)"); return; } } while (0); |
983 | |
984 | ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (buildable)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_cell_layout_get_type ())))))), CTK_CELL_RENDERER (child)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_cell_renderer_get_type ())))))), FALSE(0)); |
985 | } |