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