File: | ctk/ctkcellarea.c |
Warning: | line 3066, column 5 Value stored to 'siblings' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* ctkcellarea.c |
2 | * |
3 | * Copyright (C) 2010 Openismus GmbH |
4 | * |
5 | * Authors: |
6 | * Tristan Van Berkom <tristanvb@openismus.com> |
7 | * |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; either |
11 | * version 2 of the License, or (at your option) any later version. |
12 | * |
13 | * This library is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Library General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Library General Public |
19 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | /** |
23 | * SECTION:ctkcellarea |
24 | * @Short_Description: An abstract class for laying out CtkCellRenderers |
25 | * @Title: CtkCellArea |
26 | * |
27 | * The #CtkCellArea is an abstract class for #CtkCellLayout widgets |
28 | * (also referred to as "layouting widgets") to interface with an |
29 | * arbitrary number of #CtkCellRenderers and interact with the user |
30 | * for a given #CtkTreeModel row. |
31 | * |
32 | * The cell area handles events, focus navigation, drawing and |
33 | * size requests and allocations for a given row of data. |
34 | * |
35 | * Usually users dont have to interact with the #CtkCellArea directly |
36 | * unless they are implementing a cell-layouting widget themselves. |
37 | * |
38 | * # Requesting area sizes |
39 | * |
40 | * As outlined in |
41 | * [CtkWidget’s geometry management section][geometry-management], |
42 | * CTK+ uses a height-for-width |
43 | * geometry management system to compute the sizes of widgets and user |
44 | * interfaces. #CtkCellArea uses the same semantics to calculate the |
45 | * size of an area for an arbitrary number of #CtkTreeModel rows. |
46 | * |
47 | * When requesting the size of a cell area one needs to calculate |
48 | * the size for a handful of rows, and this will be done differently by |
49 | * different layouting widgets. For instance a #CtkTreeViewColumn |
50 | * always lines up the areas from top to bottom while a #CtkIconView |
51 | * on the other hand might enforce that all areas received the same |
52 | * width and wrap the areas around, requesting height for more cell |
53 | * areas when allocated less width. |
54 | * |
55 | * It’s also important for areas to maintain some cell |
56 | * alignments with areas rendered for adjacent rows (cells can |
57 | * appear “columnized” inside an area even when the size of |
58 | * cells are different in each row). For this reason the #CtkCellArea |
59 | * uses a #CtkCellAreaContext object to store the alignments |
60 | * and sizes along the way (as well as the overall largest minimum |
61 | * and natural size for all the rows which have been calculated |
62 | * with the said context). |
63 | * |
64 | * The #CtkCellAreaContext is an opaque object specific to the |
65 | * #CtkCellArea which created it (see ctk_cell_area_create_context()). |
66 | * The owning cell-layouting widget can create as many contexts as |
67 | * it wishes to calculate sizes of rows which should receive the |
68 | * same size in at least one orientation (horizontally or vertically), |
69 | * However, it’s important that the same #CtkCellAreaContext which |
70 | * was used to request the sizes for a given #CtkTreeModel row be |
71 | * used when rendering or processing events for that row. |
72 | * |
73 | * In order to request the width of all the rows at the root level |
74 | * of a #CtkTreeModel one would do the following: |
75 | * |
76 | * |[<!-- language="C" --> |
77 | * CtkTreeIter iter; |
78 | * gint minimum_width; |
79 | * gint natural_width; |
80 | * |
81 | * valid = ctk_tree_model_get_iter_first (model, &iter); |
82 | * while (valid) |
83 | * { |
84 | * ctk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE); |
85 | * ctk_cell_area_get_preferred_width (area, context, widget, NULL, NULL); |
86 | * |
87 | * valid = ctk_tree_model_iter_next (model, &iter); |
88 | * } |
89 | * ctk_cell_area_context_get_preferred_width (context, &minimum_width, &natural_width); |
90 | * ]| |
91 | * |
92 | * Note that in this example it’s not important to observe the |
93 | * returned minimum and natural width of the area for each row |
94 | * unless the cell-layouting object is actually interested in the |
95 | * widths of individual rows. The overall width is however stored |
96 | * in the accompanying #CtkCellAreaContext object and can be consulted |
97 | * at any time. |
98 | * |
99 | * This can be useful since #CtkCellLayout widgets usually have to |
100 | * support requesting and rendering rows in treemodels with an |
101 | * exceedingly large amount of rows. The #CtkCellLayout widget in |
102 | * that case would calculate the required width of the rows in an |
103 | * idle or timeout source (see g_timeout_add()) and when the widget |
104 | * is requested its actual width in #CtkWidgetClass.get_preferred_width() |
105 | * it can simply consult the width accumulated so far in the |
106 | * #CtkCellAreaContext object. |
107 | * |
108 | * A simple example where rows are rendered from top to bottom and |
109 | * take up the full width of the layouting widget would look like: |
110 | * |
111 | * |[<!-- language="C" --> |
112 | * static void |
113 | * foo_get_preferred_width (CtkWidget *widget, |
114 | * gint *minimum_size, |
115 | * gint *natural_size) |
116 | * { |
117 | * Foo *foo = FOO (widget); |
118 | * FooPrivate *priv = foo->priv; |
119 | * |
120 | * foo_ensure_at_least_one_handfull_of_rows_have_been_requested (foo); |
121 | * |
122 | * ctk_cell_area_context_get_preferred_width (priv->context, minimum_size, natural_size); |
123 | * } |
124 | * ]| |
125 | * |
126 | * In the above example the Foo widget has to make sure that some |
127 | * row sizes have been calculated (the amount of rows that Foo judged |
128 | * was appropriate to request space for in a single timeout iteration) |
129 | * before simply returning the amount of space required by the area via |
130 | * the #CtkCellAreaContext. |
131 | * |
132 | * Requesting the height for width (or width for height) of an area is |
133 | * a similar task except in this case the #CtkCellAreaContext does not |
134 | * store the data (actually, it does not know how much space the layouting |
135 | * widget plans to allocate it for every row. It’s up to the layouting |
136 | * widget to render each row of data with the appropriate height and |
137 | * width which was requested by the #CtkCellArea). |
138 | * |
139 | * In order to request the height for width of all the rows at the |
140 | * root level of a #CtkTreeModel one would do the following: |
141 | * |
142 | * |[<!-- language="C" --> |
143 | * CtkTreeIter iter; |
144 | * gint minimum_height; |
145 | * gint natural_height; |
146 | * gint full_minimum_height = 0; |
147 | * gint full_natural_height = 0; |
148 | * |
149 | * valid = ctk_tree_model_get_iter_first (model, &iter); |
150 | * while (valid) |
151 | * { |
152 | * ctk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE); |
153 | * ctk_cell_area_get_preferred_height_for_width (area, context, widget, |
154 | * width, &minimum_height, &natural_height); |
155 | * |
156 | * if (width_is_for_allocation) |
157 | * cache_row_height (&iter, minimum_height, natural_height); |
158 | * |
159 | * full_minimum_height += minimum_height; |
160 | * full_natural_height += natural_height; |
161 | * |
162 | * valid = ctk_tree_model_iter_next (model, &iter); |
163 | * } |
164 | * ]| |
165 | * |
166 | * Note that in the above example we would need to cache the heights |
167 | * returned for each row so that we would know what sizes to render the |
168 | * areas for each row. However we would only want to really cache the |
169 | * heights if the request is intended for the layouting widgets real |
170 | * allocation. |
171 | * |
172 | * In some cases the layouting widget is requested the height for an |
173 | * arbitrary for_width, this is a special case for layouting widgets |
174 | * who need to request size for tens of thousands of rows. For this |
175 | * case it’s only important that the layouting widget calculate |
176 | * one reasonably sized chunk of rows and return that height |
177 | * synchronously. The reasoning here is that any layouting widget is |
178 | * at least capable of synchronously calculating enough height to fill |
179 | * the screen height (or scrolled window height) in response to a single |
180 | * call to #CtkWidgetClass.get_preferred_height_for_width(). Returning |
181 | * a perfect height for width that is larger than the screen area is |
182 | * inconsequential since after the layouting receives an allocation |
183 | * from a scrolled window it simply continues to drive the scrollbar |
184 | * values while more and more height is required for the row heights |
185 | * that are calculated in the background. |
186 | * |
187 | * # Rendering Areas |
188 | * |
189 | * Once area sizes have been aquired at least for the rows in the |
190 | * visible area of the layouting widget they can be rendered at |
191 | * #CtkWidgetClass.draw() time. |
192 | * |
193 | * A crude example of how to render all the rows at the root level |
194 | * runs as follows: |
195 | * |
196 | * |[<!-- language="C" --> |
197 | * CtkAllocation allocation; |
198 | * CdkRectangle cell_area = { 0, }; |
199 | * CtkTreeIter iter; |
200 | * gint minimum_width; |
201 | * gint natural_width; |
202 | * |
203 | * ctk_widget_get_allocation (widget, &allocation); |
204 | * cell_area.width = allocation.width; |
205 | * |
206 | * valid = ctk_tree_model_get_iter_first (model, &iter); |
207 | * while (valid) |
208 | * { |
209 | * cell_area.height = get_cached_height_for_row (&iter); |
210 | * |
211 | * ctk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE); |
212 | * ctk_cell_area_render (area, context, widget, cr, |
213 | * &cell_area, &cell_area, state_flags, FALSE); |
214 | * |
215 | * cell_area.y += cell_area.height; |
216 | * |
217 | * valid = ctk_tree_model_iter_next (model, &iter); |
218 | * } |
219 | * ]| |
220 | * |
221 | * Note that the cached height in this example really depends on how |
222 | * the layouting widget works. The layouting widget might decide to |
223 | * give every row its minimum or natural height or, if the model content |
224 | * is expected to fit inside the layouting widget without scrolling, it |
225 | * would make sense to calculate the allocation for each row at |
226 | * #CtkWidget::size-allocate time using ctk_distribute_natural_allocation(). |
227 | * |
228 | * # Handling Events and Driving Keyboard Focus |
229 | * |
230 | * Passing events to the area is as simple as handling events on any |
231 | * normal widget and then passing them to the ctk_cell_area_event() |
232 | * API as they come in. Usually #CtkCellArea is only interested in |
233 | * button events, however some customized derived areas can be implemented |
234 | * who are interested in handling other events. Handling an event can |
235 | * trigger the #CtkCellArea::focus-changed signal to fire; as well as |
236 | * #CtkCellArea::add-editable in the case that an editable cell was |
237 | * clicked and needs to start editing. You can call |
238 | * ctk_cell_area_stop_editing() at any time to cancel any cell editing |
239 | * that is currently in progress. |
240 | * |
241 | * The #CtkCellArea drives keyboard focus from cell to cell in a way |
242 | * similar to #CtkWidget. For layouting widgets that support giving |
243 | * focus to cells it’s important to remember to pass %CTK_CELL_RENDERER_FOCUSED |
244 | * to the area functions for the row that has focus and to tell the |
245 | * area to paint the focus at render time. |
246 | * |
247 | * Layouting widgets that accept focus on cells should implement the |
248 | * #CtkWidgetClass.focus() virtual method. The layouting widget is always |
249 | * responsible for knowing where #CtkTreeModel rows are rendered inside |
250 | * the widget, so at #CtkWidgetClass.focus() time the layouting widget |
251 | * should use the #CtkCellArea methods to navigate focus inside the area |
252 | * and then observe the CtkDirectionType to pass the focus to adjacent |
253 | * rows and areas. |
254 | * |
255 | * A basic example of how the #CtkWidgetClass.focus() virtual method |
256 | * should be implemented: |
257 | * |
258 | * |[<!-- language="C" --> |
259 | * static gboolean |
260 | * foo_focus (CtkWidget *widget, |
261 | * CtkDirectionType direction) |
262 | * { |
263 | * Foo *foo = FOO (widget); |
264 | * FooPrivate *priv = foo->priv; |
265 | * gint focus_row; |
266 | * gboolean have_focus = FALSE; |
267 | * |
268 | * focus_row = priv->focus_row; |
269 | * |
270 | * if (!ctk_widget_has_focus (widget)) |
271 | * ctk_widget_grab_focus (widget); |
272 | * |
273 | * valid = ctk_tree_model_iter_nth_child (priv->model, &iter, NULL, priv->focus_row); |
274 | * while (valid) |
275 | * { |
276 | * ctk_cell_area_apply_attributes (priv->area, priv->model, &iter, FALSE, FALSE); |
277 | * |
278 | * if (ctk_cell_area_focus (priv->area, direction)) |
279 | * { |
280 | * priv->focus_row = focus_row; |
281 | * have_focus = TRUE; |
282 | * break; |
283 | * } |
284 | * else |
285 | * { |
286 | * if (direction == CTK_DIR_RIGHT || |
287 | * direction == CTK_DIR_LEFT) |
288 | * break; |
289 | * else if (direction == CTK_DIR_UP || |
290 | * direction == CTK_DIR_TAB_BACKWARD) |
291 | * { |
292 | * if (focus_row == 0) |
293 | * break; |
294 | * else |
295 | * { |
296 | * focus_row--; |
297 | * valid = ctk_tree_model_iter_nth_child (priv->model, &iter, NULL, focus_row); |
298 | * } |
299 | * } |
300 | * else |
301 | * { |
302 | * if (focus_row == last_row) |
303 | * break; |
304 | * else |
305 | * { |
306 | * focus_row++; |
307 | * valid = ctk_tree_model_iter_next (priv->model, &iter); |
308 | * } |
309 | * } |
310 | * } |
311 | * } |
312 | * return have_focus; |
313 | * } |
314 | * ]| |
315 | * |
316 | * Note that the layouting widget is responsible for matching the |
317 | * CtkDirectionType values to the way it lays out its cells. |
318 | * |
319 | * # Cell Properties |
320 | * |
321 | * The #CtkCellArea introduces cell properties for #CtkCellRenderers |
322 | * in very much the same way that #CtkContainer introduces |
323 | * [child properties][child-properties] |
324 | * for #CtkWidgets. This provides some general interfaces for defining |
325 | * the relationship cell areas have with their cells. For instance in a |
326 | * #CtkCellAreaBox a cell might “expand” and receive extra space when |
327 | * the area is allocated more than its full natural request, or a cell |
328 | * might be configured to “align” with adjacent rows which were requested |
329 | * and rendered with the same #CtkCellAreaContext. |
330 | * |
331 | * Use ctk_cell_area_class_install_cell_property() to install cell |
332 | * properties for a cell area class and ctk_cell_area_class_find_cell_property() |
333 | * or ctk_cell_area_class_list_cell_properties() to get information about |
334 | * existing cell properties. |
335 | * |
336 | * To set the value of a cell property, use ctk_cell_area_cell_set_property(), |
337 | * ctk_cell_area_cell_set() or ctk_cell_area_cell_set_valist(). To obtain |
338 | * the value of a cell property, use ctk_cell_area_cell_get_property(), |
339 | * ctk_cell_area_cell_get() or ctk_cell_area_cell_get_valist(). |
340 | */ |
341 | |
342 | #include "config.h" |
343 | |
344 | #include <stdarg.h> |
345 | #include <string.h> |
346 | #include <stdlib.h> |
347 | |
348 | #include "ctkintl.h" |
349 | #include "ctkcelllayout.h" |
350 | #include "ctkcellarea.h" |
351 | #include "ctkcellareacontext.h" |
352 | #include "ctkmarshalers.h" |
353 | #include "ctkprivate.h" |
354 | #include "ctkrender.h" |
355 | |
356 | #include <gobject/gvaluecollector.h> |
357 | |
358 | |
359 | /* GObjectClass */ |
360 | static void ctk_cell_area_dispose (GObject *object); |
361 | static void ctk_cell_area_finalize (GObject *object); |
362 | static void ctk_cell_area_set_property (GObject *object, |
363 | guint prop_id, |
364 | const GValue *value, |
365 | GParamSpec *pspec); |
366 | static void ctk_cell_area_get_property (GObject *object, |
367 | guint prop_id, |
368 | GValue *value, |
369 | GParamSpec *pspec); |
370 | |
371 | /* CtkCellAreaClass */ |
372 | static void ctk_cell_area_real_add (CtkCellArea *area, |
373 | CtkCellRenderer *renderer); |
374 | static void ctk_cell_area_real_remove (CtkCellArea *area, |
375 | CtkCellRenderer *renderer); |
376 | static void ctk_cell_area_real_foreach (CtkCellArea *area, |
377 | CtkCellCallback callback, |
378 | gpointer callback_data); |
379 | static void ctk_cell_area_real_foreach_alloc (CtkCellArea *area, |
380 | CtkCellAreaContext *context, |
381 | CtkWidget *widget, |
382 | const CdkRectangle *cell_area, |
383 | const CdkRectangle *background_area, |
384 | CtkCellAllocCallback callback, |
385 | gpointer callback_data); |
386 | static gint ctk_cell_area_real_event (CtkCellArea *area, |
387 | CtkCellAreaContext *context, |
388 | CtkWidget *widget, |
389 | CdkEvent *event, |
390 | const CdkRectangle *cell_area, |
391 | CtkCellRendererState flags); |
392 | static void ctk_cell_area_real_render (CtkCellArea *area, |
393 | CtkCellAreaContext *context, |
394 | CtkWidget *widget, |
395 | cairo_t *cr, |
396 | const CdkRectangle *background_area, |
397 | const CdkRectangle *cell_area, |
398 | CtkCellRendererState flags, |
399 | gboolean paint_focus); |
400 | static void ctk_cell_area_real_apply_attributes (CtkCellArea *area, |
401 | CtkTreeModel *tree_model, |
402 | CtkTreeIter *iter, |
403 | gboolean is_expander, |
404 | gboolean is_expanded); |
405 | |
406 | static CtkCellAreaContext *ctk_cell_area_real_create_context (CtkCellArea *area); |
407 | static CtkCellAreaContext *ctk_cell_area_real_copy_context (CtkCellArea *area, |
408 | CtkCellAreaContext *context); |
409 | static CtkSizeRequestMode ctk_cell_area_real_get_request_mode (CtkCellArea *area); |
410 | static void ctk_cell_area_real_get_preferred_width (CtkCellArea *area, |
411 | CtkCellAreaContext *context, |
412 | CtkWidget *widget, |
413 | gint *minimum_width, |
414 | gint *natural_width); |
415 | static void ctk_cell_area_real_get_preferred_height (CtkCellArea *area, |
416 | CtkCellAreaContext *context, |
417 | CtkWidget *widget, |
418 | gint *minimum_height, |
419 | gint *natural_height); |
420 | static void ctk_cell_area_real_get_preferred_height_for_width (CtkCellArea *area, |
421 | CtkCellAreaContext *context, |
422 | CtkWidget *widget, |
423 | gint width, |
424 | gint *minimum_height, |
425 | gint *natural_height); |
426 | static void ctk_cell_area_real_get_preferred_width_for_height (CtkCellArea *area, |
427 | CtkCellAreaContext *context, |
428 | CtkWidget *widget, |
429 | gint height, |
430 | gint *minimum_width, |
431 | gint *natural_width); |
432 | static gboolean ctk_cell_area_real_is_activatable (CtkCellArea *area); |
433 | static gboolean ctk_cell_area_real_activate (CtkCellArea *area, |
434 | CtkCellAreaContext *context, |
435 | CtkWidget *widget, |
436 | const CdkRectangle *cell_area, |
437 | CtkCellRendererState flags, |
438 | gboolean edit_only); |
439 | static gboolean ctk_cell_area_real_focus (CtkCellArea *area, |
440 | CtkDirectionType direction); |
441 | |
442 | /* CtkCellLayoutIface */ |
443 | static void ctk_cell_area_cell_layout_init (CtkCellLayoutIface *iface); |
444 | static void ctk_cell_area_pack_default (CtkCellLayout *cell_layout, |
445 | CtkCellRenderer *renderer, |
446 | gboolean expand); |
447 | static void ctk_cell_area_clear (CtkCellLayout *cell_layout); |
448 | static void ctk_cell_area_add_attribute (CtkCellLayout *cell_layout, |
449 | CtkCellRenderer *renderer, |
450 | const gchar *attribute, |
451 | gint column); |
452 | static void ctk_cell_area_set_cell_data_func (CtkCellLayout *cell_layout, |
453 | CtkCellRenderer *cell, |
454 | CtkCellLayoutDataFunc func, |
455 | gpointer func_data, |
456 | GDestroyNotify destroy); |
457 | static void ctk_cell_area_clear_attributes (CtkCellLayout *cell_layout, |
458 | CtkCellRenderer *renderer); |
459 | static void ctk_cell_area_reorder (CtkCellLayout *cell_layout, |
460 | CtkCellRenderer *cell, |
461 | gint position); |
462 | static GList *ctk_cell_area_get_cells (CtkCellLayout *cell_layout); |
463 | static CtkCellArea *ctk_cell_area_get_area (CtkCellLayout *cell_layout); |
464 | |
465 | /* CtkBuildableIface */ |
466 | static void ctk_cell_area_buildable_init (CtkBuildableIface *iface); |
467 | static void ctk_cell_area_buildable_custom_tag_end (CtkBuildable *buildable, |
468 | CtkBuilder *builder, |
469 | GObject *child, |
470 | const gchar *tagname, |
471 | gpointer *data); |
472 | |
473 | /* Used in foreach loop to check if a child renderer is present */ |
474 | typedef struct { |
475 | CtkCellRenderer *renderer; |
476 | gboolean has_renderer; |
477 | } HasRendererCheck; |
478 | |
479 | /* Used in foreach loop to get a cell's allocation */ |
480 | typedef struct { |
481 | CtkCellRenderer *renderer; |
482 | CdkRectangle allocation; |
483 | } RendererAllocationData; |
484 | |
485 | /* Used in foreach loop to render cells */ |
486 | typedef struct { |
487 | CtkCellArea *area; |
488 | CtkWidget *widget; |
489 | cairo_t *cr; |
490 | CdkRectangle focus_rect; |
491 | CtkCellRendererState render_flags; |
492 | guint paint_focus : 1; |
493 | guint focus_all : 1; |
494 | guint first_focus : 1; |
495 | } CellRenderData; |
496 | |
497 | /* Used in foreach loop to get a cell by position */ |
498 | typedef struct { |
499 | gint x; |
500 | gint y; |
501 | CtkCellRenderer *renderer; |
502 | CdkRectangle cell_area; |
503 | } CellByPositionData; |
504 | |
505 | /* Attribute/Cell metadata */ |
506 | typedef struct { |
507 | const gchar *attribute; |
508 | gint column; |
509 | } CellAttribute; |
510 | |
511 | typedef struct { |
512 | GSList *attributes; |
513 | |
514 | CtkCellLayoutDataFunc func; |
515 | gpointer data; |
516 | GDestroyNotify destroy; |
517 | CtkCellLayout *proxy; |
518 | } CellInfo; |
519 | |
520 | static CellInfo *cell_info_new (CtkCellLayoutDataFunc func, |
521 | gpointer data, |
522 | GDestroyNotify destroy); |
523 | static void cell_info_free (CellInfo *info); |
524 | static CellAttribute *cell_attribute_new (CtkCellRenderer *renderer, |
525 | const gchar *attribute, |
526 | gint column); |
527 | static void cell_attribute_free (CellAttribute *attribute); |
528 | static gint cell_attribute_find (CellAttribute *cell_attribute, |
529 | const gchar *attribute); |
530 | |
531 | /* Internal functions/signal emissions */ |
532 | static void ctk_cell_area_add_editable (CtkCellArea *area, |
533 | CtkCellRenderer *renderer, |
534 | CtkCellEditable *editable, |
535 | const CdkRectangle *cell_area); |
536 | static void ctk_cell_area_remove_editable (CtkCellArea *area, |
537 | CtkCellRenderer *renderer, |
538 | CtkCellEditable *editable); |
539 | static void ctk_cell_area_set_edit_widget (CtkCellArea *area, |
540 | CtkCellEditable *editable); |
541 | static void ctk_cell_area_set_edited_cell (CtkCellArea *area, |
542 | CtkCellRenderer *renderer); |
543 | |
544 | |
545 | /* Struct to pass data along while looping over |
546 | * cell renderers to apply attributes |
547 | */ |
548 | typedef struct { |
549 | CtkCellArea *area; |
550 | CtkTreeModel *model; |
551 | CtkTreeIter *iter; |
552 | gboolean is_expander; |
553 | gboolean is_expanded; |
554 | } AttributeData; |
555 | |
556 | struct _CtkCellAreaPrivate |
557 | { |
558 | /* The CtkCellArea bookkeeps any connected |
559 | * attributes in this hash table. |
560 | */ |
561 | GHashTable *cell_info; |
562 | |
563 | /* Current path is saved as a side-effect |
564 | * of ctk_cell_area_apply_attributes() |
565 | */ |
566 | gchar *current_path; |
567 | |
568 | /* Current cell being edited and editable widget used */ |
569 | CtkCellEditable *edit_widget; |
570 | CtkCellRenderer *edited_cell; |
571 | |
572 | /* Signal connections to the editable widget */ |
573 | gulong remove_widget_id; |
574 | |
575 | /* Currently focused cell */ |
576 | CtkCellRenderer *focus_cell; |
577 | |
578 | /* Tracking which cells are focus siblings of focusable cells */ |
579 | GHashTable *focus_siblings; |
580 | }; |
581 | |
582 | enum { |
583 | PROP_0, |
584 | PROP_FOCUS_CELL, |
585 | PROP_EDITED_CELL, |
586 | PROP_EDIT_WIDGET |
587 | }; |
588 | |
589 | enum { |
590 | SIGNAL_APPLY_ATTRIBUTES, |
591 | SIGNAL_ADD_EDITABLE, |
592 | SIGNAL_REMOVE_EDITABLE, |
593 | SIGNAL_FOCUS_CHANGED, |
594 | LAST_SIGNAL |
595 | }; |
596 | |
597 | /* Keep the paramspec pool internal, no need to deliver notifications |
598 | * on cells. at least no perceived need for now |
599 | */ |
600 | static GParamSpecPool *cell_property_pool = NULL((void*)0); |
601 | static guint cell_area_signals[LAST_SIGNAL] = { 0 }; |
602 | |
603 | #define PARAM_SPEC_PARAM_ID(pspec)((pspec)->param_id) ((pspec)->param_id) |
604 | #define PARAM_SPEC_SET_PARAM_ID(pspec, id)((pspec)->param_id = (id)) ((pspec)->param_id = (id)) |
605 | |
606 | G_DEFINE_ABSTRACT_TYPE_WITH_CODE (CtkCellArea, ctk_cell_area, G_TYPE_INITIALLY_UNOWNED,static void ctk_cell_area_init (CtkCellArea *self); static void ctk_cell_area_class_init (CtkCellAreaClass *klass); static GType ctk_cell_area_get_type_once (void); static gpointer ctk_cell_area_parent_class = ((void*)0); static gint CtkCellArea_private_offset; static void ctk_cell_area_class_intern_init (gpointer klass) { ctk_cell_area_parent_class = g_type_class_peek_parent (klass); if (CtkCellArea_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkCellArea_private_offset ); ctk_cell_area_class_init ((CtkCellAreaClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_cell_area_get_instance_private (CtkCellArea *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkCellArea_private_offset)))); } GType ctk_cell_area_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_cell_area_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_cell_area_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( g_initially_unowned_get_type()), g_intern_static_string ("CtkCellArea" ), sizeof (CtkCellAreaClass), (GClassInitFunc)(void (*)(void) ) ctk_cell_area_class_intern_init, sizeof (CtkCellArea), (GInstanceInitFunc )(void (*)(void)) ctk_cell_area_init, (GTypeFlags) G_TYPE_FLAG_ABSTRACT ); { {{ CtkCellArea_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkCellAreaPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_cell_layout_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_cell_layout_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_buildable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
607 | G_ADD_PRIVATE (CtkCellArea)static void ctk_cell_area_init (CtkCellArea *self); static void ctk_cell_area_class_init (CtkCellAreaClass *klass); static GType ctk_cell_area_get_type_once (void); static gpointer ctk_cell_area_parent_class = ((void*)0); static gint CtkCellArea_private_offset; static void ctk_cell_area_class_intern_init (gpointer klass) { ctk_cell_area_parent_class = g_type_class_peek_parent (klass); if (CtkCellArea_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkCellArea_private_offset ); ctk_cell_area_class_init ((CtkCellAreaClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_cell_area_get_instance_private (CtkCellArea *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkCellArea_private_offset)))); } GType ctk_cell_area_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_cell_area_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_cell_area_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( g_initially_unowned_get_type()), g_intern_static_string ("CtkCellArea" ), sizeof (CtkCellAreaClass), (GClassInitFunc)(void (*)(void) ) ctk_cell_area_class_intern_init, sizeof (CtkCellArea), (GInstanceInitFunc )(void (*)(void)) ctk_cell_area_init, (GTypeFlags) G_TYPE_FLAG_ABSTRACT ); { {{ CtkCellArea_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkCellAreaPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_cell_layout_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_cell_layout_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_buildable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
608 | G_IMPLEMENT_INTERFACE (CTK_TYPE_CELL_LAYOUT,static void ctk_cell_area_init (CtkCellArea *self); static void ctk_cell_area_class_init (CtkCellAreaClass *klass); static GType ctk_cell_area_get_type_once (void); static gpointer ctk_cell_area_parent_class = ((void*)0); static gint CtkCellArea_private_offset; static void ctk_cell_area_class_intern_init (gpointer klass) { ctk_cell_area_parent_class = g_type_class_peek_parent (klass); if (CtkCellArea_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkCellArea_private_offset ); ctk_cell_area_class_init ((CtkCellAreaClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_cell_area_get_instance_private (CtkCellArea *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkCellArea_private_offset)))); } GType ctk_cell_area_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_cell_area_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_cell_area_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( g_initially_unowned_get_type()), g_intern_static_string ("CtkCellArea" ), sizeof (CtkCellAreaClass), (GClassInitFunc)(void (*)(void) ) ctk_cell_area_class_intern_init, sizeof (CtkCellArea), (GInstanceInitFunc )(void (*)(void)) ctk_cell_area_init, (GTypeFlags) G_TYPE_FLAG_ABSTRACT ); { {{ CtkCellArea_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkCellAreaPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_cell_layout_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_cell_layout_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_buildable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
609 | ctk_cell_area_cell_layout_init)static void ctk_cell_area_init (CtkCellArea *self); static void ctk_cell_area_class_init (CtkCellAreaClass *klass); static GType ctk_cell_area_get_type_once (void); static gpointer ctk_cell_area_parent_class = ((void*)0); static gint CtkCellArea_private_offset; static void ctk_cell_area_class_intern_init (gpointer klass) { ctk_cell_area_parent_class = g_type_class_peek_parent (klass); if (CtkCellArea_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkCellArea_private_offset ); ctk_cell_area_class_init ((CtkCellAreaClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_cell_area_get_instance_private (CtkCellArea *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkCellArea_private_offset)))); } GType ctk_cell_area_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_cell_area_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_cell_area_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( g_initially_unowned_get_type()), g_intern_static_string ("CtkCellArea" ), sizeof (CtkCellAreaClass), (GClassInitFunc)(void (*)(void) ) ctk_cell_area_class_intern_init, sizeof (CtkCellArea), (GInstanceInitFunc )(void (*)(void)) ctk_cell_area_init, (GTypeFlags) G_TYPE_FLAG_ABSTRACT ); { {{ CtkCellArea_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkCellAreaPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_cell_layout_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_cell_layout_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_buildable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
610 | G_IMPLEMENT_INTERFACE (CTK_TYPE_BUILDABLE,static void ctk_cell_area_init (CtkCellArea *self); static void ctk_cell_area_class_init (CtkCellAreaClass *klass); static GType ctk_cell_area_get_type_once (void); static gpointer ctk_cell_area_parent_class = ((void*)0); static gint CtkCellArea_private_offset; static void ctk_cell_area_class_intern_init (gpointer klass) { ctk_cell_area_parent_class = g_type_class_peek_parent (klass); if (CtkCellArea_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkCellArea_private_offset ); ctk_cell_area_class_init ((CtkCellAreaClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_cell_area_get_instance_private (CtkCellArea *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkCellArea_private_offset)))); } GType ctk_cell_area_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_cell_area_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_cell_area_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( g_initially_unowned_get_type()), g_intern_static_string ("CtkCellArea" ), sizeof (CtkCellAreaClass), (GClassInitFunc)(void (*)(void) ) ctk_cell_area_class_intern_init, sizeof (CtkCellArea), (GInstanceInitFunc )(void (*)(void)) ctk_cell_area_init, (GTypeFlags) G_TYPE_FLAG_ABSTRACT ); { {{ CtkCellArea_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkCellAreaPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_cell_layout_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_cell_layout_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_buildable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
611 | ctk_cell_area_buildable_init))static void ctk_cell_area_init (CtkCellArea *self); static void ctk_cell_area_class_init (CtkCellAreaClass *klass); static GType ctk_cell_area_get_type_once (void); static gpointer ctk_cell_area_parent_class = ((void*)0); static gint CtkCellArea_private_offset; static void ctk_cell_area_class_intern_init (gpointer klass) { ctk_cell_area_parent_class = g_type_class_peek_parent (klass); if (CtkCellArea_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkCellArea_private_offset ); ctk_cell_area_class_init ((CtkCellAreaClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_cell_area_get_instance_private (CtkCellArea *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkCellArea_private_offset)))); } GType ctk_cell_area_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_cell_area_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_cell_area_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( g_initially_unowned_get_type()), g_intern_static_string ("CtkCellArea" ), sizeof (CtkCellAreaClass), (GClassInitFunc)(void (*)(void) ) ctk_cell_area_class_intern_init, sizeof (CtkCellArea), (GInstanceInitFunc )(void (*)(void)) ctk_cell_area_init, (GTypeFlags) G_TYPE_FLAG_ABSTRACT ); { {{ CtkCellArea_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkCellAreaPrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_cell_layout_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_cell_layout_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_cell_area_buildable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
612 | |
613 | static void |
614 | ctk_cell_area_init (CtkCellArea *area) |
615 | { |
616 | CtkCellAreaPrivate *priv; |
617 | |
618 | area->priv = ctk_cell_area_get_instance_private (area); |
619 | priv = area->priv; |
620 | |
621 | priv->cell_info = g_hash_table_new_full (g_direct_hash, |
622 | g_direct_equal, |
623 | NULL((void*)0), |
624 | (GDestroyNotify)cell_info_free); |
625 | |
626 | priv->focus_siblings = g_hash_table_new_full (g_direct_hash, |
627 | g_direct_equal, |
628 | NULL((void*)0), |
629 | (GDestroyNotify)g_list_free); |
630 | |
631 | priv->focus_cell = NULL((void*)0); |
632 | priv->edited_cell = NULL((void*)0); |
633 | priv->edit_widget = NULL((void*)0); |
634 | |
635 | priv->remove_widget_id = 0; |
636 | } |
637 | |
638 | static void |
639 | ctk_cell_area_class_init (CtkCellAreaClass *class) |
640 | { |
641 | GObjectClass *object_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))); |
642 | |
643 | /* GObjectClass */ |
644 | object_class->dispose = ctk_cell_area_dispose; |
645 | object_class->finalize = ctk_cell_area_finalize; |
646 | object_class->get_property = ctk_cell_area_get_property; |
647 | object_class->set_property = ctk_cell_area_set_property; |
648 | |
649 | /* general */ |
650 | class->add = ctk_cell_area_real_add; |
651 | class->remove = ctk_cell_area_real_remove; |
652 | class->foreach = ctk_cell_area_real_foreach; |
653 | class->foreach_alloc = ctk_cell_area_real_foreach_alloc; |
654 | class->event = ctk_cell_area_real_event; |
655 | class->render = ctk_cell_area_real_render; |
656 | class->apply_attributes = ctk_cell_area_real_apply_attributes; |
657 | |
658 | /* geometry */ |
659 | class->create_context = ctk_cell_area_real_create_context; |
660 | class->copy_context = ctk_cell_area_real_copy_context; |
661 | class->get_request_mode = ctk_cell_area_real_get_request_mode; |
662 | class->get_preferred_width = ctk_cell_area_real_get_preferred_width; |
663 | class->get_preferred_height = ctk_cell_area_real_get_preferred_height; |
664 | class->get_preferred_height_for_width = ctk_cell_area_real_get_preferred_height_for_width; |
665 | class->get_preferred_width_for_height = ctk_cell_area_real_get_preferred_width_for_height; |
666 | |
667 | /* focus */ |
668 | class->is_activatable = ctk_cell_area_real_is_activatable; |
669 | class->activate = ctk_cell_area_real_activate; |
670 | class->focus = ctk_cell_area_real_focus; |
671 | |
672 | /* Signals */ |
673 | /** |
674 | * CtkCellArea::apply-attributes: |
675 | * @area: the #CtkCellArea to apply the attributes to |
676 | * @model: the #CtkTreeModel to apply the attributes from |
677 | * @iter: the #CtkTreeIter indicating which row to apply the attributes of |
678 | * @is_expander: whether the view shows children for this row |
679 | * @is_expanded: whether the view is currently showing the children of this row |
680 | * |
681 | * This signal is emitted whenever applying attributes to @area from @model |
682 | * |
683 | * Since: 3.0 |
684 | */ |
685 | cell_area_signals[SIGNAL_APPLY_ATTRIBUTES] = |
686 | g_signal_new (I_("apply-attributes")g_intern_static_string ("apply-attributes"), |
687 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), |
688 | G_SIGNAL_RUN_FIRST, |
689 | G_STRUCT_OFFSET (CtkCellAreaClass, apply_attributes)((glong) __builtin_offsetof(CtkCellAreaClass, apply_attributes )), |
690 | NULL((void*)0), NULL((void*)0), |
691 | _ctk_marshal_VOID__OBJECT_BOXED_BOOLEAN_BOOLEAN, |
692 | G_TYPE_NONE((GType) ((1) << (2))), 4, |
693 | CTK_TYPE_TREE_MODEL(ctk_tree_model_get_type ()), |
694 | CTK_TYPE_TREE_ITER(ctk_tree_iter_get_type ()), |
695 | G_TYPE_BOOLEAN((GType) ((5) << (2))), |
696 | G_TYPE_BOOLEAN((GType) ((5) << (2)))); |
697 | g_signal_set_va_marshaller (cell_area_signals[SIGNAL_APPLY_ATTRIBUTES], G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), |
698 | _ctk_marshal_VOID__OBJECT_BOXED_BOOLEAN_BOOLEANv); |
699 | |
700 | /** |
701 | * CtkCellArea::add-editable: |
702 | * @area: the #CtkCellArea where editing started |
703 | * @renderer: the #CtkCellRenderer that started the edited |
704 | * @editable: the #CtkCellEditable widget to add |
705 | * @cell_area: the #CtkWidget relative #CdkRectangle coordinates |
706 | * where @editable should be added |
707 | * @path: the #CtkTreePath string this edit was initiated for |
708 | * |
709 | * Indicates that editing has started on @renderer and that @editable |
710 | * should be added to the owning cell-layouting widget at @cell_area. |
711 | * |
712 | * Since: 3.0 |
713 | */ |
714 | cell_area_signals[SIGNAL_ADD_EDITABLE] = |
715 | g_signal_new (I_("add-editable")g_intern_static_string ("add-editable"), |
716 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), |
717 | G_SIGNAL_RUN_FIRST, |
718 | 0, /* No class closure here */ |
719 | NULL((void*)0), NULL((void*)0), |
720 | _ctk_marshal_VOID__OBJECT_OBJECT_BOXED_STRING, |
721 | G_TYPE_NONE((GType) ((1) << (2))), 4, |
722 | CTK_TYPE_CELL_RENDERER(ctk_cell_renderer_get_type ()), |
723 | CTK_TYPE_CELL_EDITABLE(ctk_cell_editable_get_type ()), |
724 | CDK_TYPE_RECTANGLE(cdk_rectangle_get_type ()), |
725 | G_TYPE_STRING((GType) ((16) << (2)))); |
726 | |
727 | |
728 | /** |
729 | * CtkCellArea::remove-editable: |
730 | * @area: the #CtkCellArea where editing finished |
731 | * @renderer: the #CtkCellRenderer that finished editeding |
732 | * @editable: the #CtkCellEditable widget to remove |
733 | * |
734 | * Indicates that editing finished on @renderer and that @editable |
735 | * should be removed from the owning cell-layouting widget. |
736 | * |
737 | * Since: 3.0 |
738 | */ |
739 | cell_area_signals[SIGNAL_REMOVE_EDITABLE] = |
740 | g_signal_new (I_("remove-editable")g_intern_static_string ("remove-editable"), |
741 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), |
742 | G_SIGNAL_RUN_FIRST, |
743 | 0, /* No class closure here */ |
744 | NULL((void*)0), NULL((void*)0), |
745 | _ctk_marshal_VOID__OBJECT_OBJECT, |
746 | G_TYPE_NONE((GType) ((1) << (2))), 2, |
747 | CTK_TYPE_CELL_RENDERER(ctk_cell_renderer_get_type ()), |
748 | CTK_TYPE_CELL_EDITABLE(ctk_cell_editable_get_type ())); |
749 | |
750 | /** |
751 | * CtkCellArea::focus-changed: |
752 | * @area: the #CtkCellArea where focus changed |
753 | * @renderer: the #CtkCellRenderer that has focus |
754 | * @path: the current #CtkTreePath string set for @area |
755 | * |
756 | * Indicates that focus changed on this @area. This signal |
757 | * is emitted either as a result of focus handling or event |
758 | * handling. |
759 | * |
760 | * It's possible that the signal is emitted even if the |
761 | * currently focused renderer did not change, this is |
762 | * because focus may change to the same renderer in the |
763 | * same cell area for a different row of data. |
764 | * |
765 | * Since: 3.0 |
766 | */ |
767 | cell_area_signals[SIGNAL_FOCUS_CHANGED] = |
768 | g_signal_new (I_("focus-changed")g_intern_static_string ("focus-changed"), |
769 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), |
770 | G_SIGNAL_RUN_FIRST, |
771 | 0, /* No class closure here */ |
772 | NULL((void*)0), NULL((void*)0), |
773 | _ctk_marshal_VOID__OBJECT_STRING, |
774 | G_TYPE_NONE((GType) ((1) << (2))), 2, |
775 | CTK_TYPE_CELL_RENDERER(ctk_cell_renderer_get_type ()), |
776 | G_TYPE_STRING((GType) ((16) << (2)))); |
777 | |
778 | /* Properties */ |
779 | /** |
780 | * CtkCellArea:focus-cell: |
781 | * |
782 | * The cell in the area that currently has focus |
783 | * |
784 | * Since: 3.0 |
785 | */ |
786 | g_object_class_install_property (object_class, |
787 | PROP_FOCUS_CELL, |
788 | g_param_spec_object |
789 | ("focus-cell", |
790 | P_("Focus Cell")g_dgettext("ctk30" "-properties","Focus Cell"), |
791 | P_("The cell which currently has focus")g_dgettext("ctk30" "-properties","The cell which currently has focus" ), |
792 | CTK_TYPE_CELL_RENDERER(ctk_cell_renderer_get_type ()), |
793 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
794 | |
795 | /** |
796 | * CtkCellArea:edited-cell: |
797 | * |
798 | * The cell in the area that is currently edited |
799 | * |
800 | * This property is read-only and only changes as |
801 | * a result of a call ctk_cell_area_activate_cell(). |
802 | * |
803 | * Since: 3.0 |
804 | */ |
805 | g_object_class_install_property (object_class, |
806 | PROP_EDITED_CELL, |
807 | g_param_spec_object |
808 | ("edited-cell", |
809 | P_("Edited Cell")g_dgettext("ctk30" "-properties","Edited Cell"), |
810 | P_("The cell which is currently being edited")g_dgettext("ctk30" "-properties","The cell which is currently being edited" ), |
811 | CTK_TYPE_CELL_RENDERER(ctk_cell_renderer_get_type ()), |
812 | G_PARAM_READABLE)); |
813 | |
814 | /** |
815 | * CtkCellArea:edit-widget: |
816 | * |
817 | * The widget currently editing the edited cell |
818 | * |
819 | * This property is read-only and only changes as |
820 | * a result of a call ctk_cell_area_activate_cell(). |
821 | * |
822 | * Since: 3.0 |
823 | */ |
824 | g_object_class_install_property (object_class, |
825 | PROP_EDIT_WIDGET, |
826 | g_param_spec_object |
827 | ("edit-widget", |
828 | P_("Edit Widget")g_dgettext("ctk30" "-properties","Edit Widget"), |
829 | P_("The widget currently editing the edited cell")g_dgettext("ctk30" "-properties","The widget currently editing the edited cell" ), |
830 | CTK_TYPE_CELL_EDITABLE(ctk_cell_editable_get_type ()), |
831 | G_PARAM_READABLE)); |
832 | |
833 | /* Pool for Cell Properties */ |
834 | if (!cell_property_pool) |
835 | cell_property_pool = g_param_spec_pool_new (FALSE(0)); |
836 | } |
837 | |
838 | /************************************************************* |
839 | * CellInfo Basics * |
840 | *************************************************************/ |
841 | static CellInfo * |
842 | cell_info_new (CtkCellLayoutDataFunc func, |
843 | gpointer data, |
844 | GDestroyNotify destroy) |
845 | { |
846 | CellInfo *info = g_slice_new0 (CellInfo)((CellInfo*) g_slice_alloc0 (sizeof (CellInfo))); |
847 | |
848 | info->func = func; |
849 | info->data = data; |
850 | info->destroy = destroy; |
851 | |
852 | return info; |
853 | } |
854 | |
855 | static void |
856 | cell_info_free (CellInfo *info) |
857 | { |
858 | if (info->destroy) |
859 | info->destroy (info->data); |
860 | |
861 | g_slist_free_full (info->attributes, (GDestroyNotify)cell_attribute_free); |
862 | |
863 | g_slice_free (CellInfo, info)do { if (1) g_slice_free1 (sizeof (CellInfo), (info)); else ( void) ((CellInfo*) 0 == (info)); } while (0); |
864 | } |
865 | |
866 | static CellAttribute * |
867 | cell_attribute_new (CtkCellRenderer *renderer, |
868 | const gchar *attribute, |
869 | gint column) |
870 | { |
871 | GParamSpec *pspec; |
872 | |
873 | /* Check if the attribute really exists and point to |
874 | * the property string installed on the cell renderer |
875 | * class (dont dup the string) |
876 | */ |
877 | pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (renderer)((((GObjectClass*) (((GTypeInstance*) ((renderer)))->g_class )))), attribute); |
878 | |
879 | if (pspec) |
880 | { |
881 | CellAttribute *cell_attribute = g_slice_new (CellAttribute)((CellAttribute*) g_slice_alloc (sizeof (CellAttribute))); |
882 | |
883 | cell_attribute->attribute = pspec->name; |
884 | cell_attribute->column = column; |
885 | |
886 | return cell_attribute; |
887 | } |
888 | |
889 | return NULL((void*)0); |
890 | } |
891 | |
892 | static void |
893 | cell_attribute_free (CellAttribute *attribute) |
894 | { |
895 | g_slice_free (CellAttribute, attribute)do { if (1) g_slice_free1 (sizeof (CellAttribute), (attribute )); else (void) ((CellAttribute*) 0 == (attribute)); } while ( 0); |
896 | } |
897 | |
898 | /* GCompareFunc for g_slist_find_custom() */ |
899 | static gint |
900 | cell_attribute_find (CellAttribute *cell_attribute, |
901 | const gchar *attribute) |
902 | { |
903 | return g_strcmp0 (cell_attribute->attribute, attribute); |
904 | } |
905 | |
906 | /************************************************************* |
907 | * GObjectClass * |
908 | *************************************************************/ |
909 | static void |
910 | ctk_cell_area_finalize (GObject *object) |
911 | { |
912 | CtkCellArea *area = CTK_CELL_AREA (object)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_cell_area_get_type ())))))); |
913 | CtkCellAreaPrivate *priv = area->priv; |
914 | |
915 | /* All cell renderers should already be removed at this point, |
916 | * just kill our (empty) hash tables here. |
917 | */ |
918 | g_hash_table_destroy (priv->cell_info); |
919 | g_hash_table_destroy (priv->focus_siblings); |
920 | |
921 | g_free (priv->current_path); |
922 | |
923 | G_OBJECT_CLASS (ctk_cell_area_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_cell_area_parent_class)), (((GType) ((20) << ( 2))))))))->finalize (object); |
924 | } |
925 | |
926 | |
927 | static void |
928 | ctk_cell_area_dispose (GObject *object) |
929 | { |
930 | /* This removes every cell renderer that may be added to the CtkCellArea, |
931 | * subclasses should be breaking references to the CtkCellRenderers |
932 | * at this point. |
933 | */ |
934 | ctk_cell_layout_clear (CTK_CELL_LAYOUT (object)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_cell_layout_get_type ()))))))); |
935 | |
936 | /* Remove any ref to a focused/edited cell */ |
937 | ctk_cell_area_set_focus_cell (CTK_CELL_AREA (object)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_cell_area_get_type ())))))), NULL((void*)0)); |
938 | ctk_cell_area_set_edited_cell (CTK_CELL_AREA (object)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_cell_area_get_type ())))))), NULL((void*)0)); |
939 | ctk_cell_area_set_edit_widget (CTK_CELL_AREA (object)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_cell_area_get_type ())))))), NULL((void*)0)); |
940 | |
941 | G_OBJECT_CLASS (ctk_cell_area_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_cell_area_parent_class)), (((GType) ((20) << ( 2))))))))->dispose (object); |
942 | } |
943 | |
944 | static void |
945 | ctk_cell_area_set_property (GObject *object, |
946 | guint prop_id, |
947 | const GValue *value, |
948 | GParamSpec *pspec) |
949 | { |
950 | CtkCellArea *area = CTK_CELL_AREA (object)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_cell_area_get_type ())))))); |
951 | |
952 | switch (prop_id) |
953 | { |
954 | case PROP_FOCUS_CELL: |
955 | ctk_cell_area_set_focus_cell (area, (CtkCellRenderer *)g_value_get_object (value)); |
956 | break; |
957 | default: |
958 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkcellarea.c", 958, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
959 | break; |
960 | } |
961 | } |
962 | |
963 | static void |
964 | ctk_cell_area_get_property (GObject *object, |
965 | guint prop_id, |
966 | GValue *value, |
967 | GParamSpec *pspec) |
968 | { |
969 | CtkCellArea *area = CTK_CELL_AREA (object)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_cell_area_get_type ())))))); |
970 | CtkCellAreaPrivate *priv = area->priv; |
971 | |
972 | switch (prop_id) |
973 | { |
974 | case PROP_FOCUS_CELL: |
975 | g_value_set_object (value, priv->focus_cell); |
976 | break; |
977 | case PROP_EDITED_CELL: |
978 | g_value_set_object (value, priv->edited_cell); |
979 | break; |
980 | case PROP_EDIT_WIDGET: |
981 | g_value_set_object (value, priv->edit_widget); |
982 | break; |
983 | default: |
984 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctkcellarea.c", 984, ("property"), _glib__property_id, _glib__pspec ->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) ( _glib__pspec))->g_class))->g_type)))), (g_type_name ((( (((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
985 | break; |
986 | } |
987 | } |
988 | |
989 | /************************************************************* |
990 | * CtkCellAreaClass * |
991 | *************************************************************/ |
992 | static void |
993 | ctk_cell_area_real_add (CtkCellArea *area, |
994 | CtkCellRenderer *renderer G_GNUC_UNUSED__attribute__ ((__unused__))) |
995 | { |
996 | g_warning ("CtkCellAreaClass::add not implemented for '%s'", |
997 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
998 | } |
999 | |
1000 | static void |
1001 | ctk_cell_area_real_remove (CtkCellArea *area, |
1002 | CtkCellRenderer *renderer G_GNUC_UNUSED__attribute__ ((__unused__))) |
1003 | { |
1004 | g_warning ("CtkCellAreaClass::remove not implemented for '%s'", |
1005 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1006 | } |
1007 | |
1008 | static void |
1009 | ctk_cell_area_real_foreach (CtkCellArea *area, |
1010 | CtkCellCallback callback G_GNUC_UNUSED__attribute__ ((__unused__)), |
1011 | gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
1012 | { |
1013 | g_warning ("CtkCellAreaClass::foreach not implemented for '%s'", |
1014 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1015 | } |
1016 | |
1017 | static void |
1018 | ctk_cell_area_real_foreach_alloc (CtkCellArea *area, |
1019 | CtkCellAreaContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
1020 | CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1021 | const CdkRectangle *cell_area G_GNUC_UNUSED__attribute__ ((__unused__)), |
1022 | const CdkRectangle *background_area G_GNUC_UNUSED__attribute__ ((__unused__)), |
1023 | CtkCellAllocCallback callback G_GNUC_UNUSED__attribute__ ((__unused__)), |
1024 | gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
1025 | { |
1026 | g_warning ("CtkCellAreaClass::foreach_alloc not implemented for '%s'", |
1027 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1028 | } |
1029 | |
1030 | static gint |
1031 | ctk_cell_area_real_event (CtkCellArea *area, |
1032 | CtkCellAreaContext *context, |
1033 | CtkWidget *widget, |
1034 | CdkEvent *event, |
1035 | const CdkRectangle *cell_area, |
1036 | CtkCellRendererState flags) |
1037 | { |
1038 | CtkCellAreaPrivate *priv = area->priv; |
1039 | gboolean retval = FALSE(0); |
1040 | |
1041 | if (event->type == CDK_KEY_PRESS && (flags & CTK_CELL_RENDERER_FOCUSED) != 0) |
1042 | { |
1043 | CdkEventKey *key_event = (CdkEventKey *)event; |
1044 | |
1045 | /* Cancel any edits in progress */ |
1046 | if (priv->edited_cell && (key_event->keyval == CDK_KEY_Escape0xff1b)) |
1047 | { |
1048 | ctk_cell_area_stop_editing (area, TRUE(!(0))); |
1049 | retval = TRUE(!(0)); |
1050 | } |
1051 | } |
1052 | else if (event->type == CDK_BUTTON_PRESS) |
1053 | { |
1054 | CdkEventButton *button_event = (CdkEventButton *)event; |
1055 | |
1056 | if (button_event->button == CDK_BUTTON_PRIMARY(1)) |
1057 | { |
1058 | CtkCellRenderer *renderer = NULL((void*)0); |
1059 | CtkCellRenderer *focus_renderer; |
1060 | CdkRectangle alloc_area; |
1061 | gint event_x, event_y; |
1062 | |
1063 | /* We may need some semantics to tell us the offset of the event |
1064 | * window we are handling events for (i.e. CtkTreeView has a bin_window) */ |
1065 | event_x = button_event->x; |
1066 | event_y = button_event->y; |
1067 | |
1068 | /* Dont try to search for an event coordinate that is not in the area, that will |
1069 | * trigger a runtime warning. |
1070 | */ |
1071 | if (event_x >= cell_area->x && event_x <= cell_area->x + cell_area->width && |
1072 | event_y >= cell_area->y && event_y <= cell_area->y + cell_area->height) |
1073 | renderer = |
1074 | ctk_cell_area_get_cell_at_position (area, context, widget, |
1075 | cell_area, event_x, event_y, |
1076 | &alloc_area); |
1077 | |
1078 | if (renderer) |
1079 | { |
1080 | focus_renderer = ctk_cell_area_get_focus_from_sibling (area, renderer); |
1081 | if (!focus_renderer) |
1082 | focus_renderer = renderer; |
1083 | |
1084 | /* If we're already editing, cancel it and set focus */ |
1085 | if (ctk_cell_area_get_edited_cell (area)) |
1086 | { |
1087 | /* XXX Was it really canceled in this case ? */ |
1088 | ctk_cell_area_stop_editing (area, TRUE(!(0))); |
1089 | ctk_cell_area_set_focus_cell (area, focus_renderer); |
1090 | retval = TRUE(!(0)); |
1091 | } |
1092 | else |
1093 | { |
1094 | /* If we are activating via a focus sibling, |
1095 | * we need to fetch the right cell area for the real event renderer */ |
1096 | if (focus_renderer != renderer) |
1097 | ctk_cell_area_get_cell_allocation (area, context, widget, focus_renderer, |
1098 | cell_area, &alloc_area); |
1099 | |
1100 | ctk_cell_area_set_focus_cell (area, focus_renderer); |
1101 | retval = ctk_cell_area_activate_cell (area, widget, focus_renderer, |
1102 | event, &alloc_area, flags); |
1103 | } |
1104 | } |
1105 | } |
1106 | } |
1107 | |
1108 | return retval; |
1109 | } |
1110 | |
1111 | static gboolean |
1112 | render_cell (CtkCellRenderer *renderer, |
1113 | const CdkRectangle *cell_area, |
1114 | const CdkRectangle *cell_background, |
1115 | CellRenderData *data) |
1116 | { |
1117 | CtkCellRenderer *focus_cell; |
1118 | CtkCellRendererState flags; |
1119 | CdkRectangle inner_area; |
1120 | |
1121 | focus_cell = ctk_cell_area_get_focus_cell (data->area); |
1122 | flags = data->render_flags; |
1123 | |
1124 | ctk_cell_area_inner_cell_area (data->area, data->widget, cell_area, &inner_area); |
1125 | |
1126 | if ((flags & CTK_CELL_RENDERER_FOCUSED) && |
1127 | (data->focus_all || |
1128 | (focus_cell && |
1129 | (renderer == focus_cell || |
1130 | ctk_cell_area_is_focus_sibling (data->area, focus_cell, renderer))))) |
1131 | { |
1132 | CdkRectangle cell_focus; |
1133 | |
1134 | ctk_cell_renderer_get_aligned_area (renderer, data->widget, flags, &inner_area, &cell_focus); |
1135 | |
1136 | if (data->first_focus) |
1137 | { |
1138 | data->first_focus = FALSE(0); |
1139 | data->focus_rect = cell_focus; |
1140 | } |
1141 | else |
1142 | { |
1143 | cdk_rectangle_union (&data->focus_rect, &cell_focus, &data->focus_rect); |
1144 | } |
1145 | } |
1146 | |
1147 | ctk_cell_renderer_render (renderer, data->cr, data->widget, |
1148 | cell_background, &inner_area, flags); |
1149 | |
1150 | return FALSE(0); |
1151 | } |
1152 | |
1153 | static void |
1154 | ctk_cell_area_real_render (CtkCellArea *area, |
1155 | CtkCellAreaContext *context, |
1156 | CtkWidget *widget, |
1157 | cairo_t *cr, |
1158 | const CdkRectangle *background_area, |
1159 | const CdkRectangle *cell_area, |
1160 | CtkCellRendererState flags, |
1161 | gboolean paint_focus) |
1162 | { |
1163 | CellRenderData render_data = |
1164 | { |
1165 | area, |
1166 | widget, |
1167 | cr, |
1168 | { 0, }, |
1169 | flags, |
1170 | paint_focus, |
1171 | FALSE(0), TRUE(!(0)) |
1172 | }; |
1173 | |
1174 | /* Make sure we dont paint a focus rectangle while there |
1175 | * is an editable widget in play |
1176 | */ |
1177 | if (ctk_cell_area_get_edited_cell (area)) |
1178 | render_data.paint_focus = FALSE(0); |
1179 | |
1180 | if (!ctk_widget_has_visible_focus (widget)) |
1181 | render_data.paint_focus = FALSE(0); |
1182 | |
1183 | /* If no cell can activate but the caller wants focus painted, |
1184 | * then we paint focus around all cells */ |
1185 | if ((flags & CTK_CELL_RENDERER_FOCUSED) != 0 && paint_focus && |
1186 | !ctk_cell_area_is_activatable (area)) |
1187 | render_data.focus_all = TRUE(!(0)); |
1188 | |
1189 | ctk_cell_area_foreach_alloc (area, context, widget, cell_area, background_area, |
1190 | (CtkCellAllocCallback)render_cell, &render_data); |
1191 | |
1192 | if (render_data.paint_focus && |
1193 | render_data.focus_rect.width != 0 && |
1194 | render_data.focus_rect.height != 0) |
1195 | { |
1196 | CtkStyleContext *style_context; |
1197 | CtkStateFlags renderer_state = 0; |
1198 | |
1199 | style_context = ctk_widget_get_style_context (widget); |
1200 | ctk_style_context_save (style_context); |
1201 | |
1202 | renderer_state = ctk_cell_renderer_get_state (NULL((void*)0), widget, flags); |
1203 | ctk_style_context_set_state (style_context, renderer_state); |
1204 | |
1205 | cairo_save (cr); |
1206 | |
1207 | cdk_cairo_rectangle (cr, background_area); |
1208 | cairo_clip (cr); |
1209 | |
1210 | ctk_render_focus (style_context, cr, |
1211 | render_data.focus_rect.x, render_data.focus_rect.y, |
1212 | render_data.focus_rect.width, render_data.focus_rect.height); |
1213 | |
1214 | ctk_style_context_restore (style_context); |
1215 | cairo_restore (cr); |
1216 | } |
1217 | } |
1218 | |
1219 | static void |
1220 | apply_cell_attributes (CtkCellRenderer *renderer, |
1221 | CellInfo *info, |
1222 | AttributeData *data) |
1223 | { |
1224 | CellAttribute *attribute; |
1225 | GSList *list; |
1226 | GValue value = G_VALUE_INIT{ 0, { { 0 } } }; |
1227 | gboolean is_expander; |
1228 | gboolean is_expanded; |
1229 | |
1230 | g_object_freeze_notify (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2))))))))); |
1231 | |
1232 | /* Whether a row expands or is presently expanded can only be |
1233 | * provided by the view (as these states can vary across views |
1234 | * accessing the same model). |
1235 | */ |
1236 | g_object_get (renderer, "is-expander", &is_expander, NULL((void*)0)); |
1237 | if (is_expander != data->is_expander) |
1238 | g_object_set (renderer, "is-expander", data->is_expander, NULL((void*)0)); |
1239 | |
1240 | g_object_get (renderer, "is-expanded", &is_expanded, NULL((void*)0)); |
1241 | if (is_expanded != data->is_expanded) |
1242 | g_object_set (renderer, "is-expanded", data->is_expanded, NULL((void*)0)); |
1243 | |
1244 | /* Apply the attributes directly to the renderer */ |
1245 | for (list = info->attributes; list; list = list->next) |
1246 | { |
1247 | attribute = list->data; |
1248 | |
1249 | ctk_tree_model_get_value (data->model, data->iter, attribute->column, &value); |
1250 | g_object_set_property (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2)))))))), attribute->attribute, &value); |
1251 | g_value_unset (&value); |
1252 | } |
1253 | |
1254 | /* Call any CtkCellLayoutDataFunc that may have been set by the user |
1255 | */ |
1256 | if (info->func) |
1257 | info->func (info->proxy ? info->proxy : CTK_CELL_LAYOUT (data->area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->area)), ((ctk_cell_layout_get_type ())))))), renderer, |
1258 | data->model, data->iter, info->data); |
1259 | |
1260 | g_object_thaw_notify (G_OBJECT (renderer)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((renderer)), (((GType) ((20) << (2))))))))); |
1261 | } |
1262 | |
1263 | static void |
1264 | ctk_cell_area_real_apply_attributes (CtkCellArea *area, |
1265 | CtkTreeModel *tree_model, |
1266 | CtkTreeIter *iter, |
1267 | gboolean is_expander, |
1268 | gboolean is_expanded) |
1269 | { |
1270 | |
1271 | CtkCellAreaPrivate *priv; |
1272 | AttributeData data; |
1273 | CtkTreePath *path; |
1274 | |
1275 | priv = area->priv; |
1276 | |
1277 | /* Feed in data needed to apply to every renderer */ |
1278 | data.area = area; |
1279 | data.model = tree_model; |
1280 | data.iter = iter; |
1281 | data.is_expander = is_expander; |
1282 | data.is_expanded = is_expanded; |
1283 | |
1284 | /* Go over any cells that have attributes or custom CtkCellLayoutDataFuncs and |
1285 | * apply the data from the treemodel */ |
1286 | g_hash_table_foreach (priv->cell_info, (GHFunc)apply_cell_attributes, &data); |
1287 | |
1288 | /* Update the currently applied path */ |
1289 | g_free (priv->current_path); |
1290 | path = ctk_tree_model_get_path (tree_model, iter); |
1291 | priv->current_path = ctk_tree_path_to_string (path); |
1292 | ctk_tree_path_free (path); |
1293 | } |
1294 | |
1295 | static CtkCellAreaContext * |
1296 | ctk_cell_area_real_create_context (CtkCellArea *area) |
1297 | { |
1298 | g_warning ("CtkCellAreaClass::create_context not implemented for '%s'", |
1299 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1300 | |
1301 | return NULL((void*)0); |
1302 | } |
1303 | |
1304 | static CtkCellAreaContext * |
1305 | ctk_cell_area_real_copy_context (CtkCellArea *area, |
1306 | CtkCellAreaContext *context G_GNUC_UNUSED__attribute__ ((__unused__))) |
1307 | { |
1308 | g_warning ("CtkCellAreaClass::copy_context not implemented for '%s'", |
1309 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1310 | |
1311 | return NULL((void*)0); |
1312 | } |
1313 | |
1314 | static CtkSizeRequestMode |
1315 | ctk_cell_area_real_get_request_mode (CtkCellArea *area G_GNUC_UNUSED__attribute__ ((__unused__))) |
1316 | { |
1317 | /* By default cell areas are height-for-width. */ |
1318 | return CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; |
1319 | } |
1320 | |
1321 | static void |
1322 | ctk_cell_area_real_get_preferred_width (CtkCellArea *area, |
1323 | CtkCellAreaContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
1324 | CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1325 | gint *minimum_width G_GNUC_UNUSED__attribute__ ((__unused__)), |
1326 | gint *natural_width G_GNUC_UNUSED__attribute__ ((__unused__))) |
1327 | { |
1328 | g_warning ("CtkCellAreaClass::get_preferred_width not implemented for '%s'", |
1329 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1330 | } |
1331 | |
1332 | static void |
1333 | ctk_cell_area_real_get_preferred_height (CtkCellArea *area, |
1334 | CtkCellAreaContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
1335 | CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1336 | gint *minimum_height G_GNUC_UNUSED__attribute__ ((__unused__)), |
1337 | gint *natural_height G_GNUC_UNUSED__attribute__ ((__unused__))) |
1338 | { |
1339 | g_warning ("CtkCellAreaClass::get_preferred_height not implemented for '%s'", |
1340 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1341 | } |
1342 | |
1343 | static void |
1344 | ctk_cell_area_real_get_preferred_height_for_width (CtkCellArea *area, |
1345 | CtkCellAreaContext *context, |
1346 | CtkWidget *widget, |
1347 | gint width G_GNUC_UNUSED__attribute__ ((__unused__)), |
1348 | gint *minimum_height, |
1349 | gint *natural_height) |
1350 | { |
1351 | /* If the area doesnt do height-for-width, fallback on base preferred height */ |
1352 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->get_preferred_height (area, context, widget, minimum_height, natural_height); |
1353 | } |
1354 | |
1355 | static void |
1356 | ctk_cell_area_real_get_preferred_width_for_height (CtkCellArea *area, |
1357 | CtkCellAreaContext *context, |
1358 | CtkWidget *widget, |
1359 | gint height G_GNUC_UNUSED__attribute__ ((__unused__)), |
1360 | gint *minimum_width, |
1361 | gint *natural_width) |
1362 | { |
1363 | /* If the area doesnt do width-for-height, fallback on base preferred width */ |
1364 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->get_preferred_width (area, context, widget, minimum_width, natural_width); |
1365 | } |
1366 | |
1367 | static gboolean |
1368 | get_is_activatable (CtkCellRenderer *renderer, |
1369 | gboolean *activatable) |
1370 | { |
1371 | |
1372 | if (ctk_cell_renderer_is_activatable (renderer)) |
1373 | *activatable = TRUE(!(0)); |
1374 | |
1375 | return *activatable; |
1376 | } |
1377 | |
1378 | static gboolean |
1379 | ctk_cell_area_real_is_activatable (CtkCellArea *area) |
1380 | { |
1381 | gboolean activatable = FALSE(0); |
1382 | |
1383 | /* Checks if any renderer can focus for the currently applied |
1384 | * attributes. |
1385 | * |
1386 | * Subclasses can override this in the case that they are also |
1387 | * rendering widgets as well as renderers. |
1388 | */ |
1389 | ctk_cell_area_foreach (area, (CtkCellCallback)get_is_activatable, &activatable); |
1390 | |
1391 | return activatable; |
1392 | } |
1393 | |
1394 | static gboolean |
1395 | ctk_cell_area_real_activate (CtkCellArea *area, |
1396 | CtkCellAreaContext *context, |
1397 | CtkWidget *widget, |
1398 | const CdkRectangle *cell_area, |
1399 | CtkCellRendererState flags, |
1400 | gboolean edit_only) |
1401 | { |
1402 | CtkCellAreaPrivate *priv = area->priv; |
1403 | CdkRectangle renderer_area; |
1404 | CtkCellRenderer *activate_cell = NULL((void*)0); |
1405 | CtkCellRendererMode mode; |
1406 | |
1407 | if (priv->focus_cell) |
1408 | { |
1409 | g_object_get (priv->focus_cell, "mode", &mode, NULL((void*)0)); |
1410 | |
1411 | if (ctk_cell_renderer_get_visible (priv->focus_cell) && |
1412 | (edit_only ? mode == CTK_CELL_RENDERER_MODE_EDITABLE : |
1413 | mode != CTK_CELL_RENDERER_MODE_INERT)) |
1414 | activate_cell = priv->focus_cell; |
1415 | } |
1416 | else |
1417 | { |
1418 | GList *cells, *l; |
1419 | |
1420 | /* CtkTreeView sometimes wants to activate a cell when no |
1421 | * cells are in focus. |
1422 | */ |
1423 | cells = ctk_cell_layout_get_cells (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ()))))))); |
1424 | for (l = cells; l && !activate_cell; l = l->next) |
1425 | { |
1426 | CtkCellRenderer *renderer = l->data; |
1427 | |
1428 | g_object_get (renderer, "mode", &mode, NULL((void*)0)); |
1429 | |
1430 | if (ctk_cell_renderer_get_visible (renderer) && |
1431 | (edit_only ? mode == CTK_CELL_RENDERER_MODE_EDITABLE : |
1432 | mode != CTK_CELL_RENDERER_MODE_INERT)) |
1433 | activate_cell = renderer; |
1434 | } |
1435 | g_list_free (cells); |
1436 | } |
1437 | |
1438 | if (activate_cell) |
1439 | { |
1440 | /* Get the allocation of the focused cell. |
1441 | */ |
1442 | ctk_cell_area_get_cell_allocation (area, context, widget, activate_cell, |
1443 | cell_area, &renderer_area); |
1444 | |
1445 | /* Activate or Edit the cell |
1446 | * |
1447 | * Currently just not sending an event, renderers afaics dont use |
1448 | * the event argument anyway, worst case is we can synthesize one. |
1449 | */ |
1450 | if (ctk_cell_area_activate_cell (area, widget, activate_cell, NULL((void*)0), |
1451 | &renderer_area, flags)) |
1452 | return TRUE(!(0)); |
1453 | } |
1454 | |
1455 | return FALSE(0); |
1456 | } |
1457 | |
1458 | static gboolean |
1459 | ctk_cell_area_real_focus (CtkCellArea *area, |
1460 | CtkDirectionType direction G_GNUC_UNUSED__attribute__ ((__unused__))) |
1461 | { |
1462 | g_warning ("CtkCellAreaClass::focus not implemented for '%s'", |
1463 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1464 | return FALSE(0); |
1465 | } |
1466 | |
1467 | /************************************************************* |
1468 | * CtkCellLayoutIface * |
1469 | *************************************************************/ |
1470 | static void |
1471 | ctk_cell_area_cell_layout_init (CtkCellLayoutIface *iface) |
1472 | { |
1473 | iface->pack_start = ctk_cell_area_pack_default; |
1474 | iface->pack_end = ctk_cell_area_pack_default; |
1475 | iface->clear = ctk_cell_area_clear; |
1476 | iface->add_attribute = ctk_cell_area_add_attribute; |
1477 | iface->set_cell_data_func = ctk_cell_area_set_cell_data_func; |
1478 | iface->clear_attributes = ctk_cell_area_clear_attributes; |
1479 | iface->reorder = ctk_cell_area_reorder; |
1480 | iface->get_cells = ctk_cell_area_get_cells; |
1481 | iface->get_area = ctk_cell_area_get_area; |
1482 | } |
1483 | |
1484 | static void |
1485 | ctk_cell_area_pack_default (CtkCellLayout *cell_layout, |
1486 | CtkCellRenderer *renderer, |
1487 | gboolean expand G_GNUC_UNUSED__attribute__ ((__unused__))) |
1488 | { |
1489 | ctk_cell_area_add (CTK_CELL_AREA (cell_layout)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_cell_area_get_type ())))))), renderer); |
1490 | } |
1491 | |
1492 | static void |
1493 | ctk_cell_area_clear (CtkCellLayout *cell_layout) |
1494 | { |
1495 | CtkCellArea *area = CTK_CELL_AREA (cell_layout)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_cell_area_get_type ())))))); |
1496 | GList *l, *cells = |
1497 | ctk_cell_layout_get_cells (cell_layout); |
1498 | |
1499 | for (l = cells; l; l = l->next) |
1500 | { |
1501 | CtkCellRenderer *renderer = l->data; |
1502 | ctk_cell_area_remove (area, renderer); |
1503 | } |
1504 | |
1505 | g_list_free (cells); |
1506 | } |
1507 | |
1508 | static void |
1509 | ctk_cell_area_add_attribute (CtkCellLayout *cell_layout, |
1510 | CtkCellRenderer *renderer, |
1511 | const gchar *attribute, |
1512 | gint column) |
1513 | { |
1514 | ctk_cell_area_attribute_connect (CTK_CELL_AREA (cell_layout)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_cell_area_get_type ())))))), |
1515 | renderer, attribute, column); |
1516 | } |
1517 | |
1518 | static void |
1519 | ctk_cell_area_set_cell_data_func (CtkCellLayout *cell_layout, |
1520 | CtkCellRenderer *renderer, |
1521 | CtkCellLayoutDataFunc func, |
1522 | gpointer func_data, |
1523 | GDestroyNotify destroy) |
1524 | { |
1525 | CtkCellArea *area = CTK_CELL_AREA (cell_layout)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_cell_area_get_type ())))))); |
1526 | |
1527 | _ctk_cell_area_set_cell_data_func_with_proxy (area, renderer, (GFunc)func, func_data, destroy, NULL((void*)0)); |
1528 | } |
1529 | |
1530 | static void |
1531 | ctk_cell_area_clear_attributes (CtkCellLayout *cell_layout, |
1532 | CtkCellRenderer *renderer) |
1533 | { |
1534 | CtkCellArea *area = CTK_CELL_AREA (cell_layout)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_cell_area_get_type ())))))); |
1535 | CtkCellAreaPrivate *priv = area->priv; |
1536 | CellInfo *info; |
1537 | |
1538 | info = g_hash_table_lookup (priv->cell_info, renderer); |
1539 | |
1540 | if (info) |
1541 | { |
1542 | g_slist_free_full (info->attributes, (GDestroyNotify)cell_attribute_free); |
1543 | info->attributes = NULL((void*)0); |
1544 | } |
1545 | } |
1546 | |
1547 | static void |
1548 | ctk_cell_area_reorder (CtkCellLayout *cell_layout, |
1549 | CtkCellRenderer *cell G_GNUC_UNUSED__attribute__ ((__unused__)), |
1550 | gint position G_GNUC_UNUSED__attribute__ ((__unused__))) |
1551 | { |
1552 | g_warning ("CtkCellLayout::reorder not implemented for '%s'", |
1553 | g_type_name (G_TYPE_FROM_INSTANCE (cell_layout)((((GTypeClass*) (((GTypeInstance*) (cell_layout))->g_class ))->g_type)))); |
1554 | } |
1555 | |
1556 | static gboolean |
1557 | accum_cells (CtkCellRenderer *renderer, |
1558 | GList **accum) |
1559 | { |
1560 | *accum = g_list_prepend (*accum, renderer); |
1561 | |
1562 | return FALSE(0); |
1563 | } |
1564 | |
1565 | static GList * |
1566 | ctk_cell_area_get_cells (CtkCellLayout *cell_layout) |
1567 | { |
1568 | GList *cells = NULL((void*)0); |
1569 | |
1570 | ctk_cell_area_foreach (CTK_CELL_AREA (cell_layout)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_cell_area_get_type ())))))), |
1571 | (CtkCellCallback)accum_cells, |
1572 | &cells); |
1573 | |
1574 | return g_list_reverse (cells); |
1575 | } |
1576 | |
1577 | static CtkCellArea * |
1578 | ctk_cell_area_get_area (CtkCellLayout *cell_layout) |
1579 | { |
1580 | return CTK_CELL_AREA (cell_layout)((((CtkCellArea*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((cell_layout)), ((ctk_cell_area_get_type ())))))); |
1581 | } |
1582 | |
1583 | /************************************************************* |
1584 | * CtkBuildableIface * |
1585 | *************************************************************/ |
1586 | static void |
1587 | ctk_cell_area_buildable_init (CtkBuildableIface *iface) |
1588 | { |
1589 | iface->add_child = _ctk_cell_layout_buildable_add_child; |
1590 | iface->custom_tag_start = _ctk_cell_layout_buildable_custom_tag_start; |
1591 | iface->custom_tag_end = ctk_cell_area_buildable_custom_tag_end; |
1592 | } |
1593 | |
1594 | static void |
1595 | ctk_cell_area_buildable_custom_tag_end (CtkBuildable *buildable, |
1596 | CtkBuilder *builder, |
1597 | GObject *child, |
1598 | const gchar *tagname, |
1599 | gpointer *data) |
1600 | { |
1601 | /* Just ignore the boolean return from here */ |
1602 | _ctk_cell_layout_buildable_custom_tag_end (buildable, builder, child, tagname, data); |
1603 | } |
1604 | |
1605 | /************************************************************* |
1606 | * API * |
1607 | *************************************************************/ |
1608 | |
1609 | /** |
1610 | * ctk_cell_area_add: |
1611 | * @area: a #CtkCellArea |
1612 | * @renderer: the #CtkCellRenderer to add to @area |
1613 | * |
1614 | * Adds @renderer to @area with the default child cell properties. |
1615 | * |
1616 | * Since: 3.0 |
1617 | */ |
1618 | void |
1619 | ctk_cell_area_add (CtkCellArea *area, |
1620 | CtkCellRenderer *renderer) |
1621 | { |
1622 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
1623 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
1624 | |
1625 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->add (area, renderer); |
1626 | } |
1627 | |
1628 | /** |
1629 | * ctk_cell_area_remove: |
1630 | * @area: a #CtkCellArea |
1631 | * @renderer: the #CtkCellRenderer to remove from @area |
1632 | * |
1633 | * Removes @renderer from @area. |
1634 | * |
1635 | * Since: 3.0 |
1636 | */ |
1637 | void |
1638 | ctk_cell_area_remove (CtkCellArea *area, |
1639 | CtkCellRenderer *renderer) |
1640 | { |
1641 | CtkCellAreaPrivate *priv; |
1642 | GList *renderers, *l; |
1643 | |
1644 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
1645 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
1646 | |
1647 | priv = area->priv; |
1648 | |
1649 | /* Remove any custom attributes and custom cell data func here first */ |
1650 | g_hash_table_remove (priv->cell_info, renderer); |
1651 | |
1652 | /* Remove focus siblings of this renderer */ |
1653 | g_hash_table_remove (priv->focus_siblings, renderer); |
1654 | |
1655 | /* Remove this renderer from any focus renderer's sibling list */ |
1656 | renderers = ctk_cell_layout_get_cells (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ()))))))); |
1657 | |
1658 | for (l = renderers; l; l = l->next) |
1659 | { |
1660 | CtkCellRenderer *focus_renderer = l->data; |
1661 | |
1662 | if (ctk_cell_area_is_focus_sibling (area, focus_renderer, renderer)) |
1663 | { |
1664 | ctk_cell_area_remove_focus_sibling (area, focus_renderer, renderer); |
1665 | break; |
1666 | } |
1667 | } |
1668 | |
1669 | g_list_free (renderers); |
1670 | |
1671 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->remove (area, renderer); |
1672 | } |
1673 | |
1674 | static gboolean |
1675 | get_has_renderer (CtkCellRenderer *renderer, |
1676 | HasRendererCheck *check) |
1677 | { |
1678 | if (renderer == check->renderer) |
1679 | check->has_renderer = TRUE(!(0)); |
1680 | |
1681 | return check->has_renderer; |
1682 | } |
1683 | |
1684 | /** |
1685 | * ctk_cell_area_has_renderer: |
1686 | * @area: a #CtkCellArea |
1687 | * @renderer: the #CtkCellRenderer to check |
1688 | * |
1689 | * Checks if @area contains @renderer. |
1690 | * |
1691 | * Returns: %TRUE if @renderer is in the @area. |
1692 | * |
1693 | * Since: 3.0 |
1694 | */ |
1695 | gboolean |
1696 | ctk_cell_area_has_renderer (CtkCellArea *area, |
1697 | CtkCellRenderer *renderer) |
1698 | { |
1699 | HasRendererCheck check = { renderer, FALSE(0) }; |
1700 | |
1701 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return ((0)); } } while (0); |
1702 | g_return_val_if_fail (CTK_IS_CELL_RENDERER (renderer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ((0)); } } while (0); |
1703 | |
1704 | ctk_cell_area_foreach (area, (CtkCellCallback)get_has_renderer, &check); |
1705 | |
1706 | return check.has_renderer; |
1707 | } |
1708 | |
1709 | /** |
1710 | * ctk_cell_area_foreach: |
1711 | * @area: a #CtkCellArea |
1712 | * @callback: (scope call): the #CtkCellCallback to call |
1713 | * @callback_data: user provided data pointer |
1714 | * |
1715 | * Calls @callback for every #CtkCellRenderer in @area. |
1716 | * |
1717 | * Since: 3.0 |
1718 | */ |
1719 | void |
1720 | ctk_cell_area_foreach (CtkCellArea *area, |
1721 | CtkCellCallback callback, |
1722 | gpointer callback_data) |
1723 | { |
1724 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
1725 | g_return_if_fail (callback != NULL)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "callback != NULL"); return ; } } while (0); |
1726 | |
1727 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->foreach (area, callback, callback_data); |
1728 | } |
1729 | |
1730 | /** |
1731 | * ctk_cell_area_foreach_alloc: |
1732 | * @area: a #CtkCellArea |
1733 | * @context: the #CtkCellAreaContext for this row of data. |
1734 | * @widget: the #CtkWidget that @area is rendering to |
1735 | * @cell_area: the @widget relative coordinates and size for @area |
1736 | * @background_area: the @widget relative coordinates of the background area |
1737 | * @callback: (scope call): the #CtkCellAllocCallback to call |
1738 | * @callback_data: user provided data pointer |
1739 | * |
1740 | * Calls @callback for every #CtkCellRenderer in @area with the |
1741 | * allocated rectangle inside @cell_area. |
1742 | * |
1743 | * Since: 3.0 |
1744 | */ |
1745 | void |
1746 | ctk_cell_area_foreach_alloc (CtkCellArea *area, |
1747 | CtkCellAreaContext *context, |
1748 | CtkWidget *widget, |
1749 | const CdkRectangle *cell_area, |
1750 | const CdkRectangle *background_area, |
1751 | CtkCellAllocCallback callback, |
1752 | gpointer callback_data) |
1753 | { |
1754 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
1755 | g_return_if_fail (CTK_IS_CELL_AREA_CONTEXT (context))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((context)); GType __t = ((ctk_cell_area_context_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_AREA_CONTEXT (context)"); return ; } } while (0); |
1756 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
1757 | g_return_if_fail (cell_area != NULL)do { if ((cell_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell_area != NULL"); return ; } } while (0); |
1758 | g_return_if_fail (callback != NULL)do { if ((callback != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "callback != NULL"); return ; } } while (0); |
1759 | |
1760 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->foreach_alloc (area, context, widget, |
1761 | cell_area, background_area, |
1762 | callback, callback_data); |
1763 | } |
1764 | |
1765 | /** |
1766 | * ctk_cell_area_event: |
1767 | * @area: a #CtkCellArea |
1768 | * @context: the #CtkCellAreaContext for this row of data. |
1769 | * @widget: the #CtkWidget that @area is rendering to |
1770 | * @event: the #CdkEvent to handle |
1771 | * @cell_area: the @widget relative coordinates for @area |
1772 | * @flags: the #CtkCellRendererState for @area in this row. |
1773 | * |
1774 | * Delegates event handling to a #CtkCellArea. |
1775 | * |
1776 | * Returns: %TRUE if the event was handled by @area. |
1777 | * |
1778 | * Since: 3.0 |
1779 | */ |
1780 | gint |
1781 | ctk_cell_area_event (CtkCellArea *area, |
1782 | CtkCellAreaContext *context, |
1783 | CtkWidget *widget, |
1784 | CdkEvent *event, |
1785 | const CdkRectangle *cell_area, |
1786 | CtkCellRendererState flags) |
1787 | { |
1788 | CtkCellAreaClass *class; |
1789 | |
1790 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (0); } } while (0); |
1791 | g_return_val_if_fail (CTK_IS_CELL_AREA_CONTEXT (context), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((context)); GType __t = ((ctk_cell_area_context_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_AREA_CONTEXT (context)"); return (0); } } while (0); |
1792 | g_return_val_if_fail (CTK_IS_WIDGET (widget), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return (0); } } while (0); |
1793 | g_return_val_if_fail (event != NULL, 0)do { if ((event != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "event != NULL"); return (0); } } while (0); |
1794 | g_return_val_if_fail (cell_area != NULL, 0)do { if ((cell_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell_area != NULL"); return (0); } } while (0); |
1795 | |
1796 | class = CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class )))); |
1797 | |
1798 | if (class->event) |
1799 | return class->event (area, context, widget, event, cell_area, flags); |
1800 | |
1801 | g_warning ("CtkCellAreaClass::event not implemented for '%s'", |
1802 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1803 | return 0; |
1804 | } |
1805 | |
1806 | /** |
1807 | * ctk_cell_area_render: |
1808 | * @area: a #CtkCellArea |
1809 | * @context: the #CtkCellAreaContext for this row of data. |
1810 | * @widget: the #CtkWidget that @area is rendering to |
1811 | * @cr: the #cairo_t to render with |
1812 | * @background_area: the @widget relative coordinates for @area’s background |
1813 | * @cell_area: the @widget relative coordinates for @area |
1814 | * @flags: the #CtkCellRendererState for @area in this row. |
1815 | * @paint_focus: whether @area should paint focus on focused cells for focused rows or not. |
1816 | * |
1817 | * Renders @area’s cells according to @area’s layout onto @widget at |
1818 | * the given coordinates. |
1819 | * |
1820 | * Since: 3.0 |
1821 | */ |
1822 | void |
1823 | ctk_cell_area_render (CtkCellArea *area, |
1824 | CtkCellAreaContext *context, |
1825 | CtkWidget *widget, |
1826 | cairo_t *cr, |
1827 | const CdkRectangle *background_area, |
1828 | const CdkRectangle *cell_area, |
1829 | CtkCellRendererState flags, |
1830 | gboolean paint_focus) |
1831 | { |
1832 | CtkCellAreaClass *class; |
1833 | |
1834 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
1835 | g_return_if_fail (CTK_IS_CELL_AREA_CONTEXT (context))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((context)); GType __t = ((ctk_cell_area_context_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_AREA_CONTEXT (context)"); return ; } } while (0); |
1836 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
1837 | g_return_if_fail (cr != NULL)do { if ((cr != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cr != NULL"); return; } } while (0); |
1838 | g_return_if_fail (background_area != NULL)do { if ((background_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "background_area != NULL" ); return; } } while (0); |
1839 | g_return_if_fail (cell_area != NULL)do { if ((cell_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell_area != NULL"); return ; } } while (0); |
1840 | |
1841 | class = CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class )))); |
1842 | |
1843 | if (class->render) |
1844 | class->render (area, context, widget, cr, background_area, cell_area, flags, paint_focus); |
1845 | else |
1846 | g_warning ("CtkCellAreaClass::render not implemented for '%s'", |
1847 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
1848 | } |
1849 | |
1850 | static gboolean |
1851 | get_cell_allocation (CtkCellRenderer *renderer, |
1852 | const CdkRectangle *cell_area, |
1853 | const CdkRectangle *cell_background G_GNUC_UNUSED__attribute__ ((__unused__)), |
1854 | RendererAllocationData *data) |
1855 | { |
1856 | if (data->renderer == renderer) |
1857 | data->allocation = *cell_area; |
1858 | |
1859 | return (data->renderer == renderer); |
1860 | } |
1861 | |
1862 | /** |
1863 | * ctk_cell_area_get_cell_allocation: |
1864 | * @area: a #CtkCellArea |
1865 | * @context: the #CtkCellAreaContext used to hold sizes for @area. |
1866 | * @widget: the #CtkWidget that @area is rendering on |
1867 | * @renderer: the #CtkCellRenderer to get the allocation for |
1868 | * @cell_area: the whole allocated area for @area in @widget |
1869 | * for this row |
1870 | * @allocation: (out): where to store the allocation for @renderer |
1871 | * |
1872 | * Derives the allocation of @renderer inside @area if @area |
1873 | * were to be renderered in @cell_area. |
1874 | * |
1875 | * Since: 3.0 |
1876 | */ |
1877 | void |
1878 | ctk_cell_area_get_cell_allocation (CtkCellArea *area, |
1879 | CtkCellAreaContext *context, |
1880 | CtkWidget *widget, |
1881 | CtkCellRenderer *renderer, |
1882 | const CdkRectangle *cell_area, |
1883 | CdkRectangle *allocation) |
1884 | { |
1885 | RendererAllocationData data = { renderer, { 0, } }; |
1886 | |
1887 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
1888 | g_return_if_fail (CTK_IS_CELL_AREA_CONTEXT (context))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((context)); GType __t = ((ctk_cell_area_context_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_AREA_CONTEXT (context)"); return ; } } while (0); |
1889 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
1890 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
1891 | g_return_if_fail (cell_area != NULL)do { if ((cell_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell_area != NULL"); return ; } } while (0); |
1892 | g_return_if_fail (allocation != NULL)do { if ((allocation != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "allocation != NULL"); return ; } } while (0); |
1893 | |
1894 | ctk_cell_area_foreach_alloc (area, context, widget, cell_area, cell_area, |
1895 | (CtkCellAllocCallback)get_cell_allocation, &data); |
1896 | |
1897 | *allocation = data.allocation; |
1898 | } |
1899 | |
1900 | static gboolean |
1901 | get_cell_by_position (CtkCellRenderer *renderer, |
1902 | const CdkRectangle *cell_area, |
1903 | const CdkRectangle *cell_background G_GNUC_UNUSED__attribute__ ((__unused__)), |
1904 | CellByPositionData *data) |
1905 | { |
1906 | if (data->x >= cell_area->x && data->x < cell_area->x + cell_area->width && |
1907 | data->y >= cell_area->y && data->y < cell_area->y + cell_area->height) |
1908 | { |
1909 | data->renderer = renderer; |
1910 | data->cell_area = *cell_area; |
1911 | } |
1912 | |
1913 | return (data->renderer != NULL((void*)0)); |
1914 | } |
1915 | |
1916 | /** |
1917 | * ctk_cell_area_get_cell_at_position: |
1918 | * @area: a #CtkCellArea |
1919 | * @context: the #CtkCellAreaContext used to hold sizes for @area. |
1920 | * @widget: the #CtkWidget that @area is rendering on |
1921 | * @cell_area: the whole allocated area for @area in @widget |
1922 | * for this row |
1923 | * @x: the x position |
1924 | * @y: the y position |
1925 | * @alloc_area: (out) (allow-none): where to store the inner allocated area of the |
1926 | * returned cell renderer, or %NULL. |
1927 | * |
1928 | * Gets the #CtkCellRenderer at @x and @y coordinates inside @area and optionally |
1929 | * returns the full cell allocation for it inside @cell_area. |
1930 | * |
1931 | * Returns: (transfer none): the #CtkCellRenderer at @x and @y. |
1932 | * |
1933 | * Since: 3.0 |
1934 | */ |
1935 | CtkCellRenderer * |
1936 | ctk_cell_area_get_cell_at_position (CtkCellArea *area, |
1937 | CtkCellAreaContext *context, |
1938 | CtkWidget *widget, |
1939 | const CdkRectangle *cell_area, |
1940 | gint x, |
1941 | gint y, |
1942 | CdkRectangle *alloc_area) |
1943 | { |
1944 | CellByPositionData data = { x, y, NULL((void*)0), { 0, } }; |
1945 | |
1946 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
1947 | g_return_val_if_fail (CTK_IS_CELL_AREA_CONTEXT (context), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((context)); GType __t = ((ctk_cell_area_context_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_AREA_CONTEXT (context)"); return (((void*)0)); } } while (0); |
1948 | g_return_val_if_fail (CTK_IS_WIDGET (widget), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return (((void*)0)); } } while (0); |
1949 | g_return_val_if_fail (cell_area != NULL, NULL)do { if ((cell_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell_area != NULL"); return (((void*)0)); } } while (0); |
1950 | g_return_val_if_fail (x >= cell_area->x && x <= cell_area->x + cell_area->width, NULL)do { if ((x >= cell_area->x && x <= cell_area ->x + cell_area->width)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "x >= cell_area->x && x <= cell_area->x + cell_area->width" ); return (((void*)0)); } } while (0); |
1951 | g_return_val_if_fail (y >= cell_area->y && y <= cell_area->y + cell_area->height, NULL)do { if ((y >= cell_area->y && y <= cell_area ->y + cell_area->height)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "y >= cell_area->y && y <= cell_area->y + cell_area->height" ); return (((void*)0)); } } while (0); |
1952 | |
1953 | ctk_cell_area_foreach_alloc (area, context, widget, cell_area, cell_area, |
1954 | (CtkCellAllocCallback)get_cell_by_position, &data); |
1955 | |
1956 | if (alloc_area) |
1957 | *alloc_area = data.cell_area; |
1958 | |
1959 | return data.renderer; |
1960 | } |
1961 | |
1962 | /************************************************************* |
1963 | * API: Geometry * |
1964 | *************************************************************/ |
1965 | /** |
1966 | * ctk_cell_area_create_context: |
1967 | * @area: a #CtkCellArea |
1968 | * |
1969 | * Creates a #CtkCellAreaContext to be used with @area for |
1970 | * all purposes. #CtkCellAreaContext stores geometry information |
1971 | * for rows for which it was operated on, it is important to use |
1972 | * the same context for the same row of data at all times (i.e. |
1973 | * one should render and handle events with the same #CtkCellAreaContext |
1974 | * which was used to request the size of those rows of data). |
1975 | * |
1976 | * Returns: (transfer full): a newly created #CtkCellAreaContext which can be used with @area. |
1977 | * |
1978 | * Since: 3.0 |
1979 | */ |
1980 | CtkCellAreaContext * |
1981 | ctk_cell_area_create_context (CtkCellArea *area) |
1982 | { |
1983 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
1984 | |
1985 | return CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->create_context (area); |
1986 | } |
1987 | |
1988 | /** |
1989 | * ctk_cell_area_copy_context: |
1990 | * @area: a #CtkCellArea |
1991 | * @context: the #CtkCellAreaContext to copy |
1992 | * |
1993 | * This is sometimes needed for cases where rows need to share |
1994 | * alignments in one orientation but may be separately grouped |
1995 | * in the opposing orientation. |
1996 | * |
1997 | * For instance, #CtkIconView creates all icons (rows) to have |
1998 | * the same width and the cells theirin to have the same |
1999 | * horizontal alignments. However each row of icons may have |
2000 | * a separate collective height. #CtkIconView uses this to |
2001 | * request the heights of each row based on a context which |
2002 | * was already used to request all the row widths that are |
2003 | * to be displayed. |
2004 | * |
2005 | * Returns: (transfer full): a newly created #CtkCellAreaContext copy of @context. |
2006 | * |
2007 | * Since: 3.0 |
2008 | */ |
2009 | CtkCellAreaContext * |
2010 | ctk_cell_area_copy_context (CtkCellArea *area, |
2011 | CtkCellAreaContext *context) |
2012 | { |
2013 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
2014 | g_return_val_if_fail (CTK_IS_CELL_AREA_CONTEXT (context), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((context)); GType __t = ((ctk_cell_area_context_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_AREA_CONTEXT (context)"); return (((void*)0)); } } while (0); |
2015 | |
2016 | return CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->copy_context (area, context); |
2017 | } |
2018 | |
2019 | /** |
2020 | * ctk_cell_area_get_request_mode: |
2021 | * @area: a #CtkCellArea |
2022 | * |
2023 | * Gets whether the area prefers a height-for-width layout |
2024 | * or a width-for-height layout. |
2025 | * |
2026 | * Returns: The #CtkSizeRequestMode preferred by @area. |
2027 | * |
2028 | * Since: 3.0 |
2029 | */ |
2030 | CtkSizeRequestMode |
2031 | ctk_cell_area_get_request_mode (CtkCellArea *area) |
2032 | { |
2033 | g_return_val_if_fail (CTK_IS_CELL_AREA (area),do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH ); } } while (0) |
2034 | CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (CTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH ); } } while (0); |
2035 | |
2036 | return CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->get_request_mode (area); |
2037 | } |
2038 | |
2039 | /** |
2040 | * ctk_cell_area_get_preferred_width: |
2041 | * @area: a #CtkCellArea |
2042 | * @context: the #CtkCellAreaContext to perform this request with |
2043 | * @widget: the #CtkWidget where @area will be rendering |
2044 | * @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL |
2045 | * @natural_width: (out) (allow-none): location to store the natural width, or %NULL |
2046 | * |
2047 | * Retrieves a cell area’s initial minimum and natural width. |
2048 | * |
2049 | * @area will store some geometrical information in @context along the way; |
2050 | * when requesting sizes over an arbitrary number of rows, it’s not important |
2051 | * to check the @minimum_width and @natural_width of this call but rather to |
2052 | * consult ctk_cell_area_context_get_preferred_width() after a series of |
2053 | * requests. |
2054 | * |
2055 | * Since: 3.0 |
2056 | */ |
2057 | void |
2058 | ctk_cell_area_get_preferred_width (CtkCellArea *area, |
2059 | CtkCellAreaContext *context, |
2060 | CtkWidget *widget, |
2061 | gint *minimum_width, |
2062 | gint *natural_width) |
2063 | { |
2064 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2065 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
2066 | |
2067 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->get_preferred_width (area, context, widget, |
2068 | minimum_width, natural_width); |
2069 | } |
2070 | |
2071 | /** |
2072 | * ctk_cell_area_get_preferred_height_for_width: |
2073 | * @area: a #CtkCellArea |
2074 | * @context: the #CtkCellAreaContext which has already been requested for widths. |
2075 | * @widget: the #CtkWidget where @area will be rendering |
2076 | * @width: the width for which to check the height of this area |
2077 | * @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL |
2078 | * @natural_height: (out) (allow-none): location to store the natural height, or %NULL |
2079 | * |
2080 | * Retrieves a cell area’s minimum and natural height if it would be given |
2081 | * the specified @width. |
2082 | * |
2083 | * @area stores some geometrical information in @context along the way |
2084 | * while calling ctk_cell_area_get_preferred_width(). It’s important to |
2085 | * perform a series of ctk_cell_area_get_preferred_width() requests with |
2086 | * @context first and then call ctk_cell_area_get_preferred_height_for_width() |
2087 | * on each cell area individually to get the height for width of each |
2088 | * fully requested row. |
2089 | * |
2090 | * If at some point, the width of a single row changes, it should be |
2091 | * requested with ctk_cell_area_get_preferred_width() again and then |
2092 | * the full width of the requested rows checked again with |
2093 | * ctk_cell_area_context_get_preferred_width(). |
2094 | * |
2095 | * Since: 3.0 |
2096 | */ |
2097 | void |
2098 | ctk_cell_area_get_preferred_height_for_width (CtkCellArea *area, |
2099 | CtkCellAreaContext *context, |
2100 | CtkWidget *widget, |
2101 | gint width, |
2102 | gint *minimum_height, |
2103 | gint *natural_height) |
2104 | { |
2105 | CtkCellAreaClass *class; |
2106 | |
2107 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2108 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
2109 | |
2110 | class = CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class )))); |
2111 | class->get_preferred_height_for_width (area, context, widget, width, minimum_height, natural_height); |
2112 | } |
2113 | |
2114 | |
2115 | /** |
2116 | * ctk_cell_area_get_preferred_height: |
2117 | * @area: a #CtkCellArea |
2118 | * @context: the #CtkCellAreaContext to perform this request with |
2119 | * @widget: the #CtkWidget where @area will be rendering |
2120 | * @minimum_height: (out) (allow-none): location to store the minimum height, or %NULL |
2121 | * @natural_height: (out) (allow-none): location to store the natural height, or %NULL |
2122 | * |
2123 | * Retrieves a cell area’s initial minimum and natural height. |
2124 | * |
2125 | * @area will store some geometrical information in @context along the way; |
2126 | * when requesting sizes over an arbitrary number of rows, it’s not important |
2127 | * to check the @minimum_height and @natural_height of this call but rather to |
2128 | * consult ctk_cell_area_context_get_preferred_height() after a series of |
2129 | * requests. |
2130 | * |
2131 | * Since: 3.0 |
2132 | */ |
2133 | void |
2134 | ctk_cell_area_get_preferred_height (CtkCellArea *area, |
2135 | CtkCellAreaContext *context, |
2136 | CtkWidget *widget, |
2137 | gint *minimum_height, |
2138 | gint *natural_height) |
2139 | { |
2140 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2141 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
2142 | |
2143 | CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->get_preferred_height (area, context, widget, |
2144 | minimum_height, natural_height); |
2145 | } |
2146 | |
2147 | /** |
2148 | * ctk_cell_area_get_preferred_width_for_height: |
2149 | * @area: a #CtkCellArea |
2150 | * @context: the #CtkCellAreaContext which has already been requested for widths. |
2151 | * @widget: the #CtkWidget where @area will be rendering |
2152 | * @height: the height for which to check the width of this area |
2153 | * @minimum_width: (out) (allow-none): location to store the minimum width, or %NULL |
2154 | * @natural_width: (out) (allow-none): location to store the natural width, or %NULL |
2155 | * |
2156 | * Retrieves a cell area’s minimum and natural width if it would be given |
2157 | * the specified @height. |
2158 | * |
2159 | * @area stores some geometrical information in @context along the way |
2160 | * while calling ctk_cell_area_get_preferred_height(). It’s important to |
2161 | * perform a series of ctk_cell_area_get_preferred_height() requests with |
2162 | * @context first and then call ctk_cell_area_get_preferred_width_for_height() |
2163 | * on each cell area individually to get the height for width of each |
2164 | * fully requested row. |
2165 | * |
2166 | * If at some point, the height of a single row changes, it should be |
2167 | * requested with ctk_cell_area_get_preferred_height() again and then |
2168 | * the full height of the requested rows checked again with |
2169 | * ctk_cell_area_context_get_preferred_height(). |
2170 | * |
2171 | * Since: 3.0 |
2172 | */ |
2173 | void |
2174 | ctk_cell_area_get_preferred_width_for_height (CtkCellArea *area, |
2175 | CtkCellAreaContext *context, |
2176 | CtkWidget *widget, |
2177 | gint height, |
2178 | gint *minimum_width, |
2179 | gint *natural_width) |
2180 | { |
2181 | CtkCellAreaClass *class; |
2182 | |
2183 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2184 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
2185 | |
2186 | class = CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class )))); |
2187 | class->get_preferred_width_for_height (area, context, widget, height, minimum_width, natural_width); |
2188 | } |
2189 | |
2190 | /************************************************************* |
2191 | * API: Attributes * |
2192 | *************************************************************/ |
2193 | |
2194 | /** |
2195 | * ctk_cell_area_attribute_connect: |
2196 | * @area: a #CtkCellArea |
2197 | * @renderer: the #CtkCellRenderer to connect an attribute for |
2198 | * @attribute: the attribute name |
2199 | * @column: the #CtkTreeModel column to fetch attribute values from |
2200 | * |
2201 | * Connects an @attribute to apply values from @column for the |
2202 | * #CtkTreeModel in use. |
2203 | * |
2204 | * Since: 3.0 |
2205 | */ |
2206 | void |
2207 | ctk_cell_area_attribute_connect (CtkCellArea *area, |
2208 | CtkCellRenderer *renderer, |
2209 | const gchar *attribute, |
2210 | gint column) |
2211 | { |
2212 | CtkCellAreaPrivate *priv; |
2213 | CellInfo *info; |
2214 | CellAttribute *cell_attribute; |
2215 | |
2216 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2217 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2218 | 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); |
2219 | g_return_if_fail (ctk_cell_area_has_renderer (area, renderer))do { if ((ctk_cell_area_has_renderer (area, renderer))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "ctk_cell_area_has_renderer (area, renderer)"); return; } } while (0); |
2220 | |
2221 | priv = area->priv; |
2222 | info = g_hash_table_lookup (priv->cell_info, renderer); |
2223 | |
2224 | if (!info) |
2225 | { |
2226 | info = cell_info_new (NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
2227 | |
2228 | g_hash_table_insert (priv->cell_info, renderer, info); |
2229 | } |
2230 | else |
2231 | { |
2232 | GSList *node; |
2233 | |
2234 | /* Check we are not adding the same attribute twice */ |
2235 | if ((node = g_slist_find_custom (info->attributes, attribute, |
2236 | (GCompareFunc)cell_attribute_find)) != NULL((void*)0)) |
2237 | { |
2238 | cell_attribute = node->data; |
2239 | |
2240 | g_warning ("Cannot connect attribute '%s' for cell renderer class '%s' " |
2241 | "since '%s' is already attributed to column %d", |
2242 | attribute, |
2243 | G_OBJECT_TYPE_NAME (renderer)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (renderer) )->g_class))->g_type))))), |
2244 | attribute, cell_attribute->column); |
2245 | return; |
2246 | } |
2247 | } |
2248 | |
2249 | cell_attribute = cell_attribute_new (renderer, attribute, column); |
2250 | |
2251 | if (!cell_attribute) |
2252 | { |
2253 | g_warning ("Cannot connect attribute '%s' for cell renderer class '%s' " |
2254 | "since attribute does not exist", |
2255 | attribute, |
2256 | G_OBJECT_TYPE_NAME (renderer)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (renderer) )->g_class))->g_type)))))); |
2257 | return; |
2258 | } |
2259 | |
2260 | info->attributes = g_slist_prepend (info->attributes, cell_attribute); |
2261 | } |
2262 | |
2263 | /** |
2264 | * ctk_cell_area_attribute_disconnect: |
2265 | * @area: a #CtkCellArea |
2266 | * @renderer: the #CtkCellRenderer to disconnect an attribute for |
2267 | * @attribute: the attribute name |
2268 | * |
2269 | * Disconnects @attribute for the @renderer in @area so that |
2270 | * attribute will no longer be updated with values from the |
2271 | * model. |
2272 | * |
2273 | * Since: 3.0 |
2274 | */ |
2275 | void |
2276 | ctk_cell_area_attribute_disconnect (CtkCellArea *area, |
2277 | CtkCellRenderer *renderer, |
2278 | const gchar *attribute) |
2279 | { |
2280 | CtkCellAreaPrivate *priv; |
2281 | CellInfo *info; |
2282 | CellAttribute *cell_attribute; |
2283 | GSList *node; |
2284 | |
2285 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2286 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2287 | 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); |
2288 | g_return_if_fail (ctk_cell_area_has_renderer (area, renderer))do { if ((ctk_cell_area_has_renderer (area, renderer))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "ctk_cell_area_has_renderer (area, renderer)"); return; } } while (0); |
2289 | |
2290 | priv = area->priv; |
2291 | info = g_hash_table_lookup (priv->cell_info, renderer); |
2292 | |
2293 | if (info) |
2294 | { |
2295 | node = g_slist_find_custom (info->attributes, attribute, |
2296 | (GCompareFunc)cell_attribute_find); |
2297 | if (node) |
2298 | { |
2299 | cell_attribute = node->data; |
2300 | |
2301 | cell_attribute_free (cell_attribute); |
2302 | |
2303 | info->attributes = g_slist_delete_link (info->attributes, node); |
2304 | } |
2305 | } |
2306 | } |
2307 | |
2308 | /** |
2309 | * ctk_cell_area_attribute_get_column: |
2310 | * @area: a #CtkCellArea |
2311 | * @renderer: a #CtkCellRenderer |
2312 | * @attribute: an attribute on the renderer |
2313 | * |
2314 | * Returns the model column that an attribute has been mapped to, |
2315 | * or -1 if the attribute is not mapped. |
2316 | * |
2317 | * Returns: the model column, or -1 |
2318 | * |
2319 | * Since: 3.14 |
2320 | */ |
2321 | gint |
2322 | ctk_cell_area_attribute_get_column (CtkCellArea *area, |
2323 | CtkCellRenderer *renderer, |
2324 | const gchar *attribute) |
2325 | { |
2326 | CtkCellAreaPrivate *priv; |
2327 | CellInfo *info; |
2328 | CellAttribute *cell_attribute; |
2329 | GSList *node; |
2330 | |
2331 | priv = area->priv; |
2332 | info = g_hash_table_lookup (priv->cell_info, renderer); |
2333 | |
2334 | if (info) |
2335 | { |
2336 | node = g_slist_find_custom (info->attributes, attribute, |
2337 | (GCompareFunc)cell_attribute_find); |
2338 | if (node) |
2339 | { |
2340 | cell_attribute = node->data; |
2341 | return cell_attribute->column; |
2342 | } |
2343 | } |
2344 | |
2345 | return -1; |
2346 | } |
2347 | |
2348 | /** |
2349 | * ctk_cell_area_apply_attributes: |
2350 | * @area: a #CtkCellArea |
2351 | * @tree_model: the #CtkTreeModel to pull values from |
2352 | * @iter: the #CtkTreeIter in @tree_model to apply values for |
2353 | * @is_expander: whether @iter has children |
2354 | * @is_expanded: whether @iter is expanded in the view and |
2355 | * children are visible |
2356 | * |
2357 | * Applies any connected attributes to the renderers in |
2358 | * @area by pulling the values from @tree_model. |
2359 | * |
2360 | * Since: 3.0 |
2361 | */ |
2362 | void |
2363 | ctk_cell_area_apply_attributes (CtkCellArea *area, |
2364 | CtkTreeModel *tree_model, |
2365 | CtkTreeIter *iter, |
2366 | gboolean is_expander, |
2367 | gboolean is_expanded) |
2368 | { |
2369 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2370 | g_return_if_fail (CTK_IS_TREE_MODEL (tree_model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tree_model)); GType __t = ((ctk_tree_model_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_TREE_MODEL (tree_model)"); return; } } while (0); |
2371 | g_return_if_fail (iter != NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter != NULL"); return; } } while (0); |
2372 | |
2373 | g_signal_emit (area, cell_area_signals[SIGNAL_APPLY_ATTRIBUTES], 0, |
2374 | tree_model, iter, is_expander, is_expanded); |
2375 | } |
2376 | |
2377 | /** |
2378 | * ctk_cell_area_get_current_path_string: |
2379 | * @area: a #CtkCellArea |
2380 | * |
2381 | * Gets the current #CtkTreePath string for the currently |
2382 | * applied #CtkTreeIter, this is implicitly updated when |
2383 | * ctk_cell_area_apply_attributes() is called and can be |
2384 | * used to interact with renderers from #CtkCellArea |
2385 | * subclasses. |
2386 | * |
2387 | * Returns: The current #CtkTreePath string for the current |
2388 | * attributes applied to @area. This string belongs to the area and |
2389 | * should not be freed. |
2390 | * |
2391 | * Since: 3.0 |
2392 | */ |
2393 | const gchar * |
2394 | ctk_cell_area_get_current_path_string (CtkCellArea *area) |
2395 | { |
2396 | CtkCellAreaPrivate *priv; |
2397 | |
2398 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
2399 | |
2400 | priv = area->priv; |
2401 | |
2402 | return priv->current_path; |
2403 | } |
2404 | |
2405 | |
2406 | /************************************************************* |
2407 | * API: Cell Properties * |
2408 | *************************************************************/ |
2409 | /** |
2410 | * ctk_cell_area_class_install_cell_property: |
2411 | * @aclass: a #CtkCellAreaClass |
2412 | * @property_id: the id for the property |
2413 | * @pspec: the #GParamSpec for the property |
2414 | * |
2415 | * Installs a cell property on a cell area class. |
2416 | * |
2417 | * Since: 3.0 |
2418 | */ |
2419 | void |
2420 | ctk_cell_area_class_install_cell_property (CtkCellAreaClass *aclass, |
2421 | guint property_id, |
2422 | GParamSpec *pspec) |
2423 | { |
2424 | g_return_if_fail (CTK_IS_CELL_AREA_CLASS (aclass))do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass *) ((aclass)); GType __t = ((ctk_cell_area_get_type ())); gboolean __r; if (!__class) __r = (0); else if (__class->g_type == __t) __r = (!(0)); else __r = g_type_check_class_is_a (__class , __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk" , ((const char*) (__func__)), "CTK_IS_CELL_AREA_CLASS (aclass)" ); return; } } while (0); |
2425 | g_return_if_fail (G_IS_PARAM_SPEC (pspec))do { if (((((g_type_check_instance_is_fundamentally_a ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2)))))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "G_IS_PARAM_SPEC (pspec)"); return; } } while (0); |
2426 | if (pspec->flags & G_PARAM_WRITABLE) |
2427 | g_return_if_fail (aclass->set_cell_property != NULL)do { if ((aclass->set_cell_property != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "aclass->set_cell_property != NULL"); return; } } while (0); |
2428 | if (pspec->flags & G_PARAM_READABLE) |
2429 | g_return_if_fail (aclass->get_cell_property != NULL)do { if ((aclass->get_cell_property != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "aclass->get_cell_property != NULL"); return; } } while (0); |
2430 | g_return_if_fail (property_id > 0)do { if ((property_id > 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "property_id > 0"); return ; } } while (0); |
2431 | g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0)do { if ((((pspec)->param_id) == 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "PARAM_SPEC_PARAM_ID (pspec) == 0" ); return; } } while (0); /* paranoid */ |
2432 | g_return_if_fail ((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0)do { if (((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY )) == 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0" ); return; } } while (0); |
2433 | |
2434 | if (g_param_spec_pool_lookup (cell_property_pool, pspec->name, G_OBJECT_CLASS_TYPE (aclass)((((GTypeClass*) (aclass))->g_type)), TRUE(!(0)))) |
2435 | { |
2436 | g_warning (G_STRLOC"ctkcellarea.c" ":" "2436" ": class '%s' already contains a cell property named '%s'", |
2437 | G_OBJECT_CLASS_NAME (aclass)(g_type_name (((((GTypeClass*) (aclass))->g_type)))), pspec->name); |
2438 | return; |
2439 | } |
2440 | g_param_spec_ref (pspec); |
2441 | g_param_spec_sink (pspec); |
2442 | PARAM_SPEC_SET_PARAM_ID (pspec, property_id)((pspec)->param_id = (property_id)); |
2443 | g_param_spec_pool_insert (cell_property_pool, pspec, G_OBJECT_CLASS_TYPE (aclass)((((GTypeClass*) (aclass))->g_type))); |
2444 | } |
2445 | |
2446 | /** |
2447 | * ctk_cell_area_class_find_cell_property: |
2448 | * @aclass: a #CtkCellAreaClass |
2449 | * @property_name: the name of the child property to find |
2450 | * |
2451 | * Finds a cell property of a cell area class by name. |
2452 | * |
2453 | * Returns: (transfer none): the #GParamSpec of the child property |
2454 | * or %NULL if @aclass has no child property with that name. |
2455 | * |
2456 | * Since: 3.0 |
2457 | */ |
2458 | GParamSpec* |
2459 | ctk_cell_area_class_find_cell_property (CtkCellAreaClass *aclass, |
2460 | const gchar *property_name) |
2461 | { |
2462 | g_return_val_if_fail (CTK_IS_CELL_AREA_CLASS (aclass), NULL)do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass *) ((aclass)); GType __t = ((ctk_cell_area_get_type ())); gboolean __r; if (!__class) __r = (0); else if (__class->g_type == __t) __r = (!(0)); else __r = g_type_check_class_is_a (__class , __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk" , ((const char*) (__func__)), "CTK_IS_CELL_AREA_CLASS (aclass)" ); return (((void*)0)); } } while (0); |
2463 | g_return_val_if_fail (property_name != NULL, NULL)do { if ((property_name != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "property_name != NULL") ; return (((void*)0)); } } while (0); |
2464 | |
2465 | return g_param_spec_pool_lookup (cell_property_pool, |
2466 | property_name, |
2467 | G_OBJECT_CLASS_TYPE (aclass)((((GTypeClass*) (aclass))->g_type)), |
2468 | TRUE(!(0))); |
2469 | } |
2470 | |
2471 | /** |
2472 | * ctk_cell_area_class_list_cell_properties: |
2473 | * @aclass: a #CtkCellAreaClass |
2474 | * @n_properties: (out): location to return the number of cell properties found |
2475 | * |
2476 | * Returns all cell properties of a cell area class. |
2477 | * |
2478 | * Returns: (array length=n_properties) (transfer container): a newly |
2479 | * allocated %NULL-terminated array of #GParamSpec*. The array |
2480 | * must be freed with g_free(). |
2481 | * |
2482 | * Since: 3.0 |
2483 | */ |
2484 | GParamSpec** |
2485 | ctk_cell_area_class_list_cell_properties (CtkCellAreaClass *aclass, |
2486 | guint *n_properties) |
2487 | { |
2488 | GParamSpec **pspecs; |
2489 | guint n; |
2490 | |
2491 | g_return_val_if_fail (CTK_IS_CELL_AREA_CLASS (aclass), NULL)do { if (((((__extension__ ({ GTypeClass *__class = (GTypeClass *) ((aclass)); GType __t = ((ctk_cell_area_get_type ())); gboolean __r; if (!__class) __r = (0); else if (__class->g_type == __t) __r = (!(0)); else __r = g_type_check_class_is_a (__class , __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk" , ((const char*) (__func__)), "CTK_IS_CELL_AREA_CLASS (aclass)" ); return (((void*)0)); } } while (0); |
2492 | |
2493 | pspecs = g_param_spec_pool_list (cell_property_pool, |
2494 | G_OBJECT_CLASS_TYPE (aclass)((((GTypeClass*) (aclass))->g_type)), |
2495 | &n); |
2496 | if (n_properties) |
2497 | *n_properties = n; |
2498 | |
2499 | return pspecs; |
2500 | } |
2501 | |
2502 | /** |
2503 | * ctk_cell_area_add_with_properties: |
2504 | * @area: a #CtkCellArea |
2505 | * @renderer: a #CtkCellRenderer to be placed inside @area |
2506 | * @first_prop_name: the name of the first cell property to set |
2507 | * @...: a %NULL-terminated list of property names and values, starting |
2508 | * with @first_prop_name |
2509 | * |
2510 | * Adds @renderer to @area, setting cell properties at the same time. |
2511 | * See ctk_cell_area_add() and ctk_cell_area_cell_set() for more details. |
2512 | * |
2513 | * Since: 3.0 |
2514 | */ |
2515 | void |
2516 | ctk_cell_area_add_with_properties (CtkCellArea *area, |
2517 | CtkCellRenderer *renderer, |
2518 | const gchar *first_prop_name, |
2519 | ...) |
2520 | { |
2521 | CtkCellAreaClass *class; |
2522 | |
2523 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2524 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2525 | |
2526 | class = CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class )))); |
2527 | |
2528 | if (class->add) |
2529 | { |
2530 | va_list var_args; |
2531 | |
2532 | class->add (area, renderer); |
2533 | |
2534 | va_start (var_args, first_prop_name)__builtin_va_start(var_args, first_prop_name); |
2535 | ctk_cell_area_cell_set_valist (area, renderer, first_prop_name, var_args); |
2536 | va_end (var_args)__builtin_va_end(var_args); |
2537 | } |
2538 | else |
2539 | g_warning ("CtkCellAreaClass::add not implemented for '%s'", |
2540 | g_type_name (G_TYPE_FROM_INSTANCE (area)((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type)))); |
2541 | } |
2542 | |
2543 | /** |
2544 | * ctk_cell_area_cell_set: |
2545 | * @area: a #CtkCellArea |
2546 | * @renderer: a #CtkCellRenderer which is a cell inside @area |
2547 | * @first_prop_name: the name of the first cell property to set |
2548 | * @...: a %NULL-terminated list of property names and values, starting |
2549 | * with @first_prop_name |
2550 | * |
2551 | * Sets one or more cell properties for @cell in @area. |
2552 | * |
2553 | * Since: 3.0 |
2554 | */ |
2555 | void |
2556 | ctk_cell_area_cell_set (CtkCellArea *area, |
2557 | CtkCellRenderer *renderer, |
2558 | const gchar *first_prop_name, |
2559 | ...) |
2560 | { |
2561 | va_list var_args; |
2562 | |
2563 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2564 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2565 | |
2566 | va_start (var_args, first_prop_name)__builtin_va_start(var_args, first_prop_name); |
2567 | ctk_cell_area_cell_set_valist (area, renderer, first_prop_name, var_args); |
2568 | va_end (var_args)__builtin_va_end(var_args); |
2569 | } |
2570 | |
2571 | /** |
2572 | * ctk_cell_area_cell_get: |
2573 | * @area: a #CtkCellArea |
2574 | * @renderer: a #CtkCellRenderer which is inside @area |
2575 | * @first_prop_name: the name of the first cell property to get |
2576 | * @...: return location for the first cell property, followed |
2577 | * optionally by more name/return location pairs, followed by %NULL |
2578 | * |
2579 | * Gets the values of one or more cell properties for @renderer in @area. |
2580 | * |
2581 | * Since: 3.0 |
2582 | */ |
2583 | void |
2584 | ctk_cell_area_cell_get (CtkCellArea *area, |
2585 | CtkCellRenderer *renderer, |
2586 | const gchar *first_prop_name, |
2587 | ...) |
2588 | { |
2589 | va_list var_args; |
2590 | |
2591 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2592 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2593 | |
2594 | va_start (var_args, first_prop_name)__builtin_va_start(var_args, first_prop_name); |
2595 | ctk_cell_area_cell_get_valist (area, renderer, first_prop_name, var_args); |
2596 | va_end (var_args)__builtin_va_end(var_args); |
2597 | } |
2598 | |
2599 | static inline void |
2600 | area_get_cell_property (CtkCellArea *area, |
2601 | CtkCellRenderer *renderer, |
2602 | GParamSpec *pspec, |
2603 | GValue *value) |
2604 | { |
2605 | CtkCellAreaClass *class = g_type_class_peek (pspec->owner_type); |
2606 | |
2607 | class->get_cell_property (area, renderer, PARAM_SPEC_PARAM_ID (pspec)((pspec)->param_id), value, pspec); |
2608 | } |
2609 | |
2610 | static inline void |
2611 | area_set_cell_property (CtkCellArea *area, |
2612 | CtkCellRenderer *renderer, |
2613 | GParamSpec *pspec, |
2614 | const GValue *value) |
2615 | { |
2616 | GValue tmp_value = G_VALUE_INIT{ 0, { { 0 } } }; |
2617 | CtkCellAreaClass *class = g_type_class_peek (pspec->owner_type); |
2618 | |
2619 | /* provide a copy to work from, convert (if necessary) and validate */ |
2620 | g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type )); |
2621 | if (!g_value_transform (value, &tmp_value)) |
2622 | g_warning ("unable to set cell property '%s' of type '%s' from value of type '%s'", |
2623 | pspec->name, |
2624 | g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type )), |
2625 | G_VALUE_TYPE_NAME (value)(g_type_name ((((GValue*) (value))->g_type)))); |
2626 | else if (g_param_value_validate (pspec, &tmp_value) && !(pspec->flags & G_PARAM_LAX_VALIDATION)) |
2627 | { |
2628 | gchar *contents = g_strdup_value_contents (value); |
2629 | |
2630 | g_warning ("value \"%s\" of type '%s' is invalid for property '%s' of type '%s'", |
2631 | contents, |
2632 | G_VALUE_TYPE_NAME (value)(g_type_name ((((GValue*) (value))->g_type))), |
2633 | pspec->name, |
2634 | g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type ))); |
2635 | g_free (contents); |
2636 | } |
2637 | else |
2638 | { |
2639 | class->set_cell_property (area, renderer, PARAM_SPEC_PARAM_ID (pspec)((pspec)->param_id), &tmp_value, pspec); |
2640 | } |
2641 | g_value_unset (&tmp_value); |
2642 | } |
2643 | |
2644 | /** |
2645 | * ctk_cell_area_cell_set_valist: |
2646 | * @area: a #CtkCellArea |
2647 | * @renderer: a #CtkCellRenderer which inside @area |
2648 | * @first_property_name: the name of the first cell property to set |
2649 | * @var_args: a %NULL-terminated list of property names and values, starting |
2650 | * with @first_prop_name |
2651 | * |
2652 | * Sets one or more cell properties for @renderer in @area. |
2653 | * |
2654 | * Since: 3.0 |
2655 | */ |
2656 | void |
2657 | ctk_cell_area_cell_set_valist (CtkCellArea *area, |
2658 | CtkCellRenderer *renderer, |
2659 | const gchar *first_property_name, |
2660 | va_list var_args) |
2661 | { |
2662 | const gchar *name; |
2663 | |
2664 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2665 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2666 | |
2667 | name = first_property_name; |
2668 | while (name) |
2669 | { |
2670 | GValue value = G_VALUE_INIT{ 0, { { 0 } } }; |
2671 | gchar *error = NULL((void*)0); |
2672 | GParamSpec *pspec = |
2673 | g_param_spec_pool_lookup (cell_property_pool, name, |
2674 | G_OBJECT_TYPE (area)(((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type))), TRUE(!(0))); |
2675 | if (!pspec) |
2676 | { |
2677 | g_warning ("%s: cell area class '%s' has no cell property named '%s'", |
2678 | G_STRLOC"ctkcellarea.c" ":" "2678", G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type))))), name); |
2679 | break; |
2680 | } |
2681 | if (!(pspec->flags & G_PARAM_WRITABLE)) |
2682 | { |
2683 | g_warning ("%s: cell property '%s' of cell area class '%s' is not writable", |
2684 | G_STRLOC"ctkcellarea.c" ":" "2684", pspec->name, G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type)))))); |
2685 | break; |
2686 | } |
2687 | |
2688 | G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec),do { GTypeValueTable *g_vci_vtab; do { GValue *g_vci_val = (& value); guint g_vci_flags = (0); const gchar *g_vci_collect_format ; GTypeCValue g_vci_cvalues[(8)] = { { 0, }, }; guint g_vci_n_values = 0; g_vci_vtab = g_type_value_table_peek ((((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pspec )), (((GType) ((19) << (2))))))))->value_type)); g_vci_collect_format = g_vci_vtab->collect_format; g_vci_val->g_type = (((( (GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type ); while (*g_vci_collect_format) { GTypeCValue *g_vci_cvalue = g_vci_cvalues + g_vci_n_values++; switch (*g_vci_collect_format ++) { case G_VALUE_COLLECT_INT: g_vci_cvalue->v_int = __builtin_va_arg ((var_args), gint); break; case G_VALUE_COLLECT_LONG: g_vci_cvalue ->v_long = __builtin_va_arg((var_args), glong); break; case G_VALUE_COLLECT_INT64: g_vci_cvalue->v_int64 = __builtin_va_arg ((var_args), gint64); break; case G_VALUE_COLLECT_DOUBLE: g_vci_cvalue ->v_double = __builtin_va_arg((var_args), gdouble); break; case G_VALUE_COLLECT_POINTER: g_vci_cvalue->v_pointer = __builtin_va_arg ((var_args), gpointer); break; default: do { g_assertion_message_expr ("Ctk", "ctkcellarea.c", 2689, ((const char*) (__func__)), ( (void*)0)); } while (0); } } *(&error) = g_vci_vtab->collect_value (g_vci_val, g_vci_n_values, g_vci_cvalues, g_vci_flags); } while (0); } while (0) |
2689 | var_args, 0, &error)do { GTypeValueTable *g_vci_vtab; do { GValue *g_vci_val = (& value); guint g_vci_flags = (0); const gchar *g_vci_collect_format ; GTypeCValue g_vci_cvalues[(8)] = { { 0, }, }; guint g_vci_n_values = 0; g_vci_vtab = g_type_value_table_peek ((((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pspec )), (((GType) ((19) << (2))))))))->value_type)); g_vci_collect_format = g_vci_vtab->collect_format; g_vci_val->g_type = (((( (GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type ); while (*g_vci_collect_format) { GTypeCValue *g_vci_cvalue = g_vci_cvalues + g_vci_n_values++; switch (*g_vci_collect_format ++) { case G_VALUE_COLLECT_INT: g_vci_cvalue->v_int = __builtin_va_arg ((var_args), gint); break; case G_VALUE_COLLECT_LONG: g_vci_cvalue ->v_long = __builtin_va_arg((var_args), glong); break; case G_VALUE_COLLECT_INT64: g_vci_cvalue->v_int64 = __builtin_va_arg ((var_args), gint64); break; case G_VALUE_COLLECT_DOUBLE: g_vci_cvalue ->v_double = __builtin_va_arg((var_args), gdouble); break; case G_VALUE_COLLECT_POINTER: g_vci_cvalue->v_pointer = __builtin_va_arg ((var_args), gpointer); break; default: do { g_assertion_message_expr ("Ctk", "ctkcellarea.c", 2689, ((const char*) (__func__)), ( (void*)0)); } while (0); } } *(&error) = g_vci_vtab->collect_value (g_vci_val, g_vci_n_values, g_vci_cvalues, g_vci_flags); } while (0); } while (0); |
2690 | if (error) |
2691 | { |
2692 | g_warning ("%s: %s", G_STRLOC"ctkcellarea.c" ":" "2692", error); |
2693 | g_free (error); |
2694 | |
2695 | /* we purposely leak the value here, it might not be |
2696 | * in a sane state if an error condition occoured |
2697 | */ |
2698 | break; |
2699 | } |
2700 | area_set_cell_property (area, renderer, pspec, &value); |
2701 | g_value_unset (&value); |
2702 | name = va_arg (var_args, gchar*)__builtin_va_arg(var_args, gchar*); |
2703 | } |
2704 | } |
2705 | |
2706 | /** |
2707 | * ctk_cell_area_cell_get_valist: |
2708 | * @area: a #CtkCellArea |
2709 | * @renderer: a #CtkCellRenderer inside @area |
2710 | * @first_property_name: the name of the first property to get |
2711 | * @var_args: return location for the first property, followed |
2712 | * optionally by more name/return location pairs, followed by %NULL |
2713 | * |
2714 | * Gets the values of one or more cell properties for @renderer in @area. |
2715 | * |
2716 | * Since: 3.0 |
2717 | */ |
2718 | void |
2719 | ctk_cell_area_cell_get_valist (CtkCellArea *area, |
2720 | CtkCellRenderer *renderer, |
2721 | const gchar *first_property_name, |
2722 | va_list var_args) |
2723 | { |
2724 | const gchar *name; |
2725 | |
2726 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2727 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2728 | |
2729 | name = first_property_name; |
2730 | while (name) |
2731 | { |
2732 | GValue value = G_VALUE_INIT{ 0, { { 0 } } }; |
2733 | GParamSpec *pspec; |
2734 | gchar *error; |
2735 | |
2736 | pspec = g_param_spec_pool_lookup (cell_property_pool, name, |
2737 | G_OBJECT_TYPE (area)(((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type))), TRUE(!(0))); |
2738 | if (!pspec) |
2739 | { |
2740 | g_warning ("%s: cell area class '%s' has no cell property named '%s'", |
2741 | G_STRLOC"ctkcellarea.c" ":" "2741", G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type))))), name); |
2742 | break; |
2743 | } |
2744 | if (!(pspec->flags & G_PARAM_READABLE)) |
2745 | { |
2746 | g_warning ("%s: cell property '%s' of cell area class '%s' is not readable", |
2747 | G_STRLOC"ctkcellarea.c" ":" "2747", pspec->name, G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type)))))); |
2748 | break; |
2749 | } |
2750 | |
2751 | g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type )); |
2752 | area_get_cell_property (area, renderer, pspec, &value); |
2753 | G_VALUE_LCOPY (&value, var_args, 0, &error)do { const GValue *g_vl_value = (&value); guint g_vl_flags = (0); GType g_vl_value_type = (((GValue*) (g_vl_value))-> g_type); GTypeValueTable *g_vl_vtable = g_type_value_table_peek (g_vl_value_type); const gchar *g_vl_lcopy_format = g_vl_vtable ->lcopy_format; GTypeCValue g_vl_cvalues[(8)] = { { 0, }, } ; guint g_vl_n_values = 0; while (*g_vl_lcopy_format) { GTypeCValue *g_vl_cvalue = g_vl_cvalues + g_vl_n_values++; switch (*g_vl_lcopy_format ++) { case G_VALUE_COLLECT_INT: g_vl_cvalue->v_int = __builtin_va_arg ((var_args), gint); break; case G_VALUE_COLLECT_LONG: g_vl_cvalue ->v_long = __builtin_va_arg((var_args), glong); break; case G_VALUE_COLLECT_INT64: g_vl_cvalue->v_int64 = __builtin_va_arg ((var_args), gint64); break; case G_VALUE_COLLECT_DOUBLE: g_vl_cvalue ->v_double = __builtin_va_arg((var_args), gdouble); break; case G_VALUE_COLLECT_POINTER: g_vl_cvalue->v_pointer = __builtin_va_arg ((var_args), gpointer); break; default: do { g_assertion_message_expr ("Ctk", "ctkcellarea.c", 2753, ((const char*) (__func__)), ( (void*)0)); } while (0); } } *(&error) = g_vl_vtable-> lcopy_value (g_vl_value, g_vl_n_values, g_vl_cvalues, g_vl_flags ); } while (0); |
2754 | if (error) |
2755 | { |
2756 | g_warning ("%s: %s", G_STRLOC"ctkcellarea.c" ":" "2756", error); |
2757 | g_free (error); |
2758 | g_value_unset (&value); |
2759 | break; |
2760 | } |
2761 | g_value_unset (&value); |
2762 | name = va_arg (var_args, gchar*)__builtin_va_arg(var_args, gchar*); |
2763 | } |
2764 | } |
2765 | |
2766 | /** |
2767 | * ctk_cell_area_cell_set_property: |
2768 | * @area: a #CtkCellArea |
2769 | * @renderer: a #CtkCellRenderer inside @area |
2770 | * @property_name: the name of the cell property to set |
2771 | * @value: the value to set the cell property to |
2772 | * |
2773 | * Sets a cell property for @renderer in @area. |
2774 | * |
2775 | * Since: 3.0 |
2776 | */ |
2777 | void |
2778 | ctk_cell_area_cell_set_property (CtkCellArea *area, |
2779 | CtkCellRenderer *renderer, |
2780 | const gchar *property_name, |
2781 | const GValue *value) |
2782 | { |
2783 | GParamSpec *pspec; |
2784 | |
2785 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2786 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2787 | g_return_if_fail (property_name != NULL)do { if ((property_name != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "property_name != NULL") ; return; } } while (0); |
2788 | g_return_if_fail (G_IS_VALUE (value))do { if (((((g_type_check_value ((GValue*) (value))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "G_IS_VALUE (value)"); return; } } while (0); |
2789 | |
2790 | pspec = g_param_spec_pool_lookup (cell_property_pool, property_name, |
2791 | G_OBJECT_TYPE (area)(((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type))), TRUE(!(0))); |
2792 | if (!pspec) |
2793 | g_warning ("%s: cell area class '%s' has no cell property named '%s'", |
2794 | G_STRLOC"ctkcellarea.c" ":" "2794", G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type))))), property_name); |
2795 | else if (!(pspec->flags & G_PARAM_WRITABLE)) |
2796 | g_warning ("%s: cell property '%s' of cell area class '%s' is not writable", |
2797 | G_STRLOC"ctkcellarea.c" ":" "2797", pspec->name, G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type)))))); |
2798 | else |
2799 | { |
2800 | area_set_cell_property (area, renderer, pspec, value); |
2801 | } |
2802 | } |
2803 | |
2804 | /** |
2805 | * ctk_cell_area_cell_get_property: |
2806 | * @area: a #CtkCellArea |
2807 | * @renderer: a #CtkCellRenderer inside @area |
2808 | * @property_name: the name of the property to get |
2809 | * @value: a location to return the value |
2810 | * |
2811 | * Gets the value of a cell property for @renderer in @area. |
2812 | * |
2813 | * Since: 3.0 |
2814 | */ |
2815 | void |
2816 | ctk_cell_area_cell_get_property (CtkCellArea *area, |
2817 | CtkCellRenderer *renderer, |
2818 | const gchar *property_name, |
2819 | GValue *value) |
2820 | { |
2821 | GParamSpec *pspec; |
2822 | |
2823 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2824 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
2825 | g_return_if_fail (property_name != NULL)do { if ((property_name != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "property_name != NULL") ; return; } } while (0); |
2826 | g_return_if_fail (G_IS_VALUE (value))do { if (((((g_type_check_value ((GValue*) (value))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "G_IS_VALUE (value)"); return; } } while (0); |
2827 | |
2828 | pspec = g_param_spec_pool_lookup (cell_property_pool, property_name, |
2829 | G_OBJECT_TYPE (area)(((((GTypeClass*) (((GTypeInstance*) (area))->g_class))-> g_type))), TRUE(!(0))); |
2830 | if (!pspec) |
2831 | g_warning ("%s: cell area class '%s' has no cell property named '%s'", |
2832 | G_STRLOC"ctkcellarea.c" ":" "2832", G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type))))), property_name); |
2833 | else if (!(pspec->flags & G_PARAM_READABLE)) |
2834 | g_warning ("%s: cell property '%s' of cell area class '%s' is not readable", |
2835 | G_STRLOC"ctkcellarea.c" ":" "2835", pspec->name, G_OBJECT_TYPE_NAME (area)(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (area))-> g_class))->g_type)))))); |
2836 | else |
2837 | { |
2838 | GValue *prop_value, tmp_value = G_VALUE_INIT{ 0, { { 0 } } }; |
2839 | |
2840 | /* auto-conversion of the callers value type |
2841 | */ |
2842 | if (G_VALUE_TYPE (value)(((GValue*) (value))->g_type) == G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type )) |
2843 | { |
2844 | g_value_reset (value); |
2845 | prop_value = value; |
2846 | } |
2847 | else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type ), G_VALUE_TYPE (value)(((GValue*) (value))->g_type))) |
2848 | { |
2849 | g_warning ("can't retrieve cell property '%s' of type '%s' as value of type '%s'", |
2850 | pspec->name, |
2851 | g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type )), |
2852 | G_VALUE_TYPE_NAME (value)(g_type_name ((((GValue*) (value))->g_type)))); |
2853 | return; |
2854 | } |
2855 | else |
2856 | { |
2857 | g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)(((((GParamSpec*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pspec)), (((GType) ((19) << (2))))))))->value_type )); |
2858 | prop_value = &tmp_value; |
2859 | } |
2860 | |
2861 | area_get_cell_property (area, renderer, pspec, prop_value); |
2862 | |
2863 | if (prop_value != value) |
2864 | { |
2865 | g_value_transform (prop_value, value); |
2866 | g_value_unset (&tmp_value); |
2867 | } |
2868 | } |
2869 | } |
2870 | |
2871 | /************************************************************* |
2872 | * API: Focus * |
2873 | *************************************************************/ |
2874 | |
2875 | /** |
2876 | * ctk_cell_area_is_activatable: |
2877 | * @area: a #CtkCellArea |
2878 | * |
2879 | * Returns whether the area can do anything when activated, |
2880 | * after applying new attributes to @area. |
2881 | * |
2882 | * Returns: whether @area can do anything when activated. |
2883 | * |
2884 | * Since: 3.0 |
2885 | */ |
2886 | gboolean |
2887 | ctk_cell_area_is_activatable (CtkCellArea *area) |
2888 | { |
2889 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return ((0)); } } while (0); |
2890 | |
2891 | return CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->is_activatable (area); |
2892 | } |
2893 | |
2894 | /** |
2895 | * ctk_cell_area_focus: |
2896 | * @area: a #CtkCellArea |
2897 | * @direction: the #CtkDirectionType |
2898 | * |
2899 | * This should be called by the @area’s owning layout widget |
2900 | * when focus is to be passed to @area, or moved within @area |
2901 | * for a given @direction and row data. |
2902 | * |
2903 | * Implementing #CtkCellArea classes should implement this |
2904 | * method to receive and navigate focus in its own way particular |
2905 | * to how it lays out cells. |
2906 | * |
2907 | * Returns: %TRUE if focus remains inside @area as a result of this call. |
2908 | * |
2909 | * Since: 3.0 |
2910 | */ |
2911 | gboolean |
2912 | ctk_cell_area_focus (CtkCellArea *area, |
2913 | CtkDirectionType direction) |
2914 | { |
2915 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return ((0)); } } while (0); |
2916 | |
2917 | return CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->focus (area, direction); |
2918 | } |
2919 | |
2920 | /** |
2921 | * ctk_cell_area_activate: |
2922 | * @area: a #CtkCellArea |
2923 | * @context: the #CtkCellAreaContext in context with the current row data |
2924 | * @widget: the #CtkWidget that @area is rendering on |
2925 | * @cell_area: the size and location of @area relative to @widget’s allocation |
2926 | * @flags: the #CtkCellRendererState flags for @area for this row of data. |
2927 | * @edit_only: if %TRUE then only cell renderers that are %CTK_CELL_RENDERER_MODE_EDITABLE |
2928 | * will be activated. |
2929 | * |
2930 | * Activates @area, usually by activating the currently focused |
2931 | * cell, however some subclasses which embed widgets in the area |
2932 | * can also activate a widget if it currently has the focus. |
2933 | * |
2934 | * Returns: Whether @area was successfully activated. |
2935 | * |
2936 | * Since: 3.0 |
2937 | */ |
2938 | gboolean |
2939 | ctk_cell_area_activate (CtkCellArea *area, |
2940 | CtkCellAreaContext *context, |
2941 | CtkWidget *widget, |
2942 | const CdkRectangle *cell_area, |
2943 | CtkCellRendererState flags, |
2944 | gboolean edit_only) |
2945 | { |
2946 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return ((0)); } } while (0); |
2947 | |
2948 | return CTK_CELL_AREA_GET_CLASS (area)((((CtkCellAreaClass*) (((GTypeInstance*) ((area)))->g_class ))))->activate (area, context, widget, cell_area, flags, edit_only); |
2949 | } |
2950 | |
2951 | |
2952 | /** |
2953 | * ctk_cell_area_set_focus_cell: |
2954 | * @area: a #CtkCellArea |
2955 | * @renderer: the #CtkCellRenderer to give focus to |
2956 | * |
2957 | * Explicitly sets the currently focused cell to @renderer. |
2958 | * |
2959 | * This is generally called by implementations of |
2960 | * #CtkCellAreaClass.focus() or #CtkCellAreaClass.event(), |
2961 | * however it can also be used to implement functions such |
2962 | * as ctk_tree_view_set_cursor_on_cell(). |
2963 | * |
2964 | * Since: 3.0 |
2965 | */ |
2966 | void |
2967 | ctk_cell_area_set_focus_cell (CtkCellArea *area, |
2968 | CtkCellRenderer *renderer) |
2969 | { |
2970 | CtkCellAreaPrivate *priv; |
2971 | |
2972 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
2973 | g_return_if_fail (renderer == NULL || CTK_IS_CELL_RENDERER (renderer))do { if ((renderer == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((renderer)); 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__)), "renderer == NULL || CTK_IS_CELL_RENDERER (renderer)" ); return; } } while (0); |
2974 | |
2975 | priv = area->priv; |
2976 | |
2977 | if (priv->focus_cell != renderer) |
2978 | { |
2979 | if (priv->focus_cell) |
2980 | g_object_unref (priv->focus_cell); |
2981 | |
2982 | priv->focus_cell = renderer; |
2983 | |
2984 | if (priv->focus_cell) |
2985 | g_object_ref (priv->focus_cell)((__typeof__ (priv->focus_cell)) (g_object_ref) (priv-> focus_cell)); |
2986 | |
2987 | g_object_notify (G_OBJECT (area)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), (((GType) ((20) << (2)))))))), "focus-cell"); |
2988 | } |
2989 | |
2990 | /* Signal that the current focus renderer for this path changed |
2991 | * (it may be that the focus cell did not change, but the row |
2992 | * may have changed so we need to signal it) */ |
2993 | g_signal_emit (area, cell_area_signals[SIGNAL_FOCUS_CHANGED], 0, |
2994 | priv->focus_cell, priv->current_path); |
2995 | |
2996 | } |
2997 | |
2998 | /** |
2999 | * ctk_cell_area_get_focus_cell: |
3000 | * @area: a #CtkCellArea |
3001 | * |
3002 | * Retrieves the currently focused cell for @area |
3003 | * |
3004 | * Returns: (transfer none): the currently focused cell in @area. |
3005 | * |
3006 | * Since: 3.0 |
3007 | */ |
3008 | CtkCellRenderer * |
3009 | ctk_cell_area_get_focus_cell (CtkCellArea *area) |
3010 | { |
3011 | CtkCellAreaPrivate *priv; |
3012 | |
3013 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
3014 | |
3015 | priv = area->priv; |
3016 | |
3017 | return priv->focus_cell; |
3018 | } |
3019 | |
3020 | |
3021 | /************************************************************* |
3022 | * API: Focus Siblings * |
3023 | *************************************************************/ |
3024 | |
3025 | /** |
3026 | * ctk_cell_area_add_focus_sibling: |
3027 | * @area: a #CtkCellArea |
3028 | * @renderer: the #CtkCellRenderer expected to have focus |
3029 | * @sibling: the #CtkCellRenderer to add to @renderer’s focus area |
3030 | * |
3031 | * Adds @sibling to @renderer’s focusable area, focus will be drawn |
3032 | * around @renderer and all of its siblings if @renderer can |
3033 | * focus for a given row. |
3034 | * |
3035 | * Events handled by focus siblings can also activate the given |
3036 | * focusable @renderer. |
3037 | * |
3038 | * Since: 3.0 |
3039 | */ |
3040 | void |
3041 | ctk_cell_area_add_focus_sibling (CtkCellArea *area, |
3042 | CtkCellRenderer *renderer, |
3043 | CtkCellRenderer *sibling) |
3044 | { |
3045 | CtkCellAreaPrivate *priv; |
3046 | GList *siblings; |
3047 | |
3048 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3049 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
3050 | g_return_if_fail (CTK_IS_CELL_RENDERER (sibling))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((sibling)); 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 (sibling)"); return; } } while (0); |
3051 | g_return_if_fail (renderer != sibling)do { if ((renderer != sibling)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "renderer != sibling"); return ; } } while (0); |
3052 | g_return_if_fail (ctk_cell_area_has_renderer (area, renderer))do { if ((ctk_cell_area_has_renderer (area, renderer))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "ctk_cell_area_has_renderer (area, renderer)"); return; } } while (0); |
3053 | g_return_if_fail (ctk_cell_area_has_renderer (area, sibling))do { if ((ctk_cell_area_has_renderer (area, sibling))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "ctk_cell_area_has_renderer (area, sibling)"); return; } } while (0); |
3054 | g_return_if_fail (!ctk_cell_area_is_focus_sibling (area, renderer, sibling))do { if ((!ctk_cell_area_is_focus_sibling (area, renderer, sibling ))) { } else { g_return_if_fail_warning ("Ctk", ((const char* ) (__func__)), "!ctk_cell_area_is_focus_sibling (area, renderer, sibling)" ); return; } } while (0); |
3055 | |
3056 | /* XXX We should also check that sibling is not in any other renderer's sibling |
3057 | * list already, a renderer can be sibling of only one focusable renderer |
3058 | * at a time. |
3059 | */ |
3060 | |
3061 | priv = area->priv; |
3062 | |
3063 | siblings = g_hash_table_lookup (priv->focus_siblings, renderer); |
3064 | |
3065 | if (siblings) |
3066 | siblings = g_list_append (siblings, sibling); |
Value stored to 'siblings' is never read | |
3067 | else |
3068 | { |
3069 | siblings = g_list_append (siblings, sibling); |
3070 | g_hash_table_insert (priv->focus_siblings, renderer, siblings); |
3071 | } |
3072 | } |
3073 | |
3074 | /** |
3075 | * ctk_cell_area_remove_focus_sibling: |
3076 | * @area: a #CtkCellArea |
3077 | * @renderer: the #CtkCellRenderer expected to have focus |
3078 | * @sibling: the #CtkCellRenderer to remove from @renderer’s focus area |
3079 | * |
3080 | * Removes @sibling from @renderer’s focus sibling list |
3081 | * (see ctk_cell_area_add_focus_sibling()). |
3082 | * |
3083 | * Since: 3.0 |
3084 | */ |
3085 | void |
3086 | ctk_cell_area_remove_focus_sibling (CtkCellArea *area, |
3087 | CtkCellRenderer *renderer, |
3088 | CtkCellRenderer *sibling) |
3089 | { |
3090 | CtkCellAreaPrivate *priv; |
3091 | GList *siblings; |
3092 | |
3093 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3094 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
3095 | g_return_if_fail (CTK_IS_CELL_RENDERER (sibling))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((sibling)); 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 (sibling)"); return; } } while (0); |
3096 | g_return_if_fail (ctk_cell_area_is_focus_sibling (area, renderer, sibling))do { if ((ctk_cell_area_is_focus_sibling (area, renderer, sibling ))) { } else { g_return_if_fail_warning ("Ctk", ((const char* ) (__func__)), "ctk_cell_area_is_focus_sibling (area, renderer, sibling)" ); return; } } while (0); |
3097 | |
3098 | priv = area->priv; |
3099 | |
3100 | siblings = g_hash_table_lookup (priv->focus_siblings, renderer); |
3101 | |
3102 | siblings = g_list_copy (siblings); |
3103 | siblings = g_list_remove (siblings, sibling); |
3104 | |
3105 | if (!siblings) |
3106 | g_hash_table_remove (priv->focus_siblings, renderer); |
3107 | else |
3108 | g_hash_table_insert (priv->focus_siblings, renderer, siblings); |
3109 | } |
3110 | |
3111 | /** |
3112 | * ctk_cell_area_is_focus_sibling: |
3113 | * @area: a #CtkCellArea |
3114 | * @renderer: the #CtkCellRenderer expected to have focus |
3115 | * @sibling: the #CtkCellRenderer to check against @renderer’s sibling list |
3116 | * |
3117 | * Returns whether @sibling is one of @renderer’s focus siblings |
3118 | * (see ctk_cell_area_add_focus_sibling()). |
3119 | * |
3120 | * Returns: %TRUE if @sibling is a focus sibling of @renderer |
3121 | * |
3122 | * Since: 3.0 |
3123 | */ |
3124 | gboolean |
3125 | ctk_cell_area_is_focus_sibling (CtkCellArea *area, |
3126 | CtkCellRenderer *renderer, |
3127 | CtkCellRenderer *sibling) |
3128 | { |
3129 | CtkCellAreaPrivate *priv; |
3130 | GList *siblings, *l; |
3131 | |
3132 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return ((0)); } } while (0); |
3133 | g_return_val_if_fail (CTK_IS_CELL_RENDERER (renderer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ((0)); } } while (0); |
3134 | g_return_val_if_fail (CTK_IS_CELL_RENDERER (sibling), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((sibling)); 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 (sibling)"); return ((0 )); } } while (0); |
3135 | |
3136 | priv = area->priv; |
3137 | |
3138 | siblings = g_hash_table_lookup (priv->focus_siblings, renderer); |
3139 | |
3140 | for (l = siblings; l; l = l->next) |
3141 | { |
3142 | CtkCellRenderer *a_sibling = l->data; |
3143 | |
3144 | if (a_sibling == sibling) |
3145 | return TRUE(!(0)); |
3146 | } |
3147 | |
3148 | return FALSE(0); |
3149 | } |
3150 | |
3151 | /** |
3152 | * ctk_cell_area_get_focus_siblings: |
3153 | * @area: a #CtkCellArea |
3154 | * @renderer: the #CtkCellRenderer expected to have focus |
3155 | * |
3156 | * Gets the focus sibling cell renderers for @renderer. |
3157 | * |
3158 | * Returns: (element-type CtkCellRenderer) (transfer none): A #GList of #CtkCellRenderers. |
3159 | * The returned list is internal and should not be freed. |
3160 | * |
3161 | * Since: 3.0 |
3162 | */ |
3163 | const GList * |
3164 | ctk_cell_area_get_focus_siblings (CtkCellArea *area, |
3165 | CtkCellRenderer *renderer) |
3166 | { |
3167 | CtkCellAreaPrivate *priv; |
3168 | |
3169 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
3170 | g_return_val_if_fail (CTK_IS_CELL_RENDERER (renderer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return (((void*)0)); } } while (0); |
3171 | |
3172 | priv = area->priv; |
3173 | |
3174 | return g_hash_table_lookup (priv->focus_siblings, renderer); |
3175 | } |
3176 | |
3177 | /** |
3178 | * ctk_cell_area_get_focus_from_sibling: |
3179 | * @area: a #CtkCellArea |
3180 | * @renderer: the #CtkCellRenderer |
3181 | * |
3182 | * Gets the #CtkCellRenderer which is expected to be focusable |
3183 | * for which @renderer is, or may be a sibling. |
3184 | * |
3185 | * This is handy for #CtkCellArea subclasses when handling events, |
3186 | * after determining the renderer at the event location it can |
3187 | * then chose to activate the focus cell for which the event |
3188 | * cell may have been a sibling. |
3189 | * |
3190 | * Returns: (nullable) (transfer none): the #CtkCellRenderer for which @renderer |
3191 | * is a sibling, or %NULL. |
3192 | * |
3193 | * Since: 3.0 |
3194 | */ |
3195 | CtkCellRenderer * |
3196 | ctk_cell_area_get_focus_from_sibling (CtkCellArea *area, |
3197 | CtkCellRenderer *renderer) |
3198 | { |
3199 | CtkCellRenderer *ret_renderer = NULL((void*)0); |
3200 | GList *renderers, *l; |
3201 | |
3202 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
3203 | g_return_val_if_fail (CTK_IS_CELL_RENDERER (renderer), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return (((void*)0)); } } while (0); |
3204 | |
3205 | renderers = ctk_cell_layout_get_cells (CTK_CELL_LAYOUT (area)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), ((ctk_cell_layout_get_type ()))))))); |
3206 | |
3207 | for (l = renderers; l; l = l->next) |
3208 | { |
3209 | CtkCellRenderer *a_renderer = l->data; |
3210 | const GList *list; |
3211 | |
3212 | for (list = ctk_cell_area_get_focus_siblings (area, a_renderer); |
3213 | list; list = list->next) |
3214 | { |
3215 | CtkCellRenderer *sibling_renderer = list->data; |
3216 | |
3217 | if (sibling_renderer == renderer) |
3218 | { |
3219 | ret_renderer = a_renderer; |
3220 | break; |
3221 | } |
3222 | } |
3223 | } |
3224 | g_list_free (renderers); |
3225 | |
3226 | return ret_renderer; |
3227 | } |
3228 | |
3229 | /************************************************************* |
3230 | * API: Cell Activation/Editing * |
3231 | *************************************************************/ |
3232 | static void |
3233 | ctk_cell_area_add_editable (CtkCellArea *area, |
3234 | CtkCellRenderer *renderer, |
3235 | CtkCellEditable *editable, |
3236 | const CdkRectangle *cell_area) |
3237 | { |
3238 | g_signal_emit (area, cell_area_signals[SIGNAL_ADD_EDITABLE], 0, |
3239 | renderer, editable, cell_area, area->priv->current_path); |
3240 | } |
3241 | |
3242 | static void |
3243 | ctk_cell_area_remove_editable (CtkCellArea *area, |
3244 | CtkCellRenderer *renderer, |
3245 | CtkCellEditable *editable) |
3246 | { |
3247 | g_signal_emit (area, cell_area_signals[SIGNAL_REMOVE_EDITABLE], 0, renderer, editable); |
3248 | } |
3249 | |
3250 | static void |
3251 | cell_area_remove_widget_cb (CtkCellEditable *editable, |
3252 | CtkCellArea *area) |
3253 | { |
3254 | CtkCellAreaPrivate *priv = area->priv; |
3255 | |
3256 | g_assert (priv->edit_widget == editable)do { if (priv->edit_widget == editable) ; else g_assertion_message_expr ("Ctk", "ctkcellarea.c", 3256, ((const char*) (__func__)), "priv->edit_widget == editable" ); } while (0); |
3257 | g_assert (priv->edited_cell != NULL)do { if (priv->edited_cell != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctkcellarea.c", 3257, ((const char*) (__func__)), "priv->edited_cell != NULL" ); } while (0); |
3258 | |
3259 | ctk_cell_area_remove_editable (area, priv->edited_cell, priv->edit_widget); |
3260 | |
3261 | /* Now that we're done with editing the widget and it can be removed, |
3262 | * remove our references to the widget and disconnect handlers */ |
3263 | ctk_cell_area_set_edited_cell (area, NULL((void*)0)); |
3264 | ctk_cell_area_set_edit_widget (area, NULL((void*)0)); |
3265 | } |
3266 | |
3267 | static void |
3268 | ctk_cell_area_set_edited_cell (CtkCellArea *area, |
3269 | CtkCellRenderer *renderer) |
3270 | { |
3271 | CtkCellAreaPrivate *priv; |
3272 | |
3273 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3274 | g_return_if_fail (renderer == NULL || CTK_IS_CELL_RENDERER (renderer))do { if ((renderer == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((renderer)); 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__)), "renderer == NULL || CTK_IS_CELL_RENDERER (renderer)" ); return; } } while (0); |
3275 | |
3276 | priv = area->priv; |
3277 | |
3278 | if (priv->edited_cell != renderer) |
3279 | { |
3280 | if (priv->edited_cell) |
3281 | g_object_unref (priv->edited_cell); |
3282 | |
3283 | priv->edited_cell = renderer; |
3284 | |
3285 | if (priv->edited_cell) |
3286 | g_object_ref (priv->edited_cell)((__typeof__ (priv->edited_cell)) (g_object_ref) (priv-> edited_cell)); |
3287 | |
3288 | g_object_notify (G_OBJECT (area)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), (((GType) ((20) << (2)))))))), "edited-cell"); |
3289 | } |
3290 | } |
3291 | |
3292 | static void |
3293 | ctk_cell_area_set_edit_widget (CtkCellArea *area, |
3294 | CtkCellEditable *editable) |
3295 | { |
3296 | CtkCellAreaPrivate *priv; |
3297 | |
3298 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3299 | g_return_if_fail (editable == NULL || CTK_IS_CELL_EDITABLE (editable))do { if ((editable == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((editable)); GType __t = ((ctk_cell_editable_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__)), "editable == NULL || CTK_IS_CELL_EDITABLE (editable)" ); return; } } while (0); |
3300 | |
3301 | priv = area->priv; |
3302 | |
3303 | if (priv->edit_widget != editable) |
3304 | { |
3305 | if (priv->edit_widget) |
3306 | { |
3307 | g_signal_handler_disconnect (priv->edit_widget, priv->remove_widget_id); |
3308 | |
3309 | g_object_unref (priv->edit_widget); |
3310 | } |
3311 | |
3312 | priv->edit_widget = editable; |
3313 | |
3314 | if (priv->edit_widget) |
3315 | { |
3316 | priv->remove_widget_id = |
3317 | g_signal_connect (priv->edit_widget, "remove-widget",g_signal_connect_data ((priv->edit_widget), ("remove-widget" ), (((GCallback) (cell_area_remove_widget_cb))), (area), ((void *)0), (GConnectFlags) 0) |
3318 | G_CALLBACK (cell_area_remove_widget_cb), area)g_signal_connect_data ((priv->edit_widget), ("remove-widget" ), (((GCallback) (cell_area_remove_widget_cb))), (area), ((void *)0), (GConnectFlags) 0); |
3319 | |
3320 | g_object_ref (priv->edit_widget)((__typeof__ (priv->edit_widget)) (g_object_ref) (priv-> edit_widget)); |
3321 | } |
3322 | |
3323 | g_object_notify (G_OBJECT (area)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((area)), (((GType) ((20) << (2)))))))), "edit-widget"); |
3324 | } |
3325 | } |
3326 | |
3327 | /** |
3328 | * ctk_cell_area_get_edited_cell: |
3329 | * @area: a #CtkCellArea |
3330 | * |
3331 | * Gets the #CtkCellRenderer in @area that is currently |
3332 | * being edited. |
3333 | * |
3334 | * Returns: (transfer none): The currently edited #CtkCellRenderer |
3335 | * |
3336 | * Since: 3.0 |
3337 | */ |
3338 | CtkCellRenderer * |
3339 | ctk_cell_area_get_edited_cell (CtkCellArea *area) |
3340 | { |
3341 | CtkCellAreaPrivate *priv; |
3342 | |
3343 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
3344 | |
3345 | priv = area->priv; |
3346 | |
3347 | return priv->edited_cell; |
3348 | } |
3349 | |
3350 | /** |
3351 | * ctk_cell_area_get_edit_widget: |
3352 | * @area: a #CtkCellArea |
3353 | * |
3354 | * Gets the #CtkCellEditable widget currently used |
3355 | * to edit the currently edited cell. |
3356 | * |
3357 | * Returns: (transfer none): The currently active #CtkCellEditable widget |
3358 | * |
3359 | * Since: 3.0 |
3360 | */ |
3361 | CtkCellEditable * |
3362 | ctk_cell_area_get_edit_widget (CtkCellArea *area) |
3363 | { |
3364 | CtkCellAreaPrivate *priv; |
3365 | |
3366 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return (((void*)0)); } } while (0); |
3367 | |
3368 | priv = area->priv; |
3369 | |
3370 | return priv->edit_widget; |
3371 | } |
3372 | |
3373 | /** |
3374 | * ctk_cell_area_activate_cell: |
3375 | * @area: a #CtkCellArea |
3376 | * @widget: the #CtkWidget that @area is rendering onto |
3377 | * @renderer: the #CtkCellRenderer in @area to activate |
3378 | * @event: the #CdkEvent for which cell activation should occur |
3379 | * @cell_area: the #CdkRectangle in @widget relative coordinates |
3380 | * of @renderer for the current row. |
3381 | * @flags: the #CtkCellRendererState for @renderer |
3382 | * |
3383 | * This is used by #CtkCellArea subclasses when handling events |
3384 | * to activate cells, the base #CtkCellArea class activates cells |
3385 | * for keyboard events for free in its own CtkCellArea->activate() |
3386 | * implementation. |
3387 | * |
3388 | * Returns: whether cell activation was successful |
3389 | * |
3390 | * Since: 3.0 |
3391 | */ |
3392 | gboolean |
3393 | ctk_cell_area_activate_cell (CtkCellArea *area, |
3394 | CtkWidget *widget, |
3395 | CtkCellRenderer *renderer, |
3396 | CdkEvent *event, |
3397 | const CdkRectangle *cell_area, |
3398 | CtkCellRendererState flags) |
3399 | { |
3400 | CtkCellRendererMode mode; |
3401 | CtkCellAreaPrivate *priv; |
3402 | |
3403 | g_return_val_if_fail (CTK_IS_CELL_AREA (area), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return ((0)); } } while (0); |
3404 | g_return_val_if_fail (CTK_IS_WIDGET (widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return ((0)); } } while (0); |
3405 | g_return_val_if_fail (CTK_IS_CELL_RENDERER (renderer), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ((0)); } } while (0); |
3406 | g_return_val_if_fail (cell_area != NULL, FALSE)do { if ((cell_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell_area != NULL"); return ((0)); } } while (0); |
3407 | |
3408 | priv = area->priv; |
3409 | |
3410 | if (!ctk_cell_renderer_get_sensitive (renderer)) |
3411 | return FALSE(0); |
3412 | |
3413 | g_object_get (renderer, "mode", &mode, NULL((void*)0)); |
3414 | |
3415 | if (mode == CTK_CELL_RENDERER_MODE_ACTIVATABLE) |
3416 | { |
3417 | if (ctk_cell_renderer_activate (renderer, |
3418 | event, widget, |
3419 | priv->current_path, |
3420 | cell_area, |
3421 | cell_area, |
3422 | flags)) |
3423 | return TRUE(!(0)); |
3424 | } |
3425 | else if (mode == CTK_CELL_RENDERER_MODE_EDITABLE) |
3426 | { |
3427 | CtkCellEditable *editable_widget; |
3428 | CdkRectangle inner_area; |
3429 | |
3430 | ctk_cell_area_inner_cell_area (area, widget, cell_area, &inner_area); |
3431 | |
3432 | editable_widget = |
3433 | ctk_cell_renderer_start_editing (renderer, |
3434 | event, widget, |
3435 | priv->current_path, |
3436 | &inner_area, |
3437 | &inner_area, |
3438 | flags); |
3439 | |
3440 | if (editable_widget != NULL((void*)0)) |
3441 | { |
3442 | g_return_val_if_fail (CTK_IS_CELL_EDITABLE (editable_widget), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((editable_widget)); GType __t = ((ctk_cell_editable_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_EDITABLE (editable_widget)" ); return ((0)); } } while (0); |
3443 | |
3444 | ctk_cell_area_set_edited_cell (area, renderer); |
3445 | ctk_cell_area_set_edit_widget (area, editable_widget); |
3446 | |
3447 | /* Signal that editing started so that callers can get |
3448 | * a handle on the editable_widget */ |
3449 | ctk_cell_area_add_editable (area, priv->focus_cell, editable_widget, cell_area); |
3450 | |
3451 | /* If the signal was successfully handled start the editing */ |
3452 | if (ctk_widget_get_parent (CTK_WIDGET (editable_widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editable_widget)), ((ctk_widget_get_type ())))))))) |
3453 | { |
3454 | ctk_cell_editable_start_editing (editable_widget, event); |
3455 | ctk_widget_grab_focus (CTK_WIDGET (editable_widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editable_widget)), ((ctk_widget_get_type ()))))))); |
3456 | } |
3457 | else |
3458 | { |
3459 | /* Otherwise clear the editing state and fire a warning */ |
3460 | ctk_cell_area_set_edited_cell (area, NULL((void*)0)); |
3461 | ctk_cell_area_set_edit_widget (area, NULL((void*)0)); |
3462 | |
3463 | g_warning ("CtkCellArea::add-editable fired in the dark, no cell editing was started."); |
3464 | } |
3465 | |
3466 | return TRUE(!(0)); |
3467 | } |
3468 | } |
3469 | |
3470 | return FALSE(0); |
3471 | } |
3472 | |
3473 | /** |
3474 | * ctk_cell_area_stop_editing: |
3475 | * @area: a #CtkCellArea |
3476 | * @canceled: whether editing was canceled. |
3477 | * |
3478 | * Explicitly stops the editing of the currently edited cell. |
3479 | * |
3480 | * If @canceled is %TRUE, the currently edited cell renderer |
3481 | * will emit the ::editing-canceled signal, otherwise the |
3482 | * the ::editing-done signal will be emitted on the current |
3483 | * edit widget. |
3484 | * |
3485 | * See ctk_cell_area_get_edited_cell() and ctk_cell_area_get_edit_widget(). |
3486 | * |
3487 | * Since: 3.0 |
3488 | */ |
3489 | void |
3490 | ctk_cell_area_stop_editing (CtkCellArea *area, |
3491 | gboolean canceled) |
3492 | { |
3493 | CtkCellAreaPrivate *priv; |
3494 | |
3495 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3496 | |
3497 | priv = area->priv; |
3498 | |
3499 | if (priv->edited_cell) |
3500 | { |
3501 | CtkCellEditable *edit_widget = g_object_ref (priv->edit_widget)((__typeof__ (priv->edit_widget)) (g_object_ref) (priv-> edit_widget)); |
3502 | CtkCellRenderer *edit_cell = g_object_ref (priv->edited_cell)((__typeof__ (priv->edited_cell)) (g_object_ref) (priv-> edited_cell)); |
3503 | |
3504 | /* Stop editing of the cell renderer */ |
3505 | ctk_cell_renderer_stop_editing (priv->edited_cell, canceled); |
3506 | |
3507 | /* When editing is explicitly halted either |
3508 | * the "editing-canceled" signal is emitted on the cell |
3509 | * renderer or the "editing-done" signal on the CtkCellEditable widget |
3510 | */ |
3511 | if (!canceled) |
3512 | ctk_cell_editable_editing_done (edit_widget); |
3513 | |
3514 | /* Remove any references to the editable widget */ |
3515 | ctk_cell_area_set_edited_cell (area, NULL((void*)0)); |
3516 | ctk_cell_area_set_edit_widget (area, NULL((void*)0)); |
3517 | |
3518 | /* Send the remove-widget signal explicitly (this is done after setting |
3519 | * the edit cell/widget NULL to avoid feedback) |
3520 | */ |
3521 | ctk_cell_area_remove_editable (area, edit_cell, edit_widget); |
3522 | g_object_unref (edit_cell); |
3523 | g_object_unref (edit_widget); |
3524 | } |
3525 | } |
3526 | |
3527 | /************************************************************* |
3528 | * API: Convenience for area implementations * |
3529 | *************************************************************/ |
3530 | |
3531 | /** |
3532 | * ctk_cell_area_inner_cell_area: |
3533 | * @area: a #CtkCellArea |
3534 | * @widget: the #CtkWidget that @area is rendering onto |
3535 | * @cell_area: the @widget relative coordinates where one of @area’s cells |
3536 | * is to be placed |
3537 | * @inner_area: (out): the return location for the inner cell area |
3538 | * |
3539 | * This is a convenience function for #CtkCellArea implementations |
3540 | * to get the inner area where a given #CtkCellRenderer will be |
3541 | * rendered. It removes any padding previously added by ctk_cell_area_request_renderer(). |
3542 | * |
3543 | * Since: 3.0 |
3544 | */ |
3545 | void |
3546 | ctk_cell_area_inner_cell_area (CtkCellArea *area, |
3547 | CtkWidget *widget, |
3548 | const CdkRectangle *cell_area, |
3549 | CdkRectangle *inner_area) |
3550 | { |
3551 | CtkBorder border; |
3552 | CtkStyleContext *context; |
3553 | CtkStateFlags state; |
3554 | |
3555 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3556 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
3557 | g_return_if_fail (cell_area != NULL)do { if ((cell_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "cell_area != NULL"); return ; } } while (0); |
3558 | g_return_if_fail (inner_area != NULL)do { if ((inner_area != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "inner_area != NULL"); return ; } } while (0); |
3559 | |
3560 | context = ctk_widget_get_style_context (widget); |
3561 | state = ctk_style_context_get_state (context); |
3562 | ctk_style_context_get_padding (context, state, &border); |
3563 | |
3564 | *inner_area = *cell_area; |
3565 | |
3566 | inner_area->x += border.left; |
3567 | inner_area->width -= border.left + border.right; |
3568 | inner_area->y += border.top; |
3569 | inner_area->height -= border.top + border.bottom; |
3570 | } |
3571 | |
3572 | /** |
3573 | * ctk_cell_area_request_renderer: |
3574 | * @area: a #CtkCellArea |
3575 | * @renderer: the #CtkCellRenderer to request size for |
3576 | * @orientation: the #CtkOrientation in which to request size |
3577 | * @widget: the #CtkWidget that @area is rendering onto |
3578 | * @for_size: the allocation contextual size to request for, or -1 if |
3579 | * the base request for the orientation is to be returned. |
3580 | * @minimum_size: (out) (allow-none): location to store the minimum size, or %NULL |
3581 | * @natural_size: (out) (allow-none): location to store the natural size, or %NULL |
3582 | * |
3583 | * This is a convenience function for #CtkCellArea implementations |
3584 | * to request size for cell renderers. It’s important to use this |
3585 | * function to request size and then use ctk_cell_area_inner_cell_area() |
3586 | * at render and event time since this function will add padding |
3587 | * around the cell for focus painting. |
3588 | * |
3589 | * Since: 3.0 |
3590 | */ |
3591 | void |
3592 | ctk_cell_area_request_renderer (CtkCellArea *area, |
3593 | CtkCellRenderer *renderer, |
3594 | CtkOrientation orientation, |
3595 | CtkWidget *widget, |
3596 | gint for_size, |
3597 | gint *minimum_size, |
3598 | gint *natural_size) |
3599 | { |
3600 | CtkBorder border; |
3601 | CtkStyleContext *context; |
3602 | CtkStateFlags state; |
3603 | |
3604 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3605 | g_return_if_fail (CTK_IS_CELL_RENDERER (renderer))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((renderer)); 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 (renderer)"); return ; } } while (0); |
3606 | g_return_if_fail (CTK_IS_WIDGET (widget))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((widget)); GType __t = ((ctk_widget_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_WIDGET (widget)"); return; } } while (0); |
3607 | g_return_if_fail (minimum_size != NULL)do { if ((minimum_size != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "minimum_size != NULL"); return; } } while (0); |
3608 | g_return_if_fail (natural_size != NULL)do { if ((natural_size != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "natural_size != NULL"); return; } } while (0); |
3609 | |
3610 | context = ctk_widget_get_style_context (widget); |
3611 | state = ctk_style_context_get_state (context); |
3612 | ctk_style_context_get_padding (context, state, &border); |
3613 | |
3614 | if (orientation == CTK_ORIENTATION_HORIZONTAL) |
3615 | { |
3616 | if (for_size < 0) |
3617 | ctk_cell_renderer_get_preferred_width (renderer, widget, minimum_size, natural_size); |
3618 | else |
3619 | { |
3620 | for_size = MAX (0, for_size - border.left - border.right)(((0) > (for_size - border.left - border.right)) ? (0) : ( for_size - border.left - border.right)); |
3621 | |
3622 | ctk_cell_renderer_get_preferred_width_for_height (renderer, widget, for_size, |
3623 | minimum_size, natural_size); |
3624 | } |
3625 | |
3626 | *minimum_size += border.left + border.right; |
3627 | *natural_size += border.left + border.right; |
3628 | } |
3629 | else /* CTK_ORIENTATION_VERTICAL */ |
3630 | { |
3631 | if (for_size < 0) |
3632 | ctk_cell_renderer_get_preferred_height (renderer, widget, minimum_size, natural_size); |
3633 | else |
3634 | { |
3635 | for_size = MAX (0, for_size - border.top - border.bottom)(((0) > (for_size - border.top - border.bottom)) ? (0) : ( for_size - border.top - border.bottom)); |
3636 | |
3637 | ctk_cell_renderer_get_preferred_height_for_width (renderer, widget, for_size, |
3638 | minimum_size, natural_size); |
3639 | } |
3640 | |
3641 | *minimum_size += border.top + border.bottom; |
3642 | *natural_size += border.top + border.bottom; |
3643 | } |
3644 | } |
3645 | |
3646 | void |
3647 | _ctk_cell_area_set_cell_data_func_with_proxy (CtkCellArea *area, |
3648 | CtkCellRenderer *cell, |
3649 | GFunc func, |
3650 | gpointer func_data, |
3651 | GDestroyNotify destroy, |
3652 | gpointer proxy) |
3653 | { |
3654 | CtkCellAreaPrivate *priv; |
3655 | CellInfo *info; |
3656 | |
3657 | g_return_if_fail (CTK_IS_CELL_AREA (area))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((area)); GType __t = ((ctk_cell_area_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_AREA (area)"); return; } } while (0); |
3658 | 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); |
3659 | |
3660 | priv = area->priv; |
3661 | |
3662 | info = g_hash_table_lookup (priv->cell_info, cell); |
3663 | |
3664 | /* Note we do not take a reference to the proxy, the proxy is a CtkCellLayout |
3665 | * that is forwarding its implementation to a delegate CtkCellArea therefore |
3666 | * its life-cycle is longer than the area's life cycle. |
3667 | */ |
3668 | if (info) |
3669 | { |
3670 | if (info->destroy && info->data) |
3671 | info->destroy (info->data); |
3672 | |
3673 | if (func) |
3674 | { |
3675 | info->func = (CtkCellLayoutDataFunc)func; |
3676 | info->data = func_data; |
3677 | info->destroy = destroy; |
3678 | info->proxy = proxy; |
3679 | } |
3680 | else |
3681 | { |
3682 | info->func = NULL((void*)0); |
3683 | info->data = NULL((void*)0); |
3684 | info->destroy = NULL((void*)0); |
3685 | info->proxy = NULL((void*)0); |
3686 | } |
3687 | } |
3688 | else |
3689 | { |
3690 | info = cell_info_new ((CtkCellLayoutDataFunc)func, func_data, destroy); |
3691 | info->proxy = proxy; |
3692 | |
3693 | g_hash_table_insert (priv->cell_info, cell, info); |
3694 | } |
3695 | } |