1 typedef unsigned int guint32;
2 typedef unsigned int gsize;
5 typedef unsigned int guint;
6 typedef void *gpointer;
7 typedef struct _GList GList;
9 typedef struct _GTypeInstance GTypeInstance;
10 typedef void (*GClassInitFunc) (gpointer g_class, gpointer class_data);
11 typedef void (*GInstanceInitFunc) (GTypeInstance * instance, gpointer g_class);
13 G_TYPE_FLAG_CLASSED = (1 << 0), G_TYPE_FLAG_INSTANTIATABLE =
14 (1 << 1), G_TYPE_FLAG_DERIVABLE =
15 (1 << 2), G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3)
17 typedef struct _GdkRectangle GdkRectangle;
18 struct _GdkRectangle {
25 GTK_PACK_START, GTK_PACK_END
28 GTK_POS_LEFT, GTK_POS_RIGHT, GTK_POS_TOP, GTK_POS_BOTTOM
30 typedef struct _GtkObject GtkObject;
34 typedef struct _GtkWidget GtkWidget;
36 GTK_TOPLEVEL = 1 << 4, GTK_NO_WINDOW = 1 << 5, GTK_REALIZED =
37 1 << 6, GTK_MAPPED = 1 << 7, GTK_VISIBLE = 1 << 8, GTK_SENSITIVE =
38 1 << 9, GTK_PARENT_SENSITIVE = 1 << 10, GTK_CAN_FOCUS =
39 1 << 11, GTK_HAS_FOCUS = 1 << 12, GTK_CAN_DEFAULT =
40 1 << 13, GTK_HAS_DEFAULT = 1 << 14, GTK_HAS_GRAB =
41 1 << 15, GTK_RC_STYLE = 1 << 16, GTK_COMPOSITE_CHILD =
42 1 << 17, GTK_NO_REPARENT = 1 << 18, GTK_APP_PAINTABLE =
43 1 << 19, GTK_RECEIVES_DEFAULT = 1 << 20, GTK_DOUBLE_BUFFERED =
44 1 << 21, GTK_NO_SHOW_ALL = 1 << 22
46 typedef struct _GtkRequisition GtkRequisition;
47 typedef GdkRectangle GtkAllocation;
48 struct _GtkRequisition {
56 GTK_NOTEBOOK_TAB_FIRST, GTK_NOTEBOOK_TAB_LAST
58 typedef struct _GtkNotebook GtkNotebook;
59 typedef struct _GtkNotebookClass GtkNotebookClass;
60 typedef struct _GtkNotebookPage GtkNotebookPage;
62 GtkNotebookPage *cur_page;
66 struct _GtkNotebookClass {
67 gboolean(*focus_tab) (GtkNotebook * notebook, GtkNotebookTab type);
73 DRAG_OPERATION_NONE, DRAG_OPERATION_REORDER, DRAG_OPERATION_DETACH
74 } GtkNotebookDragOperation;
75 struct _GtkNotebookPage {
79 GtkRequisition requisition;
80 GtkAllocation allocation;
82 typedef struct _GtkNotebookPrivate GtkNotebookPrivate;
83 struct _GtkNotebookPrivate {
84 GtkNotebookDragOperation operation;
87 GtkNotebookPage *detached_tab;
89 static gboolean gtk_notebook_focus_tab(GtkNotebook * notebook,
91 static void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
93 static void gtk_notebook_init(GtkNotebook * self);
94 static void gtk_notebook_class_init(GtkNotebookClass * klass);
95 static void gtk_notebook_class_intern_init(gpointer klass)
97 gtk_notebook_class_init((GtkNotebookClass *) klass);
99 GType IA__gtk_notebook_get_type(void)
101 static volatile gsize g_define_type_id__volatile = 0;
102 if (g_once_init_enter(&g_define_type_id__volatile)) {
103 GType g_define_type_id =
104 g_type_register_static_simple((IA__gtk_container_get_type
106 g_intern_static_string
108 sizeof(GtkNotebookClass),
110 gtk_notebook_class_intern_init,
117 static void gtk_notebook_class_init(GtkNotebookClass * class)
119 class->focus_tab = gtk_notebook_focus_tab;
121 static gboolean gtk_notebook_focus_tab(GtkNotebook * notebook,
125 if (IA__gtk_widget_is_focus(((((GtkWidget *) ((notebook))))))
126 && notebook->show_tabs) {
128 case GTK_NOTEBOOK_TAB_LAST:
130 gtk_notebook_search_page(notebook, ((void *)0),
133 gtk_notebook_switch_focus_tab(notebook, list);
137 static gboolean gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook,
142 gint * remaining_space,
143 gint * expanded_tabs,
146 GtkNotebookPrivate *priv;
147 GtkNotebookPage *page;
148 gboolean allocate_at_bottom;
149 gint tab_overlap, tab_pos, tab_extra_space;
150 gint left_x, right_x, top_y, bottom_y, anchor;
151 gint xthickness, ythickness;
152 gboolean gap_left, packing_changed;
153 GtkAllocation child_allocation = {
156 while (*children && *children != last_child) {
158 (((GtkNotebookPage *) (page))->tab_label->parent ==
159 ((GtkWidget *) (notebook))))
162 && (showarrow || page->expand || notebook->homogeneous)) {
163 tab_extra_space = *remaining_space / *expanded_tabs;
164 *remaining_space -= tab_extra_space;
169 child_allocation.width =
170 page->requisition.width + tab_overlap +
172 if (priv->operation == DRAG_OPERATION_REORDER
173 && !gap_left && packing_changed) {
174 if (!allocate_at_bottom) {
175 if ((notebook->cur_page->pack ==
176 GTK_PACK_START && left_x >= anchor)
177 || (notebook->cur_page->pack ==
179 && left_x < anchor)) {
180 left_x = priv->drag_window_x =
187 if ((notebook->cur_page->pack ==
189 && right_x <= anchor)
190 || (notebook->cur_page->pack ==
192 && right_x > anchor)) {
196 left_x = priv->drag_window_x =
198 anchor += tab_overlap;
202 if (allocate_at_bottom)
203 anchor -= child_allocation.width;
204 if (priv->operation == DRAG_OPERATION_REORDER
205 && page->pack == notebook->cur_page->pack) {
206 if (!allocate_at_bottom
209 anchor + child_allocation.width / 2)
214 else if (allocate_at_bottom
217 child_allocation.width / 2
220 child_allocation.width)
226 child_allocation.x = anchor;
231 child_allocation.height =
232 page->requisition.height + tab_overlap +
234 if (priv->operation == DRAG_OPERATION_REORDER
235 && !gap_left && packing_changed) {
236 priv->drag_window_x = child_allocation.x;
237 priv->drag_window_y = top_y;
238 if (priv->operation == DRAG_OPERATION_REORDER
239 && page->pack == notebook->cur_page->pack) {
240 if (!allocate_at_bottom
244 child_allocation.height / 2)
252 if ((page == priv->detached_tab
253 && priv->operation == DRAG_OPERATION_DETACH)
254 || (page == notebook->cur_page
255 && priv->operation == DRAG_OPERATION_REORDER)) {
256 page->allocation.x = 0;
258 if (page != notebook->cur_page) {
261 page->allocation.y += ythickness;
263 page->allocation.height =
265 (page->allocation.height -
266 ythickness)) ? (1) : (page->allocation.
271 page->allocation.x += xthickness;
273 page->allocation.width =
275 (page->allocation.width -
276 xthickness)) ? (1) : (page->allocation.
284 if (priv->operation != DRAG_OPERATION_REORDER
285 || (priv->operation == DRAG_OPERATION_REORDER
286 && page != notebook->cur_page)) {
287 if (!allocate_at_bottom)
289 child_allocation.width -
294 if (priv->operation != DRAG_OPERATION_REORDER
295 || (priv->operation == DRAG_OPERATION_REORDER
296 && page != notebook->cur_page)) {
297 if (priv->operation == DRAG_OPERATION_REORDER) {
299 notebook->cur_page->pack
300 && !allocate_at_bottom
302 anchor + child_allocation.height / 2
304 anchor + child_allocation.height)
313 IA__gtk_widget_set_child_visible(page->tab_label,
317 static void gtk_notebook_pages_allocate(GtkNotebook * notebook)
319 GList *children = ((void *)0);
320 GList *last_child = ((void *)0);
321 gboolean showarrow = (0);
322 gint tab_space, min, max, remaining_space;
323 gint expanded_tabs, operation;
324 gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child,
325 showarrow, STEP_NEXT,
326 &remaining_space, &expanded_tabs,
328 if (children && children != last_child) {
329 gtk_notebook_calculate_tabs_allocation(notebook, &children,
330 last_child, showarrow,
337 static void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
340 GtkNotebookPage *page;
341 if (((((((((GtkObject *) ((page->tab_label)))))->
342 flags)) & GTK_MAPPED) != 0))
343 gtk_notebook_redraw_tabs(notebook);
345 gtk_notebook_pages_allocate(notebook);