typedef unsigned int guint32; typedef unsigned int gsize; typedef int gint; typedef gint gboolean; typedef unsigned int guint; typedef void *gpointer; typedef struct _GList GList; typedef gsize GType; typedef struct _GTypeInstance GTypeInstance; typedef void (*GClassInitFunc) (gpointer g_class, gpointer class_data); typedef void (*GInstanceInitFunc) (GTypeInstance * 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) } GTypeFlags; typedef struct _GdkRectangle GdkRectangle; struct _GdkRectangle { gint x; gint y; gint width; gint 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 { guint32 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 { gint width; gint 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; guint show_tabs:1; guint homogeneous:1; }; struct _GtkNotebookClass { gboolean(*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; guint expand:1; guint pack:1; GtkRequisition requisition; GtkAllocation allocation; }; typedef struct _GtkNotebookPrivate GtkNotebookPrivate; struct _GtkNotebookPrivate { GtkNotebookDragOperation operation; gint drag_window_x; gint drag_window_y; GtkNotebookPage *detached_tab; }; static gboolean gtk_notebook_focus_tab(GtkNotebook * notebook, GtkNotebookTab type); static void gtk_notebook_switch_focus_tab(GtkNotebook * notebook, GList * new_child); static void gtk_notebook_init(GtkNotebook * self); static void gtk_notebook_class_init(GtkNotebookClass * klass); static void gtk_notebook_class_intern_init(gpointer klass) { gtk_notebook_class_init((GtkNotebookClass *) klass); } GType IA__gtk_notebook_get_type(void) { static volatile gsize g_define_type_id__volatile = 0; if (g_once_init_enter(&g_define_type_id__volatile)) { GType 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, (GTypeFlags) 0); } } static void gtk_notebook_class_init(GtkNotebookClass * class) { class->focus_tab = gtk_notebook_focus_tab; } static gboolean 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); } } } static gboolean gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook, GList ** children, GList * last_child, gboolean showarrow, gint direction, gint * remaining_space, gint * expanded_tabs, gint min, gint max) { GtkNotebookPrivate *priv; GtkNotebookPage *page; gboolean allocate_at_bottom; gint tab_overlap, tab_pos, tab_extra_space; gint left_x, right_x, top_y, bottom_y, anchor; gint xthickness, ythickness; gboolean gap_left, 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))); } } static void gtk_notebook_pages_allocate(GtkNotebook * notebook) { GList *children = ((void *)0); GList *last_child = ((void *)0); gboolean showarrow = (0); gint tab_space, min, max, remaining_space; gint expanded_tabs, operation; 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); } } static 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); }