annotate src/gui_gtk_f.c @ 15125:b101b193d5ff v8.1.0573

patch 8.1.0573: cannot redefine user command without ! in same script commit https://github.com/vim/vim/commit/55d46913084745a48749d7ac4f48930852e1d87e Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 8 16:03:28 2018 +0100 patch 8.1.0573: cannot redefine user command without ! in same script Problem: Cannot redefine user command without ! in same script Solution: Allow redefining user command without ! in same script, like with functions.
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Dec 2018 16:15:05 +0100
parents 11978f68a8c3
children 7fad90423bd2
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"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #include <gtk/gtk.h> /* without this it compiles, but gives errors at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 runtime! */
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
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #ifdef WIN3264
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;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 gint x; /* relative subwidget x position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 gint y; /* relative subwidget y position */
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 /* Public interface
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 GtkWidget *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 gtk_form_new(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
112 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
113 form = g_object_new(GTK_TYPE_FORM, NULL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
114 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 form = gtk_type_new(gtk_form_get_type());
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
116 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 return GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 gtk_form_put(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 GtkWidget *child_widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 gint x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 gint y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130
129
2983cde45542 updated for version 7.0044
vimboss
parents: 66
diff changeset
131 /* LINTED: avoid warning: conversion to 'unsigned long' */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 child = g_new(GtkFormChild, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 child->widget = child_widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 child->window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 child->x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 child->y = y;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
138 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
139 gtk_widget_set_size_request(child->widget, -1, -1);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
140 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 child->widget->requisition.width = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 child->widget->requisition.height = 0;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
143 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 form->children = g_list_append(form->children, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 /* child->window must be created and attached to the widget _before_
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 * it has been realized, or else things will break with GTK2. Note
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 * that gtk_widget_set_parent() realizes the widget if it's visible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 * and its parent is mapped.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
153 if (gtk_widget_get_realized(GTK_WIDGET(form)))
7
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 /* Basic Object handling procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 */
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
215 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
216 G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
217 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 GtkType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 gtk_form_get_type(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 static GtkType form_type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 if (!form_type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 {
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
225 GtkTypeInfo form_info;
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
226
1885
605f5c2f77ba updated for version 7.2-182
vimboss
parents: 1884
diff changeset
227 vim_memset(&form_info, 0, sizeof(form_info));
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
228 form_info.type_name = "GtkForm";
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
229 form_info.object_size = sizeof(GtkForm);
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
230 form_info.class_size = sizeof(GtkFormClass);
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
231 form_info.class_init_func = (GtkClassInitFunc)gtk_form_class_init;
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
232 form_info.object_init_func = (GtkObjectInitFunc)gtk_form_init;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 return form_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
238 #endif /* !GTK_CHECK_VERSION(3,0,0) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 gtk_form_class_init(GtkFormClass *klass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 GtkWidgetClass *widget_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 GtkContainerClass *container_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 widget_class = (GtkWidgetClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 container_class = (GtkContainerClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
249 #if !GTK_CHECK_VERSION(3,0,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 parent_class = gtk_type_class(gtk_container_get_type());
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
251 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 widget_class->realize = gtk_form_realize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 widget_class->unrealize = gtk_form_unrealize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 widget_class->map = gtk_form_map;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
256 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
257 widget_class->get_preferred_width = gtk_form_get_preferred_width;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
258 widget_class->get_preferred_height = gtk_form_get_preferred_height;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
259 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 widget_class->size_request = gtk_form_size_request;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
261 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 widget_class->size_allocate = gtk_form_size_allocate;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
263 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
264 widget_class->draw = gtk_form_draw;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
265 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 widget_class->expose_event = gtk_form_expose;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
267 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 container_class->remove = gtk_form_remove;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 container_class->forall = gtk_form_forall;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 gtk_form_init(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
276 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
277 gtk_widget_set_has_window(GTK_WIDGET(form), TRUE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
278 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 form->children = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 form->freeze_count = 0;
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 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 * Widget methods
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 gtk_form_realize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 gint attributes_mask;
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
295 GtkAllocation allocation;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 form = GTK_FORM(widget);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
300 gtk_widget_set_realized(widget, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
302 gtk_widget_get_allocation(widget, &allocation);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 attributes.window_type = GDK_WINDOW_CHILD;
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
304 attributes.x = allocation.x;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
305 attributes.y = allocation.y;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
306 attributes.width = allocation.width;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
307 attributes.height = allocation.height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 attributes.visual = gtk_widget_get_visual(widget);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
310 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
311 attributes.event_mask = GDK_EXPOSURE_MASK;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
312 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 attributes.colormap = gtk_widget_get_colormap(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
315 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
317 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
318 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
319 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
321 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
323 gtk_widget_set_window(widget,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
324 gdk_window_new(gtk_widget_get_parent_window(widget),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
325 &attributes, attributes_mask));
14712
82e7ce311065 patch 8.1.0368: GTK code has too many #ifdefs and GTK 2.10 building fails
Christian Brabandt <cb@256bit.org>
parents: 11343
diff changeset
326 gdk_window_set_user_data(gtk_widget_get_window(widget), widget);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 attributes.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 attributes.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 attributes.event_mask = gtk_widget_get_events(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
332 form->bin_window = gdk_window_new(gtk_widget_get_window(widget),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
333 &attributes, attributes_mask);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 gdk_window_set_user_data(form->bin_window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
336 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
337 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
338 GtkStyleContext * const sctx = gtk_widget_get_style_context(widget);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
339
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
340 gtk_style_context_add_class(sctx, "gtk-form");
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
341 gtk_style_context_set_state(sctx, GTK_STATE_FLAG_NORMAL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
342 # if !GTK_CHECK_VERSION(3,18,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
343 gtk_style_context_set_background(sctx, gtk_widget_get_window(widget));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
344 gtk_style_context_set_background(sctx, form->bin_window);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
345 # endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
346 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
347 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 widget->style = gtk_style_attach(widget->style, widget->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 gtk_style_set_background(widget->style, form->bin_window, GTK_STATE_NORMAL);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
351 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
359 if (gtk_widget_get_visible(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 gtk_form_realize_child(form, child);
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 /* After reading the documentation at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 * I think it should be possible to remove this function when compiling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 * against gtk-2.0. It doesn't seem to cause problems, though.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 * Well, I reckon at least the gdk_window_show(form->bin_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 * is necessary. GtkForm is anything but a usual container widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 gtk_form_map(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 form = GTK_FORM(widget);
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 gtk_widget_set_mapped(widget, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
385 gdk_window_show(gtk_widget_get_window(widget));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 gdk_window_show(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
392 if (gtk_widget_get_visible(child->widget)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
393 && !gtk_widget_get_mapped(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 gtk_form_unrealize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 gdk_window_set_user_data(form->bin_window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 gdk_window_destroy(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 if (child->window != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
420 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
10176
51888fb2599f commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
421 FUNC2GENERIC(gtk_form_child_map),
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
422 child);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
423 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
10176
51888fb2599f commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
424 FUNC2GENERIC(gtk_form_child_unmap),
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
425 child);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 child->window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
436 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
437 if (GTK_WIDGET_CLASS (gtk_form_parent_class)->unrealize)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
438 (* GTK_WIDGET_CLASS (gtk_form_parent_class)->unrealize) (widget);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
439 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
442 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 gtk_form_size_request(GtkWidget *widget, GtkRequisition *requisition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 {
11271
cd8dbed175a1 patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents: 10176
diff changeset
448 g_return_if_fail(GTK_IS_FORM(widget));
cd8dbed175a1 patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents: 10176
diff changeset
449 g_return_if_fail(requisition != NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
451 requisition->width = 1;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
452 requisition->height = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
455 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
456 static void
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
457 gtk_form_get_preferred_width(GtkWidget *widget,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
458 gint *minimal_width,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
459 gint *natural_width)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
460 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
461 GtkRequisition requisition;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
462
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
463 gtk_form_size_request(widget, &requisition);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
464
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
465 *minimal_width = requisition.width;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
466 *natural_width = requisition.width;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
467 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
468
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
469 static void
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
470 gtk_form_get_preferred_height(GtkWidget *widget,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
471 gint *minimal_height,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
472 gint *natural_height)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
473 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
474 GtkRequisition requisition;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
475
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
476 gtk_form_size_request(widget, &requisition);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
477
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
478 *minimal_height = requisition.height;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
479 *natural_height = requisition.height;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
480 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
481 #endif /* GTK_CHECK_VERSION(3,0,0) */
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
482
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 gboolean need_reposition;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
489 GtkAllocation cur_alloc;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
493 gtk_widget_get_allocation(widget, &cur_alloc);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
494
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
495 if (cur_alloc.x == allocation->x
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
496 && cur_alloc.y == allocation->y
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
497 && cur_alloc.width == allocation->width
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
498 && cur_alloc.height == allocation->height)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
501 need_reposition = cur_alloc.width != allocation->width
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
502 || cur_alloc.height != allocation->height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 }
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 if (gtk_widget_get_realized(widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
520 gdk_window_move_resize(gtk_widget_get_window(widget),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
521 allocation->x, allocation->y,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
522 allocation->width, allocation->height);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 gdk_window_move_resize(GTK_FORM(widget)->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 allocation->width, allocation->height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
527 gtk_widget_set_allocation(widget, allocation);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 gtk_form_send_configure(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
532 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
533 static void
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
534 gtk_form_render_background(GtkWidget *widget, cairo_t *cr)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
535 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
536 gtk_render_background(gtk_widget_get_style_context(widget), cr,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
537 0, 0,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
538 gtk_widget_get_allocated_width(widget),
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
539 gtk_widget_get_allocated_height(widget));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
540 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
541
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
542 static gboolean
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
543 gtk_form_draw(GtkWidget *widget, cairo_t *cr)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
544 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
545 GList *tmp_list = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
546 GtkForm *form = NULL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
547
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
548 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
549
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
550 gtk_form_render_background(widget, cr);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
551
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
552 form = GTK_FORM(widget);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
553 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
554 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
555 GtkFormChild * const formchild = tmp_list->data;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
556
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
557 if (!gtk_widget_get_has_window(formchild->widget) &&
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
558 gtk_cairo_should_draw_window(cr, formchild->window))
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
559 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
560 /* To get gtk_widget_draw() to work, it is required to call
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
561 * gtk_widget_size_allocate() in advance with a well-posed
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
562 * allocation for a given child widget in order to set a
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
563 * certain private GtkWidget variable, called
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
564 * widget->priv->alloc_need, to the proper value; othewise,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
565 * gtk_widget_draw() fails and the relevant scrollbar won't
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
566 * appear on the screen.
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
567 *
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
568 * Calling gtk_form_position_child() like this is one of ways
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
569 * to make sure of that. */
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
570 gtk_form_position_child(form, formchild, TRUE);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
571
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
572 gtk_form_render_background(formchild->widget, cr);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
573 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
574 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
575
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
576 return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
577 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
578 #else /* !GTK_CHECK_VERSION(3,0,0) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 static gint
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 if (event->window == form->bin_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
11271
cd8dbed175a1 patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents: 10176
diff changeset
593 gtk_container_propagate_expose(GTK_CONTAINER(widget),
cd8dbed175a1 patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents: 10176
diff changeset
594 GTK_WIDGET(((GtkFormChild *)tmp_list->data)->widget),
cd8dbed175a1 patch 8.0.0521: GtkForm handling is outdated
Christian Brabandt <cb@256bit.org>
parents: 10176
diff changeset
595 event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
599 #endif /* !GTK_CHECK_VERSION(3,0,0) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 /* Container method
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 gtk_form_remove(GtkContainer *container, GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 GtkFormChild *child = NULL; /* init for gcc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 if (child->widget == widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 if (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
625 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
626 const gboolean was_visible = gtk_widget_get_visible(widget);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
627 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
630 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
10176
51888fb2599f commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
631 FUNC2GENERIC(&gtk_form_child_map), child);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
632 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
10176
51888fb2599f commit https://github.com/vim/vim/commit/d47d83745ff450232328ca7a4b8b00b31bad22fc
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
633 FUNC2GENERIC(&gtk_form_child_unmap), child);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 /* FIXME: This will cause problems for reparenting NO_WINDOW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 * widgets out of a GtkForm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 gtk_widget_unparent(widget);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
642 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
643 if (was_visible)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
644 gtk_widget_queue_resize(GTK_WIDGET(container));
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
645 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 form->children = g_list_remove_link(form->children, tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 g_list_free_1(tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 g_free(child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 gtk_form_forall(GtkContainer *container,
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
654 gboolean include_internals UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 GtkCallback callback,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 gpointer callback_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 g_return_if_fail(callback != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 (*callback) (child->widget, callback_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 /* Operations on children
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 if (child->window != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 return; /* been there, done that */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
686 if (!gtk_widget_get_has_window(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 gint attributes_mask;
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
691 GtkRequisition requisition;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
695 #if GTK_CHECK_VERSION(3,0,0)
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
696 gtk_widget_get_preferred_size(child->widget, &requisition, NULL);
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
697 #else
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
698 requisition = child->widget->requisition;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
699 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 attributes.window_type = GDK_WINDOW_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 attributes.x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 attributes.y = child->y;
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
703 attributes.width = requisition.width;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
704 attributes.height = requisition.height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 attributes.visual = gtk_widget_get_visual(widget);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
707 #if !GTK_CHECK_VERSION(3,0,0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 attributes.colormap = gtk_widget_get_colormap(widget);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
709 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 attributes.event_mask = GDK_EXPOSURE_MASK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
712 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
713 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
714 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
716 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 child->window = gdk_window_new(form->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 gdk_window_set_user_data(child->window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
721 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
722 {
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
723 GtkStyleContext * const sctx = gtk_widget_get_style_context(widget);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
724
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
725 gtk_style_context_set_state(sctx, GTK_STATE_FLAG_NORMAL);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
726 # if !GTK_CHECK_VERSION(3,18,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
727 gtk_style_context_set_background(sctx, child->window);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
728 # endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
729 }
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
730 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 gtk_style_set_background(widget->style,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 child->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 GTK_STATE_NORMAL);
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
734 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 gtk_widget_set_parent_window(child->widget, child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 * Install signal handlers to map/unmap child->window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 * alongside with the actual widget.
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 g_signal_connect(G_OBJECT(child->widget), "map",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
742 G_CALLBACK(&gtk_form_child_map), child);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
743 g_signal_connect(G_OBJECT(child->widget), "unmap",
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
744 G_CALLBACK(&gtk_form_child_unmap), child);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 }
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
746 else if (!gtk_widget_get_realized(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 gtk_widget_set_parent_window(child->widget, form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 gtk_form_realize_child(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 gtk_widget_realize(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 gtk_form_position_child(GtkForm *form, GtkFormChild *child,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 gboolean force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 gint x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 gint y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 y = child->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 (y >= G_MINSHORT) && (y <= G_MAXSHORT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 if (!child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
774 if (gtk_widget_get_mapped(GTK_WIDGET(form))
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
775 && gtk_widget_get_visible(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
777 if (!gtk_widget_get_mapped(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 force_allocate = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 if (force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 GtkAllocation allocation;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
788 GtkRequisition requisition;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
790 #if GTK_CHECK_VERSION(3,0,0)
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
791 gtk_widget_get_preferred_size(child->widget, &requisition, NULL);
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
792 #else
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
793 requisition = child->widget->requisition;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
794 #endif
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
795
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
796 if (!gtk_widget_get_has_window(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
800 gdk_window_move_resize(child->window,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
801 x, y,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
802 requisition.width,
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
803 requisition.height);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 allocation.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 allocation.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 allocation.x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 allocation.y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
815 allocation.width = requisition.width;
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
816 allocation.height = requisition.height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 gtk_widget_size_allocate(child->widget, &allocation);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 if (child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
827 if (gtk_widget_get_mapped(child->widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 gtk_widget_unmap(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 gtk_form_position_children(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 gtk_form_position_child(form, tmp_list->data, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 gtk_form_move_resize(GtkForm *form, GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 gint x, gint y, gint w, gint h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 {
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
846 #if GTK_CHECK_VERSION(3,0,0)
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
847 gtk_widget_set_size_request(widget, w, h);
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
848 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 widget->requisition.width = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 widget->requisition.height = h;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
851 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 gtk_form_move(form, widget, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 gtk_form_send_configure(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 GdkEventConfigure event;
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
861 GtkAllocation allocation;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
865 gtk_widget_get_allocation(widget, &allocation);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 event.type = GDK_CONFIGURE;
8218
3456e2ebebd4 commit https://github.com/vim/vim/commit/9892189d2e7ab94b750f99e6da4cbfc3c8014517
Christian Brabandt <cb@256bit.org>
parents: 2275
diff changeset
867 event.window = gtk_widget_get_window(widget);
14786
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
868 event.x = allocation.x;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
869 event.y = allocation.y;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
870 event.width = allocation.width;
11978f68a8c3 patch 8.1.0405: too many #ifdefs for GTK
Christian Brabandt <cb@256bit.org>
parents: 14712
diff changeset
871 event.height = allocation.height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 gtk_main_do_event((GdkEvent*)&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
877 gtk_form_child_map(GtkWidget *widget UNUSED, gpointer user_data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 gdk_window_show(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
888 gtk_form_child_unmap(GtkWidget *widget UNUSED, gpointer user_data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 gdk_window_hide(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 }