annotate src/gui_gtk_f.c @ 1593:2430fc9a18d1 v7.1.306

updated for version 7.1-306
author vimboss
date Wed, 04 Jun 2008 09:00:32 +0000
parents beed57a8fcd1
children 3dd986bfef63
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 gtk_form_set_size(GtkForm *form, guint width, guint height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 /* prevent unneccessary calls */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 if (form->width == width && form->height == height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 form->width = width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 form->height = height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 /* signal the change */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 gtk_widget_queue_resize(gtk_widget_get_parent(GTK_WIDGET(form)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 gtk_container_queue_resize(GTK_CONTAINER(GTK_WIDGET(form)->parent));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 gtk_form_freeze(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 ++form->freeze_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 gtk_form_thaw(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 g_return_if_fail(GTK_IS_FORM(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 if (form->freeze_count)
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 gtk_form_position_children(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 gtk_widget_queue_draw(GTK_WIDGET(form));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 gtk_widget_draw(GTK_WIDGET(form), NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 }
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 /* Basic Object handling procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 GtkType
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 gtk_form_get_type(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 static GtkType form_type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 if (!form_type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 GtkTypeInfo form_info =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 "GtkForm",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 sizeof(GtkForm),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 sizeof(GtkFormClass),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 (GtkClassInitFunc) gtk_form_class_init,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 (GtkObjectInitFunc) gtk_form_init
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 return form_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 gtk_form_class_init(GtkFormClass *klass)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 GtkWidgetClass *widget_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 GtkContainerClass *container_class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 widget_class = (GtkWidgetClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 container_class = (GtkContainerClass *) klass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 parent_class = gtk_type_class(gtk_container_get_type());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 widget_class->realize = gtk_form_realize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 widget_class->unrealize = gtk_form_unrealize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 widget_class->map = gtk_form_map;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 widget_class->size_request = gtk_form_size_request;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 widget_class->size_allocate = gtk_form_size_allocate;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 #ifndef HAVE_GTK2 /* not needed for GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 widget_class->draw = gtk_form_draw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 widget_class->expose_event = gtk_form_expose;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 container_class->remove = gtk_form_remove;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 container_class->forall = gtk_form_forall;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 gtk_form_init(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 form->children = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 form->width = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 form->height = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 form->configure_serial = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 form->visibility = GDK_VISIBILITY_PARTIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 form->freeze_count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 * Widget methods
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 gtk_form_realize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 gint attributes_mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 GTK_WIDGET_SET_FLAGS(form, GTK_REALIZED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 attributes.window_type = GDK_WINDOW_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 attributes.x = widget->allocation.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 attributes.y = widget->allocation.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 attributes.width = widget->allocation.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 attributes.height = widget->allocation.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 attributes.visual = gtk_widget_get_visual(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 attributes.colormap = gtk_widget_get_colormap(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 gdk_window_set_user_data(widget->window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 attributes.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 attributes.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 attributes.event_mask = gtk_widget_get_events(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 form->bin_window = gdk_window_new(widget->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 gdk_window_set_user_data(form->bin_window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 gtk_form_set_static_gravity(form->bin_window, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 widget->style = gtk_style_attach(widget->style, widget->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 gtk_style_set_background(widget->style, form->bin_window, GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 gdk_window_add_filter(widget->window, gtk_form_main_filter, form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 gdk_window_add_filter(form->bin_window, gtk_form_filter, form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 if (GTK_WIDGET_VISIBLE(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 gtk_form_realize_child(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 }
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 /* After reading the documentation at
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 * I think it should be possible to remove this function when compiling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 * against gtk-2.0. It doesn't seem to cause problems, though.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 * Well, I reckon at least the gdk_window_show(form->bin_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 * is necessary. GtkForm is anything but a usual container widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 gtk_form_map(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 gdk_window_show(widget->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 gdk_window_show(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 if (GTK_WIDGET_VISIBLE(child->widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 && !GTK_WIDGET_MAPPED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 gtk_form_unrealize(GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 gdk_window_set_user_data(form->bin_window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 gdk_window_destroy(form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 form->bin_window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 if (child->window != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 GTK_SIGNAL_FUNC(gtk_form_child_map),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 GTK_SIGNAL_FUNC(gtk_form_child_unmap),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 child->window = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 #ifndef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 gtk_form_draw(GtkWidget *widget, GdkRectangle *area)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 GList *children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 GdkRectangle child_area;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 if (GTK_WIDGET_DRAWABLE(widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 children = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 while (children)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 child = children->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 if (GTK_WIDGET_DRAWABLE(child->widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 && gtk_widget_intersect(child->widget, area, &child_area))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 gtk_widget_draw(child->widget, &child_area);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 children = children->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 #endif /* !HAVE_GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 gtk_form_size_request(GtkWidget *widget, GtkRequisition *requisition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 requisition->width = form->width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 requisition->height = form->height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 gtk_widget_size_request(child->widget, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 gboolean need_reposition;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 g_return_if_fail(GTK_IS_FORM(widget));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 if (widget->allocation.x == allocation->x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 && widget->allocation.y == allocation->y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 && widget->allocation.width == allocation->width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 && widget->allocation.height == allocation->height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 need_reposition = widget->allocation.width != allocation->width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 || widget->allocation.height != allocation->height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 gtk_form_position_child(form, child, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 if (GTK_WIDGET_REALIZED(widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 gdk_window_move_resize(widget->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 allocation->x, allocation->y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 allocation->width, allocation->height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 gdk_window_move_resize(GTK_FORM(widget)->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 allocation->width, allocation->height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 widget->allocation = *allocation;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 if (need_reposition)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 gtk_form_send_configure(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 static gint
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 g_return_val_if_fail(GTK_IS_FORM(widget), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 form = GTK_FORM(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 if (event->window == form->bin_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 GtkFormChild *formchild = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 GtkWidget *child = formchild->widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 * The following chunk of code is taken from gtkcontainer.c. The
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 * gtk1.x code synthesized expose events directly on the child widgets,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 * which can't be done in gtk2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 if (GTK_WIDGET_DRAWABLE(child) && GTK_WIDGET_NO_WINDOW(child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 && child->window == event->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 GdkEventExpose child_event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 child_event = *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 child_event.region = gtk_widget_region_intersect(child, event->region);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 if (!gdk_region_empty(child_event.region))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 gdk_region_get_clipbox(child_event.region, &child_event.area);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 gtk_widget_send_expose(child, (GdkEvent *)&child_event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 #else /* !HAVE_GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 GtkFormChild *child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 if (event->window == child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 return gtk_widget_event(child->widget, (GdkEvent *) event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 #endif /* !HAVE_GTK2 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 /* Container method
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 gtk_form_remove(GtkContainer *container, GtkWidget *widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 GtkFormChild *child = NULL; /* init for gcc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 if (child->widget == widget)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 if (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
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_unmap), child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 /* FIXME: This will cause problems for reparenting NO_WINDOW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 * widgets out of a GtkForm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 gdk_window_set_user_data(child->window, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 gdk_window_destroy(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 gtk_widget_unparent(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 form->children = g_list_remove_link(form->children, tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 g_list_free_1(tmp_list);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 g_free(child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 /*ARGSUSED1*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 gtk_form_forall(GtkContainer *container,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 gboolean include_internals,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 GtkCallback callback,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 gpointer callback_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 g_return_if_fail(GTK_IS_FORM(container));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 g_return_if_fail(callback != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 form = GTK_FORM(container);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 tmp_list = form->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 while (tmp_list)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 child = tmp_list->data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 tmp_list = tmp_list->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 (*callback) (child->widget, callback_data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 }
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 /* Operations on children
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 if (child->window != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 return; /* been there, done that */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 if (GTK_WIDGET_NO_WINDOW(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 GdkWindowAttr attributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 gint attributes_mask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 attributes.window_type = GDK_WINDOW_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 attributes.x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 attributes.y = child->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 attributes.width = child->widget->requisition.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 attributes.height = child->widget->requisition.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 attributes.wclass = GDK_INPUT_OUTPUT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 attributes.visual = gtk_widget_get_visual(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 attributes.colormap = gtk_widget_get_colormap(widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 attributes.event_mask = GDK_EXPOSURE_MASK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 child->window = gdk_window_new(form->bin_window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 &attributes, attributes_mask);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 gdk_window_set_user_data(child->window, widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 gtk_style_set_background(widget->style,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 child->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 GTK_STATE_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 gtk_widget_set_parent_window(child->widget, child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 gtk_form_set_static_gravity(child->window, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 * Install signal handlers to map/unmap child->window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 * alongside with the actual widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 gtk_signal_connect(GTK_OBJECT(child->widget), "map",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 gtk_signal_connect(GTK_OBJECT(child->widget), "unmap",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 GTK_SIGNAL_FUNC(&gtk_form_child_unmap), child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 else if (!GTK_WIDGET_REALIZED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 gtk_widget_set_parent_window(child->widget, form->bin_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 }
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 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 gtk_form_realize_child(GtkForm *form, GtkFormChild *child)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 gtk_form_attach_child_window(form, child);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 gtk_widget_realize(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 if (child->window == NULL) /* might be already set, see above */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 gtk_form_set_static_gravity(child->widget->window, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 gtk_form_position_child(GtkForm *form, GtkFormChild *child,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 gboolean force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 gint x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 gint y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 x = child->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 y = child->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 (y >= G_MINSHORT) && (y <= G_MAXSHORT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 if (!child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 if (GTK_WIDGET_MAPPED(form) && GTK_WIDGET_VISIBLE(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 if (!GTK_WIDGET_MAPPED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 gtk_widget_map(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 force_allocate = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 }
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 if (force_allocate)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 GtkAllocation allocation;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 if (GTK_WIDGET_NO_WINDOW(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 if (child->window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 gdk_window_move_resize(child->window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 x, y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 child->widget->requisition.width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 child->widget->requisition.height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 allocation.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 allocation.y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 allocation.x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 allocation.y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 allocation.width = child->widget->requisition.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 allocation.height = child->widget->requisition.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 gtk_widget_size_allocate(child->widget, &allocation);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 if (child->mapped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 if (GTK_WIDGET_MAPPED(child->widget))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 gtk_widget_unmap(child->widget);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 }
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 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 gtk_form_position_children(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 GList *tmp_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 gtk_form_position_child(form, tmp_list->data, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 /* Callbacks */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 /* The main event filter. Actually, we probably don't really need
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 * to install this as a filter at all, since we are calling it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 * directly above in the expose-handling hack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 * This routine identifies expose events that are generated when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 * we've temporarily moved the bin_window_origin, and translates
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 * them or discards them, depending on whether we are obscured
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 * or not.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 /*ARGSUSED1*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 static GdkFilterReturn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 gtk_form_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
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 /*ARGSUSED1*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 static GdkFilterReturn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 gtk_form_main_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 XEvent *xevent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 GtkForm *form;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 xevent = (XEvent *) gdk_xevent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 form = GTK_FORM(data);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 if (xevent->type == VisibilityNotify)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 switch (xevent->xvisibility.state)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 case VisibilityFullyObscured:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 form->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 case VisibilityPartiallyObscured:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 form->visibility = GDK_VISIBILITY_PARTIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 case VisibilityUnobscured:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 form->visibility = GDK_VISIBILITY_UNOBSCURED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 return GDK_FILTER_REMOVE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 return GDK_FILTER_CONTINUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 /* Routines to set the window gravity, and check whether it is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 * functional. Extra capabilities need to be added to GDK, so
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 * we don't have to use Xlib here.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 gtk_form_set_static_gravity(GdkWindow *window, gboolean use_static)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 gboolean static_gravity_supported;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 static_gravity_supported = gdk_window_set_static_gravities(window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 use_static);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 g_return_if_fail(static_gravity_supported);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 XSetWindowAttributes xattributes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 xattributes.win_gravity = (use_static) ? StaticGravity : NorthWestGravity;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 xattributes.bit_gravity = (use_static) ? StaticGravity : NorthWestGravity;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 XChangeWindowAttributes(GDK_WINDOW_XDISPLAY(window),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 GDK_WINDOW_XWINDOW(window),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 CWBitGravity | CWWinGravity,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 &xattributes);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 gtk_form_move_resize(GtkForm *form, GtkWidget *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 gint x, gint y, gint w, gint h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 widget->requisition.width = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 widget->requisition.height = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 gtk_form_move(form, widget, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 gtk_form_send_configure(GtkForm *form)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 GtkWidget *widget;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 GdkEventConfigure event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 widget = GTK_WIDGET(form);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 event.type = GDK_CONFIGURE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 event.window = widget->window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 event.x = widget->allocation.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 event.y = widget->allocation.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 event.width = widget->allocation.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 event.height = widget->allocation.height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 #ifdef HAVE_GTK2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 gtk_main_do_event((GdkEvent*)&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 gtk_widget_event(widget, (GdkEvent*)&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 /*ARGSUSED0*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 gtk_form_child_map(GtkWidget *widget, gpointer user_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 child->mapped = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 gdk_window_show(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 /*ARGSUSED0*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 gtk_form_child_unmap(GtkWidget *widget, gpointer user_data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 GtkFormChild *child;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 child = (GtkFormChild *)user_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 child->mapped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 gdk_window_hide(child->window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937