annotate src/gui_gtk_f.c @ 2274:7c31d761ffa9 vim73

Fix build problem with Ruby on Windows. (Cesar Romani)
author Bram Moolenaar <bram@vim.org>
date Fri, 25 Jun 2010 04:29:11 +0200
parents 770485470e59
children e4d849f4df03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
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.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 #include <gtk/gtk.h> /* without this it compiles, but gives errors at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 runtime! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 #include "gui_gtk_f.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 #include <gtk/gtksignal.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 #ifdef WIN3264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 # include <gdk/gdkwin32.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # include <gdk/gdkx.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 typedef struct _GtkFormChild GtkFormChild;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 struct _GtkFormChild
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 GdkWindow *window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 gint x; /* relative subwidget x position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 gint y; /* relative subwidget y position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 gint mapped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 static void gtk_form_class_init(GtkFormClass *klass);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 static void gtk_form_init(GtkForm *form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 static void gtk_form_realize(GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 static void gtk_form_unrealize(GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 static void gtk_form_map(GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 static void gtk_form_size_request(GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 GtkRequisition *requisition);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 static void gtk_form_size_allocate(GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 GtkAllocation *allocation);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 #ifndef HAVE_GTK2 /* this isn't needed in gtk2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 static void gtk_form_draw(GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 GdkRectangle *area);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 static gint gtk_form_expose(GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 GdkEventExpose *event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 static void gtk_form_remove(GtkContainer *container,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 GtkWidget *widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 static void gtk_form_forall(GtkContainer *container,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 gboolean include_internals,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 GtkCallback callback,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 gpointer callback_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 static void gtk_form_attach_child_window(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 GtkFormChild *child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 static void gtk_form_realize_child(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 GtkFormChild *child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 static void gtk_form_position_child(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 GtkFormChild *child,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 gboolean force_allocate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 static void gtk_form_position_children(GtkForm *form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 static GdkFilterReturn gtk_form_filter(GdkXEvent *gdk_xevent,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 GdkEvent *event,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 gpointer data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 static GdkFilterReturn gtk_form_main_filter(GdkXEvent *gdk_xevent,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 GdkEvent *event,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 gpointer data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 static void gtk_form_set_static_gravity(GdkWindow *window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 gboolean use_static);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 static void gtk_form_send_configure(GtkForm *form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 static void gtk_form_child_map(GtkWidget *widget, gpointer user_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 static void gtk_form_child_unmap(GtkWidget *widget, gpointer user_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 static GtkWidgetClass *parent_class = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 /* Public interface
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 GtkWidget *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 gtk_form_new(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 form = gtk_type_new(gtk_form_get_type());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 return GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 gtk_form_put(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 GtkWidget *child_widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 gint x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 gint y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
129
2983cde45542 updated for version 7.0044
vimboss
parents: 66
diff changeset
120 /* LINTED: avoid warning: conversion to 'unsigned long' */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 child = g_new(GtkFormChild, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 child->widget = child_widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 child->window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 child->x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 child->y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 child->widget->requisition.width = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 child->widget->requisition.height = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 form->children = g_list_append(form->children, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 /* child->window must be created and attached to the widget _before_
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 * it has been realized, or else things will break with GTK2. Note
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 * that gtk_widget_set_parent() realizes the widget if it's visible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 * and its parent is mapped.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 if (GTK_WIDGET_REALIZED(form))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 gtk_widget_set_parent(child_widget, GTK_WIDGET(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 gtk_widget_size_request(child->widget, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 if (GTK_WIDGET_REALIZED(form) && !GTK_WIDGET_REALIZED(child_widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 gtk_form_realize_child(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 gtk_form_move(GtkForm *form,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 GtkWidget *child_widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 gint x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 gint y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 if (child->widget == child_widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 child->x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 child->y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
2237
770485470e59 Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 1960
diff changeset
175 #if !defined(HAVE_GTK2) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 gtk_form_set_size(GtkForm *form, guint width, guint height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
2237
770485470e59 Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 1960
diff changeset
181 /* prevent useless calls */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 if (form->width == width && form->height == height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 form->width = width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 form->height = height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 /* signal the change */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 gtk_widget_queue_resize(gtk_widget_get_parent(GTK_WIDGET(form)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 gtk_container_queue_resize(GTK_CONTAINER(GTK_WIDGET(form)->parent));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 }
2237
770485470e59 Add a few #ifdefs to exclude functions that are not used. (Domnique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 1960
diff changeset
194 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 gtk_form_freeze(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 ++form->freeze_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 gtk_form_thaw(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 if (form->freeze_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 if (!(--form->freeze_count))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 gtk_form_position_children(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 gtk_widget_queue_draw(GTK_WIDGET(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 gtk_widget_draw(GTK_WIDGET(form), NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 /* Basic Object handling procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 GtkType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 gtk_form_get_type(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 static GtkType form_type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 if (!form_type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 {
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
232 GtkTypeInfo form_info;
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
233
1885
605f5c2f77ba updated for version 7.2-182
vimboss
parents: 1884
diff changeset
234 vim_memset(&form_info, 0, sizeof(form_info));
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
235 form_info.type_name = "GtkForm";
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
236 form_info.object_size = sizeof(GtkForm);
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
237 form_info.class_size = sizeof(GtkFormClass);
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
238 form_info.class_init_func = (GtkClassInitFunc)gtk_form_class_init;
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
239 form_info.object_init_func = (GtkObjectInitFunc)gtk_form_init;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 return form_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 gtk_form_class_init(GtkFormClass *klass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 GtkWidgetClass *widget_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 GtkContainerClass *container_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 widget_class = (GtkWidgetClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 container_class = (GtkContainerClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 parent_class = gtk_type_class(gtk_container_get_type());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 widget_class->realize = gtk_form_realize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 widget_class->unrealize = gtk_form_unrealize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 widget_class->map = gtk_form_map;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 widget_class->size_request = gtk_form_size_request;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 widget_class->size_allocate = gtk_form_size_allocate;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 #ifndef HAVE_GTK2 /* not needed for GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 widget_class->draw = gtk_form_draw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 widget_class->expose_event = gtk_form_expose;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 container_class->remove = gtk_form_remove;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 container_class->forall = gtk_form_forall;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 gtk_form_init(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 form->children = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 form->width = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 form->height = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 form->configure_serial = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 form->visibility = GDK_VISIBILITY_PARTIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 form->freeze_count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 * Widget methods
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 gtk_form_realize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 gint attributes_mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 GTK_WIDGET_SET_FLAGS(form, GTK_REALIZED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 attributes.window_type = GDK_WINDOW_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 attributes.x = widget->allocation.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 attributes.y = widget->allocation.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 attributes.width = widget->allocation.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 attributes.height = widget->allocation.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 attributes.visual = gtk_widget_get_visual(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 attributes.colormap = gtk_widget_get_colormap(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 gdk_window_set_user_data(widget->window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 attributes.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 attributes.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 attributes.event_mask = gtk_widget_get_events(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 form->bin_window = gdk_window_new(widget->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 gdk_window_set_user_data(form->bin_window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 gtk_form_set_static_gravity(form->bin_window, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 widget->style = gtk_style_attach(widget->style, widget->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 gtk_style_set_background(widget->style, form->bin_window, GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 gdk_window_add_filter(widget->window, gtk_form_main_filter, form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 gdk_window_add_filter(form->bin_window, gtk_form_filter, form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 if (GTK_WIDGET_VISIBLE(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 gtk_form_realize_child(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 /* After reading the documentation at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 * I think it should be possible to remove this function when compiling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 * against gtk-2.0. It doesn't seem to cause problems, though.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 * Well, I reckon at least the gdk_window_show(form->bin_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 * is necessary. GtkForm is anything but a usual container widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 gtk_form_map(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 gdk_window_show(widget->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 gdk_window_show(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 if (GTK_WIDGET_VISIBLE(child->widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 && !GTK_WIDGET_MAPPED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 gtk_form_unrealize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 gdk_window_set_user_data(form->bin_window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 gdk_window_destroy(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 if (child->window != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 GTK_SIGNAL_FUNC(gtk_form_child_map),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 GTK_SIGNAL_FUNC(gtk_form_child_unmap),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 child->window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 #ifndef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 gtk_form_draw(GtkWidget *widget, GdkRectangle *area)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 GList *children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 GdkRectangle child_area;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 if (GTK_WIDGET_DRAWABLE(widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 children = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 while (children)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 child = children->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 if (GTK_WIDGET_DRAWABLE(child->widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 && gtk_widget_intersect(child->widget, area, &child_area))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 gtk_widget_draw(child->widget, &child_area);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 children = children->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 #endif /* !HAVE_GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 gtk_form_size_request(GtkWidget *widget, GtkRequisition *requisition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 requisition->width = form->width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 requisition->height = form->height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 gtk_widget_size_request(child->widget, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 gboolean need_reposition;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 if (widget->allocation.x == allocation->x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 && widget->allocation.y == allocation->y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 && widget->allocation.width == allocation->width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 && widget->allocation.height == allocation->height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 need_reposition = widget->allocation.width != allocation->width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 || widget->allocation.height != allocation->height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 if (GTK_WIDGET_REALIZED(widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 gdk_window_move_resize(widget->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 allocation->x, allocation->y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 allocation->width, allocation->height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 gdk_window_move_resize(GTK_FORM(widget)->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 allocation->width, allocation->height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 widget->allocation = *allocation;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 gtk_form_send_configure(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 static gint
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 if (event->window == form->bin_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 GtkFormChild *formchild = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 GtkWidget *child = formchild->widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 * The following chunk of code is taken from gtkcontainer.c. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 * gtk1.x code synthesized expose events directly on the child widgets,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 * which can't be done in gtk2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 if (GTK_WIDGET_DRAWABLE(child) && GTK_WIDGET_NO_WINDOW(child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 && child->window == event->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 GdkEventExpose child_event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 child_event = *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 child_event.region = gtk_widget_region_intersect(child, event->region);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 if (!gdk_region_empty(child_event.region))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 gdk_region_get_clipbox(child_event.region, &child_event.area);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 gtk_widget_send_expose(child, (GdkEvent *)&child_event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 #else /* !HAVE_GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 if (event->window == child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 return gtk_widget_event(child->widget, (GdkEvent *) event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 #endif /* !HAVE_GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 /* Container method
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 gtk_form_remove(GtkContainer *container, GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 GtkFormChild *child = NULL; /* init for gcc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 if (child->widget == widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 if (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 GTK_SIGNAL_FUNC(&gtk_form_child_unmap), child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 /* FIXME: This will cause problems for reparenting NO_WINDOW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 * widgets out of a GtkForm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 gtk_widget_unparent(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 form->children = g_list_remove_link(form->children, tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 g_list_free_1(tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 g_free(child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 gtk_form_forall(GtkContainer *container,
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
618 gboolean include_internals UNUSED,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 GtkCallback callback,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 gpointer callback_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 g_return_if_fail(callback != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 (*callback) (child->widget, callback_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 /* Operations on children
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 if (child->window != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 return; /* been there, done that */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 if (GTK_WIDGET_NO_WINDOW(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 gint attributes_mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 attributes.window_type = GDK_WINDOW_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 attributes.x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 attributes.y = child->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 attributes.width = child->widget->requisition.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 attributes.height = child->widget->requisition.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 attributes.visual = gtk_widget_get_visual(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 attributes.colormap = gtk_widget_get_colormap(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 attributes.event_mask = GDK_EXPOSURE_MASK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 child->window = gdk_window_new(form->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 gdk_window_set_user_data(child->window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 gtk_style_set_background(widget->style,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 child->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 gtk_widget_set_parent_window(child->widget, child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 gtk_form_set_static_gravity(child->window, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 * Install signal handlers to map/unmap child->window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 * alongside with the actual widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 gtk_signal_connect(GTK_OBJECT(child->widget), "map",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 gtk_signal_connect(GTK_OBJECT(child->widget), "unmap",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 GTK_SIGNAL_FUNC(&gtk_form_child_unmap), child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 else if (!GTK_WIDGET_REALIZED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 gtk_widget_set_parent_window(child->widget, form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 gtk_form_realize_child(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 gtk_widget_realize(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 if (child->window == NULL) /* might be already set, see above */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 gtk_form_set_static_gravity(child->widget->window, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 gtk_form_position_child(GtkForm *form, GtkFormChild *child,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 gboolean force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 gint x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 gint y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 y = child->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 (y >= G_MINSHORT) && (y <= G_MAXSHORT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 if (!child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 if (GTK_WIDGET_MAPPED(form) && GTK_WIDGET_VISIBLE(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 if (!GTK_WIDGET_MAPPED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 force_allocate = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 if (force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 GtkAllocation allocation;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 if (GTK_WIDGET_NO_WINDOW(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 gdk_window_move_resize(child->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 x, y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 child->widget->requisition.width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 child->widget->requisition.height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 allocation.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 allocation.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 allocation.x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 allocation.y = y;
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 allocation.width = child->widget->requisition.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 allocation.height = child->widget->requisition.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 gtk_widget_size_allocate(child->widget, &allocation);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 if (child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 if (GTK_WIDGET_MAPPED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 gtk_widget_unmap(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 gtk_form_position_children(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 gtk_form_position_child(form, tmp_list->data, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 /* Callbacks */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 /* The main event filter. Actually, we probably don't really need
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 * to install this as a filter at all, since we are calling it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 * directly above in the expose-handling hack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 * This routine identifies expose events that are generated when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 * we've temporarily moved the bin_window_origin, and translates
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 * them or discards them, depending on whether we are obscured
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 * or not.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 static GdkFilterReturn
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
791 gtk_form_filter(GdkXEvent *gdk_xevent, GdkEvent *event UNUSED, gpointer data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 XEvent *xevent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 xevent = (XEvent *) gdk_xevent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 form = GTK_FORM(data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 switch (xevent->type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 case Expose:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 if (xevent->xexpose.serial == form->configure_serial)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 if (form->visibility == GDK_VISIBILITY_UNOBSCURED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 return GDK_FILTER_REMOVE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 case ConfigureNotify:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 if ((xevent->xconfigure.x != 0) || (xevent->xconfigure.y != 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 form->configure_serial = xevent->xconfigure.serial;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 return GDK_FILTER_CONTINUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 /* Although GDK does have a GDK_VISIBILITY_NOTIFY event,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 * there is no corresponding event in GTK, so we have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 * to get the events from a filter
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 static GdkFilterReturn
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
825 gtk_form_main_filter(GdkXEvent *gdk_xevent,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
826 GdkEvent *event UNUSED,
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
827 gpointer data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 XEvent *xevent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 xevent = (XEvent *) gdk_xevent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 form = GTK_FORM(data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 if (xevent->type == VisibilityNotify)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 switch (xevent->xvisibility.state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 case VisibilityFullyObscured:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 form->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 case VisibilityPartiallyObscured:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 form->visibility = GDK_VISIBILITY_PARTIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 case VisibilityUnobscured:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 form->visibility = GDK_VISIBILITY_UNOBSCURED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 return GDK_FILTER_REMOVE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 return GDK_FILTER_CONTINUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 /* Routines to set the window gravity, and check whether it is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 * functional. Extra capabilities need to be added to GDK, so
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 * we don't have to use Xlib here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 gtk_form_set_static_gravity(GdkWindow *window, gboolean use_static)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 #ifdef HAVE_GTK2
1960
3c838658fc35 updated for version 7.2-257
vimboss
parents: 1885
diff changeset
865 /* We don't check if static gravity is actually supported, because it
3c838658fc35 updated for version 7.2-257
vimboss
parents: 1885
diff changeset
866 * results in an annoying assertion error message. */
3c838658fc35 updated for version 7.2-257
vimboss
parents: 1885
diff changeset
867 gdk_window_set_static_gravities(window, use_static);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 XSetWindowAttributes xattributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 xattributes.win_gravity = (use_static) ? StaticGravity : NorthWestGravity;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 xattributes.bit_gravity = (use_static) ? StaticGravity : NorthWestGravity;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 XChangeWindowAttributes(GDK_WINDOW_XDISPLAY(window),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 GDK_WINDOW_XWINDOW(window),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 CWBitGravity | CWWinGravity,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 &xattributes);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 gtk_form_move_resize(GtkForm *form, GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 gint x, gint y, gint w, gint h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 widget->requisition.width = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 widget->requisition.height = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 gtk_form_move(form, widget, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 gtk_form_send_configure(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 GdkEventConfigure event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 event.type = GDK_CONFIGURE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 event.window = widget->window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 event.x = widget->allocation.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 event.y = widget->allocation.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 event.width = widget->allocation.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 event.height = widget->allocation.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 gtk_main_do_event((GdkEvent*)&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 gtk_widget_event(widget, (GdkEvent*)&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
914 gtk_form_child_map(GtkWidget *widget UNUSED, gpointer user_data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 gdk_window_show(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 static void
1884
3dd986bfef63 updated for version 7.2-181
vimboss
parents: 1207
diff changeset
925 gtk_form_child_unmap(GtkWidget *widget UNUSED, gpointer user_data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 gdk_window_hide(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934