Mercurial > vim
annotate src/gui_gtk_f.c @ 22681:674ba3200e1f v8.2.1889
patch 8.2.1889: Vim9: errornous error for missing white space after {}
Commit: https://github.com/vim/vim/commit/b07a39de485db5709a6b3e2f96e66ab06dd76279
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 22 19:00:01 2020 +0200
patch 8.2.1889: Vim9: errornous error for missing white space after {}
Problem: Vim9: errornous error for missing white space after {}.
Solution: Don't skip over white space after {}. (issue https://github.com/vim/vim/issues/7167)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 22 Oct 2020 19:15:03 +0200 |
parents | dd711a44e75b |
children | e5ee2ffd826a |
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 * (C) 2002,2003 Jason Hildebrand <jason@peaceworks.ca> | |
15 * Daniel Elstner <daniel.elstner@gmx.net> | |
16 * | |
1207 | 17 * This is a special purpose container widget, which manages arbitrary |
18 * children at arbitrary positions width arbitrary sizes. This finally puts | |
19 * an end on our resize problems with which we where struggling for such a | |
20 * long time. | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
21 * |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
22 * 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
|
23 * 2016 Kazunobu Kuriyama <kazunobu.kuriyama@gmail.com> |
7 | 24 */ |
25 | |
26 #include "vim.h" | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
27 #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
|
28 // runtime! |
7 | 29 #include "gui_gtk_f.h" |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
30 #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
|
31 # include <gtk/gtksignal.h> |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
32 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
14786
diff
changeset
|
33 #ifdef MSWIN |
7 | 34 # include <gdk/gdkwin32.h> |
35 #else | |
36 # include <gdk/gdkx.h> | |
37 #endif | |
38 | |
39 typedef struct _GtkFormChild GtkFormChild; | |
40 | |
41 struct _GtkFormChild | |
42 { | |
43 GtkWidget *widget; | |
44 GdkWindow *window; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
45 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
|
46 gint y; // relative subwidget y position |
7 | 47 gint mapped; |
48 }; | |
49 | |
50 | |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
51 static void gui_gtk_form_class_init(GtkFormClass *klass); |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
52 #if GTK_CHECK_VERSION(3,0,0) |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
53 static void gui_gtk_form_init(GtkForm *form); |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
54 #else |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
55 static void gui_gtk_form_init(GtkForm *form, void *g_class); |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
56 #endif |
7 | 57 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
58 static void form_realize(GtkWidget *widget); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
59 static void form_unrealize(GtkWidget *widget); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
60 static void form_map(GtkWidget *widget); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
61 static void form_size_request(GtkWidget *widget, GtkRequisition *requisition); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
62 #if GTK_CHECK_VERSION(3,0,0) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
63 static void form_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
64 static void form_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
65 #endif |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
66 static void form_size_allocate(GtkWidget *widget, GtkAllocation *allocation); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
67 #if GTK_CHECK_VERSION(3,0,0) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
68 static gboolean form_draw(GtkWidget *widget, cairo_t *cr); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
69 #else |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
70 static gint form_expose(GtkWidget *widget, GdkEventExpose *event); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
71 #endif |
7 | 72 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
73 static void form_remove(GtkContainer *container, GtkWidget *widget); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
74 static void form_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); |
7 | 75 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
76 static void form_attach_child_window(GtkForm *form, GtkFormChild *child); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
77 static void form_realize_child(GtkForm *form, GtkFormChild *child); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
78 static void form_position_child(GtkForm *form, GtkFormChild *child, gboolean force_allocate); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
79 static void form_position_children(GtkForm *form); |
7 | 80 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
81 static void form_send_configure(GtkForm *form); |
7 | 82 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
83 static void form_child_map(GtkWidget *widget, gpointer user_data); |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
84 static void form_child_unmap(GtkWidget *widget, gpointer user_data); |
7 | 85 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
86 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 87 static GtkWidgetClass *parent_class = NULL; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
88 #endif |
7 | 89 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
90 // Public interface |
7 | 91 |
92 GtkWidget * | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
93 gui_gtk_form_new(void) |
7 | 94 { |
95 GtkForm *form; | |
96 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
97 #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
|
98 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
|
99 #else |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
100 form = gtk_type_new(gui_gtk_form_get_type()); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
101 #endif |
7 | 102 |
103 return GTK_WIDGET(form); | |
104 } | |
105 | |
106 void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
107 gui_gtk_form_put( |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
108 GtkForm *form, |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
109 GtkWidget *child_widget, |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
110 gint x, |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
111 gint y) |
7 | 112 { |
113 GtkFormChild *child; | |
114 | |
115 g_return_if_fail(GTK_IS_FORM(form)); | |
116 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
117 // LINTED: avoid warning: conversion to 'unsigned long' |
7 | 118 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
|
119 if (child == NULL) |
a1229400434a
patch 8.1.1219: not checking for NULL return from alloc()
Bram Moolenaar <Bram@vim.org>
parents:
15967
diff
changeset
|
120 return; |
7 | 121 |
122 child->widget = child_widget; | |
123 child->window = NULL; | |
124 child->x = x; | |
125 child->y = y; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
126 #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
|
127 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
|
128 #else |
7 | 129 child->widget->requisition.width = 0; |
130 child->widget->requisition.height = 0; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
131 #endif |
7 | 132 child->mapped = FALSE; |
133 | |
134 form->children = g_list_append(form->children, child); | |
135 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
136 // 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
|
137 // 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
|
138 // 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
|
139 // and its parent is mapped. |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
140 if (gtk_widget_get_realized(GTK_WIDGET(form))) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
141 form_attach_child_window(form, child); |
7 | 142 |
143 gtk_widget_set_parent(child_widget, GTK_WIDGET(form)); | |
144 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
145 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
|
146 && !gtk_widget_get_realized(child_widget)) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
147 form_realize_child(form, child); |
7 | 148 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
149 form_position_child(form, child, TRUE); |
7 | 150 } |
151 | |
152 void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
153 gui_gtk_form_move( |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
154 GtkForm *form, |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
155 GtkWidget *child_widget, |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
156 gint x, |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
157 gint y) |
7 | 158 { |
159 GList *tmp_list; | |
160 GtkFormChild *child; | |
161 | |
162 g_return_if_fail(GTK_IS_FORM(form)); | |
163 | |
164 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
165 { | |
166 child = tmp_list->data; | |
167 if (child->widget == child_widget) | |
168 { | |
169 child->x = x; | |
170 child->y = y; | |
171 | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
172 form_position_child(form, child, TRUE); |
7 | 173 return; |
174 } | |
175 } | |
176 } | |
177 | |
178 void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
179 gui_gtk_form_freeze(GtkForm *form) |
7 | 180 { |
181 g_return_if_fail(GTK_IS_FORM(form)); | |
182 | |
183 ++form->freeze_count; | |
184 } | |
185 | |
186 void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
187 gui_gtk_form_thaw(GtkForm *form) |
7 | 188 { |
189 g_return_if_fail(GTK_IS_FORM(form)); | |
190 | |
191 if (form->freeze_count) | |
192 { | |
193 if (!(--form->freeze_count)) | |
194 { | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
195 form_position_children(form); |
7 | 196 gtk_widget_queue_draw(GTK_WIDGET(form)); |
197 } | |
198 } | |
199 } | |
200 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
201 // Basic Object handling procedures |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
202 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
203 #if GTK_CHECK_VERSION(3,0,0) |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
204 G_DEFINE_TYPE(GtkForm, gui_gtk_form, GTK_TYPE_CONTAINER) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
205 #else |
7 | 206 GtkType |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
207 gui_gtk_form_get_type(void) |
7 | 208 { |
209 static GtkType form_type = 0; | |
210 | |
211 if (!form_type) | |
212 { | |
1884 | 213 GtkTypeInfo form_info; |
214 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
18781
diff
changeset
|
215 CLEAR_FIELD(form_info); |
1884 | 216 form_info.type_name = "GtkForm"; |
217 form_info.object_size = sizeof(GtkForm); | |
218 form_info.class_size = sizeof(GtkFormClass); | |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
219 form_info.class_init_func = (GtkClassInitFunc)gui_gtk_form_class_init; |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
220 form_info.object_init_func = (GtkObjectInitFunc)gui_gtk_form_init; |
7 | 221 |
222 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info); | |
223 } | |
224 return form_type; | |
225 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
226 #endif // !GTK_CHECK_VERSION(3,0,0) |
7 | 227 |
228 static void | |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
229 gui_gtk_form_class_init(GtkFormClass *klass) |
7 | 230 { |
231 GtkWidgetClass *widget_class; | |
232 GtkContainerClass *container_class; | |
233 | |
234 widget_class = (GtkWidgetClass *) klass; | |
235 container_class = (GtkContainerClass *) klass; | |
236 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
237 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 238 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
|
239 #endif |
7 | 240 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
241 widget_class->realize = form_realize; |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
242 widget_class->unrealize = form_unrealize; |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
243 widget_class->map = form_map; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
244 #if GTK_CHECK_VERSION(3,0,0) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
245 widget_class->get_preferred_width = form_get_preferred_width; |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
246 widget_class->get_preferred_height = form_get_preferred_height; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
247 #else |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
248 widget_class->size_request = form_size_request; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
249 #endif |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
250 widget_class->size_allocate = form_size_allocate; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
251 #if GTK_CHECK_VERSION(3,0,0) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
252 widget_class->draw = form_draw; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
253 #else |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
254 widget_class->expose_event = form_expose; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
255 #endif |
7 | 256 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
257 container_class->remove = form_remove; |
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
258 container_class->forall = form_forall; |
7 | 259 } |
260 | |
261 static void | |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
262 gui_gtk_form_init(GtkForm *form |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
263 #if !GTK_CHECK_VERSION(3,0,0) |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
264 , void *g_class UNUSED |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
265 #endif |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
266 ) |
7 | 267 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
268 #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
|
269 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
|
270 #endif |
7 | 271 form->children = NULL; |
272 form->bin_window = NULL; | |
273 form->freeze_count = 0; | |
274 } | |
275 | |
276 /* | |
277 * Widget methods | |
278 */ | |
279 | |
280 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
281 form_realize(GtkWidget *widget) |
7 | 282 { |
283 GList *tmp_list; | |
284 GtkForm *form; | |
285 GdkWindowAttr attributes; | |
286 gint attributes_mask; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
287 GtkAllocation allocation; |
7 | 288 |
289 g_return_if_fail(GTK_IS_FORM(widget)); | |
290 | |
291 form = GTK_FORM(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
292 gtk_widget_set_realized(widget, TRUE); |
7 | 293 |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
294 gtk_widget_get_allocation(widget, &allocation); |
7 | 295 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
|
296 attributes.x = allocation.x; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
297 attributes.y = allocation.y; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
298 attributes.width = allocation.width; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
299 attributes.height = allocation.height; |
7 | 300 attributes.wclass = GDK_INPUT_OUTPUT; |
301 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
|
302 #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
|
303 attributes.event_mask = GDK_EXPOSURE_MASK; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
304 #else |
7 | 305 attributes.colormap = gtk_widget_get_colormap(widget); |
306 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
|
307 #endif |
7 | 308 |
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_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
|
311 #else |
7 | 312 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
|
313 #endif |
7 | 314 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
315 gtk_widget_set_window(widget, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
316 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
|
317 &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
|
318 gdk_window_set_user_data(gtk_widget_get_window(widget), widget); |
7 | 319 |
320 attributes.x = 0; | |
321 attributes.y = 0; | |
322 attributes.event_mask = gtk_widget_get_events(widget); | |
323 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
324 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
|
325 &attributes, attributes_mask); |
7 | 326 gdk_window_set_user_data(form->bin_window, widget); |
327 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
328 #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
|
329 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
330 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
|
331 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
332 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
|
333 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
|
334 # 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
|
335 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
|
336 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
|
337 # endif |
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 #else |
7 | 340 widget->style = gtk_style_attach(widget->style, widget->window); |
341 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); | |
342 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
|
343 #endif |
7 | 344 |
345 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
346 { | |
347 GtkFormChild *child = tmp_list->data; | |
348 | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
349 form_attach_child_window(form, child); |
7 | 350 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
351 if (gtk_widget_get_visible(child->widget)) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
352 form_realize_child(form, child); |
7 | 353 } |
354 } | |
355 | |
356 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
357 // After reading the documentation at |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
358 // 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
|
359 // 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
|
360 // 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
|
361 // |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
362 // 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
|
363 // is necessary. GtkForm is anything but a usual container widget. |
7 | 364 static void |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
365 form_map(GtkWidget *widget) |
7 | 366 { |
367 GList *tmp_list; | |
368 GtkForm *form; | |
369 | |
370 g_return_if_fail(GTK_IS_FORM(widget)); | |
371 | |
372 form = GTK_FORM(widget); | |
373 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
374 gtk_widget_set_mapped(widget, TRUE); |
7 | 375 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
376 gdk_window_show(gtk_widget_get_window(widget)); |
7 | 377 gdk_window_show(form->bin_window); |
378 | |
379 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
380 { | |
381 GtkFormChild *child = tmp_list->data; | |
382 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
383 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
|
384 && !gtk_widget_get_mapped(child->widget)) |
7 | 385 gtk_widget_map(child->widget); |
386 } | |
387 } | |
388 | |
389 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
390 form_unrealize(GtkWidget *widget) |
7 | 391 { |
392 GList *tmp_list; | |
393 GtkForm *form; | |
394 | |
395 g_return_if_fail(GTK_IS_FORM(widget)); | |
396 | |
397 form = GTK_FORM(widget); | |
398 | |
399 tmp_list = form->children; | |
400 | |
401 gdk_window_set_user_data(form->bin_window, NULL); | |
402 gdk_window_destroy(form->bin_window); | |
403 form->bin_window = NULL; | |
404 | |
405 while (tmp_list) | |
406 { | |
407 GtkFormChild *child = tmp_list->data; | |
408 | |
409 if (child->window != NULL) | |
410 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
411 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
412 FUNC2GENERIC(form_child_map), |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
413 child); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
414 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
415 FUNC2GENERIC(form_child_unmap), |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
416 child); |
7 | 417 |
418 gdk_window_set_user_data(child->window, NULL); | |
419 gdk_window_destroy(child->window); | |
420 | |
421 child->window = NULL; | |
422 } | |
423 | |
424 tmp_list = tmp_list->next; | |
425 } | |
426 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
427 #if GTK_CHECK_VERSION(3,0,0) |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
428 if (GTK_WIDGET_CLASS (gui_gtk_form_parent_class)->unrealize) |
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
429 (* GTK_WIDGET_CLASS (gui_gtk_form_parent_class)->unrealize) (widget); |
8218
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_CLASS (parent_class)->unrealize) |
432 (* 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
|
433 #endif |
7 | 434 } |
435 | |
436 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
437 form_size_request(GtkWidget *widget, GtkRequisition *requisition) |
7 | 438 { |
11271
cd8dbed175a1
patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents:
10176
diff
changeset
|
439 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
|
440 g_return_if_fail(requisition != NULL); |
7 | 441 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
442 requisition->width = 1; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
443 requisition->height = 1; |
7 | 444 } |
445 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
446 #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
|
447 static void |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
448 form_get_preferred_width(GtkWidget *widget, |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
449 gint *minimal_width, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
450 gint *natural_width) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
451 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
452 GtkRequisition requisition; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
453 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
454 form_size_request(widget, &requisition); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
455 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
456 *minimal_width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
457 *natural_width = requisition.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 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
460 static void |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
461 form_get_preferred_height(GtkWidget *widget, |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
462 gint *minimal_height, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
463 gint *natural_height) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
464 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
465 GtkRequisition requisition; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
466 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
467 form_size_request(widget, &requisition); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
468 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
469 *minimal_height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
470 *natural_height = requisition.height; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
471 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
472 #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
|
473 |
7 | 474 static void |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
475 form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) |
7 | 476 { |
477 GList *tmp_list; | |
478 GtkForm *form; | |
479 gboolean need_reposition; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
480 GtkAllocation cur_alloc; |
7 | 481 |
482 g_return_if_fail(GTK_IS_FORM(widget)); | |
483 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
484 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
|
485 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
486 if (cur_alloc.x == allocation->x |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
487 && cur_alloc.y == allocation->y |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
488 && cur_alloc.width == allocation->width |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
489 && cur_alloc.height == allocation->height) |
7 | 490 return; |
491 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
492 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
|
493 || cur_alloc.height != allocation->height; |
7 | 494 form = GTK_FORM(widget); |
495 | |
496 if (need_reposition) | |
497 { | |
498 tmp_list = form->children; | |
499 | |
500 while (tmp_list) | |
501 { | |
502 GtkFormChild *child = tmp_list->data; | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
503 form_position_child(form, child, TRUE); |
7 | 504 |
505 tmp_list = tmp_list->next; | |
506 } | |
507 } | |
508 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
509 if (gtk_widget_get_realized(widget)) |
7 | 510 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
511 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
|
512 allocation->x, allocation->y, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
513 allocation->width, allocation->height); |
7 | 514 gdk_window_move_resize(GTK_FORM(widget)->bin_window, |
515 0, 0, | |
516 allocation->width, allocation->height); | |
517 } | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
518 gtk_widget_set_allocation(widget, allocation); |
7 | 519 if (need_reposition) |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
520 form_send_configure(form); |
7 | 521 } |
522 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
523 #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
|
524 static void |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
525 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
|
526 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
527 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
|
528 0, 0, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
529 gtk_widget_get_allocated_width(widget), |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
530 gtk_widget_get_allocated_height(widget)); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
531 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
532 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
533 static gboolean |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
534 form_draw(GtkWidget *widget, cairo_t *cr) |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
535 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
536 GList *tmp_list = NULL; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
537 GtkForm *form = NULL; |
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 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
|
540 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
541 gtk_form_render_background(widget, 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 form = GTK_FORM(widget); |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
544 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
|
545 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
546 GtkFormChild * const formchild = tmp_list->data; |
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 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
|
549 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
|
550 { |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
551 // 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
|
552 // 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
|
553 // 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
|
554 // certain private GtkWidget variable, called |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
555 // 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
|
556 // 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
|
557 // appear on the screen. |
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
558 // |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
559 // Calling form_position_child() like this is one of ways |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
560 // to make sure of that. |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
561 form_position_child(form, formchild, TRUE); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
562 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
563 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
|
564 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
565 } |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
566 |
22665
dd711a44e75b
patch 8.2.1881: cannot build with GTK3
Bram Moolenaar <Bram@vim.org>
parents:
22659
diff
changeset
|
567 return GTK_WIDGET_CLASS(gui_gtk_form_parent_class)->draw(widget, cr); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
568 } |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
569 #else // !GTK_CHECK_VERSION(3,0,0) |
7 | 570 static gint |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
571 form_expose(GtkWidget *widget, GdkEventExpose *event) |
7 | 572 { |
573 GList *tmp_list; | |
574 GtkForm *form; | |
575 | |
576 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); | |
577 | |
578 form = GTK_FORM(widget); | |
579 | |
580 if (event->window == form->bin_window) | |
581 return FALSE; | |
582 | |
583 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
|
584 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
|
585 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
|
586 event); |
7 | 587 |
588 return FALSE; | |
589 } | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
590 #endif // !GTK_CHECK_VERSION(3,0,0) |
7 | 591 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
592 // Container method |
7 | 593 static void |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
594 form_remove(GtkContainer *container, GtkWidget *widget) |
7 | 595 { |
596 GList *tmp_list; | |
597 GtkForm *form; | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
598 GtkFormChild *child = NULL; // init for gcc |
7 | 599 |
600 g_return_if_fail(GTK_IS_FORM(container)); | |
601 | |
602 form = GTK_FORM(container); | |
603 | |
604 tmp_list = form->children; | |
605 while (tmp_list) | |
606 { | |
607 child = tmp_list->data; | |
608 if (child->widget == widget) | |
609 break; | |
610 tmp_list = tmp_list->next; | |
611 } | |
612 | |
613 if (tmp_list) | |
614 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
615 #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
|
616 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
|
617 #endif |
7 | 618 if (child->window) |
619 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
620 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
621 FUNC2GENERIC(&form_child_map), child); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
622 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
623 FUNC2GENERIC(&form_child_unmap), child); |
7 | 624 |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
625 // 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
|
626 // widgets out of a GtkForm |
7 | 627 gdk_window_set_user_data(child->window, NULL); |
628 gdk_window_destroy(child->window); | |
629 } | |
630 gtk_widget_unparent(widget); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
631 #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
|
632 if (was_visible) |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
633 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
|
634 #endif |
7 | 635 form->children = g_list_remove_link(form->children, tmp_list); |
636 g_list_free_1(tmp_list); | |
637 g_free(child); | |
638 } | |
639 } | |
640 | |
641 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
642 form_forall(GtkContainer *container, |
1884 | 643 gboolean include_internals UNUSED, |
7 | 644 GtkCallback callback, |
645 gpointer callback_data) | |
646 { | |
647 GtkForm *form; | |
648 GtkFormChild *child; | |
649 GList *tmp_list; | |
650 | |
651 g_return_if_fail(GTK_IS_FORM(container)); | |
652 g_return_if_fail(callback != NULL); | |
653 | |
654 form = GTK_FORM(container); | |
655 | |
656 tmp_list = form->children; | |
657 while (tmp_list) | |
658 { | |
659 child = tmp_list->data; | |
660 tmp_list = tmp_list->next; | |
661 | |
662 (*callback) (child->widget, callback_data); | |
663 } | |
664 } | |
665 | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
666 // Operations on children |
7 | 667 |
668 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
669 form_attach_child_window(GtkForm *form, GtkFormChild *child) |
7 | 670 { |
671 if (child->window != NULL) | |
18781
79e10adc821d
patch 8.1.2380: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
16429
diff
changeset
|
672 return; // been there, done that |
7 | 673 |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
674 if (!gtk_widget_get_has_window(child->widget)) |
7 | 675 { |
676 GtkWidget *widget; | |
677 GdkWindowAttr attributes; | |
678 gint attributes_mask; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
679 GtkRequisition requisition; |
7 | 680 |
681 widget = GTK_WIDGET(form); | |
682 | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
683 #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
|
684 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
|
685 #else |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
686 requisition = child->widget->requisition; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
687 #endif |
7 | 688 attributes.window_type = GDK_WINDOW_CHILD; |
689 attributes.x = child->x; | |
690 attributes.y = child->y; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
691 attributes.width = requisition.width; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
692 attributes.height = requisition.height; |
7 | 693 attributes.wclass = GDK_INPUT_OUTPUT; |
694 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
|
695 #if !GTK_CHECK_VERSION(3,0,0) |
7 | 696 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
|
697 #endif |
7 | 698 attributes.event_mask = GDK_EXPOSURE_MASK; |
699 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
700 #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
|
701 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
|
702 #else |
7 | 703 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
|
704 #endif |
7 | 705 child->window = gdk_window_new(form->bin_window, |
706 &attributes, attributes_mask); | |
707 gdk_window_set_user_data(child->window, widget); | |
708 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
709 #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
|
710 { |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
711 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
|
712 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
713 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
|
714 # 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
|
715 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
|
716 # endif |
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 #else |
7 | 719 gtk_style_set_background(widget->style, |
720 child->window, | |
721 GTK_STATE_NORMAL); | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
722 #endif |
7 | 723 |
724 gtk_widget_set_parent_window(child->widget, child->window); | |
725 /* | |
726 * Install signal handlers to map/unmap child->window | |
727 * alongside with the actual widget. | |
728 */ | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
729 g_signal_connect(G_OBJECT(child->widget), "map", |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
730 G_CALLBACK(&form_child_map), child); |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
731 g_signal_connect(G_OBJECT(child->widget), "unmap", |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
732 G_CALLBACK(&form_child_unmap), child); |
7 | 733 } |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
734 else if (!gtk_widget_get_realized(child->widget)) |
7 | 735 { |
736 gtk_widget_set_parent_window(child->widget, form->bin_window); | |
737 } | |
738 } | |
739 | |
740 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
741 form_realize_child(GtkForm *form, GtkFormChild *child) |
7 | 742 { |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
743 form_attach_child_window(form, child); |
7 | 744 gtk_widget_realize(child->widget); |
745 } | |
746 | |
747 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
748 form_position_child(GtkForm *form, GtkFormChild *child, gboolean force_allocate) |
7 | 749 { |
750 gint x; | |
751 gint y; | |
752 | |
753 x = child->x; | |
754 y = child->y; | |
755 | |
756 if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && | |
757 (y >= G_MINSHORT) && (y <= G_MAXSHORT)) | |
758 { | |
759 if (!child->mapped) | |
760 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
761 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
|
762 && gtk_widget_get_visible(child->widget)) |
7 | 763 { |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
764 if (!gtk_widget_get_mapped(child->widget)) |
7 | 765 gtk_widget_map(child->widget); |
766 | |
767 child->mapped = TRUE; | |
768 force_allocate = TRUE; | |
769 } | |
770 } | |
771 | |
772 if (force_allocate) | |
773 { | |
774 GtkAllocation allocation; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
775 GtkRequisition requisition; |
7 | 776 |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
777 #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
|
778 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
|
779 #else |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
780 requisition = child->widget->requisition; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
781 #endif |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
782 |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
783 if (!gtk_widget_get_has_window(child->widget)) |
7 | 784 { |
785 if (child->window) | |
786 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
787 gdk_window_move_resize(child->window, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
788 x, y, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
789 requisition.width, |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
790 requisition.height); |
7 | 791 } |
792 | |
793 allocation.x = 0; | |
794 allocation.y = 0; | |
795 } | |
796 else | |
797 { | |
798 allocation.x = x; | |
799 allocation.y = y; | |
800 } | |
801 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
802 allocation.width = requisition.width; |
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
803 allocation.height = requisition.height; |
7 | 804 |
805 gtk_widget_size_allocate(child->widget, &allocation); | |
806 } | |
807 } | |
808 else | |
809 { | |
810 if (child->mapped) | |
811 { | |
812 child->mapped = FALSE; | |
813 | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
814 if (gtk_widget_get_mapped(child->widget)) |
7 | 815 gtk_widget_unmap(child->widget); |
816 } | |
817 } | |
818 } | |
819 | |
820 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
821 form_position_children(GtkForm *form) |
7 | 822 { |
823 GList *tmp_list; | |
824 | |
825 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
826 form_position_child(form, tmp_list->data, FALSE); |
7 | 827 } |
828 | |
829 void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
830 gui_gtk_form_move_resize(GtkForm *form, GtkWidget *widget, |
7 | 831 gint x, gint y, gint w, gint h) |
832 { | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
833 #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
|
834 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
|
835 #else |
7 | 836 widget->requisition.width = w; |
837 widget->requisition.height = h; | |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
838 #endif |
7 | 839 |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
840 gui_gtk_form_move(form, widget, x, y); |
7 | 841 } |
842 | |
843 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
844 form_send_configure(GtkForm *form) |
7 | 845 { |
846 GtkWidget *widget; | |
847 GdkEventConfigure event; | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
848 GtkAllocation allocation; |
7 | 849 |
850 widget = GTK_WIDGET(form); | |
851 | |
14786
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
852 gtk_widget_get_allocation(widget, &allocation); |
7 | 853 event.type = GDK_CONFIGURE; |
8218
3456e2ebebd4
commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents:
2275
diff
changeset
|
854 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
|
855 event.x = allocation.x; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
856 event.y = allocation.y; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
857 event.width = allocation.width; |
11978f68a8c3
patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents:
14712
diff
changeset
|
858 event.height = allocation.height; |
7 | 859 |
860 gtk_main_do_event((GdkEvent*)&event); | |
861 } | |
862 | |
863 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
864 form_child_map(GtkWidget *widget UNUSED, gpointer user_data) |
7 | 865 { |
866 GtkFormChild *child; | |
867 | |
868 child = (GtkFormChild *)user_data; | |
869 | |
870 child->mapped = TRUE; | |
871 gdk_window_show(child->window); | |
872 } | |
873 | |
874 static void | |
22659
8623ab39b421
patch 8.2.1878: GTK: error for redefining function
Bram Moolenaar <Bram@vim.org>
parents:
22653
diff
changeset
|
875 form_child_unmap(GtkWidget *widget UNUSED, gpointer user_data) |
7 | 876 { |
877 GtkFormChild *child; | |
878 | |
879 child = (GtkFormChild *)user_data; | |
880 | |
881 child->mapped = FALSE; | |
882 gdk_window_hide(child->window); | |
883 } |