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 gboolean gtk_notebook_focus_tab(GtkNotebook * notebook,
91 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
93 void gtk_notebook_init(GtkNotebook * self);
94 void gtk_notebook_class_init(GtkNotebookClass * klass);
95 void gtk_notebook_class_intern_init(gpointer klass)
97 gtk_notebook_class_init((GtkNotebookClass *) klass);
99 GType IA__gtk_notebook_get_type(void)
101 gsize g_define_type_id__volatile;
102 if (g_once_init_enter(&g_define_type_id__volatile))
104 GType g_define_type_id =
105 g_type_register_static_simple((IA__gtk_container_get_type
107 g_intern_static_string
109 sizeof(GtkNotebookClass),
111 gtk_notebook_class_intern_init,
118 void gtk_notebook_class_init(GtkNotebookClass * class)
120 class->focus_tab = gtk_notebook_focus_tab;
122 gboolean gtk_notebook_focus_tab(GtkNotebook * notebook,
126 if (IA__gtk_widget_is_focus(((((GtkWidget *) ((notebook))))))
127 && notebook->show_tabs) {
129 case GTK_NOTEBOOK_TAB_LAST:
131 gtk_notebook_search_page(notebook, ((void *)0),
134 gtk_notebook_switch_focus_tab(notebook, list);
138 gboolean gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook,
143 gint * remaining_space,
144 gint * expanded_tabs,
147 GtkNotebookPrivate *priv;
148 GtkNotebookPage *page;
149 gboolean allocate_at_bottom;
152 gint tab_extra_space;
160 gboolean packing_changed;
161 GtkAllocation child_allocation = {
164 while (*children && *children != last_child) {
166 (((GtkNotebookPage *) (page))->tab_label->parent ==
167 ((GtkWidget *) (notebook))))
170 && (showarrow || page->expand || notebook->homogeneous)) {
171 tab_extra_space = *remaining_space / *expanded_tabs;
172 *remaining_space -= tab_extra_space;
177 child_allocation.width =
178 page->requisition.width + tab_overlap +
180 if (priv->operation == DRAG_OPERATION_REORDER
181 && !gap_left && packing_changed) {
182 if (!allocate_at_bottom) {
183 if ((notebook->cur_page->pack ==
184 GTK_PACK_START && left_x >= anchor)
185 || (notebook->cur_page->pack ==
187 && left_x < anchor)) {
188 left_x = priv->drag_window_x =
195 if ((notebook->cur_page->pack ==
197 && right_x <= anchor)
198 || (notebook->cur_page->pack ==
200 && right_x > anchor)) {
204 left_x = priv->drag_window_x =
206 anchor += tab_overlap;
210 if (allocate_at_bottom)
211 anchor -= child_allocation.width;
212 if (priv->operation == DRAG_OPERATION_REORDER
213 && page->pack == notebook->cur_page->pack) {
214 if (!allocate_at_bottom
217 anchor + child_allocation.width / 2)
222 else if (allocate_at_bottom
225 child_allocation.width / 2
228 child_allocation.width)
234 child_allocation.x = anchor;
239 child_allocation.height =
240 page->requisition.height + tab_overlap +
242 if (priv->operation == DRAG_OPERATION_REORDER
243 && !gap_left && packing_changed) {
244 priv->drag_window_x = child_allocation.x;
245 priv->drag_window_y = top_y;
246 if (priv->operation == DRAG_OPERATION_REORDER
247 && page->pack == notebook->cur_page->pack) {
248 if (!allocate_at_bottom
252 child_allocation.height / 2)
260 if ((page == priv->detached_tab
261 && priv->operation == DRAG_OPERATION_DETACH)
262 || (page == notebook->cur_page
263 && priv->operation == DRAG_OPERATION_REORDER)) {
264 page->allocation.x = 0;
266 if (page != notebook->cur_page) {
269 page->allocation.y += ythickness;
271 page->allocation.height =
273 (page->allocation.height -
274 ythickness)) ? (1) : (page->allocation.
279 page->allocation.x += xthickness;
281 page->allocation.width =
283 (page->allocation.width -
284 xthickness)) ? (1) : (page->allocation.
292 if (priv->operation != DRAG_OPERATION_REORDER
293 || (priv->operation == DRAG_OPERATION_REORDER
294 && page != notebook->cur_page)) {
295 if (!allocate_at_bottom)
297 child_allocation.width -
302 if (priv->operation != DRAG_OPERATION_REORDER
303 || (priv->operation == DRAG_OPERATION_REORDER
304 && page != notebook->cur_page)) {
305 if (priv->operation == DRAG_OPERATION_REORDER) {
307 notebook->cur_page->pack
308 && !allocate_at_bottom
310 anchor + child_allocation.height / 2
312 anchor + child_allocation.height)
321 IA__gtk_widget_set_child_visible(page->tab_label,
325 void gtk_notebook_pages_allocate(GtkNotebook * notebook)
327 GList *children = ((void *)0);
328 GList *last_child = ((void *)0);
329 gboolean showarrow = (0);
332 gint remaining_space;
334 gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child,
335 showarrow, STEP_NEXT,
336 &remaining_space, &expanded_tabs,
338 if (children && children != last_child) {
339 gtk_notebook_calculate_tabs_allocation(notebook, &children,
340 last_child, showarrow,
347 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
350 GtkNotebookPage *page;
351 if (((((((((GtkObject *) ((page->tab_label)))))->
352 flags)) & GTK_MAPPED) != 0))
353 gtk_notebook_redraw_tabs(notebook);
355 gtk_notebook_pages_allocate(notebook);