1 typedef void *gpointer;
2 typedef struct _GList GList;
3 typedef struct _unsigned intInstance unsigned intInstance;
4 typedef void (*GClassInitFunc) (gpointer g_class, gpointer class_data);
5 typedef void (*GInstanceInitFunc) (unsigned intInstance * instance, gpointer g_class);
7 G_TYPE_FLAG_CLASSED = (1 << 0), G_TYPE_FLAG_INSTANTIATABLE =
8 (1 << 1), G_TYPE_FLAG_DERIVABLE =
9 (1 << 2), G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3)
11 typedef struct _GdkRectangle GdkRectangle;
12 struct _GdkRectangle {
19 GTK_PACK_START, GTK_PACK_END
22 GTK_POS_LEFT, GTK_POS_RIGHT, GTK_POS_TOP, GTK_POS_BOTTOM
24 typedef struct _GtkObject GtkObject;
28 typedef struct _GtkWidget GtkWidget;
30 GTK_TOPLEVEL = 1 << 4, GTK_NO_WINDOW = 1 << 5, GTK_REALIZED =
31 1 << 6, GTK_MAPPED = 1 << 7, GTK_VISIBLE = 1 << 8, GTK_SENSITIVE =
32 1 << 9, GTK_PARENT_SENSITIVE = 1 << 10, GTK_CAN_FOCUS =
33 1 << 11, GTK_HAS_FOCUS = 1 << 12, GTK_CAN_DEFAULT =
34 1 << 13, GTK_HAS_DEFAULT = 1 << 14, GTK_HAS_GRAB =
35 1 << 15, GTK_RC_STYLE = 1 << 16, GTK_COMPOSITE_CHILD =
36 1 << 17, GTK_NO_REPARENT = 1 << 18, GTK_APP_PAINTABLE =
37 1 << 19, GTK_RECEIVES_DEFAULT = 1 << 20, GTK_DOUBLE_BUFFERED =
38 1 << 21, GTK_NO_SHOW_ALL = 1 << 22
40 typedef struct _GtkRequisition GtkRequisition;
41 typedef GdkRectangle GtkAllocation;
42 struct _GtkRequisition {
50 GTK_NOTEBOOK_TAB_FIRST, GTK_NOTEBOOK_TAB_LAST
52 typedef struct _GtkNotebook GtkNotebook;
53 typedef struct _GtkNotebookClass GtkNotebookClass;
54 typedef struct _GtkNotebookPage GtkNotebookPage;
56 GtkNotebookPage *cur_page;
57 unsigned int show_tabs:1;
58 unsigned int homogeneous:1;
60 struct _GtkNotebookClass {
61 int(*focus_tab) (GtkNotebook * notebook, GtkNotebookTab type);
67 DRAG_OPERATION_NONE, DRAG_OPERATION_REORDER, DRAG_OPERATION_DETACH
68 } GtkNotebookDragOperation;
69 struct _GtkNotebookPage {
71 unsigned int expand:1;
73 GtkRequisition requisition;
74 GtkAllocation allocation;
76 typedef struct _GtkNotebookPrivate GtkNotebookPrivate;
77 struct _GtkNotebookPrivate {
78 GtkNotebookDragOperation operation;
81 GtkNotebookPage *detached_tab;
83 int gtk_notebook_focus_tab(GtkNotebook * notebook,
85 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
87 void gtk_notebook_init(GtkNotebook * self);
88 void gtk_notebook_class_init(GtkNotebookClass * klass);
89 void gtk_notebook_class_intern_init(gpointer klass)
91 gtk_notebook_class_init((GtkNotebookClass *) klass);
93 unsigned int IA__gtk_notebook_get_type(void)
95 unsigned int g_define_type_id__volatile;
96 if (g_once_init_enter(&g_define_type_id__volatile))
98 unsigned int g_define_type_id =
99 g_type_register_static_simple((IA__gtk_container_get_type
101 g_intern_static_string
103 sizeof(GtkNotebookClass),
105 gtk_notebook_class_intern_init,
109 (unsigned intFlags) 0);
112 void gtk_notebook_class_init(GtkNotebookClass * class)
114 class->focus_tab = gtk_notebook_focus_tab;
116 int gtk_notebook_focus_tab(GtkNotebook * notebook,
120 if (IA__gtk_widget_is_focus(((((GtkWidget *) ((notebook))))))
121 && notebook->show_tabs) {
123 case GTK_NOTEBOOK_TAB_LAST:
125 gtk_notebook_search_page(notebook, ((void *)0),
128 gtk_notebook_switch_focus_tab(notebook, list);
132 int gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook,
137 int * remaining_space,
141 GtkNotebookPrivate *priv;
142 GtkNotebookPage *page;
143 int allocate_at_bottom;
155 GtkAllocation child_allocation = {
158 while (*children && *children != last_child) {
160 (((GtkNotebookPage *) (page))->tab_label->parent ==
161 ((GtkWidget *) (notebook))))
164 && (showarrow || page->expand || notebook->homogeneous)) {
165 tab_extra_space = *remaining_space / *expanded_tabs;
166 *remaining_space -= tab_extra_space;
171 child_allocation.width =
172 page->requisition.width + tab_overlap +
174 if (priv->operation == DRAG_OPERATION_REORDER
175 && !gap_left && packing_changed) {
176 if (!allocate_at_bottom) {
177 if ((notebook->cur_page->pack ==
178 GTK_PACK_START && left_x >= anchor)
179 || (notebook->cur_page->pack ==
181 && left_x < anchor)) {
182 left_x = priv->drag_window_x =
189 if ((notebook->cur_page->pack ==
191 && right_x <= anchor)
192 || (notebook->cur_page->pack ==
194 && right_x > anchor)) {
198 left_x = priv->drag_window_x =
200 anchor += tab_overlap;
204 if (allocate_at_bottom)
205 anchor -= child_allocation.width;
206 if (priv->operation == DRAG_OPERATION_REORDER
207 && page->pack == notebook->cur_page->pack) {
208 if (!allocate_at_bottom
211 anchor + child_allocation.width / 2)
216 else if (allocate_at_bottom
219 child_allocation.width / 2
222 child_allocation.width)
228 child_allocation.x = anchor;
233 child_allocation.height =
234 page->requisition.height + tab_overlap +
236 if (priv->operation == DRAG_OPERATION_REORDER
237 && !gap_left && packing_changed) {
238 priv->drag_window_x = child_allocation.x;
239 priv->drag_window_y = top_y;
240 if (priv->operation == DRAG_OPERATION_REORDER
241 && page->pack == notebook->cur_page->pack) {
242 if (!allocate_at_bottom
246 child_allocation.height / 2)
254 if ((page == priv->detached_tab
255 && priv->operation == DRAG_OPERATION_DETACH)
256 || (page == notebook->cur_page
257 && priv->operation == DRAG_OPERATION_REORDER)) {
258 page->allocation.x = 0;
260 if (page != notebook->cur_page) {
263 page->allocation.y += ythickness;
265 page->allocation.height =
267 (page->allocation.height -
268 ythickness)) ? (1) : (page->allocation.
273 page->allocation.x += xthickness;
275 page->allocation.width =
277 (page->allocation.width -
278 xthickness)) ? (1) : (page->allocation.
286 if (priv->operation != DRAG_OPERATION_REORDER
287 || (priv->operation == DRAG_OPERATION_REORDER
288 && page != notebook->cur_page)) {
289 if (!allocate_at_bottom)
291 child_allocation.width -
296 if (priv->operation != DRAG_OPERATION_REORDER
297 || (priv->operation == DRAG_OPERATION_REORDER
298 && page != notebook->cur_page)) {
299 if (priv->operation == DRAG_OPERATION_REORDER) {
301 notebook->cur_page->pack
302 && !allocate_at_bottom
304 anchor + child_allocation.height / 2
306 anchor + child_allocation.height)
315 IA__gtk_widget_set_child_visible(page->tab_label,
319 void gtk_notebook_pages_allocate(GtkNotebook * notebook)
321 GList *children = ((void *)0);
322 GList *last_child = ((void *)0);
328 gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child,
329 showarrow, STEP_NEXT,
330 &remaining_space, &expanded_tabs,
332 if (children && children != last_child) {
333 gtk_notebook_calculate_tabs_allocation(notebook, &children,
334 last_child, showarrow,
341 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
344 GtkNotebookPage *page;
345 if (((((((((GtkObject *) ((page->tab_label)))))->
346 flags)) & GTK_MAPPED) != 0))
347 gtk_notebook_redraw_tabs(notebook);
349 gtk_notebook_pages_allocate(notebook);