chiark / gitweb /
Infra: Rudimentary setup system.
[clg] / gtk / alien / glue.c
CommitLineData
112ac1d3 1/* Common Lisp bindings for GTK+ v2.x
2 * Copyright 1999-2005 Espen S. Johnsen <espen@users.sf.net>
3350ea74 3 *
112ac1d3 4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
3350ea74 11 *
112ac1d3 12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
3350ea74 14 *
112ac1d3 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3350ea74 22 */
23
7166a443 24/* $Id: glue.c,v 1.9 2007-09-06 14:27:07 espen Exp $ */
3350ea74 25
26
27#include <gtk/gtk.h>
28
29
30/*
31 *
32 * Gtk helper functions
33 *
34 */
35
36void
37gtk_query_version (guint *major, guint *minor, guint *micro)
38{
39 *major = gtk_major_version;
40 *minor = gtk_minor_version;
41 *micro = gtk_micro_version;
42}
43
44
3350ea74 45/* Widget */
46
47GdkWindow*
48gtk_widget_get_window (GtkWidget *widget)
49{
50 return widget->window;
51}
52
53GtkStateType
54gtk_widget_get_state (GtkWidget *widget)
55{
56 return widget->state;
57}
58
7166a443 59gint32
60gtk_widget_flags (GtkWidget *widget)
3350ea74 61{
7166a443 62 return GTK_WIDGET_FLAGS (widget);
3350ea74 63}
64
7166a443 65
3350ea74 66void
67gtk_widget_get_size_allocation (GtkWidget *widget, int *width, int *height)
68{
69 *width = widget->allocation.width;
70 *height = widget->allocation.height;
71}
72
73
74/* Container */
75
76GtkWidget*
77gtk_container_get_focus_child (GtkContainer *container)
78{
79 return container->focus_child;
80}
81
d76e9fca 82gboolean
83gtk_container_get_reallocate_redraws (GtkContainer *container)
84{
85 return container->reallocate_redraws;
86}
87
3350ea74 88
89/* Dialog */
90
91GtkWidget*
92gtk_dialog_get_vbox (GtkDialog *dialog)
93{
94 return dialog->vbox;
95}
96
97GtkWidget*
98gtk_dialog_get_action_area (GtkDialog *dialog)
99{
100 return dialog->action_area;
101}
102
103
104
3350ea74 105/* Window */
106
107GtkWidget*
108gtk_window_get_default (GtkWindow *window)
109{
110 return window->default_widget;
111}
112
4d16221f 113GtkWindowGroup*
114gtk_window_get_group (GtkWindow *window)
115{
116 return window->group;
117}
118
119
3350ea74 120
f6fc1365 121/* Menu */
3350ea74 122
d76e9fca 123GdkScreen*
124gtk_menu_get_screen (GtkMenu *menu)
3350ea74 125{
d76e9fca 126 return (GdkScreen*)g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen");
3350ea74 127}
128
129
3350ea74 130
f6fc1365 131/* Toolbar */
132
133GtkTooltips*
134gtk_toolbar_get_tooltips_object (GtkToolbar *toolbar)
135{
136 return toolbar->tooltips;
137}
138
139
140
141/* Tooltips */
142
143gint
144gtk_tooltips_get_enabled (GtkTooltips *tooltips)
145{
146 return tooltips->enabled;
147}
148
149
d76e9fca 150/* Layout */
3350ea74 151
d76e9fca 152GdkWindow*
153gtk_layout_get_bin_window (GtkLayout *layout)
154{
155 return layout->bin_window;
3350ea74 156}
157
158
3350ea74 159/* GtkStyle accessor functions */
160
161typedef enum {
162 GTK_COLOR_FG,
163 GTK_COLOR_BG,
164 GTK_COLOR_LIGHT,
165 GTK_COLOR_DARK,
166 GTK_COLOR_MID,
167 GTK_COLOR_TEXT,
168 GTK_COLOR_BASE,
ec0dd9ca 169 GTK_COLOR_TEXT_AA,
3350ea74 170 GTK_COLOR_WHITE,
171 GTK_COLOR_BLACK
172} GtkColorType;
173
174GdkColor*
175gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
176 GtkStateType state)
177{
178 switch (color_type)
179 {
180 case GTK_COLOR_WHITE:
181 return &style->white;
182 case GTK_COLOR_BLACK:
183 return &style->black;
184 case GTK_COLOR_FG:
185 return &style->fg[state];
186 case GTK_COLOR_BG:
187 return &style->bg[state];
188 case GTK_COLOR_LIGHT:
189 return &style->light[state];
190 case GTK_COLOR_DARK:
191 return &style->dark[state];
192 case GTK_COLOR_MID:
193 return &style->mid[state];
194 case GTK_COLOR_TEXT:
195 return &style->text[state];
196 case GTK_COLOR_BASE:
197 return &style->base[state];
ec0dd9ca 198 case GTK_COLOR_TEXT_AA:
199 return &style->text_aa[state];
3350ea74 200 }
201}
202
203
ec0dd9ca 204void
3350ea74 205gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
206 GtkStateType state, GdkColor *color)
207{
208 switch (color_type)
209 {
210 case GTK_COLOR_WHITE:
211 style->white = *color; break;
212 case GTK_COLOR_BLACK:
213 style->black = *color; break;
214 case GTK_COLOR_FG:
215 style->fg[state] = *color; break;
216 case GTK_COLOR_BG:
217 style->bg[state] = *color; break;
218 case GTK_COLOR_LIGHT:
219 style->light[state] = *color; break;
220 case GTK_COLOR_DARK:
221 style->dark[state] = *color; break;
222 case GTK_COLOR_MID:
223 style->mid[state] = *color; break;
224 case GTK_COLOR_TEXT:
225 style->text[state] = *color; break;
226 case GTK_COLOR_BASE:
227 style->base[state] = *color; break;
ec0dd9ca 228 case GTK_COLOR_TEXT_AA:
229 style->text_aa[state] = *color; break;
3350ea74 230 }
3350ea74 231}
232
3350ea74 233
234GdkGC*
235gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
236{
237 switch (color_type)
238 {
239 case GTK_COLOR_WHITE:
240 return style->white_gc;
241 case GTK_COLOR_BLACK:
242 return style->black_gc;
243 case GTK_COLOR_FG:
244 return style->fg_gc[state];
245 case GTK_COLOR_BG:
246 return style->bg_gc[state];
247 case GTK_COLOR_LIGHT:
248 return style->light_gc[state];
249 case GTK_COLOR_DARK:
250 return style->dark_gc[state];
251 case GTK_COLOR_MID:
252 return style->mid_gc[state];
253 case GTK_COLOR_TEXT:
254 return style->text_gc[state];
255 case GTK_COLOR_BASE:
256 return style->base_gc[state];
ec0dd9ca 257 case GTK_COLOR_TEXT_AA:
258 return style->text_aa_gc[state];
3350ea74 259 }
260}
ec0dd9ca 261
262int
263gtk_style_font_desc_offset ()
264{
265 GtkStyle style;
266
267 return (int)&style.font_desc - (int)&style;
268}
269