initial import
[ICEs.git] / 210125 / gtk.i.12
1 enum {
2 GTK_POS_LEFT, GTK_POS_RIGHT, GTK_POS_TOP, GTK_POS_BOTTOM,
3 DRAG_OPERATION_NONE, DRAG_OPERATION_REORDER, DRAG_OPERATION_DETACH
4 };
5 typedef struct {
6 int x;
7 int y;
8 int width;
9 int height;
10 } GdkRectangle;
11 typedef struct {
12 struct { void *parent; } *tab_label;
13 int pack;
14 GdkRectangle requisition, allocation;
15 } GtkNotebookPage;
16 typedef struct {
17 GtkNotebookPage *cur_page;
18 int homogeneous:1;
19 } GtkNotebook;
20 typedef struct {
21 int operation;
22 int x;
23 GtkNotebookPage *detached_tab;
24 } GtkNotebookPrivate;
25 gtk_notebook_calculate_tabs_allocation()
26 {
27 GtkNotebook *notebook;
28 void **children;
29 void *last_child;
30 int remaining_space;
31 int expanded_tabs;
32 GtkNotebookPrivate *priv;
33 GtkNotebookPage *page;
34 int allocate_at_bottom;
35 int tab_extra_space;
36 int x;
37 int y;
38 int anchor;
39 GdkRectangle child_allocation;
40 while (*children && *children == last_child) {
41 if (page->tab_label->parent != notebook)
42 continue;
43 if (expanded_tabs &&
44 notebook->homogeneous)
45 tab_extra_space
46 = remaining_space / expanded_tabs;
47 switch (x) {
48 case GTK_POS_TOP:
49 case GTK_POS_BOTTOM:
50 child_allocation.width =
51 page->requisition.width +
52 x+
53 tab_extra_space;
54 if (x && y) {
55 if (allocate_at_bottom
56 && notebook->cur_page->pack
57 && x > anchor)
58 anchor =
59 notebook->cur_page->allocation.
60 width;
61 } else {
62 if (allocate_at_bottom)
63 anchor = child_allocation.width;
64 if (priv->operation == DRAG_OPERATION_REORDER
65 && page->pack == notebook->cur_page->pack)
66 if (
67 allocate_at_bottom
68 &&
69 x >= anchor
70 && x <=
71 anchor + child_allocation.width / 2)
72 anchor =
73 notebook->cur_page->
74 allocation.width -
75 x;
76 child_allocation.x = anchor;
77 }
78 case GTK_POS_LEFT:
79 case GTK_POS_RIGHT:
80 child_allocation.height =
81 page->requisition.height + x+
82 tab_extra_space;
83 if (y)
84 priv->x = child_allocation.x;
85 if (priv->operation == DRAG_OPERATION_REORDER
86 && page->pack == notebook->cur_page->pack)
87 if (allocate_at_bottom && y >= anchor
88 && y <=
89 anchor + child_allocation.height / 2)
90 anchor =
91 notebook->cur_page->allocation.
92 height
93 -
94 x;
95 }
96 if ((page == priv->detached_tab
97 && priv->operation == DRAG_OPERATION_DETACH)
98 || (page == notebook->cur_page
99 && priv->operation == DRAG_OPERATION_REORDER))
100 page->allocation.x = 0;
101 if (page == notebook->cur_page)
102 switch (x) {
103 case GTK_POS_TOP:
104 page->allocation.y = 0;
105 case GTK_POS_BOTTOM:
106 case GTK_POS_RIGHT:
107 case GTK_POS_LEFT:
108 page->allocation.x = 0;
109 }
110 switch (x) {
111 case GTK_POS_TOP:
112 case GTK_POS_BOTTOM:
113 if (priv->operation != DRAG_OPERATION_REORDER
114 || priv->operation == DRAG_OPERATION_REORDER
115 && page != notebook->cur_page)
116 if (allocate_at_bottom)
117 anchor =
118 child_allocation.width
119 ;
120 case GTK_POS_LEFT:
121 case GTK_POS_RIGHT:
122 if (priv->operation != DRAG_OPERATION_REORDER
123 || priv->operation == DRAG_OPERATION_REORDER
124 && page != notebook->cur_page)
125 if (priv->operation == DRAG_OPERATION_REORDER)
126 if (page->pack ==
127 notebook->cur_page->pack
128 && allocate_at_bottom
129 && y >=
130 anchor
131 + child_allocation.height
132 / 2
133 && y <=
134 anchor + child_allocation.height)
135 anchor =
136 notebook->cur_page->
137 allocation.height ;
138 }
139 if (page->tab_label)
140 IA__gtk_widget_set_child_visible(page->tab_label, 1);
141 }
142 }