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