File: | ctk/ctknotebook.c |
Warning: | line 5797, column 3 Value stored to 'anchor' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */ |
2 | /* CTK - The GIMP Toolkit |
3 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | /* |
20 | * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS |
21 | * file for a list of people on the CTK+ Team. See the ChangeLog |
22 | * files for a list of changes. These files are distributed with |
23 | * CTK+ at ftp:ftp.ctk.org/pub/ctk/. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | |
28 | #include <stdio.h> |
29 | #include <string.h> |
30 | #include <math.h> |
31 | |
32 | #include "ctknotebook.h" |
33 | |
34 | #include "ctkmain.h" |
35 | #include "ctkmenu.h" |
36 | #include "ctkmenuitem.h" |
37 | #include "ctklabel.h" |
38 | #include "ctkintl.h" |
39 | #include "ctkmarshalers.h" |
40 | #include "ctkbindings.h" |
41 | #include "ctkprivate.h" |
42 | #include "ctkdnd.h" |
43 | #include "ctkbuildable.h" |
44 | #include "ctktypebuiltins.h" |
45 | #include "ctkwidgetpath.h" |
46 | #include "ctkboxgadgetprivate.h" |
47 | #include "ctkbuiltiniconprivate.h" |
48 | #include "ctkcsscustomgadgetprivate.h" |
49 | #include "ctkcssstylepropertyprivate.h" |
50 | #include "ctksizerequest.h" |
51 | #include "ctkstylecontextprivate.h" |
52 | #include "ctkwidgetprivate.h" |
53 | #include "a11y/ctknotebookaccessible.h" |
54 | |
55 | |
56 | /** |
57 | * SECTION:ctknotebook |
58 | * @Short_description: A tabbed notebook container |
59 | * @Title: CtkNotebook |
60 | * @See_also: #CtkContainer |
61 | * |
62 | * The #CtkNotebook widget is a #CtkContainer whose children are pages that |
63 | * can be switched between using tab labels along one edge. |
64 | * |
65 | * There are many configuration options for CtkNotebook. Among other |
66 | * things, you can choose on which edge the tabs appear |
67 | * (see ctk_notebook_set_tab_pos()), whether, if there are too many |
68 | * tabs to fit the notebook should be made bigger or scrolling |
69 | * arrows added (see ctk_notebook_set_scrollable()), and whether there |
70 | * will be a popup menu allowing the users to switch pages. |
71 | * (see ctk_notebook_popup_enable(), ctk_notebook_popup_disable()) |
72 | * |
73 | * # CtkNotebook as CtkBuildable |
74 | * |
75 | * The CtkNotebook implementation of the #CtkBuildable interface |
76 | * supports placing children into tabs by specifying “tab” as the |
77 | * “type” attribute of a <child> element. Note that the content |
78 | * of the tab must be created before the tab can be filled. |
79 | * A tab child can be specified without specifying a <child> |
80 | * type attribute. |
81 | * |
82 | * To add a child widget in the notebooks action area, specify |
83 | * "action-start" or “action-end” as the “type” attribute of the |
84 | * <child> element. |
85 | * |
86 | * An example of a UI definition fragment with CtkNotebook: |
87 | * |[ |
88 | * <object class="CtkNotebook"> |
89 | * <child> |
90 | * <object class="CtkLabel" id="notebook-content"> |
91 | * <property name="label">Content</property> |
92 | * </object> |
93 | * </child> |
94 | * <child type="tab"> |
95 | * <object class="CtkLabel" id="notebook-tab"> |
96 | * <property name="label">Tab</property> |
97 | * </object> |
98 | * </child> |
99 | * </object> |
100 | * ]| |
101 | * |
102 | * # CSS nodes |
103 | * |
104 | * |[<!-- language="plain" --> |
105 | * notebook |
106 | * ├── header.top |
107 | * │ ├── [<action widget>] |
108 | * │ ├── tabs |
109 | * │ │ ├── [arrow] |
110 | * │ │ ├── tab |
111 | * │ │ │ ╰── <tab label> |
112 | * ┊ ┊ ┊ |
113 | * │ │ ├── tab[.reorderable-page] |
114 | * │ │ │ ╰── <tab label> |
115 | * │ │ ╰── [arrow] |
116 | * │ ╰── [<action widget>] |
117 | * │ |
118 | * ╰── stack |
119 | * ├── <child> |
120 | * ┊ |
121 | * ╰── <child> |
122 | * ]| |
123 | * |
124 | * CtkNotebook has a main CSS node with name notebook, a subnode |
125 | * with name header and below that a subnode with name tabs which |
126 | * contains one subnode per tab with name tab. |
127 | * |
128 | * If action widgets are present, their CSS nodes are placed next |
129 | * to the tabs node. If the notebook is scrollable, CSS nodes with |
130 | * name arrow are placed as first and last child of the tabs node. |
131 | * |
132 | * The main node gets the .frame style class when the notebook |
133 | * has a border (see ctk_notebook_set_show_border()). |
134 | * |
135 | * The header node gets one of the style class .top, .bottom, |
136 | * .left or .right, depending on where the tabs are placed. For |
137 | * reorderable pages, the tab node gets the .reorderable-page class. |
138 | * |
139 | * A tab node gets the .dnd style class while it is moved with drag-and-drop. |
140 | * |
141 | * The nodes are always arranged from left-to-right, regarldess of text direction. |
142 | */ |
143 | |
144 | |
145 | #define SCROLL_DELAY_FACTOR5 5 |
146 | #define SCROLL_THRESHOLD12 12 |
147 | #define DND_THRESHOLD_MULTIPLIER4 4 |
148 | |
149 | #define TIMEOUT_INITIAL500 500 |
150 | #define TIMEOUT_REPEAT50 50 |
151 | #define TIMEOUT_EXPAND500 500 |
152 | |
153 | typedef struct _CtkNotebookPage CtkNotebookPage; |
154 | |
155 | typedef enum |
156 | { |
157 | DRAG_OPERATION_NONE, |
158 | DRAG_OPERATION_REORDER, |
159 | DRAG_OPERATION_DETACH |
160 | } CtkNotebookDragOperation; |
161 | |
162 | enum { |
163 | ACTION_WIDGET_START, |
164 | ACTION_WIDGET_END, |
165 | N_ACTION_WIDGETS |
166 | }; |
167 | |
168 | struct _CtkNotebookPrivate |
169 | { |
170 | CtkNotebookDragOperation operation; |
171 | CtkNotebookPage *cur_page; |
172 | CtkNotebookPage *detached_tab; |
173 | CtkNotebookPage *prelight_tab; |
174 | CtkTargetList *source_targets; |
175 | CtkWidget *action_widget[N_ACTION_WIDGETS]; |
176 | CtkWidget *dnd_window; |
177 | CtkWidget *menu; |
178 | |
179 | CdkWindow *drag_window; |
180 | CdkWindow *event_window; |
181 | |
182 | CtkCssGadget *gadget; |
183 | CtkCssGadget *stack_gadget; |
184 | CtkCssGadget *header_gadget; |
185 | CtkCssGadget *tabs_gadget; |
186 | CtkCssGadget *arrow_gadget[4]; |
187 | |
188 | GList *children; |
189 | GList *first_tab; /* The first tab visible (for scrolling notebooks) */ |
190 | GList *focus_tab; |
191 | |
192 | gint drag_begin_x; |
193 | gint drag_begin_y; |
194 | gint drag_offset_x; |
195 | gint drag_offset_y; |
196 | gint drag_window_x; |
197 | gint drag_window_y; |
198 | gint mouse_x; |
199 | gint mouse_y; |
200 | gint pressed_button; |
201 | |
202 | GQuark group; |
203 | |
204 | guint dnd_timer; |
205 | guint switch_tab_timer; |
206 | GList *switch_tab; |
207 | |
208 | guint32 timer; |
209 | |
210 | guint child_has_focus : 1; |
211 | guint click_child : 3; |
212 | guint remove_in_detach : 1; |
213 | guint focus_out : 1; /* Flag used by ::move-focus-out implementation */ |
214 | guint has_scrolled : 1; |
215 | guint in_child : 3; |
216 | guint need_timer : 1; |
217 | guint show_border : 1; |
218 | guint show_tabs : 1; |
219 | guint scrollable : 1; |
220 | guint tab_pos : 2; |
221 | guint tabs_reversed : 1; |
222 | guint rootwindow_drop : 1; |
223 | }; |
224 | |
225 | enum { |
226 | SWITCH_PAGE, |
227 | FOCUS_TAB, |
228 | SELECT_PAGE, |
229 | CHANGE_CURRENT_PAGE, |
230 | MOVE_FOCUS_OUT, |
231 | REORDER_TAB, |
232 | PAGE_REORDERED, |
233 | PAGE_REMOVED, |
234 | PAGE_ADDED, |
235 | CREATE_WINDOW, |
236 | LAST_SIGNAL |
237 | }; |
238 | |
239 | enum { |
240 | STEP_PREV, |
241 | STEP_NEXT |
242 | }; |
243 | |
244 | typedef enum |
245 | { |
246 | ARROW_LEFT_BEFORE, |
247 | ARROW_RIGHT_BEFORE, |
248 | ARROW_LEFT_AFTER, |
249 | ARROW_RIGHT_AFTER, |
250 | ARROW_NONE |
251 | } CtkNotebookArrow; |
252 | |
253 | typedef enum |
254 | { |
255 | POINTER_BEFORE, |
256 | POINTER_AFTER, |
257 | POINTER_BETWEEN |
258 | } CtkNotebookPointerPosition; |
259 | |
260 | #define ARROW_IS_LEFT(arrow)((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_LEFT_AFTER) ((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_LEFT_AFTER) |
261 | #define ARROW_IS_BEFORE(arrow)((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_RIGHT_BEFORE ) ((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_RIGHT_BEFORE) |
262 | |
263 | enum { |
264 | PROP_0, |
265 | PROP_TAB_POS, |
266 | PROP_SHOW_TABS, |
267 | PROP_SHOW_BORDER, |
268 | PROP_SCROLLABLE, |
269 | PROP_PAGE, |
270 | PROP_ENABLE_POPUP, |
271 | PROP_GROUP_NAME, |
272 | LAST_PROP |
273 | }; |
274 | |
275 | static GParamSpec *properties[LAST_PROP]; |
276 | |
277 | enum { |
278 | CHILD_PROP_0, |
279 | CHILD_PROP_TAB_LABEL, |
280 | CHILD_PROP_MENU_LABEL, |
281 | CHILD_PROP_POSITION, |
282 | CHILD_PROP_TAB_EXPAND, |
283 | CHILD_PROP_TAB_FILL, |
284 | CHILD_PROP_REORDERABLE, |
285 | CHILD_PROP_DETACHABLE |
286 | }; |
287 | |
288 | #define CTK_NOTEBOOK_PAGE(_glist_)((CtkNotebookPage *)(_glist_)->data) ((CtkNotebookPage *)(_glist_)->data) |
289 | |
290 | /* some useful defines for calculating coords */ |
291 | #define NOTEBOOK_IS_TAB_LABEL_PARENT(_notebook_,_page_)(ctk_widget_get_parent ((_page_)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((_notebook_ )), ((ctk_widget_get_type ())))))))) (ctk_widget_get_parent ((_page_)->tab_label) == (CTK_WIDGET (_notebook_)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((_notebook_)), ((ctk_widget_get_type ())))))))) |
292 | |
293 | struct _CtkNotebookPage |
294 | { |
295 | CtkWidget *child; |
296 | CtkWidget *tab_label; |
297 | CtkWidget *menu_label; |
298 | CtkWidget *last_focus_child; /* Last descendant of the page that had focus */ |
299 | |
300 | CtkCssGadget *gadget; /* gadget used for the tab itself */ |
301 | |
302 | guint default_menu : 1; /* If true, we create the menu label ourself */ |
303 | guint default_tab : 1; /* If true, we create the tab label ourself */ |
304 | guint expand : 1; |
305 | guint fill : 1; |
306 | guint reorderable : 1; |
307 | guint detachable : 1; |
308 | |
309 | CtkRequisition requisition; |
310 | |
311 | gulong mnemonic_activate_signal; |
312 | gulong notify_visible_handler; |
313 | }; |
314 | |
315 | static const CtkTargetEntry src_notebook_targets [] = { |
316 | { "CTK_NOTEBOOK_TAB", CTK_TARGET_SAME_APP, 0 }, |
317 | { "application/x-rootwindow-drop", 0, 0 }, |
318 | }; |
319 | |
320 | static const CtkTargetEntry dst_notebook_targets [] = { |
321 | { "CTK_NOTEBOOK_TAB", CTK_TARGET_SAME_APP, 0 }, |
322 | }; |
323 | |
324 | /*** CtkNotebook Methods ***/ |
325 | static gboolean ctk_notebook_select_page (CtkNotebook *notebook, |
326 | gboolean move_focus); |
327 | static gboolean ctk_notebook_focus_tab (CtkNotebook *notebook, |
328 | CtkNotebookTab type); |
329 | static gboolean ctk_notebook_change_current_page (CtkNotebook *notebook, |
330 | gint offset); |
331 | static void ctk_notebook_move_focus_out (CtkNotebook *notebook, |
332 | CtkDirectionType direction_type); |
333 | static gboolean ctk_notebook_reorder_tab (CtkNotebook *notebook, |
334 | CtkDirectionType direction_type, |
335 | gboolean move_to_last); |
336 | static void ctk_notebook_remove_tab_label (CtkNotebook *notebook, |
337 | CtkNotebookPage *page); |
338 | static void ctk_notebook_set_tab_label_packing (CtkNotebook *notebook, |
339 | CtkWidget *child, |
340 | gboolean expand, |
341 | gboolean fill); |
342 | static void ctk_notebook_query_tab_label_packing (CtkNotebook *notebook, |
343 | CtkWidget *child, |
344 | gboolean *expand, |
345 | gboolean *fill); |
346 | |
347 | /*** GObject Methods ***/ |
348 | static void ctk_notebook_set_property (GObject *object, |
349 | guint prop_id, |
350 | const GValue *value, |
351 | GParamSpec *pspec); |
352 | static void ctk_notebook_get_property (GObject *object, |
353 | guint prop_id, |
354 | GValue *value, |
355 | GParamSpec *pspec); |
356 | static void ctk_notebook_finalize (GObject *object); |
357 | |
358 | /*** CtkWidget Methods ***/ |
359 | static void ctk_notebook_destroy (CtkWidget *widget); |
360 | static void ctk_notebook_map (CtkWidget *widget); |
361 | static void ctk_notebook_unmap (CtkWidget *widget); |
362 | static void ctk_notebook_realize (CtkWidget *widget); |
363 | static void ctk_notebook_unrealize (CtkWidget *widget); |
364 | static void ctk_notebook_get_preferred_width (CtkWidget *widget, |
365 | gint *minimum, |
366 | gint *natural); |
367 | static void ctk_notebook_get_preferred_height(CtkWidget *widget, |
368 | gint *minimum, |
369 | gint *natural); |
370 | static void ctk_notebook_get_preferred_width_for_height |
371 | (CtkWidget *widget, |
372 | gint height, |
373 | gint *minimum, |
374 | gint *natural); |
375 | static void ctk_notebook_get_preferred_height_for_width |
376 | (CtkWidget *widget, |
377 | gint width, |
378 | gint *minimum, |
379 | gint *natural); |
380 | static void ctk_notebook_size_allocate (CtkWidget *widget, |
381 | CtkAllocation *allocation); |
382 | static gboolean ctk_notebook_draw (CtkWidget *widget, |
383 | cairo_t *cr); |
384 | static gboolean ctk_notebook_button_press (CtkWidget *widget, |
385 | CdkEventButton *event); |
386 | static gboolean ctk_notebook_button_release (CtkWidget *widget, |
387 | CdkEventButton *event); |
388 | static gboolean ctk_notebook_popup_menu (CtkWidget *widget); |
389 | static gboolean ctk_notebook_enter_notify (CtkWidget *widget, |
390 | CdkEventCrossing *event); |
391 | static gboolean ctk_notebook_leave_notify (CtkWidget *widget, |
392 | CdkEventCrossing *event); |
393 | static gboolean ctk_notebook_motion_notify (CtkWidget *widget, |
394 | CdkEventMotion *event); |
395 | static gboolean ctk_notebook_focus_in (CtkWidget *widget, |
396 | CdkEventFocus *event); |
397 | static gboolean ctk_notebook_focus_out (CtkWidget *widget, |
398 | CdkEventFocus *event); |
399 | static void ctk_notebook_grab_notify (CtkWidget *widget, |
400 | gboolean was_grabbed); |
401 | static void ctk_notebook_state_flags_changed (CtkWidget *widget, |
402 | CtkStateFlags previous_state); |
403 | static gboolean ctk_notebook_focus (CtkWidget *widget, |
404 | CtkDirectionType direction); |
405 | static void ctk_notebook_style_updated (CtkWidget *widget); |
406 | |
407 | /*** Drag and drop Methods ***/ |
408 | static void ctk_notebook_drag_begin (CtkWidget *widget, |
409 | CdkDragContext *context); |
410 | static void ctk_notebook_drag_end (CtkWidget *widget, |
411 | CdkDragContext *context); |
412 | static gboolean ctk_notebook_drag_failed (CtkWidget *widget, |
413 | CdkDragContext *context, |
414 | CtkDragResult result); |
415 | static gboolean ctk_notebook_drag_motion (CtkWidget *widget, |
416 | CdkDragContext *context, |
417 | gint x, |
418 | gint y, |
419 | guint time); |
420 | static void ctk_notebook_drag_leave (CtkWidget *widget, |
421 | CdkDragContext *context, |
422 | guint time); |
423 | static gboolean ctk_notebook_drag_drop (CtkWidget *widget, |
424 | CdkDragContext *context, |
425 | gint x, |
426 | gint y, |
427 | guint time); |
428 | static void ctk_notebook_drag_data_get (CtkWidget *widget, |
429 | CdkDragContext *context, |
430 | CtkSelectionData *data, |
431 | guint info, |
432 | guint time); |
433 | static void ctk_notebook_drag_data_received (CtkWidget *widget, |
434 | CdkDragContext *context, |
435 | gint x, |
436 | gint y, |
437 | CtkSelectionData *data, |
438 | guint info, |
439 | guint time); |
440 | static void ctk_notebook_direction_changed (CtkWidget *widget, |
441 | CtkTextDirection previous_direction); |
442 | |
443 | /*** CtkContainer Methods ***/ |
444 | static void ctk_notebook_set_child_property (CtkContainer *container, |
445 | CtkWidget *child, |
446 | guint property_id, |
447 | const GValue *value, |
448 | GParamSpec *pspec); |
449 | static void ctk_notebook_get_child_property (CtkContainer *container, |
450 | CtkWidget *child, |
451 | guint property_id, |
452 | GValue *value, |
453 | GParamSpec *pspec); |
454 | static void ctk_notebook_add (CtkContainer *container, |
455 | CtkWidget *widget); |
456 | static void ctk_notebook_remove (CtkContainer *container, |
457 | CtkWidget *widget); |
458 | static void ctk_notebook_set_focus_child (CtkContainer *container, |
459 | CtkWidget *child); |
460 | static GType ctk_notebook_child_type (CtkContainer *container); |
461 | static void ctk_notebook_forall (CtkContainer *container, |
462 | gboolean include_internals, |
463 | CtkCallback callback, |
464 | gpointer callback_data); |
465 | |
466 | /*** CtkNotebook Methods ***/ |
467 | static gint ctk_notebook_real_insert_page (CtkNotebook *notebook, |
468 | CtkWidget *child, |
469 | CtkWidget *tab_label, |
470 | CtkWidget *menu_label, |
471 | gint position); |
472 | |
473 | static CtkNotebook *ctk_notebook_create_window (CtkNotebook *notebook, |
474 | CtkWidget *page, |
475 | gint x, |
476 | gint y); |
477 | |
478 | /*** Gadget Functions ***/ |
479 | static void ctk_notebook_measure_tabs (CtkCssGadget *gadget, |
480 | CtkOrientation orientation, |
481 | gint for_size, |
482 | gint *minimum, |
483 | gint *natural, |
484 | gint *minimum_baseline, |
485 | gint *natural_baseline, |
486 | gpointer data); |
487 | static void ctk_notebook_allocate_tabs (CtkCssGadget *gadget, |
488 | const CtkAllocation *allocation, |
489 | int baseline, |
490 | CtkAllocation *out_clip, |
491 | gpointer data); |
492 | static gboolean ctk_notebook_draw_tabs (CtkCssGadget *gadget, |
493 | cairo_t *cr, |
494 | int x, |
495 | int y, |
496 | int width, |
497 | int height, |
498 | gpointer data); |
499 | static void ctk_notebook_measure_stack (CtkCssGadget *gadget, |
500 | CtkOrientation orientation, |
501 | gint for_size, |
502 | gint *minimum, |
503 | gint *natural, |
504 | gint *minimum_baseline, |
505 | gint *natural_baseline, |
506 | gpointer data); |
507 | static void ctk_notebook_allocate_stack (CtkCssGadget *gadget, |
508 | const CtkAllocation *allocation, |
509 | int baseline, |
510 | CtkAllocation *out_clip, |
511 | gpointer data); |
512 | static gboolean ctk_notebook_draw_stack (CtkCssGadget *gadget, |
513 | cairo_t *cr, |
514 | int x, |
515 | int y, |
516 | int width, |
517 | int height, |
518 | gpointer data); |
519 | |
520 | /*** CtkNotebook Private Functions ***/ |
521 | static void ctk_notebook_redraw_arrows (CtkNotebook *notebook); |
522 | static void ctk_notebook_real_remove (CtkNotebook *notebook, |
523 | GList *list); |
524 | static void ctk_notebook_update_labels (CtkNotebook *notebook); |
525 | static gint ctk_notebook_timer (CtkNotebook *notebook); |
526 | static void ctk_notebook_set_scroll_timer (CtkNotebook *notebook); |
527 | static gint ctk_notebook_page_compare (gconstpointer a, |
528 | gconstpointer b); |
529 | static GList* ctk_notebook_find_child (CtkNotebook *notebook, |
530 | CtkWidget *child); |
531 | static GList * ctk_notebook_search_page (CtkNotebook *notebook, |
532 | GList *list, |
533 | gint direction, |
534 | gboolean find_visible); |
535 | static void ctk_notebook_child_reordered (CtkNotebook *notebook, |
536 | CtkNotebookPage *page); |
537 | |
538 | /*** CtkNotebook Size Allocate Functions ***/ |
539 | static void ctk_notebook_pages_allocate (CtkNotebook *notebook, |
540 | const CtkAllocation *allocation); |
541 | static void ctk_notebook_calc_tabs (CtkNotebook *notebook, |
542 | GList *start, |
543 | GList **end, |
544 | gint *tab_space, |
545 | guint direction); |
546 | |
547 | /*** CtkNotebook Page Switch Methods ***/ |
548 | static void ctk_notebook_real_switch_page (CtkNotebook *notebook, |
549 | CtkWidget *child, |
550 | guint page_num); |
551 | |
552 | /*** CtkNotebook Page Switch Functions ***/ |
553 | static void ctk_notebook_switch_page (CtkNotebook *notebook, |
554 | CtkNotebookPage *page); |
555 | static gint ctk_notebook_page_select (CtkNotebook *notebook, |
556 | gboolean move_focus); |
557 | static void ctk_notebook_switch_focus_tab (CtkNotebook *notebook, |
558 | GList *new_child); |
559 | static void ctk_notebook_menu_switch_page (CtkWidget *widget, |
560 | CtkNotebookPage *page); |
561 | |
562 | /*** CtkNotebook Menu Functions ***/ |
563 | static void ctk_notebook_menu_item_create (CtkNotebook *notebook, |
564 | GList *list); |
565 | static void ctk_notebook_menu_item_recreate (CtkNotebook *notebook, |
566 | GList *list); |
567 | static void ctk_notebook_menu_label_unparent (CtkWidget *widget, |
568 | gpointer data); |
569 | static void ctk_notebook_menu_detacher (CtkWidget *widget, |
570 | CtkMenu *menu); |
571 | |
572 | static void ctk_notebook_update_tab_pos (CtkNotebook *notebook); |
573 | |
574 | /*** CtkNotebook Private Setters ***/ |
575 | static gboolean ctk_notebook_mnemonic_activate_switch_page (CtkWidget *child, |
576 | gboolean overload, |
577 | gpointer data); |
578 | |
579 | static gboolean focus_tabs_in (CtkNotebook *notebook); |
580 | static gboolean focus_child_in (CtkNotebook *notebook, |
581 | CtkDirectionType direction); |
582 | |
583 | static void stop_scrolling (CtkNotebook *notebook); |
584 | static void do_detach_tab (CtkNotebook *from, |
585 | CtkNotebook *to, |
586 | CtkWidget *child, |
587 | gint x, |
588 | gint y); |
589 | |
590 | /* CtkBuildable */ |
591 | static void ctk_notebook_buildable_init (CtkBuildableIface *iface); |
592 | static void ctk_notebook_buildable_add_child (CtkBuildable *buildable, |
593 | CtkBuilder *builder, |
594 | GObject *child, |
595 | const gchar *type); |
596 | |
597 | static guint notebook_signals[LAST_SIGNAL] = { 0 }; |
598 | |
599 | G_DEFINE_TYPE_WITH_CODE (CtkNotebook, ctk_notebook, CTK_TYPE_CONTAINER,static void ctk_notebook_init (CtkNotebook *self); static void ctk_notebook_class_init (CtkNotebookClass *klass); static GType ctk_notebook_get_type_once (void); static gpointer ctk_notebook_parent_class = ((void*)0); static gint CtkNotebook_private_offset; static void ctk_notebook_class_intern_init (gpointer klass) { ctk_notebook_parent_class = g_type_class_peek_parent (klass); if (CtkNotebook_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkNotebook_private_offset ); ctk_notebook_class_init ((CtkNotebookClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_notebook_get_instance_private (CtkNotebook *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkNotebook_private_offset)))); } GType ctk_notebook_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_notebook_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_notebook_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkNotebook" ), sizeof (CtkNotebookClass), (GClassInitFunc)(void (*)(void) ) ctk_notebook_class_intern_init, sizeof (CtkNotebook), (GInstanceInitFunc )(void (*)(void)) ctk_notebook_init, (GTypeFlags) 0); { {{ CtkNotebook_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkNotebookPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_notebook_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; } |
600 | G_ADD_PRIVATE (CtkNotebook)static void ctk_notebook_init (CtkNotebook *self); static void ctk_notebook_class_init (CtkNotebookClass *klass); static GType ctk_notebook_get_type_once (void); static gpointer ctk_notebook_parent_class = ((void*)0); static gint CtkNotebook_private_offset; static void ctk_notebook_class_intern_init (gpointer klass) { ctk_notebook_parent_class = g_type_class_peek_parent (klass); if (CtkNotebook_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkNotebook_private_offset ); ctk_notebook_class_init ((CtkNotebookClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_notebook_get_instance_private (CtkNotebook *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkNotebook_private_offset)))); } GType ctk_notebook_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_notebook_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_notebook_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkNotebook" ), sizeof (CtkNotebookClass), (GClassInitFunc)(void (*)(void) ) ctk_notebook_class_intern_init, sizeof (CtkNotebook), (GInstanceInitFunc )(void (*)(void)) ctk_notebook_init, (GTypeFlags) 0); { {{ CtkNotebook_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkNotebookPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_notebook_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; } |
601 | G_IMPLEMENT_INTERFACE (CTK_TYPE_BUILDABLE,static void ctk_notebook_init (CtkNotebook *self); static void ctk_notebook_class_init (CtkNotebookClass *klass); static GType ctk_notebook_get_type_once (void); static gpointer ctk_notebook_parent_class = ((void*)0); static gint CtkNotebook_private_offset; static void ctk_notebook_class_intern_init (gpointer klass) { ctk_notebook_parent_class = g_type_class_peek_parent (klass); if (CtkNotebook_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkNotebook_private_offset ); ctk_notebook_class_init ((CtkNotebookClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_notebook_get_instance_private (CtkNotebook *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkNotebook_private_offset)))); } GType ctk_notebook_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_notebook_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_notebook_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkNotebook" ), sizeof (CtkNotebookClass), (GClassInitFunc)(void (*)(void) ) ctk_notebook_class_intern_init, sizeof (CtkNotebook), (GInstanceInitFunc )(void (*)(void)) ctk_notebook_init, (GTypeFlags) 0); { {{ CtkNotebook_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkNotebookPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_notebook_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; } |
602 | ctk_notebook_buildable_init))static void ctk_notebook_init (CtkNotebook *self); static void ctk_notebook_class_init (CtkNotebookClass *klass); static GType ctk_notebook_get_type_once (void); static gpointer ctk_notebook_parent_class = ((void*)0); static gint CtkNotebook_private_offset; static void ctk_notebook_class_intern_init (gpointer klass) { ctk_notebook_parent_class = g_type_class_peek_parent (klass); if (CtkNotebook_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkNotebook_private_offset ); ctk_notebook_class_init ((CtkNotebookClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_notebook_get_instance_private (CtkNotebook *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkNotebook_private_offset)))); } GType ctk_notebook_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_notebook_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_notebook_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_container_get_type ()), g_intern_static_string ("CtkNotebook" ), sizeof (CtkNotebookClass), (GClassInitFunc)(void (*)(void) ) ctk_notebook_class_intern_init, sizeof (CtkNotebook), (GInstanceInitFunc )(void (*)(void)) ctk_notebook_init, (GTypeFlags) 0); { {{ CtkNotebook_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkNotebookPrivate )); } { const GInterfaceInfo g_implement_interface_info = { ( GInterfaceInitFunc)(void (*)(void)) ctk_notebook_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; } |
603 | |
604 | static void |
605 | add_tab_bindings (CtkBindingSet *binding_set, |
606 | CdkModifierType modifiers, |
607 | CtkDirectionType direction) |
608 | { |
609 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_Tab0xff09, modifiers, |
610 | "move_focus_out", 1, |
611 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); |
612 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Tab0xff89, modifiers, |
613 | "move_focus_out", 1, |
614 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); |
615 | } |
616 | |
617 | static void |
618 | add_arrow_bindings (CtkBindingSet *binding_set, |
619 | guint keysym, |
620 | CtkDirectionType direction) |
621 | { |
622 | guint keypad_keysym = keysym - CDK_KEY_Left0xff51 + CDK_KEY_KP_Left0xff96; |
623 | |
624 | ctk_binding_entry_add_signal (binding_set, keysym, CDK_CONTROL_MASK, |
625 | "move_focus_out", 1, |
626 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); |
627 | ctk_binding_entry_add_signal (binding_set, keypad_keysym, CDK_CONTROL_MASK, |
628 | "move_focus_out", 1, |
629 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction); |
630 | } |
631 | |
632 | static void |
633 | add_reorder_bindings (CtkBindingSet *binding_set, |
634 | guint keysym, |
635 | CtkDirectionType direction, |
636 | gboolean move_to_last) |
637 | { |
638 | guint keypad_keysym = keysym - CDK_KEY_Left0xff51 + CDK_KEY_KP_Left0xff96; |
639 | |
640 | ctk_binding_entry_add_signal (binding_set, keysym, CDK_MOD1_MASK, |
641 | "reorder_tab", 2, |
642 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction, |
643 | G_TYPE_BOOLEAN((GType) ((5) << (2))), move_to_last); |
644 | ctk_binding_entry_add_signal (binding_set, keypad_keysym, CDK_MOD1_MASK, |
645 | "reorder_tab", 2, |
646 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), direction, |
647 | G_TYPE_BOOLEAN((GType) ((5) << (2))), move_to_last); |
648 | } |
649 | |
650 | static gboolean |
651 | ctk_object_handled_accumulator (GSignalInvocationHint *ihint G_GNUC_UNUSED__attribute__ ((__unused__)), |
652 | GValue *return_accu, |
653 | const GValue *handler_return, |
654 | gpointer dummy G_GNUC_UNUSED__attribute__ ((__unused__))) |
655 | { |
656 | gboolean continue_emission; |
657 | GObject *object; |
658 | |
659 | object = g_value_get_object (handler_return); |
660 | g_value_set_object (return_accu, object); |
661 | continue_emission = !object; |
662 | |
663 | return continue_emission; |
664 | } |
665 | |
666 | static void |
667 | ctk_notebook_compute_expand (CtkWidget *widget, |
668 | gboolean *hexpand_p, |
669 | gboolean *vexpand_p) |
670 | { |
671 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
672 | CtkNotebookPrivate *priv = notebook->priv; |
673 | gboolean hexpand; |
674 | gboolean vexpand; |
675 | GList *list; |
676 | CtkNotebookPage *page; |
677 | |
678 | hexpand = FALSE(0); |
679 | vexpand = FALSE(0); |
680 | |
681 | for (list = priv->children; list; list = list->next) |
682 | { |
683 | page = list->data; |
684 | |
685 | hexpand = hexpand || |
686 | ctk_widget_compute_expand (page->child, CTK_ORIENTATION_HORIZONTAL); |
687 | |
688 | vexpand = vexpand || |
689 | ctk_widget_compute_expand (page->child, CTK_ORIENTATION_VERTICAL); |
690 | |
691 | if (hexpand & vexpand) |
692 | break; |
693 | } |
694 | |
695 | *hexpand_p = hexpand; |
696 | *vexpand_p = vexpand; |
697 | } |
698 | |
699 | static void |
700 | ctk_notebook_class_init (CtkNotebookClass *class) |
701 | { |
702 | GObjectClass *gobject_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))); |
703 | CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), ((ctk_widget_get_type ())))))); |
704 | CtkContainerClass *container_class = CTK_CONTAINER_CLASS (class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), ((ctk_container_get_type ())))))); |
705 | CtkBindingSet *binding_set; |
706 | |
707 | gobject_class->set_property = ctk_notebook_set_property; |
708 | gobject_class->get_property = ctk_notebook_get_property; |
709 | gobject_class->finalize = ctk_notebook_finalize; |
710 | |
711 | widget_class->destroy = ctk_notebook_destroy; |
712 | widget_class->map = ctk_notebook_map; |
713 | widget_class->unmap = ctk_notebook_unmap; |
714 | widget_class->realize = ctk_notebook_realize; |
715 | widget_class->unrealize = ctk_notebook_unrealize; |
716 | widget_class->get_preferred_width = ctk_notebook_get_preferred_width; |
717 | widget_class->get_preferred_height = ctk_notebook_get_preferred_height; |
718 | widget_class->get_preferred_width_for_height = ctk_notebook_get_preferred_width_for_height; |
719 | widget_class->get_preferred_height_for_width = ctk_notebook_get_preferred_height_for_width; |
720 | widget_class->size_allocate = ctk_notebook_size_allocate; |
721 | widget_class->draw = ctk_notebook_draw; |
722 | widget_class->button_press_event = ctk_notebook_button_press; |
723 | widget_class->button_release_event = ctk_notebook_button_release; |
724 | widget_class->popup_menu = ctk_notebook_popup_menu; |
725 | widget_class->enter_notify_event = ctk_notebook_enter_notify; |
726 | widget_class->leave_notify_event = ctk_notebook_leave_notify; |
727 | widget_class->motion_notify_event = ctk_notebook_motion_notify; |
728 | widget_class->grab_notify = ctk_notebook_grab_notify; |
729 | widget_class->state_flags_changed = ctk_notebook_state_flags_changed; |
730 | widget_class->focus_in_event = ctk_notebook_focus_in; |
731 | widget_class->focus_out_event = ctk_notebook_focus_out; |
732 | widget_class->focus = ctk_notebook_focus; |
733 | widget_class->style_updated = ctk_notebook_style_updated; |
734 | widget_class->drag_begin = ctk_notebook_drag_begin; |
735 | widget_class->drag_end = ctk_notebook_drag_end; |
736 | widget_class->drag_motion = ctk_notebook_drag_motion; |
737 | widget_class->drag_leave = ctk_notebook_drag_leave; |
738 | widget_class->drag_drop = ctk_notebook_drag_drop; |
739 | widget_class->drag_data_get = ctk_notebook_drag_data_get; |
740 | widget_class->drag_data_received = ctk_notebook_drag_data_received; |
741 | widget_class->drag_failed = ctk_notebook_drag_failed; |
742 | widget_class->compute_expand = ctk_notebook_compute_expand; |
743 | widget_class->direction_changed = ctk_notebook_direction_changed; |
744 | |
745 | container_class->add = ctk_notebook_add; |
746 | container_class->remove = ctk_notebook_remove; |
747 | container_class->forall = ctk_notebook_forall; |
748 | container_class->set_focus_child = ctk_notebook_set_focus_child; |
749 | container_class->get_child_property = ctk_notebook_get_child_property; |
750 | container_class->set_child_property = ctk_notebook_set_child_property; |
751 | container_class->child_type = ctk_notebook_child_type; |
752 | |
753 | class->switch_page = ctk_notebook_real_switch_page; |
754 | class->insert_page = ctk_notebook_real_insert_page; |
755 | |
756 | class->focus_tab = ctk_notebook_focus_tab; |
757 | class->select_page = ctk_notebook_select_page; |
758 | class->change_current_page = ctk_notebook_change_current_page; |
759 | class->move_focus_out = ctk_notebook_move_focus_out; |
760 | class->reorder_tab = ctk_notebook_reorder_tab; |
761 | class->create_window = ctk_notebook_create_window; |
762 | |
763 | properties[PROP_PAGE] = |
764 | g_param_spec_int ("page", |
765 | P_("Page")g_dgettext("ctk30" "-properties","Page"), |
766 | P_("The index of the current page")g_dgettext("ctk30" "-properties","The index of the current page" ), |
767 | -1, G_MAXINT2147483647, |
768 | -1, |
769 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
770 | |
771 | properties[PROP_TAB_POS] = |
772 | g_param_spec_enum ("tab-pos", |
773 | P_("Tab Position")g_dgettext("ctk30" "-properties","Tab Position"), |
774 | P_("Which side of the notebook holds the tabs")g_dgettext("ctk30" "-properties","Which side of the notebook holds the tabs" ), |
775 | CTK_TYPE_POSITION_TYPE(ctk_position_type_get_type ()), |
776 | CTK_POS_TOP, |
777 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
778 | |
779 | properties[PROP_SHOW_TABS] = |
780 | g_param_spec_boolean ("show-tabs", |
781 | P_("Show Tabs")g_dgettext("ctk30" "-properties","Show Tabs"), |
782 | P_("Whether tabs should be shown")g_dgettext("ctk30" "-properties","Whether tabs should be shown" ), |
783 | TRUE(!(0)), |
784 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
785 | |
786 | properties[PROP_SHOW_BORDER] = |
787 | g_param_spec_boolean ("show-border", |
788 | P_("Show Border")g_dgettext("ctk30" "-properties","Show Border"), |
789 | P_("Whether the border should be shown")g_dgettext("ctk30" "-properties","Whether the border should be shown" ), |
790 | TRUE(!(0)), |
791 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
792 | |
793 | properties[PROP_SCROLLABLE] = |
794 | g_param_spec_boolean ("scrollable", |
795 | P_("Scrollable")g_dgettext("ctk30" "-properties","Scrollable"), |
796 | P_("If TRUE, scroll arrows are added if there are too many tabs to fit")g_dgettext("ctk30" "-properties","If TRUE, scroll arrows are added if there are too many tabs to fit" ), |
797 | FALSE(0), |
798 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
799 | |
800 | properties[PROP_ENABLE_POPUP] = |
801 | g_param_spec_boolean ("enable-popup", |
802 | P_("Enable Popup")g_dgettext("ctk30" "-properties","Enable Popup"), |
803 | P_("If TRUE, pressing the right mouse button on the notebook pops up a menu that you can use to go to a page")g_dgettext("ctk30" "-properties","If TRUE, pressing the right mouse button on the notebook pops up a menu that you can use to go to a page" ), |
804 | FALSE(0), |
805 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
806 | |
807 | /** |
808 | * CtkNotebook:group-name: |
809 | * |
810 | * Group name for tab drag and drop. |
811 | * |
812 | * Since: 2.24 |
813 | */ |
814 | properties[PROP_GROUP_NAME] = |
815 | g_param_spec_string ("group-name", |
816 | P_("Group Name")g_dgettext("ctk30" "-properties","Group Name"), |
817 | P_("Group name for tab drag and drop")g_dgettext("ctk30" "-properties","Group name for tab drag and drop" ), |
818 | NULL((void*)0), |
819 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY); |
820 | |
821 | g_object_class_install_properties (gobject_class, LAST_PROP, properties); |
822 | |
823 | ctk_container_class_install_child_property (container_class, |
824 | CHILD_PROP_TAB_LABEL, |
825 | g_param_spec_string ("tab-label", |
826 | P_("Tab label")g_dgettext("ctk30" "-properties","Tab label"), |
827 | P_("The string displayed on the child's tab label")g_dgettext("ctk30" "-properties","The string displayed on the child's tab label" ), |
828 | NULL((void*)0), |
829 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
830 | ctk_container_class_install_child_property (container_class, |
831 | CHILD_PROP_MENU_LABEL, |
832 | g_param_spec_string ("menu-label", |
833 | P_("Menu label")g_dgettext("ctk30" "-properties","Menu label"), |
834 | P_("The string displayed in the child's menu entry")g_dgettext("ctk30" "-properties","The string displayed in the child's menu entry" ), |
835 | NULL((void*)0), |
836 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
837 | ctk_container_class_install_child_property (container_class, |
838 | CHILD_PROP_POSITION, |
839 | g_param_spec_int ("position", |
840 | P_("Position")g_dgettext("ctk30" "-properties","Position"), |
841 | P_("The index of the child in the parent")g_dgettext("ctk30" "-properties","The index of the child in the parent" ), |
842 | -1, G_MAXINT2147483647, 0, |
843 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
844 | ctk_container_class_install_child_property (container_class, |
845 | CHILD_PROP_TAB_EXPAND, |
846 | g_param_spec_boolean ("tab-expand", |
847 | P_("Tab expand")g_dgettext("ctk30" "-properties","Tab expand"), |
848 | P_("Whether to expand the child's tab")g_dgettext("ctk30" "-properties","Whether to expand the child's tab" ), |
849 | FALSE(0), |
850 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
851 | ctk_container_class_install_child_property (container_class, |
852 | CHILD_PROP_TAB_FILL, |
853 | g_param_spec_boolean ("tab-fill", |
854 | P_("Tab fill")g_dgettext("ctk30" "-properties","Tab fill"), |
855 | P_("Whether the child's tab should fill the allocated area")g_dgettext("ctk30" "-properties","Whether the child's tab should fill the allocated area" ), |
856 | TRUE(!(0)), |
857 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
858 | |
859 | ctk_container_class_install_child_property (container_class, |
860 | CHILD_PROP_REORDERABLE, |
861 | g_param_spec_boolean ("reorderable", |
862 | P_("Tab reorderable")g_dgettext("ctk30" "-properties","Tab reorderable"), |
863 | P_("Whether the tab is reorderable by user action")g_dgettext("ctk30" "-properties","Whether the tab is reorderable by user action" ), |
864 | FALSE(0), |
865 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
866 | ctk_container_class_install_child_property (container_class, |
867 | CHILD_PROP_DETACHABLE, |
868 | g_param_spec_boolean ("detachable", |
869 | P_("Tab detachable")g_dgettext("ctk30" "-properties","Tab detachable"), |
870 | P_("Whether the tab is detachable")g_dgettext("ctk30" "-properties","Whether the tab is detachable" ), |
871 | FALSE(0), |
872 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
873 | |
874 | /** |
875 | * CtkNotebook:has-secondary-backward-stepper: |
876 | * |
877 | * The “has-secondary-backward-stepper” property determines whether |
878 | * a second backward arrow button is displayed on the opposite end |
879 | * of the tab area. |
880 | * |
881 | * Since: 2.4 |
882 | */ |
883 | ctk_widget_class_install_style_property (widget_class, |
884 | g_param_spec_boolean ("has-secondary-backward-stepper", |
885 | P_("Secondary backward stepper")g_dgettext("ctk30" "-properties","Secondary backward stepper" ), |
886 | P_("Display a second backward arrow button on the opposite end of the tab area")g_dgettext("ctk30" "-properties","Display a second backward arrow button on the opposite end of the tab area" ), |
887 | FALSE(0), |
888 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
889 | |
890 | /** |
891 | * CtkNotebook:has-secondary-forward-stepper: |
892 | * |
893 | * The “has-secondary-forward-stepper” property determines whether |
894 | * a second forward arrow button is displayed on the opposite end |
895 | * of the tab area. |
896 | * |
897 | * Since: 2.4 |
898 | */ |
899 | ctk_widget_class_install_style_property (widget_class, |
900 | g_param_spec_boolean ("has-secondary-forward-stepper", |
901 | P_("Secondary forward stepper")g_dgettext("ctk30" "-properties","Secondary forward stepper"), |
902 | P_("Display a second forward arrow button on the opposite end of the tab area")g_dgettext("ctk30" "-properties","Display a second forward arrow button on the opposite end of the tab area" ), |
903 | FALSE(0), |
904 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
905 | |
906 | /** |
907 | * CtkNotebook:has-backward-stepper: |
908 | * |
909 | * The “has-backward-stepper” property determines whether |
910 | * the standard backward arrow button is displayed. |
911 | * |
912 | * Since: 2.4 |
913 | */ |
914 | ctk_widget_class_install_style_property (widget_class, |
915 | g_param_spec_boolean ("has-backward-stepper", |
916 | P_("Backward stepper")g_dgettext("ctk30" "-properties","Backward stepper"), |
917 | P_("Display the standard backward arrow button")g_dgettext("ctk30" "-properties","Display the standard backward arrow button" ), |
918 | TRUE(!(0)), |
919 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
920 | |
921 | /** |
922 | * CtkNotebook:has-forward-stepper: |
923 | * |
924 | * The “has-forward-stepper” property determines whether |
925 | * the standard forward arrow button is displayed. |
926 | * |
927 | * Since: 2.4 |
928 | */ |
929 | ctk_widget_class_install_style_property (widget_class, |
930 | g_param_spec_boolean ("has-forward-stepper", |
931 | P_("Forward stepper")g_dgettext("ctk30" "-properties","Forward stepper"), |
932 | P_("Display the standard forward arrow button")g_dgettext("ctk30" "-properties","Display the standard forward arrow button" ), |
933 | TRUE(!(0)), |
934 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
935 | |
936 | /** |
937 | * CtkNotebook:tab-overlap: |
938 | * |
939 | * The “tab-overlap” property defines size of tab overlap |
940 | * area. |
941 | * |
942 | * Since: 2.10 |
943 | * |
944 | * Deprecated: 3.20: This property is ignored. Use margins on tab nodes |
945 | * to achieve the same effect. |
946 | */ |
947 | ctk_widget_class_install_style_property (widget_class, |
948 | g_param_spec_int ("tab-overlap", |
949 | P_("Tab overlap")g_dgettext("ctk30" "-properties","Tab overlap"), |
950 | P_("Size of tab overlap area")g_dgettext("ctk30" "-properties","Size of tab overlap area"), |
951 | G_MININT(-2147483647 -1), |
952 | G_MAXINT2147483647, |
953 | 2, |
954 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED)); |
955 | |
956 | /** |
957 | * CtkNotebook:tab-curvature: |
958 | * |
959 | * The “tab-curvature” property defines size of tab curvature. |
960 | * |
961 | * Since: 2.10 |
962 | * |
963 | * Deprecated: 3.20: This property is ignored. Use margins on tab nodes |
964 | * to achieve the same effect. |
965 | */ |
966 | ctk_widget_class_install_style_property (widget_class, |
967 | g_param_spec_int ("tab-curvature", |
968 | P_("Tab curvature")g_dgettext("ctk30" "-properties","Tab curvature"), |
969 | P_("Size of tab curvature")g_dgettext("ctk30" "-properties","Size of tab curvature"), |
970 | 0, |
971 | G_MAXINT2147483647, |
972 | 1, |
973 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED)); |
974 | |
975 | /** |
976 | * CtkNotebook:arrow-spacing: |
977 | * |
978 | * The "arrow-spacing" property defines the spacing between the scroll |
979 | * arrows and the tabs. |
980 | * |
981 | * Since: 2.10 |
982 | * |
983 | * Deprecated: 3.20: This property is ignored. Use margins on arrows or |
984 | * the "tabs" node to achieve the same effect. |
985 | */ |
986 | ctk_widget_class_install_style_property (widget_class, |
987 | g_param_spec_int ("arrow-spacing", |
988 | P_("Arrow spacing")g_dgettext("ctk30" "-properties","Arrow spacing"), |
989 | P_("Scroll arrow spacing")g_dgettext("ctk30" "-properties","Scroll arrow spacing"), |
990 | 0, |
991 | G_MAXINT2147483647, |
992 | 0, |
993 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED)); |
994 | |
995 | /** |
996 | * CtkNotebook:initial-gap: |
997 | * |
998 | * The "initial-gap" property defines the minimum size for the initial |
999 | * gap between the first tab. |
1000 | * |
1001 | * Since: 3.2 |
1002 | * |
1003 | * Deprecated: 3.20: The intial gap is ignored. Use margins on the header node |
1004 | * to achieve the same effect. |
1005 | */ |
1006 | ctk_widget_class_install_style_property (widget_class, |
1007 | g_param_spec_int ("initial-gap", |
1008 | P_("Initial gap")g_dgettext("ctk30" "-properties","Initial gap"), |
1009 | P_("Initial gap before the first tab")g_dgettext("ctk30" "-properties","Initial gap before the first tab" ), |
1010 | 0, |
1011 | G_MAXINT2147483647, |
1012 | 0, |
1013 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED)); |
1014 | |
1015 | /** |
1016 | * CtkNotebook:has-tab-gap: |
1017 | * |
1018 | * The "has-tab-gap" property defines whether the active tab is draw |
1019 | * with a gap at the bottom. When %TRUE the theme engine uses |
1020 | * ctk_render_extension to draw the active tab. When %FALSE |
1021 | * ctk_render_background and ctk_render_frame are used. |
1022 | * |
1023 | * Since: 3.12 |
1024 | * |
1025 | * Deprecated: 3.20: This function always behaves as if it was set to %FALSE. |
1026 | */ |
1027 | ctk_widget_class_install_style_property (widget_class, |
1028 | g_param_spec_boolean ("has-tab-gap", |
1029 | P_("Tab gap")g_dgettext("ctk30" "-properties","Tab gap"), |
1030 | P_("Active tab is drawn with a gap at the bottom")g_dgettext("ctk30" "-properties","Active tab is drawn with a gap at the bottom" ), |
1031 | TRUE(!(0)), |
1032 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB | G_PARAM_DEPRECATED)); |
1033 | |
1034 | /** |
1035 | * CtkNotebook::switch-page: |
1036 | * @notebook: the object which received the signal. |
1037 | * @page: the new current page |
1038 | * @page_num: the index of the page |
1039 | * |
1040 | * Emitted when the user or a function changes the current page. |
1041 | */ |
1042 | notebook_signals[SWITCH_PAGE] = |
1043 | g_signal_new (I_("switch-page")g_intern_static_string ("switch-page"), |
1044 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1045 | G_SIGNAL_RUN_LAST, |
1046 | G_STRUCT_OFFSET (CtkNotebookClass, switch_page)((glong) __builtin_offsetof(CtkNotebookClass, switch_page)), |
1047 | NULL((void*)0), NULL((void*)0), |
1048 | _ctk_marshal_VOID__OBJECT_UINT, |
1049 | G_TYPE_NONE((GType) ((1) << (2))), 2, |
1050 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), |
1051 | G_TYPE_UINT((GType) ((7) << (2)))); |
1052 | g_signal_set_va_marshaller (notebook_signals[SWITCH_PAGE], |
1053 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1054 | _ctk_marshal_VOID__OBJECT_UINTv); |
1055 | notebook_signals[FOCUS_TAB] = |
1056 | g_signal_new (I_("focus-tab")g_intern_static_string ("focus-tab"), |
1057 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1058 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
1059 | G_STRUCT_OFFSET (CtkNotebookClass, focus_tab)((glong) __builtin_offsetof(CtkNotebookClass, focus_tab)), |
1060 | NULL((void*)0), NULL((void*)0), |
1061 | _ctk_marshal_BOOLEAN__ENUM, |
1062 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 1, |
1063 | CTK_TYPE_NOTEBOOK_TAB(ctk_notebook_tab_get_type ())); |
1064 | g_signal_set_va_marshaller (notebook_signals[FOCUS_TAB], |
1065 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1066 | _ctk_marshal_BOOLEAN__ENUMv); |
1067 | notebook_signals[SELECT_PAGE] = |
1068 | g_signal_new (I_("select-page")g_intern_static_string ("select-page"), |
1069 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1070 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
1071 | G_STRUCT_OFFSET (CtkNotebookClass, select_page)((glong) __builtin_offsetof(CtkNotebookClass, select_page)), |
1072 | NULL((void*)0), NULL((void*)0), |
1073 | _ctk_marshal_BOOLEAN__BOOLEAN, |
1074 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 1, |
1075 | G_TYPE_BOOLEAN((GType) ((5) << (2)))); |
1076 | g_signal_set_va_marshaller (notebook_signals[SELECT_PAGE], |
1077 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1078 | _ctk_marshal_BOOLEAN__BOOLEANv); |
1079 | notebook_signals[CHANGE_CURRENT_PAGE] = |
1080 | g_signal_new (I_("change-current-page")g_intern_static_string ("change-current-page"), |
1081 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1082 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
1083 | G_STRUCT_OFFSET (CtkNotebookClass, change_current_page)((glong) __builtin_offsetof(CtkNotebookClass, change_current_page )), |
1084 | NULL((void*)0), NULL((void*)0), |
1085 | _ctk_marshal_BOOLEAN__INT, |
1086 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 1, |
1087 | G_TYPE_INT((GType) ((6) << (2)))); |
1088 | g_signal_set_va_marshaller (notebook_signals[CHANGE_CURRENT_PAGE], |
1089 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1090 | _ctk_marshal_BOOLEAN__INTv); |
1091 | notebook_signals[MOVE_FOCUS_OUT] = |
1092 | g_signal_new (I_("move-focus-out")g_intern_static_string ("move-focus-out"), |
1093 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1094 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
1095 | G_STRUCT_OFFSET (CtkNotebookClass, move_focus_out)((glong) __builtin_offsetof(CtkNotebookClass, move_focus_out) ), |
1096 | NULL((void*)0), NULL((void*)0), |
1097 | NULL((void*)0), |
1098 | G_TYPE_NONE((GType) ((1) << (2))), 1, |
1099 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ())); |
1100 | notebook_signals[REORDER_TAB] = |
1101 | g_signal_new (I_("reorder-tab")g_intern_static_string ("reorder-tab"), |
1102 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1103 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
1104 | G_STRUCT_OFFSET (CtkNotebookClass, reorder_tab)((glong) __builtin_offsetof(CtkNotebookClass, reorder_tab)), |
1105 | NULL((void*)0), NULL((void*)0), |
1106 | _ctk_marshal_BOOLEAN__ENUM_BOOLEAN, |
1107 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 2, |
1108 | CTK_TYPE_DIRECTION_TYPE(ctk_direction_type_get_type ()), |
1109 | G_TYPE_BOOLEAN((GType) ((5) << (2)))); |
1110 | g_signal_set_va_marshaller (notebook_signals[REORDER_TAB], |
1111 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1112 | _ctk_marshal_BOOLEAN__ENUM_BOOLEANv); |
1113 | /** |
1114 | * CtkNotebook::page-reordered: |
1115 | * @notebook: the #CtkNotebook |
1116 | * @child: the child #CtkWidget affected |
1117 | * @page_num: the new page number for @child |
1118 | * |
1119 | * the ::page-reordered signal is emitted in the notebook |
1120 | * right after a page has been reordered. |
1121 | * |
1122 | * Since: 2.10 |
1123 | */ |
1124 | notebook_signals[PAGE_REORDERED] = |
1125 | g_signal_new (I_("page-reordered")g_intern_static_string ("page-reordered"), |
1126 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1127 | G_SIGNAL_RUN_LAST, |
1128 | G_STRUCT_OFFSET (CtkNotebookClass, page_reordered)((glong) __builtin_offsetof(CtkNotebookClass, page_reordered) ), |
1129 | NULL((void*)0), NULL((void*)0), |
1130 | _ctk_marshal_VOID__OBJECT_UINT, |
1131 | G_TYPE_NONE((GType) ((1) << (2))), 2, |
1132 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), |
1133 | G_TYPE_UINT((GType) ((7) << (2)))); |
1134 | g_signal_set_va_marshaller (notebook_signals[PAGE_REORDERED], |
1135 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1136 | _ctk_marshal_VOID__OBJECT_UINTv); |
1137 | /** |
1138 | * CtkNotebook::page-removed: |
1139 | * @notebook: the #CtkNotebook |
1140 | * @child: the child #CtkWidget affected |
1141 | * @page_num: the @child page number |
1142 | * |
1143 | * the ::page-removed signal is emitted in the notebook |
1144 | * right after a page is removed from the notebook. |
1145 | * |
1146 | * Since: 2.10 |
1147 | */ |
1148 | notebook_signals[PAGE_REMOVED] = |
1149 | g_signal_new (I_("page-removed")g_intern_static_string ("page-removed"), |
1150 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1151 | G_SIGNAL_RUN_LAST, |
1152 | G_STRUCT_OFFSET (CtkNotebookClass, page_removed)((glong) __builtin_offsetof(CtkNotebookClass, page_removed)), |
1153 | NULL((void*)0), NULL((void*)0), |
1154 | _ctk_marshal_VOID__OBJECT_UINT, |
1155 | G_TYPE_NONE((GType) ((1) << (2))), 2, |
1156 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), |
1157 | G_TYPE_UINT((GType) ((7) << (2)))); |
1158 | g_signal_set_va_marshaller (notebook_signals[PAGE_REMOVED], |
1159 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1160 | _ctk_marshal_VOID__OBJECT_UINTv); |
1161 | /** |
1162 | * CtkNotebook::page-added: |
1163 | * @notebook: the #CtkNotebook |
1164 | * @child: the child #CtkWidget affected |
1165 | * @page_num: the new page number for @child |
1166 | * |
1167 | * the ::page-added signal is emitted in the notebook |
1168 | * right after a page is added to the notebook. |
1169 | * |
1170 | * Since: 2.10 |
1171 | */ |
1172 | notebook_signals[PAGE_ADDED] = |
1173 | g_signal_new (I_("page-added")g_intern_static_string ("page-added"), |
1174 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1175 | G_SIGNAL_RUN_LAST, |
1176 | G_STRUCT_OFFSET (CtkNotebookClass, page_added)((glong) __builtin_offsetof(CtkNotebookClass, page_added)), |
1177 | NULL((void*)0), NULL((void*)0), |
1178 | _ctk_marshal_VOID__OBJECT_UINT, |
1179 | G_TYPE_NONE((GType) ((1) << (2))), 2, |
1180 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), |
1181 | G_TYPE_UINT((GType) ((7) << (2)))); |
1182 | g_signal_set_va_marshaller (notebook_signals[PAGE_ADDED], |
1183 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1184 | _ctk_marshal_VOID__OBJECT_UINTv); |
1185 | |
1186 | /** |
1187 | * CtkNotebook::create-window: |
1188 | * @notebook: the #CtkNotebook emitting the signal |
1189 | * @page: the tab of @notebook that is being detached |
1190 | * @x: the X coordinate where the drop happens |
1191 | * @y: the Y coordinate where the drop happens |
1192 | * |
1193 | * The ::create-window signal is emitted when a detachable |
1194 | * tab is dropped on the root window. |
1195 | * |
1196 | * A handler for this signal can create a window containing |
1197 | * a notebook where the tab will be attached. It is also |
1198 | * responsible for moving/resizing the window and adding the |
1199 | * necessary properties to the notebook (e.g. the |
1200 | * #CtkNotebook:group-name ). |
1201 | * |
1202 | * Returns: (transfer none): a #CtkNotebook that @page should be |
1203 | * added to, or %NULL. |
1204 | * |
1205 | * Since: 2.12 |
1206 | */ |
1207 | notebook_signals[CREATE_WINDOW] = |
1208 | g_signal_new (I_("create-window")g_intern_static_string ("create-window"), |
1209 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1210 | G_SIGNAL_RUN_LAST, |
1211 | G_STRUCT_OFFSET (CtkNotebookClass, create_window)((glong) __builtin_offsetof(CtkNotebookClass, create_window)), |
1212 | ctk_object_handled_accumulator, NULL((void*)0), |
1213 | _ctk_marshal_OBJECT__OBJECT_INT_INT, |
1214 | CTK_TYPE_NOTEBOOK(ctk_notebook_get_type ()), 3, |
1215 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), G_TYPE_INT((GType) ((6) << (2))), G_TYPE_INT((GType) ((6) << (2)))); |
1216 | g_signal_set_va_marshaller (notebook_signals[CREATE_WINDOW], |
1217 | G_TYPE_FROM_CLASS (gobject_class)(((GTypeClass*) (gobject_class))->g_type), |
1218 | _ctk_marshal_OBJECT__OBJECT_INT_INTv); |
1219 | |
1220 | binding_set = ctk_binding_set_by_class (class); |
1221 | ctk_binding_entry_add_signal (binding_set, |
1222 | CDK_KEY_space0x020, 0, |
1223 | "select-page", 1, |
1224 | G_TYPE_BOOLEAN((GType) ((5) << (2))), FALSE(0)); |
1225 | ctk_binding_entry_add_signal (binding_set, |
1226 | CDK_KEY_KP_Space0xff80, 0, |
1227 | "select-page", 1, |
1228 | G_TYPE_BOOLEAN((GType) ((5) << (2))), FALSE(0)); |
1229 | |
1230 | ctk_binding_entry_add_signal (binding_set, |
1231 | CDK_KEY_Home0xff50, 0, |
1232 | "focus-tab", 1, |
1233 | CTK_TYPE_NOTEBOOK_TAB(ctk_notebook_tab_get_type ()), CTK_NOTEBOOK_TAB_FIRST); |
1234 | ctk_binding_entry_add_signal (binding_set, |
1235 | CDK_KEY_KP_Home0xff95, 0, |
1236 | "focus-tab", 1, |
1237 | CTK_TYPE_NOTEBOOK_TAB(ctk_notebook_tab_get_type ()), CTK_NOTEBOOK_TAB_FIRST); |
1238 | ctk_binding_entry_add_signal (binding_set, |
1239 | CDK_KEY_End0xff57, 0, |
1240 | "focus-tab", 1, |
1241 | CTK_TYPE_NOTEBOOK_TAB(ctk_notebook_tab_get_type ()), CTK_NOTEBOOK_TAB_LAST); |
1242 | ctk_binding_entry_add_signal (binding_set, |
1243 | CDK_KEY_KP_End0xff9c, 0, |
1244 | "focus-tab", 1, |
1245 | CTK_TYPE_NOTEBOOK_TAB(ctk_notebook_tab_get_type ()), CTK_NOTEBOOK_TAB_LAST); |
1246 | |
1247 | ctk_binding_entry_add_signal (binding_set, |
1248 | CDK_KEY_Page_Up0xff55, CDK_CONTROL_MASK, |
1249 | "change-current-page", 1, |
1250 | G_TYPE_INT((GType) ((6) << (2))), -1); |
1251 | ctk_binding_entry_add_signal (binding_set, |
1252 | CDK_KEY_Page_Down0xff56, CDK_CONTROL_MASK, |
1253 | "change-current-page", 1, |
1254 | G_TYPE_INT((GType) ((6) << (2))), 1); |
1255 | |
1256 | ctk_binding_entry_add_signal (binding_set, |
1257 | CDK_KEY_Page_Up0xff55, CDK_CONTROL_MASK | CDK_MOD1_MASK, |
1258 | "change-current-page", 1, |
1259 | G_TYPE_INT((GType) ((6) << (2))), -1); |
1260 | ctk_binding_entry_add_signal (binding_set, |
1261 | CDK_KEY_Page_Down0xff56, CDK_CONTROL_MASK | CDK_MOD1_MASK, |
1262 | "change-current-page", 1, |
1263 | G_TYPE_INT((GType) ((6) << (2))), 1); |
1264 | |
1265 | add_arrow_bindings (binding_set, CDK_KEY_Up0xff52, CTK_DIR_UP); |
1266 | add_arrow_bindings (binding_set, CDK_KEY_Down0xff54, CTK_DIR_DOWN); |
1267 | add_arrow_bindings (binding_set, CDK_KEY_Left0xff51, CTK_DIR_LEFT); |
1268 | add_arrow_bindings (binding_set, CDK_KEY_Right0xff53, CTK_DIR_RIGHT); |
1269 | |
1270 | add_reorder_bindings (binding_set, CDK_KEY_Up0xff52, CTK_DIR_UP, FALSE(0)); |
1271 | add_reorder_bindings (binding_set, CDK_KEY_Down0xff54, CTK_DIR_DOWN, FALSE(0)); |
1272 | add_reorder_bindings (binding_set, CDK_KEY_Left0xff51, CTK_DIR_LEFT, FALSE(0)); |
1273 | add_reorder_bindings (binding_set, CDK_KEY_Right0xff53, CTK_DIR_RIGHT, FALSE(0)); |
1274 | add_reorder_bindings (binding_set, CDK_KEY_Home0xff50, CTK_DIR_LEFT, TRUE(!(0))); |
1275 | add_reorder_bindings (binding_set, CDK_KEY_Home0xff50, CTK_DIR_UP, TRUE(!(0))); |
1276 | add_reorder_bindings (binding_set, CDK_KEY_End0xff57, CTK_DIR_RIGHT, TRUE(!(0))); |
1277 | add_reorder_bindings (binding_set, CDK_KEY_End0xff57, CTK_DIR_DOWN, TRUE(!(0))); |
1278 | |
1279 | add_tab_bindings (binding_set, CDK_CONTROL_MASK, CTK_DIR_TAB_FORWARD); |
1280 | add_tab_bindings (binding_set, CDK_CONTROL_MASK | CDK_SHIFT_MASK, CTK_DIR_TAB_BACKWARD); |
1281 | |
1282 | ctk_container_class_handle_border_width (container_class); |
1283 | |
1284 | ctk_widget_class_set_accessible_type (widget_class, CTK_TYPE_NOTEBOOK_ACCESSIBLE(ctk_notebook_accessible_get_type ())); |
1285 | ctk_widget_class_set_css_name (widget_class, "notebook"); |
1286 | } |
1287 | |
1288 | static void |
1289 | ctk_notebook_init (CtkNotebook *notebook) |
1290 | { |
1291 | CtkNotebookPrivate *priv; |
1292 | CtkCssNode *widget_node; |
1293 | |
1294 | ctk_widget_set_can_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), TRUE(!(0))); |
1295 | ctk_widget_set_has_window (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), FALSE(0)); |
1296 | |
1297 | notebook->priv = ctk_notebook_get_instance_private (notebook); |
1298 | priv = notebook->priv; |
1299 | |
1300 | priv->cur_page = NULL((void*)0); |
1301 | priv->children = NULL((void*)0); |
1302 | priv->first_tab = NULL((void*)0); |
1303 | priv->focus_tab = NULL((void*)0); |
1304 | priv->event_window = NULL((void*)0); |
1305 | priv->menu = NULL((void*)0); |
1306 | |
1307 | priv->show_tabs = TRUE(!(0)); |
1308 | priv->show_border = TRUE(!(0)); |
1309 | priv->tab_pos = CTK_POS_TOP; |
1310 | priv->scrollable = FALSE(0); |
1311 | priv->in_child = ARROW_NONE; |
1312 | priv->click_child = ARROW_NONE; |
1313 | priv->need_timer = 0; |
1314 | priv->child_has_focus = FALSE(0); |
1315 | priv->focus_out = FALSE(0); |
1316 | |
1317 | priv->group = 0; |
1318 | priv->pressed_button = 0; |
1319 | priv->dnd_timer = 0; |
1320 | priv->switch_tab_timer = 0; |
1321 | priv->source_targets = ctk_target_list_new (src_notebook_targets, |
1322 | G_N_ELEMENTS (src_notebook_targets)(sizeof (src_notebook_targets) / sizeof ((src_notebook_targets )[0]))); |
1323 | priv->operation = DRAG_OPERATION_NONE; |
1324 | priv->detached_tab = NULL((void*)0); |
1325 | priv->has_scrolled = FALSE(0); |
1326 | |
1327 | if (ctk_widget_get_direction (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL) |
1328 | priv->tabs_reversed = TRUE(!(0)); |
1329 | else |
1330 | priv->tabs_reversed = FALSE(0); |
1331 | |
1332 | ctk_drag_dest_set (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), 0, |
1333 | dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets)(sizeof (dst_notebook_targets) / sizeof ((dst_notebook_targets )[0])), |
1334 | CDK_ACTION_MOVE); |
1335 | |
1336 | ctk_drag_dest_set_track_motion (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), TRUE(!(0))); |
1337 | |
1338 | widget_node = ctk_widget_get_css_node (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
1339 | priv->gadget = ctk_box_gadget_new_for_node (widget_node, |
1340 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
1341 | ctk_css_gadget_add_class (priv->gadget, CTK_STYLE_CLASS_FRAME"frame"); |
1342 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), CTK_ORIENTATION_VERTICAL); |
1343 | ctk_box_gadget_set_draw_reverse (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), TRUE(!(0))); |
1344 | |
1345 | priv->stack_gadget = ctk_css_custom_gadget_new ("stack", |
1346 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), |
1347 | priv->gadget, |
1348 | NULL((void*)0), |
1349 | ctk_notebook_measure_stack, |
1350 | ctk_notebook_allocate_stack, |
1351 | ctk_notebook_draw_stack, |
1352 | NULL((void*)0), |
1353 | NULL((void*)0)); |
1354 | ctk_css_gadget_set_state (priv->stack_gadget, ctk_css_node_get_state (widget_node)); |
1355 | ctk_box_gadget_insert_gadget (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), -1, priv->stack_gadget, TRUE(!(0)), CTK_ALIGN_FILL); |
1356 | |
1357 | priv->header_gadget = ctk_box_gadget_new ("header", |
1358 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), |
1359 | priv->gadget, |
1360 | priv->stack_gadget); |
1361 | ctk_css_gadget_add_class (priv->header_gadget, CTK_STYLE_CLASS_TOP"top"); |
1362 | ctk_css_gadget_set_state (priv->header_gadget, ctk_css_node_get_state (widget_node)); |
1363 | ctk_css_gadget_set_visible (priv->header_gadget, FALSE(0)); |
1364 | ctk_box_gadget_insert_gadget (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), 0, priv->header_gadget, FALSE(0), CTK_ALIGN_FILL); |
1365 | |
1366 | priv->tabs_gadget = ctk_css_custom_gadget_new ("tabs", |
1367 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), |
1368 | priv->header_gadget, |
1369 | NULL((void*)0), |
1370 | ctk_notebook_measure_tabs, |
1371 | ctk_notebook_allocate_tabs, |
1372 | ctk_notebook_draw_tabs, |
1373 | NULL((void*)0), |
1374 | NULL((void*)0)); |
1375 | ctk_css_gadget_set_state (priv->tabs_gadget, ctk_css_node_get_state (widget_node)); |
1376 | ctk_box_gadget_insert_gadget (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) )), 0, priv->tabs_gadget, TRUE(!(0)), CTK_ALIGN_FILL); |
1377 | } |
1378 | |
1379 | static void |
1380 | ctk_notebook_buildable_init (CtkBuildableIface *iface) |
1381 | { |
1382 | iface->add_child = ctk_notebook_buildable_add_child; |
1383 | } |
1384 | |
1385 | static void |
1386 | ctk_notebook_buildable_add_child (CtkBuildable *buildable, |
1387 | CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)), |
1388 | GObject *child, |
1389 | const gchar *type) |
1390 | { |
1391 | CtkNotebook *notebook = CTK_NOTEBOOK (buildable)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_notebook_get_type ())))))); |
1392 | |
1393 | if (type && strcmp (type, "tab") == 0) |
1394 | { |
1395 | CtkWidget * page; |
1396 | |
1397 | page = ctk_notebook_get_nth_page (notebook, -1); |
1398 | /* To set the tab label widget, we must have already a child |
1399 | * inside the tab container. */ |
1400 | g_assert (page != NULL)do { if (page != ((void*)0)) ; else g_assertion_message_expr ( "Ctk", "ctknotebook.c", 1400, ((const char*) (__func__)), "page != NULL" ); } while (0); |
1401 | /* warn when Glade tries to overwrite label */ |
1402 | if (ctk_notebook_get_tab_label (notebook, page)) |
1403 | g_warning ("Overriding tab label for notebook"); |
1404 | ctk_notebook_set_tab_label (notebook, page, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ()))))))); |
1405 | } |
1406 | else if (type && strcmp (type, "action-start") == 0) |
1407 | { |
1408 | ctk_notebook_set_action_widget (notebook, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ())))))), CTK_PACK_START); |
1409 | } |
1410 | else if (type && strcmp (type, "action-end") == 0) |
1411 | { |
1412 | ctk_notebook_set_action_widget (notebook, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ())))))), CTK_PACK_END); |
1413 | } |
1414 | else if (!type) |
1415 | ctk_notebook_append_page (notebook, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ())))))), NULL((void*)0)); |
1416 | else |
1417 | CTK_BUILDER_WARN_INVALID_CHILD_TYPE (notebook, type)g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (notebook))->g_class ))->g_type))))); |
1418 | } |
1419 | |
1420 | static gboolean |
1421 | ctk_notebook_has_current_page (CtkNotebook *notebook) |
1422 | { |
1423 | CtkNotebookPrivate *priv = notebook->priv; |
1424 | |
1425 | return priv->cur_page && |
1426 | ctk_widget_get_visible (priv->cur_page->child); |
1427 | } |
1428 | |
1429 | static gboolean |
1430 | ctk_notebook_select_page (CtkNotebook *notebook, |
1431 | gboolean move_focus) |
1432 | { |
1433 | CtkNotebookPrivate *priv = notebook->priv; |
1434 | |
1435 | if (ctk_widget_is_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) && priv->show_tabs) |
1436 | { |
1437 | ctk_notebook_page_select (notebook, move_focus); |
1438 | return TRUE(!(0)); |
1439 | } |
1440 | else |
1441 | return FALSE(0); |
1442 | } |
1443 | |
1444 | static gboolean |
1445 | ctk_notebook_focus_tab (CtkNotebook *notebook, |
1446 | CtkNotebookTab type) |
1447 | { |
1448 | CtkNotebookPrivate *priv = notebook->priv; |
1449 | GList *list; |
1450 | |
1451 | if (ctk_widget_is_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) && priv->show_tabs) |
1452 | { |
1453 | switch (type) |
1454 | { |
1455 | case CTK_NOTEBOOK_TAB_FIRST: |
1456 | list = ctk_notebook_search_page (notebook, NULL((void*)0), STEP_NEXT, TRUE(!(0))); |
1457 | if (list) |
1458 | ctk_notebook_switch_focus_tab (notebook, list); |
1459 | break; |
1460 | case CTK_NOTEBOOK_TAB_LAST: |
1461 | list = ctk_notebook_search_page (notebook, NULL((void*)0), STEP_PREV, TRUE(!(0))); |
1462 | if (list) |
1463 | ctk_notebook_switch_focus_tab (notebook, list); |
1464 | break; |
1465 | } |
1466 | |
1467 | return TRUE(!(0)); |
1468 | } |
1469 | else |
1470 | return FALSE(0); |
1471 | } |
1472 | |
1473 | static gboolean |
1474 | ctk_notebook_change_current_page (CtkNotebook *notebook, |
1475 | gint offset) |
1476 | { |
1477 | CtkNotebookPrivate *priv = notebook->priv; |
1478 | GList *current = NULL((void*)0); |
1479 | |
1480 | if (!priv->show_tabs) |
1481 | return FALSE(0); |
1482 | |
1483 | if (priv->cur_page) |
1484 | current = g_list_find (priv->children, priv->cur_page); |
1485 | |
1486 | while (offset != 0) |
1487 | { |
1488 | current = ctk_notebook_search_page (notebook, current, |
1489 | offset < 0 ? STEP_PREV : STEP_NEXT, |
1490 | TRUE(!(0))); |
1491 | |
1492 | if (!current) |
1493 | { |
1494 | current = ctk_notebook_search_page (notebook, NULL((void*)0), |
1495 | offset < 0 ? STEP_PREV : STEP_NEXT, |
1496 | TRUE(!(0))); |
1497 | } |
1498 | |
1499 | offset += offset < 0 ? 1 : -1; |
1500 | } |
1501 | |
1502 | if (current) |
1503 | ctk_notebook_switch_page (notebook, current->data); |
1504 | else |
1505 | ctk_widget_error_bell (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
1506 | |
1507 | return TRUE(!(0)); |
1508 | } |
1509 | |
1510 | static CtkDirectionType |
1511 | get_effective_direction (CtkNotebook *notebook, |
1512 | CtkDirectionType direction) |
1513 | { |
1514 | CtkNotebookPrivate *priv = notebook->priv; |
1515 | |
1516 | /* Remap the directions into the effective direction it would be for a |
1517 | * CTK_POS_TOP notebook |
1518 | */ |
1519 | |
1520 | #define D(rest) CTK_DIR_##rest |
1521 | |
1522 | static const CtkDirectionType translate_direction[2][4][6] = { |
1523 | /* LEFT */ {{ D(TAB_FORWARD), D(TAB_BACKWARD), D(LEFT), D(RIGHT), D(UP), D(DOWN) }, |
1524 | /* RIGHT */ { D(TAB_BACKWARD), D(TAB_FORWARD), D(LEFT), D(RIGHT), D(DOWN), D(UP) }, |
1525 | /* TOP */ { D(TAB_FORWARD), D(TAB_BACKWARD), D(UP), D(DOWN), D(LEFT), D(RIGHT) }, |
1526 | /* BOTTOM */ { D(TAB_BACKWARD), D(TAB_FORWARD), D(DOWN), D(UP), D(LEFT), D(RIGHT) }}, |
1527 | /* LEFT */ {{ D(TAB_BACKWARD), D(TAB_FORWARD), D(LEFT), D(RIGHT), D(DOWN), D(UP) }, |
1528 | /* RIGHT */ { D(TAB_FORWARD), D(TAB_BACKWARD), D(LEFT), D(RIGHT), D(UP), D(DOWN) }, |
1529 | /* TOP */ { D(TAB_FORWARD), D(TAB_BACKWARD), D(UP), D(DOWN), D(RIGHT), D(LEFT) }, |
1530 | /* BOTTOM */ { D(TAB_BACKWARD), D(TAB_FORWARD), D(DOWN), D(UP), D(RIGHT), D(LEFT) }}, |
1531 | }; |
1532 | |
1533 | #undef D |
1534 | |
1535 | int text_dir = ctk_widget_get_direction (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL ? 1 : 0; |
1536 | |
1537 | return translate_direction[text_dir][priv->tab_pos][direction]; |
1538 | } |
1539 | |
1540 | static CtkPositionType |
1541 | get_effective_tab_pos (CtkNotebook *notebook) |
1542 | { |
1543 | CtkNotebookPrivate *priv = notebook->priv; |
1544 | |
1545 | if (ctk_widget_get_direction (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL) |
1546 | { |
1547 | switch (priv->tab_pos) |
1548 | { |
1549 | case CTK_POS_LEFT: |
1550 | return CTK_POS_RIGHT; |
1551 | case CTK_POS_RIGHT: |
1552 | return CTK_POS_LEFT; |
1553 | default: ; |
1554 | } |
1555 | } |
1556 | |
1557 | return priv->tab_pos; |
1558 | } |
1559 | |
1560 | static void |
1561 | ctk_notebook_move_focus_out (CtkNotebook *notebook, |
1562 | CtkDirectionType direction_type) |
1563 | { |
1564 | CtkNotebookPrivate *priv = notebook->priv; |
1565 | CtkDirectionType effective_direction = get_effective_direction (notebook, direction_type); |
1566 | CtkWidget *toplevel; |
1567 | |
1568 | if (ctk_container_get_focus_child (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ()))))))) && effective_direction == CTK_DIR_UP) |
1569 | if (focus_tabs_in (notebook)) |
1570 | return; |
1571 | if (ctk_widget_is_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) && effective_direction == CTK_DIR_DOWN) |
1572 | if (focus_child_in (notebook, CTK_DIR_TAB_FORWARD)) |
1573 | return; |
1574 | |
1575 | /* At this point, we know we should be focusing out of the notebook entirely. We |
1576 | * do this by setting a flag, then propagating the focus motion to the notebook. |
1577 | */ |
1578 | toplevel = ctk_widget_get_toplevel (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
1579 | if (!ctk_widget_is_toplevel (toplevel)) |
1580 | return; |
1581 | |
1582 | g_object_ref (notebook)((__typeof__ (notebook)) (g_object_ref) (notebook)); |
1583 | |
1584 | priv->focus_out = TRUE(!(0)); |
1585 | g_signal_emit_by_name (toplevel, "move-focus", direction_type); |
1586 | priv->focus_out = FALSE(0); |
1587 | |
1588 | g_object_unref (notebook); |
1589 | } |
1590 | |
1591 | static gint |
1592 | reorder_tab (CtkNotebook *notebook, GList *position, GList *tab) |
1593 | { |
1594 | CtkNotebookPrivate *priv = notebook->priv; |
1595 | GList *elem; |
1596 | |
1597 | if (position == tab) |
1598 | return g_list_position (priv->children, tab); |
1599 | |
1600 | /* check that we aren't inserting the tab in the |
1601 | * same relative position, taking packing into account */ |
1602 | elem = (position) ? position->prev : g_list_last (priv->children); |
1603 | |
1604 | if (elem == tab) |
1605 | return g_list_position (priv->children, tab); |
1606 | |
1607 | /* now actually reorder the tab */ |
1608 | if (priv->first_tab == tab) |
1609 | priv->first_tab = ctk_notebook_search_page (notebook, priv->first_tab, |
1610 | STEP_NEXT, TRUE(!(0))); |
1611 | |
1612 | priv->children = g_list_remove_link (priv->children, tab); |
1613 | |
1614 | if (!position) |
1615 | elem = g_list_last (priv->children); |
1616 | else |
1617 | { |
1618 | elem = position->prev; |
1619 | position->prev = tab; |
1620 | } |
1621 | |
1622 | if (elem) |
1623 | elem->next = tab; |
1624 | else |
1625 | priv->children = tab; |
1626 | |
1627 | tab->prev = elem; |
1628 | tab->next = position; |
1629 | |
1630 | return g_list_position (priv->children, tab); |
1631 | } |
1632 | |
1633 | static gboolean |
1634 | ctk_notebook_reorder_tab (CtkNotebook *notebook, |
1635 | CtkDirectionType direction_type, |
1636 | gboolean move_to_last) |
1637 | { |
1638 | CtkNotebookPrivate *priv = notebook->priv; |
1639 | CtkDirectionType effective_direction = get_effective_direction (notebook, direction_type); |
1640 | GList *last, *child, *element; |
1641 | gint page_num, old_page_num, i; |
1642 | |
1643 | if (!ctk_widget_is_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) || !priv->show_tabs) |
1644 | return FALSE(0); |
1645 | |
1646 | if (!ctk_notebook_has_current_page (notebook) || |
1647 | !priv->cur_page->reorderable) |
1648 | return FALSE(0); |
1649 | |
1650 | if (effective_direction != CTK_DIR_LEFT && |
1651 | effective_direction != CTK_DIR_RIGHT) |
1652 | return FALSE(0); |
1653 | |
1654 | if (move_to_last) |
1655 | { |
1656 | child = priv->focus_tab; |
1657 | |
1658 | do |
1659 | { |
1660 | last = child; |
1661 | child = ctk_notebook_search_page (notebook, last, |
1662 | (effective_direction == CTK_DIR_RIGHT) ? STEP_NEXT : STEP_PREV, |
1663 | TRUE(!(0))); |
1664 | } |
1665 | while (child); |
1666 | |
1667 | child = last; |
1668 | } |
1669 | else |
1670 | child = ctk_notebook_search_page (notebook, priv->focus_tab, |
1671 | (effective_direction == CTK_DIR_RIGHT) ? STEP_NEXT : STEP_PREV, |
1672 | TRUE(!(0))); |
1673 | |
1674 | if (!child || child->data == priv->cur_page) |
1675 | return FALSE(0); |
1676 | |
1677 | old_page_num = g_list_position (priv->children, priv->focus_tab); |
1678 | if (effective_direction == CTK_DIR_RIGHT) |
1679 | page_num = reorder_tab (notebook, child->next, priv->focus_tab); |
1680 | else |
1681 | page_num = reorder_tab (notebook, child, priv->focus_tab); |
1682 | |
1683 | ctk_notebook_child_reordered (notebook, priv->focus_tab->data); |
1684 | for (element = priv->children, i = 0; element; element = element->next, i++) |
1685 | { |
1686 | if (MIN (old_page_num, page_num)(((old_page_num) < (page_num)) ? (old_page_num) : (page_num )) <= i && i <= MAX (old_page_num, page_num)(((old_page_num) > (page_num)) ? (old_page_num) : (page_num ))) |
1687 | ctk_widget_child_notify (((CtkNotebookPage *) element->data)->child, "position"); |
1688 | } |
1689 | g_signal_emit (notebook, |
1690 | notebook_signals[PAGE_REORDERED], |
1691 | 0, |
1692 | ((CtkNotebookPage *) priv->focus_tab->data)->child, |
1693 | page_num); |
1694 | |
1695 | return TRUE(!(0)); |
1696 | } |
1697 | |
1698 | /** |
1699 | * ctk_notebook_new: |
1700 | * |
1701 | * Creates a new #CtkNotebook widget with no pages. |
1702 | |
1703 | * Returns: the newly created #CtkNotebook |
1704 | */ |
1705 | CtkWidget* |
1706 | ctk_notebook_new (void) |
1707 | { |
1708 | return g_object_new (CTK_TYPE_NOTEBOOK(ctk_notebook_get_type ()), NULL((void*)0)); |
1709 | } |
1710 | |
1711 | /* Private GObject Methods : |
1712 | * |
1713 | * ctk_notebook_set_property |
1714 | * ctk_notebook_get_property |
1715 | */ |
1716 | static void |
1717 | ctk_notebook_set_property (GObject *object, |
1718 | guint prop_id, |
1719 | const GValue *value, |
1720 | GParamSpec *pspec) |
1721 | { |
1722 | CtkNotebook *notebook; |
1723 | |
1724 | notebook = CTK_NOTEBOOK (object)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_notebook_get_type ())))))); |
1725 | |
1726 | switch (prop_id) |
1727 | { |
1728 | case PROP_SHOW_TABS: |
1729 | ctk_notebook_set_show_tabs (notebook, g_value_get_boolean (value)); |
1730 | break; |
1731 | case PROP_SHOW_BORDER: |
1732 | ctk_notebook_set_show_border (notebook, g_value_get_boolean (value)); |
1733 | break; |
1734 | case PROP_SCROLLABLE: |
1735 | ctk_notebook_set_scrollable (notebook, g_value_get_boolean (value)); |
1736 | break; |
1737 | case PROP_ENABLE_POPUP: |
1738 | if (g_value_get_boolean (value)) |
1739 | ctk_notebook_popup_enable (notebook); |
1740 | else |
1741 | ctk_notebook_popup_disable (notebook); |
1742 | break; |
1743 | case PROP_PAGE: |
1744 | ctk_notebook_set_current_page (notebook, g_value_get_int (value)); |
1745 | break; |
1746 | case PROP_TAB_POS: |
1747 | ctk_notebook_set_tab_pos (notebook, g_value_get_enum (value)); |
1748 | break; |
1749 | case PROP_GROUP_NAME: |
1750 | ctk_notebook_set_group_name (notebook, g_value_get_string (value)); |
1751 | break; |
1752 | default: |
1753 | 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'" , "ctknotebook.c", 1753, ("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); |
1754 | break; |
1755 | } |
1756 | } |
1757 | |
1758 | static void |
1759 | ctk_notebook_get_property (GObject *object, |
1760 | guint prop_id, |
1761 | GValue *value, |
1762 | GParamSpec *pspec) |
1763 | { |
1764 | CtkNotebook *notebook = CTK_NOTEBOOK (object)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_notebook_get_type ())))))); |
1765 | CtkNotebookPrivate *priv = notebook->priv; |
1766 | |
1767 | switch (prop_id) |
1768 | { |
1769 | case PROP_SHOW_TABS: |
1770 | g_value_set_boolean (value, priv->show_tabs); |
1771 | break; |
1772 | case PROP_SHOW_BORDER: |
1773 | g_value_set_boolean (value, priv->show_border); |
1774 | break; |
1775 | case PROP_SCROLLABLE: |
1776 | g_value_set_boolean (value, priv->scrollable); |
1777 | break; |
1778 | case PROP_ENABLE_POPUP: |
1779 | g_value_set_boolean (value, priv->menu != NULL((void*)0)); |
1780 | break; |
1781 | case PROP_PAGE: |
1782 | g_value_set_int (value, ctk_notebook_get_current_page (notebook)); |
1783 | break; |
1784 | case PROP_TAB_POS: |
1785 | g_value_set_enum (value, priv->tab_pos); |
1786 | break; |
1787 | case PROP_GROUP_NAME: |
1788 | g_value_set_string (value, ctk_notebook_get_group_name (notebook)); |
1789 | break; |
1790 | default: |
1791 | 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'" , "ctknotebook.c", 1791, ("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); |
1792 | break; |
1793 | } |
1794 | } |
1795 | |
1796 | /* Private CtkWidget Methods : |
1797 | * |
1798 | * ctk_notebook_destroy |
1799 | * ctk_notebook_map |
1800 | * ctk_notebook_unmap |
1801 | * ctk_notebook_realize |
1802 | * ctk_notebook_size_allocate |
1803 | * ctk_notebook_draw |
1804 | * ctk_notebook_scroll |
1805 | * ctk_notebook_button_press |
1806 | * ctk_notebook_button_release |
1807 | * ctk_notebook_popup_menu |
1808 | * ctk_notebook_enter_notify |
1809 | * ctk_notebook_leave_notify |
1810 | * ctk_notebook_motion_notify |
1811 | * ctk_notebook_focus_in |
1812 | * ctk_notebook_focus_out |
1813 | * ctk_notebook_style_updated |
1814 | * ctk_notebook_drag_begin |
1815 | * ctk_notebook_drag_end |
1816 | * ctk_notebook_drag_failed |
1817 | * ctk_notebook_drag_motion |
1818 | * ctk_notebook_drag_drop |
1819 | * ctk_notebook_drag_data_get |
1820 | * ctk_notebook_drag_data_received |
1821 | */ |
1822 | static void |
1823 | remove_switch_tab_timer (CtkNotebook *notebook) |
1824 | { |
1825 | CtkNotebookPrivate *priv = notebook->priv; |
1826 | |
1827 | if (priv->switch_tab_timer) |
1828 | { |
1829 | g_source_remove (priv->switch_tab_timer); |
1830 | priv->switch_tab_timer = 0; |
1831 | } |
1832 | } |
1833 | |
1834 | static void |
1835 | ctk_notebook_destroy (CtkWidget *widget) |
1836 | { |
1837 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
1838 | CtkNotebookPrivate *priv = notebook->priv; |
1839 | |
1840 | if (priv->action_widget[CTK_PACK_START]) |
1841 | { |
1842 | ctk_widget_unparent (priv->action_widget[CTK_PACK_START]); |
1843 | priv->action_widget[CTK_PACK_START] = NULL((void*)0); |
1844 | } |
1845 | |
1846 | if (priv->action_widget[CTK_PACK_END]) |
1847 | { |
1848 | ctk_widget_unparent (priv->action_widget[CTK_PACK_END]); |
1849 | priv->action_widget[CTK_PACK_END] = NULL((void*)0); |
1850 | } |
1851 | |
1852 | if (priv->menu) |
1853 | ctk_notebook_popup_disable (notebook); |
1854 | |
1855 | if (priv->source_targets) |
1856 | { |
1857 | ctk_target_list_unref (priv->source_targets); |
1858 | priv->source_targets = NULL((void*)0); |
1859 | } |
1860 | |
1861 | remove_switch_tab_timer (notebook); |
1862 | |
1863 | CTK_WIDGET_CLASS (ctk_notebook_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), ((ctk_widget_get_type ()))) )))->destroy (widget); |
1864 | } |
1865 | |
1866 | static void |
1867 | ctk_notebook_finalize (GObject *object) |
1868 | { |
1869 | CtkNotebook *notebook = CTK_NOTEBOOK (object)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_notebook_get_type ())))))); |
1870 | CtkNotebookPrivate *priv = notebook->priv; |
1871 | |
1872 | g_clear_object (&priv->gadget)do { _Static_assert (sizeof *((&priv->gadget)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &priv->gadget))) _pp = ((&priv->gadget)); __typeof__ (*((&priv->gadget))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
1873 | g_clear_object (&priv->header_gadget)do { _Static_assert (sizeof *((&priv->header_gadget)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->header_gadget))) _pp = ((&priv->header_gadget )); __typeof__ (*((&priv->header_gadget))) _ptr = *_pp ; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
1874 | g_clear_object (&priv->tabs_gadget)do { _Static_assert (sizeof *((&priv->tabs_gadget)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->tabs_gadget))) _pp = ((&priv->tabs_gadget )); __typeof__ (*((&priv->tabs_gadget))) _ptr = *_pp; * _pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while ( 0); |
1875 | g_clear_object (&priv->arrow_gadget[0])do { _Static_assert (sizeof *((&priv->arrow_gadget[0]) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->arrow_gadget[0]))) _pp = ((&priv->arrow_gadget [0])); __typeof__ (*((&priv->arrow_gadget[0]))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
1876 | g_clear_object (&priv->arrow_gadget[1])do { _Static_assert (sizeof *((&priv->arrow_gadget[1]) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->arrow_gadget[1]))) _pp = ((&priv->arrow_gadget [1])); __typeof__ (*((&priv->arrow_gadget[1]))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
1877 | g_clear_object (&priv->arrow_gadget[2])do { _Static_assert (sizeof *((&priv->arrow_gadget[2]) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->arrow_gadget[2]))) _pp = ((&priv->arrow_gadget [2])); __typeof__ (*((&priv->arrow_gadget[2]))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
1878 | g_clear_object (&priv->arrow_gadget[3])do { _Static_assert (sizeof *((&priv->arrow_gadget[3]) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->arrow_gadget[3]))) _pp = ((&priv->arrow_gadget [3])); __typeof__ (*((&priv->arrow_gadget[3]))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
1879 | g_clear_object (&priv->stack_gadget)do { _Static_assert (sizeof *((&priv->stack_gadget)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->stack_gadget))) _pp = ((&priv->stack_gadget )); __typeof__ (*((&priv->stack_gadget))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
1880 | |
1881 | G_OBJECT_CLASS (ctk_notebook_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), (((GType) ((20) << (2 ))))))))->finalize (object); |
1882 | } |
1883 | |
1884 | static void |
1885 | update_node_ordering (CtkNotebook *notebook) |
1886 | { |
1887 | CtkNotebookPrivate *priv = notebook->priv; |
1888 | gboolean reverse_tabs; |
1889 | |
1890 | reverse_tabs = (priv->tab_pos == CTK_POS_TOP || priv->tab_pos == CTK_POS_BOTTOM) && |
1891 | ctk_widget_get_direction (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL; |
1892 | |
1893 | if ((reverse_tabs && !priv->tabs_reversed) || |
1894 | (!reverse_tabs && priv->tabs_reversed)) |
1895 | { |
1896 | ctk_box_gadget_reverse_children (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) ))); |
1897 | ctk_css_node_reverse_children (ctk_css_gadget_get_node (priv->tabs_gadget)); |
1898 | priv->tabs_reversed = reverse_tabs; |
1899 | } |
1900 | } |
1901 | |
1902 | static void |
1903 | ctk_notebook_direction_changed (CtkWidget *widget, |
1904 | CtkTextDirection previous_dir) |
1905 | { |
1906 | update_node_ordering (CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ()))))))); |
1907 | |
1908 | CTK_WIDGET_CLASS (ctk_notebook_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), ((ctk_widget_get_type ()))) )))->direction_changed (widget, previous_dir); |
1909 | } |
1910 | |
1911 | static gboolean |
1912 | ctk_notebook_get_event_window_position (CtkNotebook *notebook, |
1913 | CdkRectangle *rectangle) |
1914 | { |
1915 | CtkNotebookPrivate *priv = notebook->priv; |
1916 | |
1917 | if (priv->show_tabs && ctk_notebook_has_current_page (notebook)) |
1918 | { |
1919 | if (rectangle) |
1920 | ctk_css_gadget_get_border_allocation (priv->header_gadget, rectangle, NULL((void*)0)); |
1921 | |
1922 | return TRUE(!(0)); |
1923 | } |
1924 | else |
1925 | { |
1926 | if (rectangle) |
1927 | { |
1928 | rectangle->x = rectangle->y = 0; |
1929 | rectangle->width = rectangle->height = 10; |
1930 | } |
1931 | } |
1932 | |
1933 | return FALSE(0); |
1934 | } |
1935 | |
1936 | static void |
1937 | ctk_notebook_map (CtkWidget *widget) |
1938 | { |
1939 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
1940 | CtkNotebookPrivate *priv = notebook->priv; |
1941 | |
1942 | CTK_WIDGET_CLASS (ctk_notebook_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), ((ctk_widget_get_type ()))) )))->map (widget); |
1943 | |
1944 | if (ctk_notebook_get_event_window_position (notebook, NULL((void*)0))) |
1945 | cdk_window_show_unraised (priv->event_window); |
1946 | } |
1947 | |
1948 | static void |
1949 | ctk_notebook_unmap (CtkWidget *widget) |
1950 | { |
1951 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
1952 | CtkNotebookPrivate *priv = notebook->priv; |
1953 | |
1954 | stop_scrolling (notebook); |
1955 | |
1956 | cdk_window_hide (priv->event_window); |
1957 | |
1958 | CTK_WIDGET_CLASS (ctk_notebook_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), ((ctk_widget_get_type ()))) )))->unmap (widget); |
1959 | } |
1960 | |
1961 | static void |
1962 | ctk_notebook_realize (CtkWidget *widget) |
1963 | { |
1964 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
1965 | CtkNotebookPrivate *priv = notebook->priv; |
1966 | CdkWindow *window; |
1967 | CdkWindowAttr attributes; |
1968 | gint attributes_mask; |
1969 | CdkRectangle event_window_pos; |
1970 | |
1971 | ctk_widget_set_realized (widget, TRUE(!(0))); |
1972 | |
1973 | ctk_css_gadget_get_border_allocation (priv->header_gadget, &event_window_pos, NULL((void*)0)); |
1974 | |
1975 | window = ctk_widget_get_parent_window (widget); |
1976 | ctk_widget_set_window (widget, window); |
1977 | g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window)); |
1978 | |
1979 | attributes.window_type = CDK_WINDOW_CHILD; |
1980 | attributes.x = event_window_pos.x; |
1981 | attributes.y = event_window_pos.y; |
1982 | attributes.width = event_window_pos.width; |
1983 | attributes.height = event_window_pos.height; |
1984 | attributes.wclass = CDK_INPUT_ONLY; |
1985 | attributes.event_mask = ctk_widget_get_events (widget); |
1986 | attributes.event_mask |= (CDK_BUTTON_PRESS_MASK | |
1987 | CDK_BUTTON_RELEASE_MASK | CDK_KEY_PRESS_MASK | |
1988 | CDK_POINTER_MOTION_MASK | CDK_ENTER_NOTIFY_MASK | CDK_LEAVE_NOTIFY_MASK); |
1989 | attributes_mask = CDK_WA_X | CDK_WA_Y; |
1990 | |
1991 | priv->event_window = cdk_window_new (ctk_widget_get_parent_window (widget), |
1992 | &attributes, attributes_mask); |
1993 | ctk_widget_register_window (widget, priv->event_window); |
1994 | } |
1995 | |
1996 | static void |
1997 | ctk_notebook_unrealize (CtkWidget *widget) |
1998 | { |
1999 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2000 | CtkNotebookPrivate *priv = notebook->priv; |
2001 | |
2002 | ctk_widget_unregister_window (widget, priv->event_window); |
2003 | cdk_window_destroy (priv->event_window); |
2004 | priv->event_window = NULL((void*)0); |
2005 | |
2006 | if (priv->drag_window) |
2007 | { |
2008 | ctk_widget_unregister_window (widget, priv->drag_window); |
2009 | cdk_window_destroy (priv->drag_window); |
2010 | priv->drag_window = NULL((void*)0); |
2011 | } |
2012 | |
2013 | CTK_WIDGET_CLASS (ctk_notebook_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), ((ctk_widget_get_type ()))) )))->unrealize (widget); |
2014 | } |
2015 | |
2016 | static void |
2017 | ctk_notebook_distribute_arrow_width (CtkNotebook *notebook, |
2018 | CtkPackType type, |
2019 | gint size, |
2020 | gint *out_left, |
2021 | gint *out_right) |
2022 | { |
2023 | CtkNotebookPrivate *priv = notebook->priv; |
2024 | CtkRequestedSize sizes[2]; |
2025 | |
2026 | if (priv->arrow_gadget[2 * type + 1] == NULL((void*)0)) |
2027 | { |
2028 | if (priv->arrow_gadget[2 * type] == NULL((void*)0)) |
2029 | *out_left = 0; |
2030 | else |
2031 | *out_left = size; |
2032 | *out_right = 0; |
2033 | } |
2034 | else if (priv->arrow_gadget[2 * type] == NULL((void*)0)) |
2035 | { |
2036 | *out_left = 0; |
2037 | *out_right = size; |
2038 | } |
2039 | else |
2040 | { |
2041 | ctk_css_gadget_get_preferred_size (priv->arrow_gadget[2 * type], |
2042 | CTK_ORIENTATION_HORIZONTAL, |
2043 | -1, |
2044 | &sizes[0].minimum_size, &sizes[0].natural_size, |
2045 | NULL((void*)0), NULL((void*)0)); |
2046 | ctk_css_gadget_get_preferred_size (priv->arrow_gadget[2 * type + 1], |
2047 | CTK_ORIENTATION_HORIZONTAL, |
2048 | -1, |
2049 | &sizes[1].minimum_size, &sizes[1].natural_size, |
2050 | NULL((void*)0), NULL((void*)0)); |
2051 | |
2052 | size -= sizes[0].minimum_size + sizes[1].minimum_size; |
2053 | size = ctk_distribute_natural_allocation (size, G_N_ELEMENTS (sizes)(sizeof (sizes) / sizeof ((sizes)[0])), sizes); |
2054 | |
2055 | *out_left = sizes[0].minimum_size + size / 2; |
2056 | *out_right = sizes[1].minimum_size + (size + 1) / 2; |
2057 | } |
2058 | } |
2059 | |
2060 | static void |
2061 | ctk_notebook_measure_arrows (CtkNotebook *notebook, |
2062 | CtkPackType type, |
2063 | CtkOrientation orientation, |
2064 | gint for_size, |
2065 | gint *minimum, |
2066 | gint *natural, |
2067 | gint *minimum_baseline, |
2068 | gint *natural_baseline) |
2069 | { |
2070 | CtkNotebookPrivate *priv = notebook->priv; |
2071 | gint child1_min, child1_nat; |
2072 | gint child2_min, child2_nat; |
2073 | |
2074 | if (orientation == CTK_ORIENTATION_HORIZONTAL) |
2075 | { |
2076 | if (priv->arrow_gadget[2 * type]) |
2077 | { |
2078 | ctk_css_gadget_get_preferred_size (priv->arrow_gadget[2 * type], |
2079 | orientation, |
2080 | for_size, |
2081 | &child1_min, &child1_nat, |
2082 | NULL((void*)0), NULL((void*)0)); |
2083 | } |
2084 | else |
2085 | { |
2086 | child1_min = child1_nat = 0; |
2087 | } |
2088 | if (priv->arrow_gadget[2 * type + 1]) |
2089 | { |
2090 | ctk_css_gadget_get_preferred_size (priv->arrow_gadget[2 * type + 1], |
2091 | orientation, |
2092 | for_size, |
2093 | &child2_min, &child2_nat, |
2094 | NULL((void*)0), NULL((void*)0)); |
2095 | } |
2096 | else |
2097 | { |
2098 | child2_min = child2_nat = 0; |
2099 | } |
2100 | *minimum = child1_min + child2_min; |
2101 | *natural = child1_nat + child2_nat; |
2102 | if (minimum_baseline) |
2103 | *minimum_baseline = -1; |
2104 | if (natural_baseline) |
2105 | *natural_baseline = -1; |
2106 | } |
2107 | else |
2108 | { |
2109 | gint child1_size, child2_size; |
2110 | |
2111 | if (for_size > -1) |
2112 | ctk_notebook_distribute_arrow_width (notebook, type, for_size, &child1_size, &child2_size); |
2113 | else |
2114 | child1_size = child2_size = for_size; |
2115 | |
2116 | if (priv->arrow_gadget[2 * type]) |
2117 | { |
2118 | ctk_css_gadget_get_preferred_size (priv->arrow_gadget[2 * type], |
2119 | orientation, |
2120 | child1_size, |
2121 | &child1_min, &child1_nat, |
2122 | NULL((void*)0), NULL((void*)0)); |
2123 | } |
2124 | else |
2125 | { |
2126 | child1_min = child1_nat = 0; |
2127 | } |
2128 | if (priv->arrow_gadget[2 * type + 1]) |
2129 | { |
2130 | ctk_css_gadget_get_preferred_size (priv->arrow_gadget[2 * type + 1], |
2131 | orientation, |
2132 | child2_size, |
2133 | &child2_min, &child2_nat, |
2134 | NULL((void*)0), NULL((void*)0)); |
2135 | } |
2136 | else |
2137 | { |
2138 | child2_min = child2_nat = 0; |
2139 | } |
2140 | *minimum = MAX (child1_min, child2_min)(((child1_min) > (child2_min)) ? (child1_min) : (child2_min )); |
2141 | *natural = MAX (child1_nat, child2_nat)(((child1_nat) > (child2_nat)) ? (child1_nat) : (child2_nat )); |
2142 | if (minimum_baseline) |
2143 | *minimum_baseline = -1; |
2144 | if (natural_baseline) |
2145 | *natural_baseline = -1; |
2146 | } |
2147 | } |
2148 | |
2149 | static void |
2150 | ctk_notebook_get_preferred_tabs_size (CtkNotebook *notebook, |
2151 | CtkRequisition *requisition) |
2152 | { |
2153 | CtkNotebookPrivate *priv = notebook->priv; |
2154 | gint tab_width = 0; |
2155 | gint tab_height = 0; |
2156 | gint tab_max = 0; |
2157 | guint vis_pages = 0; |
2158 | GList *children; |
2159 | CtkNotebookPage *page; |
2160 | |
2161 | |
2162 | for (children = priv->children; children; |
2163 | children = children->next) |
2164 | { |
2165 | page = children->data; |
2166 | |
2167 | if (ctk_widget_get_visible (page->child)) |
2168 | { |
2169 | vis_pages++; |
2170 | |
2171 | if (!ctk_widget_get_visible (page->tab_label)) |
2172 | ctk_widget_show (page->tab_label); |
2173 | |
2174 | ctk_css_gadget_get_preferred_size (page->gadget, |
2175 | CTK_ORIENTATION_HORIZONTAL, |
2176 | -1, |
2177 | &page->requisition.width, NULL((void*)0), |
2178 | NULL((void*)0), NULL((void*)0)); |
2179 | ctk_css_gadget_get_preferred_size (page->gadget, |
2180 | CTK_ORIENTATION_VERTICAL, |
2181 | page->requisition.width, |
2182 | &page->requisition.height, NULL((void*)0), |
2183 | NULL((void*)0), NULL((void*)0)); |
2184 | |
2185 | switch (priv->tab_pos) |
2186 | { |
2187 | case CTK_POS_TOP: |
2188 | case CTK_POS_BOTTOM: |
2189 | tab_height = MAX (tab_height, page->requisition.height)(((tab_height) > (page->requisition.height)) ? (tab_height ) : (page->requisition.height)); |
2190 | tab_max = MAX (tab_max, page->requisition.width)(((tab_max) > (page->requisition.width)) ? (tab_max) : ( page->requisition.width)); |
2191 | break; |
2192 | case CTK_POS_LEFT: |
2193 | case CTK_POS_RIGHT: |
2194 | tab_width = MAX (tab_width, page->requisition.width)(((tab_width) > (page->requisition.width)) ? (tab_width ) : (page->requisition.width)); |
2195 | tab_max = MAX (tab_max, page->requisition.height)(((tab_max) > (page->requisition.height)) ? (tab_max) : (page->requisition.height)); |
2196 | break; |
2197 | } |
2198 | } |
2199 | else if (ctk_widget_get_visible (page->tab_label)) |
2200 | ctk_widget_hide (page->tab_label); |
2201 | } |
2202 | |
2203 | children = priv->children; |
2204 | |
2205 | if (vis_pages) |
2206 | { |
2207 | switch (priv->tab_pos) |
2208 | { |
2209 | case CTK_POS_TOP: |
2210 | case CTK_POS_BOTTOM: |
2211 | if (tab_height == 0) |
2212 | break; |
2213 | |
2214 | if (priv->scrollable) |
2215 | { |
2216 | gint arrow_height, unused; |
2217 | ctk_notebook_measure_arrows (notebook, |
2218 | CTK_PACK_START, |
2219 | CTK_ORIENTATION_VERTICAL, |
2220 | -1, |
2221 | &arrow_height, &unused, |
2222 | NULL((void*)0), NULL((void*)0)); |
2223 | tab_height = MAX (tab_height, arrow_height)(((tab_height) > (arrow_height)) ? (tab_height) : (arrow_height )); |
2224 | ctk_notebook_measure_arrows (notebook, |
2225 | CTK_PACK_END, |
2226 | CTK_ORIENTATION_VERTICAL, |
2227 | -1, |
2228 | &arrow_height, &unused, |
2229 | NULL((void*)0), NULL((void*)0)); |
2230 | tab_height = MAX (tab_height, arrow_height)(((tab_height) > (arrow_height)) ? (tab_height) : (arrow_height )); |
2231 | } |
2232 | |
2233 | while (children) |
2234 | { |
2235 | page = children->data; |
2236 | children = children->next; |
2237 | |
2238 | if (!ctk_widget_get_visible (page->child)) |
2239 | continue; |
2240 | |
2241 | tab_width += page->requisition.width; |
2242 | page->requisition.height = tab_height; |
2243 | } |
2244 | |
2245 | if (priv->scrollable) |
2246 | { |
2247 | gint start_arrow_width, end_arrow_width, unused; |
2248 | |
2249 | ctk_notebook_measure_arrows (notebook, |
2250 | CTK_PACK_START, |
2251 | CTK_ORIENTATION_HORIZONTAL, |
2252 | tab_height, |
2253 | &start_arrow_width, &unused, |
2254 | NULL((void*)0), NULL((void*)0)); |
2255 | ctk_notebook_measure_arrows (notebook, |
2256 | CTK_PACK_END, |
2257 | CTK_ORIENTATION_HORIZONTAL, |
2258 | tab_height, |
2259 | &end_arrow_width, &unused, |
2260 | NULL((void*)0), NULL((void*)0)); |
2261 | tab_width = MIN (tab_width,(((tab_width) < (tab_max + start_arrow_width + end_arrow_width )) ? (tab_width) : (tab_max + start_arrow_width + end_arrow_width )) |
2262 | tab_max + start_arrow_width + end_arrow_width)(((tab_width) < (tab_max + start_arrow_width + end_arrow_width )) ? (tab_width) : (tab_max + start_arrow_width + end_arrow_width )); |
2263 | } |
2264 | |
2265 | requisition->width = tab_width; |
2266 | |
2267 | requisition->height = tab_height; |
2268 | break; |
2269 | case CTK_POS_LEFT: |
2270 | case CTK_POS_RIGHT: |
2271 | if (tab_width == 0) |
2272 | break; |
2273 | |
2274 | if (priv->scrollable) |
2275 | { |
2276 | gint arrow_width, unused; |
2277 | ctk_notebook_measure_arrows (notebook, |
2278 | CTK_PACK_START, |
2279 | CTK_ORIENTATION_HORIZONTAL, |
2280 | -1, |
2281 | &arrow_width, &unused, |
2282 | NULL((void*)0), NULL((void*)0)); |
2283 | tab_width = MAX (tab_width, arrow_width)(((tab_width) > (arrow_width)) ? (tab_width) : (arrow_width )); |
2284 | ctk_notebook_measure_arrows (notebook, |
2285 | CTK_PACK_END, |
2286 | CTK_ORIENTATION_HORIZONTAL, |
2287 | -1, |
2288 | &arrow_width, &unused, |
2289 | NULL((void*)0), NULL((void*)0)); |
2290 | tab_width = MAX (tab_width, arrow_width)(((tab_width) > (arrow_width)) ? (tab_width) : (arrow_width )); |
2291 | } |
2292 | |
2293 | while (children) |
2294 | { |
2295 | page = children->data; |
2296 | children = children->next; |
2297 | |
2298 | if (!ctk_widget_get_visible (page->child)) |
2299 | continue; |
2300 | |
2301 | page->requisition.width = tab_width; |
2302 | |
2303 | tab_height += page->requisition.height; |
2304 | } |
2305 | |
2306 | if (priv->scrollable) |
2307 | { |
2308 | gint start_arrow_height, end_arrow_height, unused; |
2309 | |
2310 | ctk_notebook_measure_arrows (notebook, |
2311 | CTK_PACK_START, |
2312 | CTK_ORIENTATION_VERTICAL, |
2313 | tab_width, |
2314 | &start_arrow_height, &unused, |
2315 | NULL((void*)0), NULL((void*)0)); |
2316 | ctk_notebook_measure_arrows (notebook, |
2317 | CTK_PACK_END, |
2318 | CTK_ORIENTATION_VERTICAL, |
2319 | tab_width, |
2320 | &end_arrow_height, &unused, |
2321 | NULL((void*)0), NULL((void*)0)); |
2322 | tab_height = MIN (tab_height, tab_max + start_arrow_height + end_arrow_height)(((tab_height) < (tab_max + start_arrow_height + end_arrow_height )) ? (tab_height) : (tab_max + start_arrow_height + end_arrow_height )); |
2323 | } |
2324 | |
2325 | requisition->height = tab_height; |
2326 | requisition->height = MAX (requisition->height, tab_max)(((requisition->height) > (tab_max)) ? (requisition-> height) : (tab_max)); |
2327 | |
2328 | requisition->width = tab_width; |
2329 | break; |
2330 | default: |
2331 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctknotebook.c", 2331, ( (const char*) (__func__)), ((void*)0)); } while (0); |
2332 | requisition->width = 0; |
2333 | requisition->height = 0; |
2334 | } |
2335 | } |
2336 | else |
2337 | { |
2338 | requisition->width = 0; |
2339 | requisition->height = 0; |
2340 | } |
2341 | } |
2342 | |
2343 | static void |
2344 | ctk_notebook_measure_tabs (CtkCssGadget *gadget, |
2345 | CtkOrientation orientation, |
2346 | gint size G_GNUC_UNUSED__attribute__ ((__unused__)), |
2347 | gint *minimum, |
2348 | gint *natural, |
2349 | gint *minimum_baseline G_GNUC_UNUSED__attribute__ ((__unused__)), |
2350 | gint *natural_baseline G_GNUC_UNUSED__attribute__ ((__unused__)), |
2351 | gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__))) |
2352 | { |
2353 | CtkWidget *widget = ctk_css_gadget_get_owner (gadget); |
2354 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2355 | CtkRequisition tabs_requisition = { 0 }; |
2356 | |
2357 | ctk_notebook_get_preferred_tabs_size (notebook, &tabs_requisition); |
2358 | if (orientation == CTK_ORIENTATION_HORIZONTAL) |
2359 | { |
2360 | *minimum = tabs_requisition.width; |
2361 | *natural = tabs_requisition.width; |
2362 | } |
2363 | else |
2364 | { |
2365 | *minimum = tabs_requisition.height; |
2366 | *natural = tabs_requisition.height; |
2367 | } |
2368 | } |
2369 | |
2370 | static void |
2371 | ctk_notebook_measure_stack (CtkCssGadget *gadget, |
2372 | CtkOrientation orientation, |
2373 | gint size, |
2374 | gint *minimum, |
2375 | gint *natural, |
2376 | gint *minimum_baseline G_GNUC_UNUSED__attribute__ ((__unused__)), |
2377 | gint *natural_baseline G_GNUC_UNUSED__attribute__ ((__unused__)), |
2378 | gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__))) |
2379 | { |
2380 | CtkWidget *widget = ctk_css_gadget_get_owner (gadget); |
2381 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2382 | CtkNotebookPrivate *priv = notebook->priv; |
2383 | GList *children; |
2384 | gint child_minimum, child_natural; |
2385 | |
2386 | *minimum = 0; |
2387 | *natural = 0; |
2388 | |
2389 | for (children = priv->children; |
2390 | children; |
2391 | children = children->next) |
2392 | { |
2393 | CtkNotebookPage *page = children->data; |
2394 | |
2395 | if (ctk_widget_get_visible (page->child)) |
2396 | { |
2397 | _ctk_widget_get_preferred_size_for_size (page->child, |
2398 | orientation, |
2399 | size, |
2400 | &child_minimum, |
2401 | &child_natural, |
2402 | NULL((void*)0), |
2403 | NULL((void*)0)); |
2404 | |
2405 | *minimum = MAX (*minimum, child_minimum)(((*minimum) > (child_minimum)) ? (*minimum) : (child_minimum )); |
2406 | *natural = MAX (*natural, child_natural)(((*natural) > (child_natural)) ? (*natural) : (child_natural )); |
2407 | } |
2408 | } |
2409 | } |
2410 | |
2411 | static void |
2412 | ctk_notebook_get_preferred_width_for_height (CtkWidget *widget, |
2413 | gint height, |
2414 | gint *minimum, |
2415 | gint *natural) |
2416 | { |
2417 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2418 | CtkNotebookPrivate *priv = notebook->priv; |
2419 | |
2420 | ctk_css_gadget_get_preferred_size (priv->gadget, CTK_ORIENTATION_HORIZONTAL, height, minimum, natural, NULL((void*)0), NULL((void*)0)); |
2421 | } |
2422 | |
2423 | static void |
2424 | ctk_notebook_get_preferred_height_for_width (CtkWidget *widget, |
2425 | gint width, |
2426 | gint *minimum, |
2427 | gint *natural) |
2428 | { |
2429 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2430 | CtkNotebookPrivate *priv = notebook->priv; |
2431 | |
2432 | ctk_css_gadget_get_preferred_size (priv->gadget, CTK_ORIENTATION_VERTICAL, width, minimum, natural, NULL((void*)0), NULL((void*)0)); |
2433 | } |
2434 | |
2435 | static void |
2436 | ctk_notebook_get_preferred_width (CtkWidget *widget, |
2437 | gint *minimum, |
2438 | gint *natural) |
2439 | { |
2440 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2441 | CtkNotebookPrivate *priv = notebook->priv; |
2442 | |
2443 | ctk_css_gadget_get_preferred_size (priv->gadget, CTK_ORIENTATION_HORIZONTAL, -1, minimum, natural, NULL((void*)0), NULL((void*)0)); |
2444 | } |
2445 | |
2446 | static void |
2447 | ctk_notebook_get_preferred_height (CtkWidget *widget, |
2448 | gint *minimum, |
2449 | gint *natural) |
2450 | { |
2451 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2452 | CtkNotebookPrivate *priv = notebook->priv; |
2453 | |
2454 | ctk_css_gadget_get_preferred_size (priv->gadget, CTK_ORIENTATION_VERTICAL, -1, minimum, natural, NULL((void*)0), NULL((void*)0)); |
2455 | } |
2456 | |
2457 | static void |
2458 | ctk_notebook_allocate_tabs (CtkCssGadget *gadget, |
2459 | const CtkAllocation *allocation, |
2460 | int baseline G_GNUC_UNUSED__attribute__ ((__unused__)), |
2461 | CtkAllocation *out_clip G_GNUC_UNUSED__attribute__ ((__unused__)), |
2462 | gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__))) |
2463 | { |
2464 | CtkWidget *widget = ctk_css_gadget_get_owner (gadget); |
2465 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2466 | |
2467 | ctk_notebook_pages_allocate (notebook, allocation); |
2468 | } |
2469 | |
2470 | static void |
2471 | ctk_notebook_allocate_stack (CtkCssGadget *gadget, |
2472 | const CtkAllocation *allocation, |
2473 | int baseline, |
2474 | CtkAllocation *out_clip, |
2475 | gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__))) |
2476 | { |
2477 | CtkWidget *widget = ctk_css_gadget_get_owner (gadget); |
2478 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2479 | CtkNotebookPrivate *priv = notebook->priv; |
2480 | GList *children; |
2481 | |
2482 | for (children = priv->children; |
2483 | children; |
2484 | children = children->next) |
2485 | { |
2486 | CtkNotebookPage *page = children->data; |
2487 | |
2488 | if (ctk_widget_get_visible (page->child)) |
2489 | ctk_widget_size_allocate_with_baseline (page->child, (CtkAllocation *) allocation, baseline); |
2490 | } |
2491 | |
2492 | if (ctk_notebook_has_current_page (notebook)) |
2493 | ctk_widget_get_clip (priv->cur_page->child, out_clip); |
2494 | } |
2495 | |
2496 | static void |
2497 | ctk_notebook_size_allocate (CtkWidget *widget, |
2498 | CtkAllocation *allocation) |
2499 | { |
2500 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2501 | CtkNotebookPrivate *priv = notebook->priv; |
2502 | CtkAllocation clip; |
2503 | |
2504 | ctk_widget_set_allocation (widget, allocation); |
2505 | |
2506 | ctk_css_gadget_allocate (priv->gadget, |
2507 | allocation, |
2508 | ctk_widget_get_allocated_baseline (widget), |
2509 | &clip); |
2510 | |
2511 | ctk_widget_set_clip (widget, &clip); |
2512 | |
2513 | if (ctk_widget_get_realized (widget)) |
2514 | { |
2515 | CdkRectangle position; |
2516 | |
2517 | if (ctk_notebook_get_event_window_position (notebook, &position)) |
2518 | { |
2519 | cdk_window_move_resize (priv->event_window, |
2520 | position.x, position.y, |
2521 | position.width, position.height); |
2522 | if (ctk_widget_get_mapped (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))))) |
2523 | cdk_window_show_unraised (priv->event_window); |
2524 | } |
2525 | else |
2526 | cdk_window_hide (priv->event_window); |
2527 | } |
2528 | } |
2529 | |
2530 | static gboolean |
2531 | ctk_notebook_draw_stack (CtkCssGadget *gadget, |
2532 | cairo_t *cr, |
2533 | int x G_GNUC_UNUSED__attribute__ ((__unused__)), |
2534 | int y G_GNUC_UNUSED__attribute__ ((__unused__)), |
2535 | int width G_GNUC_UNUSED__attribute__ ((__unused__)), |
2536 | int height G_GNUC_UNUSED__attribute__ ((__unused__)), |
2537 | gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__))) |
2538 | { |
2539 | CtkWidget *widget = ctk_css_gadget_get_owner (gadget); |
2540 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2541 | CtkNotebookPrivate *priv = notebook->priv; |
2542 | |
2543 | if (ctk_notebook_has_current_page (notebook)) |
2544 | ctk_container_propagate_draw (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ())))))), |
2545 | priv->cur_page->child, |
2546 | cr); |
2547 | |
2548 | return FALSE(0); |
2549 | } |
2550 | |
2551 | static gboolean |
2552 | ctk_notebook_draw (CtkWidget *widget, |
2553 | cairo_t *cr) |
2554 | { |
2555 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2556 | CtkNotebookPrivate *priv = notebook->priv; |
2557 | |
2558 | if (ctk_cairo_should_draw_window (cr, ctk_widget_get_window (widget))) |
2559 | ctk_css_gadget_draw (priv->gadget, cr); |
2560 | |
2561 | if (priv->operation == DRAG_OPERATION_REORDER && |
2562 | ctk_cairo_should_draw_window (cr, priv->drag_window)) |
2563 | ctk_css_gadget_draw (priv->cur_page->gadget, cr); |
2564 | |
2565 | return FALSE(0); |
2566 | } |
2567 | |
2568 | static gboolean |
2569 | ctk_notebook_show_arrows (CtkNotebook *notebook) |
2570 | { |
2571 | CtkNotebookPrivate *priv = notebook->priv; |
2572 | gboolean show_arrow = FALSE(0); |
2573 | GList *children; |
2574 | |
2575 | if (!priv->scrollable) |
2576 | return FALSE(0); |
2577 | |
2578 | children = priv->children; |
2579 | while (children) |
2580 | { |
2581 | CtkNotebookPage *page = children->data; |
2582 | |
2583 | if (page->tab_label && !ctk_widget_get_child_visible (page->tab_label)) |
2584 | show_arrow = TRUE(!(0)); |
2585 | |
2586 | children = children->next; |
2587 | } |
2588 | |
2589 | return show_arrow; |
2590 | } |
2591 | |
2592 | static void |
2593 | ctk_notebook_get_arrow_rect (CtkNotebook *notebook, |
2594 | CdkRectangle *rectangle, |
2595 | CtkNotebookArrow arrow) |
2596 | { |
2597 | CtkNotebookPrivate *priv = notebook->priv; |
2598 | |
2599 | ctk_css_gadget_get_border_allocation (priv->arrow_gadget[arrow], rectangle, NULL((void*)0)); |
2600 | } |
2601 | |
2602 | static CtkNotebookArrow |
2603 | ctk_notebook_get_arrow (CtkNotebook *notebook, |
2604 | gint x, |
2605 | gint y) |
2606 | { |
2607 | CtkNotebookPrivate *priv = notebook->priv; |
2608 | CdkRectangle arrow_rect; |
2609 | gint i; |
2610 | gint x0, y0; |
2611 | |
2612 | if (ctk_notebook_show_arrows (notebook)) |
2613 | { |
2614 | for (i = 0; i < 4; i++) |
2615 | { |
2616 | if (priv->arrow_gadget[i] == NULL((void*)0)) |
2617 | continue; |
2618 | |
2619 | ctk_notebook_get_arrow_rect (notebook, &arrow_rect, i); |
2620 | |
2621 | x0 = x - arrow_rect.x; |
2622 | y0 = y - arrow_rect.y; |
2623 | |
2624 | if (y0 >= 0 && y0 < arrow_rect.height && |
2625 | x0 >= 0 && x0 < arrow_rect.width) |
2626 | return i; |
2627 | } |
2628 | } |
2629 | |
2630 | return ARROW_NONE; |
2631 | } |
2632 | |
2633 | static void |
2634 | ctk_notebook_do_arrow (CtkNotebook *notebook, |
2635 | CtkNotebookArrow arrow) |
2636 | { |
2637 | CtkNotebookPrivate *priv = notebook->priv; |
2638 | CtkWidget *widget = CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))); |
2639 | gboolean is_rtl, left; |
2640 | |
2641 | is_rtl = ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL; |
2642 | left = (ARROW_IS_LEFT (arrow)((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_LEFT_AFTER) && !is_rtl) || |
2643 | (!ARROW_IS_LEFT (arrow)((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_LEFT_AFTER) && is_rtl); |
2644 | |
2645 | if (!priv->focus_tab || |
2646 | ctk_notebook_search_page (notebook, priv->focus_tab, |
2647 | left ? STEP_PREV : STEP_NEXT, |
2648 | TRUE(!(0)))) |
2649 | { |
2650 | ctk_notebook_change_current_page (notebook, left ? -1 : 1); |
2651 | ctk_widget_grab_focus (widget); |
2652 | } |
2653 | } |
2654 | |
2655 | static gboolean |
2656 | ctk_notebook_arrow_button_press (CtkNotebook *notebook, |
2657 | CtkNotebookArrow arrow, |
2658 | gint button) |
2659 | { |
2660 | CtkNotebookPrivate *priv = notebook->priv; |
2661 | CtkWidget *widget = CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))); |
2662 | gboolean is_rtl = ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL; |
2663 | gboolean left = (ARROW_IS_LEFT (arrow)((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_LEFT_AFTER) && !is_rtl) || |
2664 | (!ARROW_IS_LEFT (arrow)((arrow) == ARROW_LEFT_BEFORE || (arrow) == ARROW_LEFT_AFTER) && is_rtl); |
2665 | |
2666 | if (priv->pressed_button) |
2667 | return FALSE(0); |
2668 | |
2669 | if (!ctk_widget_has_focus (widget)) |
2670 | ctk_widget_grab_focus (widget); |
2671 | |
2672 | priv->pressed_button = button; |
2673 | priv->click_child = arrow; |
2674 | |
2675 | if (button == CDK_BUTTON_PRIMARY(1)) |
2676 | { |
2677 | ctk_notebook_do_arrow (notebook, arrow); |
2678 | ctk_notebook_set_scroll_timer (notebook); |
2679 | } |
2680 | else if (button == CDK_BUTTON_MIDDLE(2)) |
2681 | ctk_notebook_page_select (notebook, TRUE(!(0))); |
2682 | else if (button == CDK_BUTTON_SECONDARY(3)) |
2683 | ctk_notebook_switch_focus_tab (notebook, |
2684 | ctk_notebook_search_page (notebook, |
2685 | NULL((void*)0), |
2686 | left ? STEP_NEXT : STEP_PREV, |
2687 | TRUE(!(0)))); |
2688 | ctk_notebook_redraw_arrows (notebook); |
2689 | |
2690 | return TRUE(!(0)); |
2691 | } |
2692 | |
2693 | static gboolean |
2694 | get_widget_coordinates (CtkWidget *widget, |
2695 | CdkEvent *event, |
2696 | gdouble *x, |
2697 | gdouble *y) |
2698 | { |
2699 | CdkWindow *window = ((CdkEventAny *)event)->window; |
2700 | gdouble tx, ty; |
2701 | |
2702 | if (!cdk_event_get_coords (event, &tx, &ty)) |
2703 | return FALSE(0); |
2704 | |
2705 | while (window && window != ctk_widget_get_window (widget)) |
2706 | { |
2707 | gint window_x, window_y; |
2708 | |
2709 | cdk_window_get_position (window, &window_x, &window_y); |
2710 | tx += window_x; |
2711 | ty += window_y; |
2712 | |
2713 | window = cdk_window_get_parent (window); |
2714 | } |
2715 | |
2716 | if (window) |
2717 | { |
2718 | *x = tx; |
2719 | *y = ty; |
2720 | |
2721 | return TRUE(!(0)); |
2722 | } |
2723 | else |
2724 | return FALSE(0); |
2725 | } |
2726 | |
2727 | static gboolean |
2728 | ctk_notebook_page_tab_label_is_visible (CtkNotebookPage *page) |
2729 | { |
2730 | return page->tab_label |
2731 | && ctk_widget_get_visible (page->tab_label) |
2732 | && ctk_widget_get_child_visible (page->tab_label); |
2733 | } |
2734 | |
2735 | static GList* |
2736 | get_tab_at_pos (CtkNotebook *notebook, |
2737 | gdouble x, |
2738 | gdouble y) |
2739 | { |
2740 | CtkNotebookPrivate *priv = notebook->priv; |
2741 | CtkNotebookPage *page; |
2742 | CtkAllocation allocation; |
2743 | GList *children; |
2744 | |
2745 | for (children = priv->children; children; children = children->next) |
2746 | { |
2747 | page = children->data; |
2748 | |
2749 | if (!ctk_notebook_page_tab_label_is_visible (page)) |
2750 | continue; |
2751 | |
2752 | ctk_css_gadget_get_border_allocation (page->gadget, &allocation, NULL((void*)0)); |
2753 | if ((x >= allocation.x) && |
2754 | (y >= allocation.y) && |
2755 | (x <= (allocation.x + allocation.width)) && |
2756 | (y <= (allocation.y + allocation.height))) |
2757 | return children; |
2758 | } |
2759 | |
2760 | return NULL((void*)0); |
2761 | } |
2762 | |
2763 | static gboolean |
2764 | ctk_notebook_button_press (CtkWidget *widget, |
2765 | CdkEventButton *event) |
2766 | { |
2767 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2768 | CtkNotebookPrivate *priv = notebook->priv; |
2769 | CtkNotebookPage *page; |
2770 | GList *tab; |
2771 | CtkNotebookArrow arrow; |
2772 | gdouble x, y; |
2773 | |
2774 | if (event->type != CDK_BUTTON_PRESS || !priv->children) |
2775 | return FALSE(0); |
2776 | |
2777 | if (!get_widget_coordinates (widget, (CdkEvent *)event, &x, &y)) |
2778 | return FALSE(0); |
2779 | |
2780 | arrow = ctk_notebook_get_arrow (notebook, x, y); |
2781 | if (arrow != ARROW_NONE) |
2782 | return ctk_notebook_arrow_button_press (notebook, arrow, event->button); |
2783 | |
2784 | if (priv->menu && cdk_event_triggers_context_menu ((CdkEvent *) event)) |
2785 | { |
2786 | ctk_menu_popup_at_pointer (CTK_MENU (priv->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_menu_get_type ())))))), (CdkEvent *) event); |
2787 | return TRUE(!(0)); |
2788 | } |
2789 | |
2790 | if (event->button != CDK_BUTTON_PRIMARY(1)) |
2791 | return FALSE(0); |
2792 | |
2793 | if ((tab = get_tab_at_pos (notebook, x, y)) != NULL((void*)0)) |
2794 | { |
2795 | CtkAllocation allocation; |
2796 | gboolean page_changed, was_focus; |
2797 | |
2798 | page = tab->data; |
2799 | page_changed = page != priv->cur_page; |
2800 | was_focus = ctk_widget_is_focus (widget); |
2801 | |
2802 | ctk_notebook_switch_focus_tab (notebook, tab); |
2803 | ctk_widget_grab_focus (widget); |
2804 | |
2805 | if (page_changed && !was_focus) |
2806 | ctk_widget_child_focus (page->child, CTK_DIR_TAB_FORWARD); |
2807 | |
2808 | /* save press to possibly begin a drag */ |
2809 | if (page->reorderable || page->detachable) |
2810 | { |
2811 | priv->pressed_button = event->button; |
2812 | |
2813 | priv->mouse_x = x; |
2814 | priv->mouse_y = y; |
2815 | |
2816 | priv->drag_begin_x = priv->mouse_x; |
2817 | priv->drag_begin_y = priv->mouse_y; |
2818 | |
2819 | ctk_css_gadget_get_margin_allocation (page->gadget, &allocation, NULL((void*)0)); |
2820 | |
2821 | priv->drag_offset_x = priv->drag_begin_x - allocation.x; |
2822 | priv->drag_offset_y = priv->drag_begin_y - allocation.y; |
2823 | } |
2824 | } |
2825 | |
2826 | return TRUE(!(0)); |
2827 | } |
2828 | |
2829 | static gboolean |
2830 | ctk_notebook_popup_menu (CtkWidget *widget) |
2831 | { |
2832 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
2833 | CtkNotebookPrivate *priv = notebook->priv; |
2834 | CtkNotebookPage *page; |
2835 | CtkWidget *tab_label = NULL((void*)0); |
2836 | |
2837 | if (priv->menu) |
2838 | { |
2839 | if (priv->focus_tab) |
2840 | { |
2841 | page = priv->focus_tab->data; |
2842 | tab_label = page->tab_label; |
2843 | } |
2844 | |
2845 | if (tab_label) |
2846 | { |
2847 | g_object_set (priv->menu, |
2848 | "anchor-hints", (CDK_ANCHOR_FLIP_Y | |
2849 | CDK_ANCHOR_SLIDE | |
2850 | CDK_ANCHOR_RESIZE), |
2851 | NULL((void*)0)); |
2852 | |
2853 | ctk_menu_popup_at_widget (CTK_MENU (priv->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_menu_get_type ())))))), |
2854 | tab_label, |
2855 | CDK_GRAVITY_SOUTH_WEST, |
2856 | CDK_GRAVITY_NORTH_WEST, |
2857 | NULL((void*)0)); |
2858 | } |
2859 | else |
2860 | { |
2861 | g_object_set (priv->menu, |
2862 | "anchor-hints", (CDK_ANCHOR_SLIDE | |
2863 | CDK_ANCHOR_RESIZE), |
2864 | NULL((void*)0)); |
2865 | |
2866 | ctk_menu_popup_at_widget (CTK_MENU (priv->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_menu_get_type ())))))), |
2867 | widget, |
2868 | CDK_GRAVITY_NORTH_WEST, |
2869 | CDK_GRAVITY_NORTH_WEST, |
2870 | NULL((void*)0)); |
2871 | } |
2872 | |
2873 | ctk_menu_shell_select_first (CTK_MENU_SHELL (priv->menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_menu_shell_get_type ())))))), FALSE(0)); |
2874 | return TRUE(!(0)); |
2875 | } |
2876 | |
2877 | return FALSE(0); |
2878 | } |
2879 | |
2880 | static void |
2881 | stop_scrolling (CtkNotebook *notebook) |
2882 | { |
2883 | CtkNotebookPrivate *priv = notebook->priv; |
2884 | |
2885 | if (priv->timer) |
2886 | { |
2887 | g_source_remove (priv->timer); |
2888 | priv->timer = 0; |
2889 | priv->need_timer = FALSE(0); |
2890 | } |
2891 | priv->click_child = ARROW_NONE; |
2892 | priv->pressed_button = 0; |
2893 | ctk_notebook_redraw_arrows (notebook); |
2894 | } |
2895 | |
2896 | static GList* |
2897 | get_drop_position (CtkNotebook *notebook) |
2898 | { |
2899 | CtkNotebookPrivate *priv = notebook->priv; |
2900 | GList *children, *last_child; |
2901 | CtkNotebookPage *page; |
2902 | gboolean is_rtl; |
2903 | gint x, y; |
2904 | |
2905 | x = priv->mouse_x; |
2906 | y = priv->mouse_y; |
2907 | |
2908 | is_rtl = ctk_widget_get_direction ((CtkWidget *) notebook) == CTK_TEXT_DIR_RTL; |
2909 | children = priv->children; |
2910 | last_child = NULL((void*)0); |
2911 | |
2912 | while (children) |
2913 | { |
2914 | page = children->data; |
2915 | |
2916 | if ((priv->operation != DRAG_OPERATION_REORDER || page != priv->cur_page) && |
2917 | ctk_widget_get_visible (page->child) && |
2918 | page->tab_label && |
2919 | ctk_widget_get_mapped (page->tab_label)) |
2920 | { |
2921 | CtkAllocation allocation; |
2922 | |
2923 | ctk_css_gadget_get_border_allocation (page->gadget, &allocation, NULL((void*)0)); |
2924 | |
2925 | switch (priv->tab_pos) |
2926 | { |
2927 | case CTK_POS_TOP: |
2928 | case CTK_POS_BOTTOM: |
2929 | if (!is_rtl) |
2930 | { |
2931 | if (allocation.x + allocation.width / 2 > x) |
2932 | return children; |
2933 | } |
2934 | else |
2935 | { |
2936 | if (allocation.x + allocation.width / 2 < x) |
2937 | return children; |
2938 | } |
2939 | |
2940 | break; |
2941 | case CTK_POS_LEFT: |
2942 | case CTK_POS_RIGHT: |
2943 | if (allocation.y + allocation.height / 2 > y) |
2944 | return children; |
2945 | |
2946 | break; |
2947 | } |
2948 | |
2949 | last_child = children->next; |
2950 | } |
2951 | |
2952 | children = children->next; |
2953 | } |
2954 | |
2955 | return last_child; |
2956 | } |
2957 | |
2958 | static void |
2959 | prepare_drag_window (CdkSeat *seat G_GNUC_UNUSED__attribute__ ((__unused__)), |
2960 | CdkWindow *window, |
2961 | gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
2962 | { |
2963 | cdk_window_show (window); |
2964 | } |
2965 | |
2966 | static void |
2967 | show_drag_window (CtkNotebook *notebook, |
2968 | CtkNotebookPrivate *priv, |
2969 | CtkNotebookPage *page, |
2970 | CdkDevice *device) |
2971 | { |
2972 | CtkWidget *widget = CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))); |
2973 | |
2974 | if (!priv->drag_window) |
2975 | { |
2976 | CdkWindowAttr attributes; |
2977 | CtkAllocation allocation; |
2978 | guint attributes_mask; |
2979 | CdkRGBA transparent = {0, 0, 0, 0}; |
2980 | |
2981 | ctk_css_gadget_get_margin_allocation (page->gadget, &allocation, NULL((void*)0)); |
2982 | attributes.x = priv->drag_window_x; |
2983 | attributes.y = priv->drag_window_y; |
2984 | attributes.width = allocation.width; |
2985 | attributes.height = allocation.height; |
2986 | attributes.window_type = CDK_WINDOW_CHILD; |
2987 | attributes.wclass = CDK_INPUT_OUTPUT; |
2988 | attributes.visual = ctk_widget_get_visual (widget); |
2989 | attributes.event_mask = CDK_VISIBILITY_NOTIFY_MASK | CDK_POINTER_MOTION_MASK; |
2990 | attributes_mask = CDK_WA_X | CDK_WA_Y | CDK_WA_VISUAL; |
2991 | |
2992 | priv->drag_window = cdk_window_new (ctk_widget_get_parent_window (widget), |
2993 | &attributes, |
2994 | attributes_mask); |
2995 | ctk_widget_register_window (widget, priv->drag_window); |
2996 | cdk_window_set_background_rgba (priv->drag_window, &transparent); |
2997 | } |
2998 | |
2999 | ctk_widget_set_child_visible (page->tab_label, FALSE(0)); |
3000 | ctk_widget_unrealize (page->tab_label); |
3001 | ctk_widget_set_parent_window (page->tab_label, priv->drag_window); |
3002 | ctk_widget_set_child_visible (page->tab_label, TRUE(!(0))); |
3003 | |
3004 | ctk_css_gadget_add_class (page->gadget, CTK_STYLE_CLASS_DND"dnd"); |
3005 | |
3006 | /* the grab will dissapear when the window is hidden */ |
3007 | cdk_seat_grab (cdk_device_get_seat (device), priv->drag_window, |
3008 | CDK_SEAT_CAPABILITY_ALL, FALSE(0), |
3009 | NULL((void*)0), NULL((void*)0), prepare_drag_window, notebook); |
3010 | } |
3011 | |
3012 | /* This function undoes the reparenting that happens both when drag_window |
3013 | * is shown for reordering and when the DnD icon is shown for detaching |
3014 | */ |
3015 | static void |
3016 | hide_drag_window (CtkNotebook *notebook, |
3017 | CtkNotebookPrivate *priv, |
3018 | CtkNotebookPage *page) |
3019 | { |
3020 | CtkWidget *widget = CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))); |
3021 | |
3022 | if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ()))))))))) |
3023 | { |
3024 | g_object_ref (page->tab_label)((__typeof__ (page->tab_label)) (g_object_ref) (page->tab_label )); |
3025 | ctk_container_remove (CTK_CONTAINER (ctk_widget_get_parent (page->tab_label))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_widget_get_parent (page->tab_label))), ((ctk_container_get_type ())))))), page->tab_label); |
3026 | ctk_css_node_set_parent (ctk_widget_get_css_node (page->tab_label), |
3027 | ctk_css_gadget_get_node (page->gadget)); |
3028 | ctk_widget_set_parent (page->tab_label, CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
3029 | g_object_unref (page->tab_label); |
3030 | } |
3031 | else if (ctk_widget_get_window (page->tab_label) != ctk_widget_get_window (widget)) |
3032 | { |
3033 | ctk_widget_set_child_visible (page->tab_label, FALSE(0)); |
3034 | ctk_widget_unrealize (page->tab_label); |
3035 | ctk_widget_set_parent_window (page->tab_label, NULL((void*)0)); |
3036 | ctk_widget_set_child_visible (page->tab_label, TRUE(!(0))); |
3037 | } |
3038 | |
3039 | ctk_css_gadget_remove_class (page->gadget, CTK_STYLE_CLASS_DND"dnd"); |
3040 | |
3041 | if (priv->drag_window && |
3042 | cdk_window_is_visible (priv->drag_window)) |
3043 | cdk_window_hide (priv->drag_window); |
3044 | } |
3045 | |
3046 | static void |
3047 | ctk_notebook_stop_reorder (CtkNotebook *notebook) |
3048 | { |
3049 | CtkNotebookPrivate *priv = notebook->priv; |
3050 | CtkNotebookPage *page; |
3051 | |
3052 | if (priv->operation == DRAG_OPERATION_DETACH) |
3053 | page = priv->detached_tab; |
3054 | else |
3055 | page = priv->cur_page; |
3056 | |
3057 | if (!page || !page->tab_label) |
3058 | return; |
3059 | |
3060 | priv->pressed_button = 0; |
3061 | |
3062 | if (page->reorderable || page->detachable) |
3063 | { |
3064 | if (priv->operation == DRAG_OPERATION_REORDER) |
3065 | { |
3066 | gint old_page_num, page_num, i; |
3067 | GList *element; |
3068 | |
3069 | element = get_drop_position (notebook); |
3070 | old_page_num = g_list_position (priv->children, priv->focus_tab); |
3071 | page_num = reorder_tab (notebook, element, priv->focus_tab); |
3072 | ctk_notebook_child_reordered (notebook, page); |
3073 | |
3074 | if (priv->has_scrolled || old_page_num != page_num) |
3075 | { |
3076 | for (element = priv->children, i = 0; element; element = element->next, i++) |
3077 | { |
3078 | if (MIN (old_page_num, page_num)(((old_page_num) < (page_num)) ? (old_page_num) : (page_num )) <= i && i <= MAX (old_page_num, page_num)(((old_page_num) > (page_num)) ? (old_page_num) : (page_num ))) |
3079 | ctk_widget_child_notify (((CtkNotebookPage *) element->data)->child, "position"); |
3080 | } |
3081 | g_signal_emit (notebook, |
3082 | notebook_signals[PAGE_REORDERED], 0, |
3083 | page->child, page_num); |
3084 | } |
3085 | } |
3086 | |
3087 | priv->has_scrolled = FALSE(0); |
3088 | |
3089 | hide_drag_window (notebook, priv, page); |
3090 | |
3091 | priv->operation = DRAG_OPERATION_NONE; |
3092 | |
3093 | if (priv->dnd_timer) |
3094 | { |
3095 | g_source_remove (priv->dnd_timer); |
3096 | priv->dnd_timer = 0; |
3097 | } |
3098 | |
3099 | ctk_widget_queue_allocate (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
3100 | } |
3101 | } |
3102 | |
3103 | static gboolean |
3104 | ctk_notebook_button_release (CtkWidget *widget, |
3105 | CdkEventButton *event) |
3106 | { |
3107 | CtkNotebook *notebook; |
3108 | CtkNotebookPrivate *priv; |
3109 | |
3110 | if (event->type != CDK_BUTTON_RELEASE) |
3111 | return FALSE(0); |
3112 | |
3113 | notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3114 | priv = notebook->priv; |
3115 | |
3116 | if (priv->pressed_button != event->button) |
3117 | return FALSE(0); |
3118 | |
3119 | if (priv->operation == DRAG_OPERATION_REORDER && |
3120 | priv->cur_page && |
3121 | priv->cur_page->reorderable) |
3122 | ctk_notebook_stop_reorder (notebook); |
3123 | |
3124 | stop_scrolling (notebook); |
3125 | return TRUE(!(0)); |
3126 | } |
3127 | |
3128 | static void |
3129 | update_prelight_tab (CtkNotebook *notebook, |
3130 | CtkNotebookPage *page) |
3131 | { |
3132 | CtkNotebookPrivate *priv = notebook->priv; |
3133 | |
3134 | if (priv->prelight_tab == page) |
3135 | return; |
3136 | |
3137 | if (priv->prelight_tab) |
3138 | ctk_css_gadget_remove_state (priv->prelight_tab->gadget, CTK_STATE_FLAG_PRELIGHT); |
3139 | |
3140 | if (page) |
3141 | ctk_css_gadget_add_state (page->gadget, CTK_STATE_FLAG_PRELIGHT); |
3142 | |
3143 | priv->prelight_tab = page; |
3144 | } |
3145 | |
3146 | static void |
3147 | tab_prelight (CtkNotebook *notebook, |
3148 | CdkEvent *event) |
3149 | { |
3150 | GList *tab; |
3151 | gdouble x, y; |
3152 | |
3153 | if (get_widget_coordinates (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), (CdkEvent *)event, &x, &y)) |
3154 | { |
3155 | tab = get_tab_at_pos (notebook, x, y); |
3156 | update_prelight_tab (notebook, tab == NULL((void*)0) ? NULL((void*)0) : tab->data); |
3157 | } |
3158 | } |
3159 | |
3160 | static gboolean |
3161 | ctk_notebook_enter_notify (CtkWidget *widget, |
3162 | CdkEventCrossing *event) |
3163 | { |
3164 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3165 | |
3166 | tab_prelight (notebook, (CdkEvent *)event); |
3167 | |
3168 | return FALSE(0); |
3169 | } |
3170 | |
3171 | static gboolean |
3172 | ctk_notebook_leave_notify (CtkWidget *widget, |
3173 | CdkEventCrossing *event) |
3174 | { |
3175 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3176 | CtkNotebookPrivate *priv = notebook->priv; |
3177 | gdouble x, y; |
3178 | |
3179 | if (get_widget_coordinates (widget, (CdkEvent *)event, &x, &y)) |
3180 | { |
3181 | if (priv->prelight_tab != NULL((void*)0)) |
3182 | { |
3183 | tab_prelight (notebook, (CdkEvent *)event); |
3184 | } |
3185 | |
3186 | if (priv->in_child != ARROW_NONE) |
3187 | { |
3188 | priv->in_child = ARROW_NONE; |
3189 | ctk_notebook_redraw_arrows (notebook); |
3190 | } |
3191 | } |
3192 | |
3193 | return FALSE(0); |
3194 | } |
3195 | |
3196 | static CtkNotebookPointerPosition |
3197 | get_pointer_position (CtkNotebook *notebook) |
3198 | { |
3199 | CtkNotebookPrivate *priv = notebook->priv; |
3200 | CtkWidget *widget = CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))); |
3201 | gint wx, wy, width, height; |
3202 | gboolean is_rtl; |
3203 | |
3204 | if (!priv->scrollable) |
3205 | return POINTER_BETWEEN; |
3206 | |
3207 | cdk_window_get_position (priv->event_window, &wx, &wy); |
3208 | width = cdk_window_get_width (priv->event_window); |
3209 | height = cdk_window_get_height (priv->event_window); |
3210 | |
3211 | if (priv->tab_pos == CTK_POS_TOP || |
3212 | priv->tab_pos == CTK_POS_BOTTOM) |
3213 | { |
3214 | gint x; |
3215 | |
3216 | is_rtl = ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL; |
3217 | x = priv->mouse_x - wx; |
3218 | |
3219 | if (x > width - SCROLL_THRESHOLD12) |
3220 | return (is_rtl) ? POINTER_BEFORE : POINTER_AFTER; |
3221 | else if (x < SCROLL_THRESHOLD12) |
3222 | return (is_rtl) ? POINTER_AFTER : POINTER_BEFORE; |
3223 | else |
3224 | return POINTER_BETWEEN; |
3225 | } |
3226 | else |
3227 | { |
3228 | gint y; |
3229 | |
3230 | y = priv->mouse_y - wy; |
3231 | if (y > height - SCROLL_THRESHOLD12) |
3232 | return POINTER_AFTER; |
3233 | else if (y < SCROLL_THRESHOLD12) |
3234 | return POINTER_BEFORE; |
3235 | else |
3236 | return POINTER_BETWEEN; |
3237 | } |
3238 | } |
3239 | |
3240 | static gboolean |
3241 | scroll_notebook_timer (gpointer data) |
3242 | { |
3243 | CtkNotebook *notebook = CTK_NOTEBOOK (data)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_notebook_get_type ())))))); |
3244 | CtkNotebookPrivate *priv = notebook->priv; |
3245 | CtkNotebookPointerPosition pointer_position; |
3246 | GList *element, *first_tab; |
3247 | |
3248 | pointer_position = get_pointer_position (notebook); |
3249 | |
3250 | element = get_drop_position (notebook); |
3251 | reorder_tab (notebook, element, priv->focus_tab); |
3252 | first_tab = ctk_notebook_search_page (notebook, priv->first_tab, |
3253 | (pointer_position == POINTER_BEFORE) ? STEP_PREV : STEP_NEXT, |
3254 | TRUE(!(0))); |
3255 | if (first_tab && priv->cur_page) |
3256 | { |
3257 | priv->first_tab = first_tab; |
3258 | |
3259 | ctk_css_gadget_queue_allocate (priv->tabs_gadget); |
3260 | } |
3261 | |
3262 | return TRUE(!(0)); |
3263 | } |
3264 | |
3265 | static gboolean |
3266 | check_threshold (CtkNotebook *notebook, |
3267 | gint current_x, |
3268 | gint current_y) |
3269 | { |
3270 | CtkNotebookPrivate *priv = notebook->priv; |
3271 | gint dnd_threshold; |
3272 | CdkRectangle rectangle = { 0, }; /* shut up gcc */ |
3273 | CtkSettings *settings; |
3274 | |
3275 | settings = ctk_widget_get_settings (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
3276 | g_object_get (G_OBJECT (settings)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((settings)), (((GType) ((20) << (2)))))))), "ctk-dnd-drag-threshold", &dnd_threshold, NULL((void*)0)); |
3277 | |
3278 | /* we want a large threshold */ |
3279 | dnd_threshold *= DND_THRESHOLD_MULTIPLIER4; |
3280 | |
3281 | cdk_window_get_position (priv->event_window, &rectangle.x, &rectangle.y); |
3282 | rectangle.width = cdk_window_get_width (priv->event_window); |
3283 | rectangle.height = cdk_window_get_height (priv->event_window); |
3284 | |
3285 | rectangle.x -= dnd_threshold; |
3286 | rectangle.width += 2 * dnd_threshold; |
3287 | rectangle.y -= dnd_threshold; |
3288 | rectangle.height += 2 * dnd_threshold; |
3289 | |
3290 | return (current_x < rectangle.x || |
3291 | current_x > rectangle.x + rectangle.width || |
3292 | current_y < rectangle.y || |
3293 | current_y > rectangle.y + rectangle.height); |
3294 | } |
3295 | |
3296 | static gboolean |
3297 | ctk_notebook_motion_notify (CtkWidget *widget, |
3298 | CdkEventMotion *event) |
3299 | { |
3300 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3301 | CtkNotebookPrivate *priv = notebook->priv; |
3302 | CtkNotebookPage *page; |
3303 | CtkNotebookArrow arrow; |
3304 | CtkNotebookPointerPosition pointer_position; |
3305 | gint x_win, y_win; |
3306 | |
3307 | page = priv->cur_page; |
3308 | |
3309 | if (!page) |
3310 | return FALSE(0); |
3311 | |
3312 | if (!(event->state & CDK_BUTTON1_MASK) && |
3313 | priv->pressed_button != 0) |
3314 | { |
3315 | ctk_notebook_stop_reorder (notebook); |
3316 | stop_scrolling (notebook); |
3317 | } |
3318 | |
3319 | tab_prelight (notebook, (CdkEvent *)event); |
3320 | |
3321 | /* While animating the move, event->x is relative to the flying tab |
3322 | * (priv->drag_window has a pointer grab), but we need coordinates relative to |
3323 | * the notebook widget. |
3324 | */ |
3325 | cdk_window_get_origin (ctk_widget_get_window (widget), &x_win, &y_win); |
3326 | priv->mouse_x = event->x_root - x_win; |
3327 | priv->mouse_y = event->y_root - y_win; |
3328 | |
3329 | arrow = ctk_notebook_get_arrow (notebook, priv->mouse_x, priv->mouse_y); |
3330 | if (arrow != priv->in_child) |
3331 | { |
3332 | priv->in_child = arrow; |
3333 | ctk_notebook_redraw_arrows (notebook); |
3334 | } |
3335 | |
3336 | if (priv->pressed_button == 0) |
3337 | return FALSE(0); |
3338 | |
3339 | if (page->detachable && |
3340 | check_threshold (notebook, priv->mouse_x, priv->mouse_y)) |
3341 | { |
3342 | priv->detached_tab = priv->cur_page; |
3343 | |
3344 | ctk_drag_begin_with_coordinates (widget, priv->source_targets, CDK_ACTION_MOVE, |
3345 | priv->pressed_button, (CdkEvent*) event, |
3346 | priv->drag_begin_x, priv->drag_begin_y); |
3347 | return TRUE(!(0)); |
3348 | } |
3349 | |
3350 | if (page->reorderable && |
3351 | (priv->operation == DRAG_OPERATION_REORDER || |
3352 | ctk_drag_check_threshold (widget, priv->drag_begin_x, priv->drag_begin_y, priv->mouse_x, priv->mouse_y))) |
3353 | { |
3354 | pointer_position = get_pointer_position (notebook); |
3355 | |
3356 | if (event->window == priv->drag_window && |
3357 | pointer_position != POINTER_BETWEEN && |
3358 | ctk_notebook_show_arrows (notebook)) |
3359 | { |
3360 | /* scroll tabs */ |
3361 | if (!priv->dnd_timer) |
3362 | { |
3363 | priv->has_scrolled = TRUE(!(0)); |
3364 | priv->dnd_timer = cdk_threads_add_timeout (TIMEOUT_REPEAT50 * SCROLL_DELAY_FACTOR5, |
3365 | scroll_notebook_timer, |
3366 | (gpointer) notebook); |
3367 | g_source_set_name_by_id (priv->dnd_timer, "[ctk+] scroll_notebook_timer"); |
3368 | } |
3369 | } |
3370 | else |
3371 | { |
3372 | if (priv->dnd_timer) |
3373 | { |
3374 | g_source_remove (priv->dnd_timer); |
3375 | priv->dnd_timer = 0; |
3376 | } |
3377 | } |
3378 | |
3379 | if (event->window == priv->drag_window || |
3380 | priv->operation != DRAG_OPERATION_REORDER) |
3381 | { |
3382 | /* the drag operation is beginning, create the window */ |
3383 | if (priv->operation != DRAG_OPERATION_REORDER) |
3384 | { |
3385 | priv->operation = DRAG_OPERATION_REORDER; |
3386 | show_drag_window (notebook, priv, page, event->device); |
3387 | } |
3388 | } |
3389 | } |
3390 | |
3391 | if (priv->operation == DRAG_OPERATION_REORDER) |
3392 | ctk_widget_queue_allocate (widget); |
3393 | |
3394 | return TRUE(!(0)); |
3395 | } |
3396 | |
3397 | static void |
3398 | ctk_notebook_grab_notify (CtkWidget *widget, |
3399 | gboolean was_grabbed) |
3400 | { |
3401 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3402 | |
3403 | if (!was_grabbed) |
3404 | { |
3405 | ctk_notebook_stop_reorder (notebook); |
3406 | stop_scrolling (notebook); |
3407 | } |
3408 | } |
3409 | |
3410 | static void |
3411 | update_tab_state (CtkNotebook *notebook) |
3412 | { |
3413 | CtkNotebookPrivate *priv = notebook->priv; |
3414 | CtkStateFlags state, tab_state; |
3415 | GList *l; |
3416 | |
3417 | state = ctk_widget_get_state_flags (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
3418 | |
3419 | state = state & ~CTK_STATE_FLAG_FOCUSED; |
3420 | |
3421 | ctk_css_gadget_set_state (priv->stack_gadget, state); |
3422 | ctk_css_gadget_set_state (priv->header_gadget, state); |
3423 | ctk_css_gadget_set_state (priv->tabs_gadget, state); |
3424 | |
3425 | for (l = priv->children; l; l = l->next) |
3426 | { |
3427 | CtkNotebookPage *page = l->data; |
3428 | |
3429 | tab_state = state & ~(CTK_STATE_FLAG_CHECKED | CTK_STATE_FLAG_PRELIGHT); |
3430 | |
3431 | if (page == priv->cur_page) |
3432 | tab_state |= CTK_STATE_FLAG_CHECKED; |
3433 | if (page == priv->prelight_tab) |
3434 | tab_state |= CTK_STATE_FLAG_PRELIGHT; |
3435 | |
3436 | ctk_css_gadget_set_state (page->gadget, tab_state); |
3437 | } |
3438 | } |
3439 | |
3440 | static void |
3441 | update_arrow_state (CtkNotebook *notebook) |
3442 | { |
3443 | CtkNotebookPrivate *priv = notebook->priv; |
3444 | gint i; |
3445 | CtkStateFlags state; |
3446 | gboolean is_rtl, left; |
3447 | |
3448 | is_rtl = ctk_widget_get_direction (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) == CTK_TEXT_DIR_RTL; |
3449 | |
3450 | for (i = 0; i < 4; i++) |
3451 | { |
3452 | if (priv->arrow_gadget[i] == NULL((void*)0)) |
3453 | continue; |
3454 | |
3455 | state = ctk_widget_get_state_flags (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
3456 | state &= ~CTK_STATE_FLAG_FOCUSED; |
3457 | |
3458 | |
3459 | left = (ARROW_IS_LEFT (i)((i) == ARROW_LEFT_BEFORE || (i) == ARROW_LEFT_AFTER) && !is_rtl) || |
3460 | (!ARROW_IS_LEFT (i)((i) == ARROW_LEFT_BEFORE || (i) == ARROW_LEFT_AFTER) && is_rtl); |
3461 | |
3462 | if (priv->focus_tab && |
3463 | !ctk_notebook_search_page (notebook, priv->focus_tab, |
3464 | left ? STEP_PREV : STEP_NEXT, TRUE(!(0)))) |
3465 | { |
3466 | state |= CTK_STATE_FLAG_INSENSITIVE; |
3467 | } |
3468 | else if (priv->in_child == i) |
3469 | { |
3470 | state |= CTK_STATE_FLAG_PRELIGHT; |
3471 | if (priv->click_child == i) |
3472 | state |= CTK_STATE_FLAG_ACTIVE; |
3473 | } |
3474 | |
3475 | ctk_css_gadget_set_state (priv->arrow_gadget[i], state); |
3476 | } |
3477 | } |
3478 | |
3479 | static void |
3480 | ctk_notebook_state_flags_changed (CtkWidget *widget, |
3481 | CtkStateFlags previous_state G_GNUC_UNUSED__attribute__ ((__unused__))) |
3482 | { |
3483 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3484 | |
3485 | update_tab_state (notebook); |
3486 | update_arrow_state (notebook); |
3487 | |
3488 | if (!ctk_widget_is_sensitive (widget)) |
3489 | stop_scrolling (notebook); |
3490 | } |
3491 | |
3492 | static gboolean |
3493 | ctk_notebook_focus_in (CtkWidget *widget, |
3494 | CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__))) |
3495 | { |
3496 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3497 | CtkNotebookPrivate *priv = notebook->priv; |
3498 | |
3499 | ctk_css_gadget_queue_draw (priv->tabs_gadget); |
3500 | |
3501 | return FALSE(0); |
3502 | } |
3503 | |
3504 | static gboolean |
3505 | ctk_notebook_focus_out (CtkWidget *widget, |
3506 | CdkEventFocus *event G_GNUC_UNUSED__attribute__ ((__unused__))) |
3507 | { |
3508 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3509 | CtkNotebookPrivate *priv = notebook->priv; |
3510 | |
3511 | ctk_css_gadget_queue_draw (priv->tabs_gadget); |
3512 | |
3513 | return FALSE(0); |
3514 | } |
3515 | |
3516 | static void |
3517 | update_arrow_nodes (CtkNotebook *notebook) |
3518 | { |
3519 | CtkNotebookPrivate *priv = notebook->priv; |
3520 | gboolean arrow[4]; |
3521 | CtkCssImageBuiltinType up_image_type, down_image_type; |
3522 | const char *style_property_name; |
3523 | CtkCssNode *tabs_node; |
3524 | gint i; |
3525 | |
3526 | tabs_node = ctk_css_gadget_get_node (priv->tabs_gadget); |
3527 | |
3528 | if (priv->tab_pos == CTK_POS_LEFT || |
3529 | priv->tab_pos == CTK_POS_RIGHT) |
3530 | { |
3531 | up_image_type = CTK_CSS_IMAGE_BUILTIN_ARROW_UP; |
3532 | down_image_type = CTK_CSS_IMAGE_BUILTIN_ARROW_DOWN; |
3533 | style_property_name = "scroll-arrow-vlength"; |
3534 | } |
3535 | else |
3536 | { |
3537 | up_image_type = CTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT; |
3538 | down_image_type = CTK_CSS_IMAGE_BUILTIN_ARROW_LEFT; |
3539 | style_property_name = "scroll-arrow-hlength"; |
3540 | } |
3541 | |
3542 | ctk_widget_style_get (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), |
3543 | "has-backward-stepper", &arrow[0], |
3544 | "has-secondary-forward-stepper", &arrow[1], |
3545 | "has-secondary-backward-stepper", &arrow[2], |
3546 | "has-forward-stepper", &arrow[3], |
3547 | NULL((void*)0)); |
3548 | |
3549 | for (i = 0; i < 4; i++) |
3550 | { |
3551 | if (priv->scrollable && arrow[i]) |
3552 | { |
3553 | if (priv->arrow_gadget[i] == NULL((void*)0)) |
3554 | { |
3555 | CtkCssGadget *next_gadget; |
3556 | |
3557 | switch (i) |
3558 | { |
3559 | case 0: |
3560 | if (priv->arrow_gadget[1]) |
3561 | { |
3562 | next_gadget = priv->arrow_gadget[1]; |
3563 | break; |
3564 | } |
3565 | /* fall through */ |
3566 | case 1: |
3567 | if (priv->children) |
3568 | { |
3569 | CtkNotebookPage *page = priv->children->data; |
3570 | next_gadget = page->gadget; |
3571 | break; |
3572 | } |
3573 | if (priv->arrow_gadget[2]) |
3574 | { |
3575 | next_gadget = priv->arrow_gadget[2]; |
3576 | break; |
3577 | } |
3578 | /* fall through */ |
3579 | case 2: |
3580 | if (priv->arrow_gadget[3]) |
3581 | { |
3582 | next_gadget = priv->arrow_gadget[3]; |
3583 | break; |
3584 | } |
3585 | /* fall through */ |
3586 | case 3: |
3587 | next_gadget = NULL((void*)0); |
3588 | break; |
3589 | |
3590 | default: |
3591 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctknotebook.c", 3591, ( (const char*) (__func__)), ((void*)0)); } while (0); |
3592 | next_gadget = NULL((void*)0); |
3593 | break; |
3594 | } |
3595 | |
3596 | priv->arrow_gadget[i] = ctk_builtin_icon_new ("arrow", |
3597 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), |
3598 | priv->tabs_gadget, |
3599 | next_gadget); |
3600 | if (i == ARROW_LEFT_BEFORE || i == ARROW_LEFT_AFTER) |
3601 | ctk_css_gadget_add_class (priv->arrow_gadget[i], "down"); |
3602 | else |
3603 | ctk_css_gadget_add_class (priv->arrow_gadget[i], "up"); |
3604 | ctk_css_gadget_set_state (priv->arrow_gadget[i], ctk_css_node_get_state (tabs_node)); |
3605 | } |
3606 | |
3607 | if (i == ARROW_LEFT_BEFORE || i == ARROW_LEFT_AFTER) |
3608 | ctk_builtin_icon_set_image (CTK_BUILTIN_ICON (priv->arrow_gadget[i])((((CtkBuiltinIcon*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->arrow_gadget[i]), ((ctk_builtin_icon_get_type () )))))), down_image_type); |
3609 | else |
3610 | ctk_builtin_icon_set_image (CTK_BUILTIN_ICON (priv->arrow_gadget[i])((((CtkBuiltinIcon*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->arrow_gadget[i]), ((ctk_builtin_icon_get_type () )))))), up_image_type); |
3611 | |
3612 | ctk_builtin_icon_set_default_size_property (CTK_BUILTIN_ICON (priv->arrow_gadget[i])((((CtkBuiltinIcon*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->arrow_gadget[i]), ((ctk_builtin_icon_get_type () )))))), style_property_name); |
3613 | } |
3614 | else |
3615 | { |
3616 | if (priv->arrow_gadget[i]) |
3617 | { |
3618 | ctk_css_node_set_parent (ctk_css_gadget_get_node (priv->arrow_gadget[i]), NULL((void*)0)); |
3619 | g_clear_object (&priv->arrow_gadget[i])do { _Static_assert (sizeof *((&priv->arrow_gadget[i]) ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&priv->arrow_gadget[i]))) _pp = ((&priv->arrow_gadget [i])); __typeof__ (*((&priv->arrow_gadget[i]))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
3620 | } |
3621 | } |
3622 | } |
3623 | } |
3624 | |
3625 | static void |
3626 | ctk_notebook_style_updated (CtkWidget *widget) |
3627 | { |
3628 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3629 | |
3630 | update_arrow_nodes (notebook); |
3631 | update_arrow_state (notebook); |
3632 | |
3633 | CTK_WIDGET_CLASS (ctk_notebook_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), ((ctk_widget_get_type ()))) )))->style_updated (widget); |
3634 | } |
3635 | |
3636 | static gboolean |
3637 | on_drag_icon_draw (CtkWidget *widget, |
3638 | cairo_t *cr, |
3639 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
3640 | { |
3641 | CtkWidget *child; |
3642 | CtkRequisition requisition; |
3643 | CtkStyleContext *context; |
3644 | |
3645 | child = ctk_bin_get_child (CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_bin_get_type ()))))))); |
3646 | context = ctk_widget_get_style_context (widget); |
3647 | |
3648 | ctk_style_context_save (context); |
3649 | |
3650 | ctk_widget_get_preferred_size (widget, |
3651 | &requisition, NULL((void*)0)); |
3652 | |
3653 | ctk_render_background (context, cr, 0, 0, |
3654 | requisition.width, |
3655 | requisition.height); |
3656 | |
3657 | ctk_render_frame (context, cr, 0, 0, |
3658 | requisition.width, |
3659 | requisition.height); |
3660 | |
3661 | if (child) |
3662 | ctk_container_propagate_draw (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), child, cr); |
3663 | |
3664 | ctk_style_context_restore (context); |
3665 | |
3666 | return TRUE(!(0)); |
3667 | } |
3668 | |
3669 | static void |
3670 | ctk_notebook_drag_begin (CtkWidget *widget, |
3671 | CdkDragContext *context) |
3672 | { |
3673 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3674 | CtkNotebookPrivate *priv = notebook->priv; |
3675 | CtkAllocation allocation; |
3676 | CtkWidget *tab_label; |
3677 | |
3678 | if (priv->dnd_timer) |
3679 | { |
3680 | g_source_remove (priv->dnd_timer); |
3681 | priv->dnd_timer = 0; |
3682 | } |
3683 | |
3684 | g_assert (priv->cur_page != NULL)do { if (priv->cur_page != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctknotebook.c", 3684, ((const char*) (__func__)), "priv->cur_page != NULL" ); } while (0); |
3685 | |
3686 | priv->operation = DRAG_OPERATION_DETACH; |
3687 | |
3688 | tab_label = priv->detached_tab->tab_label; |
3689 | |
3690 | hide_drag_window (notebook, priv, priv->cur_page); |
3691 | g_object_ref (tab_label)((__typeof__ (tab_label)) (g_object_ref) (tab_label)); |
3692 | ctk_widget_unparent (tab_label); |
3693 | |
3694 | priv->dnd_window = ctk_window_new (CTK_WINDOW_POPUP); |
3695 | ctk_window_set_screen (CTK_WINDOW (priv->dnd_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dnd_window)), ((ctk_window_get_type ())))))), |
3696 | ctk_widget_get_screen (widget)); |
3697 | ctk_container_add (CTK_CONTAINER (priv->dnd_window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dnd_window)), ((ctk_container_get_type ())))))), tab_label); |
3698 | ctk_css_gadget_get_margin_allocation (priv->detached_tab->gadget, &allocation, NULL((void*)0)); |
3699 | ctk_widget_set_size_request (priv->dnd_window, |
3700 | allocation.width, |
3701 | allocation.height); |
3702 | g_object_unref (tab_label); |
3703 | |
3704 | g_signal_connect (G_OBJECT (priv->dnd_window), "draw",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->dnd_window)), (((GType) ((20) << (2))))))))), ("draw"), (((GCallback) (on_drag_icon_draw))), ( notebook), ((void*)0), (GConnectFlags) 0) |
3705 | G_CALLBACK (on_drag_icon_draw), notebook)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((priv->dnd_window)), (((GType) ((20) << (2))))))))), ("draw"), (((GCallback) (on_drag_icon_draw))), ( notebook), ((void*)0), (GConnectFlags) 0); |
3706 | |
3707 | ctk_drag_set_icon_widget (context, priv->dnd_window, -2, -2); |
3708 | g_object_set_data (G_OBJECT (priv->dnd_window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dnd_window)), (((GType) ((20) << (2)))))) )), "drag-context", context); |
3709 | } |
3710 | |
3711 | static void |
3712 | ctk_notebook_drag_end (CtkWidget *widget, |
3713 | CdkDragContext *context) |
3714 | { |
3715 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3716 | CtkNotebookPrivate *priv = notebook->priv; |
3717 | |
3718 | ctk_notebook_stop_reorder (notebook); |
3719 | |
3720 | if (priv->rootwindow_drop) |
3721 | { |
3722 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3723 | CtkNotebookPrivate *priv = notebook->priv; |
3724 | CtkNotebook *dest_notebook = NULL((void*)0); |
3725 | gint x, y; |
3726 | |
3727 | cdk_device_get_position (cdk_drag_context_get_device (context), |
3728 | NULL((void*)0), &x, &y); |
3729 | g_signal_emit (notebook, notebook_signals[CREATE_WINDOW], 0, |
3730 | priv->detached_tab->child, x, y, &dest_notebook); |
3731 | |
3732 | if (dest_notebook) |
3733 | do_detach_tab (notebook, dest_notebook, priv->detached_tab->child, 0, 0); |
3734 | |
3735 | priv->rootwindow_drop = FALSE(0); |
3736 | } |
3737 | else if (priv->detached_tab) |
3738 | ctk_notebook_switch_page (notebook, priv->detached_tab); |
3739 | |
3740 | _ctk_bin_set_child (CTK_BIN (priv->dnd_window)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dnd_window)), ((ctk_bin_get_type ())))))), NULL((void*)0)); |
3741 | ctk_widget_destroy (priv->dnd_window); |
3742 | priv->dnd_window = NULL((void*)0); |
3743 | |
3744 | priv->operation = DRAG_OPERATION_NONE; |
3745 | } |
3746 | |
3747 | static CtkNotebook * |
3748 | ctk_notebook_create_window (CtkNotebook *notebook G_GNUC_UNUSED__attribute__ ((__unused__)), |
3749 | CtkWidget *page G_GNUC_UNUSED__attribute__ ((__unused__)), |
3750 | gint x G_GNUC_UNUSED__attribute__ ((__unused__)), |
3751 | gint y G_GNUC_UNUSED__attribute__ ((__unused__))) |
3752 | { |
3753 | return NULL((void*)0); |
3754 | } |
3755 | |
3756 | static gboolean |
3757 | ctk_notebook_drag_failed (CtkWidget *widget, |
3758 | CdkDragContext *context, |
3759 | CtkDragResult result) |
3760 | { |
3761 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3762 | CtkNotebookPrivate *priv = notebook->priv; |
3763 | |
3764 | priv->rootwindow_drop = FALSE(0); |
3765 | |
3766 | if (result == CTK_DRAG_RESULT_NO_TARGET) |
3767 | { |
3768 | CtkNotebook *dest_notebook = NULL((void*)0); |
3769 | gint x, y; |
3770 | |
3771 | cdk_device_get_position (cdk_drag_context_get_device (context), |
3772 | NULL((void*)0), &x, &y); |
3773 | |
3774 | g_signal_emit (notebook, notebook_signals[CREATE_WINDOW], 0, |
3775 | priv->detached_tab->child, x, y, &dest_notebook); |
3776 | |
3777 | if (dest_notebook) |
3778 | do_detach_tab (notebook, dest_notebook, priv->detached_tab->child, 0, 0); |
3779 | |
3780 | return TRUE(!(0)); |
3781 | } |
3782 | |
3783 | return FALSE(0); |
3784 | } |
3785 | |
3786 | static gboolean |
3787 | ctk_notebook_switch_tab_timeout (gpointer data) |
3788 | { |
3789 | CtkNotebook *notebook = CTK_NOTEBOOK (data)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_notebook_get_type ())))))); |
3790 | CtkNotebookPrivate *priv = notebook->priv; |
3791 | GList *switch_tab; |
3792 | |
3793 | priv->switch_tab_timer = 0; |
3794 | |
3795 | switch_tab = priv->switch_tab; |
3796 | priv->switch_tab = NULL((void*)0); |
3797 | |
3798 | if (switch_tab) |
3799 | { |
3800 | /* FIXME: hack, we don't want the |
3801 | * focus to move fom the source widget |
3802 | */ |
3803 | priv->child_has_focus = FALSE(0); |
3804 | ctk_notebook_switch_focus_tab (notebook, switch_tab); |
3805 | } |
3806 | |
3807 | return FALSE(0); |
3808 | } |
3809 | |
3810 | static gboolean |
3811 | ctk_notebook_drag_motion (CtkWidget *widget, |
3812 | CdkDragContext *context, |
3813 | gint x, |
3814 | gint y, |
3815 | guint time) |
3816 | { |
3817 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3818 | CtkNotebookPrivate *priv = notebook->priv; |
3819 | CtkAllocation allocation; |
3820 | CdkRectangle position; |
3821 | CtkNotebookArrow arrow; |
3822 | CdkAtom target, tab_target; |
3823 | GList *tab; |
3824 | gboolean retval = FALSE(0); |
3825 | |
3826 | ctk_widget_get_allocation (widget, &allocation); |
3827 | |
3828 | arrow = ctk_notebook_get_arrow (notebook, |
3829 | x + allocation.x, |
3830 | y + allocation.y); |
3831 | if (arrow != ARROW_NONE) |
3832 | { |
3833 | priv->click_child = arrow; |
3834 | ctk_notebook_set_scroll_timer (notebook); |
3835 | cdk_drag_status (context, 0, time); |
3836 | |
3837 | retval = TRUE(!(0)); |
3838 | goto out; |
3839 | } |
3840 | |
3841 | stop_scrolling (notebook); |
3842 | target = ctk_drag_dest_find_target (widget, context, NULL((void*)0)); |
3843 | tab_target = cdk_atom_intern_static_string ("CTK_NOTEBOOK_TAB"); |
3844 | |
3845 | if (target == tab_target) |
3846 | { |
3847 | GQuark group, source_group; |
3848 | CtkNotebook *source; |
3849 | CtkWidget *source_child; |
3850 | |
3851 | retval = TRUE(!(0)); |
3852 | |
3853 | source = CTK_NOTEBOOK (ctk_drag_get_source_widget (context))((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_drag_get_source_widget (context))), ((ctk_notebook_get_type ())))))); |
3854 | g_assert (source->priv->cur_page != NULL)do { if (source->priv->cur_page != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctknotebook.c", 3854, ((const char*) (__func__)), "source->priv->cur_page != NULL" ); } while (0); |
3855 | source_child = source->priv->cur_page->child; |
3856 | |
3857 | group = notebook->priv->group; |
3858 | source_group = source->priv->group; |
3859 | |
3860 | if (group != 0 && group == source_group && |
3861 | !(widget == source_child || |
3862 | ctk_widget_is_ancestor (widget, source_child))) |
3863 | { |
3864 | cdk_drag_status (context, CDK_ACTION_MOVE, time); |
3865 | goto out; |
3866 | } |
3867 | else |
3868 | { |
3869 | /* it's a tab, but doesn't share |
3870 | * ID with this notebook */ |
3871 | cdk_drag_status (context, 0, time); |
3872 | } |
3873 | } |
3874 | |
3875 | x += allocation.x; |
3876 | y += allocation.y; |
3877 | |
3878 | if (ctk_notebook_get_event_window_position (notebook, &position) && |
3879 | x >= position.x && x <= position.x + position.width && |
3880 | y >= position.y && y <= position.y + position.height && |
3881 | (tab = get_tab_at_pos (notebook, x, y))) |
3882 | { |
3883 | priv->mouse_x = x; |
3884 | priv->mouse_y = y; |
3885 | |
3886 | retval = TRUE(!(0)); |
3887 | |
3888 | if (tab != priv->switch_tab) |
3889 | remove_switch_tab_timer (notebook); |
3890 | |
3891 | priv->switch_tab = tab; |
3892 | |
3893 | if (!priv->switch_tab_timer) |
3894 | { |
3895 | priv->switch_tab_timer = cdk_threads_add_timeout (TIMEOUT_EXPAND500, |
3896 | ctk_notebook_switch_tab_timeout, |
3897 | widget); |
3898 | g_source_set_name_by_id (priv->switch_tab_timer, "[ctk+] ctk_notebook_switch_tab_timeout"); |
3899 | } |
3900 | } |
3901 | else |
3902 | { |
3903 | remove_switch_tab_timer (notebook); |
3904 | } |
3905 | |
3906 | out: |
3907 | return retval; |
3908 | } |
3909 | |
3910 | static void |
3911 | ctk_notebook_drag_leave (CtkWidget *widget, |
3912 | CdkDragContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
3913 | guint time G_GNUC_UNUSED__attribute__ ((__unused__))) |
3914 | { |
3915 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
3916 | |
3917 | remove_switch_tab_timer (notebook); |
3918 | stop_scrolling (notebook); |
3919 | } |
3920 | |
3921 | static gboolean |
3922 | ctk_notebook_drag_drop (CtkWidget *widget, |
3923 | CdkDragContext *context, |
3924 | gint x G_GNUC_UNUSED__attribute__ ((__unused__)), |
3925 | gint y G_GNUC_UNUSED__attribute__ ((__unused__)), |
3926 | guint time) |
3927 | { |
3928 | CdkAtom target, tab_target; |
3929 | |
3930 | target = ctk_drag_dest_find_target (widget, context, NULL((void*)0)); |
3931 | tab_target = cdk_atom_intern_static_string ("CTK_NOTEBOOK_TAB"); |
3932 | |
3933 | if (target == tab_target) |
3934 | { |
3935 | ctk_drag_get_data (widget, context, target, time); |
3936 | return TRUE(!(0)); |
3937 | } |
3938 | |
3939 | return FALSE(0); |
3940 | } |
3941 | |
3942 | /** |
3943 | * ctk_notebook_detach_tab: |
3944 | * @notebook: a #CtkNotebook |
3945 | * @child: a child |
3946 | * |
3947 | * Removes the child from the notebook. |
3948 | * |
3949 | * This function is very similar to ctk_container_remove(), |
3950 | * but additionally informs the notebook that the removal |
3951 | * is happening as part of a tab DND operation, which should |
3952 | * not be cancelled. |
3953 | * |
3954 | * Since: 3.16 |
3955 | */ |
3956 | void |
3957 | ctk_notebook_detach_tab (CtkNotebook *notebook, |
3958 | CtkWidget *child) |
3959 | { |
3960 | notebook->priv->remove_in_detach = TRUE(!(0)); |
3961 | ctk_container_remove (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ())))))), child); |
3962 | notebook->priv->remove_in_detach = FALSE(0); |
3963 | } |
3964 | |
3965 | static void |
3966 | do_detach_tab (CtkNotebook *from, |
3967 | CtkNotebook *to, |
3968 | CtkWidget *child, |
3969 | gint x, |
3970 | gint y) |
3971 | { |
3972 | CtkNotebookPrivate *to_priv = to->priv; |
3973 | CtkAllocation to_allocation; |
3974 | CtkWidget *tab_label, *menu_label; |
3975 | gboolean tab_expand, tab_fill, reorderable, detachable; |
3976 | GList *element; |
3977 | gint page_num; |
3978 | |
3979 | menu_label = ctk_notebook_get_menu_label (from, child); |
3980 | |
3981 | if (menu_label) |
3982 | g_object_ref (menu_label)((__typeof__ (menu_label)) (g_object_ref) (menu_label)); |
3983 | |
3984 | tab_label = ctk_notebook_get_tab_label (from, child); |
3985 | |
3986 | if (tab_label) |
3987 | g_object_ref (tab_label)((__typeof__ (tab_label)) (g_object_ref) (tab_label)); |
3988 | |
3989 | g_object_ref (child)((__typeof__ (child)) (g_object_ref) (child)); |
3990 | |
3991 | ctk_container_child_get (CTK_CONTAINER (from)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((from)), ((ctk_container_get_type ())))))), |
3992 | child, |
3993 | "tab-expand", &tab_expand, |
3994 | "tab-fill", &tab_fill, |
3995 | "reorderable", &reorderable, |
3996 | "detachable", &detachable, |
3997 | NULL((void*)0)); |
3998 | |
3999 | ctk_notebook_detach_tab (from, child); |
4000 | |
4001 | ctk_widget_get_allocation (CTK_WIDGET (to)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((to)), ((ctk_widget_get_type ())))))), &to_allocation); |
4002 | to_priv->mouse_x = x + to_allocation.x; |
4003 | to_priv->mouse_y = y + to_allocation.y; |
4004 | |
4005 | element = get_drop_position (to); |
4006 | page_num = g_list_position (to_priv->children, element); |
4007 | ctk_notebook_insert_page_menu (to, child, tab_label, menu_label, page_num); |
4008 | |
4009 | ctk_container_child_set (CTK_CONTAINER (to)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((to)), ((ctk_container_get_type ())))))), child, |
4010 | "tab-expand", tab_expand, |
4011 | "tab-fill", tab_fill, |
4012 | "reorderable", reorderable, |
4013 | "detachable", detachable, |
4014 | NULL((void*)0)); |
4015 | if (child) |
4016 | g_object_unref (child); |
4017 | |
4018 | if (tab_label) |
4019 | g_object_unref (tab_label); |
4020 | |
4021 | if (menu_label) |
4022 | g_object_unref (menu_label); |
4023 | |
4024 | ctk_notebook_set_current_page (to, page_num); |
4025 | } |
4026 | |
4027 | static void |
4028 | ctk_notebook_drag_data_get (CtkWidget *widget, |
4029 | CdkDragContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
4030 | CtkSelectionData *data, |
4031 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
4032 | guint time G_GNUC_UNUSED__attribute__ ((__unused__))) |
4033 | { |
4034 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
4035 | CtkNotebookPrivate *priv = notebook->priv; |
4036 | CdkAtom target; |
4037 | |
4038 | target = ctk_selection_data_get_target (data); |
4039 | if (target == cdk_atom_intern_static_string ("CTK_NOTEBOOK_TAB")) |
4040 | { |
4041 | ctk_selection_data_set (data, |
4042 | target, |
4043 | 8, |
4044 | (void*) &priv->detached_tab->child, |
4045 | sizeof (gpointer)); |
4046 | priv->rootwindow_drop = FALSE(0); |
4047 | } |
4048 | else if (target == cdk_atom_intern_static_string ("application/x-rootwindow-drop")) |
4049 | { |
4050 | ctk_selection_data_set (data, target, 8, NULL((void*)0), 0); |
4051 | priv->rootwindow_drop = TRUE(!(0)); |
4052 | } |
4053 | } |
4054 | |
4055 | static void |
4056 | ctk_notebook_drag_data_received (CtkWidget *widget, |
4057 | CdkDragContext *context, |
4058 | gint x, |
4059 | gint y, |
4060 | CtkSelectionData *data, |
4061 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
4062 | guint time) |
4063 | { |
4064 | CtkNotebook *notebook; |
4065 | CtkWidget *source_widget; |
4066 | CtkWidget **child; |
4067 | |
4068 | notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
4069 | source_widget = ctk_drag_get_source_widget (context); |
4070 | |
4071 | if (source_widget && |
4072 | ctk_selection_data_get_target (data) == cdk_atom_intern_static_string ("CTK_NOTEBOOK_TAB")) |
4073 | { |
4074 | child = (void*) ctk_selection_data_get_data (data); |
4075 | |
4076 | do_detach_tab (CTK_NOTEBOOK (source_widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_widget)), ((ctk_notebook_get_type ())))))), notebook, *child, x, y); |
4077 | ctk_drag_finish (context, TRUE(!(0)), FALSE(0), time); |
4078 | } |
4079 | else |
4080 | ctk_drag_finish (context, FALSE(0), FALSE(0), time); |
4081 | } |
4082 | |
4083 | /* Private CtkContainer Methods : |
4084 | * |
4085 | * ctk_notebook_set_child_arg |
4086 | * ctk_notebook_get_child_arg |
4087 | * ctk_notebook_add |
4088 | * ctk_notebook_remove |
4089 | * ctk_notebook_focus |
4090 | * ctk_notebook_set_focus_child |
4091 | * ctk_notebook_child_type |
4092 | * ctk_notebook_forall |
4093 | */ |
4094 | static void |
4095 | ctk_notebook_set_child_property (CtkContainer *container, |
4096 | CtkWidget *child, |
4097 | guint property_id, |
4098 | const GValue *value, |
4099 | GParamSpec *pspec) |
4100 | { |
4101 | gboolean expand; |
4102 | gboolean fill; |
4103 | |
4104 | /* not finding child's page is valid for menus or labels */ |
4105 | if (!ctk_notebook_find_child (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child)) |
4106 | return; |
4107 | |
4108 | switch (property_id) |
4109 | { |
4110 | case CHILD_PROP_TAB_LABEL: |
4111 | /* a NULL pointer indicates a default_tab setting, otherwise |
4112 | * we need to set the associated label |
4113 | */ |
4114 | ctk_notebook_set_tab_label_text (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4115 | g_value_get_string (value)); |
4116 | break; |
4117 | case CHILD_PROP_MENU_LABEL: |
4118 | ctk_notebook_set_menu_label_text (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4119 | g_value_get_string (value)); |
4120 | break; |
4121 | case CHILD_PROP_POSITION: |
4122 | ctk_notebook_reorder_child (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4123 | g_value_get_int (value)); |
4124 | break; |
4125 | case CHILD_PROP_TAB_EXPAND: |
4126 | ctk_notebook_query_tab_label_packing (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4127 | &expand, &fill); |
4128 | ctk_notebook_set_tab_label_packing (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4129 | g_value_get_boolean (value), |
4130 | fill); |
4131 | break; |
4132 | case CHILD_PROP_TAB_FILL: |
4133 | ctk_notebook_query_tab_label_packing (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4134 | &expand, &fill); |
4135 | ctk_notebook_set_tab_label_packing (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4136 | expand, |
4137 | g_value_get_boolean (value)); |
4138 | break; |
4139 | case CHILD_PROP_REORDERABLE: |
4140 | ctk_notebook_set_tab_reorderable (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4141 | g_value_get_boolean (value)); |
4142 | break; |
4143 | case CHILD_PROP_DETACHABLE: |
4144 | ctk_notebook_set_tab_detachable (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4145 | g_value_get_boolean (value)); |
4146 | break; |
4147 | default: |
4148 | CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctknotebook.c", 4148, ("child 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); |
4149 | break; |
4150 | } |
4151 | } |
4152 | |
4153 | static void |
4154 | ctk_notebook_get_child_property (CtkContainer *container, |
4155 | CtkWidget *child, |
4156 | guint property_id, |
4157 | GValue *value, |
4158 | GParamSpec *pspec) |
4159 | { |
4160 | CtkNotebook *notebook = CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))); |
4161 | CtkNotebookPrivate *priv = notebook->priv; |
4162 | GList *list; |
4163 | CtkWidget *label; |
4164 | gboolean expand; |
4165 | gboolean fill; |
4166 | |
4167 | /* not finding child's page is valid for menus or labels */ |
4168 | list = ctk_notebook_find_child (notebook, child); |
4169 | if (!list) |
4170 | { |
4171 | /* nothing to set on labels or menus */ |
4172 | g_param_value_set_default (pspec, value); |
4173 | return; |
4174 | } |
4175 | |
4176 | switch (property_id) |
4177 | { |
4178 | case CHILD_PROP_TAB_LABEL: |
4179 | label = ctk_notebook_get_tab_label (notebook, child); |
4180 | |
4181 | if (CTK_IS_LABEL (label)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (label)); GType __t = ((ctk_label_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; }))))) |
4182 | g_value_set_string (value, ctk_label_get_label (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))))); |
4183 | else |
4184 | g_value_set_string (value, NULL((void*)0)); |
4185 | break; |
4186 | case CHILD_PROP_MENU_LABEL: |
4187 | label = ctk_notebook_get_menu_label (notebook, child); |
4188 | |
4189 | if (CTK_IS_LABEL (label)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (label)); GType __t = ((ctk_label_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; }))))) |
4190 | g_value_set_string (value, ctk_label_get_label (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))))); |
4191 | else |
4192 | g_value_set_string (value, NULL((void*)0)); |
4193 | break; |
4194 | case CHILD_PROP_POSITION: |
4195 | g_value_set_int (value, g_list_position (priv->children, list)); |
4196 | break; |
4197 | case CHILD_PROP_TAB_EXPAND: |
4198 | ctk_notebook_query_tab_label_packing (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4199 | &expand, NULL((void*)0)); |
4200 | g_value_set_boolean (value, expand); |
4201 | break; |
4202 | case CHILD_PROP_TAB_FILL: |
4203 | ctk_notebook_query_tab_label_packing (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child, |
4204 | NULL((void*)0), &fill); |
4205 | g_value_set_boolean (value, fill); |
4206 | break; |
4207 | case CHILD_PROP_REORDERABLE: |
4208 | g_value_set_boolean (value, |
4209 | ctk_notebook_get_tab_reorderable (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child)); |
4210 | break; |
4211 | case CHILD_PROP_DETACHABLE: |
4212 | g_value_set_boolean (value, |
4213 | ctk_notebook_get_tab_detachable (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), child)); |
4214 | break; |
4215 | default: |
4216 | CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "ctknotebook.c", 4216, ("child 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); |
4217 | break; |
4218 | } |
4219 | } |
4220 | |
4221 | static void |
4222 | ctk_notebook_add (CtkContainer *container, |
4223 | CtkWidget *widget) |
4224 | { |
4225 | ctk_notebook_insert_page_menu (CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))), widget, |
4226 | NULL((void*)0), NULL((void*)0), -1); |
4227 | } |
4228 | |
4229 | static void |
4230 | ctk_notebook_remove (CtkContainer *container, |
4231 | CtkWidget *widget) |
4232 | { |
4233 | CtkNotebook *notebook = CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))); |
4234 | CtkNotebookPrivate *priv = notebook->priv; |
4235 | CtkNotebookPage *page; |
4236 | GList *children, *list; |
4237 | gint page_num = 0; |
4238 | |
4239 | children = priv->children; |
4240 | while (children) |
4241 | { |
4242 | page = children->data; |
4243 | |
4244 | if (page->child == widget) |
4245 | break; |
4246 | |
4247 | page_num++; |
4248 | children = children->next; |
4249 | } |
4250 | |
4251 | if (children == NULL((void*)0)) |
4252 | return; |
4253 | |
4254 | g_object_ref (widget)((__typeof__ (widget)) (g_object_ref) (widget)); |
4255 | |
4256 | list = children->next; |
4257 | ctk_notebook_real_remove (notebook, children); |
4258 | |
4259 | while (list) |
4260 | { |
4261 | ctk_widget_child_notify (((CtkNotebookPage *)list->data)->child, "position"); |
4262 | list = list->next; |
4263 | } |
4264 | |
4265 | g_signal_emit (notebook, |
4266 | notebook_signals[PAGE_REMOVED], |
4267 | 0, |
4268 | widget, |
4269 | page_num); |
4270 | |
4271 | g_object_unref (widget); |
4272 | } |
4273 | |
4274 | static gboolean |
4275 | focus_tabs_in (CtkNotebook *notebook) |
4276 | { |
4277 | CtkNotebookPrivate *priv = notebook->priv; |
4278 | |
4279 | if (priv->show_tabs && ctk_notebook_has_current_page (notebook)) |
4280 | { |
4281 | ctk_widget_grab_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
4282 | ctk_notebook_set_focus_child (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ())))))), NULL((void*)0)); |
4283 | ctk_notebook_switch_focus_tab (notebook, |
4284 | g_list_find (priv->children, |
4285 | priv->cur_page)); |
4286 | |
4287 | return TRUE(!(0)); |
4288 | } |
4289 | else |
4290 | return FALSE(0); |
4291 | } |
4292 | |
4293 | static gboolean |
4294 | focus_tabs_move (CtkNotebook *notebook, |
4295 | CtkDirectionType direction G_GNUC_UNUSED__attribute__ ((__unused__)), |
4296 | gint search_direction) |
4297 | { |
4298 | CtkNotebookPrivate *priv = notebook->priv; |
4299 | GList *new_page; |
4300 | |
4301 | new_page = ctk_notebook_search_page (notebook, priv->focus_tab, |
4302 | search_direction, TRUE(!(0))); |
4303 | if (!new_page) |
4304 | { |
4305 | new_page = ctk_notebook_search_page (notebook, NULL((void*)0), |
4306 | search_direction, TRUE(!(0))); |
4307 | } |
4308 | |
4309 | if (new_page) |
4310 | ctk_notebook_switch_focus_tab (notebook, new_page); |
4311 | else |
4312 | ctk_widget_error_bell (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
4313 | |
4314 | return TRUE(!(0)); |
4315 | } |
4316 | |
4317 | static gboolean |
4318 | focus_child_in (CtkNotebook *notebook, |
4319 | CtkDirectionType direction) |
4320 | { |
4321 | CtkNotebookPrivate *priv = notebook->priv; |
4322 | |
4323 | if (priv->cur_page) |
4324 | return ctk_widget_child_focus (priv->cur_page->child, direction); |
4325 | else |
4326 | return FALSE(0); |
4327 | } |
4328 | |
4329 | static gboolean |
4330 | focus_action_in (CtkNotebook *notebook, |
4331 | gint action, |
4332 | CtkDirectionType direction) |
4333 | { |
4334 | CtkNotebookPrivate *priv = notebook->priv; |
4335 | |
4336 | if (priv->action_widget[action] && |
4337 | ctk_widget_get_visible (priv->action_widget[action])) |
4338 | return ctk_widget_child_focus (priv->action_widget[action], direction); |
4339 | else |
4340 | return FALSE(0); |
4341 | } |
4342 | |
4343 | /* Focus in the notebook can either be on the pages, or on |
4344 | * the tabs or on the action_widgets. |
4345 | */ |
4346 | static gboolean |
4347 | ctk_notebook_focus (CtkWidget *widget, |
4348 | CtkDirectionType direction) |
4349 | { |
4350 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
4351 | CtkNotebookPrivate *priv = notebook->priv; |
4352 | CtkWidget *old_focus_child; |
4353 | CtkDirectionType effective_direction; |
4354 | gint first_action; |
4355 | gint last_action; |
4356 | |
4357 | gboolean widget_is_focus; |
4358 | CtkContainer *container; |
4359 | |
4360 | container = CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))); |
4361 | |
4362 | if (priv->tab_pos == CTK_POS_TOP || |
4363 | priv->tab_pos == CTK_POS_LEFT) |
4364 | { |
4365 | first_action = ACTION_WIDGET_START; |
4366 | last_action = ACTION_WIDGET_END; |
4367 | } |
4368 | else |
4369 | { |
4370 | first_action = ACTION_WIDGET_END; |
4371 | last_action = ACTION_WIDGET_START; |
4372 | } |
4373 | |
4374 | if (priv->focus_out) |
4375 | { |
4376 | priv->focus_out = FALSE(0); /* Clear this to catch the wrap-around case */ |
4377 | return FALSE(0); |
4378 | } |
4379 | |
4380 | widget_is_focus = ctk_widget_is_focus (widget); |
4381 | old_focus_child = ctk_container_get_focus_child (container); |
4382 | |
4383 | effective_direction = get_effective_direction (notebook, direction); |
4384 | |
4385 | if (old_focus_child) /* Focus on page child or action widget */ |
4386 | { |
4387 | if (ctk_widget_child_focus (old_focus_child, direction)) |
4388 | return TRUE(!(0)); |
4389 | |
4390 | if (old_focus_child == priv->action_widget[ACTION_WIDGET_START]) |
4391 | { |
4392 | switch (effective_direction) |
4393 | { |
4394 | case CTK_DIR_DOWN: |
4395 | return focus_child_in (notebook, CTK_DIR_TAB_FORWARD); |
4396 | case CTK_DIR_RIGHT: |
4397 | return focus_tabs_in (notebook); |
4398 | case CTK_DIR_LEFT: |
4399 | return FALSE(0); |
4400 | case CTK_DIR_UP: |
4401 | return FALSE(0); |
4402 | default: |
4403 | switch (direction) |
4404 | { |
4405 | case CTK_DIR_TAB_FORWARD: |
4406 | if ((priv->tab_pos == CTK_POS_RIGHT || priv->tab_pos == CTK_POS_BOTTOM) && |
4407 | focus_child_in (notebook, direction)) |
4408 | return TRUE(!(0)); |
4409 | return focus_tabs_in (notebook); |
4410 | case CTK_DIR_TAB_BACKWARD: |
4411 | return FALSE(0); |
4412 | default: |
4413 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctknotebook.c", 4413, ( (const char*) (__func__)), ((void*)0)); } while (0); |
4414 | } |
4415 | } |
4416 | } |
4417 | else if (old_focus_child == priv->action_widget[ACTION_WIDGET_END]) |
4418 | { |
4419 | switch (effective_direction) |
4420 | { |
4421 | case CTK_DIR_DOWN: |
4422 | return focus_child_in (notebook, CTK_DIR_TAB_FORWARD); |
4423 | case CTK_DIR_RIGHT: |
4424 | return FALSE(0); |
4425 | case CTK_DIR_LEFT: |
4426 | return focus_tabs_in (notebook); |
4427 | case CTK_DIR_UP: |
4428 | return FALSE(0); |
4429 | default: |
4430 | switch (direction) |
4431 | { |
4432 | case CTK_DIR_TAB_FORWARD: |
4433 | return FALSE(0); |
4434 | case CTK_DIR_TAB_BACKWARD: |
4435 | if ((priv->tab_pos == CTK_POS_TOP || priv->tab_pos == CTK_POS_LEFT) && |
4436 | focus_child_in (notebook, direction)) |
4437 | return TRUE(!(0)); |
4438 | return focus_tabs_in (notebook); |
4439 | default: |
4440 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctknotebook.c", 4440, ( (const char*) (__func__)), ((void*)0)); } while (0); |
4441 | } |
4442 | } |
4443 | } |
4444 | else |
4445 | { |
4446 | switch (effective_direction) |
4447 | { |
4448 | case CTK_DIR_TAB_BACKWARD: |
4449 | case CTK_DIR_UP: |
4450 | /* Focus onto the tabs */ |
4451 | return focus_tabs_in (notebook); |
4452 | case CTK_DIR_DOWN: |
4453 | case CTK_DIR_LEFT: |
4454 | case CTK_DIR_RIGHT: |
4455 | return FALSE(0); |
4456 | case CTK_DIR_TAB_FORWARD: |
4457 | return focus_action_in (notebook, last_action, direction); |
4458 | } |
4459 | } |
4460 | } |
4461 | else if (widget_is_focus) /* Focus was on tabs */ |
4462 | { |
4463 | switch (effective_direction) |
4464 | { |
4465 | case CTK_DIR_TAB_BACKWARD: |
4466 | return focus_action_in (notebook, first_action, direction); |
4467 | case CTK_DIR_UP: |
4468 | return FALSE(0); |
4469 | case CTK_DIR_TAB_FORWARD: |
4470 | if (focus_child_in (notebook, CTK_DIR_TAB_FORWARD)) |
4471 | return TRUE(!(0)); |
4472 | return focus_action_in (notebook, last_action, direction); |
4473 | case CTK_DIR_DOWN: |
4474 | /* We use TAB_FORWARD rather than direction so that we focus a more |
4475 | * predictable widget for the user; users may be using arrow focusing |
4476 | * in this situation even if they don't usually use arrow focusing. |
4477 | */ |
4478 | return focus_child_in (notebook, CTK_DIR_TAB_FORWARD); |
4479 | case CTK_DIR_LEFT: |
4480 | return focus_tabs_move (notebook, direction, STEP_PREV); |
4481 | case CTK_DIR_RIGHT: |
4482 | return focus_tabs_move (notebook, direction, STEP_NEXT); |
4483 | } |
4484 | } |
4485 | else /* Focus was not on widget */ |
4486 | { |
4487 | switch (effective_direction) |
4488 | { |
4489 | case CTK_DIR_TAB_FORWARD: |
4490 | case CTK_DIR_DOWN: |
4491 | if (focus_action_in (notebook, first_action, direction)) |
4492 | return TRUE(!(0)); |
4493 | if (focus_tabs_in (notebook)) |
4494 | return TRUE(!(0)); |
4495 | if (focus_action_in (notebook, last_action, direction)) |
4496 | return TRUE(!(0)); |
4497 | if (focus_child_in (notebook, direction)) |
4498 | return TRUE(!(0)); |
4499 | return FALSE(0); |
4500 | case CTK_DIR_TAB_BACKWARD: |
4501 | if (focus_action_in (notebook, last_action, direction)) |
4502 | return TRUE(!(0)); |
4503 | if (focus_child_in (notebook, direction)) |
4504 | return TRUE(!(0)); |
4505 | if (focus_tabs_in (notebook)) |
4506 | return TRUE(!(0)); |
4507 | if (focus_action_in (notebook, first_action, direction)) |
4508 | return TRUE(!(0)); |
4509 | case CTK_DIR_UP: |
4510 | case CTK_DIR_LEFT: |
4511 | case CTK_DIR_RIGHT: |
4512 | return focus_child_in (notebook, direction); |
4513 | } |
4514 | } |
4515 | |
4516 | g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctknotebook.c", 4516, ( (const char*) (__func__)), ((void*)0)); } while (0); |
4517 | return FALSE(0); |
4518 | } |
4519 | |
4520 | static void |
4521 | ctk_notebook_set_focus_child (CtkContainer *container, |
4522 | CtkWidget *child) |
4523 | { |
4524 | CtkNotebook *notebook = CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))); |
4525 | CtkNotebookPrivate *priv = notebook->priv; |
4526 | CtkWidget *page_child; |
4527 | CtkWidget *toplevel; |
4528 | |
4529 | /* If the old focus widget was within a page of the notebook, |
4530 | * (child may either be NULL or not in this case), record it |
4531 | * for future use if we switch to the page with a mnemonic. |
4532 | */ |
4533 | |
4534 | toplevel = ctk_widget_get_toplevel (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ()))))))); |
4535 | if (toplevel && ctk_widget_is_toplevel (toplevel)) |
4536 | { |
4537 | page_child = ctk_window_get_focus (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_window_get_type ()))))))); |
4538 | while (page_child) |
4539 | { |
4540 | if (ctk_widget_get_parent (page_child) == CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_widget_get_type ()))))))) |
4541 | { |
4542 | GList *list = ctk_notebook_find_child (notebook, page_child); |
4543 | if (list != NULL((void*)0)) |
4544 | { |
4545 | CtkNotebookPage *page = list->data; |
4546 | |
4547 | if (page->last_focus_child) |
4548 | g_object_remove_weak_pointer (G_OBJECT (page->last_focus_child)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->last_focus_child)), (((GType) ((20) << (2 )))))))), (gpointer *)&page->last_focus_child); |
4549 | |
4550 | page->last_focus_child = ctk_window_get_focus (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_window_get_type ()))))))); |
4551 | g_object_add_weak_pointer (G_OBJECT (page->last_focus_child)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->last_focus_child)), (((GType) ((20) << (2 )))))))), (gpointer *)&page->last_focus_child); |
4552 | |
4553 | break; |
4554 | } |
4555 | } |
4556 | |
4557 | page_child = ctk_widget_get_parent (page_child); |
4558 | } |
4559 | } |
4560 | |
4561 | if (child) |
4562 | { |
4563 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
4564 | |
4565 | priv->child_has_focus = TRUE(!(0)); |
4566 | if (!priv->focus_tab) |
4567 | { |
4568 | GList *children; |
4569 | CtkNotebookPage *page; |
4570 | |
4571 | children = priv->children; |
4572 | while (children) |
4573 | { |
4574 | page = children->data; |
4575 | if (page->child == child || page->tab_label == child) |
4576 | ctk_notebook_switch_focus_tab (notebook, children); |
4577 | children = children->next; |
4578 | } |
4579 | } |
4580 | } |
4581 | else |
4582 | priv->child_has_focus = FALSE(0); |
4583 | |
4584 | CTK_CONTAINER_CLASS (ctk_notebook_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_notebook_parent_class)), ((ctk_container_get_type () ))))))->set_focus_child (container, child); |
4585 | } |
4586 | |
4587 | static void |
4588 | ctk_notebook_forall (CtkContainer *container, |
4589 | gboolean include_internals, |
4590 | CtkCallback callback, |
4591 | gpointer callback_data) |
4592 | { |
4593 | CtkNotebook *notebook = CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))); |
4594 | CtkNotebookPrivate *priv = notebook->priv; |
4595 | GList *children; |
4596 | gint i; |
4597 | |
4598 | children = priv->children; |
4599 | while (children) |
4600 | { |
4601 | CtkNotebookPage *page; |
4602 | |
4603 | page = children->data; |
4604 | children = children->next; |
4605 | (* callback) (page->child, callback_data); |
4606 | |
4607 | if (include_internals) |
4608 | { |
4609 | if (page->tab_label) |
4610 | (* callback) (page->tab_label, callback_data); |
4611 | } |
4612 | } |
4613 | |
4614 | if (include_internals) |
4615 | { |
4616 | for (i = 0; i < N_ACTION_WIDGETS; i++) |
4617 | { |
4618 | if (priv->action_widget[i]) |
4619 | (* callback) (priv->action_widget[i], callback_data); |
4620 | } |
4621 | } |
4622 | } |
4623 | |
4624 | static GType |
4625 | ctk_notebook_child_type (CtkContainer *container G_GNUC_UNUSED__attribute__ ((__unused__))) |
4626 | { |
4627 | return CTK_TYPE_WIDGET(ctk_widget_get_type ()); |
4628 | } |
4629 | |
4630 | /* Private CtkNotebook Methods: |
4631 | * |
4632 | * ctk_notebook_real_insert_page |
4633 | */ |
4634 | static void |
4635 | page_visible_cb (CtkWidget *child, |
4636 | GParamSpec *arg G_GNUC_UNUSED__attribute__ ((__unused__)), |
4637 | gpointer data) |
4638 | { |
4639 | CtkNotebook *notebook = CTK_NOTEBOOK (data)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_notebook_get_type ())))))); |
4640 | CtkNotebookPrivate *priv = notebook->priv; |
4641 | GList *list = ctk_notebook_find_child (notebook, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ()))))))); |
4642 | CtkNotebookPage *page = list->data; |
4643 | GList *next = NULL((void*)0); |
4644 | |
4645 | if (priv->menu && page->menu_label) |
4646 | { |
4647 | CtkWidget *parent = ctk_widget_get_parent (page->menu_label); |
4648 | if (parent) |
4649 | ctk_widget_set_visible (parent, ctk_widget_get_visible (child)); |
4650 | } |
4651 | |
4652 | if (priv->cur_page == page) |
4653 | { |
4654 | if (!ctk_widget_get_visible (child)) |
4655 | { |
4656 | list = g_list_find (priv->children, priv->cur_page); |
4657 | if (list) |
4658 | { |
4659 | next = ctk_notebook_search_page (notebook, list, STEP_NEXT, TRUE(!(0))); |
4660 | if (!next) |
4661 | next = ctk_notebook_search_page (notebook, list, STEP_PREV, TRUE(!(0))); |
4662 | } |
4663 | |
4664 | if (next) |
4665 | ctk_notebook_switch_page (notebook, CTK_NOTEBOOK_PAGE (next)((CtkNotebookPage *)(next)->data)); |
4666 | } |
4667 | ctk_css_gadget_set_visible (priv->header_gadget, priv->show_tabs && ctk_notebook_has_current_page (notebook)); |
4668 | } |
4669 | |
4670 | if (!ctk_notebook_has_current_page (notebook) && ctk_widget_get_visible (child)) |
4671 | { |
4672 | ctk_notebook_switch_page (notebook, page); |
4673 | /* focus_tab is set in the switch_page method */ |
4674 | ctk_notebook_switch_focus_tab (notebook, priv->focus_tab); |
4675 | } |
4676 | } |
4677 | |
4678 | static void |
4679 | measure_tab (CtkCssGadget *gadget G_GNUC_UNUSED__attribute__ ((__unused__)), |
4680 | CtkOrientation orientation, |
4681 | gint for_size, |
4682 | gint *minimum, |
4683 | gint *natural, |
4684 | gint *minimum_baseline, |
4685 | gint *natural_baseline, |
4686 | gpointer data) |
4687 | { |
4688 | CtkNotebookPage *page = data; |
4689 | |
4690 | _ctk_widget_get_preferred_size_for_size (page->tab_label, |
4691 | orientation, |
4692 | for_size, |
4693 | minimum, natural, |
4694 | minimum_baseline, natural_baseline); |
4695 | } |
4696 | |
4697 | static void |
4698 | allocate_tab (CtkCssGadget *gadget, |
4699 | const CtkAllocation *allocation, |
4700 | int baseline, |
4701 | CtkAllocation *out_clip, |
4702 | gpointer data) |
4703 | { |
4704 | CtkNotebook *notebook = CTK_NOTEBOOK (ctk_css_gadget_get_owner (gadget))((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_css_gadget_get_owner (gadget))), ((ctk_notebook_get_type ())))))); |
4705 | CtkNotebookPrivate *priv = notebook->priv; |
4706 | CtkNotebookPage *page = data; |
4707 | CtkAllocation child_allocation; |
4708 | |
4709 | child_allocation = *allocation; |
4710 | |
4711 | if (page == priv->cur_page && priv->operation == DRAG_OPERATION_REORDER) |
4712 | { |
4713 | /* needs to be allocated for the drag window */ |
4714 | child_allocation.x -= priv->drag_window_x; |
4715 | child_allocation.y -= priv->drag_window_y; |
4716 | } |
4717 | |
4718 | if (!page->fill) |
4719 | { |
4720 | if (priv->tab_pos == CTK_POS_TOP || priv->tab_pos == CTK_POS_BOTTOM) |
4721 | { |
4722 | ctk_widget_get_preferred_width_for_height (page->tab_label, |
4723 | allocation->height, |
4724 | NULL((void*)0), |
4725 | &child_allocation.width); |
4726 | if (child_allocation.width > allocation->width) |
4727 | child_allocation.width = allocation->width; |
4728 | else |
4729 | child_allocation.x += (allocation->width - child_allocation.width) / 2; |
4730 | |
4731 | } |
4732 | else |
4733 | { |
4734 | ctk_widget_get_preferred_height_for_width (page->tab_label, |
4735 | allocation->width, |
4736 | NULL((void*)0), |
4737 | &child_allocation.height); |
4738 | if (child_allocation.height > allocation->height) |
4739 | child_allocation.height = allocation->height; |
4740 | else |
4741 | child_allocation.y += (allocation->height - child_allocation.height) / 2; |
4742 | } |
4743 | } |
4744 | |
4745 | ctk_widget_size_allocate_with_baseline (page->tab_label, |
4746 | &child_allocation, |
4747 | baseline); |
4748 | |
4749 | ctk_widget_get_clip (page->tab_label, out_clip); |
4750 | } |
4751 | |
4752 | static gboolean |
4753 | draw_tab (CtkCssGadget *gadget, |
4754 | cairo_t *cr, |
4755 | int x G_GNUC_UNUSED__attribute__ ((__unused__)), |
4756 | int y G_GNUC_UNUSED__attribute__ ((__unused__)), |
4757 | int width G_GNUC_UNUSED__attribute__ ((__unused__)), |
4758 | int height G_GNUC_UNUSED__attribute__ ((__unused__)), |
4759 | gpointer data) |
4760 | { |
4761 | CtkNotebookPage *page = data; |
4762 | CtkWidget *widget; |
4763 | |
4764 | widget = ctk_css_gadget_get_owner (gadget); |
4765 | |
4766 | ctk_container_propagate_draw (CTK_CONTAINER (widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_container_get_type ())))))), |
4767 | page->tab_label, |
4768 | cr); |
4769 | |
4770 | return ctk_widget_has_visible_focus (widget) && |
4771 | CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ()))))))->priv->cur_page == page; |
4772 | } |
4773 | |
4774 | static gint |
4775 | ctk_notebook_real_insert_page (CtkNotebook *notebook, |
4776 | CtkWidget *child, |
4777 | CtkWidget *tab_label, |
4778 | CtkWidget *menu_label, |
4779 | gint position) |
4780 | { |
4781 | CtkNotebookPrivate *priv = notebook->priv; |
4782 | CtkNotebookPage *page; |
4783 | gint nchildren; |
4784 | GList *list; |
4785 | CtkCssGadget *sibling; |
4786 | |
4787 | ctk_widget_freeze_child_notify (child); |
4788 | |
4789 | page = g_slice_new0 (CtkNotebookPage)((CtkNotebookPage*) g_slice_alloc0 (sizeof (CtkNotebookPage)) ); |
4790 | page->child = child; |
4791 | |
4792 | nchildren = g_list_length (priv->children); |
4793 | if ((position < 0) || (position > nchildren)) |
4794 | position = nchildren; |
4795 | |
4796 | priv->children = g_list_insert (priv->children, page, position); |
4797 | |
4798 | if (position < nchildren) |
4799 | sibling = CTK_NOTEBOOK_PAGE (g_list_nth (priv->children, position))((CtkNotebookPage *)(g_list_nth (priv->children, position) )->data)->gadget; |
4800 | else if (priv->arrow_gadget[ARROW_LEFT_AFTER]) |
4801 | sibling = priv->arrow_gadget[ARROW_LEFT_AFTER]; |
4802 | else |
4803 | sibling = priv->arrow_gadget[ARROW_RIGHT_AFTER]; |
4804 | |
4805 | if (priv->tabs_reversed) |
4806 | ctk_css_node_reverse_children (ctk_css_gadget_get_node (priv->tabs_gadget)); |
4807 | |
4808 | page->gadget = ctk_css_custom_gadget_new ("tab", |
4809 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), |
4810 | priv->tabs_gadget, |
4811 | sibling, |
4812 | measure_tab, |
4813 | allocate_tab, |
4814 | draw_tab, |
4815 | page, |
4816 | NULL((void*)0)); |
4817 | if (priv->tabs_reversed) |
4818 | ctk_css_node_reverse_children (ctk_css_gadget_get_node (priv->tabs_gadget)); |
4819 | |
4820 | ctk_css_gadget_set_state (page->gadget, ctk_css_node_get_state (ctk_css_gadget_get_node (priv->tabs_gadget))); |
4821 | |
4822 | if (!tab_label) |
4823 | page->default_tab = TRUE(!(0)); |
4824 | |
4825 | page->tab_label = tab_label; |
4826 | page->menu_label = menu_label; |
4827 | page->expand = FALSE(0); |
4828 | page->fill = TRUE(!(0)); |
4829 | |
4830 | if (!menu_label) |
4831 | page->default_menu = TRUE(!(0)); |
4832 | else |
4833 | g_object_ref_sink (page->menu_label)((__typeof__ (page->menu_label)) (g_object_ref_sink) (page ->menu_label)); |
4834 | |
4835 | if (priv->menu) |
4836 | ctk_notebook_menu_item_create (notebook, |
4837 | g_list_find (priv->children, page)); |
4838 | |
4839 | /* child visible will be turned on by switch_page below */ |
4840 | ctk_widget_set_child_visible (child, FALSE(0)); |
4841 | |
4842 | ctk_css_node_set_parent (ctk_widget_get_css_node (child), ctk_css_gadget_get_node (priv->stack_gadget)); |
4843 | ctk_widget_set_parent (child, CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
4844 | if (tab_label) |
4845 | { |
4846 | ctk_css_node_set_parent (ctk_widget_get_css_node (tab_label), |
4847 | ctk_css_gadget_get_node (page->gadget)); |
4848 | ctk_widget_set_parent (tab_label, CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
4849 | } |
4850 | |
4851 | ctk_notebook_update_labels (notebook); |
4852 | |
4853 | if (!priv->first_tab) |
4854 | priv->first_tab = priv->children; |
4855 | |
4856 | if (tab_label) |
4857 | { |
4858 | if (priv->show_tabs && ctk_widget_get_visible (child)) |
4859 | ctk_widget_show (tab_label); |
4860 | else |
4861 | ctk_widget_hide (tab_label); |
4862 | |
4863 | page->mnemonic_activate_signal = |
4864 | g_signal_connect (tab_label,g_signal_connect_data ((tab_label), ("mnemonic-activate"), (( (GCallback) (ctk_notebook_mnemonic_activate_switch_page))), ( notebook), ((void*)0), (GConnectFlags) 0) |
4865 | "mnemonic-activate",g_signal_connect_data ((tab_label), ("mnemonic-activate"), (( (GCallback) (ctk_notebook_mnemonic_activate_switch_page))), ( notebook), ((void*)0), (GConnectFlags) 0) |
4866 | G_CALLBACK (ctk_notebook_mnemonic_activate_switch_page),g_signal_connect_data ((tab_label), ("mnemonic-activate"), (( (GCallback) (ctk_notebook_mnemonic_activate_switch_page))), ( notebook), ((void*)0), (GConnectFlags) 0) |
4867 | notebook)g_signal_connect_data ((tab_label), ("mnemonic-activate"), (( (GCallback) (ctk_notebook_mnemonic_activate_switch_page))), ( notebook), ((void*)0), (GConnectFlags) 0); |
4868 | } |
4869 | |
4870 | page->notify_visible_handler = g_signal_connect (child, "notify::visible",g_signal_connect_data ((child), ("notify::visible"), (((GCallback ) (page_visible_cb))), (notebook), ((void*)0), (GConnectFlags ) 0) |
4871 | G_CALLBACK (page_visible_cb), notebook)g_signal_connect_data ((child), ("notify::visible"), (((GCallback ) (page_visible_cb))), (notebook), ((void*)0), (GConnectFlags ) 0); |
4872 | |
4873 | g_signal_emit (notebook, |
4874 | notebook_signals[PAGE_ADDED], |
4875 | 0, |
4876 | child, |
4877 | position); |
4878 | |
4879 | if (!ctk_notebook_has_current_page (notebook)) |
4880 | { |
4881 | ctk_notebook_switch_page (notebook, page); |
4882 | /* focus_tab is set in the switch_page method */ |
4883 | ctk_notebook_switch_focus_tab (notebook, priv->focus_tab); |
4884 | } |
4885 | |
4886 | if (priv->scrollable) |
4887 | ctk_notebook_redraw_arrows (notebook); |
4888 | |
4889 | ctk_widget_child_notify (child, "tab-expand"); |
4890 | ctk_widget_child_notify (child, "tab-fill"); |
4891 | ctk_widget_child_notify (child, "tab-label"); |
4892 | ctk_widget_child_notify (child, "menu-label"); |
4893 | |
4894 | list = g_list_nth (priv->children, position); |
4895 | while (list) |
4896 | { |
4897 | ctk_widget_child_notify (((CtkNotebookPage *)list->data)->child, "position"); |
4898 | list = list->next; |
4899 | } |
4900 | |
4901 | ctk_widget_thaw_child_notify (child); |
4902 | |
4903 | /* The page-added handler might have reordered the pages, re-get the position */ |
4904 | return ctk_notebook_page_num (notebook, child); |
4905 | } |
4906 | |
4907 | /* Private CtkNotebook Functions: |
4908 | * |
4909 | * ctk_notebook_real_remove |
4910 | * ctk_notebook_update_labels |
4911 | * ctk_notebook_timer |
4912 | * ctk_notebook_set_scroll_timer |
4913 | * ctk_notebook_page_compare |
4914 | * ctk_notebook_search_page |
4915 | */ |
4916 | static void |
4917 | ctk_notebook_redraw_arrows (CtkNotebook *notebook) |
4918 | { |
4919 | CtkNotebookPrivate *priv = notebook->priv; |
4920 | |
4921 | update_arrow_state (notebook); |
4922 | |
4923 | if (ctk_widget_get_mapped (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) && |
4924 | ctk_notebook_show_arrows (notebook)) |
4925 | { |
4926 | CdkRectangle rect; |
4927 | gint i; |
4928 | |
4929 | for (i = 0; i < 4; i++) |
4930 | { |
4931 | if (priv->arrow_gadget[i] == NULL((void*)0)) |
4932 | continue; |
4933 | |
4934 | ctk_notebook_get_arrow_rect (notebook, &rect, i); |
4935 | cdk_window_invalidate_rect (ctk_widget_get_window (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))), |
4936 | &rect, FALSE(0)); |
4937 | } |
4938 | } |
4939 | } |
4940 | |
4941 | static gboolean |
4942 | ctk_notebook_timer (CtkNotebook *notebook) |
4943 | { |
4944 | CtkNotebookPrivate *priv = notebook->priv; |
4945 | gboolean retval = FALSE(0); |
4946 | |
4947 | if (priv->timer) |
4948 | { |
4949 | ctk_notebook_do_arrow (notebook, priv->click_child); |
4950 | |
4951 | if (priv->need_timer) |
4952 | { |
4953 | priv->need_timer = FALSE(0); |
4954 | priv->timer = cdk_threads_add_timeout (TIMEOUT_REPEAT50 * SCROLL_DELAY_FACTOR5, |
4955 | (GSourceFunc) ctk_notebook_timer, |
4956 | (gpointer) notebook); |
4957 | g_source_set_name_by_id (priv->timer, "[ctk+] ctk_notebook_timer"); |
4958 | } |
4959 | else |
4960 | retval = TRUE(!(0)); |
4961 | } |
4962 | |
4963 | return retval; |
4964 | } |
4965 | |
4966 | static void |
4967 | ctk_notebook_set_scroll_timer (CtkNotebook *notebook) |
4968 | { |
4969 | CtkNotebookPrivate *priv = notebook->priv; |
4970 | |
4971 | if (!priv->timer) |
4972 | { |
4973 | priv->timer = cdk_threads_add_timeout (TIMEOUT_INITIAL500, |
4974 | (GSourceFunc) ctk_notebook_timer, |
4975 | (gpointer) notebook); |
4976 | g_source_set_name_by_id (priv->timer, "[ctk+] ctk_notebook_timer"); |
4977 | priv->need_timer = TRUE(!(0)); |
4978 | } |
4979 | } |
4980 | |
4981 | static gint |
4982 | ctk_notebook_page_compare (gconstpointer a, |
4983 | gconstpointer b) |
4984 | { |
4985 | return (((CtkNotebookPage *) a)->child != b); |
4986 | } |
4987 | |
4988 | static GList* |
4989 | ctk_notebook_find_child (CtkNotebook *notebook, |
4990 | CtkWidget *child) |
4991 | { |
4992 | return g_list_find_custom (notebook->priv->children, |
4993 | child, |
4994 | ctk_notebook_page_compare); |
4995 | } |
4996 | |
4997 | static void |
4998 | ctk_notebook_remove_tab_label (CtkNotebook *notebook, |
4999 | CtkNotebookPage *page) |
5000 | { |
5001 | if (page->tab_label) |
5002 | { |
5003 | if (page->mnemonic_activate_signal) |
5004 | g_signal_handler_disconnect (page->tab_label, |
5005 | page->mnemonic_activate_signal); |
5006 | page->mnemonic_activate_signal = 0; |
5007 | |
5008 | if (ctk_widget_get_window (page->tab_label) != ctk_widget_get_window (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))) || |
5009 | !NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ()))))))))) |
5010 | { |
5011 | CtkWidget *parent; |
5012 | |
5013 | /* we hit this condition during dnd of a detached tab */ |
5014 | parent = ctk_widget_get_parent (page->tab_label); |
5015 | if (CTK_IS_WINDOW (parent)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (parent)); GType __t = ((ctk_window_get_type ())); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) |
5016 | ctk_container_remove (CTK_CONTAINER (parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_container_get_type ())))))), page->tab_label); |
5017 | else |
5018 | ctk_widget_unparent (page->tab_label); |
5019 | } |
5020 | else |
5021 | { |
5022 | ctk_widget_unparent (page->tab_label); |
5023 | } |
5024 | |
5025 | page->tab_label = NULL((void*)0); |
5026 | } |
5027 | } |
5028 | |
5029 | static void |
5030 | ctk_notebook_real_remove (CtkNotebook *notebook, |
5031 | GList *list) |
5032 | { |
5033 | CtkNotebookPrivate *priv = notebook->priv; |
5034 | CtkNotebookPage *page; |
5035 | GList * next_list; |
5036 | gint need_resize = FALSE(0); |
5037 | CtkWidget *tab_label; |
5038 | gboolean destroying; |
5039 | |
5040 | destroying = ctk_widget_in_destruction (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
5041 | |
5042 | next_list = ctk_notebook_search_page (notebook, list, STEP_NEXT, TRUE(!(0))); |
5043 | if (!next_list) |
5044 | next_list = ctk_notebook_search_page (notebook, list, STEP_PREV, TRUE(!(0))); |
5045 | |
5046 | priv->children = g_list_remove_link (priv->children, list); |
5047 | |
5048 | if (priv->cur_page == list->data) |
5049 | { |
5050 | priv->cur_page = NULL((void*)0); |
5051 | if (next_list && !destroying) |
5052 | ctk_notebook_switch_page (notebook, CTK_NOTEBOOK_PAGE (next_list)((CtkNotebookPage *)(next_list)->data)); |
5053 | if (priv->operation == DRAG_OPERATION_REORDER && !priv->remove_in_detach) |
5054 | ctk_notebook_stop_reorder (notebook); |
5055 | } |
5056 | |
5057 | if (priv->detached_tab == list->data) |
5058 | { |
5059 | priv->detached_tab = NULL((void*)0); |
5060 | |
5061 | if (priv->operation == DRAG_OPERATION_DETACH && !priv->remove_in_detach) |
5062 | { |
5063 | CdkDragContext *context; |
5064 | |
5065 | context = (CdkDragContext *)g_object_get_data (G_OBJECT (priv->dnd_window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dnd_window)), (((GType) ((20) << (2)))))) )), "drag-context"); |
5066 | ctk_drag_cancel (context); |
5067 | } |
5068 | } |
5069 | if (priv->prelight_tab == list->data) |
5070 | update_prelight_tab (notebook, NULL((void*)0)); |
5071 | if (priv->switch_tab == list) |
5072 | priv->switch_tab = NULL((void*)0); |
5073 | |
5074 | if (list == priv->first_tab) |
5075 | priv->first_tab = next_list; |
5076 | if (list == priv->focus_tab && !destroying) |
5077 | ctk_notebook_switch_focus_tab (notebook, next_list); |
5078 | |
5079 | page = list->data; |
5080 | |
5081 | g_signal_handler_disconnect (page->child, page->notify_visible_handler); |
5082 | |
5083 | if (ctk_widget_get_visible (page->child) && |
5084 | ctk_widget_get_visible (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))))) |
5085 | need_resize = TRUE(!(0)); |
5086 | |
5087 | ctk_widget_unparent (page->child); |
5088 | |
5089 | tab_label = page->tab_label; |
5090 | if (tab_label) |
5091 | { |
5092 | g_object_ref (tab_label)((__typeof__ (tab_label)) (g_object_ref) (tab_label)); |
5093 | ctk_notebook_remove_tab_label (notebook, page); |
5094 | if (destroying) |
5095 | ctk_widget_destroy (tab_label); |
5096 | g_object_unref (tab_label); |
5097 | } |
5098 | |
5099 | if (priv->menu) |
5100 | { |
5101 | CtkWidget *parent = ctk_widget_get_parent (page->menu_label); |
5102 | |
5103 | ctk_notebook_menu_label_unparent (parent, NULL((void*)0)); |
5104 | ctk_container_remove (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_container_get_type ())))))), parent); |
5105 | |
5106 | ctk_widget_queue_resize (priv->menu); |
5107 | } |
5108 | if (!page->default_menu) |
5109 | g_object_unref (page->menu_label); |
5110 | |
5111 | g_list_free (list); |
5112 | |
5113 | if (page->last_focus_child) |
5114 | { |
5115 | g_object_remove_weak_pointer (G_OBJECT (page->last_focus_child)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->last_focus_child)), (((GType) ((20) << (2 )))))))), (gpointer *)&page->last_focus_child); |
5116 | page->last_focus_child = NULL((void*)0); |
5117 | } |
5118 | |
5119 | ctk_css_node_set_parent (ctk_css_gadget_get_node (page->gadget), NULL((void*)0)); |
5120 | g_object_unref (page->gadget); |
5121 | |
5122 | g_slice_free (CtkNotebookPage, page)do { if (1) g_slice_free1 (sizeof (CtkNotebookPage), (page)); else (void) ((CtkNotebookPage*) 0 == (page)); } while (0); |
5123 | |
5124 | ctk_notebook_update_labels (notebook); |
5125 | if (need_resize) |
5126 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
5127 | if (!destroying && priv->scrollable) |
5128 | ctk_notebook_redraw_arrows (notebook); |
5129 | } |
5130 | |
5131 | static void |
5132 | ctk_notebook_update_labels (CtkNotebook *notebook) |
5133 | { |
5134 | CtkNotebookPrivate *priv = notebook->priv; |
5135 | CtkNotebookPage *page; |
5136 | GList *list; |
5137 | gchar string[32]; |
5138 | gint page_num = 1; |
5139 | |
5140 | if (!priv->show_tabs && !priv->menu) |
5141 | return; |
5142 | |
5143 | for (list = ctk_notebook_search_page (notebook, NULL((void*)0), STEP_NEXT, FALSE(0)); |
5144 | list; |
5145 | list = ctk_notebook_search_page (notebook, list, STEP_NEXT, FALSE(0))) |
5146 | { |
5147 | page = list->data; |
5148 | g_snprintf (string, sizeof(string), _("Page %u")((char *) g_dgettext ("ctk30", "Page %u")), page_num++); |
5149 | if (priv->show_tabs) |
5150 | { |
5151 | if (page->default_tab) |
5152 | { |
5153 | if (!page->tab_label) |
5154 | { |
5155 | page->tab_label = ctk_label_new (string); |
5156 | ctk_css_node_set_parent (ctk_widget_get_css_node (page->tab_label), |
5157 | ctk_css_gadget_get_node (page->gadget)); |
5158 | ctk_widget_set_parent (page->tab_label, |
5159 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
5160 | } |
5161 | else |
5162 | ctk_label_set_text (CTK_LABEL (page->tab_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->tab_label)), ((ctk_label_get_type ())))))), string); |
5163 | } |
5164 | |
5165 | if (ctk_widget_get_visible (page->child) && |
5166 | !ctk_widget_get_visible (page->tab_label)) |
5167 | ctk_widget_show (page->tab_label); |
5168 | else if (!ctk_widget_get_visible (page->child) && |
5169 | ctk_widget_get_visible (page->tab_label)) |
5170 | ctk_widget_hide (page->tab_label); |
5171 | } |
5172 | if (priv->menu && page->default_menu) |
5173 | { |
5174 | if (CTK_IS_LABEL (page->tab_label)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (page->tab_label)); GType __t = ((ctk_label_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; } ))))) |
5175 | ctk_label_set_text (CTK_LABEL (page->menu_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->menu_label)), ((ctk_label_get_type ())))))), |
5176 | ctk_label_get_text (CTK_LABEL (page->tab_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->tab_label)), ((ctk_label_get_type ())))))))); |
5177 | else |
5178 | ctk_label_set_text (CTK_LABEL (page->menu_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->menu_label)), ((ctk_label_get_type ())))))), string); |
5179 | } |
5180 | } |
5181 | } |
5182 | |
5183 | static GList * |
5184 | ctk_notebook_search_page (CtkNotebook *notebook, |
5185 | GList *list, |
5186 | gint direction, |
5187 | gboolean find_visible) |
5188 | { |
5189 | CtkNotebookPrivate *priv = notebook->priv; |
5190 | CtkNotebookPage *page = NULL((void*)0); |
5191 | GList *old_list = NULL((void*)0); |
5192 | |
5193 | if (list) |
5194 | page = list->data; |
5195 | |
5196 | if (!page || direction == STEP_NEXT) |
5197 | { |
5198 | if (list) |
5199 | { |
5200 | old_list = list; |
5201 | list = list->next; |
5202 | } |
5203 | else |
5204 | list = priv->children; |
5205 | |
5206 | while (list) |
5207 | { |
5208 | page = list->data; |
5209 | if (direction == STEP_NEXT && |
5210 | (!find_visible || |
5211 | (ctk_widget_get_visible (page->child) && |
5212 | (!page->tab_label || NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))))))) |
5213 | return list; |
5214 | old_list = list; |
5215 | list = list->next; |
5216 | } |
5217 | list = old_list; |
5218 | } |
5219 | else |
5220 | { |
5221 | list = list->prev; |
5222 | } |
5223 | while (list) |
5224 | { |
5225 | page = list->data; |
5226 | if (direction == STEP_PREV && |
5227 | (!find_visible || |
5228 | (ctk_widget_get_visible (page->child) && |
5229 | (!page->tab_label || NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))))))) |
5230 | return list; |
5231 | list = list->prev; |
5232 | } |
5233 | return NULL((void*)0); |
5234 | } |
5235 | |
5236 | static gboolean |
5237 | ctk_notebook_draw_tabs (CtkCssGadget *gadget, |
5238 | cairo_t *cr, |
5239 | int x G_GNUC_UNUSED__attribute__ ((__unused__)), |
5240 | int y G_GNUC_UNUSED__attribute__ ((__unused__)), |
5241 | int width G_GNUC_UNUSED__attribute__ ((__unused__)), |
5242 | int height G_GNUC_UNUSED__attribute__ ((__unused__)), |
5243 | gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__))) |
5244 | { |
5245 | CtkWidget *widget = ctk_css_gadget_get_owner (gadget); |
5246 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
5247 | CtkNotebookPrivate *priv = notebook->priv; |
5248 | CtkNotebookPage *page; |
5249 | GList *children; |
5250 | gboolean showarrow; |
5251 | gint step = STEP_PREV; |
5252 | gboolean is_rtl; |
5253 | CtkPositionType tab_pos; |
5254 | guint i; |
5255 | |
5256 | is_rtl = ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL; |
5257 | tab_pos = get_effective_tab_pos (notebook); |
5258 | showarrow = FALSE(0); |
5259 | |
5260 | if (!ctk_notebook_has_current_page (notebook)) |
5261 | return FALSE(0); |
5262 | |
5263 | if (!priv->first_tab) |
5264 | priv->first_tab = priv->children; |
5265 | |
5266 | if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, priv->cur_page)(ctk_widget_get_parent ((priv->cur_page)->tab_label) == (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))))) || |
5267 | !ctk_widget_get_mapped (priv->cur_page->tab_label)) |
5268 | { |
5269 | step = STEP_PREV; |
5270 | } |
5271 | else |
5272 | { |
5273 | switch (tab_pos) |
5274 | { |
5275 | case CTK_POS_TOP: |
5276 | case CTK_POS_BOTTOM: |
5277 | step = is_rtl ? STEP_PREV : STEP_NEXT; |
5278 | break; |
5279 | case CTK_POS_LEFT: |
5280 | case CTK_POS_RIGHT: |
5281 | step = STEP_PREV; |
5282 | break; |
5283 | } |
5284 | } |
5285 | |
5286 | for (children = priv->children; children; children = children->next) |
5287 | { |
5288 | page = children->data; |
5289 | |
5290 | if (!ctk_widget_get_visible (page->child)) |
5291 | continue; |
5292 | |
5293 | if (!ctk_widget_get_mapped (page->tab_label)) |
5294 | showarrow = TRUE(!(0)); |
5295 | |
5296 | /* No point in keeping searching */ |
5297 | if (showarrow) |
5298 | break; |
5299 | } |
5300 | |
5301 | for (children = ctk_notebook_search_page (notebook, NULL((void*)0), step, TRUE(!(0))); |
5302 | children; |
5303 | children = ctk_notebook_search_page (notebook, children, step, TRUE(!(0)))) |
5304 | { |
5305 | page = children->data; |
5306 | |
5307 | if (page == priv->cur_page) |
5308 | break; |
5309 | |
5310 | if (!ctk_notebook_page_tab_label_is_visible (page)) |
5311 | continue; |
5312 | |
5313 | ctk_css_gadget_draw (page->gadget, cr); |
5314 | } |
5315 | |
5316 | if (children != NULL((void*)0)) |
5317 | { |
5318 | GList *other_order = NULL((void*)0); |
5319 | |
5320 | for (children = ctk_notebook_search_page (notebook, children, step, TRUE(!(0))); |
5321 | children; |
5322 | children = ctk_notebook_search_page (notebook, children, step, TRUE(!(0)))) |
5323 | { |
5324 | page = children->data; |
5325 | |
5326 | if (!ctk_notebook_page_tab_label_is_visible (page)) |
5327 | continue; |
5328 | |
5329 | other_order = g_list_prepend (other_order, page); |
5330 | } |
5331 | |
5332 | /* draw them with the opposite order */ |
5333 | for (children = other_order; children; children = children->next) |
5334 | { |
5335 | page = children->data; |
5336 | ctk_css_gadget_draw (page->gadget, cr); |
5337 | } |
5338 | |
5339 | g_list_free (other_order); |
5340 | } |
5341 | |
5342 | if (showarrow && priv->scrollable) |
5343 | { |
5344 | for (i = 0; i < 4; i++) |
5345 | { |
5346 | if (priv->arrow_gadget[i] == NULL((void*)0)) |
5347 | continue; |
5348 | |
5349 | ctk_css_gadget_draw (priv->arrow_gadget[i], cr); |
5350 | } |
5351 | } |
5352 | |
5353 | if (priv->operation != DRAG_OPERATION_DETACH) |
5354 | ctk_css_gadget_draw (priv->cur_page->gadget, cr); |
5355 | |
5356 | return FALSE(0); |
5357 | } |
5358 | |
5359 | /* Private CtkNotebook Size Allocate Functions: |
5360 | * |
5361 | * ctk_notebook_tab_space |
5362 | * ctk_notebook_calculate_shown_tabs |
5363 | * ctk_notebook_calculate_tabs_allocation |
5364 | * ctk_notebook_pages_allocate |
5365 | * ctk_notebook_calc_tabs |
5366 | */ |
5367 | static void |
5368 | ctk_notebook_allocate_arrows (CtkNotebook *notebook, |
5369 | CtkAllocation *allocation) |
5370 | { |
5371 | CtkNotebookPrivate *priv = notebook->priv; |
5372 | CtkAllocation arrow_allocation, arrow_clip; |
5373 | gint size1, size2, min, nat; |
5374 | guint i, ii; |
5375 | |
5376 | switch (priv->tab_pos) |
5377 | { |
5378 | case CTK_POS_TOP: |
5379 | case CTK_POS_BOTTOM: |
5380 | arrow_allocation.y = allocation->y; |
5381 | arrow_allocation.height = allocation->height; |
5382 | for (i = 0; i < 4; i++) |
5383 | { |
5384 | ii = i < 2 ? i : i ^ 1; |
5385 | |
5386 | if (priv->arrow_gadget[ii] == NULL((void*)0)) |
5387 | continue; |
5388 | |
5389 | ctk_css_gadget_get_preferred_size (priv->arrow_gadget[ii], |
5390 | CTK_ORIENTATION_HORIZONTAL, |
5391 | allocation->height, |
5392 | &min, &nat, |
5393 | NULL((void*)0), NULL((void*)0)); |
5394 | if (i < 2) |
5395 | { |
5396 | arrow_allocation.x = allocation->x; |
5397 | arrow_allocation.width = min; |
5398 | ctk_css_gadget_allocate (priv->arrow_gadget[ii], &arrow_allocation, -1, &arrow_clip); |
5399 | allocation->x += min; |
5400 | allocation->width -= min; |
5401 | } |
5402 | else |
5403 | { |
5404 | arrow_allocation.x = allocation->x + allocation->width - min; |
5405 | arrow_allocation.width = min; |
5406 | ctk_css_gadget_allocate (priv->arrow_gadget[ii], &arrow_allocation, -1, &arrow_clip); |
5407 | allocation->width -= min; |
5408 | } |
5409 | } |
5410 | break; |
5411 | |
5412 | case CTK_POS_LEFT: |
5413 | case CTK_POS_RIGHT: |
5414 | if (priv->arrow_gadget[0] || priv->arrow_gadget[1]) |
5415 | { |
5416 | ctk_notebook_measure_arrows (notebook, |
5417 | CTK_PACK_START, |
5418 | CTK_ORIENTATION_VERTICAL, |
5419 | allocation->width, |
5420 | &min, &nat, |
5421 | NULL((void*)0), NULL((void*)0)); |
5422 | ctk_notebook_distribute_arrow_width (notebook, CTK_PACK_START, allocation->width, &size1, &size2); |
5423 | arrow_allocation.x = allocation->x; |
5424 | arrow_allocation.y = allocation->y; |
5425 | arrow_allocation.width = size1; |
5426 | arrow_allocation.height = min; |
5427 | if (priv->arrow_gadget[0]) |
5428 | ctk_css_gadget_allocate (priv->arrow_gadget[0], &arrow_allocation, -1, &arrow_clip); |
5429 | arrow_allocation.x += size1; |
5430 | arrow_allocation.width = size2; |
5431 | if (priv->arrow_gadget[1]) |
5432 | ctk_css_gadget_allocate (priv->arrow_gadget[1], &arrow_allocation, -1, &arrow_clip); |
5433 | allocation->y += min; |
5434 | allocation->height -= min; |
5435 | } |
5436 | if (priv->arrow_gadget[2] || priv->arrow_gadget[3]) |
5437 | { |
5438 | ctk_notebook_measure_arrows (notebook, |
5439 | CTK_PACK_END, |
5440 | CTK_ORIENTATION_VERTICAL, |
5441 | allocation->width, |
5442 | &min, &nat, |
5443 | NULL((void*)0), NULL((void*)0)); |
5444 | ctk_notebook_distribute_arrow_width (notebook, CTK_PACK_END, allocation->width, &size1, &size2); |
5445 | arrow_allocation.x = allocation->x; |
5446 | arrow_allocation.y = allocation->y + allocation->height - min; |
5447 | arrow_allocation.width = size1; |
5448 | arrow_allocation.height = min; |
5449 | if (priv->arrow_gadget[2]) |
5450 | ctk_css_gadget_allocate (priv->arrow_gadget[2], &arrow_allocation, -1, &arrow_clip); |
5451 | arrow_allocation.x += size1; |
5452 | arrow_allocation.width = size2; |
5453 | if (priv->arrow_gadget[3]) |
5454 | ctk_css_gadget_allocate (priv->arrow_gadget[3], &arrow_allocation, -1, &arrow_clip); |
5455 | allocation->height -= min; |
5456 | } |
5457 | break; |
5458 | |
5459 | } |
5460 | } |
5461 | |
5462 | |
5463 | static void |
5464 | ctk_notebook_tab_space (CtkNotebook *notebook, |
5465 | const CtkAllocation *allocation, |
5466 | gboolean *show_arrows, |
5467 | CtkAllocation *tabs_allocation, |
5468 | gint *tab_space) |
5469 | { |
5470 | CtkNotebookPrivate *priv = notebook->priv; |
5471 | GList *children; |
5472 | CtkPositionType tab_pos = get_effective_tab_pos (notebook); |
5473 | |
5474 | children = priv->children; |
5475 | |
5476 | *tabs_allocation = *allocation; |
5477 | |
5478 | switch (tab_pos) |
5479 | { |
5480 | case CTK_POS_TOP: |
5481 | case CTK_POS_BOTTOM: |
5482 | while (children) |
5483 | { |
5484 | CtkNotebookPage *page; |
5485 | |
5486 | page = children->data; |
5487 | children = children->next; |
5488 | |
5489 | if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))) && |
5490 | ctk_widget_get_visible (page->child)) |
5491 | *tab_space += page->requisition.width; |
5492 | } |
5493 | break; |
5494 | case CTK_POS_RIGHT: |
5495 | case CTK_POS_LEFT: |
5496 | while (children) |
5497 | { |
5498 | CtkNotebookPage *page; |
5499 | |
5500 | page = children->data; |
5501 | children = children->next; |
5502 | |
5503 | if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))) && |
5504 | ctk_widget_get_visible (page->child)) |
5505 | *tab_space += page->requisition.height; |
5506 | } |
5507 | break; |
5508 | } |
5509 | |
5510 | if (!priv->scrollable) |
5511 | *show_arrows = FALSE(0); |
5512 | else |
5513 | { |
5514 | switch (tab_pos) |
5515 | { |
5516 | case CTK_POS_TOP: |
5517 | case CTK_POS_BOTTOM: |
5518 | if (*tab_space > tabs_allocation->width) |
5519 | { |
5520 | *show_arrows = TRUE(!(0)); |
5521 | |
5522 | ctk_notebook_allocate_arrows (notebook, tabs_allocation); |
5523 | |
5524 | *tab_space = tabs_allocation->width; |
5525 | } |
5526 | break; |
5527 | case CTK_POS_LEFT: |
5528 | case CTK_POS_RIGHT: |
5529 | if (*tab_space > tabs_allocation->height) |
5530 | { |
5531 | *show_arrows = TRUE(!(0)); |
5532 | |
5533 | ctk_notebook_allocate_arrows (notebook, tabs_allocation); |
5534 | |
5535 | *tab_space = tabs_allocation->height; |
5536 | } |
5537 | break; |
5538 | } |
5539 | } |
5540 | } |
5541 | |
5542 | static void |
5543 | ctk_notebook_calculate_shown_tabs (CtkNotebook *notebook, |
5544 | gboolean show_arrows, |
5545 | const CtkAllocation *tabs_allocation, |
5546 | gint tab_space, |
5547 | GList **last_child, |
5548 | gint *n, |
5549 | gint *remaining_space) |
5550 | { |
5551 | CtkNotebookPrivate *priv = notebook->priv; |
5552 | GList *children; |
5553 | CtkNotebookPage *page; |
5554 | |
5555 | if (show_arrows) /* first_tab <- focus_tab */ |
5556 | { |
5557 | *remaining_space = tab_space; |
5558 | |
5559 | if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, priv->cur_page)(ctk_widget_get_parent ((priv->cur_page)->tab_label) == (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))))) && |
5560 | ctk_widget_get_visible (priv->cur_page->child)) |
5561 | { |
5562 | ctk_notebook_calc_tabs (notebook, |
5563 | priv->focus_tab, |
5564 | &(priv->focus_tab), |
5565 | remaining_space, STEP_NEXT); |
5566 | } |
5567 | |
5568 | if (tab_space <= 0 || *remaining_space <= 0) |
5569 | { |
5570 | /* show 1 tab */ |
5571 | priv->first_tab = priv->focus_tab; |
5572 | *last_child = ctk_notebook_search_page (notebook, priv->focus_tab, |
5573 | STEP_NEXT, TRUE(!(0))); |
5574 | *n = 1; |
5575 | } |
5576 | else |
5577 | { |
5578 | children = NULL((void*)0); |
5579 | |
5580 | if (priv->first_tab && priv->first_tab != priv->focus_tab) |
5581 | { |
5582 | /* Is first_tab really predecessor of focus_tab? */ |
5583 | page = priv->first_tab->data; |
5584 | if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))) && |
5585 | ctk_widget_get_visible (page->child)) |
5586 | for (children = priv->focus_tab; |
5587 | children && children != priv->first_tab; |
5588 | children = ctk_notebook_search_page (notebook, |
5589 | children, |
5590 | STEP_PREV, |
5591 | TRUE(!(0)))); |
5592 | } |
5593 | |
5594 | if (!children) |
5595 | { |
5596 | if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, priv->cur_page)(ctk_widget_get_parent ((priv->cur_page)->tab_label) == (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))))) |
5597 | priv->first_tab = priv->focus_tab; |
5598 | else |
5599 | priv->first_tab = ctk_notebook_search_page (notebook, priv->focus_tab, |
5600 | STEP_NEXT, TRUE(!(0))); |
5601 | } |
5602 | else |
5603 | /* calculate shown tabs counting backwards from the focus tab */ |
5604 | ctk_notebook_calc_tabs (notebook, |
5605 | ctk_notebook_search_page (notebook, |
5606 | priv->focus_tab, |
5607 | STEP_PREV, |
5608 | TRUE(!(0))), |
5609 | &(priv->first_tab), |
5610 | remaining_space, |
5611 | STEP_PREV); |
5612 | |
5613 | if (*remaining_space < 0) |
5614 | { |
5615 | priv->first_tab = |
5616 | ctk_notebook_search_page (notebook, priv->first_tab, |
5617 | STEP_NEXT, TRUE(!(0))); |
5618 | if (!priv->first_tab) |
5619 | priv->first_tab = priv->focus_tab; |
5620 | |
5621 | *last_child = ctk_notebook_search_page (notebook, priv->focus_tab, |
5622 | STEP_NEXT, TRUE(!(0))); |
5623 | } |
5624 | else /* focus_tab -> end */ |
5625 | { |
5626 | if (!priv->first_tab) |
5627 | priv->first_tab = ctk_notebook_search_page (notebook, |
5628 | NULL((void*)0), |
5629 | STEP_NEXT, |
5630 | TRUE(!(0))); |
5631 | children = NULL((void*)0); |
5632 | ctk_notebook_calc_tabs (notebook, |
5633 | ctk_notebook_search_page (notebook, |
5634 | priv->focus_tab, |
5635 | STEP_NEXT, |
5636 | TRUE(!(0))), |
5637 | &children, |
5638 | remaining_space, |
5639 | STEP_NEXT); |
5640 | |
5641 | if (*remaining_space <= 0) |
5642 | *last_child = children; |
5643 | else /* start <- first_tab */ |
5644 | { |
5645 | *last_child = NULL((void*)0); |
5646 | children = NULL((void*)0); |
5647 | |
5648 | ctk_notebook_calc_tabs (notebook, |
5649 | ctk_notebook_search_page (notebook, |
5650 | priv->first_tab, |
5651 | STEP_PREV, |
5652 | TRUE(!(0))), |
5653 | &children, |
5654 | remaining_space, |
5655 | STEP_PREV); |
5656 | |
5657 | if (*remaining_space == 0) |
5658 | priv->first_tab = children; |
5659 | else |
5660 | priv->first_tab = ctk_notebook_search_page(notebook, |
5661 | children, |
5662 | STEP_NEXT, |
5663 | TRUE(!(0))); |
5664 | } |
5665 | } |
5666 | |
5667 | if (*remaining_space < 0) |
5668 | { |
5669 | /* calculate number of tabs */ |
5670 | *remaining_space = - (*remaining_space); |
5671 | *n = 0; |
5672 | |
5673 | for (children = priv->first_tab; |
5674 | children && children != *last_child; |
5675 | children = ctk_notebook_search_page (notebook, children, |
5676 | STEP_NEXT, TRUE(!(0)))) |
5677 | (*n)++; |
5678 | } |
5679 | else |
5680 | *remaining_space = 0; |
5681 | } |
5682 | |
5683 | /* unmap all non-visible tabs */ |
5684 | for (children = ctk_notebook_search_page (notebook, NULL((void*)0), |
5685 | STEP_NEXT, TRUE(!(0))); |
5686 | children && children != priv->first_tab; |
5687 | children = ctk_notebook_search_page (notebook, children, |
5688 | STEP_NEXT, TRUE(!(0)))) |
5689 | { |
5690 | page = children->data; |
5691 | |
5692 | if (page->tab_label && |
5693 | NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ()))))))))) |
5694 | ctk_widget_set_child_visible (page->tab_label, FALSE(0)); |
5695 | } |
5696 | |
5697 | for (children = *last_child; children; |
5698 | children = ctk_notebook_search_page (notebook, children, |
5699 | STEP_NEXT, TRUE(!(0)))) |
5700 | { |
5701 | page = children->data; |
5702 | |
5703 | if (page->tab_label && |
5704 | NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ()))))))))) |
5705 | ctk_widget_set_child_visible (page->tab_label, FALSE(0)); |
5706 | } |
5707 | } |
5708 | else /* !show_arrows */ |
5709 | { |
5710 | CtkOrientation tab_expand_orientation; |
5711 | gint c = 0; |
5712 | *n = 0; |
5713 | |
5714 | if (priv->tab_pos == CTK_POS_TOP || priv->tab_pos == CTK_POS_BOTTOM) |
5715 | { |
5716 | tab_expand_orientation = CTK_ORIENTATION_HORIZONTAL; |
5717 | *remaining_space = tabs_allocation->width - tab_space; |
5718 | } |
5719 | else |
5720 | { |
5721 | tab_expand_orientation = CTK_ORIENTATION_VERTICAL; |
5722 | *remaining_space = tabs_allocation->height - tab_space; |
5723 | } |
5724 | children = priv->children; |
5725 | priv->first_tab = ctk_notebook_search_page (notebook, NULL((void*)0), |
5726 | STEP_NEXT, TRUE(!(0))); |
5727 | while (children) |
5728 | { |
5729 | page = children->data; |
5730 | children = children->next; |
5731 | |
5732 | if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))) || |
5733 | !ctk_widget_get_visible (page->child)) |
5734 | continue; |
5735 | |
5736 | c++; |
5737 | |
5738 | if (page->expand || |
5739 | (ctk_widget_compute_expand (page->tab_label, tab_expand_orientation))) |
5740 | (*n)++; |
5741 | } |
5742 | } |
5743 | } |
5744 | |
5745 | static gboolean |
5746 | get_allocate_at_bottom (CtkWidget *widget, |
5747 | gint search_direction) |
5748 | { |
5749 | gboolean is_rtl = (ctk_widget_get_direction (widget) == CTK_TEXT_DIR_RTL); |
5750 | CtkPositionType tab_pos = get_effective_tab_pos (CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ()))))))); |
5751 | |
5752 | switch (tab_pos) |
5753 | { |
5754 | case CTK_POS_TOP: |
5755 | case CTK_POS_BOTTOM: |
5756 | if (!is_rtl) |
5757 | return (search_direction == STEP_PREV); |
5758 | else |
5759 | return (search_direction == STEP_NEXT); |
5760 | |
5761 | break; |
5762 | case CTK_POS_RIGHT: |
5763 | case CTK_POS_LEFT: |
5764 | return (search_direction == STEP_PREV); |
5765 | break; |
5766 | } |
5767 | |
5768 | return FALSE(0); |
5769 | } |
5770 | |
5771 | static void |
5772 | ctk_notebook_calculate_tabs_allocation (CtkNotebook *notebook, |
5773 | GList **children, |
5774 | GList *last_child, |
5775 | gboolean showarrow, |
5776 | gint direction, |
5777 | gint *remaining_space, |
5778 | gint *expanded_tabs, |
5779 | const CtkAllocation *allocation) |
5780 | { |
5781 | CtkNotebookPrivate *priv = notebook->priv; |
5782 | CtkWidget *widget; |
5783 | CtkNotebookPage *page; |
5784 | gboolean allocate_at_bottom; |
5785 | gint tab_extra_space; |
5786 | CtkPositionType tab_pos; |
5787 | gint left_x, right_x, top_y, bottom_y, anchor; |
5788 | gboolean gap_left, packing_changed; |
5789 | CtkAllocation child_allocation, drag_allocation, page_clip; |
5790 | CtkOrientation tab_expand_orientation; |
5791 | |
5792 | g_assert (priv->cur_page != NULL)do { if (priv->cur_page != ((void*)0)) ; else g_assertion_message_expr ("Ctk", "ctknotebook.c", 5792, ((const char*) (__func__)), "priv->cur_page != NULL" ); } while (0); |
5793 | |
5794 | widget = CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))); |
5795 | tab_pos = get_effective_tab_pos (notebook); |
5796 | allocate_at_bottom = get_allocate_at_bottom (widget, direction); |
5797 | anchor = 0; |
Value stored to 'anchor' is never read | |
5798 | |
5799 | child_allocation = *allocation; |
5800 | |
5801 | switch (tab_pos) |
5802 | { |
5803 | case CTK_POS_BOTTOM: |
5804 | case CTK_POS_TOP: |
5805 | if (allocate_at_bottom) |
5806 | child_allocation.x += allocation->width; |
5807 | anchor = child_allocation.x; |
5808 | break; |
5809 | |
5810 | case CTK_POS_RIGHT: |
5811 | case CTK_POS_LEFT: |
5812 | if (allocate_at_bottom) |
5813 | child_allocation.y += allocation->height; |
5814 | anchor = child_allocation.y; |
5815 | break; |
5816 | } |
5817 | |
5818 | ctk_css_gadget_get_margin_allocation (priv->cur_page->gadget, &drag_allocation, NULL((void*)0)); |
5819 | left_x = CLAMP (priv->mouse_x - priv->drag_offset_x,(((priv->mouse_x - priv->drag_offset_x) > (allocation ->x + allocation->width - drag_allocation.width)) ? (allocation ->x + allocation->width - drag_allocation.width) : (((priv ->mouse_x - priv->drag_offset_x) < (allocation->x )) ? (allocation->x) : (priv->mouse_x - priv->drag_offset_x ))) |
5820 | allocation->x, allocation->x + allocation->width - drag_allocation.width)(((priv->mouse_x - priv->drag_offset_x) > (allocation ->x + allocation->width - drag_allocation.width)) ? (allocation ->x + allocation->width - drag_allocation.width) : (((priv ->mouse_x - priv->drag_offset_x) < (allocation->x )) ? (allocation->x) : (priv->mouse_x - priv->drag_offset_x ))); |
5821 | top_y = CLAMP (priv->mouse_y - priv->drag_offset_y,(((priv->mouse_y - priv->drag_offset_y) > (allocation ->y + allocation->height - drag_allocation.height)) ? ( allocation->y + allocation->height - drag_allocation.height ) : (((priv->mouse_y - priv->drag_offset_y) < (allocation ->y)) ? (allocation->y) : (priv->mouse_y - priv-> drag_offset_y))) |
5822 | allocation->y, allocation->y + allocation->height - drag_allocation.height)(((priv->mouse_y - priv->drag_offset_y) > (allocation ->y + allocation->height - drag_allocation.height)) ? ( allocation->y + allocation->height - drag_allocation.height ) : (((priv->mouse_y - priv->drag_offset_y) < (allocation ->y)) ? (allocation->y) : (priv->mouse_y - priv-> drag_offset_y))); |
5823 | right_x = left_x + drag_allocation.width; |
5824 | bottom_y = top_y + drag_allocation.height; |
5825 | gap_left = packing_changed = FALSE(0); |
5826 | |
5827 | if (priv->tab_pos == CTK_POS_TOP || priv->tab_pos == CTK_POS_BOTTOM) |
5828 | tab_expand_orientation = CTK_ORIENTATION_HORIZONTAL; |
5829 | else |
5830 | tab_expand_orientation = CTK_ORIENTATION_VERTICAL; |
5831 | |
5832 | while (*children && *children != last_child) |
5833 | { |
5834 | page = (*children)->data; |
5835 | |
5836 | if (direction == STEP_NEXT) |
5837 | *children = ctk_notebook_search_page (notebook, *children, direction, TRUE(!(0))); |
5838 | else |
5839 | { |
5840 | *children = (*children)->next; |
5841 | continue; |
5842 | } |
5843 | |
5844 | if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ()))))))))) |
5845 | continue; |
5846 | |
5847 | tab_extra_space = 0; |
5848 | if (*expanded_tabs && (showarrow || page->expand || ctk_widget_compute_expand (page->tab_label, tab_expand_orientation))) |
5849 | { |
5850 | tab_extra_space = *remaining_space / *expanded_tabs; |
5851 | *remaining_space -= tab_extra_space; |
5852 | (*expanded_tabs)--; |
5853 | } |
5854 | |
5855 | switch (tab_pos) |
5856 | { |
5857 | case CTK_POS_TOP: |
5858 | case CTK_POS_BOTTOM: |
5859 | child_allocation.width = MAX (1, page->requisition.width + tab_extra_space)(((1) > (page->requisition.width + tab_extra_space)) ? ( 1) : (page->requisition.width + tab_extra_space)); |
5860 | |
5861 | /* make sure that the reordered tab doesn't go past the last position */ |
5862 | if (priv->operation == DRAG_OPERATION_REORDER && |
5863 | !gap_left && packing_changed) |
5864 | { |
5865 | if (!allocate_at_bottom) |
5866 | { |
5867 | if (left_x >= anchor) |
5868 | { |
5869 | left_x = priv->drag_window_x = anchor; |
5870 | anchor += drag_allocation.width; |
5871 | } |
5872 | } |
5873 | else |
5874 | { |
5875 | if (right_x <= anchor) |
5876 | { |
5877 | anchor -= drag_allocation.width; |
5878 | left_x = priv->drag_window_x = anchor; |
5879 | } |
5880 | } |
5881 | |
5882 | gap_left = TRUE(!(0)); |
5883 | } |
5884 | |
5885 | if (priv->operation == DRAG_OPERATION_REORDER && page == priv->cur_page) |
5886 | { |
5887 | priv->drag_window_x = left_x; |
5888 | priv->drag_window_y = child_allocation.y; |
5889 | } |
5890 | else |
5891 | { |
5892 | if (allocate_at_bottom) |
5893 | anchor -= child_allocation.width; |
5894 | |
5895 | if (priv->operation == DRAG_OPERATION_REORDER) |
5896 | { |
5897 | if (!allocate_at_bottom && |
5898 | left_x >= anchor && |
5899 | left_x <= anchor + child_allocation.width / 2) |
5900 | anchor += drag_allocation.width; |
5901 | else if (allocate_at_bottom && |
5902 | right_x >= anchor + child_allocation.width / 2 && |
5903 | right_x <= anchor + child_allocation.width) |
5904 | anchor -= drag_allocation.width; |
5905 | } |
5906 | |
5907 | child_allocation.x = anchor; |
5908 | } |
5909 | |
5910 | break; |
5911 | case CTK_POS_LEFT: |
5912 | case CTK_POS_RIGHT: |
5913 | child_allocation.height = MAX (1, page->requisition.height + tab_extra_space)(((1) > (page->requisition.height + tab_extra_space)) ? (1) : (page->requisition.height + tab_extra_space)); |
5914 | |
5915 | /* make sure that the reordered tab doesn't go past the last position */ |
5916 | if (priv->operation == DRAG_OPERATION_REORDER && |
5917 | !gap_left && packing_changed) |
5918 | { |
5919 | if (!allocate_at_bottom && top_y >= anchor) |
5920 | { |
5921 | top_y = priv->drag_window_y = anchor; |
5922 | anchor += drag_allocation.height; |
5923 | } |
5924 | |
5925 | gap_left = TRUE(!(0)); |
5926 | } |
5927 | |
5928 | if (priv->operation == DRAG_OPERATION_REORDER && page == priv->cur_page) |
5929 | { |
5930 | priv->drag_window_x = child_allocation.x; |
5931 | priv->drag_window_y = top_y; |
5932 | } |
5933 | else |
5934 | { |
5935 | if (allocate_at_bottom) |
5936 | anchor -= child_allocation.height; |
5937 | |
5938 | if (priv->operation == DRAG_OPERATION_REORDER) |
5939 | { |
5940 | if (!allocate_at_bottom && |
5941 | top_y >= anchor && |
5942 | top_y <= anchor + child_allocation.height / 2) |
5943 | anchor += drag_allocation.height; |
5944 | else if (allocate_at_bottom && |
5945 | bottom_y >= anchor + child_allocation.height / 2 && |
5946 | bottom_y <= anchor + child_allocation.height) |
5947 | anchor -= drag_allocation.height; |
5948 | } |
5949 | |
5950 | child_allocation.y = anchor; |
5951 | } |
5952 | |
5953 | break; |
5954 | } |
5955 | |
5956 | if (page == priv->cur_page && priv->operation == DRAG_OPERATION_REORDER) |
5957 | { |
5958 | CtkAllocation fixed_allocation = { priv->drag_window_x, priv->drag_window_y, |
5959 | child_allocation.width, child_allocation.height }; |
5960 | cdk_window_move_resize (priv->drag_window, |
5961 | priv->drag_window_x, priv->drag_window_y, |
5962 | child_allocation.width, child_allocation.height); |
5963 | ctk_css_gadget_allocate (page->gadget, &fixed_allocation, -1, &page_clip); |
5964 | } |
5965 | else if (page == priv->detached_tab && priv->operation == DRAG_OPERATION_DETACH) |
5966 | { |
5967 | /* needs to be allocated at 0,0 |
5968 | * to be shown in the drag window */ |
5969 | CtkAllocation fixed_allocation = { 0, 0, child_allocation.width, child_allocation.height }; |
5970 | ctk_css_gadget_allocate (page->gadget, &fixed_allocation, -1, &page_clip); |
5971 | } |
5972 | else |
5973 | { |
5974 | ctk_css_gadget_allocate (page->gadget, &child_allocation, -1, &page_clip); |
5975 | } |
5976 | |
5977 | /* calculate whether to leave a gap based on reorder operation or not */ |
5978 | switch (tab_pos) |
5979 | { |
5980 | case CTK_POS_TOP: |
5981 | case CTK_POS_BOTTOM: |
5982 | if (priv->operation != DRAG_OPERATION_REORDER || page != priv->cur_page) |
5983 | { |
5984 | if (priv->operation == DRAG_OPERATION_REORDER) |
5985 | { |
5986 | if (!allocate_at_bottom && |
5987 | left_x > anchor + child_allocation.width / 2 && |
5988 | left_x <= anchor + child_allocation.width) |
5989 | anchor += drag_allocation.width; |
5990 | else if (allocate_at_bottom && |
5991 | right_x >= anchor && |
5992 | right_x <= anchor + child_allocation.width / 2) |
5993 | anchor -= drag_allocation.width; |
5994 | } |
5995 | |
5996 | if (!allocate_at_bottom) |
5997 | anchor += child_allocation.width; |
5998 | } |
5999 | |
6000 | break; |
6001 | case CTK_POS_LEFT: |
6002 | case CTK_POS_RIGHT: |
6003 | if (priv->operation != DRAG_OPERATION_REORDER || page != priv->cur_page) |
6004 | { |
6005 | if (priv->operation == DRAG_OPERATION_REORDER) |
6006 | { |
6007 | if (!allocate_at_bottom && |
6008 | top_y >= anchor + child_allocation.height / 2 && |
6009 | top_y <= anchor + child_allocation.height) |
6010 | anchor += drag_allocation.height; |
6011 | else if (allocate_at_bottom && |
6012 | bottom_y >= anchor && |
6013 | bottom_y <= anchor + child_allocation.height / 2) |
6014 | anchor -= drag_allocation.height; |
6015 | } |
6016 | |
6017 | if (!allocate_at_bottom) |
6018 | anchor += child_allocation.height; |
6019 | } |
6020 | |
6021 | break; |
6022 | } |
6023 | |
6024 | /* set child visible */ |
6025 | if (page->tab_label) |
6026 | ctk_widget_set_child_visible (page->tab_label, TRUE(!(0))); |
6027 | } |
6028 | |
6029 | /* Don't move the current tab past the last position during tabs reordering */ |
6030 | if (priv->operation == DRAG_OPERATION_REORDER && |
6031 | direction == STEP_NEXT) |
6032 | { |
6033 | switch (tab_pos) |
6034 | { |
6035 | case CTK_POS_TOP: |
6036 | case CTK_POS_BOTTOM: |
6037 | if (allocate_at_bottom) |
6038 | anchor -= drag_allocation.width; |
6039 | |
6040 | if ((!allocate_at_bottom && priv->drag_window_x > anchor) || |
6041 | (allocate_at_bottom && priv->drag_window_x < anchor)) |
6042 | priv->drag_window_x = anchor; |
6043 | break; |
6044 | case CTK_POS_LEFT: |
6045 | case CTK_POS_RIGHT: |
6046 | if (allocate_at_bottom) |
6047 | anchor -= drag_allocation.height; |
6048 | |
6049 | if ((!allocate_at_bottom && priv->drag_window_y > anchor) || |
6050 | (allocate_at_bottom && priv->drag_window_y < anchor)) |
6051 | priv->drag_window_y = anchor; |
6052 | break; |
6053 | } |
6054 | } |
6055 | } |
6056 | |
6057 | static void |
6058 | ctk_notebook_pages_allocate (CtkNotebook *notebook, |
6059 | const CtkAllocation *allocation) |
6060 | { |
6061 | CtkNotebookPrivate *priv = notebook->priv; |
6062 | GList *children = NULL((void*)0); |
6063 | GList *last_child = NULL((void*)0); |
6064 | gboolean showarrow = FALSE(0); |
6065 | CtkAllocation tabs_allocation; |
6066 | gint tab_space, remaining_space; |
6067 | gint expanded_tabs; |
6068 | |
6069 | if (!priv->show_tabs || !ctk_notebook_has_current_page (notebook)) |
6070 | return; |
6071 | |
6072 | tab_space = remaining_space = 0; |
6073 | expanded_tabs = 1; |
6074 | |
6075 | ctk_notebook_tab_space (notebook, allocation, |
6076 | &showarrow, &tabs_allocation, &tab_space); |
6077 | |
6078 | ctk_notebook_calculate_shown_tabs (notebook, showarrow, |
6079 | &tabs_allocation, tab_space, &last_child, |
6080 | &expanded_tabs, &remaining_space); |
6081 | |
6082 | children = priv->first_tab; |
6083 | ctk_notebook_calculate_tabs_allocation (notebook, &children, last_child, |
6084 | showarrow, STEP_NEXT, |
6085 | &remaining_space, &expanded_tabs, &tabs_allocation); |
6086 | if (children && children != last_child) |
6087 | { |
6088 | children = priv->children; |
6089 | ctk_notebook_calculate_tabs_allocation (notebook, &children, last_child, |
6090 | showarrow, STEP_PREV, |
6091 | &remaining_space, &expanded_tabs, &tabs_allocation); |
6092 | } |
6093 | |
6094 | if (!priv->first_tab) |
6095 | priv->first_tab = priv->children; |
6096 | |
6097 | ctk_css_gadget_queue_draw (priv->tabs_gadget); |
6098 | } |
6099 | |
6100 | static void |
6101 | ctk_notebook_calc_tabs (CtkNotebook *notebook, |
6102 | GList *start, |
6103 | GList **end, |
6104 | gint *tab_space, |
6105 | guint direction) |
6106 | { |
6107 | CtkNotebookPage *page = NULL((void*)0); |
6108 | GList *children; |
6109 | GList *last_calculated_child = NULL((void*)0); |
6110 | CtkPositionType tab_pos = get_effective_tab_pos (notebook); |
6111 | |
6112 | if (!start) |
6113 | return; |
6114 | |
6115 | children = start; |
6116 | |
6117 | switch (tab_pos) |
6118 | { |
6119 | case CTK_POS_TOP: |
6120 | case CTK_POS_BOTTOM: |
6121 | while (children) |
6122 | { |
6123 | page = children->data; |
6124 | if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))) && |
6125 | ctk_widget_get_visible (page->child)) |
6126 | { |
6127 | *tab_space -= page->requisition.width; |
6128 | if (*tab_space < 0 || children == *end) |
6129 | { |
6130 | if (*tab_space < 0) |
6131 | { |
6132 | *tab_space = - (*tab_space + |
6133 | page->requisition.width); |
6134 | |
6135 | if (*tab_space == 0 && direction == STEP_PREV) |
6136 | children = last_calculated_child; |
6137 | |
6138 | *end = children; |
6139 | } |
6140 | return; |
6141 | } |
6142 | |
6143 | last_calculated_child = children; |
6144 | } |
6145 | if (direction == STEP_NEXT) |
6146 | children = children->next; |
6147 | else |
6148 | children = children->prev; |
6149 | } |
6150 | break; |
6151 | case CTK_POS_LEFT: |
6152 | case CTK_POS_RIGHT: |
6153 | while (children) |
6154 | { |
6155 | page = children->data; |
6156 | if (NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)(ctk_widget_get_parent ((page)->tab_label) == (((((CtkWidget *) (void *) g_type_check_instance_cast ((GTypeInstance*) ((notebook )), ((ctk_widget_get_type ())))))))) && |
6157 | ctk_widget_get_visible (page->child)) |
6158 | { |
6159 | *tab_space -= page->requisition.height; |
6160 | if (*tab_space < 0 || children == *end) |
6161 | { |
6162 | if (*tab_space < 0) |
6163 | { |
6164 | *tab_space = - (*tab_space + page->requisition.height); |
6165 | |
6166 | if (*tab_space == 0 && direction == STEP_PREV) |
6167 | children = last_calculated_child; |
6168 | |
6169 | *end = children; |
6170 | } |
6171 | return; |
6172 | } |
6173 | |
6174 | last_calculated_child = children; |
6175 | } |
6176 | if (direction == STEP_NEXT) |
6177 | children = children->next; |
6178 | else |
6179 | children = children->prev; |
6180 | } |
6181 | break; |
6182 | } |
6183 | } |
6184 | |
6185 | /* Private CtkNotebook Page Switch Methods: |
6186 | * |
6187 | * ctk_notebook_real_switch_page |
6188 | */ |
6189 | static void |
6190 | ctk_notebook_real_switch_page (CtkNotebook *notebook, |
6191 | CtkWidget* child, |
6192 | guint page_num G_GNUC_UNUSED__attribute__ ((__unused__))) |
6193 | { |
6194 | CtkNotebookPrivate *priv = notebook->priv; |
6195 | GList *list = ctk_notebook_find_child (notebook, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ()))))))); |
6196 | CtkNotebookPage *page = CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data); |
6197 | gboolean child_has_focus; |
6198 | |
6199 | if (priv->cur_page == page || !ctk_widget_get_visible (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ())))))))) |
6200 | return; |
6201 | |
6202 | /* save the value here, changing visibility changes focus */ |
6203 | child_has_focus = priv->child_has_focus; |
6204 | |
6205 | if (priv->cur_page) |
6206 | { |
6207 | ctk_widget_set_child_visible (priv->cur_page->child, FALSE(0)); |
6208 | ctk_css_gadget_remove_state (priv->cur_page->gadget, CTK_STATE_FLAG_CHECKED); |
6209 | } |
6210 | |
6211 | priv->cur_page = page; |
6212 | ctk_css_gadget_add_state (page->gadget, CTK_STATE_FLAG_CHECKED); |
6213 | ctk_css_gadget_set_visible (priv->header_gadget, priv->show_tabs); |
6214 | |
6215 | if (!priv->focus_tab || |
6216 | priv->focus_tab->data != (gpointer) priv->cur_page) |
6217 | priv->focus_tab = |
6218 | g_list_find (priv->children, priv->cur_page); |
6219 | |
6220 | ctk_widget_set_child_visible (priv->cur_page->child, TRUE(!(0))); |
6221 | |
6222 | /* If the focus was on the previous page, move it to the first |
6223 | * element on the new page, if possible, or if not, to the |
6224 | * notebook itself. |
6225 | */ |
6226 | if (child_has_focus) |
6227 | { |
6228 | if (priv->cur_page->last_focus_child && |
6229 | ctk_widget_is_ancestor (priv->cur_page->last_focus_child, priv->cur_page->child)) |
6230 | ctk_widget_grab_focus (priv->cur_page->last_focus_child); |
6231 | else |
6232 | if (!ctk_widget_child_focus (priv->cur_page->child, CTK_DIR_TAB_FORWARD)) |
6233 | ctk_widget_grab_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
6234 | } |
6235 | |
6236 | if (priv->scrollable) |
6237 | ctk_notebook_redraw_arrows (notebook); |
6238 | |
6239 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
6240 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_PAGE]); |
6241 | } |
6242 | |
6243 | /* Private CtkNotebook Page Switch Functions: |
6244 | * |
6245 | * ctk_notebook_switch_page |
6246 | * ctk_notebook_page_select |
6247 | * ctk_notebook_switch_focus_tab |
6248 | * ctk_notebook_menu_switch_page |
6249 | */ |
6250 | static void |
6251 | ctk_notebook_switch_page (CtkNotebook *notebook, |
6252 | CtkNotebookPage *page) |
6253 | { |
6254 | CtkNotebookPrivate *priv = notebook->priv; |
6255 | guint page_num; |
6256 | |
6257 | if (priv->cur_page == page) |
6258 | return; |
6259 | |
6260 | page_num = g_list_index (priv->children, page); |
6261 | |
6262 | g_signal_emit (notebook, |
6263 | notebook_signals[SWITCH_PAGE], |
6264 | 0, |
6265 | page->child, |
6266 | page_num); |
6267 | } |
6268 | |
6269 | static gint |
6270 | ctk_notebook_page_select (CtkNotebook *notebook, |
6271 | gboolean move_focus) |
6272 | { |
6273 | CtkNotebookPrivate *priv = notebook->priv; |
6274 | CtkNotebookPage *page; |
6275 | CtkDirectionType dir = CTK_DIR_DOWN; /* Quiet GCC */ |
6276 | CtkPositionType tab_pos = get_effective_tab_pos (notebook); |
6277 | |
6278 | if (!priv->focus_tab) |
6279 | return FALSE(0); |
6280 | |
6281 | page = priv->focus_tab->data; |
6282 | ctk_notebook_switch_page (notebook, page); |
6283 | |
6284 | if (move_focus) |
6285 | { |
6286 | switch (tab_pos) |
6287 | { |
6288 | case CTK_POS_TOP: |
6289 | dir = CTK_DIR_DOWN; |
6290 | break; |
6291 | case CTK_POS_BOTTOM: |
6292 | dir = CTK_DIR_UP; |
6293 | break; |
6294 | case CTK_POS_LEFT: |
6295 | dir = CTK_DIR_RIGHT; |
6296 | break; |
6297 | case CTK_POS_RIGHT: |
6298 | dir = CTK_DIR_LEFT; |
6299 | break; |
6300 | } |
6301 | |
6302 | if (ctk_widget_child_focus (page->child, dir)) |
6303 | return TRUE(!(0)); |
6304 | } |
6305 | return FALSE(0); |
6306 | } |
6307 | |
6308 | static void |
6309 | ctk_notebook_switch_focus_tab (CtkNotebook *notebook, |
6310 | GList *new_child) |
6311 | { |
6312 | CtkNotebookPrivate *priv = notebook->priv; |
6313 | CtkNotebookPage *page; |
6314 | |
6315 | if (priv->focus_tab == new_child) |
6316 | return; |
6317 | |
6318 | priv->focus_tab = new_child; |
6319 | |
6320 | if (priv->scrollable) |
6321 | ctk_notebook_redraw_arrows (notebook); |
6322 | |
6323 | if (!priv->show_tabs || !priv->focus_tab) |
6324 | return; |
6325 | |
6326 | page = priv->focus_tab->data; |
6327 | ctk_notebook_switch_page (notebook, page); |
6328 | } |
6329 | |
6330 | static void |
6331 | ctk_notebook_menu_switch_page (CtkWidget *widget, |
6332 | CtkNotebookPage *page) |
6333 | { |
6334 | CtkNotebookPrivate *priv; |
6335 | CtkNotebook *notebook; |
6336 | CtkWidget *parent; |
6337 | GList *children; |
6338 | guint page_num; |
6339 | |
6340 | parent = ctk_widget_get_parent (widget); |
6341 | notebook = CTK_NOTEBOOK (ctk_menu_get_attach_widget (CTK_MENU (parent)))((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_menu_get_attach_widget (((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((parent)), ((ctk_menu_get_type ())))))))) ), ((ctk_notebook_get_type ())))))); |
6342 | priv = notebook->priv; |
6343 | |
6344 | if (priv->cur_page == page) |
6345 | return; |
6346 | |
6347 | page_num = 0; |
6348 | children = priv->children; |
6349 | while (children && children->data != page) |
6350 | { |
6351 | children = children->next; |
6352 | page_num++; |
6353 | } |
6354 | |
6355 | g_signal_emit (notebook, |
6356 | notebook_signals[SWITCH_PAGE], |
6357 | 0, |
6358 | page->child, |
6359 | page_num); |
6360 | } |
6361 | |
6362 | /* Private CtkNotebook Menu Functions: |
6363 | * |
6364 | * ctk_notebook_menu_item_create |
6365 | * ctk_notebook_menu_item_recreate |
6366 | * ctk_notebook_menu_label_unparent |
6367 | * ctk_notebook_menu_detacher |
6368 | */ |
6369 | static void |
6370 | ctk_notebook_menu_item_create (CtkNotebook *notebook, |
6371 | GList *list) |
6372 | { |
6373 | CtkNotebookPrivate *priv = notebook->priv; |
6374 | CtkNotebookPage *page; |
6375 | CtkWidget *menu_item; |
6376 | |
6377 | page = list->data; |
6378 | if (page->default_menu) |
6379 | { |
6380 | if (CTK_IS_LABEL (page->tab_label)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (page->tab_label)); GType __t = ((ctk_label_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; } ))))) |
6381 | page->menu_label = ctk_label_new (ctk_label_get_text (CTK_LABEL (page->tab_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((page->tab_label)), ((ctk_label_get_type ())))))))); |
6382 | else |
6383 | page->menu_label = ctk_label_new (""); |
6384 | ctk_widget_set_halign (page->menu_label, CTK_ALIGN_START); |
6385 | ctk_widget_set_valign (page->menu_label, CTK_ALIGN_CENTER); |
6386 | } |
6387 | |
6388 | ctk_widget_show (page->menu_label); |
6389 | menu_item = ctk_menu_item_new (); |
6390 | ctk_container_add (CTK_CONTAINER (menu_item)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu_item)), ((ctk_container_get_type ())))))), page->menu_label); |
6391 | ctk_menu_shell_insert (CTK_MENU_SHELL (priv->menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_menu_shell_get_type ())))))), menu_item, |
6392 | g_list_position (priv->children, list)); |
6393 | g_signal_connect (menu_item, "activate",g_signal_connect_data ((menu_item), ("activate"), (((GCallback ) (ctk_notebook_menu_switch_page))), (page), ((void*)0), (GConnectFlags ) 0) |
6394 | G_CALLBACK (ctk_notebook_menu_switch_page), page)g_signal_connect_data ((menu_item), ("activate"), (((GCallback ) (ctk_notebook_menu_switch_page))), (page), ((void*)0), (GConnectFlags ) 0); |
6395 | if (ctk_widget_get_visible (page->child)) |
6396 | ctk_widget_show (menu_item); |
6397 | } |
6398 | |
6399 | static void |
6400 | ctk_notebook_menu_item_recreate (CtkNotebook *notebook, |
6401 | GList *list) |
6402 | { |
6403 | CtkNotebookPrivate *priv = notebook->priv; |
6404 | CtkNotebookPage *page = list->data; |
6405 | CtkWidget *menu_item = ctk_widget_get_parent (page->menu_label); |
6406 | |
6407 | ctk_container_remove (CTK_CONTAINER (menu_item)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu_item)), ((ctk_container_get_type ())))))), page->menu_label); |
6408 | ctk_container_remove (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_container_get_type ())))))), menu_item); |
6409 | ctk_notebook_menu_item_create (notebook, list); |
6410 | } |
6411 | |
6412 | static void |
6413 | ctk_notebook_menu_label_unparent (CtkWidget *widget, |
6414 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
6415 | { |
6416 | ctk_widget_unparent (ctk_bin_get_child (CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_bin_get_type ())))))))); |
6417 | _ctk_bin_set_child (CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_bin_get_type ())))))), NULL((void*)0)); |
6418 | } |
6419 | |
6420 | static void |
6421 | ctk_notebook_menu_detacher (CtkWidget *widget, |
6422 | CtkMenu *menu) |
6423 | { |
6424 | CtkNotebook *notebook = CTK_NOTEBOOK (widget)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_notebook_get_type ())))))); |
6425 | CtkNotebookPrivate *priv = notebook->priv; |
6426 | |
6427 | g_return_if_fail (priv->menu == (CtkWidget*) menu)do { if ((priv->menu == (CtkWidget*) menu)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "priv->menu == (CtkWidget*) menu" ); return; } } while (0); |
6428 | |
6429 | priv->menu = NULL((void*)0); |
6430 | } |
6431 | |
6432 | /* Public CtkNotebook Page Insert/Remove Methods : |
6433 | * |
6434 | * ctk_notebook_append_page |
6435 | * ctk_notebook_append_page_menu |
6436 | * ctk_notebook_prepend_page |
6437 | * ctk_notebook_prepend_page_menu |
6438 | * ctk_notebook_insert_page |
6439 | * ctk_notebook_insert_page_menu |
6440 | * ctk_notebook_remove_page |
6441 | */ |
6442 | /** |
6443 | * ctk_notebook_append_page: |
6444 | * @notebook: a #CtkNotebook |
6445 | * @child: the #CtkWidget to use as the contents of the page |
6446 | * @tab_label: (allow-none): the #CtkWidget to be used as the label |
6447 | * for the page, or %NULL to use the default label, “page N” |
6448 | * |
6449 | * Appends a page to @notebook. |
6450 | * |
6451 | * Returns: the index (starting from 0) of the appended |
6452 | * page in the notebook, or -1 if function fails |
6453 | */ |
6454 | gint |
6455 | ctk_notebook_append_page (CtkNotebook *notebook, |
6456 | CtkWidget *child, |
6457 | CtkWidget *tab_label) |
6458 | { |
6459 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6460 | g_return_val_if_fail (CTK_IS_WIDGET (child), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (-1); } } while (0); |
6461 | g_return_val_if_fail (tab_label == NULL || CTK_IS_WIDGET (tab_label), -1)do { if ((tab_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((tab_label)); 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__)), "tab_label == NULL || CTK_IS_WIDGET (tab_label)" ); return (-1); } } while (0); |
6462 | |
6463 | return ctk_notebook_insert_page_menu (notebook, child, tab_label, NULL((void*)0), -1); |
6464 | } |
6465 | |
6466 | /** |
6467 | * ctk_notebook_append_page_menu: |
6468 | * @notebook: a #CtkNotebook |
6469 | * @child: the #CtkWidget to use as the contents of the page |
6470 | * @tab_label: (allow-none): the #CtkWidget to be used as the label |
6471 | * for the page, or %NULL to use the default label, “page N” |
6472 | * @menu_label: (allow-none): the widget to use as a label for the |
6473 | * page-switch menu, if that is enabled. If %NULL, and @tab_label |
6474 | * is a #CtkLabel or %NULL, then the menu label will be a newly |
6475 | * created label with the same text as @tab_label; if @tab_label |
6476 | * is not a #CtkLabel, @menu_label must be specified if the |
6477 | * page-switch menu is to be used. |
6478 | * |
6479 | * Appends a page to @notebook, specifying the widget to use as the |
6480 | * label in the popup menu. |
6481 | * |
6482 | * Returns: the index (starting from 0) of the appended |
6483 | * page in the notebook, or -1 if function fails |
6484 | */ |
6485 | gint |
6486 | ctk_notebook_append_page_menu (CtkNotebook *notebook, |
6487 | CtkWidget *child, |
6488 | CtkWidget *tab_label, |
6489 | CtkWidget *menu_label) |
6490 | { |
6491 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6492 | g_return_val_if_fail (CTK_IS_WIDGET (child), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (-1); } } while (0); |
6493 | g_return_val_if_fail (tab_label == NULL || CTK_IS_WIDGET (tab_label), -1)do { if ((tab_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((tab_label)); 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__)), "tab_label == NULL || CTK_IS_WIDGET (tab_label)" ); return (-1); } } while (0); |
6494 | g_return_val_if_fail (menu_label == NULL || CTK_IS_WIDGET (menu_label), -1)do { if ((menu_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((menu_label)); 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__)), "menu_label == NULL || CTK_IS_WIDGET (menu_label)" ); return (-1); } } while (0); |
6495 | |
6496 | return ctk_notebook_insert_page_menu (notebook, child, tab_label, menu_label, -1); |
6497 | } |
6498 | |
6499 | /** |
6500 | * ctk_notebook_prepend_page: |
6501 | * @notebook: a #CtkNotebook |
6502 | * @child: the #CtkWidget to use as the contents of the page |
6503 | * @tab_label: (allow-none): the #CtkWidget to be used as the label |
6504 | * for the page, or %NULL to use the default label, “page N” |
6505 | * |
6506 | * Prepends a page to @notebook. |
6507 | * |
6508 | * Returns: the index (starting from 0) of the prepended |
6509 | * page in the notebook, or -1 if function fails |
6510 | */ |
6511 | gint |
6512 | ctk_notebook_prepend_page (CtkNotebook *notebook, |
6513 | CtkWidget *child, |
6514 | CtkWidget *tab_label) |
6515 | { |
6516 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6517 | g_return_val_if_fail (CTK_IS_WIDGET (child), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (-1); } } while (0); |
6518 | g_return_val_if_fail (tab_label == NULL || CTK_IS_WIDGET (tab_label), -1)do { if ((tab_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((tab_label)); 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__)), "tab_label == NULL || CTK_IS_WIDGET (tab_label)" ); return (-1); } } while (0); |
6519 | |
6520 | return ctk_notebook_insert_page_menu (notebook, child, tab_label, NULL((void*)0), 0); |
6521 | } |
6522 | |
6523 | /** |
6524 | * ctk_notebook_prepend_page_menu: |
6525 | * @notebook: a #CtkNotebook |
6526 | * @child: the #CtkWidget to use as the contents of the page |
6527 | * @tab_label: (allow-none): the #CtkWidget to be used as the label |
6528 | * for the page, or %NULL to use the default label, “page N” |
6529 | * @menu_label: (allow-none): the widget to use as a label for the |
6530 | * page-switch menu, if that is enabled. If %NULL, and @tab_label |
6531 | * is a #CtkLabel or %NULL, then the menu label will be a newly |
6532 | * created label with the same text as @tab_label; if @tab_label |
6533 | * is not a #CtkLabel, @menu_label must be specified if the |
6534 | * page-switch menu is to be used. |
6535 | * |
6536 | * Prepends a page to @notebook, specifying the widget to use as the |
6537 | * label in the popup menu. |
6538 | * |
6539 | * Returns: the index (starting from 0) of the prepended |
6540 | * page in the notebook, or -1 if function fails |
6541 | */ |
6542 | gint |
6543 | ctk_notebook_prepend_page_menu (CtkNotebook *notebook, |
6544 | CtkWidget *child, |
6545 | CtkWidget *tab_label, |
6546 | CtkWidget *menu_label) |
6547 | { |
6548 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6549 | g_return_val_if_fail (CTK_IS_WIDGET (child), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (-1); } } while (0); |
6550 | g_return_val_if_fail (tab_label == NULL || CTK_IS_WIDGET (tab_label), -1)do { if ((tab_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((tab_label)); 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__)), "tab_label == NULL || CTK_IS_WIDGET (tab_label)" ); return (-1); } } while (0); |
6551 | g_return_val_if_fail (menu_label == NULL || CTK_IS_WIDGET (menu_label), -1)do { if ((menu_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((menu_label)); 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__)), "menu_label == NULL || CTK_IS_WIDGET (menu_label)" ); return (-1); } } while (0); |
6552 | |
6553 | return ctk_notebook_insert_page_menu (notebook, child, tab_label, menu_label, 0); |
6554 | } |
6555 | |
6556 | /** |
6557 | * ctk_notebook_insert_page: |
6558 | * @notebook: a #CtkNotebook |
6559 | * @child: the #CtkWidget to use as the contents of the page |
6560 | * @tab_label: (allow-none): the #CtkWidget to be used as the label |
6561 | * for the page, or %NULL to use the default label, “page N” |
6562 | * @position: the index (starting at 0) at which to insert the page, |
6563 | * or -1 to append the page after all other pages |
6564 | * |
6565 | * Insert a page into @notebook at the given position. |
6566 | * |
6567 | * Returns: the index (starting from 0) of the inserted |
6568 | * page in the notebook, or -1 if function fails |
6569 | */ |
6570 | gint |
6571 | ctk_notebook_insert_page (CtkNotebook *notebook, |
6572 | CtkWidget *child, |
6573 | CtkWidget *tab_label, |
6574 | gint position) |
6575 | { |
6576 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6577 | g_return_val_if_fail (CTK_IS_WIDGET (child), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (-1); } } while (0); |
6578 | g_return_val_if_fail (tab_label == NULL || CTK_IS_WIDGET (tab_label), -1)do { if ((tab_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((tab_label)); 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__)), "tab_label == NULL || CTK_IS_WIDGET (tab_label)" ); return (-1); } } while (0); |
6579 | |
6580 | return ctk_notebook_insert_page_menu (notebook, child, tab_label, NULL((void*)0), position); |
6581 | } |
6582 | |
6583 | |
6584 | static gint |
6585 | ctk_notebook_page_compare_tab (gconstpointer a, |
6586 | gconstpointer b) |
6587 | { |
6588 | return (((CtkNotebookPage *) a)->tab_label != b); |
6589 | } |
6590 | |
6591 | static gboolean |
6592 | ctk_notebook_mnemonic_activate_switch_page (CtkWidget *child, |
6593 | gboolean overload G_GNUC_UNUSED__attribute__ ((__unused__)), |
6594 | gpointer data) |
6595 | { |
6596 | CtkNotebook *notebook = CTK_NOTEBOOK (data)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_notebook_get_type ())))))); |
6597 | CtkNotebookPrivate *priv = notebook->priv; |
6598 | GList *list; |
6599 | |
6600 | list = g_list_find_custom (priv->children, child, |
6601 | ctk_notebook_page_compare_tab); |
6602 | if (list) |
6603 | { |
6604 | CtkNotebookPage *page = list->data; |
6605 | |
6606 | ctk_widget_grab_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); /* Do this first to avoid focusing new page */ |
6607 | ctk_notebook_switch_page (notebook, page); |
6608 | focus_tabs_in (notebook); |
6609 | } |
6610 | |
6611 | return TRUE(!(0)); |
6612 | } |
6613 | |
6614 | /** |
6615 | * ctk_notebook_insert_page_menu: |
6616 | * @notebook: a #CtkNotebook |
6617 | * @child: the #CtkWidget to use as the contents of the page |
6618 | * @tab_label: (allow-none): the #CtkWidget to be used as the label |
6619 | * for the page, or %NULL to use the default label, “page N” |
6620 | * @menu_label: (allow-none): the widget to use as a label for the |
6621 | * page-switch menu, if that is enabled. If %NULL, and @tab_label |
6622 | * is a #CtkLabel or %NULL, then the menu label will be a newly |
6623 | * created label with the same text as @tab_label; if @tab_label |
6624 | * is not a #CtkLabel, @menu_label must be specified if the |
6625 | * page-switch menu is to be used. |
6626 | * @position: the index (starting at 0) at which to insert the page, |
6627 | * or -1 to append the page after all other pages. |
6628 | * |
6629 | * Insert a page into @notebook at the given position, specifying |
6630 | * the widget to use as the label in the popup menu. |
6631 | * |
6632 | * Returns: the index (starting from 0) of the inserted |
6633 | * page in the notebook |
6634 | */ |
6635 | gint |
6636 | ctk_notebook_insert_page_menu (CtkNotebook *notebook, |
6637 | CtkWidget *child, |
6638 | CtkWidget *tab_label, |
6639 | CtkWidget *menu_label, |
6640 | gint position) |
6641 | { |
6642 | CtkNotebookClass *class; |
6643 | |
6644 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6645 | g_return_val_if_fail (CTK_IS_WIDGET (child), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (-1); } } while (0); |
6646 | g_return_val_if_fail (tab_label == NULL || CTK_IS_WIDGET (tab_label), -1)do { if ((tab_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((tab_label)); 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__)), "tab_label == NULL || CTK_IS_WIDGET (tab_label)" ); return (-1); } } while (0); |
6647 | g_return_val_if_fail (menu_label == NULL || CTK_IS_WIDGET (menu_label), -1)do { if ((menu_label == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((menu_label)); 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__)), "menu_label == NULL || CTK_IS_WIDGET (menu_label)" ); return (-1); } } while (0); |
6648 | |
6649 | class = CTK_NOTEBOOK_GET_CLASS (notebook)((((CtkNotebookClass*) (((GTypeInstance*) ((notebook)))->g_class )))); |
6650 | |
6651 | return (class->insert_page) (notebook, child, tab_label, menu_label, position); |
6652 | } |
6653 | |
6654 | /** |
6655 | * ctk_notebook_remove_page: |
6656 | * @notebook: a #CtkNotebook |
6657 | * @page_num: the index of a notebook page, starting |
6658 | * from 0. If -1, the last page will be removed. |
6659 | * |
6660 | * Removes a page from the notebook given its index |
6661 | * in the notebook. |
6662 | */ |
6663 | void |
6664 | ctk_notebook_remove_page (CtkNotebook *notebook, |
6665 | gint page_num) |
6666 | { |
6667 | CtkNotebookPrivate *priv; |
6668 | GList *list = NULL((void*)0); |
6669 | |
6670 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
6671 | |
6672 | priv = notebook->priv; |
6673 | |
6674 | if (page_num >= 0) |
6675 | list = g_list_nth (priv->children, page_num); |
6676 | else |
6677 | list = g_list_last (priv->children); |
6678 | |
6679 | if (list) |
6680 | ctk_container_remove (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ())))))), |
6681 | ((CtkNotebookPage *) list->data)->child); |
6682 | } |
6683 | |
6684 | /* Public CtkNotebook Page Switch Methods : |
6685 | * ctk_notebook_get_current_page |
6686 | * ctk_notebook_page_num |
6687 | * ctk_notebook_set_current_page |
6688 | * ctk_notebook_next_page |
6689 | * ctk_notebook_prev_page |
6690 | */ |
6691 | /** |
6692 | * ctk_notebook_get_current_page: |
6693 | * @notebook: a #CtkNotebook |
6694 | * |
6695 | * Returns the page number of the current page. |
6696 | * |
6697 | * Returns: the index (starting from 0) of the current |
6698 | * page in the notebook. If the notebook has no pages, |
6699 | * then -1 will be returned. |
6700 | */ |
6701 | gint |
6702 | ctk_notebook_get_current_page (CtkNotebook *notebook) |
6703 | { |
6704 | CtkNotebookPrivate *priv; |
6705 | |
6706 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6707 | |
6708 | priv = notebook->priv; |
6709 | |
6710 | if (!priv->cur_page) |
6711 | return -1; |
6712 | |
6713 | return g_list_index (priv->children, priv->cur_page); |
6714 | } |
6715 | |
6716 | /** |
6717 | * ctk_notebook_get_nth_page: |
6718 | * @notebook: a #CtkNotebook |
6719 | * @page_num: the index of a page in the notebook, or -1 |
6720 | * to get the last page |
6721 | * |
6722 | * Returns the child widget contained in page number @page_num. |
6723 | * |
6724 | * Returns: (nullable) (transfer none): the child widget, or %NULL if @page_num |
6725 | * is out of bounds |
6726 | */ |
6727 | CtkWidget* |
6728 | ctk_notebook_get_nth_page (CtkNotebook *notebook, |
6729 | gint page_num) |
6730 | { |
6731 | CtkNotebookPrivate *priv; |
6732 | CtkNotebookPage *page; |
6733 | GList *list; |
6734 | |
6735 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (((void*)0)); } } while (0); |
6736 | |
6737 | priv = notebook->priv; |
6738 | |
6739 | if (page_num >= 0) |
6740 | list = g_list_nth (priv->children, page_num); |
6741 | else |
6742 | list = g_list_last (priv->children); |
6743 | |
6744 | if (list) |
6745 | { |
6746 | page = list->data; |
6747 | return page->child; |
6748 | } |
6749 | |
6750 | return NULL((void*)0); |
6751 | } |
6752 | |
6753 | /** |
6754 | * ctk_notebook_get_n_pages: |
6755 | * @notebook: a #CtkNotebook |
6756 | * |
6757 | * Gets the number of pages in a notebook. |
6758 | * |
6759 | * Returns: the number of pages in the notebook |
6760 | * |
6761 | * Since: 2.2 |
6762 | */ |
6763 | gint |
6764 | ctk_notebook_get_n_pages (CtkNotebook *notebook) |
6765 | { |
6766 | CtkNotebookPrivate *priv; |
6767 | |
6768 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (0); } } while (0); |
6769 | |
6770 | priv = notebook->priv; |
6771 | |
6772 | return g_list_length (priv->children); |
6773 | } |
6774 | |
6775 | /** |
6776 | * ctk_notebook_page_num: |
6777 | * @notebook: a #CtkNotebook |
6778 | * @child: a #CtkWidget |
6779 | * |
6780 | * Finds the index of the page which contains the given child |
6781 | * widget. |
6782 | * |
6783 | * Returns: the index of the page containing @child, or |
6784 | * -1 if @child is not in the notebook |
6785 | */ |
6786 | gint |
6787 | ctk_notebook_page_num (CtkNotebook *notebook, |
6788 | CtkWidget *child) |
6789 | { |
6790 | CtkNotebookPrivate *priv; |
6791 | GList *children; |
6792 | gint num; |
6793 | |
6794 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (-1); } } while (0); |
6795 | |
6796 | priv = notebook->priv; |
6797 | |
6798 | num = 0; |
6799 | children = priv->children; |
6800 | while (children) |
6801 | { |
6802 | CtkNotebookPage *page = children->data; |
6803 | |
6804 | if (page->child == child) |
6805 | return num; |
6806 | |
6807 | children = children->next; |
6808 | num++; |
6809 | } |
6810 | |
6811 | return -1; |
6812 | } |
6813 | |
6814 | /** |
6815 | * ctk_notebook_set_current_page: |
6816 | * @notebook: a #CtkNotebook |
6817 | * @page_num: index of the page to switch to, starting from 0. |
6818 | * If negative, the last page will be used. If greater |
6819 | * than the number of pages in the notebook, nothing |
6820 | * will be done. |
6821 | * |
6822 | * Switches to the page number @page_num. |
6823 | * |
6824 | * Note that due to historical reasons, CtkNotebook refuses |
6825 | * to switch to a page unless the child widget is visible. |
6826 | * Therefore, it is recommended to show child widgets before |
6827 | * adding them to a notebook. |
6828 | */ |
6829 | void |
6830 | ctk_notebook_set_current_page (CtkNotebook *notebook, |
6831 | gint page_num) |
6832 | { |
6833 | CtkNotebookPrivate *priv; |
6834 | GList *list; |
6835 | |
6836 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
6837 | |
6838 | priv = notebook->priv; |
6839 | |
6840 | if (page_num < 0) |
6841 | page_num = g_list_length (priv->children) - 1; |
6842 | |
6843 | list = g_list_nth (priv->children, page_num); |
6844 | if (list) |
6845 | ctk_notebook_switch_page (notebook, CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)); |
6846 | |
6847 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_PAGE]); |
6848 | } |
6849 | |
6850 | /** |
6851 | * ctk_notebook_next_page: |
6852 | * @notebook: a #CtkNotebook |
6853 | * |
6854 | * Switches to the next page. Nothing happens if the current page is |
6855 | * the last page. |
6856 | */ |
6857 | void |
6858 | ctk_notebook_next_page (CtkNotebook *notebook) |
6859 | { |
6860 | CtkNotebookPrivate *priv; |
6861 | GList *list; |
6862 | |
6863 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
6864 | |
6865 | priv = notebook->priv; |
6866 | |
6867 | list = g_list_find (priv->children, priv->cur_page); |
6868 | if (!list) |
6869 | return; |
6870 | |
6871 | list = ctk_notebook_search_page (notebook, list, STEP_NEXT, TRUE(!(0))); |
6872 | if (!list) |
6873 | return; |
6874 | |
6875 | ctk_notebook_switch_page (notebook, CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)); |
6876 | } |
6877 | |
6878 | /** |
6879 | * ctk_notebook_prev_page: |
6880 | * @notebook: a #CtkNotebook |
6881 | * |
6882 | * Switches to the previous page. Nothing happens if the current page |
6883 | * is the first page. |
6884 | */ |
6885 | void |
6886 | ctk_notebook_prev_page (CtkNotebook *notebook) |
6887 | { |
6888 | CtkNotebookPrivate *priv; |
6889 | GList *list; |
6890 | |
6891 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
6892 | |
6893 | priv = notebook->priv; |
6894 | |
6895 | list = g_list_find (priv->children, priv->cur_page); |
6896 | if (!list) |
6897 | return; |
6898 | |
6899 | list = ctk_notebook_search_page (notebook, list, STEP_PREV, TRUE(!(0))); |
6900 | if (!list) |
6901 | return; |
6902 | |
6903 | ctk_notebook_switch_page (notebook, CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)); |
6904 | } |
6905 | |
6906 | /* Public CtkNotebook/Tab Style Functions |
6907 | * |
6908 | * ctk_notebook_set_show_border |
6909 | * ctk_notebook_get_show_border |
6910 | * ctk_notebook_set_show_tabs |
6911 | * ctk_notebook_get_show_tabs |
6912 | * ctk_notebook_set_tab_pos |
6913 | * ctk_notebook_get_tab_pos |
6914 | * ctk_notebook_set_scrollable |
6915 | * ctk_notebook_get_scrollable |
6916 | * ctk_notebook_get_tab_hborder |
6917 | * ctk_notebook_get_tab_vborder |
6918 | */ |
6919 | /** |
6920 | * ctk_notebook_set_show_border: |
6921 | * @notebook: a #CtkNotebook |
6922 | * @show_border: %TRUE if a bevel should be drawn around the notebook |
6923 | * |
6924 | * Sets whether a bevel will be drawn around the notebook pages. |
6925 | * This only has a visual effect when the tabs are not shown. |
6926 | * See ctk_notebook_set_show_tabs(). |
6927 | */ |
6928 | void |
6929 | ctk_notebook_set_show_border (CtkNotebook *notebook, |
6930 | gboolean show_border) |
6931 | { |
6932 | CtkNotebookPrivate *priv; |
6933 | CtkCssNode *node; |
6934 | |
6935 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
6936 | |
6937 | priv = notebook->priv; |
6938 | |
6939 | if (priv->show_border != show_border) |
6940 | { |
6941 | priv->show_border = show_border; |
6942 | |
6943 | node = ctk_widget_get_css_node (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
6944 | if (show_border) |
6945 | ctk_css_node_add_class (node, g_quark_from_static_string (CTK_STYLE_CLASS_FRAME"frame")); |
6946 | else |
6947 | ctk_css_node_remove_class (node, g_quark_from_static_string (CTK_STYLE_CLASS_FRAME"frame")); |
6948 | |
6949 | if (ctk_widget_get_visible (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))))) |
6950 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
6951 | |
6952 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_SHOW_BORDER]); |
6953 | } |
6954 | } |
6955 | |
6956 | /** |
6957 | * ctk_notebook_get_show_border: |
6958 | * @notebook: a #CtkNotebook |
6959 | * |
6960 | * Returns whether a bevel will be drawn around the notebook pages. |
6961 | * See ctk_notebook_set_show_border(). |
6962 | * |
6963 | * Returns: %TRUE if the bevel is drawn |
6964 | */ |
6965 | gboolean |
6966 | ctk_notebook_get_show_border (CtkNotebook *notebook) |
6967 | { |
6968 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return ((0)); } } while (0 ); |
6969 | |
6970 | return notebook->priv->show_border; |
6971 | } |
6972 | |
6973 | /** |
6974 | * ctk_notebook_set_show_tabs: |
6975 | * @notebook: a #CtkNotebook |
6976 | * @show_tabs: %TRUE if the tabs should be shown |
6977 | * |
6978 | * Sets whether to show the tabs for the notebook or not. |
6979 | */ |
6980 | void |
6981 | ctk_notebook_set_show_tabs (CtkNotebook *notebook, |
6982 | gboolean show_tabs) |
6983 | { |
6984 | CtkNotebookPrivate *priv; |
6985 | CtkNotebookPage *page; |
6986 | GList *children; |
6987 | gint i; |
6988 | |
6989 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
6990 | |
6991 | priv = notebook->priv; |
6992 | |
6993 | show_tabs = show_tabs != FALSE(0); |
6994 | |
6995 | if (priv->show_tabs == show_tabs) |
6996 | return; |
6997 | |
6998 | priv->show_tabs = show_tabs; |
6999 | children = priv->children; |
7000 | |
7001 | if (!show_tabs) |
7002 | { |
7003 | ctk_widget_set_can_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), FALSE(0)); |
7004 | |
7005 | while (children) |
7006 | { |
7007 | page = children->data; |
7008 | children = children->next; |
7009 | if (page->default_tab) |
7010 | { |
7011 | ctk_widget_destroy (page->tab_label); |
7012 | page->tab_label = NULL((void*)0); |
7013 | } |
7014 | else |
7015 | ctk_widget_hide (page->tab_label); |
7016 | } |
7017 | ctk_css_gadget_set_visible (priv->header_gadget, |
7018 | ctk_notebook_has_current_page (notebook)); |
7019 | } |
7020 | else |
7021 | { |
7022 | ctk_widget_set_can_focus (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), TRUE(!(0))); |
7023 | ctk_notebook_update_labels (notebook); |
7024 | ctk_css_gadget_set_visible (priv->header_gadget, TRUE(!(0))); |
7025 | } |
7026 | |
7027 | for (i = 0; i < N_ACTION_WIDGETS; i++) |
7028 | { |
7029 | if (priv->action_widget[i]) |
7030 | ctk_widget_set_child_visible (priv->action_widget[i], show_tabs); |
7031 | } |
7032 | |
7033 | ctk_notebook_update_tab_pos (notebook); |
7034 | ctk_widget_reset_style (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7035 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7036 | |
7037 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_SHOW_TABS]); |
7038 | } |
7039 | |
7040 | /** |
7041 | * ctk_notebook_get_show_tabs: |
7042 | * @notebook: a #CtkNotebook |
7043 | * |
7044 | * Returns whether the tabs of the notebook are shown. |
7045 | * See ctk_notebook_set_show_tabs(). |
7046 | * |
7047 | * Returns: %TRUE if the tabs are shown |
7048 | */ |
7049 | gboolean |
7050 | ctk_notebook_get_show_tabs (CtkNotebook *notebook) |
7051 | { |
7052 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return ((0)); } } while (0 ); |
7053 | |
7054 | return notebook->priv->show_tabs; |
7055 | } |
7056 | |
7057 | static void |
7058 | ctk_notebook_update_tab_pos (CtkNotebook *notebook) |
7059 | { |
7060 | CtkNotebookPrivate *priv = notebook->priv; |
7061 | CtkPositionType tab_pos; |
7062 | const char *tab_pos_names[] = { |
7063 | CTK_STYLE_CLASS_LEFT"left", |
7064 | CTK_STYLE_CLASS_RIGHT"right", |
7065 | CTK_STYLE_CLASS_TOP"top", |
7066 | CTK_STYLE_CLASS_BOTTOM"bottom" |
7067 | }; |
7068 | gint i; |
7069 | |
7070 | tab_pos = get_effective_tab_pos (notebook); |
7071 | |
7072 | for (i = 0; i < G_N_ELEMENTS (tab_pos_names)(sizeof (tab_pos_names) / sizeof ((tab_pos_names)[0])); i++) |
7073 | { |
7074 | if (tab_pos == i) |
7075 | ctk_css_gadget_add_class (priv->header_gadget, tab_pos_names[i]); |
7076 | else |
7077 | ctk_css_gadget_remove_class (priv->header_gadget, tab_pos_names[i]); |
7078 | } |
7079 | |
7080 | ctk_box_gadget_remove_gadget (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), priv->header_gadget); |
7081 | switch (tab_pos) |
7082 | { |
7083 | case CTK_POS_TOP: |
7084 | if (priv->show_tabs) |
7085 | ctk_box_gadget_insert_gadget (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), 0, priv->header_gadget, FALSE(0), CTK_ALIGN_FILL); |
7086 | ctk_box_gadget_set_draw_reverse (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), TRUE(!(0))); |
7087 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), CTK_ORIENTATION_VERTICAL); |
7088 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) )), CTK_ORIENTATION_HORIZONTAL); |
7089 | break; |
7090 | |
7091 | case CTK_POS_BOTTOM: |
7092 | if (priv->show_tabs) |
7093 | ctk_box_gadget_insert_gadget (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), 1, priv->header_gadget, FALSE(0), CTK_ALIGN_FILL); |
7094 | ctk_box_gadget_set_draw_reverse (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), FALSE(0)); |
7095 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), CTK_ORIENTATION_VERTICAL); |
7096 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) )), CTK_ORIENTATION_HORIZONTAL); |
7097 | break; |
7098 | |
7099 | case CTK_POS_LEFT: |
7100 | if (priv->show_tabs) |
7101 | ctk_box_gadget_insert_gadget (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), 0, priv->header_gadget, FALSE(0), CTK_ALIGN_FILL); |
7102 | ctk_box_gadget_set_draw_reverse (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), TRUE(!(0))); |
7103 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), CTK_ORIENTATION_HORIZONTAL); |
7104 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) )), CTK_ORIENTATION_VERTICAL); |
7105 | break; |
7106 | |
7107 | case CTK_POS_RIGHT: |
7108 | if (priv->show_tabs) |
7109 | ctk_box_gadget_insert_gadget (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), 1, priv->header_gadget, FALSE(0), CTK_ALIGN_FILL); |
7110 | ctk_box_gadget_set_draw_reverse (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), FALSE(0)); |
7111 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->gadget), ((ctk_box_gadget_get_type ())))))), CTK_ORIENTATION_HORIZONTAL); |
7112 | ctk_box_gadget_set_orientation (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) )), CTK_ORIENTATION_VERTICAL); |
7113 | break; |
7114 | } |
7115 | |
7116 | update_node_ordering (notebook); |
7117 | } |
7118 | |
7119 | /** |
7120 | * ctk_notebook_set_tab_pos: |
7121 | * @notebook: a #CtkNotebook. |
7122 | * @pos: the edge to draw the tabs at |
7123 | * |
7124 | * Sets the edge at which the tabs for switching pages in the |
7125 | * notebook are drawn. |
7126 | */ |
7127 | void |
7128 | ctk_notebook_set_tab_pos (CtkNotebook *notebook, |
7129 | CtkPositionType pos) |
7130 | { |
7131 | CtkNotebookPrivate *priv; |
7132 | |
7133 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7134 | |
7135 | priv = notebook->priv; |
7136 | |
7137 | if (priv->tab_pos != pos) |
7138 | { |
7139 | priv->tab_pos = pos; |
7140 | if (ctk_widget_get_visible (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))))) |
7141 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7142 | |
7143 | ctk_notebook_update_tab_pos (notebook); |
7144 | |
7145 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_TAB_POS]); |
7146 | } |
7147 | } |
7148 | |
7149 | /** |
7150 | * ctk_notebook_get_tab_pos: |
7151 | * @notebook: a #CtkNotebook |
7152 | * |
7153 | * Gets the edge at which the tabs for switching pages in the |
7154 | * notebook are drawn. |
7155 | * |
7156 | * Returns: the edge at which the tabs are drawn |
7157 | */ |
7158 | CtkPositionType |
7159 | ctk_notebook_get_tab_pos (CtkNotebook *notebook) |
7160 | { |
7161 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), CTK_POS_TOP)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (CTK_POS_TOP); } } while (0); |
7162 | |
7163 | return notebook->priv->tab_pos; |
7164 | } |
7165 | |
7166 | /** |
7167 | * ctk_notebook_set_scrollable: |
7168 | * @notebook: a #CtkNotebook |
7169 | * @scrollable: %TRUE if scroll arrows should be added |
7170 | * |
7171 | * Sets whether the tab label area will have arrows for |
7172 | * scrolling if there are too many tabs to fit in the area. |
7173 | */ |
7174 | void |
7175 | ctk_notebook_set_scrollable (CtkNotebook *notebook, |
7176 | gboolean scrollable) |
7177 | { |
7178 | CtkNotebookPrivate *priv; |
7179 | |
7180 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7181 | |
7182 | priv = notebook->priv; |
7183 | |
7184 | scrollable = (scrollable != FALSE(0)); |
7185 | |
7186 | if (priv->scrollable == scrollable) |
7187 | return; |
7188 | |
7189 | priv->scrollable = scrollable; |
7190 | |
7191 | update_arrow_nodes (notebook); |
7192 | update_arrow_state (notebook); |
7193 | |
7194 | if (ctk_widget_get_visible (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))))) |
7195 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7196 | |
7197 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_SCROLLABLE]); |
7198 | } |
7199 | |
7200 | /** |
7201 | * ctk_notebook_get_scrollable: |
7202 | * @notebook: a #CtkNotebook |
7203 | * |
7204 | * Returns whether the tab label area has arrows for scrolling. |
7205 | * See ctk_notebook_set_scrollable(). |
7206 | * |
7207 | * Returns: %TRUE if arrows for scrolling are present |
7208 | */ |
7209 | gboolean |
7210 | ctk_notebook_get_scrollable (CtkNotebook *notebook) |
7211 | { |
7212 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return ((0)); } } while (0 ); |
7213 | |
7214 | return notebook->priv->scrollable; |
7215 | } |
7216 | |
7217 | /** |
7218 | * ctk_notebook_get_tab_hborder: |
7219 | * @notebook: a #CtkNotebook |
7220 | * |
7221 | * Returns the horizontal width of a tab border. |
7222 | * |
7223 | * Returns: horizontal width of a tab border |
7224 | * |
7225 | * Since: 2.22 |
7226 | * |
7227 | * Deprecated: 3.4: this function returns zero |
7228 | */ |
7229 | guint16 |
7230 | ctk_notebook_get_tab_hborder (CtkNotebook *notebook) |
7231 | { |
7232 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return ((0)); } } while (0 ); |
7233 | |
7234 | return 0; |
7235 | } |
7236 | |
7237 | /** |
7238 | * ctk_notebook_get_tab_vborder: |
7239 | * @notebook: a #CtkNotebook |
7240 | * |
7241 | * Returns the vertical width of a tab border. |
7242 | * |
7243 | * Returns: vertical width of a tab border |
7244 | * |
7245 | * Since: 2.22 |
7246 | * |
7247 | * Deprecated: 3.4: this function returns zero |
7248 | */ |
7249 | guint16 |
7250 | ctk_notebook_get_tab_vborder (CtkNotebook *notebook) |
7251 | { |
7252 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return ((0)); } } while (0 ); |
7253 | |
7254 | return 0; |
7255 | } |
7256 | |
7257 | |
7258 | /* Public CtkNotebook Popup Menu Methods: |
7259 | * |
7260 | * ctk_notebook_popup_enable |
7261 | * ctk_notebook_popup_disable |
7262 | */ |
7263 | |
7264 | |
7265 | /** |
7266 | * ctk_notebook_popup_enable: |
7267 | * @notebook: a #CtkNotebook |
7268 | * |
7269 | * Enables the popup menu: if the user clicks with the right |
7270 | * mouse button on the tab labels, a menu with all the pages |
7271 | * will be popped up. |
7272 | */ |
7273 | void |
7274 | ctk_notebook_popup_enable (CtkNotebook *notebook) |
7275 | { |
7276 | CtkNotebookPrivate *priv; |
7277 | GList *list; |
7278 | |
7279 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7280 | |
7281 | priv = notebook->priv; |
7282 | |
7283 | if (priv->menu) |
7284 | return; |
7285 | |
7286 | priv->menu = ctk_menu_new (); |
7287 | ctk_style_context_add_class (ctk_widget_get_style_context (priv->menu), |
7288 | CTK_STYLE_CLASS_CONTEXT_MENU"context-menu"); |
7289 | |
7290 | for (list = ctk_notebook_search_page (notebook, NULL((void*)0), STEP_NEXT, FALSE(0)); |
7291 | list; |
7292 | list = ctk_notebook_search_page (notebook, list, STEP_NEXT, FALSE(0))) |
7293 | ctk_notebook_menu_item_create (notebook, list); |
7294 | |
7295 | ctk_notebook_update_labels (notebook); |
7296 | ctk_menu_attach_to_widget (CTK_MENU (priv->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_menu_get_type ())))))), |
7297 | CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ())))))), |
7298 | ctk_notebook_menu_detacher); |
7299 | |
7300 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_ENABLE_POPUP]); |
7301 | } |
7302 | |
7303 | /** |
7304 | * ctk_notebook_popup_disable: |
7305 | * @notebook: a #CtkNotebook |
7306 | * |
7307 | * Disables the popup menu. |
7308 | */ |
7309 | void |
7310 | ctk_notebook_popup_disable (CtkNotebook *notebook) |
7311 | { |
7312 | CtkNotebookPrivate *priv; |
7313 | |
7314 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7315 | |
7316 | priv = notebook->priv; |
7317 | |
7318 | if (!priv->menu) |
7319 | return; |
7320 | |
7321 | ctk_container_foreach (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_container_get_type ())))))), |
7322 | (CtkCallback) ctk_notebook_menu_label_unparent, NULL((void*)0)); |
7323 | ctk_widget_destroy (priv->menu); |
7324 | |
7325 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_ENABLE_POPUP]); |
7326 | } |
7327 | |
7328 | /* Public CtkNotebook Page Properties Functions: |
7329 | * |
7330 | * ctk_notebook_get_tab_label |
7331 | * ctk_notebook_set_tab_label |
7332 | * ctk_notebook_set_tab_label_text |
7333 | * ctk_notebook_get_menu_label |
7334 | * ctk_notebook_set_menu_label |
7335 | * ctk_notebook_set_menu_label_text |
7336 | * ctk_notebook_get_tab_reorderable |
7337 | * ctk_notebook_set_tab_reorderable |
7338 | * ctk_notebook_get_tab_detachable |
7339 | * ctk_notebook_set_tab_detachable |
7340 | */ |
7341 | |
7342 | /** |
7343 | * ctk_notebook_get_tab_label: |
7344 | * @notebook: a #CtkNotebook |
7345 | * @child: the page |
7346 | * |
7347 | * Returns the tab label widget for the page @child. |
7348 | * %NULL is returned if @child is not in @notebook or |
7349 | * if no tab label has specifically been set for @child. |
7350 | * |
7351 | * Returns: (transfer none) (nullable): the tab label |
7352 | */ |
7353 | CtkWidget * |
7354 | ctk_notebook_get_tab_label (CtkNotebook *notebook, |
7355 | CtkWidget *child) |
7356 | { |
7357 | GList *list; |
7358 | |
7359 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (((void*)0)); } } while (0); |
7360 | g_return_val_if_fail (CTK_IS_WIDGET (child), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (((void*)0)); } } while ( 0); |
7361 | |
7362 | list = ctk_notebook_find_child (notebook, child); |
7363 | g_return_val_if_fail (list != NULL, NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return ( ((void*)0)); } } while (0); |
7364 | |
7365 | if (CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->default_tab) |
7366 | return NULL((void*)0); |
7367 | |
7368 | return CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->tab_label; |
7369 | } |
7370 | |
7371 | /** |
7372 | * ctk_notebook_set_tab_label: |
7373 | * @notebook: a #CtkNotebook |
7374 | * @child: the page |
7375 | * @tab_label: (allow-none): the tab label widget to use, or %NULL |
7376 | * for default tab label |
7377 | * |
7378 | * Changes the tab label for @child. |
7379 | * If %NULL is specified for @tab_label, then the page will |
7380 | * have the label “page N”. |
7381 | */ |
7382 | void |
7383 | ctk_notebook_set_tab_label (CtkNotebook *notebook, |
7384 | CtkWidget *child, |
7385 | CtkWidget *tab_label) |
7386 | { |
7387 | CtkNotebookPrivate *priv; |
7388 | CtkNotebookPage *page; |
7389 | GList *list; |
7390 | |
7391 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7392 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
7393 | |
7394 | priv = notebook->priv; |
7395 | |
7396 | list = ctk_notebook_find_child (notebook, child); |
7397 | g_return_if_fail (list != NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return; } } while (0); |
7398 | |
7399 | /* a NULL pointer indicates a default_tab setting, otherwise |
7400 | * we need to set the associated label |
7401 | */ |
7402 | page = list->data; |
7403 | |
7404 | if (page->tab_label == tab_label) |
7405 | return; |
7406 | |
7407 | ctk_notebook_remove_tab_label (notebook, page); |
7408 | |
7409 | if (tab_label) |
7410 | { |
7411 | page->default_tab = FALSE(0); |
7412 | page->tab_label = tab_label; |
7413 | ctk_css_node_set_parent (ctk_widget_get_css_node (page->tab_label), |
7414 | ctk_css_gadget_get_node (page->gadget)); |
7415 | ctk_widget_set_parent (page->tab_label, CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7416 | } |
7417 | else |
7418 | { |
7419 | page->default_tab = TRUE(!(0)); |
7420 | page->tab_label = NULL((void*)0); |
7421 | |
7422 | if (priv->show_tabs) |
7423 | { |
7424 | gchar string[32]; |
7425 | |
7426 | g_snprintf (string, sizeof(string), _("Page %u")((char *) g_dgettext ("ctk30", "Page %u")), |
7427 | g_list_position (priv->children, list)); |
7428 | page->tab_label = ctk_label_new (string); |
7429 | ctk_css_node_set_parent (ctk_widget_get_css_node (page->tab_label), |
7430 | ctk_css_gadget_get_node (page->gadget)); |
7431 | ctk_widget_set_parent (page->tab_label, CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7432 | } |
7433 | } |
7434 | |
7435 | if (page->tab_label) |
7436 | page->mnemonic_activate_signal = |
7437 | g_signal_connect (page->tab_label,g_signal_connect_data ((page->tab_label), ("mnemonic-activate" ), (((GCallback) (ctk_notebook_mnemonic_activate_switch_page) )), (notebook), ((void*)0), (GConnectFlags) 0) |
7438 | "mnemonic-activate",g_signal_connect_data ((page->tab_label), ("mnemonic-activate" ), (((GCallback) (ctk_notebook_mnemonic_activate_switch_page) )), (notebook), ((void*)0), (GConnectFlags) 0) |
7439 | G_CALLBACK (ctk_notebook_mnemonic_activate_switch_page),g_signal_connect_data ((page->tab_label), ("mnemonic-activate" ), (((GCallback) (ctk_notebook_mnemonic_activate_switch_page) )), (notebook), ((void*)0), (GConnectFlags) 0) |
7440 | notebook)g_signal_connect_data ((page->tab_label), ("mnemonic-activate" ), (((GCallback) (ctk_notebook_mnemonic_activate_switch_page) )), (notebook), ((void*)0), (GConnectFlags) 0); |
7441 | |
7442 | if (priv->show_tabs && ctk_widget_get_visible (child)) |
7443 | { |
7444 | ctk_widget_show (page->tab_label); |
7445 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7446 | } |
7447 | |
7448 | if (priv->menu) |
7449 | ctk_notebook_menu_item_recreate (notebook, list); |
7450 | |
7451 | ctk_widget_child_notify (child, "tab-label"); |
7452 | } |
7453 | |
7454 | /** |
7455 | * ctk_notebook_set_tab_label_text: |
7456 | * @notebook: a #CtkNotebook |
7457 | * @child: the page |
7458 | * @tab_text: the label text |
7459 | * |
7460 | * Creates a new label and sets it as the tab label for the page |
7461 | * containing @child. |
7462 | */ |
7463 | void |
7464 | ctk_notebook_set_tab_label_text (CtkNotebook *notebook, |
7465 | CtkWidget *child, |
7466 | const gchar *tab_text) |
7467 | { |
7468 | CtkWidget *tab_label = NULL((void*)0); |
7469 | |
7470 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7471 | |
7472 | if (tab_text) |
7473 | tab_label = ctk_label_new (tab_text); |
7474 | ctk_notebook_set_tab_label (notebook, child, tab_label); |
7475 | } |
7476 | |
7477 | /** |
7478 | * ctk_notebook_get_tab_label_text: |
7479 | * @notebook: a #CtkNotebook |
7480 | * @child: a widget contained in a page of @notebook |
7481 | * |
7482 | * Retrieves the text of the tab label for the page containing |
7483 | * @child. |
7484 | * |
7485 | * Returns: (nullable): the text of the tab label, or %NULL if the tab label |
7486 | * widget is not a #CtkLabel. The string is owned by the widget and must not be |
7487 | * freed. |
7488 | */ |
7489 | const gchar * |
7490 | ctk_notebook_get_tab_label_text (CtkNotebook *notebook, |
7491 | CtkWidget *child) |
7492 | { |
7493 | CtkWidget *tab_label; |
7494 | |
7495 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (((void*)0)); } } while (0); |
7496 | g_return_val_if_fail (CTK_IS_WIDGET (child), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (((void*)0)); } } while ( 0); |
7497 | |
7498 | tab_label = ctk_notebook_get_tab_label (notebook, child); |
7499 | |
7500 | if (CTK_IS_LABEL (tab_label)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (tab_label)); GType __t = ((ctk_label_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; }))))) |
7501 | return ctk_label_get_text (CTK_LABEL (tab_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab_label)), ((ctk_label_get_type ()))))))); |
7502 | else |
7503 | return NULL((void*)0); |
7504 | } |
7505 | |
7506 | /** |
7507 | * ctk_notebook_get_menu_label: |
7508 | * @notebook: a #CtkNotebook |
7509 | * @child: a widget contained in a page of @notebook |
7510 | * |
7511 | * Retrieves the menu label widget of the page containing @child. |
7512 | * |
7513 | * Returns: (nullable) (transfer none): the menu label, or %NULL if the |
7514 | * notebook page does not have a menu label other than the default (the tab |
7515 | * label). |
7516 | */ |
7517 | CtkWidget* |
7518 | ctk_notebook_get_menu_label (CtkNotebook *notebook, |
7519 | CtkWidget *child) |
7520 | { |
7521 | GList *list; |
7522 | |
7523 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (((void*)0)); } } while (0); |
7524 | g_return_val_if_fail (CTK_IS_WIDGET (child), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (((void*)0)); } } while ( 0); |
7525 | |
7526 | list = ctk_notebook_find_child (notebook, child); |
7527 | g_return_val_if_fail (list != NULL, NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return ( ((void*)0)); } } while (0); |
7528 | |
7529 | if (CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->default_menu) |
7530 | return NULL((void*)0); |
7531 | |
7532 | return CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->menu_label; |
7533 | } |
7534 | |
7535 | /** |
7536 | * ctk_notebook_set_menu_label: |
7537 | * @notebook: a #CtkNotebook |
7538 | * @child: the child widget |
7539 | * @menu_label: (allow-none): the menu label, or %NULL for default |
7540 | * |
7541 | * Changes the menu label for the page containing @child. |
7542 | */ |
7543 | void |
7544 | ctk_notebook_set_menu_label (CtkNotebook *notebook, |
7545 | CtkWidget *child, |
7546 | CtkWidget *menu_label) |
7547 | { |
7548 | CtkNotebookPrivate *priv; |
7549 | CtkNotebookPage *page; |
7550 | GList *list; |
7551 | |
7552 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7553 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
7554 | |
7555 | priv = notebook->priv; |
7556 | |
7557 | list = ctk_notebook_find_child (notebook, child); |
7558 | g_return_if_fail (list != NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return; } } while (0); |
7559 | |
7560 | page = list->data; |
7561 | if (page->menu_label) |
7562 | { |
7563 | if (priv->menu) |
7564 | ctk_container_remove (CTK_CONTAINER (priv->menu)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->menu)), ((ctk_container_get_type ())))))), |
7565 | ctk_widget_get_parent (page->menu_label)); |
7566 | |
7567 | if (!page->default_menu) |
7568 | g_object_unref (page->menu_label); |
7569 | } |
7570 | |
7571 | if (menu_label) |
7572 | { |
7573 | page->menu_label = menu_label; |
7574 | g_object_ref_sink (page->menu_label)((__typeof__ (page->menu_label)) (g_object_ref_sink) (page ->menu_label)); |
7575 | page->default_menu = FALSE(0); |
7576 | } |
7577 | else |
7578 | page->default_menu = TRUE(!(0)); |
7579 | |
7580 | if (priv->menu) |
7581 | ctk_notebook_menu_item_create (notebook, list); |
7582 | ctk_widget_child_notify (child, "menu-label"); |
7583 | } |
7584 | |
7585 | /** |
7586 | * ctk_notebook_set_menu_label_text: |
7587 | * @notebook: a #CtkNotebook |
7588 | * @child: the child widget |
7589 | * @menu_text: the label text |
7590 | * |
7591 | * Creates a new label and sets it as the menu label of @child. |
7592 | */ |
7593 | void |
7594 | ctk_notebook_set_menu_label_text (CtkNotebook *notebook, |
7595 | CtkWidget *child, |
7596 | const gchar *menu_text) |
7597 | { |
7598 | CtkWidget *menu_label = NULL((void*)0); |
7599 | |
7600 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7601 | |
7602 | if (menu_text) |
7603 | { |
7604 | menu_label = ctk_label_new (menu_text); |
7605 | ctk_widget_set_halign (menu_label, CTK_ALIGN_START); |
7606 | ctk_widget_set_valign (menu_label, CTK_ALIGN_CENTER); |
7607 | } |
7608 | ctk_notebook_set_menu_label (notebook, child, menu_label); |
7609 | ctk_widget_child_notify (child, "menu-label"); |
7610 | } |
7611 | |
7612 | /** |
7613 | * ctk_notebook_get_menu_label_text: |
7614 | * @notebook: a #CtkNotebook |
7615 | * @child: the child widget of a page of the notebook. |
7616 | * |
7617 | * Retrieves the text of the menu label for the page containing |
7618 | * @child. |
7619 | * |
7620 | * Returns: (nullable): the text of the tab label, or %NULL if the widget does |
7621 | * not have a menu label other than the default menu label, or the menu label |
7622 | * widget is not a #CtkLabel. The string is owned by the widget and must not be |
7623 | * freed. |
7624 | */ |
7625 | const gchar * |
7626 | ctk_notebook_get_menu_label_text (CtkNotebook *notebook, |
7627 | CtkWidget *child) |
7628 | { |
7629 | CtkWidget *menu_label; |
7630 | |
7631 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (((void*)0)); } } while (0); |
7632 | g_return_val_if_fail (CTK_IS_WIDGET (child), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return (((void*)0)); } } while ( 0); |
7633 | |
7634 | menu_label = ctk_notebook_get_menu_label (notebook, child); |
7635 | |
7636 | if (CTK_IS_LABEL (menu_label)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (menu_label)); GType __t = ((ctk_label_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; }))))) |
7637 | return ctk_label_get_text (CTK_LABEL (menu_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu_label)), ((ctk_label_get_type ()))))))); |
7638 | else |
7639 | return NULL((void*)0); |
7640 | } |
7641 | |
7642 | /* Helper function called when pages are reordered |
7643 | */ |
7644 | static void |
7645 | ctk_notebook_child_reordered (CtkNotebook *notebook, |
7646 | CtkNotebookPage *page) |
7647 | { |
7648 | CtkNotebookPrivate *priv = notebook->priv; |
7649 | GList *list; |
7650 | CtkCssNode *sibling; |
7651 | |
7652 | list = g_list_find (priv->children, page); |
7653 | |
7654 | if (priv->menu) |
7655 | ctk_notebook_menu_item_recreate (notebook, list); |
7656 | |
7657 | if (list->prev) |
7658 | sibling = ctk_css_gadget_get_node (CTK_NOTEBOOK_PAGE (list->prev)((CtkNotebookPage *)(list->prev)->data)->gadget); |
7659 | else if (priv->arrow_gadget[ARROW_RIGHT_BEFORE]) |
7660 | sibling = ctk_css_gadget_get_node (priv->arrow_gadget[ARROW_RIGHT_BEFORE]); |
7661 | else if (priv->arrow_gadget[ARROW_LEFT_BEFORE]) |
7662 | sibling = ctk_css_gadget_get_node (priv->arrow_gadget[ARROW_LEFT_BEFORE]); |
7663 | else |
7664 | sibling = NULL((void*)0); |
7665 | |
7666 | ctk_css_node_insert_after (ctk_css_gadget_get_node (priv->tabs_gadget), |
7667 | ctk_css_gadget_get_node (page->gadget), |
7668 | sibling); |
7669 | ctk_notebook_update_labels (notebook); |
7670 | ctk_css_gadget_queue_allocate (priv->tabs_gadget); |
7671 | } |
7672 | |
7673 | static void |
7674 | ctk_notebook_set_tab_label_packing (CtkNotebook *notebook, |
7675 | CtkWidget *child, |
7676 | gboolean expand, |
7677 | gboolean fill) |
7678 | { |
7679 | CtkNotebookPrivate *priv; |
7680 | CtkNotebookPage *page; |
7681 | GList *list; |
7682 | |
7683 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7684 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
7685 | |
7686 | priv = notebook->priv; |
7687 | |
7688 | list = ctk_notebook_find_child (notebook, child); |
7689 | g_return_if_fail (list != NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return; } } while (0); |
7690 | |
7691 | page = list->data; |
7692 | expand = expand != FALSE(0); |
7693 | fill = fill != FALSE(0); |
7694 | if (page->expand == expand && page->fill == fill) |
7695 | return; |
7696 | |
7697 | ctk_widget_freeze_child_notify (child); |
7698 | page->expand = expand; |
7699 | ctk_widget_child_notify (child, "tab-expand"); |
7700 | page->fill = fill; |
7701 | ctk_widget_child_notify (child, "tab-fill"); |
7702 | ctk_widget_child_notify (child, "position"); |
7703 | if (priv->show_tabs) |
7704 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
7705 | ctk_widget_thaw_child_notify (child); |
7706 | } |
7707 | |
7708 | static void |
7709 | ctk_notebook_query_tab_label_packing (CtkNotebook *notebook, |
7710 | CtkWidget *child, |
7711 | gboolean *expand, |
7712 | gboolean *fill) |
7713 | { |
7714 | GList *list; |
7715 | |
7716 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7717 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
7718 | |
7719 | list = ctk_notebook_find_child (notebook, child); |
7720 | g_return_if_fail (list != NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return; } } while (0); |
7721 | |
7722 | if (expand) |
7723 | *expand = CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->expand; |
7724 | if (fill) |
7725 | *fill = CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->fill; |
7726 | } |
7727 | |
7728 | /** |
7729 | * ctk_notebook_reorder_child: |
7730 | * @notebook: a #CtkNotebook |
7731 | * @child: the child to move |
7732 | * @position: the new position, or -1 to move to the end |
7733 | * |
7734 | * Reorders the page containing @child, so that it appears in position |
7735 | * @position. If @position is greater than or equal to the number of |
7736 | * children in the list or negative, @child will be moved to the end |
7737 | * of the list. |
7738 | */ |
7739 | void |
7740 | ctk_notebook_reorder_child (CtkNotebook *notebook, |
7741 | CtkWidget *child, |
7742 | gint position) |
7743 | { |
7744 | CtkNotebookPrivate *priv; |
7745 | GList *list, *new_list; |
7746 | CtkNotebookPage *page; |
7747 | gint old_pos; |
7748 | gint max_pos; |
7749 | gint i; |
7750 | |
7751 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7752 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
7753 | |
7754 | priv = notebook->priv; |
7755 | |
7756 | list = ctk_notebook_find_child (notebook, child); |
7757 | g_return_if_fail (list != NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return; } } while (0); |
7758 | |
7759 | max_pos = g_list_length (priv->children) - 1; |
7760 | if (position < 0 || position > max_pos) |
7761 | position = max_pos; |
7762 | |
7763 | old_pos = g_list_position (priv->children, list); |
7764 | |
7765 | if (old_pos == position) |
7766 | return; |
7767 | |
7768 | page = list->data; |
7769 | priv->children = g_list_delete_link (priv->children, list); |
7770 | |
7771 | priv->children = g_list_insert (priv->children, page, position); |
7772 | new_list = g_list_nth (priv->children, position); |
7773 | |
7774 | /* Fix up GList references in CtkNotebook structure */ |
7775 | if (priv->first_tab == list) |
7776 | priv->first_tab = new_list; |
7777 | if (priv->focus_tab == list) |
7778 | priv->focus_tab = new_list; |
7779 | |
7780 | ctk_widget_freeze_child_notify (child); |
7781 | |
7782 | /* Move around the menu items if necessary */ |
7783 | ctk_notebook_child_reordered (notebook, page); |
7784 | |
7785 | for (list = priv->children, i = 0; list; list = list->next, i++) |
7786 | { |
7787 | if (MIN (old_pos, position)(((old_pos) < (position)) ? (old_pos) : (position)) <= i && i <= MAX (old_pos, position)(((old_pos) > (position)) ? (old_pos) : (position))) |
7788 | ctk_widget_child_notify (((CtkNotebookPage *) list->data)->child, "position"); |
7789 | } |
7790 | |
7791 | ctk_widget_thaw_child_notify (child); |
7792 | |
7793 | g_signal_emit (notebook, |
7794 | notebook_signals[PAGE_REORDERED], |
7795 | 0, |
7796 | child, |
7797 | position); |
7798 | } |
7799 | |
7800 | /** |
7801 | * ctk_notebook_set_group_name: |
7802 | * @notebook: a #CtkNotebook |
7803 | * @group_name: (allow-none): the name of the notebook group, |
7804 | * or %NULL to unset it |
7805 | * |
7806 | * Sets a group name for @notebook. |
7807 | * |
7808 | * Notebooks with the same name will be able to exchange tabs |
7809 | * via drag and drop. A notebook with a %NULL group name will |
7810 | * not be able to exchange tabs with any other notebook. |
7811 | * |
7812 | * Since: 2.24 |
7813 | */ |
7814 | void |
7815 | ctk_notebook_set_group_name (CtkNotebook *notebook, |
7816 | const gchar *group_name) |
7817 | { |
7818 | CtkNotebookPrivate *priv; |
7819 | GQuark group; |
7820 | |
7821 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7822 | |
7823 | priv = notebook->priv; |
7824 | |
7825 | group = g_quark_from_string (group_name); |
7826 | |
7827 | if (priv->group != group) |
7828 | { |
7829 | priv->group = group; |
7830 | |
7831 | g_object_notify_by_pspec (G_OBJECT (notebook)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), (((GType) ((20) << (2)))))))), properties[PROP_GROUP_NAME]); |
7832 | } |
7833 | } |
7834 | |
7835 | /** |
7836 | * ctk_notebook_get_group_name: |
7837 | * @notebook: a #CtkNotebook |
7838 | * |
7839 | * Gets the current group name for @notebook. |
7840 | * |
7841 | * Returns: (nullable) (transfer none): the group name, or %NULL if none is set |
7842 | * |
7843 | * Since: 2.24 |
7844 | */ |
7845 | const gchar * |
7846 | ctk_notebook_get_group_name (CtkNotebook *notebook) |
7847 | { |
7848 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (((void*)0)); } } while (0); |
7849 | |
7850 | return g_quark_to_string (notebook->priv->group); |
7851 | } |
7852 | |
7853 | /** |
7854 | * ctk_notebook_get_tab_reorderable: |
7855 | * @notebook: a #CtkNotebook |
7856 | * @child: a child #CtkWidget |
7857 | * |
7858 | * Gets whether the tab can be reordered via drag and drop or not. |
7859 | * |
7860 | * Returns: %TRUE if the tab is reorderable. |
7861 | * |
7862 | * Since: 2.10 |
7863 | */ |
7864 | gboolean |
7865 | ctk_notebook_get_tab_reorderable (CtkNotebook *notebook, |
7866 | CtkWidget *child) |
7867 | { |
7868 | GList *list; |
7869 | |
7870 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return ((0)); } } while (0 ); |
7871 | g_return_val_if_fail (CTK_IS_WIDGET (child), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return ((0)); } } while (0); |
7872 | |
7873 | list = ctk_notebook_find_child (notebook, child); |
7874 | g_return_val_if_fail (list != NULL, FALSE)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return ( (0)); } } while (0); |
7875 | |
7876 | return CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->reorderable; |
7877 | } |
7878 | |
7879 | /** |
7880 | * ctk_notebook_set_tab_reorderable: |
7881 | * @notebook: a #CtkNotebook |
7882 | * @child: a child #CtkWidget |
7883 | * @reorderable: whether the tab is reorderable or not |
7884 | * |
7885 | * Sets whether the notebook tab can be reordered |
7886 | * via drag and drop or not. |
7887 | * |
7888 | * Since: 2.10 |
7889 | */ |
7890 | void |
7891 | ctk_notebook_set_tab_reorderable (CtkNotebook *notebook, |
7892 | CtkWidget *child, |
7893 | gboolean reorderable) |
7894 | { |
7895 | CtkNotebookPage *page; |
7896 | GList *list; |
7897 | |
7898 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
7899 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
7900 | |
7901 | list = ctk_notebook_find_child (notebook, child); |
7902 | g_return_if_fail (list != NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return; } } while (0); |
7903 | |
7904 | page = CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data); |
7905 | reorderable = reorderable != FALSE(0); |
7906 | |
7907 | if (page->reorderable != reorderable) |
7908 | { |
7909 | page->reorderable = reorderable; |
7910 | if (reorderable) |
7911 | ctk_css_gadget_add_class (page->gadget, "reorderable-page"); |
7912 | else |
7913 | ctk_css_gadget_remove_class (page->gadget, "reorderable-page"); |
7914 | ctk_widget_child_notify (child, "reorderable"); |
7915 | } |
7916 | } |
7917 | |
7918 | /** |
7919 | * ctk_notebook_get_tab_detachable: |
7920 | * @notebook: a #CtkNotebook |
7921 | * @child: a child #CtkWidget |
7922 | * |
7923 | * Returns whether the tab contents can be detached from @notebook. |
7924 | * |
7925 | * Returns: %TRUE if the tab is detachable. |
7926 | * |
7927 | * Since: 2.10 |
7928 | */ |
7929 | gboolean |
7930 | ctk_notebook_get_tab_detachable (CtkNotebook *notebook, |
7931 | CtkWidget *child) |
7932 | { |
7933 | GList *list; |
7934 | |
7935 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return ((0)); } } while (0 ); |
7936 | g_return_val_if_fail (CTK_IS_WIDGET (child), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return ((0)); } } while (0); |
7937 | |
7938 | list = ctk_notebook_find_child (notebook, child); |
7939 | g_return_val_if_fail (list != NULL, FALSE)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return ( (0)); } } while (0); |
7940 | |
7941 | return CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->detachable; |
7942 | } |
7943 | |
7944 | /** |
7945 | * ctk_notebook_set_tab_detachable: |
7946 | * @notebook: a #CtkNotebook |
7947 | * @child: a child #CtkWidget |
7948 | * @detachable: whether the tab is detachable or not |
7949 | * |
7950 | * Sets whether the tab can be detached from @notebook to another |
7951 | * notebook or widget. |
7952 | * |
7953 | * Note that 2 notebooks must share a common group identificator |
7954 | * (see ctk_notebook_set_group_name()) to allow automatic tabs |
7955 | * interchange between them. |
7956 | * |
7957 | * If you want a widget to interact with a notebook through DnD |
7958 | * (i.e.: accept dragged tabs from it) it must be set as a drop |
7959 | * destination and accept the target “CTK_NOTEBOOK_TAB”. The notebook |
7960 | * will fill the selection with a CtkWidget** pointing to the child |
7961 | * widget that corresponds to the dropped tab. |
7962 | * |
7963 | * Note that you should use ctk_notebook_detach_tab() instead |
7964 | * of ctk_container_remove() if you want to remove the tab from |
7965 | * the source notebook as part of accepting a drop. Otherwise, |
7966 | * the source notebook will think that the dragged tab was |
7967 | * removed from underneath the ongoing drag operation, and |
7968 | * will initiate a drag cancel animation. |
7969 | * |
7970 | * |[<!-- language="C" --> |
7971 | * static void |
7972 | * on_drag_data_received (CtkWidget *widget, |
7973 | * CdkDragContext *context, |
7974 | * gint x, |
7975 | * gint y, |
7976 | * CtkSelectionData *data, |
7977 | * guint info, |
7978 | * guint time, |
7979 | * gpointer user_data) |
7980 | * { |
7981 | * CtkWidget *notebook; |
7982 | * CtkWidget **child; |
7983 | * |
7984 | * notebook = ctk_drag_get_source_widget (context); |
7985 | * child = (void*) ctk_selection_data_get_data (data); |
7986 | * |
7987 | * // process_widget (*child); |
7988 | * |
7989 | * ctk_notebook_detach_tab (CTK_NOTEBOOK (notebook), *child); |
7990 | * } |
7991 | * ]| |
7992 | * |
7993 | * If you want a notebook to accept drags from other widgets, |
7994 | * you will have to set your own DnD code to do it. |
7995 | * |
7996 | * Since: 2.10 |
7997 | */ |
7998 | void |
7999 | ctk_notebook_set_tab_detachable (CtkNotebook *notebook, |
8000 | CtkWidget *child, |
8001 | gboolean detachable) |
8002 | { |
8003 | GList *list; |
8004 | |
8005 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
8006 | g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((child)); 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 (child)"); return; } } while (0); |
8007 | |
8008 | list = ctk_notebook_find_child (notebook, child); |
8009 | g_return_if_fail (list != NULL)do { if ((list != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "list != NULL"); return; } } while (0); |
8010 | |
8011 | detachable = detachable != FALSE(0); |
8012 | |
8013 | if (CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->detachable != detachable) |
8014 | { |
8015 | CTK_NOTEBOOK_PAGE (list)((CtkNotebookPage *)(list)->data)->detachable = detachable; |
8016 | ctk_widget_child_notify (child, "detachable"); |
8017 | } |
8018 | } |
8019 | |
8020 | /** |
8021 | * ctk_notebook_get_action_widget: |
8022 | * @notebook: a #CtkNotebook |
8023 | * @pack_type: pack type of the action widget to receive |
8024 | * |
8025 | * Gets one of the action widgets. See ctk_notebook_set_action_widget(). |
8026 | * |
8027 | * Returns: (nullable) (transfer none): The action widget with the given |
8028 | * @pack_type or %NULL when this action widget has not been set |
8029 | * |
8030 | * Since: 2.20 |
8031 | */ |
8032 | CtkWidget* |
8033 | ctk_notebook_get_action_widget (CtkNotebook *notebook, |
8034 | CtkPackType pack_type) |
8035 | { |
8036 | g_return_val_if_fail (CTK_IS_NOTEBOOK (notebook), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return (((void*)0)); } } while (0); |
8037 | |
8038 | return notebook->priv->action_widget[pack_type]; |
8039 | } |
8040 | |
8041 | /** |
8042 | * ctk_notebook_set_action_widget: |
8043 | * @notebook: a #CtkNotebook |
8044 | * @widget: a #CtkWidget |
8045 | * @pack_type: pack type of the action widget |
8046 | * |
8047 | * Sets @widget as one of the action widgets. Depending on the pack type |
8048 | * the widget will be placed before or after the tabs. You can use |
8049 | * a #CtkBox if you need to pack more than one widget on the same side. |
8050 | * |
8051 | * Note that action widgets are “internal” children of the notebook and thus |
8052 | * not included in the list returned from ctk_container_foreach(). |
8053 | * |
8054 | * Since: 2.20 |
8055 | */ |
8056 | void |
8057 | ctk_notebook_set_action_widget (CtkNotebook *notebook, |
8058 | CtkWidget *widget, |
8059 | CtkPackType pack_type) |
8060 | { |
8061 | CtkNotebookPrivate *priv; |
8062 | |
8063 | g_return_if_fail (CTK_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((ctk_notebook_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_NOTEBOOK (notebook)"); return; } } while (0); |
8064 | g_return_if_fail (!widget || CTK_IS_WIDGET (widget))do { if ((!widget || (((__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__)), "!widget || CTK_IS_WIDGET (widget)"); return ; } } while (0); |
8065 | g_return_if_fail (!widget || ctk_widget_get_parent (widget) == NULL)do { if ((!widget || ctk_widget_get_parent (widget) == ((void *)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "!widget || ctk_widget_get_parent (widget) == NULL" ); return; } } while (0); |
8066 | |
8067 | priv = notebook->priv; |
8068 | |
8069 | if (priv->action_widget[pack_type]) |
8070 | { |
8071 | ctk_box_gadget_remove_widget (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) )), |
8072 | priv->action_widget[pack_type]); |
8073 | ctk_widget_unparent (priv->action_widget[pack_type]); |
8074 | } |
8075 | |
8076 | priv->action_widget[pack_type] = widget; |
8077 | |
8078 | if (widget) |
8079 | { |
8080 | int pos; |
8081 | |
8082 | ctk_css_node_set_parent (ctk_widget_get_css_node (widget), |
8083 | ctk_css_gadget_get_node (priv->header_gadget)); |
8084 | |
8085 | if (priv->tabs_reversed) |
8086 | pos = pack_type == CTK_PACK_START ? -1 : 0; |
8087 | else |
8088 | pos = pack_type == CTK_PACK_START ? 0 : -1; |
8089 | |
8090 | ctk_box_gadget_insert_widget (CTK_BOX_GADGET (priv->header_gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance *) (priv->header_gadget), ((ctk_box_gadget_get_type ())))) )), pos, widget); |
8091 | ctk_widget_set_child_visible (widget, priv->show_tabs); |
8092 | ctk_widget_set_parent (widget, CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
8093 | } |
8094 | |
8095 | ctk_widget_queue_resize (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
8096 | } |