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;
151 gint tab_extra_space;
159 gboolean packing_changed;
160 GtkAllocation child_allocation = {
163 while (*children && *children != last_child) {
165 (((GtkNotebookPage *) (page))->tab_label->parent ==
166 ((GtkWidget *) (notebook))))
169 && (showarrow || page->expand || notebook->homogeneous)) {
170 tab_extra_space = *remaining_space / *expanded_tabs;
171 *remaining_space -= tab_extra_space;
176 child_allocation.width =
177 page->requisition.width + tab_overlap +
179 if (priv->operation == DRAG_OPERATION_REORDER
180 && !gap_left && packing_changed) {
181 if (!allocate_at_bottom) {
182 if ((notebook->cur_page->pack ==
183 GTK_PACK_START && left_x >= anchor)
184 || (notebook->cur_page->pack ==
186 && left_x < anchor)) {
187 left_x = priv->drag_window_x =
194 if ((notebook->cur_page->pack ==
196 && right_x <= anchor)
197 || (notebook->cur_page->pack ==
199 && right_x > anchor)) {
203 left_x = priv->drag_window_x =
205 anchor += tab_overlap;
209 if (allocate_at_bottom)
210 anchor -= child_allocation.width;
211 if (priv->operation == DRAG_OPERATION_REORDER
212 && page->pack == notebook->cur_page->pack) {
213 if (!allocate_at_bottom
216 anchor + child_allocation.width / 2)
221 else if (allocate_at_bottom
224 child_allocation.width / 2
227 child_allocation.width)
233 child_allocation.x = anchor;
238 child_allocation.height =
239 page->requisition.height + tab_overlap +
241 if (priv->operation == DRAG_OPERATION_REORDER
242 && !gap_left && packing_changed) {
243 priv->drag_window_x = child_allocation.x;
244 priv->drag_window_y = top_y;
245 if (priv->operation == DRAG_OPERATION_REORDER
246 && page->pack == notebook->cur_page->pack) {
247 if (!allocate_at_bottom
251 child_allocation.height / 2)
259 if ((page == priv->detached_tab
260 && priv->operation == DRAG_OPERATION_DETACH)
261 || (page == notebook->cur_page
262 && priv->operation == DRAG_OPERATION_REORDER)) {
263 page->allocation.x = 0;
265 if (page != notebook->cur_page) {
268 page->allocation.y += ythickness;
270 page->allocation.height =
272 (page->allocation.height -
273 ythickness)) ? (1) : (page->allocation.
278 page->allocation.x += xthickness;
280 page->allocation.width =
282 (page->allocation.width -
283 xthickness)) ? (1) : (page->allocation.
291 if (priv->operation != DRAG_OPERATION_REORDER
292 || (priv->operation == DRAG_OPERATION_REORDER
293 && page != notebook->cur_page)) {
294 if (!allocate_at_bottom)
296 child_allocation.width -
301 if (priv->operation != DRAG_OPERATION_REORDER
302 || (priv->operation == DRAG_OPERATION_REORDER
303 && page != notebook->cur_page)) {
304 if (priv->operation == DRAG_OPERATION_REORDER) {
306 notebook->cur_page->pack
307 && !allocate_at_bottom
309 anchor + child_allocation.height / 2
311 anchor + child_allocation.height)
320 IA__gtk_widget_set_child_visible(page->tab_label,
324 static void gtk_notebook_pages_allocate(GtkNotebook * notebook)
326 GList *children = ((void *)0);
327 GList *last_child = ((void *)0);
328 gboolean showarrow = (0);
331 gint remaining_space;
333 gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child,
334 showarrow, STEP_NEXT,
335 &remaining_space, &expanded_tabs,
337 if (children && children != last_child) {
338 gtk_notebook_calculate_tabs_allocation(notebook, &children,
339 last_child, showarrow,
346 static void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
349 GtkNotebookPage *page;
350 if (((((((((GtkObject *) ((page->tab_label)))))->
351 flags)) & GTK_MAPPED) != 0))
352 gtk_notebook_redraw_tabs(notebook);
354 gtk_notebook_pages_allocate(notebook);