4641cb32 |
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 | |
831668e8 |
19 | /* $Id: glue.c,v 1.2 2004/11/01 00:08:50 espen Exp $ */ |
4641cb32 |
20 | |
21 | |
22 | #include <gtk/gtk.h> |
23 | |
24 | |
25 | /* |
26 | * |
27 | * Gtk helper functions |
28 | * |
29 | */ |
30 | |
31 | void |
32 | gtk_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 | |
4641cb32 |
40 | /* Widget */ |
41 | |
42 | GdkWindow* |
43 | gtk_widget_get_window (GtkWidget *widget) |
44 | { |
45 | return widget->window; |
46 | } |
47 | |
48 | GtkStateType |
49 | gtk_widget_get_state (GtkWidget *widget) |
50 | { |
51 | return widget->state; |
52 | } |
53 | |
54 | gboolean |
55 | gtk_widget_mapped_p (GtkWidget *widget) |
56 | { |
57 | return GTK_WIDGET_MAPPED (widget); |
58 | } |
59 | |
60 | void |
61 | gtk_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 | |
70 | GtkWidget* |
71 | gtk_container_get_focus_child (GtkContainer *container) |
72 | { |
73 | return container->focus_child; |
74 | } |
75 | |
76 | |
77 | /* Dialog */ |
78 | |
79 | GtkWidget* |
80 | gtk_dialog_get_vbox (GtkDialog *dialog) |
81 | { |
82 | return dialog->vbox; |
83 | } |
84 | |
85 | GtkWidget* |
86 | gtk_dialog_get_action_area (GtkDialog *dialog) |
87 | { |
88 | return dialog->action_area; |
89 | } |
90 | |
91 | |
92 | |
93 | /* Check menu item */ |
94 | |
95 | gboolean |
96 | gtk_check_menu_item_get_active (GtkCheckMenuItem* check_menu_item) |
97 | { |
98 | return check_menu_item->active; |
99 | } |
100 | |
101 | gboolean |
102 | gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem* check_menu_item) |
103 | { |
104 | return check_menu_item->always_show_toggle; |
105 | } |
106 | |
107 | |
108 | |
109 | /* Window */ |
110 | |
111 | GtkWidget* |
112 | gtk_window_get_default (GtkWindow *window) |
113 | { |
114 | return window->default_widget; |
115 | } |
116 | |
117 | |
118 | /* File selection */ |
119 | |
120 | GtkWidget* |
121 | gtk_file_selection_get_action_area (GtkFileSelection *filesel) |
122 | { |
123 | return filesel->action_area; |
124 | } |
125 | |
126 | GtkWidget* |
127 | gtk_file_selection_get_ok_button (GtkFileSelection *filesel) |
128 | { |
129 | return filesel->ok_button; |
130 | } |
131 | |
132 | GtkWidget* |
133 | gtk_file_selection_get_cancel_button (GtkFileSelection *filesel) |
134 | { |
135 | return filesel->cancel_button; |
136 | } |
137 | |
138 | |
139 | /* Color selection */ |
140 | |
141 | gtk_color_selection_set_color_by_values (GtkColorSelection *colorsel, |
142 | gdouble red, |
143 | gdouble green, |
144 | gdouble blue, |
145 | gdouble opacity) |
146 | { |
147 | gdouble color[4]; |
148 | |
149 | color[0] = red; |
150 | color[1] = green; |
151 | color[2] = blue; |
152 | color[3] = opacity; |
153 | |
154 | gtk_color_selection_set_color (colorsel, color); |
155 | } |
156 | |
157 | void |
158 | gtk_color_selection_get_color_as_values (GtkColorSelection *colorsel, |
159 | gdouble *red, |
160 | gdouble *green, |
161 | gdouble *blue, |
162 | gdouble *opacity) |
163 | { |
164 | gdouble color[4]; |
165 | |
166 | gtk_color_selection_get_color (colorsel, color); |
167 | |
168 | *red = color[0]; |
169 | *green = color[1]; |
170 | *blue = color[2]; |
171 | *opacity = color[3]; |
172 | } |
173 | |
174 | |
175 | /* Combo */ |
176 | |
177 | GtkWidget* |
178 | gtk_combo_get_entry (GtkCombo *combo) |
179 | { |
180 | return combo->entry; |
181 | } |
182 | |
183 | gboolean |
184 | gtk_combo_get_use_arrows (GtkCombo *combo) |
185 | { |
186 | return combo->use_arrows; |
187 | } |
188 | |
189 | gboolean |
190 | gtk_combo_get_use_arrows_always (GtkCombo *combo) |
191 | { |
192 | return combo->use_arrows_always; |
193 | } |
194 | |
195 | gboolean |
196 | gtk_combo_get_case_sensitive (GtkCombo *combo) |
197 | { |
198 | return combo->case_sensitive; |
199 | } |
200 | |
201 | |
202 | /* Paned */ |
203 | |
204 | GtkWidget* |
205 | gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink) |
206 | { |
207 | *resize = paned->child1_resize; |
208 | *shrink = paned->child1_shrink; |
209 | |
210 | return paned->child1; |
211 | } |
212 | |
213 | |
214 | GtkWidget* |
215 | gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink) |
216 | { |
217 | *resize = paned->child2_resize; |
218 | *shrink = paned->child2_shrink; |
219 | |
220 | return paned->child2; |
221 | } |
222 | |
223 | |
224 | /* Layout */ |
225 | |
226 | GdkWindow* |
227 | gtk_layout_get_bin_window (GtkLayout *layout) |
228 | { |
229 | return layout->bin_window; |
230 | } |
231 | |
232 | |
233 | /* List */ |
234 | |
235 | GList* |
236 | gtk_list_selection (GtkList *list) |
237 | { |
238 | return list->selection; |
239 | } |
240 | |
241 | |
242 | |
243 | /* Toolbar */ |
244 | |
245 | gint |
246 | gtk_toolbar_get_tooltips (GtkToolbar *toolbar) |
247 | { |
248 | return toolbar->tooltips->enabled; |
249 | } |
250 | |
251 | |
252 | /* Drawing area */ |
253 | |
254 | void |
255 | gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height) |
256 | { |
257 | GtkWidget *widget; |
258 | |
259 | widget = GTK_WIDGET (darea); |
260 | *width = widget->allocation.width; |
261 | *height = widget->allocation.height; |
262 | } |
263 | |
264 | |
265 | /* Progress */ |
266 | |
267 | gchar* |
268 | gtk_progress_get_format_string (GtkProgress *progress) |
269 | { |
270 | return progress->format; |
271 | } |
272 | |
273 | GtkAdjustment* |
274 | gtk_progress_get_adjustment (GtkProgress *progress) |
275 | { |
276 | return progress->adjustment; |
277 | } |
278 | |
279 | |
280 | /* Tooltips */ |
281 | |
282 | gboolean |
283 | gtk_tooltips_get_enabled (GtkTooltips *tooltips) |
284 | { |
285 | return tooltips->enabled; |
286 | } |
287 | |
288 | |
289 | /* GtkStyle accessor functions */ |
290 | |
291 | typedef enum { |
292 | GTK_COLOR_FG, |
293 | GTK_COLOR_BG, |
294 | GTK_COLOR_LIGHT, |
295 | GTK_COLOR_DARK, |
296 | GTK_COLOR_MID, |
297 | GTK_COLOR_TEXT, |
298 | GTK_COLOR_BASE, |
299 | GTK_COLOR_WHITE, |
300 | GTK_COLOR_BLACK |
301 | } GtkColorType; |
302 | |
303 | GdkColor* |
304 | gtk_style_get_color (GtkStyle *style, GtkColorType color_type, |
305 | GtkStateType state) |
306 | { |
307 | switch (color_type) |
308 | { |
309 | case GTK_COLOR_WHITE: |
310 | return &style->white; |
311 | case GTK_COLOR_BLACK: |
312 | return &style->black; |
313 | case GTK_COLOR_FG: |
314 | return &style->fg[state]; |
315 | case GTK_COLOR_BG: |
316 | return &style->bg[state]; |
317 | case GTK_COLOR_LIGHT: |
318 | return &style->light[state]; |
319 | case GTK_COLOR_DARK: |
320 | return &style->dark[state]; |
321 | case GTK_COLOR_MID: |
322 | return &style->mid[state]; |
323 | case GTK_COLOR_TEXT: |
324 | return &style->text[state]; |
325 | case GTK_COLOR_BASE: |
326 | return &style->base[state]; |
327 | } |
328 | } |
329 | |
330 | |
331 | GdkColor* |
332 | gtk_style_set_color (GtkStyle *style, GtkColorType color_type, |
333 | GtkStateType state, GdkColor *color) |
334 | { |
335 | switch (color_type) |
336 | { |
337 | case GTK_COLOR_WHITE: |
338 | style->white = *color; break; |
339 | case GTK_COLOR_BLACK: |
340 | style->black = *color; break; |
341 | case GTK_COLOR_FG: |
342 | style->fg[state] = *color; break; |
343 | case GTK_COLOR_BG: |
344 | style->bg[state] = *color; break; |
345 | case GTK_COLOR_LIGHT: |
346 | style->light[state] = *color; break; |
347 | case GTK_COLOR_DARK: |
348 | style->dark[state] = *color; break; |
349 | case GTK_COLOR_MID: |
350 | style->mid[state] = *color; break; |
351 | case GTK_COLOR_TEXT: |
352 | style->text[state] = *color; break; |
353 | case GTK_COLOR_BASE: |
354 | style->base[state] = *color; break; |
355 | } |
356 | |
357 | return gtk_style_get_color (style, color_type, state); |
358 | } |
359 | |
360 | /* |
361 | GdkFont* |
362 | gtk_style_get_font (GtkStyle *style) |
363 | { |
364 | return style->font; |
365 | } |
366 | |
367 | |
368 | GdkFont* |
369 | gtk_style_set_font (GtkStyle *style, GdkFont *font) |
370 | { |
371 | return style->font = font; |
372 | } |
373 | */ |
374 | |
375 | GdkGC* |
376 | gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state) |
377 | { |
378 | switch (color_type) |
379 | { |
380 | case GTK_COLOR_WHITE: |
381 | return style->white_gc; |
382 | case GTK_COLOR_BLACK: |
383 | return style->black_gc; |
384 | case GTK_COLOR_FG: |
385 | return style->fg_gc[state]; |
386 | case GTK_COLOR_BG: |
387 | return style->bg_gc[state]; |
388 | case GTK_COLOR_LIGHT: |
389 | return style->light_gc[state]; |
390 | case GTK_COLOR_DARK: |
391 | return style->dark_gc[state]; |
392 | case GTK_COLOR_MID: |
393 | return style->mid_gc[state]; |
394 | case GTK_COLOR_TEXT: |
395 | return style->text_gc[state]; |
396 | case GTK_COLOR_BASE: |
397 | return style->base_gc[state]; |
398 | } |
399 | } |