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