initial import
[ICEs.git] / 210125 / gtk.i.1
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, tab_pos, tab_extra_space;
150 gint left_x, right_x, top_y, bottom_y, anchor;
151 gint xthickness, ythickness;
152 gboolean gap_left, packing_changed;
153 GtkAllocation child_allocation = {
154 0,
155 };
156 while (*children && *children != last_child) {
157 if (!
158 (((GtkNotebookPage *) (page))->tab_label->parent ==
159 ((GtkWidget *) (notebook))))
160 continue;
161 if (*expanded_tabs
162 && (showarrow || page->expand || notebook->homogeneous)) {
163 tab_extra_space = *remaining_space / *expanded_tabs;
164 *remaining_space -= tab_extra_space;
165 }
166 switch (tab_pos) {
167 case GTK_POS_TOP:
168 case GTK_POS_BOTTOM:
169 child_allocation.width =
170 page->requisition.width + tab_overlap +
171 tab_extra_space;
172 if (priv->operation == DRAG_OPERATION_REORDER
173 && !gap_left && packing_changed) {
174 if (!allocate_at_bottom) {
175 if ((notebook->cur_page->pack ==
176 GTK_PACK_START && left_x >= anchor)
177 || (notebook->cur_page->pack ==
178 GTK_PACK_END
179 && left_x < anchor)) {
180 left_x = priv->drag_window_x =
181 anchor;
182 anchor +=
183 notebook->cur_page->
184 allocation.width -
185 tab_overlap;
186 }
187 if ((notebook->cur_page->pack ==
188 GTK_PACK_START
189 && right_x <= anchor)
190 || (notebook->cur_page->pack ==
191 GTK_PACK_END
192 && right_x > anchor)) {
193 anchor -=
194 notebook->cur_page->
195 allocation.width;
196 left_x = priv->drag_window_x =
197 anchor;
198 anchor += tab_overlap;
199 }
200 }
201 } else {
202 if (allocate_at_bottom)
203 anchor -= child_allocation.width;
204 if (priv->operation == DRAG_OPERATION_REORDER
205 && page->pack == notebook->cur_page->pack) {
206 if (!allocate_at_bottom
207 && left_x >= anchor
208 && left_x <=
209 anchor + child_allocation.width / 2)
210 anchor +=
211 notebook->cur_page->
212 allocation.width -
213 tab_overlap;
214 else if (allocate_at_bottom
215 && right_x >=
216 anchor +
217 child_allocation.width / 2
218 && right_x <=
219 anchor +
220 child_allocation.width)
221 anchor -=
222 notebook->cur_page->
223 allocation.width -
224 tab_overlap;
225 }
226 child_allocation.x = anchor;
227 }
228 break;
229 case GTK_POS_LEFT:
230 case GTK_POS_RIGHT:
231 child_allocation.height =
232 page->requisition.height + tab_overlap +
233 tab_extra_space;
234 if (priv->operation == DRAG_OPERATION_REORDER
235 && !gap_left && packing_changed) {
236 priv->drag_window_x = child_allocation.x;
237 priv->drag_window_y = top_y;
238 if (priv->operation == DRAG_OPERATION_REORDER
239 && page->pack == notebook->cur_page->pack) {
240 if (!allocate_at_bottom
241 && top_y >= anchor
242 && top_y <=
243 anchor +
244 child_allocation.height / 2)
245 anchor +=
246 notebook->cur_page->
247 allocation.height -
248 tab_overlap;
249 }
250 }
251 }
252 if ((page == priv->detached_tab
253 && priv->operation == DRAG_OPERATION_DETACH)
254 || (page == notebook->cur_page
255 && priv->operation == DRAG_OPERATION_REORDER)) {
256 page->allocation.x = 0;
257 }
258 if (page != notebook->cur_page) {
259 switch (tab_pos) {
260 case GTK_POS_TOP:
261 page->allocation.y += ythickness;
262 case GTK_POS_BOTTOM:
263 page->allocation.height =
264 (((1) >
265 (page->allocation.height -
266 ythickness)) ? (1) : (page->allocation.
267 height -
268 ythickness));
269 break;
270 case GTK_POS_LEFT:
271 page->allocation.x += xthickness;
272 case GTK_POS_RIGHT:
273 page->allocation.width =
274 (((1) >
275 (page->allocation.width -
276 xthickness)) ? (1) : (page->allocation.
277 width -
278 xthickness));
279 }
280 }
281 switch (tab_pos) {
282 case GTK_POS_TOP:
283 case GTK_POS_BOTTOM:
284 if (priv->operation != DRAG_OPERATION_REORDER
285 || (priv->operation == DRAG_OPERATION_REORDER
286 && page != notebook->cur_page)) {
287 if (!allocate_at_bottom)
288 anchor +=
289 child_allocation.width -
290 tab_overlap;
291 }
292 case GTK_POS_LEFT:
293 case GTK_POS_RIGHT:
294 if (priv->operation != DRAG_OPERATION_REORDER
295 || (priv->operation == DRAG_OPERATION_REORDER
296 && page != notebook->cur_page)) {
297 if (priv->operation == DRAG_OPERATION_REORDER) {
298 if (page->pack ==
299 notebook->cur_page->pack
300 && !allocate_at_bottom
301 && top_y >=
302 anchor + child_allocation.height / 2
303 && top_y <=
304 anchor + child_allocation.height)
305 anchor +=
306 notebook->cur_page->
307 allocation.height -
308 tab_overlap;
309 }
310 }
311 }
312 if (page->tab_label)
313 IA__gtk_widget_set_child_visible(page->tab_label,
314 (!(0)));
315 }
316 }
317 static void gtk_notebook_pages_allocate(GtkNotebook * notebook)
318 {
319 GList *children = ((void *)0);
320 GList *last_child = ((void *)0);
321 gboolean showarrow = (0);
322 gint tab_space, min, max, remaining_space;
323 gint expanded_tabs, operation;
324 gtk_notebook_calculate_tabs_allocation(notebook, &children, last_child,
325 showarrow, STEP_NEXT,
326 &remaining_space, &expanded_tabs,
327 min, max);
328 if (children && children != last_child) {
329 gtk_notebook_calculate_tabs_allocation(notebook, &children,
330 last_child, showarrow,
331 STEP_PREV,
332 &remaining_space,
333 &expanded_tabs, min,
334 max);
335 }
336 }
337 static void gtk_notebook_switch_focus_tab(GtkNotebook * notebook,
338 GList * new_child)
339 {
340 GtkNotebookPage *page;
341 if (((((((((GtkObject *) ((page->tab_label)))))->
342 flags)) & GTK_MAPPED) != 0))
343 gtk_notebook_redraw_tabs(notebook);
344 else
345 gtk_notebook_pages_allocate(notebook);
346 }