]> git.wh0rd.org - ICEs.git/blob - 210125/gtk.i.3
add bfin ice
[ICEs.git] / 210125 / gtk.i.3
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 gboolean gtk_notebook_focus_tab(GtkNotebook * notebook,
90 GtkNotebookTab type);
91 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
92 GList * new_child);
93 void gtk_notebook_init(GtkNotebook * self);
94 void gtk_notebook_class_init(GtkNotebookClass * klass);
95 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 gsize g_define_type_id__volatile;
102 if (g_once_init_enter(&g_define_type_id__volatile))
103 {
104 GType g_define_type_id =
105 g_type_register_static_simple((IA__gtk_container_get_type
106 ()),
107 g_intern_static_string
108 ("GtkNotebook"),
109 sizeof(GtkNotebookClass),
110 (GClassInitFunc)
111 gtk_notebook_class_intern_init,
112 sizeof(GtkNotebook),
113 (GInstanceInitFunc)
114 gtk_notebook_init,
115 (GTypeFlags) 0);
116 }
117 }
118 void gtk_notebook_class_init(GtkNotebookClass * class)
119 {
120 class->focus_tab = gtk_notebook_focus_tab;
121 }
122 gboolean gtk_notebook_focus_tab(GtkNotebook * notebook,
123 GtkNotebookTab type)
124 {
125 GList *list;
126 if (IA__gtk_widget_is_focus(((((GtkWidget *) ((notebook))))))
127 && notebook->show_tabs) {
128 switch (type) {
129 case GTK_NOTEBOOK_TAB_LAST:
130 list =
131 gtk_notebook_search_page(notebook, ((void *)0),
132 STEP_PREV, (!(0)));
133 if (list)
134 gtk_notebook_switch_focus_tab(notebook, list);
135 }
136 }
137 }
138 gboolean gtk_notebook_calculate_tabs_allocation(GtkNotebook * notebook,
139 GList ** children,
140 GList * last_child,
141 gboolean showarrow,
142 gint direction,
143 gint * remaining_space,
144 gint * expanded_tabs,
145 gint min, gint max)
146 {
147 GtkNotebookPrivate *priv;
148 GtkNotebookPage *page;
149 gboolean allocate_at_bottom;
150 gint tab_overlap;
151 gint tab_pos;
152 gint tab_extra_space;
153 gint left_x;
154 gint right_x;
155 gint top_y;
156 gint anchor;
157 gint xthickness;
158 gint ythickness;
159 gboolean gap_left;
160 gboolean packing_changed;
161 GtkAllocation child_allocation = {
162 0,
163 };
164 while (*children && *children != last_child) {
165 if (!
166 (((GtkNotebookPage *) (page))->tab_label->parent ==
167 ((GtkWidget *) (notebook))))
168 continue;
169 if (*expanded_tabs
170 && (showarrow || page->expand || notebook->homogeneous)) {
171 tab_extra_space = *remaining_space / *expanded_tabs;
172 *remaining_space -= tab_extra_space;
173 }
174 switch (tab_pos) {
175 case GTK_POS_TOP:
176 case GTK_POS_BOTTOM:
177 child_allocation.width =
178 page->requisition.width + tab_overlap +
179 tab_extra_space;
180 if (priv->operation == DRAG_OPERATION_REORDER
181 && !gap_left && packing_changed) {
182 if (!allocate_at_bottom) {
183 if ((notebook->cur_page->pack ==
184 GTK_PACK_START && left_x >= anchor)
185 || (notebook->cur_page->pack ==
186 GTK_PACK_END
187 && left_x < anchor)) {
188 left_x = priv->drag_window_x =
189 anchor;
190 anchor +=
191 notebook->cur_page->
192 allocation.width -
193 tab_overlap;
194 }
195 if ((notebook->cur_page->pack ==
196 GTK_PACK_START
197 && right_x <= anchor)
198 || (notebook->cur_page->pack ==
199 GTK_PACK_END
200 && right_x > anchor)) {
201 anchor -=
202 notebook->cur_page->
203 allocation.width;
204 left_x = priv->drag_window_x =
205 anchor;
206 anchor += tab_overlap;
207 }
208 }
209 } else {
210 if (allocate_at_bottom)
211 anchor -= child_allocation.width;
212 if (priv->operation == DRAG_OPERATION_REORDER
213 && page->pack == notebook->cur_page->pack) {
214 if (!allocate_at_bottom
215 && left_x >= anchor
216 && left_x <=
217 anchor + child_allocation.width / 2)
218 anchor +=
219 notebook->cur_page->
220 allocation.width -
221 tab_overlap;
222 else if (allocate_at_bottom
223 && right_x >=
224 anchor +
225 child_allocation.width / 2
226 && right_x <=
227 anchor +
228 child_allocation.width)
229 anchor -=
230 notebook->cur_page->
231 allocation.width -
232 tab_overlap;
233 }
234 child_allocation.x = anchor;
235 }
236 break;
237 case GTK_POS_LEFT:
238 case GTK_POS_RIGHT:
239 child_allocation.height =
240 page->requisition.height + tab_overlap +
241 tab_extra_space;
242 if (priv->operation == DRAG_OPERATION_REORDER
243 && !gap_left && packing_changed) {
244 priv->drag_window_x = child_allocation.x;
245 priv->drag_window_y = top_y;
246 if (priv->operation == DRAG_OPERATION_REORDER
247 && page->pack == notebook->cur_page->pack) {
248 if (!allocate_at_bottom
249 && top_y >= anchor
250 && top_y <=
251 anchor +
252 child_allocation.height / 2)
253 anchor +=
254 notebook->cur_page->
255 allocation.height -
256 tab_overlap;
257 }
258 }
259 }
260 if ((page == priv->detached_tab
261 && priv->operation == DRAG_OPERATION_DETACH)
262 || (page == notebook->cur_page
263 && priv->operation == DRAG_OPERATION_REORDER)) {
264 page->allocation.x = 0;
265 }
266 if (page != notebook->cur_page) {
267 switch (tab_pos) {
268 case GTK_POS_TOP:
269 page->allocation.y += ythickness;
270 case GTK_POS_BOTTOM:
271 page->allocation.height =
272 (((1) >
273 (page->allocation.height -
274 ythickness)) ? (1) : (page->allocation.
275 height -
276 ythickness));
277 break;
278 case GTK_POS_LEFT:
279 page->allocation.x += xthickness;
280 case GTK_POS_RIGHT:
281 page->allocation.width =
282 (((1) >
283 (page->allocation.width -
284 xthickness)) ? (1) : (page->allocation.
285 width -
286 xthickness));
287 }
288 }
289 switch (tab_pos) {
290 case GTK_POS_TOP:
291 case GTK_POS_BOTTOM:
292 if (priv->operation != DRAG_OPERATION_REORDER
293 || (priv->operation == DRAG_OPERATION_REORDER
294 && page != notebook->cur_page)) {
295 if (!allocate_at_bottom)
296 anchor +=
297 child_allocation.width -
298 tab_overlap;
299 }
300 case GTK_POS_LEFT:
301 case GTK_POS_RIGHT:
302 if (priv->operation != DRAG_OPERATION_REORDER
303 || (priv->operation == DRAG_OPERATION_REORDER
304 && page != notebook->cur_page)) {
305 if (priv->operation == DRAG_OPERATION_REORDER) {
306 if (page->pack ==
307 notebook->cur_page->pack
308 && !allocate_at_bottom
309 && top_y >=
310 anchor + child_allocation.height / 2
311 && top_y <=
312 anchor + child_allocation.height)
313 anchor +=
314 notebook->cur_page->
315 allocation.height -
316 tab_overlap;
317 }
318 }
319 }
320 if (page->tab_label)
321 IA__gtk_widget_set_child_visible(page->tab_label,
322 (!(0)));
323 }
324 }
325 void gtk_notebook_pages_allocate(GtkNotebook * notebook)
326 {
327 GList *children = ((void *)0);
328 GList *last_child = ((void *)0);
329 gboolean showarrow = (0);
330 gint min;
331 gint max;
332 gint remaining_space;
333 gint expanded_tabs;
334 gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child,
335 showarrow, STEP_NEXT,
336 &remaining_space, &expanded_tabs,
337 min, max);
338 if (children && children != last_child) {
339 gtk_notebook_calculate_tabs_allocation(notebook, &children,
340 last_child, showarrow,
341 STEP_PREV,
342 &remaining_space,
343 &expanded_tabs, min,
344 max);
345 }
346 }
347 void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
348 GList * new_child)
349 {
350 GtkNotebookPage *page;
351 if (((((((((GtkObject *) ((page->tab_label)))))->
352 flags)) & GTK_MAPPED) != 0))
353 gtk_notebook_redraw_tabs(notebook);
354 else
355 gtk_notebook_pages_allocate(notebook);
356 }