chiark / gitweb /
Added dependency to the gtk system and a couple of bug fixes
[clg] / gtk / alien / glue.c
CommitLineData
3350ea74 1/* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2002 Espen S. Johnsen <espen@users.sourceforge.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
f6fc1365 19/* $Id: glue.c,v 1.7 2005-01-06 21:54:19 espen Exp $ */
3350ea74 20
21
22#include <gtk/gtk.h>
23
24
25/*
26 *
27 * Gtk helper functions
28 *
29 */
30
31void
32gtk_query_version (guint *major, guint *minor, guint *micro)
33{
34 *major = gtk_major_version;
35 *minor = gtk_minor_version;
36 *micro = gtk_micro_version;
37}
38
39
3350ea74 40/* Widget */
41
42GdkWindow*
43gtk_widget_get_window (GtkWidget *widget)
44{
45 return widget->window;
46}
47
48GtkStateType
49gtk_widget_get_state (GtkWidget *widget)
50{
51 return widget->state;
52}
53
54gboolean
55gtk_widget_mapped_p (GtkWidget *widget)
56{
57 return GTK_WIDGET_MAPPED (widget);
58}
59
60void
61gtk_widget_get_size_allocation (GtkWidget *widget, int *width, int *height)
62{
63 *width = widget->allocation.width;
64 *height = widget->allocation.height;
65}
66
67
68/* Container */
69
70GtkWidget*
71gtk_container_get_focus_child (GtkContainer *container)
72{
73 return container->focus_child;
74}
75
d76e9fca 76gboolean
77gtk_container_get_reallocate_redraws (GtkContainer *container)
78{
79 return container->reallocate_redraws;
80}
81
3350ea74 82
83/* Dialog */
84
85GtkWidget*
86gtk_dialog_get_vbox (GtkDialog *dialog)
87{
88 return dialog->vbox;
89}
90
91GtkWidget*
92gtk_dialog_get_action_area (GtkDialog *dialog)
93{
94 return dialog->action_area;
95}
96
97
98
3350ea74 99/* Window */
100
101GtkWidget*
102gtk_window_get_default (GtkWindow *window)
103{
104 return window->default_widget;
105}
106
4d16221f 107GtkWindowGroup*
108gtk_window_get_group (GtkWindow *window)
109{
110 return window->group;
111}
112
113
3350ea74 114
f6fc1365 115/* Menu */
3350ea74 116
d76e9fca 117GdkScreen*
118gtk_menu_get_screen (GtkMenu *menu)
3350ea74 119{
d76e9fca 120 return (GdkScreen*)g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen");
3350ea74 121}
122
123
3350ea74 124
f6fc1365 125/* Toolbar */
126
127GtkTooltips*
128gtk_toolbar_get_tooltips_object (GtkToolbar *toolbar)
129{
130 return toolbar->tooltips;
131}
132
133
134
135/* Tooltips */
136
137gint
138gtk_tooltips_get_enabled (GtkTooltips *tooltips)
139{
140 return tooltips->enabled;
141}
142
143
d76e9fca 144/* Layout */
3350ea74 145
d76e9fca 146GdkWindow*
147gtk_layout_get_bin_window (GtkLayout *layout)
148{
149 return layout->bin_window;
3350ea74 150}
151
152
3350ea74 153/* GtkStyle accessor functions */
154
155typedef enum {
156 GTK_COLOR_FG,
157 GTK_COLOR_BG,
158 GTK_COLOR_LIGHT,
159 GTK_COLOR_DARK,
160 GTK_COLOR_MID,
161 GTK_COLOR_TEXT,
162 GTK_COLOR_BASE,
ec0dd9ca 163 GTK_COLOR_TEXT_AA,
3350ea74 164 GTK_COLOR_WHITE,
165 GTK_COLOR_BLACK
166} GtkColorType;
167
168GdkColor*
169gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
170 GtkStateType state)
171{
172 switch (color_type)
173 {
174 case GTK_COLOR_WHITE:
175 return &style->white;
176 case GTK_COLOR_BLACK:
177 return &style->black;
178 case GTK_COLOR_FG:
179 return &style->fg[state];
180 case GTK_COLOR_BG:
181 return &style->bg[state];
182 case GTK_COLOR_LIGHT:
183 return &style->light[state];
184 case GTK_COLOR_DARK:
185 return &style->dark[state];
186 case GTK_COLOR_MID:
187 return &style->mid[state];
188 case GTK_COLOR_TEXT:
189 return &style->text[state];
190 case GTK_COLOR_BASE:
191 return &style->base[state];
ec0dd9ca 192 case GTK_COLOR_TEXT_AA:
193 return &style->text_aa[state];
3350ea74 194 }
195}
196
197
ec0dd9ca 198void
3350ea74 199gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
200 GtkStateType state, GdkColor *color)
201{
202 switch (color_type)
203 {
204 case GTK_COLOR_WHITE:
205 style->white = *color; break;
206 case GTK_COLOR_BLACK:
207 style->black = *color; break;
208 case GTK_COLOR_FG:
209 style->fg[state] = *color; break;
210 case GTK_COLOR_BG:
211 style->bg[state] = *color; break;
212 case GTK_COLOR_LIGHT:
213 style->light[state] = *color; break;
214 case GTK_COLOR_DARK:
215 style->dark[state] = *color; break;
216 case GTK_COLOR_MID:
217 style->mid[state] = *color; break;
218 case GTK_COLOR_TEXT:
219 style->text[state] = *color; break;
220 case GTK_COLOR_BASE:
221 style->base[state] = *color; break;
ec0dd9ca 222 case GTK_COLOR_TEXT_AA:
223 style->text_aa[state] = *color; break;
3350ea74 224 }
3350ea74 225}
226
3350ea74 227
228GdkGC*
229gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
230{
231 switch (color_type)
232 {
233 case GTK_COLOR_WHITE:
234 return style->white_gc;
235 case GTK_COLOR_BLACK:
236 return style->black_gc;
237 case GTK_COLOR_FG:
238 return style->fg_gc[state];
239 case GTK_COLOR_BG:
240 return style->bg_gc[state];
241 case GTK_COLOR_LIGHT:
242 return style->light_gc[state];
243 case GTK_COLOR_DARK:
244 return style->dark_gc[state];
245 case GTK_COLOR_MID:
246 return style->mid_gc[state];
247 case GTK_COLOR_TEXT:
248 return style->text_gc[state];
249 case GTK_COLOR_BASE:
250 return style->base_gc[state];
ec0dd9ca 251 case GTK_COLOR_TEXT_AA:
252 return style->text_aa_gc[state];
3350ea74 253 }
254}
ec0dd9ca 255
256int
257gtk_style_font_desc_offset ()
258{
259 GtkStyle style;
260
261 return (int)&style.font_desc - (int)&style;
262}
263