File: | src/baul-notebook.c |
Warning: | line 372, column 5 Value stored to 'position' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
2 | /* |
3 | * Copyright © 2002 Christophe Fergeau |
4 | * Copyright © 2003, 2004 Marco Pesenti Gritti |
5 | * Copyright © 2003, 2004, 2005 Christian Persch |
6 | * (ephy-notebook.c) |
7 | * |
8 | * Copyright © 2008 Free Software Foundation, Inc. |
9 | * (baul-notebook.c) |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2, or (at your option) |
14 | * any later version. |
15 | * |
16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 | * |
25 | */ |
26 | |
27 | #include <config.h> |
28 | |
29 | #include <glib/gi18n.h> |
30 | #include <gio/gio.h> |
31 | #include <ctk/ctk.h> |
32 | |
33 | #include <libbaul-private/baul-dnd.h> |
34 | |
35 | #include "baul-notebook.h" |
36 | #include "baul-navigation-window.h" |
37 | #include "baul-window-manage-views.h" |
38 | #include "baul-window-private.h" |
39 | #include "baul-window-slot.h" |
40 | #include "baul-navigation-window-pane.h" |
41 | |
42 | #define AFTER_ALL_TABS-1 -1 |
43 | |
44 | static int baul_notebook_insert_page (CtkNotebook *notebook, |
45 | CtkWidget *child, |
46 | CtkWidget *tab_label, |
47 | CtkWidget *menu_label, |
48 | int position); |
49 | static void baul_notebook_remove (CtkContainer *container, |
50 | CtkWidget *tab_widget); |
51 | |
52 | enum |
53 | { |
54 | TAB_CLOSE_REQUEST, |
55 | LAST_SIGNAL |
56 | }; |
57 | |
58 | static guint signals[LAST_SIGNAL] = { 0 }; |
59 | |
60 | G_DEFINE_TYPE (BaulNotebook, baul_notebook, CTK_TYPE_NOTEBOOK)static void baul_notebook_init (BaulNotebook *self); static void baul_notebook_class_init (BaulNotebookClass *klass); static GType baul_notebook_get_type_once (void); static gpointer baul_notebook_parent_class = ((void*)0); static gint BaulNotebook_private_offset; static void baul_notebook_class_intern_init (gpointer klass) { baul_notebook_parent_class = g_type_class_peek_parent (klass); if (BaulNotebook_private_offset != 0) g_type_class_adjust_private_offset (klass, &BaulNotebook_private_offset ); baul_notebook_class_init ((BaulNotebookClass*) klass); } __attribute__ ((__unused__)) static inline gpointer baul_notebook_get_instance_private (BaulNotebook *self) { return (((gpointer) ((guint8*) (self) + (glong) (BaulNotebook_private_offset)))); } GType baul_notebook_get_type (void) { static gsize 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 (&static_g_define_type_id )); }))) { GType g_define_type_id = baul_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 ((&static_g_define_type_id ), (gsize) (g_define_type_id)); })); } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType baul_notebook_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_notebook_get_type ()), g_intern_static_string ("BaulNotebook" ), sizeof (BaulNotebookClass), (GClassInitFunc)(void (*)(void )) baul_notebook_class_intern_init, sizeof (BaulNotebook), (GInstanceInitFunc )(void (*)(void)) baul_notebook_init, (GTypeFlags) 0); { {{}; } } return g_define_type_id; }; |
61 | |
62 | static void |
63 | baul_notebook_class_init (BaulNotebookClass *klass) |
64 | { |
65 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
66 | CtkContainerClass *container_class = CTK_CONTAINER_CLASS (klass)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_container_get_type ())))))); |
67 | CtkNotebookClass *notebook_class = CTK_NOTEBOOK_CLASS (klass)((((CtkNotebookClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_notebook_get_type ())))))); |
68 | |
69 | container_class->remove = baul_notebook_remove; |
70 | |
71 | notebook_class->insert_page = baul_notebook_insert_page; |
72 | |
73 | signals[TAB_CLOSE_REQUEST] = |
74 | g_signal_new ("tab-close-request", |
75 | G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)), |
76 | G_SIGNAL_RUN_LAST, |
77 | G_STRUCT_OFFSET (BaulNotebookClass, tab_close_request)((glong) __builtin_offsetof(BaulNotebookClass, tab_close_request )), |
78 | NULL((void*)0), NULL((void*)0), |
79 | g_cclosure_marshal_VOID__OBJECT, |
80 | G_TYPE_NONE((GType) ((1) << (2))), |
81 | 1, |
82 | BAUL_TYPE_WINDOW_SLOT(baul_window_slot_get_type())); |
83 | } |
84 | |
85 | static gint |
86 | find_tab_num_at_pos (BaulNotebook *notebook, gint abs_x, gint abs_y) |
87 | { |
88 | CtkPositionType tab_pos; |
89 | int page_num = 0; |
90 | CtkNotebook *nb = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))); |
91 | CtkWidget *page; |
92 | CtkAllocation allocation; |
93 | |
94 | tab_pos = ctk_notebook_get_tab_pos (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ()))))))); |
95 | |
96 | while ((page = ctk_notebook_get_nth_page (nb, page_num))) |
97 | { |
98 | CtkWidget *tab; |
99 | gint max_x, max_y; |
100 | gint x_root, y_root; |
101 | |
102 | tab = ctk_notebook_get_tab_label (nb, page); |
103 | g_return_val_if_fail (tab != NULL, -1)do { if ((tab != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "tab != NULL"); return (-1); } } while (0); |
104 | |
105 | if (!ctk_widget_get_mapped (CTK_WIDGET (tab)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tab)), ((ctk_widget_get_type ())))))))) |
106 | { |
107 | page_num++; |
108 | continue; |
109 | } |
110 | |
111 | cdk_window_get_origin (ctk_widget_get_window (tab), |
112 | &x_root, &y_root); |
113 | ctk_widget_get_allocation (tab, &allocation); |
114 | |
115 | max_x = x_root + allocation.x + allocation.width; |
116 | max_y = y_root + allocation.y + allocation.height; |
117 | |
118 | if (((tab_pos == CTK_POS_TOP) |
119 | || (tab_pos == CTK_POS_BOTTOM)) |
120 | &&(abs_x<=max_x)) |
121 | { |
122 | return page_num; |
123 | } |
124 | else if (((tab_pos == CTK_POS_LEFT) |
125 | || (tab_pos == CTK_POS_RIGHT)) |
126 | && (abs_y<=max_y)) |
127 | { |
128 | return page_num; |
129 | } |
130 | |
131 | page_num++; |
132 | } |
133 | return AFTER_ALL_TABS-1; |
134 | } |
135 | |
136 | static gboolean |
137 | button_press_cb (BaulNotebook *notebook, |
138 | CdkEventButton *event, |
139 | gpointer data) |
140 | { |
141 | int tab_clicked; |
142 | |
143 | tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root); |
144 | |
145 | if (event->type == CDK_BUTTON_PRESS && |
146 | (event->button == 3 || event->button == 2) && |
147 | (event->state & ctk_accelerator_get_default_mod_mask ()) == 0) |
148 | { |
149 | if (tab_clicked == -1) |
150 | { |
151 | /* consume event, so that we don't pop up the context menu when |
152 | * the mouse if not over a tab label |
153 | */ |
154 | return TRUE(!(0)); |
155 | } |
156 | |
157 | /* switch to the page the mouse is over, but don't consume the event */ |
158 | ctk_notebook_set_current_page (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), tab_clicked); |
159 | } |
160 | |
161 | return FALSE(0); |
162 | } |
163 | |
164 | static void |
165 | baul_notebook_init (BaulNotebook *notebook) |
166 | { |
167 | CtkStyleContext *context; |
168 | |
169 | context = ctk_widget_get_style_context (CTK_WIDGET (notebook)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_widget_get_type ()))))))); |
170 | ctk_style_context_add_class (context, "baul-notebook"); |
171 | |
172 | ctk_notebook_set_scrollable (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), TRUE(!(0))); |
173 | ctk_notebook_set_show_border (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), FALSE(0)); |
174 | ctk_notebook_set_show_tabs (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), FALSE(0)); |
175 | |
176 | g_signal_connect (notebook, "button-press-event",g_signal_connect_data ((notebook), ("button-press-event"), (( GCallback)button_press_cb), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
177 | (GCallback)button_press_cb, NULL)g_signal_connect_data ((notebook), ("button-press-event"), (( GCallback)button_press_cb), (((void*)0)), ((void*)0), (GConnectFlags ) 0); |
178 | } |
179 | |
180 | void |
181 | baul_notebook_sync_loading (BaulNotebook *notebook, |
182 | BaulWindowSlot *slot) |
183 | { |
184 | CtkWidget *tab_label, *spinner, *icon; |
185 | gboolean active; |
186 | |
187 | g_return_if_fail (BAUL_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((baul_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_NOTEBOOK (notebook)"); return; } } while (0); |
188 | g_return_if_fail (BAUL_IS_WINDOW_SLOT (slot))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((slot)); GType __t = ((baul_window_slot_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"); return; } } while (0); |
189 | |
190 | tab_label = ctk_notebook_get_tab_label (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), slot->content_box); |
191 | g_return_if_fail (CTK_IS_WIDGET (tab_label))do { if (((((__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 (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (tab_label)"); return; } } while (0); |
192 | |
193 | spinner = CTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "spinner"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((tab_label)), (((GType) ((20) << (2 )))))))), "spinner"))), ((ctk_widget_get_type ())))))); |
194 | icon = CTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "icon"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((tab_label)), (((GType) ((20) << (2 )))))))), "icon"))), ((ctk_widget_get_type ())))))); |
195 | g_return_if_fail (spinner != NULL && icon != NULL)do { if ((spinner != ((void*)0) && icon != ((void*)0) )) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "spinner != NULL && icon != NULL" ); return; } } while (0); |
196 | |
197 | active = FALSE(0); |
198 | g_object_get (spinner, "active", &active, NULL((void*)0)); |
199 | if (active == slot->allow_stop) |
200 | { |
201 | return; |
202 | } |
203 | |
204 | if (slot->allow_stop) |
205 | { |
206 | ctk_widget_hide (icon); |
207 | ctk_widget_show (spinner); |
208 | ctk_spinner_start (CTK_SPINNER (spinner)((((CtkSpinner*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((spinner)), ((ctk_spinner_get_type ()))))))); |
209 | } |
210 | else |
211 | { |
212 | ctk_spinner_stop (CTK_SPINNER (spinner)((((CtkSpinner*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((spinner)), ((ctk_spinner_get_type ()))))))); |
213 | ctk_widget_hide (spinner); |
214 | ctk_widget_show (icon); |
215 | } |
216 | } |
217 | |
218 | void |
219 | baul_notebook_sync_tab_label (BaulNotebook *notebook, |
220 | BaulWindowSlot *slot) |
221 | { |
222 | CtkWidget *hbox, *label; |
223 | |
224 | g_return_if_fail (BAUL_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((baul_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_NOTEBOOK (notebook)"); return; } } while (0); |
225 | g_return_if_fail (BAUL_IS_WINDOW_SLOT (slot))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((slot)); GType __t = ((baul_window_slot_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"); return; } } while (0); |
226 | g_return_if_fail (CTK_IS_WIDGET (slot->content_box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((slot->content_box)); 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 (((gchar*) 0 ), ((const char*) (__func__)), "CTK_IS_WIDGET (slot->content_box)" ); return; } } while (0); |
227 | |
228 | hbox = ctk_notebook_get_tab_label (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), slot->content_box); |
229 | g_return_if_fail (CTK_IS_WIDGET (hbox))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((hbox)); 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 (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (hbox)"); return; } } while (0); |
230 | |
231 | label = CTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((hbox)), (((GType) ((20) << (2))))) ))), "label"))), ((ctk_widget_get_type ())))))); |
232 | g_return_if_fail (CTK_IS_WIDGET (label))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((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 (((gchar*) 0), ((const char* ) (__func__)), "CTK_IS_WIDGET (label)"); return; } } while (0 ); |
233 | |
234 | ctk_label_set_text (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), slot->title); |
235 | |
236 | if (slot->location != NULL((void*)0)) |
237 | { |
238 | char *location_name; |
239 | |
240 | /* Set the tooltip on the label's parent (the tab label hbox), |
241 | * so it covers all of the tab label. |
242 | */ |
243 | location_name = g_file_get_parse_name (slot->location); |
244 | ctk_widget_set_tooltip_text (ctk_widget_get_parent (label), location_name); |
245 | g_free (location_name); |
246 | } |
247 | else |
248 | { |
249 | ctk_widget_set_tooltip_text (ctk_widget_get_parent (label), NULL((void*)0)); |
250 | } |
251 | } |
252 | |
253 | static void |
254 | close_button_clicked_cb (CtkWidget *widget, |
255 | BaulWindowSlot *slot) |
256 | { |
257 | CtkWidget *notebook; |
258 | |
259 | notebook = ctk_widget_get_ancestor (slot->content_box, BAUL_TYPE_NOTEBOOK(baul_notebook_get_type ())); |
260 | if (notebook != NULL((void*)0)) |
261 | { |
262 | g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, slot); |
263 | } |
264 | } |
265 | |
266 | static CtkWidget * |
267 | build_tab_label (BaulNotebook *nb, BaulWindowSlot *slot) |
268 | { |
269 | BaulDragSlotProxyInfo *drag_info; |
270 | CtkWidget *hbox, *label, *close_button, *image, *spinner, *icon; |
271 | |
272 | /* set hbox spacing and label padding (see below) so that there's an |
273 | * equal amount of space around the label */ |
274 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 4); |
275 | ctk_widget_show (hbox); |
276 | |
277 | /* setup load feedback */ |
278 | spinner = ctk_spinner_new (); |
279 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), spinner, FALSE(0), FALSE(0), 0); |
280 | |
281 | /* setup site icon, empty by default */ |
282 | icon = ctk_image_new (); |
283 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), icon, FALSE(0), FALSE(0), 0); |
284 | /* don't show the icon */ |
285 | |
286 | /* setup label */ |
287 | label = ctk_label_new (NULL((void*)0)); |
288 | ctk_label_set_ellipsize (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), PANGO_ELLIPSIZE_END); |
289 | ctk_label_set_single_line_mode (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), TRUE(!(0))); |
290 | ctk_label_set_xalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), 0.0); |
291 | ctk_label_set_yalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), 0.5); |
292 | |
293 | ctk_widget_set_margin_start (label, 0); |
294 | ctk_widget_set_margin_end (label, 0); |
295 | ctk_widget_set_margin_top (label, 0); |
296 | ctk_widget_set_margin_bottom (label, 0); |
297 | |
298 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), label, TRUE(!(0)), TRUE(!(0)), 0); |
299 | ctk_widget_show (label); |
300 | |
301 | /* setup close button */ |
302 | close_button = ctk_button_new (); |
303 | ctk_button_set_relief (CTK_BUTTON (close_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((close_button)), ((ctk_button_get_type ())))))), |
304 | CTK_RELIEF_NONE); |
305 | /* don't allow focus on the close button */ |
306 | ctk_widget_set_focus_on_click (close_button, FALSE(0)); |
307 | |
308 | ctk_widget_set_name (close_button, "baul-tab-close-button"); |
309 | |
310 | image = ctk_image_new_from_icon_name ("window-close", CTK_ICON_SIZE_MENU); |
311 | ctk_widget_set_tooltip_text (close_button, _("Close tab")gettext ("Close tab")); |
312 | g_signal_connect_object (close_button, "clicked", |
313 | G_CALLBACK (close_button_clicked_cb)((GCallback) (close_button_clicked_cb)), slot, 0); |
314 | |
315 | ctk_container_add (CTK_CONTAINER (close_button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((close_button)), ((ctk_container_get_type ())))))), image); |
316 | ctk_widget_show (image); |
317 | |
318 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), close_button, FALSE(0), FALSE(0), 0); |
319 | ctk_widget_show (close_button); |
320 | |
321 | drag_info = g_new0 (BaulDragSlotProxyInfo, 1)((BaulDragSlotProxyInfo *) g_malloc0_n ((1), sizeof (BaulDragSlotProxyInfo ))); |
322 | drag_info->target_slot = slot; |
323 | g_object_set_data_full (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "proxy-drag-info", |
324 | drag_info, (GDestroyNotify) g_free); |
325 | |
326 | baul_drag_slot_proxy_init (hbox, drag_info); |
327 | |
328 | g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "label", label); |
329 | g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "spinner", spinner); |
330 | g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "icon", icon); |
331 | g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "close-button", close_button); |
332 | |
333 | return hbox; |
334 | } |
335 | |
336 | static int |
337 | baul_notebook_insert_page (CtkNotebook *gnotebook, |
338 | CtkWidget *tab_widget, |
339 | CtkWidget *tab_label, |
340 | CtkWidget *menu_label, |
341 | int position) |
342 | { |
343 | g_assert (CTK_IS_WIDGET (tab_widget))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((tab_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_assertion_message_expr (((gchar*) 0), "baul-notebook.c", 343 , ((const char*) (__func__)), "CTK_IS_WIDGET (tab_widget)"); } while (0); |
344 | |
345 | position = CTK_NOTEBOOK_CLASS (baul_notebook_parent_class)((((CtkNotebookClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_notebook_parent_class)), ((ctk_notebook_get_type () ))))))->insert_page (gnotebook, |
346 | tab_widget, |
347 | tab_label, |
348 | menu_label, |
349 | position); |
350 | |
351 | ctk_notebook_set_show_tabs (gnotebook, |
352 | ctk_notebook_get_n_pages (gnotebook) > 1); |
353 | ctk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE(!(0))); |
354 | |
355 | return position; |
356 | } |
357 | |
358 | int |
359 | baul_notebook_add_tab (BaulNotebook *notebook, |
360 | BaulWindowSlot *slot, |
361 | int position, |
362 | gboolean jump_to) |
363 | { |
364 | CtkNotebook *gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))); |
365 | CtkWidget *tab_label; |
366 | |
367 | g_return_val_if_fail (BAUL_IS_NOTEBOOK (notebook), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((baul_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_NOTEBOOK (notebook)"); return (-1); } } while (0); |
368 | g_return_val_if_fail (BAUL_IS_WINDOW_SLOT (slot), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((slot)); GType __t = ((baul_window_slot_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"); return (-1); } } while (0); |
369 | |
370 | tab_label = build_tab_label (notebook, slot); |
371 | |
372 | position = ctk_notebook_insert_page (CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))), |
Value stored to 'position' is never read | |
373 | slot->content_box, |
374 | tab_label, |
375 | position); |
376 | |
377 | ctk_container_child_set (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ())))))), |
378 | slot->content_box, |
379 | "tab-expand", TRUE(!(0)), |
380 | NULL((void*)0)); |
381 | |
382 | baul_notebook_sync_tab_label (notebook, slot); |
383 | baul_notebook_sync_loading (notebook, slot); |
384 | |
385 | |
386 | /* FIXME ctk bug! */ |
387 | /* FIXME: this should be fixed in ctk 2.12; check & remove this! */ |
388 | /* The signal handler may have reordered the tabs */ |
389 | position = ctk_notebook_page_num (gnotebook, slot->content_box); |
390 | |
391 | if (jump_to) |
392 | { |
393 | ctk_notebook_set_current_page (gnotebook, position); |
394 | |
395 | } |
396 | |
397 | return position; |
398 | } |
399 | |
400 | static void |
401 | baul_notebook_remove (CtkContainer *container, |
402 | CtkWidget *tab_widget) |
403 | { |
404 | CtkNotebook *gnotebook = CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ())))))); |
405 | CTK_CONTAINER_CLASS (baul_notebook_parent_class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_notebook_parent_class)), ((ctk_container_get_type ( )))))))->remove (container, tab_widget); |
406 | |
407 | ctk_notebook_set_show_tabs (gnotebook, |
408 | ctk_notebook_get_n_pages (gnotebook) > 1); |
409 | |
410 | } |
411 | |
412 | void |
413 | baul_notebook_reorder_current_child_relative (BaulNotebook *notebook, |
414 | int offset) |
415 | { |
416 | CtkNotebook *gnotebook; |
417 | CtkWidget *child; |
418 | int page; |
419 | |
420 | g_return_if_fail (BAUL_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((baul_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_NOTEBOOK (notebook)"); return; } } while (0); |
421 | |
422 | if (!baul_notebook_can_reorder_current_child_relative (notebook, offset)) |
423 | { |
424 | return; |
425 | } |
426 | |
427 | gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))); |
428 | |
429 | page = ctk_notebook_get_current_page (gnotebook); |
430 | child = ctk_notebook_get_nth_page (gnotebook, page); |
431 | ctk_notebook_reorder_child (gnotebook, child, page + offset); |
432 | } |
433 | |
434 | void |
435 | baul_notebook_set_current_page_relative (BaulNotebook *notebook, |
436 | int offset) |
437 | { |
438 | CtkNotebook *gnotebook; |
439 | int page; |
440 | |
441 | g_return_if_fail (BAUL_IS_NOTEBOOK (notebook))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((baul_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_NOTEBOOK (notebook)"); return; } } while (0); |
442 | |
443 | if (!baul_notebook_can_set_current_page_relative (notebook, offset)) |
444 | { |
445 | return; |
446 | } |
447 | |
448 | gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))); |
449 | |
450 | page = ctk_notebook_get_current_page (gnotebook); |
451 | ctk_notebook_set_current_page (gnotebook, page + offset); |
452 | |
453 | } |
454 | |
455 | static gboolean |
456 | baul_notebook_is_valid_relative_position (BaulNotebook *notebook, |
457 | int offset) |
458 | { |
459 | CtkNotebook *gnotebook; |
460 | int page; |
461 | int n_pages; |
462 | |
463 | gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ())))))); |
464 | |
465 | page = ctk_notebook_get_current_page (gnotebook); |
466 | n_pages = ctk_notebook_get_n_pages (gnotebook) - 1; |
467 | if (page < 0 || |
468 | (offset < 0 && page < -offset) || |
469 | (offset > 0 && page > n_pages - offset)) |
470 | { |
471 | return FALSE(0); |
472 | } |
473 | |
474 | return TRUE(!(0)); |
475 | } |
476 | |
477 | gboolean |
478 | baul_notebook_can_reorder_current_child_relative (BaulNotebook *notebook, |
479 | int offset) |
480 | { |
481 | g_return_val_if_fail (BAUL_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((baul_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_NOTEBOOK (notebook)"); return ((0)); } } while (0); |
482 | |
483 | return baul_notebook_is_valid_relative_position (notebook, offset); |
484 | } |
485 | |
486 | gboolean |
487 | baul_notebook_can_set_current_page_relative (BaulNotebook *notebook, |
488 | int offset) |
489 | { |
490 | g_return_val_if_fail (BAUL_IS_NOTEBOOK (notebook), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((notebook)); GType __t = ((baul_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 (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_NOTEBOOK (notebook)"); return ((0)); } } while (0); |
491 | |
492 | return baul_notebook_is_valid_relative_position (notebook, offset); |
493 | } |
494 |