| File: | src/baul-notebook.c | 
| Warning: | line 373, 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 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 = 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_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (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 G_GNUC_UNUSED__attribute__ ((__unused__))) | 
| 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 G_GNUC_UNUSED__attribute__ ((__unused__)), | 
| 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 G_GNUC_UNUSED__attribute__ ((__unused__)), | 
| 268 | BaulWindowSlot *slot) | 
| 269 | { | 
| 270 | BaulDragSlotProxyInfo *drag_info; | 
| 271 | CtkWidget *hbox, *label, *close_button, *image, *spinner, *icon; | 
| 272 | |
| 273 | /* set hbox spacing and label padding (see below) so that there's an | 
| 274 | * equal amount of space around the label */ | 
| 275 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 4); | 
| 276 | ctk_widget_show (hbox); | 
| 277 | |
| 278 | /* setup load feedback */ | 
| 279 | spinner = ctk_spinner_new (); | 
| 280 |     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);  | 
| 281 | |
| 282 | /* setup site icon, empty by default */ | 
| 283 | icon = ctk_image_new (); | 
| 284 |     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);  | 
| 285 | /* don't show the icon */ | 
| 286 | |
| 287 | /* setup label */ | 
| 288 | label = ctk_label_new (NULL((void*)0)); | 
| 289 |     ctk_label_set_ellipsize (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), PANGO_ELLIPSIZE_END);  | 
| 290 |     ctk_label_set_single_line_mode (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), TRUE(!(0)));  | 
| 291 |     ctk_label_set_xalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), 0.0);  | 
| 292 |     ctk_label_set_yalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), 0.5);  | 
| 293 | |
| 294 | ctk_widget_set_margin_start (label, 0); | 
| 295 | ctk_widget_set_margin_end (label, 0); | 
| 296 | ctk_widget_set_margin_top (label, 0); | 
| 297 | ctk_widget_set_margin_bottom (label, 0); | 
| 298 | |
| 299 |     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);  | 
| 300 | ctk_widget_show (label); | 
| 301 | |
| 302 | /* setup close button */ | 
| 303 | close_button = ctk_button_new (); | 
| 304 |     ctk_button_set_relief (CTK_BUTTON (close_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((close_button)), ((ctk_button_get_type ())))))),  | 
| 305 | CTK_RELIEF_NONE); | 
| 306 | /* don't allow focus on the close button */ | 
| 307 | ctk_widget_set_focus_on_click (close_button, FALSE(0)); | 
| 308 | |
| 309 | ctk_widget_set_name (close_button, "baul-tab-close-button"); | 
| 310 | |
| 311 | image = ctk_image_new_from_icon_name ("window-close", CTK_ICON_SIZE_MENU); | 
| 312 | ctk_widget_set_tooltip_text (close_button, _("Close tab")gettext ("Close tab")); | 
| 313 | g_signal_connect_object (close_button, "clicked", | 
| 314 | G_CALLBACK (close_button_clicked_cb)((GCallback) (close_button_clicked_cb)), slot, 0); | 
| 315 | |
| 316 |     ctk_container_add (CTK_CONTAINER (close_button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((close_button)), ((ctk_container_get_type ())))))), image);  | 
| 317 | ctk_widget_show (image); | 
| 318 | |
| 319 |     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);  | 
| 320 | ctk_widget_show (close_button); | 
| 321 | |
| 322 |     drag_info = g_new0 (BaulDragSlotProxyInfo, 1)((BaulDragSlotProxyInfo *) g_malloc0_n ((1), sizeof (BaulDragSlotProxyInfo )));  | 
| 323 | drag_info->target_slot = slot; | 
| 324 |     g_object_set_data_full (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "proxy-drag-info",  | 
| 325 | drag_info, (GDestroyNotify) g_free); | 
| 326 | |
| 327 | baul_drag_slot_proxy_init (hbox, drag_info); | 
| 328 | |
| 329 |     g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "label", label);  | 
| 330 |     g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "spinner", spinner);  | 
| 331 |     g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "icon", icon);  | 
| 332 |     g_object_set_data (G_OBJECT (hbox)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), (((GType) ((20) << (2)))))))), "close-button", close_button);  | 
| 333 | |
| 334 | return hbox; | 
| 335 | } | 
| 336 | |
| 337 | static int | 
| 338 | baul_notebook_insert_page (CtkNotebook *gnotebook, | 
| 339 | CtkWidget *tab_widget, | 
| 340 | CtkWidget *tab_label, | 
| 341 | CtkWidget *menu_label, | 
| 342 | int position) | 
| 343 | { | 
| 344 |     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", 344 , ((const char*) (__func__)), "CTK_IS_WIDGET (tab_widget)"); } while (0);  | 
| 345 | |
| 346 |     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,  | 
| 347 | tab_widget, | 
| 348 | tab_label, | 
| 349 | menu_label, | 
| 350 | position); | 
| 351 | |
| 352 | ctk_notebook_set_show_tabs (gnotebook, | 
| 353 | ctk_notebook_get_n_pages (gnotebook) > 1); | 
| 354 | ctk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE(!(0))); | 
| 355 | |
| 356 | return position; | 
| 357 | } | 
| 358 | |
| 359 | int | 
| 360 | baul_notebook_add_tab (BaulNotebook *notebook, | 
| 361 | BaulWindowSlot *slot, | 
| 362 | int position, | 
| 363 | gboolean jump_to) | 
| 364 | { | 
| 365 |     CtkNotebook *gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ()))))));  | 
| 366 | CtkWidget *tab_label; | 
| 367 | |
| 368 |     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);  | 
| 369 |     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);  | 
| 370 | |
| 371 | tab_label = build_tab_label (notebook, slot); | 
| 372 | |
| 373 |     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  | |
| 374 | slot->content_box, | 
| 375 | tab_label, | 
| 376 | position); | 
| 377 | |
| 378 |     ctk_container_child_set (CTK_CONTAINER (notebook)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_container_get_type ())))))),  | 
| 379 | slot->content_box, | 
| 380 | "tab-expand", TRUE(!(0)), | 
| 381 | NULL((void*)0)); | 
| 382 | |
| 383 | baul_notebook_sync_tab_label (notebook, slot); | 
| 384 | baul_notebook_sync_loading (notebook, slot); | 
| 385 | |
| 386 | |
| 387 | /* FIXME ctk bug! */ | 
| 388 | /* FIXME: this should be fixed in ctk 2.12; check & remove this! */ | 
| 389 | /* The signal handler may have reordered the tabs */ | 
| 390 | position = ctk_notebook_page_num (gnotebook, slot->content_box); | 
| 391 | |
| 392 | if (jump_to) | 
| 393 | { | 
| 394 | ctk_notebook_set_current_page (gnotebook, position); | 
| 395 | |
| 396 | } | 
| 397 | |
| 398 | return position; | 
| 399 | } | 
| 400 | |
| 401 | static void | 
| 402 | baul_notebook_remove (CtkContainer *container, | 
| 403 | CtkWidget *tab_widget) | 
| 404 | { | 
| 405 |     CtkNotebook *gnotebook = CTK_NOTEBOOK (container)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((container)), ((ctk_notebook_get_type ()))))));  | 
| 406 |     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);  | 
| 407 | |
| 408 | ctk_notebook_set_show_tabs (gnotebook, | 
| 409 | ctk_notebook_get_n_pages (gnotebook) > 1); | 
| 410 | |
| 411 | } | 
| 412 | |
| 413 | void | 
| 414 | baul_notebook_reorder_current_child_relative (BaulNotebook *notebook, | 
| 415 | int offset) | 
| 416 | { | 
| 417 | CtkNotebook *gnotebook; | 
| 418 | CtkWidget *child; | 
| 419 | int page; | 
| 420 | |
| 421 |     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);  | 
| 422 | |
| 423 | if (!baul_notebook_can_reorder_current_child_relative (notebook, offset)) | 
| 424 | { | 
| 425 | return; | 
| 426 | } | 
| 427 | |
| 428 |     gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ()))))));  | 
| 429 | |
| 430 | page = ctk_notebook_get_current_page (gnotebook); | 
| 431 | child = ctk_notebook_get_nth_page (gnotebook, page); | 
| 432 | ctk_notebook_reorder_child (gnotebook, child, page + offset); | 
| 433 | } | 
| 434 | |
| 435 | void | 
| 436 | baul_notebook_set_current_page_relative (BaulNotebook *notebook, | 
| 437 | int offset) | 
| 438 | { | 
| 439 | CtkNotebook *gnotebook; | 
| 440 | int page; | 
| 441 | |
| 442 |     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);  | 
| 443 | |
| 444 | if (!baul_notebook_can_set_current_page_relative (notebook, offset)) | 
| 445 | { | 
| 446 | return; | 
| 447 | } | 
| 448 | |
| 449 |     gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ()))))));  | 
| 450 | |
| 451 | page = ctk_notebook_get_current_page (gnotebook); | 
| 452 | ctk_notebook_set_current_page (gnotebook, page + offset); | 
| 453 | |
| 454 | } | 
| 455 | |
| 456 | static gboolean | 
| 457 | baul_notebook_is_valid_relative_position (BaulNotebook *notebook, | 
| 458 | int offset) | 
| 459 | { | 
| 460 | CtkNotebook *gnotebook; | 
| 461 | int page; | 
| 462 | int n_pages; | 
| 463 | |
| 464 |     gnotebook = CTK_NOTEBOOK (notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((notebook)), ((ctk_notebook_get_type ()))))));  | 
| 465 | |
| 466 | page = ctk_notebook_get_current_page (gnotebook); | 
| 467 | n_pages = ctk_notebook_get_n_pages (gnotebook) - 1; | 
| 468 | if (page < 0 || | 
| 469 | (offset < 0 && page < -offset) || | 
| 470 | (offset > 0 && page > n_pages - offset)) | 
| 471 | { | 
| 472 | return FALSE(0); | 
| 473 | } | 
| 474 | |
| 475 | return TRUE(!(0)); | 
| 476 | } | 
| 477 | |
| 478 | gboolean | 
| 479 | baul_notebook_can_reorder_current_child_relative (BaulNotebook *notebook, | 
| 480 | int offset) | 
| 481 | { | 
| 482 |     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);  | 
| 483 | |
| 484 | return baul_notebook_is_valid_relative_position (notebook, offset); | 
| 485 | } | 
| 486 | |
| 487 | gboolean | 
| 488 | baul_notebook_can_set_current_page_relative (BaulNotebook *notebook, | 
| 489 | int offset) | 
| 490 | { | 
| 491 |     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);  | 
| 492 | |
| 493 | return baul_notebook_is_valid_relative_position (notebook, offset); | 
| 494 | } | 
| 495 |