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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
66
99064882c85b updated for version 7.0030
vimboss
parents: 7
diff changeset
11 * (C) 1998,1999 by Marcin Dalecki <martin@dalecki.de>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * Support for GTK+ 2 was added by:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * (C) 2002,2003 Jason Hildebrand <jason@peaceworks.ca>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * Daniel Elstner <daniel.elstner@gmx.net>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 *
1207
beed57a8fcd1 updated for version 7.1b
vimboss
parents: 129
diff changeset
18 * This is a special purpose container widget, which manages arbitrary
beed57a8fcd1 updated for version 7.1b
vimboss
parents: 129
diff changeset
19 * children at arbitrary positions width arbitrary sizes. This finally puts
beed57a8fcd1 updated for version 7.1b
vimboss
parents: 129
diff changeset
20 * an end on our resize problems with which we where struggling for such a
beed57a8fcd1 updated for version 7.1b
vimboss
parents: 129
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 # include <gdk/gdkwin32.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 # include <gdk/gdkx.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 typedef struct _GtkFormChild GtkFormChild;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 struct _GtkFormChild
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 gint mapped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 static void gtk_form_class_init(GtkFormClass *klass);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 static void gtk_form_init(GtkForm *form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 static void gtk_form_realize(GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 static void gtk_form_unrealize(GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 static void gtk_form_map(GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 static void gtk_form_size_request(GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 static void gtk_form_size_allocate(GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 static gint gtk_form_expose(GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 static void gtk_form_remove(GtkContainer *container,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 static void gtk_form_forall(GtkContainer *container,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 gboolean include_internals,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 GtkCallback callback,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 gpointer callback_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 static void gtk_form_attach_child_window(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 GtkFormChild *child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 static void gtk_form_realize_child(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 GtkFormChild *child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 static void gtk_form_position_child(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 GtkFormChild *child,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 gboolean force_allocate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 static void gtk_form_position_children(GtkForm *form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 static void gtk_form_send_configure(GtkForm *form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 static void gtk_form_child_map(GtkWidget *widget, gpointer user_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 static void gtk_form_child_unmap(GtkWidget *widget, gpointer user_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 GtkWidget *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 gtk_form_new(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 return GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 gtk_form_put(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 GtkWidget *child_widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 gint x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 gint y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 child->widget = child_widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 child->window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 child->x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 child->widget->requisition.width = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 form->children = g_list_append(form->children, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 gtk_widget_set_parent(child_widget, GTK_WIDGET(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 gtk_form_realize_child(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 gtk_form_move(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 GtkWidget *child_widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 gint x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 gint y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 if (child->widget == child_widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 child->x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 child->y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 gtk_form_freeze(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 ++form->freeze_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 gtk_form_thaw(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 if (form->freeze_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 if (!(--form->freeze_count))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 gtk_form_position_children(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 gtk_widget_queue_draw(GTK_WIDGET(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 GtkType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 gtk_form_get_type(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 static GtkType form_type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 if (!form_type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 {
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
224 GtkTypeInfo form_info;
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
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
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
227 form_info.type_name = "GtkForm";
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
228 form_info.object_size = sizeof(GtkForm);
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
229 form_info.class_size = sizeof(GtkFormClass);
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
230 form_info.class_init_func = (GtkClassInitFunc)gtk_form_class_init;
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
231 form_info.object_init_func = (GtkObjectInitFunc)gtk_form_init;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 return form_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 gtk_form_class_init(GtkFormClass *klass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 GtkWidgetClass *widget_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 GtkContainerClass *container_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 widget_class = (GtkWidgetClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 container_class = (GtkContainerClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 widget_class->realize = gtk_form_realize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 widget_class->unrealize = gtk_form_unrealize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 container_class->remove = gtk_form_remove;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 container_class->forall = gtk_form_forall;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 gtk_form_init(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 form->children = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 form->freeze_count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 * Widget methods
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 gtk_form_realize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 attributes.colormap = gtk_widget_get_colormap(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 attributes.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 attributes.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 attributes.event_mask = gtk_widget_get_events(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 gdk_window_set_user_data(form->bin_window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 widget->style = gtk_style_attach(widget->style, widget->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 gtk_form_realize_child(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 gtk_form_map(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 gdk_window_show(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 gtk_form_unrealize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 gdk_window_set_user_data(form->bin_window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 gdk_window_destroy(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 if (child->window != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 child->window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 gtk_form_size_request(GtkWidget *widget, GtkRequisition *requisition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 gdk_window_move_resize(GTK_FORM(widget)->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 allocation->width, allocation->height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 gtk_form_send_configure(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 static gint
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 if (event->window == form->bin_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 gtk_form_remove(GtkContainer *container, GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 if (child->widget == widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 if (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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(&gtk_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(&gtk_form_child_unmap), child);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 form->children = g_list_remove_link(form->children, tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 g_list_free_1(tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 g_free(child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 gtk_form_forall(GtkContainer *container,
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
650 gboolean include_internals UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 GtkCallback callback,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 gpointer callback_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 g_return_if_fail(callback != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 (*callback) (child->widget, callback_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 attributes.window_type = GDK_WINDOW_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 attributes.x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 attributes.event_mask = GDK_EXPOSURE_MASK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 child->window = gdk_window_new(form->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 gdk_window_set_user_data(child->window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 gtk_style_set_background(widget->style,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 child->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 gtk_widget_set_parent_window(child->widget, child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 * Install signal handlers to map/unmap child->window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 * alongside with the actual widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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(&gtk_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(&gtk_form_child_unmap), child);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 gtk_widget_set_parent_window(child->widget, form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 gtk_form_realize_child(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 gtk_widget_realize(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 gtk_form_position_child(GtkForm *form, GtkFormChild *child,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 gboolean force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 gint x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 gint y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 y = child->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 (y >= G_MINSHORT) && (y <= G_MAXSHORT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 if (!child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 force_allocate = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 if (force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 allocation.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 allocation.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 allocation.x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 allocation.y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 gtk_widget_size_allocate(child->widget, &allocation);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 if (child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 gtk_widget_unmap(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 gtk_form_position_children(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 gtk_form_position_child(form, tmp_list->data, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 gtk_form_move_resize(GtkForm *form, GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 gint x, gint y, gint w, gint h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 widget->requisition.width = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 gtk_form_move(form, widget, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 gtk_form_send_configure(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 gtk_main_do_event((GdkEvent*)&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
872 gtk_form_child_map(GtkWidget *widget UNUSED, gpointer user_data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 gdk_window_show(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
883 gtk_form_child_unmap(GtkWidget *widget UNUSED, gpointer user_data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 gdk_window_hide(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 }