Mercurial > vim
annotate src/gui_gtk_f.c @ 9969:176e34b0d678 v7.4.2258
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Aug 26 17:58:53 2016 +0200
patch 7.4.2258
Problem: Two JSON messages are sent without a separator.
Solution: Separate messages with a NL. (closes https://github.com/vim/vim/issues/1001)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 26 Aug 2016 18:00:08 +0200 |
parents | 3456e2ebebd4 |
children | 4aead6a9b7a9 |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
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 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
95 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 96 static GdkFilterReturn gtk_form_filter(GdkXEvent *gdk_xevent, |
97 GdkEvent *event, | |
98 gpointer data); | |
99 static GdkFilterReturn gtk_form_main_filter(GdkXEvent *gdk_xevent, | |
100 GdkEvent *event, | |
101 gpointer data); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
102 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
103 #if !GTK_CHECK_VERSION(3,16,0) |
7 | 104 static void gtk_form_set_static_gravity(GdkWindow *window, |
105 gboolean use_static); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
106 #endif |
7 | 107 |
108 static void gtk_form_send_configure(GtkForm *form); | |
109 | |
110 static void gtk_form_child_map(GtkWidget *widget, gpointer user_data); | |
111 static void gtk_form_child_unmap(GtkWidget *widget, gpointer user_data); | |
112 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
113 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 114 static GtkWidgetClass *parent_class = NULL; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
115 #endif |
7 | 116 |
117 /* Public interface | |
118 */ | |
119 | |
120 GtkWidget * | |
121 gtk_form_new(void) | |
122 { | |
123 GtkForm *form; | |
124 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
125 #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
|
126 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
|
127 #else |
7 | 128 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
|
129 #endif |
7 | 130 |
131 return GTK_WIDGET(form); | |
132 } | |
133 | |
134 void | |
135 gtk_form_put(GtkForm *form, | |
136 GtkWidget *child_widget, | |
137 gint x, | |
138 gint y) | |
139 { | |
140 GtkFormChild *child; | |
141 | |
142 g_return_if_fail(GTK_IS_FORM(form)); | |
143 | |
129 | 144 /* LINTED: avoid warning: conversion to 'unsigned long' */ |
7 | 145 child = g_new(GtkFormChild, 1); |
146 | |
147 child->widget = child_widget; | |
148 child->window = NULL; | |
149 child->x = x; | |
150 child->y = y; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
151 #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
|
152 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
|
153 #else |
7 | 154 child->widget->requisition.width = 0; |
155 child->widget->requisition.height = 0; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
156 #endif |
7 | 157 child->mapped = FALSE; |
158 | |
159 form->children = g_list_append(form->children, child); | |
160 | |
161 /* child->window must be created and attached to the widget _before_ | |
162 * it has been realized, or else things will break with GTK2. Note | |
163 * that gtk_widget_set_parent() realizes the widget if it's visible | |
164 * and its parent is mapped. | |
165 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
166 #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
|
167 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
|
168 #else |
7 | 169 if (GTK_WIDGET_REALIZED(form)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
170 #endif |
7 | 171 gtk_form_attach_child_window(form, child); |
172 | |
173 gtk_widget_set_parent(child_widget, GTK_WIDGET(form)); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
174 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 175 gtk_widget_size_request(child->widget, NULL); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
176 #endif |
7 | 177 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
178 #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
|
179 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
|
180 && !gtk_widget_get_realized(child_widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
181 #else |
7 | 182 if (GTK_WIDGET_REALIZED(form) && !GTK_WIDGET_REALIZED(child_widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
183 #endif |
7 | 184 gtk_form_realize_child(form, child); |
185 | |
186 gtk_form_position_child(form, child, TRUE); | |
187 } | |
188 | |
189 void | |
190 gtk_form_move(GtkForm *form, | |
191 GtkWidget *child_widget, | |
192 gint x, | |
193 gint y) | |
194 { | |
195 GList *tmp_list; | |
196 GtkFormChild *child; | |
197 | |
198 g_return_if_fail(GTK_IS_FORM(form)); | |
199 | |
200 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
201 { | |
202 child = tmp_list->data; | |
203 if (child->widget == child_widget) | |
204 { | |
205 child->x = x; | |
206 child->y = y; | |
207 | |
208 gtk_form_position_child(form, child, TRUE); | |
209 return; | |
210 } | |
211 } | |
212 } | |
213 | |
214 void | |
215 gtk_form_freeze(GtkForm *form) | |
216 { | |
217 g_return_if_fail(GTK_IS_FORM(form)); | |
218 | |
219 ++form->freeze_count; | |
220 } | |
221 | |
222 void | |
223 gtk_form_thaw(GtkForm *form) | |
224 { | |
225 g_return_if_fail(GTK_IS_FORM(form)); | |
226 | |
227 if (form->freeze_count) | |
228 { | |
229 if (!(--form->freeze_count)) | |
230 { | |
231 gtk_form_position_children(form); | |
232 gtk_widget_queue_draw(GTK_WIDGET(form)); | |
233 } | |
234 } | |
235 } | |
236 | |
237 /* Basic Object handling procedures | |
238 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
239 #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
|
240 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
|
241 #else |
7 | 242 GtkType |
243 gtk_form_get_type(void) | |
244 { | |
245 static GtkType form_type = 0; | |
246 | |
247 if (!form_type) | |
248 { | |
1884 | 249 GtkTypeInfo form_info; |
250 | |
1885 | 251 vim_memset(&form_info, 0, sizeof(form_info)); |
1884 | 252 form_info.type_name = "GtkForm"; |
253 form_info.object_size = sizeof(GtkForm); | |
254 form_info.class_size = sizeof(GtkFormClass); | |
255 form_info.class_init_func = (GtkClassInitFunc)gtk_form_class_init; | |
256 form_info.object_init_func = (GtkObjectInitFunc)gtk_form_init; | |
7 | 257 |
258 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info); | |
259 } | |
260 return form_type; | |
261 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
262 #endif /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 263 |
264 static void | |
265 gtk_form_class_init(GtkFormClass *klass) | |
266 { | |
267 GtkWidgetClass *widget_class; | |
268 GtkContainerClass *container_class; | |
269 | |
270 widget_class = (GtkWidgetClass *) klass; | |
271 container_class = (GtkContainerClass *) klass; | |
272 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
273 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 274 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
|
275 #endif |
7 | 276 |
277 widget_class->realize = gtk_form_realize; | |
278 widget_class->unrealize = gtk_form_unrealize; | |
279 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
|
280 #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
|
281 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
|
282 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
|
283 #else |
7 | 284 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
|
285 #endif |
7 | 286 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
|
287 #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
|
288 widget_class->draw = gtk_form_draw; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
289 #else |
7 | 290 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
|
291 #endif |
7 | 292 |
293 container_class->remove = gtk_form_remove; | |
294 container_class->forall = gtk_form_forall; | |
295 } | |
296 | |
297 static void | |
298 gtk_form_init(GtkForm *form) | |
299 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
300 #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
|
301 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
|
302 #endif |
7 | 303 form->children = NULL; |
304 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
305 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 306 form->width = 1; |
307 form->height = 1; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
308 #endif |
7 | 309 |
310 form->bin_window = NULL; | |
311 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
312 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 313 form->configure_serial = 0; |
314 form->visibility = GDK_VISIBILITY_PARTIAL; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
315 #endif |
7 | 316 |
317 form->freeze_count = 0; | |
318 } | |
319 | |
320 /* | |
321 * Widget methods | |
322 */ | |
323 | |
324 static void | |
325 gtk_form_realize(GtkWidget *widget) | |
326 { | |
327 GList *tmp_list; | |
328 GtkForm *form; | |
329 GdkWindowAttr attributes; | |
330 gint attributes_mask; | |
331 | |
332 g_return_if_fail(GTK_IS_FORM(widget)); | |
333 | |
334 form = GTK_FORM(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
335 #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
|
336 gtk_widget_set_realized(widget, TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
337 #else |
7 | 338 GTK_WIDGET_SET_FLAGS(form, GTK_REALIZED); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
339 #endif |
7 | 340 |
341 attributes.window_type = GDK_WINDOW_CHILD; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
342 #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
|
343 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
344 GtkAllocation allocation; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
345 gtk_widget_get_allocation(widget, &allocation); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
346 attributes.x = allocation.x; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
347 attributes.y = allocation.y; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
348 attributes.width = allocation.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
349 attributes.height = allocation.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
350 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
351 #else |
7 | 352 attributes.x = widget->allocation.x; |
353 attributes.y = widget->allocation.y; | |
354 attributes.width = widget->allocation.width; | |
355 attributes.height = widget->allocation.height; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
356 #endif |
7 | 357 attributes.wclass = GDK_INPUT_OUTPUT; |
358 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
|
359 #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
|
360 attributes.event_mask = GDK_EXPOSURE_MASK; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
361 #else |
7 | 362 attributes.colormap = gtk_widget_get_colormap(widget); |
363 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
|
364 #endif |
7 | 365 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
366 #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
|
367 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
|
368 #else |
7 | 369 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
|
370 #endif |
7 | 371 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
372 #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
|
373 gtk_widget_set_window(widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
374 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
|
375 &attributes, attributes_mask)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
376 gdk_window_set_user_data(gtk_widget_get_window(widget), widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
377 #else |
7 | 378 widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), |
379 &attributes, attributes_mask); | |
380 gdk_window_set_user_data(widget->window, widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
381 #endif |
7 | 382 |
383 attributes.x = 0; | |
384 attributes.y = 0; | |
385 attributes.event_mask = gtk_widget_get_events(widget); | |
386 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
387 #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
|
388 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
|
389 &attributes, attributes_mask); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
390 #else |
7 | 391 form->bin_window = gdk_window_new(widget->window, |
392 &attributes, attributes_mask); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
393 #endif |
7 | 394 gdk_window_set_user_data(form->bin_window, widget); |
395 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
396 #if !GTK_CHECK_VERSION(3,16,0) |
7 | 397 gtk_form_set_static_gravity(form->bin_window, TRUE); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
398 #endif |
7 | 399 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
400 #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
|
401 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
402 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
|
403 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
404 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
|
405 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
|
406 # 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
|
407 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
|
408 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
|
409 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
410 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
411 #else |
7 | 412 widget->style = gtk_style_attach(widget->style, widget->window); |
413 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); | |
414 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
|
415 #endif |
7 | 416 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
417 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 418 gdk_window_add_filter(widget->window, gtk_form_main_filter, form); |
419 gdk_window_add_filter(form->bin_window, gtk_form_filter, form); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
420 #endif |
7 | 421 |
422 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
423 { | |
424 GtkFormChild *child = tmp_list->data; | |
425 | |
426 gtk_form_attach_child_window(form, child); | |
427 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
428 #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
|
429 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
|
430 #else |
7 | 431 if (GTK_WIDGET_VISIBLE(child->widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
432 #endif |
7 | 433 gtk_form_realize_child(form, child); |
434 } | |
435 } | |
436 | |
437 | |
438 /* After reading the documentation at | |
439 * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html | |
440 * I think it should be possible to remove this function when compiling | |
441 * against gtk-2.0. It doesn't seem to cause problems, though. | |
442 * | |
443 * Well, I reckon at least the gdk_window_show(form->bin_window) | |
444 * is necessary. GtkForm is anything but a usual container widget. | |
445 */ | |
446 static void | |
447 gtk_form_map(GtkWidget *widget) | |
448 { | |
449 GList *tmp_list; | |
450 GtkForm *form; | |
451 | |
452 g_return_if_fail(GTK_IS_FORM(widget)); | |
453 | |
454 form = GTK_FORM(widget); | |
455 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
456 #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
|
457 gtk_widget_set_mapped(widget, TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
458 #else |
7 | 459 GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
460 #endif |
7 | 461 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
462 #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
|
463 gdk_window_show(gtk_widget_get_window(widget)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
464 #else |
7 | 465 gdk_window_show(widget->window); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
466 #endif |
7 | 467 gdk_window_show(form->bin_window); |
468 | |
469 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
470 { | |
471 GtkFormChild *child = tmp_list->data; | |
472 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
473 #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
|
474 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
|
475 && !gtk_widget_get_mapped(child->widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
476 #else |
7 | 477 if (GTK_WIDGET_VISIBLE(child->widget) |
478 && !GTK_WIDGET_MAPPED(child->widget)) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
479 #endif |
7 | 480 gtk_widget_map(child->widget); |
481 } | |
482 } | |
483 | |
484 static void | |
485 gtk_form_unrealize(GtkWidget *widget) | |
486 { | |
487 GList *tmp_list; | |
488 GtkForm *form; | |
489 | |
490 g_return_if_fail(GTK_IS_FORM(widget)); | |
491 | |
492 form = GTK_FORM(widget); | |
493 | |
494 tmp_list = form->children; | |
495 | |
496 gdk_window_set_user_data(form->bin_window, NULL); | |
497 gdk_window_destroy(form->bin_window); | |
498 form->bin_window = NULL; | |
499 | |
500 while (tmp_list) | |
501 { | |
502 GtkFormChild *child = tmp_list->data; | |
503 | |
504 if (child->window != NULL) | |
505 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
506 #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
|
507 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
508 G_CALLBACK(gtk_form_child_map), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
509 child); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
510 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
511 G_CALLBACK(gtk_form_child_unmap), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
512 child); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
513 #else |
7 | 514 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), |
515 GTK_SIGNAL_FUNC(gtk_form_child_map), | |
516 child); | |
517 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), | |
518 GTK_SIGNAL_FUNC(gtk_form_child_unmap), | |
519 child); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
520 #endif |
7 | 521 |
522 gdk_window_set_user_data(child->window, NULL); | |
523 gdk_window_destroy(child->window); | |
524 | |
525 child->window = NULL; | |
526 } | |
527 | |
528 tmp_list = tmp_list->next; | |
529 } | |
530 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
531 #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
|
532 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
|
533 (* 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
|
534 #else |
7 | 535 if (GTK_WIDGET_CLASS (parent_class)->unrealize) |
536 (* 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
|
537 #endif |
7 | 538 } |
539 | |
540 static void | |
541 gtk_form_size_request(GtkWidget *widget, GtkRequisition *requisition) | |
542 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
543 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 544 GList *tmp_list; |
545 GtkForm *form; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
546 #endif |
7 | 547 |
548 g_return_if_fail(GTK_IS_FORM(widget)); | |
549 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
550 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 551 form = GTK_FORM(widget); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
552 #endif |
7 | 553 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
554 #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
|
555 requisition->width = 1; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
556 requisition->height = 1; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
557 #else |
7 | 558 requisition->width = form->width; |
559 requisition->height = form->height; | |
560 | |
561 tmp_list = form->children; | |
562 | |
563 while (tmp_list) | |
564 { | |
565 GtkFormChild *child = tmp_list->data; | |
566 gtk_widget_size_request(child->widget, NULL); | |
567 tmp_list = tmp_list->next; | |
568 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
569 #endif |
7 | 570 } |
571 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
572 #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
|
573 static void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
574 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
|
575 gint *minimal_width, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
576 gint *natural_width) |
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 GtkRequisition requisition; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
579 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
580 gtk_form_size_request(widget, &requisition); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
581 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
582 *minimal_width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
583 *natural_width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
584 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
585 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
586 static void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
587 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
|
588 gint *minimal_height, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
589 gint *natural_height) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
590 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
591 GtkRequisition requisition; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
592 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
593 gtk_form_size_request(widget, &requisition); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
594 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
595 *minimal_height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
596 *natural_height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
597 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
598 #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
|
599 |
7 | 600 static void |
601 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) | |
602 { | |
603 GList *tmp_list; | |
604 GtkForm *form; | |
605 gboolean need_reposition; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
606 #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
|
607 GtkAllocation cur_alloc; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
608 #endif |
7 | 609 |
610 g_return_if_fail(GTK_IS_FORM(widget)); | |
611 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
612 #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
|
613 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
|
614 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
615 if (cur_alloc.x == allocation->x |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
616 && cur_alloc.y == allocation->y |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
617 && cur_alloc.width == allocation->width |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
618 && cur_alloc.height == allocation->height) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
619 #else |
7 | 620 if (widget->allocation.x == allocation->x |
621 && widget->allocation.y == allocation->y | |
622 && widget->allocation.width == allocation->width | |
623 && widget->allocation.height == allocation->height) | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
624 #endif |
7 | 625 return; |
626 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
627 #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
|
628 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
|
629 || cur_alloc.height != allocation->height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
630 #else |
7 | 631 need_reposition = widget->allocation.width != allocation->width |
632 || widget->allocation.height != allocation->height; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
633 #endif |
7 | 634 form = GTK_FORM(widget); |
635 | |
636 if (need_reposition) | |
637 { | |
638 tmp_list = form->children; | |
639 | |
640 while (tmp_list) | |
641 { | |
642 GtkFormChild *child = tmp_list->data; | |
643 gtk_form_position_child(form, child, TRUE); | |
644 | |
645 tmp_list = tmp_list->next; | |
646 } | |
647 } | |
648 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
649 #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
|
650 if (gtk_widget_get_realized(widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
651 #else |
7 | 652 if (GTK_WIDGET_REALIZED(widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
653 #endif |
7 | 654 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
655 #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
|
656 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
|
657 allocation->x, allocation->y, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
658 allocation->width, allocation->height); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
659 #else |
7 | 660 gdk_window_move_resize(widget->window, |
661 allocation->x, allocation->y, | |
662 allocation->width, allocation->height); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
663 #endif |
7 | 664 gdk_window_move_resize(GTK_FORM(widget)->bin_window, |
665 0, 0, | |
666 allocation->width, allocation->height); | |
667 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
668 #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
|
669 gtk_widget_set_allocation(widget, allocation); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
670 #else |
7 | 671 widget->allocation = *allocation; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
672 #endif |
7 | 673 if (need_reposition) |
674 gtk_form_send_configure(form); | |
675 } | |
676 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
677 #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
|
678 static void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
679 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
|
680 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
681 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
|
682 0, 0, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
683 gtk_widget_get_allocated_width(widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
684 gtk_widget_get_allocated_height(widget)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
685 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
686 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
687 static gboolean |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
688 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
|
689 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
690 GList *tmp_list = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
691 GtkForm *form = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
692 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
693 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
|
694 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
695 gtk_form_render_background(widget, cr); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
696 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
697 form = GTK_FORM(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
698 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
|
699 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
700 GtkFormChild * const formchild = tmp_list->data; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
701 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
702 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
|
703 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
|
704 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
705 /* 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
|
706 * 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
|
707 * 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
|
708 * certain private GtkWidget variable, called |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
709 * 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
|
710 * 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
|
711 * appear on the screen. |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
712 * |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
713 * 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
|
714 * to make sure of that. */ |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
715 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
|
716 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
717 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
|
718 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
719 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
720 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
721 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
|
722 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
723 #else /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 724 static gint |
725 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) | |
726 { | |
727 GList *tmp_list; | |
728 GtkForm *form; | |
729 | |
730 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); | |
731 | |
732 form = GTK_FORM(widget); | |
733 | |
734 if (event->window == form->bin_window) | |
735 return FALSE; | |
736 | |
737 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
738 { | |
739 GtkFormChild *formchild = tmp_list->data; | |
740 GtkWidget *child = formchild->widget; | |
741 /* | |
742 * The following chunk of code is taken from gtkcontainer.c. The | |
743 * gtk1.x code synthesized expose events directly on the child widgets, | |
744 * which can't be done in gtk2 | |
745 */ | |
746 if (GTK_WIDGET_DRAWABLE(child) && GTK_WIDGET_NO_WINDOW(child) | |
747 && child->window == event->window) | |
748 { | |
749 GdkEventExpose child_event; | |
750 child_event = *event; | |
751 | |
752 child_event.region = gtk_widget_region_intersect(child, event->region); | |
753 if (!gdk_region_empty(child_event.region)) | |
754 { | |
755 gdk_region_get_clipbox(child_event.region, &child_event.area); | |
756 gtk_widget_send_expose(child, (GdkEvent *)&child_event); | |
757 } | |
758 } | |
759 } | |
760 | |
761 return FALSE; | |
762 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
763 #endif /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 764 |
765 /* Container method | |
766 */ | |
767 static void | |
768 gtk_form_remove(GtkContainer *container, GtkWidget *widget) | |
769 { | |
770 GList *tmp_list; | |
771 GtkForm *form; | |
772 GtkFormChild *child = NULL; /* init for gcc */ | |
773 | |
774 g_return_if_fail(GTK_IS_FORM(container)); | |
775 | |
776 form = GTK_FORM(container); | |
777 | |
778 tmp_list = form->children; | |
779 while (tmp_list) | |
780 { | |
781 child = tmp_list->data; | |
782 if (child->widget == widget) | |
783 break; | |
784 tmp_list = tmp_list->next; | |
785 } | |
786 | |
787 if (tmp_list) | |
788 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
789 #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
|
790 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
|
791 #endif |
7 | 792 if (child->window) |
793 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
794 #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
|
795 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
796 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
|
797 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
798 G_CALLBACK(>k_form_child_unmap), child); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
799 #else |
7 | 800 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), |
801 GTK_SIGNAL_FUNC(>k_form_child_map), child); | |
802 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget), | |
803 GTK_SIGNAL_FUNC(>k_form_child_unmap), child); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
804 #endif |
7 | 805 |
806 /* FIXME: This will cause problems for reparenting NO_WINDOW | |
807 * widgets out of a GtkForm | |
808 */ | |
809 gdk_window_set_user_data(child->window, NULL); | |
810 gdk_window_destroy(child->window); | |
811 } | |
812 gtk_widget_unparent(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
813 #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
|
814 if (was_visible) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
815 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
|
816 #endif |
7 | 817 form->children = g_list_remove_link(form->children, tmp_list); |
818 g_list_free_1(tmp_list); | |
819 g_free(child); | |
820 } | |
821 } | |
822 | |
823 static void | |
824 gtk_form_forall(GtkContainer *container, | |
1884 | 825 gboolean include_internals UNUSED, |
7 | 826 GtkCallback callback, |
827 gpointer callback_data) | |
828 { | |
829 GtkForm *form; | |
830 GtkFormChild *child; | |
831 GList *tmp_list; | |
832 | |
833 g_return_if_fail(GTK_IS_FORM(container)); | |
834 g_return_if_fail(callback != NULL); | |
835 | |
836 form = GTK_FORM(container); | |
837 | |
838 tmp_list = form->children; | |
839 while (tmp_list) | |
840 { | |
841 child = tmp_list->data; | |
842 tmp_list = tmp_list->next; | |
843 | |
844 (*callback) (child->widget, callback_data); | |
845 } | |
846 } | |
847 | |
848 /* Operations on children | |
849 */ | |
850 | |
851 static void | |
852 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) | |
853 { | |
854 if (child->window != NULL) | |
855 return; /* been there, done that */ | |
856 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
857 #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
|
858 if (!gtk_widget_get_has_window(child->widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
859 #else |
7 | 860 if (GTK_WIDGET_NO_WINDOW(child->widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
861 #endif |
7 | 862 { |
863 GtkWidget *widget; | |
864 GdkWindowAttr attributes; | |
865 gint attributes_mask; | |
866 | |
867 widget = GTK_WIDGET(form); | |
868 | |
869 attributes.window_type = GDK_WINDOW_CHILD; | |
870 attributes.x = child->x; | |
871 attributes.y = child->y; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
872 #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
|
873 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
874 GtkRequisition requisition; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
875 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
876 gtk_widget_get_preferred_size(child->widget, &requisition, NULL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
877 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
878 attributes.width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
879 attributes.height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
880 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
881 #else |
7 | 882 attributes.width = child->widget->requisition.width; |
883 attributes.height = child->widget->requisition.height; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
884 #endif |
7 | 885 attributes.wclass = GDK_INPUT_OUTPUT; |
886 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
|
887 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 888 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
|
889 #endif |
7 | 890 attributes.event_mask = GDK_EXPOSURE_MASK; |
891 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
892 #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
|
893 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
|
894 #else |
7 | 895 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
|
896 #endif |
7 | 897 child->window = gdk_window_new(form->bin_window, |
898 &attributes, attributes_mask); | |
899 gdk_window_set_user_data(child->window, widget); | |
900 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
901 #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
|
902 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
903 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
|
904 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
905 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
|
906 # 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
|
907 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
|
908 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
909 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
910 #else |
7 | 911 gtk_style_set_background(widget->style, |
912 child->window, | |
913 GTK_STATE_NORMAL); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
914 #endif |
7 | 915 |
916 gtk_widget_set_parent_window(child->widget, child->window); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
917 #if !GTK_CHECK_VERSION(3,16,0) |
7 | 918 gtk_form_set_static_gravity(child->window, TRUE); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
919 #endif |
7 | 920 /* |
921 * Install signal handlers to map/unmap child->window | |
922 * alongside with the actual widget. | |
923 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
924 #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
|
925 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
|
926 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
|
927 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
|
928 G_CALLBACK(>k_form_child_unmap), child); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
929 #else |
7 | 930 gtk_signal_connect(GTK_OBJECT(child->widget), "map", |
931 GTK_SIGNAL_FUNC(>k_form_child_map), child); | |
932 gtk_signal_connect(GTK_OBJECT(child->widget), "unmap", | |
933 GTK_SIGNAL_FUNC(>k_form_child_unmap), child); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
934 #endif |
7 | 935 } |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
936 #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
|
937 else if (!gtk_widget_get_realized(child->widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
938 #else |
7 | 939 else if (!GTK_WIDGET_REALIZED(child->widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
940 #endif |
7 | 941 { |
942 gtk_widget_set_parent_window(child->widget, form->bin_window); | |
943 } | |
944 } | |
945 | |
946 static void | |
947 gtk_form_realize_child(GtkForm *form, GtkFormChild *child) | |
948 { | |
949 gtk_form_attach_child_window(form, child); | |
950 gtk_widget_realize(child->widget); | |
951 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
952 #if !GTK_CHECK_VERSION(3,16,0) |
7 | 953 if (child->window == NULL) /* might be already set, see above */ |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
954 # 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
|
955 gtk_form_set_static_gravity(gtk_widget_get_window(child->widget), TRUE); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
956 # else |
7 | 957 gtk_form_set_static_gravity(child->widget->window, TRUE); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
958 # endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
959 #endif |
7 | 960 } |
961 | |
962 static void | |
963 gtk_form_position_child(GtkForm *form, GtkFormChild *child, | |
964 gboolean force_allocate) | |
965 { | |
966 gint x; | |
967 gint y; | |
968 | |
969 x = child->x; | |
970 y = child->y; | |
971 | |
972 if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && | |
973 (y >= G_MINSHORT) && (y <= G_MAXSHORT)) | |
974 { | |
975 if (!child->mapped) | |
976 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
977 #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
|
978 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
|
979 && gtk_widget_get_visible(child->widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
980 #else |
7 | 981 if (GTK_WIDGET_MAPPED(form) && GTK_WIDGET_VISIBLE(child->widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
982 #endif |
7 | 983 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
984 #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
|
985 if (!gtk_widget_get_mapped(child->widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
986 #else |
7 | 987 if (!GTK_WIDGET_MAPPED(child->widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
988 #endif |
7 | 989 gtk_widget_map(child->widget); |
990 | |
991 child->mapped = TRUE; | |
992 force_allocate = TRUE; | |
993 } | |
994 } | |
995 | |
996 if (force_allocate) | |
997 { | |
998 GtkAllocation allocation; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
999 #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
|
1000 GtkRequisition requisition; |
7 | 1001 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1002 gtk_widget_get_preferred_size(child->widget, &requisition, NULL); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1003 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1004 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1005 #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
|
1006 if (!gtk_widget_get_has_window(child->widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1007 #else |
7 | 1008 if (GTK_WIDGET_NO_WINDOW(child->widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1009 #endif |
7 | 1010 { |
1011 if (child->window) | |
1012 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1013 #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
|
1014 gdk_window_move_resize(child->window, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1015 x, y, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1016 requisition.width, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1017 requisition.height); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1018 #else |
7 | 1019 gdk_window_move_resize(child->window, |
1020 x, y, | |
1021 child->widget->requisition.width, | |
1022 child->widget->requisition.height); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1023 #endif |
7 | 1024 } |
1025 | |
1026 allocation.x = 0; | |
1027 allocation.y = 0; | |
1028 } | |
1029 else | |
1030 { | |
1031 allocation.x = x; | |
1032 allocation.y = y; | |
1033 } | |
1034 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1035 #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
|
1036 allocation.width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1037 allocation.height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1038 #else |
7 | 1039 allocation.width = child->widget->requisition.width; |
1040 allocation.height = child->widget->requisition.height; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1041 #endif |
7 | 1042 |
1043 gtk_widget_size_allocate(child->widget, &allocation); | |
1044 } | |
1045 } | |
1046 else | |
1047 { | |
1048 if (child->mapped) | |
1049 { | |
1050 child->mapped = FALSE; | |
1051 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1052 #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
|
1053 if (gtk_widget_get_mapped(child->widget)) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1054 #else |
7 | 1055 if (GTK_WIDGET_MAPPED(child->widget)) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1056 #endif |
7 | 1057 gtk_widget_unmap(child->widget); |
1058 } | |
1059 } | |
1060 } | |
1061 | |
1062 static void | |
1063 gtk_form_position_children(GtkForm *form) | |
1064 { | |
1065 GList *tmp_list; | |
1066 | |
1067 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
1068 gtk_form_position_child(form, tmp_list->data, FALSE); | |
1069 } | |
1070 | |
1071 /* Callbacks */ | |
1072 | |
1073 /* The main event filter. Actually, we probably don't really need | |
1074 * to install this as a filter at all, since we are calling it | |
1075 * directly above in the expose-handling hack. | |
1076 * | |
1077 * This routine identifies expose events that are generated when | |
1078 * we've temporarily moved the bin_window_origin, and translates | |
1079 * them or discards them, depending on whether we are obscured | |
1080 * or not. | |
1081 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1082 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 1083 static GdkFilterReturn |
1884 | 1084 gtk_form_filter(GdkXEvent *gdk_xevent, GdkEvent *event UNUSED, gpointer data) |
7 | 1085 { |
1086 XEvent *xevent; | |
1087 GtkForm *form; | |
1088 | |
1089 xevent = (XEvent *) gdk_xevent; | |
1090 form = GTK_FORM(data); | |
1091 | |
1092 switch (xevent->type) | |
1093 { | |
1094 case Expose: | |
1095 if (xevent->xexpose.serial == form->configure_serial) | |
1096 { | |
1097 if (form->visibility == GDK_VISIBILITY_UNOBSCURED) | |
1098 return GDK_FILTER_REMOVE; | |
1099 else | |
1100 break; | |
1101 } | |
1102 break; | |
1103 | |
1104 case ConfigureNotify: | |
1105 if ((xevent->xconfigure.x != 0) || (xevent->xconfigure.y != 0)) | |
1106 form->configure_serial = xevent->xconfigure.serial; | |
1107 break; | |
1108 } | |
1109 | |
1110 return GDK_FILTER_CONTINUE; | |
1111 } | |
1112 | |
1113 /* Although GDK does have a GDK_VISIBILITY_NOTIFY event, | |
1114 * there is no corresponding event in GTK, so we have | |
1115 * to get the events from a filter | |
1116 */ | |
1117 static GdkFilterReturn | |
1884 | 1118 gtk_form_main_filter(GdkXEvent *gdk_xevent, |
1119 GdkEvent *event UNUSED, | |
1120 gpointer data) | |
7 | 1121 { |
1122 XEvent *xevent; | |
1123 GtkForm *form; | |
1124 | |
1125 xevent = (XEvent *) gdk_xevent; | |
1126 form = GTK_FORM(data); | |
1127 | |
1128 if (xevent->type == VisibilityNotify) | |
1129 { | |
1130 switch (xevent->xvisibility.state) | |
1131 { | |
1132 case VisibilityFullyObscured: | |
1133 form->visibility = GDK_VISIBILITY_FULLY_OBSCURED; | |
1134 break; | |
1135 | |
1136 case VisibilityPartiallyObscured: | |
1137 form->visibility = GDK_VISIBILITY_PARTIAL; | |
1138 break; | |
1139 | |
1140 case VisibilityUnobscured: | |
1141 form->visibility = GDK_VISIBILITY_UNOBSCURED; | |
1142 break; | |
1143 } | |
1144 | |
1145 return GDK_FILTER_REMOVE; | |
1146 } | |
1147 return GDK_FILTER_CONTINUE; | |
1148 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1149 #endif /* !GTK_CHECK_VERSION(3,0,0) */ |
7 | 1150 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1151 #if !GTK_CHECK_VERSION(3,16,0) |
7 | 1152 static void |
1153 gtk_form_set_static_gravity(GdkWindow *window, gboolean use_static) | |
1154 { | |
1960 | 1155 /* We don't check if static gravity is actually supported, because it |
1156 * results in an annoying assertion error message. */ | |
1157 gdk_window_set_static_gravities(window, use_static); | |
7 | 1158 } |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1159 #endif /* !GTK_CHECK_VERSION(3,16,0) */ |
7 | 1160 |
1161 void | |
1162 gtk_form_move_resize(GtkForm *form, GtkWidget *widget, | |
1163 gint x, gint y, gint w, gint h) | |
1164 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1165 #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
|
1166 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
|
1167 #else |
7 | 1168 widget->requisition.width = w; |
1169 widget->requisition.height = h; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1170 #endif |
7 | 1171 |
1172 gtk_form_move(form, widget, x, y); | |
1173 } | |
1174 | |
1175 static void | |
1176 gtk_form_send_configure(GtkForm *form) | |
1177 { | |
1178 GtkWidget *widget; | |
1179 GdkEventConfigure event; | |
1180 | |
1181 widget = GTK_WIDGET(form); | |
1182 | |
1183 event.type = GDK_CONFIGURE; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1184 #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
|
1185 event.window = gtk_widget_get_window(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1186 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1187 GtkAllocation allocation; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1188 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1189 gtk_widget_get_allocation(widget, &allocation); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1190 event.x = allocation.x; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1191 event.y = allocation.y; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1192 event.width = allocation.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1193 event.height = allocation.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1194 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1195 #else |
7 | 1196 event.window = widget->window; |
1197 event.x = widget->allocation.x; | |
1198 event.y = widget->allocation.y; | |
1199 event.width = widget->allocation.width; | |
1200 event.height = widget->allocation.height; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
1201 #endif |
7 | 1202 |
1203 gtk_main_do_event((GdkEvent*)&event); | |
1204 } | |
1205 | |
1206 static void | |
1884 | 1207 gtk_form_child_map(GtkWidget *widget UNUSED, gpointer user_data) |
7 | 1208 { |
1209 GtkFormChild *child; | |
1210 | |
1211 child = (GtkFormChild *)user_data; | |
1212 | |
1213 child->mapped = TRUE; | |
1214 gdk_window_show(child->window); | |
1215 } | |
1216 | |
1217 static void | |
1884 | 1218 gtk_form_child_unmap(GtkWidget *widget UNUSED, gpointer user_data) |
7 | 1219 { |
1220 GtkFormChild *child; | |
1221 | |
1222 child = (GtkFormChild *)user_data; | |
1223 | |
1224 child->mapped = FALSE; | |
1225 gdk_window_hide(child->window); | |
1226 } |