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