Mercurial > vim
annotate src/gui_gtk_f.c @ 14972:5d52b21b2e7f v8.1.0497
patch 8.1.0497: :%diffput changes order of lines
commit https://github.com/vim/vim/commit/5f57bdcab77bc417ae0357fe8ad6c7259b6d25df
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 25 17:52:23 2018 +0200
patch 8.1.0497: :%diffput changes order of lines
Problem: :%diffput changes order of lines. (Markus Braun)
Solution: Do adjust marks when using internal diff.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 25 Oct 2018 18:00:07 +0200 |
parents | 11978f68a8c3 |
children | 7fad90423bd2 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
8218
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
66 | 11 * (C) 1998,1999 by Marcin Dalecki <martin@dalecki.de> |
7 | 12 * |
13 * Support for GTK+ 2 was added by: | |
14 * | |
15 * (C) 2002,2003 Jason Hildebrand <jason@peaceworks.ca> | |
16 * Daniel Elstner <daniel.elstner@gmx.net> | |
17 * | |
1207 | 18 * This is a special purpose container widget, which manages arbitrary |
19 * children at arbitrary positions width arbitrary sizes. This finally puts | |
20 * an end on our resize problems with which we where struggling for such a | |
21 * long time. | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
22 * |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
23 * Support for GTK+ 3 was added by: |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
24 * |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
25 * 2016 Kazunobu Kuriyama <kazunobu.kuriyama@gmail.com> |
7 | 26 */ |
27 | |
28 #include "vim.h" | |
29 #include <gtk/gtk.h> /* without this it compiles, but gives errors at | |
30 runtime! */ | |
31 #include "gui_gtk_f.h" | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
32 #if !GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
33 # include <gtk/gtksignal.h> |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
34 #endif |
7 | 35 #ifdef WIN3264 |
36 # include <gdk/gdkwin32.h> | |
37 #else | |
38 # include <gdk/gdkx.h> | |
39 #endif | |
40 | |
41 typedef struct _GtkFormChild GtkFormChild; | |
42 | |
43 struct _GtkFormChild | |
44 { | |
45 GtkWidget *widget; | |
46 GdkWindow *window; | |
47 gint x; /* relative subwidget x position */ | |
48 gint y; /* relative subwidget y position */ | |
49 gint mapped; | |
50 }; | |
51 | |
52 | |
53 static void gtk_form_class_init(GtkFormClass *klass); | |
54 static void gtk_form_init(GtkForm *form); | |
55 | |
56 static void gtk_form_realize(GtkWidget *widget); | |
57 static void gtk_form_unrealize(GtkWidget *widget); | |
58 static void gtk_form_map(GtkWidget *widget); | |
59 static void gtk_form_size_request(GtkWidget *widget, | |
60 GtkRequisition *requisition); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
61 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
62 static void gtk_form_get_preferred_width(GtkWidget *widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
63 gint *minimal_width, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
64 gint *natural_width); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
65 static void gtk_form_get_preferred_height(GtkWidget *widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
66 gint *minimal_height, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
67 gint *natural_height); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
68 #endif |
7 | 69 static void gtk_form_size_allocate(GtkWidget *widget, |
70 GtkAllocation *allocation); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
71 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
72 static gboolean gtk_form_draw(GtkWidget *widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
73 cairo_t *cr); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
74 #else |
7 | 75 static gint gtk_form_expose(GtkWidget *widget, |
76 GdkEventExpose *event); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
77 #endif |
7 | 78 |
79 static void gtk_form_remove(GtkContainer *container, | |
80 GtkWidget *widget); | |
81 static void gtk_form_forall(GtkContainer *container, | |
82 gboolean include_internals, | |
83 GtkCallback callback, | |
84 gpointer callback_data); | |
85 | |
86 static void gtk_form_attach_child_window(GtkForm *form, | |
87 GtkFormChild *child); | |
88 static void gtk_form_realize_child(GtkForm *form, | |
89 GtkFormChild *child); | |
90 static void gtk_form_position_child(GtkForm *form, | |
91 GtkFormChild *child, | |
92 gboolean force_allocate); | |
93 static void gtk_form_position_children(GtkForm *form); | |
94 | |
95 static void gtk_form_send_configure(GtkForm *form); | |
96 | |
97 static void gtk_form_child_map(GtkWidget *widget, gpointer user_data); | |
98 static void gtk_form_child_unmap(GtkWidget *widget, gpointer user_data); | |
99 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
100 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 101 static GtkWidgetClass *parent_class = NULL; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
102 #endif |
7 | 103 |
104 /* Public interface | |
105 */ | |
106 | |
107 GtkWidget * | |
108 gtk_form_new(void) | |
109 { | |
110 GtkForm *form; | |
111 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
112 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
113 form = g_object_new(GTK_TYPE_FORM, NULL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
114 #else |
7 | 115 form = gtk_type_new(gtk_form_get_type()); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
116 #endif |
7 | 117 |
118 return GTK_WIDGET(form); | |
119 } | |
120 | |
121 void | |
122 gtk_form_put(GtkForm *form, | |
123 GtkWidget *child_widget, | |
124 gint x, | |
125 gint y) | |
126 { | |
127 GtkFormChild *child; | |
128 | |
129 g_return_if_fail(GTK_IS_FORM(form)); | |
130 | |
129 | 131 /* LINTED: avoid warning: conversion to 'unsigned long' */ |
7 | 132 child = g_new(GtkFormChild, 1); |
133 | |
134 child->widget = child_widget; | |
135 child->window = NULL; | |
136 child->x = x; | |
137 child->y = y; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
138 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
139 gtk_widget_set_size_request(child->widget, -1, -1); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
140 #else |
7 | 141 child->widget->requisition.width = 0; |
142 child->widget->requisition.height = 0; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
143 #endif |
7 | 144 child->mapped = FALSE; |
145 | |
146 form->children = g_list_append(form->children, child); | |
147 | |
148 /* child->window must be created and attached to the widget _before_ | |
149 * it has been realized, or else things will break with GTK2. Note | |
150 * that gtk_widget_set_parent() realizes the widget if it's visible | |
151 * and its parent is mapped. | |
152 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
153 if (gtk_widget_get_realized(GTK_WIDGET(form))) |
7 | 154 gtk_form_attach_child_window(form, child); |
155 | |
156 gtk_widget_set_parent(child_widget, GTK_WIDGET(form)); | |
157 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
158 if (gtk_widget_get_realized(GTK_WIDGET(form)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
159 && !gtk_widget_get_realized(child_widget)) |
7 | 160 gtk_form_realize_child(form, child); |
161 | |
162 gtk_form_position_child(form, child, TRUE); | |
163 } | |
164 | |
165 void | |
166 gtk_form_move(GtkForm *form, | |
167 GtkWidget *child_widget, | |
168 gint x, | |
169 gint y) | |
170 { | |
171 GList *tmp_list; | |
172 GtkFormChild *child; | |
173 | |
174 g_return_if_fail(GTK_IS_FORM(form)); | |
175 | |
176 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
177 { | |
178 child = tmp_list->data; | |
179 if (child->widget == child_widget) | |
180 { | |
181 child->x = x; | |
182 child->y = y; | |
183 | |
184 gtk_form_position_child(form, child, TRUE); | |
185 return; | |
186 } | |
187 } | |
188 } | |
189 | |
190 void | |
191 gtk_form_freeze(GtkForm *form) | |
192 { | |
193 g_return_if_fail(GTK_IS_FORM(form)); | |
194 | |
195 ++form->freeze_count; | |
196 } | |
197 | |
198 void | |
199 gtk_form_thaw(GtkForm *form) | |
200 { | |
201 g_return_if_fail(GTK_IS_FORM(form)); | |
202 | |
203 if (form->freeze_count) | |
204 { | |
205 if (!(--form->freeze_count)) | |
206 { | |
207 gtk_form_position_children(form); | |
208 gtk_widget_queue_draw(GTK_WIDGET(form)); | |
209 } | |
210 } | |
211 } | |
212 | |
213 /* Basic Object handling procedures | |
214 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
215 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
216 G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
217 #else |
7 | 218 GtkType |
219 gtk_form_get_type(void) | |
220 { | |
221 static GtkType form_type = 0; | |
222 | |
223 if (!form_type) | |
224 { | |
1884 | 225 GtkTypeInfo form_info; |
226 | |
1885 | 227 vim_memset(&form_info, 0, sizeof(form_info)); |
1884 | 228 form_info.type_name = "GtkForm"; |
229 form_info.object_size = sizeof(GtkForm); | |
230 form_info.class_size = sizeof(GtkFormClass); | |
231 form_info.class_init_func = (GtkClassInitFunc)gtk_form_class_init; | |
232 form_info.object_init_func = (GtkObjectInitFunc)gtk_form_init; | |
7 | 233 |
234 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info); | |
235 } | |
236 return form_type; | |
237 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
238 #endif /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 239 |
240 static void | |
241 gtk_form_class_init(GtkFormClass *klass) | |
242 { | |
243 GtkWidgetClass *widget_class; | |
244 GtkContainerClass *container_class; | |
245 | |
246 widget_class = (GtkWidgetClass *) klass; | |
247 container_class = (GtkContainerClass *) klass; | |
248 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
249 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 250 parent_class = gtk_type_class(gtk_container_get_type()); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
251 #endif |
7 | 252 |
253 widget_class->realize = gtk_form_realize; | |
254 widget_class->unrealize = gtk_form_unrealize; | |
255 widget_class->map = gtk_form_map; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
256 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
257 widget_class->get_preferred_width = gtk_form_get_preferred_width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
258 widget_class->get_preferred_height = gtk_form_get_preferred_height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
259 #else |
7 | 260 widget_class->size_request = gtk_form_size_request; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
261 #endif |
7 | 262 widget_class->size_allocate = gtk_form_size_allocate; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
263 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
264 widget_class->draw = gtk_form_draw; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
265 #else |
7 | 266 widget_class->expose_event = gtk_form_expose; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
267 #endif |
7 | 268 |
269 container_class->remove = gtk_form_remove; | |
270 container_class->forall = gtk_form_forall; | |
271 } | |
272 | |
273 static void | |
274 gtk_form_init(GtkForm *form) | |
275 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
276 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
277 gtk_widget_set_has_window(GTK_WIDGET(form), TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
278 #endif |
7 | 279 form->children = NULL; |
280 form->bin_window = NULL; | |
281 form->freeze_count = 0; | |
282 } | |
283 | |
284 /* | |
285 * Widget methods | |
286 */ | |
287 | |
288 static void | |
289 gtk_form_realize(GtkWidget *widget) | |
290 { | |
291 GList *tmp_list; | |
292 GtkForm *form; | |
293 GdkWindowAttr attributes; | |
294 gint attributes_mask; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
295 GtkAllocation allocation; |
7 | 296 |
297 g_return_if_fail(GTK_IS_FORM(widget)); | |
298 | |
299 form = GTK_FORM(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
300 gtk_widget_set_realized(widget, TRUE); |
7 | 301 |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
302 gtk_widget_get_allocation(widget, &allocation); |
7 | 303 attributes.window_type = GDK_WINDOW_CHILD; |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
304 attributes.x = allocation.x; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
305 attributes.y = allocation.y; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
306 attributes.width = allocation.width; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
307 attributes.height = allocation.height; |
7 | 308 attributes.wclass = GDK_INPUT_OUTPUT; |
309 attributes.visual = gtk_widget_get_visual(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
310 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
311 attributes.event_mask = GDK_EXPOSURE_MASK; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
312 #else |
7 | 313 attributes.colormap = gtk_widget_get_colormap(widget); |
314 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
315 #endif |
7 | 316 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
317 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
318 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
319 #else |
7 | 320 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
321 #endif |
7 | 322 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
323 gtk_widget_set_window(widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
324 gdk_window_new(gtk_widget_get_parent_window(widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
325 &attributes, attributes_mask)); |
14712
82e7ce311065
patch 8.1.0368: GTK code has too many #ifdefs and GTK 2.10 building fails
Christian Brabandt <cb@256bit.org>
parents:
11343
diff
changeset
|
326 gdk_window_set_user_data(gtk_widget_get_window(widget), widget); |
7 | 327 |
328 attributes.x = 0; | |
329 attributes.y = 0; | |
330 attributes.event_mask = gtk_widget_get_events(widget); | |
331 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
332 form->bin_window = gdk_window_new(gtk_widget_get_window(widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
333 &attributes, attributes_mask); |
7 | 334 gdk_window_set_user_data(form->bin_window, widget); |
335 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
336 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
337 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
338 GtkStyleContext * const sctx = gtk_widget_get_style_context(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
339 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
340 gtk_style_context_add_class(sctx, "gtk-form"); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
341 gtk_style_context_set_state(sctx, GTK_STATE_FLAG_NORMAL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
342 # if !GTK_CHECK_VERSION(3,18,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
343 gtk_style_context_set_background(sctx, gtk_widget_get_window(widget)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
344 gtk_style_context_set_background(sctx, form->bin_window); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
345 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
346 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
347 #else |
7 | 348 widget->style = gtk_style_attach(widget->style, widget->window); |
349 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); | |
350 gtk_style_set_background(widget->style, form->bin_window, GTK_STATE_NORMAL); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
351 #endif |
7 | 352 |
353 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
354 { | |
355 GtkFormChild *child = tmp_list->data; | |
356 | |
357 gtk_form_attach_child_window(form, child); | |
358 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
359 if (gtk_widget_get_visible(child->widget)) |
7 | 360 gtk_form_realize_child(form, child); |
361 } | |
362 } | |
363 | |
364 | |
365 /* After reading the documentation at | |
366 * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html | |
367 * I think it should be possible to remove this function when compiling | |
368 * against gtk-2.0. It doesn't seem to cause problems, though. | |
369 * | |
370 * Well, I reckon at least the gdk_window_show(form->bin_window) | |
371 * is necessary. GtkForm is anything but a usual container widget. | |
372 */ | |
373 static void | |
374 gtk_form_map(GtkWidget *widget) | |
375 { | |
376 GList *tmp_list; | |
377 GtkForm *form; | |
378 | |
379 g_return_if_fail(GTK_IS_FORM(widget)); | |
380 | |
381 form = GTK_FORM(widget); | |
382 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
383 gtk_widget_set_mapped(widget, TRUE); |
7 | 384 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
385 gdk_window_show(gtk_widget_get_window(widget)); |
7 | 386 gdk_window_show(form->bin_window); |
387 | |
388 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
389 { | |
390 GtkFormChild *child = tmp_list->data; | |
391 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
392 if (gtk_widget_get_visible(child->widget) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
393 && !gtk_widget_get_mapped(child->widget)) |
7 | 394 gtk_widget_map(child->widget); |
395 } | |
396 } | |
397 | |
398 static void | |
399 gtk_form_unrealize(GtkWidget *widget) | |
400 { | |
401 GList *tmp_list; | |
402 GtkForm *form; | |
403 | |
404 g_return_if_fail(GTK_IS_FORM(widget)); | |
405 | |
406 form = GTK_FORM(widget); | |
407 | |
408 tmp_list = form->children; | |
409 | |
410 gdk_window_set_user_data(form->bin_window, NULL); | |
411 gdk_window_destroy(form->bin_window); | |
412 form->bin_window = NULL; | |
413 | |
414 while (tmp_list) | |
415 { | |
416 GtkFormChild *child = tmp_list->data; | |
417 | |
418 if (child->window != NULL) | |
419 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
420 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
10176
51888fb2599f
commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
421 FUNC2GENERIC(gtk_form_child_map), |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
422 child); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
423 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
10176
51888fb2599f
commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
424 FUNC2GENERIC(gtk_form_child_unmap), |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
425 child); |
7 | 426 |
427 gdk_window_set_user_data(child->window, NULL); | |
428 gdk_window_destroy(child->window); | |
429 | |
430 child->window = NULL; | |
431 } | |
432 | |
433 tmp_list = tmp_list->next; | |
434 } | |
435 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
436 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
437 if (GTK_WIDGET_CLASS (gtk_form_parent_class)->unrealize) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
438 (* GTK_WIDGET_CLASS (gtk_form_parent_class)->unrealize) (widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
439 #else |
7 | 440 if (GTK_WIDGET_CLASS (parent_class)->unrealize) |
441 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
442 #endif |
7 | 443 } |
444 | |
445 static void | |
446 gtk_form_size_request(GtkWidget *widget, GtkRequisition *requisition) | |
447 { | |
11271
cd8dbed175a1
patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents:
10176
diff
changeset
|
448 g_return_if_fail(GTK_IS_FORM(widget)); |
cd8dbed175a1
patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents:
10176
diff
changeset
|
449 g_return_if_fail(requisition != NULL); |
7 | 450 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
451 requisition->width = 1; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
452 requisition->height = 1; |
7 | 453 } |
454 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
455 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
456 static void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
457 gtk_form_get_preferred_width(GtkWidget *widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
458 gint *minimal_width, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
459 gint *natural_width) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
460 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
461 GtkRequisition requisition; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
462 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
463 gtk_form_size_request(widget, &requisition); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
464 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
465 *minimal_width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
466 *natural_width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
467 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
468 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
469 static void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
470 gtk_form_get_preferred_height(GtkWidget *widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
471 gint *minimal_height, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
472 gint *natural_height) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
473 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
474 GtkRequisition requisition; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
475 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
476 gtk_form_size_request(widget, &requisition); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
477 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
478 *minimal_height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
479 *natural_height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
480 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
481 #endif /* GTK_CHECK_VERSION(3,0,0) */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
482 |
7 | 483 static void |
484 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) | |
485 { | |
486 GList *tmp_list; | |
487 GtkForm *form; | |
488 gboolean need_reposition; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
489 GtkAllocation cur_alloc; |
7 | 490 |
491 g_return_if_fail(GTK_IS_FORM(widget)); | |
492 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
493 gtk_widget_get_allocation(widget, &cur_alloc); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
494 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
495 if (cur_alloc.x == allocation->x |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
496 && cur_alloc.y == allocation->y |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
497 && cur_alloc.width == allocation->width |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
498 && cur_alloc.height == allocation->height) |
7 | 499 return; |
500 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
501 need_reposition = cur_alloc.width != allocation->width |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
502 || cur_alloc.height != allocation->height; |
7 | 503 form = GTK_FORM(widget); |
504 | |
505 if (need_reposition) | |
506 { | |
507 tmp_list = form->children; | |
508 | |
509 while (tmp_list) | |
510 { | |
511 GtkFormChild *child = tmp_list->data; | |
512 gtk_form_position_child(form, child, TRUE); | |
513 | |
514 tmp_list = tmp_list->next; | |
515 } | |
516 } | |
517 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
518 if (gtk_widget_get_realized(widget)) |
7 | 519 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
520 gdk_window_move_resize(gtk_widget_get_window(widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
521 allocation->x, allocation->y, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
522 allocation->width, allocation->height); |
7 | 523 gdk_window_move_resize(GTK_FORM(widget)->bin_window, |
524 0, 0, | |
525 allocation->width, allocation->height); | |
526 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
527 gtk_widget_set_allocation(widget, allocation); |
7 | 528 if (need_reposition) |
529 gtk_form_send_configure(form); | |
530 } | |
531 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
532 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
533 static void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
534 gtk_form_render_background(GtkWidget *widget, cairo_t *cr) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
535 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
536 gtk_render_background(gtk_widget_get_style_context(widget), cr, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
537 0, 0, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
538 gtk_widget_get_allocated_width(widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
539 gtk_widget_get_allocated_height(widget)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
540 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
541 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
542 static gboolean |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
543 gtk_form_draw(GtkWidget *widget, cairo_t *cr) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
544 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
545 GList *tmp_list = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
546 GtkForm *form = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
547 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
548 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
549 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
550 gtk_form_render_background(widget, cr); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
551 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
552 form = GTK_FORM(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
553 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
554 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
555 GtkFormChild * const formchild = tmp_list->data; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
556 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
557 if (!gtk_widget_get_has_window(formchild->widget) && |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
558 gtk_cairo_should_draw_window(cr, formchild->window)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
559 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
560 /* To get gtk_widget_draw() to work, it is required to call |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
561 * gtk_widget_size_allocate() in advance with a well-posed |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
562 * allocation for a given child widget in order to set a |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
563 * certain private GtkWidget variable, called |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
564 * widget->priv->alloc_need, to the proper value; othewise, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
565 * gtk_widget_draw() fails and the relevant scrollbar won't |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
566 * appear on the screen. |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
567 * |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
568 * Calling gtk_form_position_child() like this is one of ways |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
569 * to make sure of that. */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
570 gtk_form_position_child(form, formchild, TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
571 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
572 gtk_form_render_background(formchild->widget, cr); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
573 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
574 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
575 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
576 return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
577 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
578 #else /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 579 static gint |
580 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) | |
581 { | |
582 GList *tmp_list; | |
583 GtkForm *form; | |
584 | |
585 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); | |
586 | |
587 form = GTK_FORM(widget); | |
588 | |
589 if (event->window == form->bin_window) | |
590 return FALSE; | |
591 | |
592 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
11271
cd8dbed175a1
patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents:
10176
diff
changeset
|
593 gtk_container_propagate_expose(GTK_CONTAINER(widget), |
cd8dbed175a1
patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents:
10176
diff
changeset
|
594 GTK_WIDGET(((GtkFormChild *)tmp_list->data)->widget), |
cd8dbed175a1
patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents:
10176
diff
changeset
|
595 event); |
7 | 596 |
597 return FALSE; | |
598 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
599 #endif /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 600 |
601 /* Container method | |
602 */ | |
603 static void | |
604 gtk_form_remove(GtkContainer *container, GtkWidget *widget) | |
605 { | |
606 GList *tmp_list; | |
607 GtkForm *form; | |
608 GtkFormChild *child = NULL; /* init for gcc */ | |
609 | |
610 g_return_if_fail(GTK_IS_FORM(container)); | |
611 | |
612 form = GTK_FORM(container); | |
613 | |
614 tmp_list = form->children; | |
615 while (tmp_list) | |
616 { | |
617 child = tmp_list->data; | |
618 if (child->widget == widget) | |
619 break; | |
620 tmp_list = tmp_list->next; | |
621 } | |
622 | |
623 if (tmp_list) | |
624 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
625 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
626 const gboolean was_visible = gtk_widget_get_visible(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
627 #endif |
7 | 628 if (child->window) |
629 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
630 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
10176
51888fb2599f
commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
631 FUNC2GENERIC(>k_form_child_map), child); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
632 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
10176
51888fb2599f
commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
633 FUNC2GENERIC(>k_form_child_unmap), child); |
7 | 634 |
635 /* FIXME: This will cause problems for reparenting NO_WINDOW | |
636 * widgets out of a GtkForm | |
637 */ | |
638 gdk_window_set_user_data(child->window, NULL); | |
639 gdk_window_destroy(child->window); | |
640 } | |
641 gtk_widget_unparent(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
642 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
643 if (was_visible) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
644 gtk_widget_queue_resize(GTK_WIDGET(container)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
645 #endif |
7 | 646 form->children = g_list_remove_link(form->children, tmp_list); |
647 g_list_free_1(tmp_list); | |
648 g_free(child); | |
649 } | |
650 } | |
651 | |
652 static void | |
653 gtk_form_forall(GtkContainer *container, | |
1884 | 654 gboolean include_internals UNUSED, |
7 | 655 GtkCallback callback, |
656 gpointer callback_data) | |
657 { | |
658 GtkForm *form; | |
659 GtkFormChild *child; | |
660 GList *tmp_list; | |
661 | |
662 g_return_if_fail(GTK_IS_FORM(container)); | |
663 g_return_if_fail(callback != NULL); | |
664 | |
665 form = GTK_FORM(container); | |
666 | |
667 tmp_list = form->children; | |
668 while (tmp_list) | |
669 { | |
670 child = tmp_list->data; | |
671 tmp_list = tmp_list->next; | |
672 | |
673 (*callback) (child->widget, callback_data); | |
674 } | |
675 } | |
676 | |
677 /* Operations on children | |
678 */ | |
679 | |
680 static void | |
681 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) | |
682 { | |
683 if (child->window != NULL) | |
684 return; /* been there, done that */ | |
685 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
686 if (!gtk_widget_get_has_window(child->widget)) |
7 | 687 { |
688 GtkWidget *widget; | |
689 GdkWindowAttr attributes; | |
690 gint attributes_mask; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
691 GtkRequisition requisition; |
7 | 692 |
693 widget = GTK_WIDGET(form); | |
694 | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
695 #if GTK_CHECK_VERSION(3,0,0) |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
696 gtk_widget_get_preferred_size(child->widget, &requisition, NULL); |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
697 #else |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
698 requisition = child->widget->requisition; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
699 #endif |
7 | 700 attributes.window_type = GDK_WINDOW_CHILD; |
701 attributes.x = child->x; | |
702 attributes.y = child->y; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
703 attributes.width = requisition.width; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
704 attributes.height = requisition.height; |
7 | 705 attributes.wclass = GDK_INPUT_OUTPUT; |
706 attributes.visual = gtk_widget_get_visual(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
707 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 708 attributes.colormap = gtk_widget_get_colormap(widget); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
709 #endif |
7 | 710 attributes.event_mask = GDK_EXPOSURE_MASK; |
711 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
712 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
713 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
714 #else |
7 | 715 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
716 #endif |
7 | 717 child->window = gdk_window_new(form->bin_window, |
718 &attributes, attributes_mask); | |
719 gdk_window_set_user_data(child->window, widget); | |
720 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
721 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
722 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
723 GtkStyleContext * const sctx = gtk_widget_get_style_context(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
724 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
725 gtk_style_context_set_state(sctx, GTK_STATE_FLAG_NORMAL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
726 # if !GTK_CHECK_VERSION(3,18,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
727 gtk_style_context_set_background(sctx, child->window); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
728 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
729 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
730 #else |
7 | 731 gtk_style_set_background(widget->style, |
732 child->window, | |
733 GTK_STATE_NORMAL); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
734 #endif |
7 | 735 |
736 gtk_widget_set_parent_window(child->widget, child->window); | |
737 /* | |
738 * Install signal handlers to map/unmap child->window | |
739 * alongside with the actual widget. | |
740 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
741 g_signal_connect(G_OBJECT(child->widget), "map", |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
742 G_CALLBACK(>k_form_child_map), child); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
743 g_signal_connect(G_OBJECT(child->widget), "unmap", |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
744 G_CALLBACK(>k_form_child_unmap), child); |
7 | 745 } |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
746 else if (!gtk_widget_get_realized(child->widget)) |
7 | 747 { |
748 gtk_widget_set_parent_window(child->widget, form->bin_window); | |
749 } | |
750 } | |
751 | |
752 static void | |
753 gtk_form_realize_child(GtkForm *form, GtkFormChild *child) | |
754 { | |
755 gtk_form_attach_child_window(form, child); | |
756 gtk_widget_realize(child->widget); | |
757 } | |
758 | |
759 static void | |
760 gtk_form_position_child(GtkForm *form, GtkFormChild *child, | |
761 gboolean force_allocate) | |
762 { | |
763 gint x; | |
764 gint y; | |
765 | |
766 x = child->x; | |
767 y = child->y; | |
768 | |
769 if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && | |
770 (y >= G_MINSHORT) && (y <= G_MAXSHORT)) | |
771 { | |
772 if (!child->mapped) | |
773 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
774 if (gtk_widget_get_mapped(GTK_WIDGET(form)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
775 && gtk_widget_get_visible(child->widget)) |
7 | 776 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
777 if (!gtk_widget_get_mapped(child->widget)) |
7 | 778 gtk_widget_map(child->widget); |
779 | |
780 child->mapped = TRUE; | |
781 force_allocate = TRUE; | |
782 } | |
783 } | |
784 | |
785 if (force_allocate) | |
786 { | |
787 GtkAllocation allocation; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
788 GtkRequisition requisition; |
7 | 789 |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
790 #if GTK_CHECK_VERSION(3,0,0) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
791 gtk_widget_get_preferred_size(child->widget, &requisition, NULL); |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
792 #else |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
793 requisition = child->widget->requisition; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
794 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
795 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
796 if (!gtk_widget_get_has_window(child->widget)) |
7 | 797 { |
798 if (child->window) | |
799 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
800 gdk_window_move_resize(child->window, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
801 x, y, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
802 requisition.width, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
803 requisition.height); |
7 | 804 } |
805 | |
806 allocation.x = 0; | |
807 allocation.y = 0; | |
808 } | |
809 else | |
810 { | |
811 allocation.x = x; | |
812 allocation.y = y; | |
813 } | |
814 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
815 allocation.width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
816 allocation.height = requisition.height; |
7 | 817 |
818 gtk_widget_size_allocate(child->widget, &allocation); | |
819 } | |
820 } | |
821 else | |
822 { | |
823 if (child->mapped) | |
824 { | |
825 child->mapped = FALSE; | |
826 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
827 if (gtk_widget_get_mapped(child->widget)) |
7 | 828 gtk_widget_unmap(child->widget); |
829 } | |
830 } | |
831 } | |
832 | |
833 static void | |
834 gtk_form_position_children(GtkForm *form) | |
835 { | |
836 GList *tmp_list; | |
837 | |
838 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
839 gtk_form_position_child(form, tmp_list->data, FALSE); | |
840 } | |
841 | |
842 void | |
843 gtk_form_move_resize(GtkForm *form, GtkWidget *widget, | |
844 gint x, gint y, gint w, gint h) | |
845 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
846 #if GTK_CHECK_VERSION(3,0,0) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
847 gtk_widget_set_size_request(widget, w, h); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
848 #else |
7 | 849 widget->requisition.width = w; |
850 widget->requisition.height = h; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
851 #endif |
7 | 852 |
853 gtk_form_move(form, widget, x, y); | |
854 } | |
855 | |
856 static void | |
857 gtk_form_send_configure(GtkForm *form) | |
858 { | |
859 GtkWidget *widget; | |
860 GdkEventConfigure event; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
861 GtkAllocation allocation; |
7 | 862 |
863 widget = GTK_WIDGET(form); | |
864 | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
865 gtk_widget_get_allocation(widget, &allocation); |
7 | 866 event.type = GDK_CONFIGURE; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
867 event.window = gtk_widget_get_window(widget); |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
868 event.x = allocation.x; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
869 event.y = allocation.y; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
870 event.width = allocation.width; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
871 event.height = allocation.height; |
7 | 872 |
873 gtk_main_do_event((GdkEvent*)&event); | |
874 } | |
875 | |
876 static void | |
1884 | 877 gtk_form_child_map(GtkWidget *widget UNUSED, gpointer user_data) |
7 | 878 { |
879 GtkFormChild *child; | |
880 | |
881 child = (GtkFormChild *)user_data; | |
882 | |
883 child->mapped = TRUE; | |
884 gdk_window_show(child->window); | |
885 } | |
886 | |
887 static void | |
1884 | 888 gtk_form_child_unmap(GtkWidget *widget UNUSED, gpointer user_data) |
7 | 889 { |
890 GtkFormChild *child; | |
891 | |
892 child = (GtkFormChild *)user_data; | |
893 | |
894 child->mapped = FALSE; | |
895 gdk_window_hide(child->window); | |
896 } |