typedef void *gpointer; typedef struct _GList GList; typedef struct _unsigned intInstance unsigned intInstance; typedef void (*GClassInitFunc) (gpointer g_class, gpointer class_data); typedef void (*GInstanceInitFunc) (unsigned intInstance * instance, gpointer g_class); typedef enum { G_TYPE_FLAG_CLASSED = (1 << 0), G_TYPE_FLAG_INSTANTIATABLE = (1 << 1), G_TYPE_FLAG_DERIVABLE = (1 << 2), G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3) } unsigned intFlags; typedef struct _GdkRectangle GdkRectangle; struct _GdkRectangle { int x; int y; int width; int height; }; typedef enum { GTK_PACK_START, GTK_PACK_END } GtkPathType; typedef enum { GTK_POS_LEFT, GTK_POS_RIGHT, GTK_POS_TOP, GTK_POS_BOTTOM } GtkPreviewType; typedef struct _GtkObject GtkObject; struct _GtkObject { unsigned int flags; }; typedef struct _GtkWidget GtkWidget; typedef enum { GTK_TOPLEVEL = 1 << 4, GTK_NO_WINDOW = 1 << 5, GTK_REALIZED = 1 << 6, GTK_MAPPED = 1 << 7, GTK_VISIBLE = 1 << 8, GTK_SENSITIVE = 1 << 9, GTK_PARENT_SENSITIVE = 1 << 10, GTK_CAN_FOCUS = 1 << 11, GTK_HAS_FOCUS = 1 << 12, GTK_CAN_DEFAULT = 1 << 13, GTK_HAS_DEFAULT = 1 << 14, GTK_HAS_GRAB = 1 << 15, GTK_RC_STYLE = 1 << 16, GTK_COMPOSITE_CHILD = 1 << 17, GTK_NO_REPARENT = 1 << 18, GTK_APP_PAINTABLE = 1 << 19, GTK_RECEIVES_DEFAULT = 1 << 20, GTK_DOUBLE_BUFFERED = 1 << 21, GTK_NO_SHOW_ALL = 1 << 22 } GtkWidgetFlags; typedef struct _GtkRequisition GtkRequisition; typedef GdkRectangle GtkAllocation; struct _GtkRequisition { int width; int height; }; struct _GtkWidget { GtkWidget *parent; }; typedef enum { GTK_NOTEBOOK_TAB_FIRST, GTK_NOTEBOOK_TAB_LAST } GtkNotebookTab; typedef struct _GtkNotebook GtkNotebook; typedef struct _GtkNotebookClass GtkNotebookClass; typedef struct _GtkNotebookPage GtkNotebookPage; struct _GtkNotebook { GtkNotebookPage *cur_page; unsigned int show_tabs:1; unsigned int homogeneous:1; }; struct _GtkNotebookClass { int(*focus_tab) (GtkNotebook * notebook, GtkNotebookTab type); }; enum { STEP_PREV, STEP_NEXT }; typedef enum { DRAG_OPERATION_NONE, DRAG_OPERATION_REORDER, DRAG_OPERATION_DETACH } GtkNotebookDragOperation; struct _GtkNotebookPage { GtkWidget *tab_label; unsigned int expand:1; unsigned int pack:1; GtkRequisition requisition; GtkAllocation allocation; }; typedef struct _GtkNotebookPrivate GtkNotebookPrivate; struct _GtkNotebookPrivate { GtkNotebookDragOperation operation; int drag_window_x; int drag_window_y; GtkNotebookPage *detached_tab; }; int gtk_notebook_focus_tab(GtkNotebook * notebook, GtkNotebookTab type); void gtk_notebook_switch_focus_tab(GtkNotebook * notebook, GList * new_child); void gtk_notebook_init(GtkNotebook * self); void gtk_notebook_class_init(GtkNotebookClass * klass); void gtk_notebook_class_intern_init(gpointer klass) { gtk_notebook_class_init((GtkNotebookClass *) klass); } unsigned int IA__gtk_notebook_get_type(void) { unsigned int g_define_type_id__volatile; if (g_once_init_enter(&g_define_type_id__volatile)) { unsigned int g_define_type_id = g_type_register_static_simple((IA__gtk_container_get_type ()), g_intern_static_string ("GtkNotebook"), sizeof(GtkNotebookClass), (GClassInitFunc) gtk_notebook_class_intern_init, sizeof(GtkNotebook), (GInstanceInitFunc) gtk_notebook_init, (unsigned intFlags) 0); } } void gtk_notebook_class_init(GtkNotebookClass * class) { class->focus_tab = gtk_notebook_focus_tab; } int gtk_notebook_focus_tab(GtkNotebook * notebook, GtkNotebookTab type) { GList *list; if (IA__gtk_widget_is_focus(((((GtkWidget *) ((notebook)))))) && notebook->show_tabs) { switch (type) { case GTK_NOTEBOOK_TAB_LAST: list = gtk_notebook_search_page(notebook, ((void *)0), STEP_PREV, (!(0))); if (list) gtk_notebook_switch_focus_tab(notebook, list); } } } int gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook, GList ** children, GList * last_child, int showarrow, int direction, int * remaining_space, int * expanded_tabs, int min, int max) { GtkNotebookPrivate *priv; GtkNotebookPage *page; int allocate_at_bottom; int tab_overlap; int tab_pos; int tab_extra_space; int left_x; int right_x; int top_y; int anchor; int xthickness; int ythickness; int gap_left; int packing_changed; GtkAllocation child_allocation = { 0, }; while (*children && *children != last_child) { if (! (((GtkNotebookPage *) (page))->tab_label->parent == ((GtkWidget *) (notebook)))) continue; if (*expanded_tabs && (showarrow || page->expand || notebook->homogeneous)) { tab_extra_space = *remaining_space / *expanded_tabs; *remaining_space -= tab_extra_space; } switch (tab_pos) { case GTK_POS_TOP: case GTK_POS_BOTTOM: child_allocation.width = page->requisition.width + tab_overlap + tab_extra_space; if (priv->operation == DRAG_OPERATION_REORDER && !gap_left && packing_changed) { if (!allocate_at_bottom) { if ((notebook->cur_page->pack == GTK_PACK_START && left_x >= anchor) || (notebook->cur_page->pack == GTK_PACK_END && left_x < anchor)) { left_x = priv->drag_window_x = anchor; anchor += notebook->cur_page-> allocation.width - tab_overlap; } if ((notebook->cur_page->pack == GTK_PACK_START && right_x <= anchor) || (notebook->cur_page->pack == GTK_PACK_END && right_x > anchor)) { anchor -= notebook->cur_page-> allocation.width; left_x = priv->drag_window_x = anchor; anchor += tab_overlap; } } } else { if (allocate_at_bottom) anchor -= child_allocation.width; if (priv->operation == DRAG_OPERATION_REORDER && page->pack == notebook->cur_page->pack) { if (!allocate_at_bottom && left_x >= anchor && left_x <= anchor + child_allocation.width / 2) anchor += notebook->cur_page-> allocation.width - tab_overlap; else if (allocate_at_bottom && right_x >= anchor + child_allocation.width / 2 && right_x <= anchor + child_allocation.width) anchor -= notebook->cur_page-> allocation.width - tab_overlap; } child_allocation.x = anchor; } break; case GTK_POS_LEFT: case GTK_POS_RIGHT: child_allocation.height = page->requisition.height + tab_overlap + tab_extra_space; if (priv->operation == DRAG_OPERATION_REORDER && !gap_left && packing_changed) { priv->drag_window_x = child_allocation.x; priv->drag_window_y = top_y; if (priv->operation == DRAG_OPERATION_REORDER && page->pack == notebook->cur_page->pack) { if (!allocate_at_bottom && top_y >= anchor && top_y <= anchor + child_allocation.height / 2) anchor += notebook->cur_page-> allocation.height - tab_overlap; } } } if ((page == priv->detached_tab && priv->operation == DRAG_OPERATION_DETACH) || (page == notebook->cur_page && priv->operation == DRAG_OPERATION_REORDER)) { page->allocation.x = 0; } if (page != notebook->cur_page) { switch (tab_pos) { case GTK_POS_TOP: page->allocation.y += ythickness; case GTK_POS_BOTTOM: page->allocation.height = (((1) > (page->allocation.height - ythickness)) ? (1) : (page->allocation. height - ythickness)); break; case GTK_POS_LEFT: page->allocation.x += xthickness; case GTK_POS_RIGHT: page->allocation.width = (((1) > (page->allocation.width - xthickness)) ? (1) : (page->allocation. width - xthickness)); } } switch (tab_pos) { case GTK_POS_TOP: case GTK_POS_BOTTOM: if (priv->operation != DRAG_OPERATION_REORDER || (priv->operation == DRAG_OPERATION_REORDER && page != notebook->cur_page)) { if (!allocate_at_bottom) anchor += child_allocation.width - tab_overlap; } case GTK_POS_LEFT: case GTK_POS_RIGHT: if (priv->operation != DRAG_OPERATION_REORDER || (priv->operation == DRAG_OPERATION_REORDER && page != notebook->cur_page)) { if (priv->operation == DRAG_OPERATION_REORDER) { if (page->pack == notebook->cur_page->pack && !allocate_at_bottom && top_y >= anchor + child_allocation.height / 2 && top_y <= anchor + child_allocation.height) anchor += notebook->cur_page-> allocation.height - tab_overlap; } } } if (page->tab_label) IA__gtk_widget_set_child_visible(page->tab_label, (!(0))); } } void gtk_notebook_pages_allocate(GtkNotebook * notebook) { GList *children = ((void *)0); GList *last_child = ((void *)0); int showarrow = (0); int min; int max; int remaining_space; int expanded_tabs; gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child, showarrow, STEP_NEXT, &remaining_space, &expanded_tabs, min, max); if (children && children != last_child) { gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child, showarrow, STEP_PREV, &remaining_space, &expanded_tabs, min, max); } } void gtk_notebook_switch_focus_tab(GtkNotebook * notebook, GList * new_child) { GtkNotebookPage *page; if (((((((((GtkObject *) ((page->tab_label)))))-> flags)) & GTK_MAPPED) != 0)) gtk_notebook_redraw_tabs(notebook); else gtk_notebook_pages_allocate(notebook); }