]> git.wh0rd.org - ICEs.git/blame - 210125/gtk.i.4
initial import
[ICEs.git] / 210125 / gtk.i.4
CommitLineData
45516216 1typedef void *gpointer;
2typedef struct _GList GList;
3typedef struct _unsigned intInstance unsigned intInstance;
4typedef void (*GClassInitFunc) (gpointer g_class, gpointer class_data);
5typedef void (*GInstanceInitFunc) (unsigned intInstance * instance, gpointer g_class);
6typedef enum {
7 G_TYPE_FLAG_CLASSED = (1 << 0), G_TYPE_FLAG_INSTANTIATABLE =
8 (1 << 1), G_TYPE_FLAG_DERIVABLE =
9 (1 << 2), G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3)
10} unsigned intFlags;
11typedef struct _GdkRectangle GdkRectangle;
12struct _GdkRectangle {
13 int x;
14 int y;
15 int width;
16 int height;
17};
18typedef enum {
19 GTK_PACK_START, GTK_PACK_END
20} GtkPathType;
21typedef enum {
22 GTK_POS_LEFT, GTK_POS_RIGHT, GTK_POS_TOP, GTK_POS_BOTTOM
23} GtkPreviewType;
24typedef struct _GtkObject GtkObject;
25struct _GtkObject {
26 unsigned int flags;
27};
28typedef struct _GtkWidget GtkWidget;
29typedef enum {
30 GTK_TOPLEVEL = 1 << 4, GTK_NO_WINDOW = 1 << 5, GTK_REALIZED =
31 1 << 6, GTK_MAPPED = 1 << 7, GTK_VISIBLE = 1 << 8, GTK_SENSITIVE =
32 1 << 9, GTK_PARENT_SENSITIVE = 1 << 10, GTK_CAN_FOCUS =
33 1 << 11, GTK_HAS_FOCUS = 1 << 12, GTK_CAN_DEFAULT =
34 1 << 13, GTK_HAS_DEFAULT = 1 << 14, GTK_HAS_GRAB =
35 1 << 15, GTK_RC_STYLE = 1 << 16, GTK_COMPOSITE_CHILD =
36 1 << 17, GTK_NO_REPARENT = 1 << 18, GTK_APP_PAINTABLE =
37 1 << 19, GTK_RECEIVES_DEFAULT = 1 << 20, GTK_DOUBLE_BUFFERED =
38 1 << 21, GTK_NO_SHOW_ALL = 1 << 22
39} GtkWidgetFlags;
40typedef struct _GtkRequisition GtkRequisition;
41typedef GdkRectangle GtkAllocation;
42struct _GtkRequisition {
43 int width;
44 int height;
45};
46struct _GtkWidget {
47 GtkWidget *parent;
48};
49typedef enum {
50 GTK_NOTEBOOK_TAB_FIRST, GTK_NOTEBOOK_TAB_LAST
51} GtkNotebookTab;
52typedef struct _GtkNotebook GtkNotebook;
53typedef struct _GtkNotebookClass GtkNotebookClass;
54typedef struct _GtkNotebookPage GtkNotebookPage;
55struct _GtkNotebook {
56 GtkNotebookPage *cur_page;
57 unsigned int show_tabs:1;
58 unsigned int homogeneous:1;
59};
60struct _GtkNotebookClass {
61 int(*focus_tab) (GtkNotebook * notebook, GtkNotebookTab type);
62};
63enum {
64 STEP_PREV, STEP_NEXT
65};
66typedef enum {
67 DRAG_OPERATION_NONE, DRAG_OPERATION_REORDER, DRAG_OPERATION_DETACH
68} GtkNotebookDragOperation;
69struct _GtkNotebookPage {
70 GtkWidget *tab_label;
71 unsigned int expand:1;
72 unsigned int pack:1;
73 GtkRequisition requisition;
74 GtkAllocation allocation;
75};
76typedef struct _GtkNotebookPrivate GtkNotebookPrivate;
77struct _GtkNotebookPrivate {
78 GtkNotebookDragOperation operation;
79 int drag_window_x;
80 int drag_window_y;
81 GtkNotebookPage *detached_tab;
82};
83 int gtk_notebook_focus_tab(GtkNotebook * notebook,
84 GtkNotebookTab type);
85 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
86 GList * new_child);
87 void gtk_notebook_init(GtkNotebook * self);
88 void gtk_notebook_class_init(GtkNotebookClass * klass);
89 void gtk_notebook_class_intern_init(gpointer klass)
90{
91 gtk_notebook_class_init((GtkNotebookClass *) klass);
92}
93unsigned int IA__gtk_notebook_get_type(void)
94{
95 unsigned int g_define_type_id__volatile;
96 if (g_once_init_enter(&g_define_type_id__volatile))
97{
98 unsigned int g_define_type_id =
99 g_type_register_static_simple((IA__gtk_container_get_type
100 ()),
101 g_intern_static_string
102 ("GtkNotebook"),
103 sizeof(GtkNotebookClass),
104 (GClassInitFunc)
105 gtk_notebook_class_intern_init,
106 sizeof(GtkNotebook),
107 (GInstanceInitFunc)
108 gtk_notebook_init,
109 (unsigned intFlags) 0);
110}
111}
112 void gtk_notebook_class_init(GtkNotebookClass * class)
113{
114 class->focus_tab = gtk_notebook_focus_tab;
115}
116 int gtk_notebook_focus_tab(GtkNotebook * notebook,
117 GtkNotebookTab type)
118{
119 GList *list;
120 if (IA__gtk_widget_is_focus(((((GtkWidget *) ((notebook))))))
121 && notebook->show_tabs) {
122 switch (type) {
123 case GTK_NOTEBOOK_TAB_LAST:
124 list =
125 gtk_notebook_search_page(notebook, ((void *)0),
126 STEP_PREV, (!(0)));
127 if (list)
128 gtk_notebook_switch_focus_tab(notebook, list);
129 }
130 }
131}
132 int gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook,
133 GList ** children,
134 GList * last_child,
135 int showarrow,
136 int direction,
137 int * remaining_space,
138 int * expanded_tabs,
139 int min, int max)
140{
141 GtkNotebookPrivate *priv;
142 GtkNotebookPage *page;
143 int allocate_at_bottom;
144 int tab_overlap;
145 int tab_pos;
146 int tab_extra_space;
147 int left_x;
148 int right_x;
149 int top_y;
150 int anchor;
151 int xthickness;
152 int ythickness;
153 int gap_left;
154 int packing_changed;
155 GtkAllocation child_allocation = {
156 0,
157 };
158 while (*children && *children != last_child) {
159 if (!
160 (((GtkNotebookPage *) (page))->tab_label->parent ==
161 ((GtkWidget *) (notebook))))
162 continue;
163 if (*expanded_tabs
164 && (showarrow || page->expand || notebook->homogeneous)) {
165 tab_extra_space = *remaining_space / *expanded_tabs;
166 *remaining_space -= tab_extra_space;
167 }
168 switch (tab_pos) {
169 case GTK_POS_TOP:
170 case GTK_POS_BOTTOM:
171 child_allocation.width =
172 page->requisition.width + tab_overlap +
173 tab_extra_space;
174 if (priv->operation == DRAG_OPERATION_REORDER
175 && !gap_left && packing_changed) {
176 if (!allocate_at_bottom) {
177 if ((notebook->cur_page->pack ==
178 GTK_PACK_START && left_x >= anchor)
179 || (notebook->cur_page->pack ==
180 GTK_PACK_END
181 && left_x < anchor)) {
182 left_x = priv->drag_window_x =
183 anchor;
184 anchor +=
185 notebook->cur_page->
186 allocation.width -
187 tab_overlap;
188 }
189 if ((notebook->cur_page->pack ==
190 GTK_PACK_START
191 && right_x <= anchor)
192 || (notebook->cur_page->pack ==
193 GTK_PACK_END
194 && right_x > anchor)) {
195 anchor -=
196 notebook->cur_page->
197 allocation.width;
198 left_x = priv->drag_window_x =
199 anchor;
200 anchor += tab_overlap;
201 }
202 }
203 } else {
204 if (allocate_at_bottom)
205 anchor -= child_allocation.width;
206 if (priv->operation == DRAG_OPERATION_REORDER
207 && page->pack == notebook->cur_page->pack) {
208 if (!allocate_at_bottom
209 && left_x >= anchor
210 && left_x <=
211 anchor + child_allocation.width / 2)
212 anchor +=
213 notebook->cur_page->
214 allocation.width -
215 tab_overlap;
216 else if (allocate_at_bottom
217 && right_x >=
218 anchor +
219 child_allocation.width / 2
220 && right_x <=
221 anchor +
222 child_allocation.width)
223 anchor -=
224 notebook->cur_page->
225 allocation.width -
226 tab_overlap;
227 }
228 child_allocation.x = anchor;
229 }
230 break;
231 case GTK_POS_LEFT:
232 case GTK_POS_RIGHT:
233 child_allocation.height =
234 page->requisition.height + tab_overlap +
235 tab_extra_space;
236 if (priv->operation == DRAG_OPERATION_REORDER
237 && !gap_left && packing_changed) {
238 priv->drag_window_x = child_allocation.x;
239 priv->drag_window_y = top_y;
240 if (priv->operation == DRAG_OPERATION_REORDER
241 && page->pack == notebook->cur_page->pack) {
242 if (!allocate_at_bottom
243 && top_y >= anchor
244 && top_y <=
245 anchor +
246 child_allocation.height / 2)
247 anchor +=
248 notebook->cur_page->
249 allocation.height -
250 tab_overlap;
251 }
252 }
253 }
254 if ((page == priv->detached_tab
255 && priv->operation == DRAG_OPERATION_DETACH)
256 || (page == notebook->cur_page
257 && priv->operation == DRAG_OPERATION_REORDER)) {
258 page->allocation.x = 0;
259 }
260 if (page != notebook->cur_page) {
261 switch (tab_pos) {
262 case GTK_POS_TOP:
263 page->allocation.y += ythickness;
264 case GTK_POS_BOTTOM:
265 page->allocation.height =
266 (((1) >
267 (page->allocation.height -
268 ythickness)) ? (1) : (page->allocation.
269 height -
270 ythickness));
271 break;
272 case GTK_POS_LEFT:
273 page->allocation.x += xthickness;
274 case GTK_POS_RIGHT:
275 page->allocation.width =
276 (((1) >
277 (page->allocation.width -
278 xthickness)) ? (1) : (page->allocation.
279 width -
280 xthickness));
281 }
282 }
283 switch (tab_pos) {
284 case GTK_POS_TOP:
285 case GTK_POS_BOTTOM:
286 if (priv->operation != DRAG_OPERATION_REORDER
287 || (priv->operation == DRAG_OPERATION_REORDER
288 && page != notebook->cur_page)) {
289 if (!allocate_at_bottom)
290 anchor +=
291 child_allocation.width -
292 tab_overlap;
293 }
294 case GTK_POS_LEFT:
295 case GTK_POS_RIGHT:
296 if (priv->operation != DRAG_OPERATION_REORDER
297 || (priv->operation == DRAG_OPERATION_REORDER
298 && page != notebook->cur_page)) {
299 if (priv->operation == DRAG_OPERATION_REORDER) {
300 if (page->pack ==
301 notebook->cur_page->pack
302 && !allocate_at_bottom
303 && top_y >=
304 anchor + child_allocation.height / 2
305 && top_y <=
306 anchor + child_allocation.height)
307 anchor +=
308 notebook->cur_page->
309 allocation.height -
310 tab_overlap;
311 }
312 }
313 }
314 if (page->tab_label)
315 IA__gtk_widget_set_child_visible(page->tab_label,
316 (!(0)));
317 }
318}
319 void gtk_notebook_pages_allocate(GtkNotebook * notebook)
320{
321 GList *children = ((void *)0);
322 GList *last_child = ((void *)0);
323 int showarrow = (0);
324 int min;
325 int max;
326 int remaining_space;
327 int expanded_tabs;
328 gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child,
329 showarrow, STEP_NEXT,
330 &remaining_space, &expanded_tabs,
331 min, max);
332 if (children && children != last_child) {
333 gtk_notebook_calculate_tabs_allocation(notebook, &children,
334 last_child, showarrow,
335 STEP_PREV,
336 &remaining_space,
337 &expanded_tabs, min,
338 max);
339 }
340}
341 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
342 GList * new_child)
343{
344 GtkNotebookPage *page;
345 if (((((((((GtkObject *) ((page->tab_label)))))->
346 flags)) & GTK_MAPPED) != 0))
347 gtk_notebook_redraw_tabs(notebook);
348 else
349 gtk_notebook_pages_allocate(notebook);
350}