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