chiark / gitweb /
Updated for gtk-1.3.11
[clg] / gtk / gtkglue.c
CommitLineData
560af5c5 1/* Common Lisp bindings for GTK+ v2.0
c8c48a4c 2 * Copyright (C) 1999-2000 Espen S. Johnsen <esj@stud.cs.uit.no>
560af5c5 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
f784870f 19/* $Id: gtkglue.c,v 1.8 2001-12-12 20:24:41 espen Exp $ */
560af5c5 20
21
22#include <gtk/gtk.h>
23
560af5c5 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
40/* Is this necessary? */
41
42GtkType
43gtk_object_type (GtkObject *obj)
44{
45 return GTK_OBJECT_TYPE (obj);
46}
47
48
49
50/* Widget */
51
52GdkWindow*
53gtk_widget_get_window (GtkWidget *widget)
54{
55 return widget->window;
56}
57
58GtkStateType
59gtk_widget_get_state (GtkWidget *widget)
60{
61 return widget->state;
62}
63
64gboolean
65gtk_widget_mapped_p (GtkWidget *widget)
66{
67 return GTK_WIDGET_MAPPED (widget);
68}
69
70void
71gtk_widget_allocation (GtkWidget *widget, int *width, int *height)
72{
73 *width = widget->allocation.width;
74 *height = widget->allocation.height;
75}
76
77
78/* Container */
79
80GtkWidget*
81gtk_container_get_focus_child (GtkContainer *container)
82{
83 return container->focus_child;
84}
85
86
be0a901d 87/* Dialog */
560af5c5 88
be0a901d 89GtkWidget*
90gtk_dialog_get_vbox (GtkDialog *dialog)
91{
92 return dialog->vbox;
93}
560af5c5 94
95GtkWidget*
be0a901d 96gtk_dialog_get_action_area (GtkDialog *dialog)
560af5c5 97{
be0a901d 98 return dialog->action_area;
560af5c5 99}
100
be0a901d 101
102
103/* Menu item */
104
c11e33f7 105GtkSubmenuPlacement
106gtk_menu_item_get_placement (GtkMenuItem* menu_item)
107{
108 return menu_item->submenu_placement;
109}
110
560af5c5 111gint
be0a901d 112gtk_menu_item_get_show_submenu (GtkMenuItem* menu_item)
560af5c5 113{
be0a901d 114 return menu_item->show_submenu_indicator;
560af5c5 115}
116
be0a901d 117void
118gtk_menu_item_set_show_submenu (GtkMenuItem* menu_item, guint show)
560af5c5 119{
be0a901d 120 menu_item->show_submenu_indicator = show;
560af5c5 121}
122
123
124
125/* Check menu item */
126
127gboolean
128gtk_check_menu_item_get_active (GtkCheckMenuItem* check_menu_item)
129{
130 return check_menu_item->active;
131}
132
133gboolean
134gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem* check_menu_item)
135{
136 return check_menu_item->always_show_toggle;
137}
138
139
560af5c5 140/* Window */
141
142void
143gtk_window_wmclass (GtkWindow* window, gchar* name, gchar* class)
144{
145 name = window->wmclass_name;
146 class = window->wmclass_class;
147}
148
149
560af5c5 150/* File selection */
151
152GtkWidget*
153gtk_file_selection_get_action_area (GtkFileSelection *filesel)
154{
155 return filesel->action_area;
156}
157
158GtkWidget*
159gtk_file_selection_get_ok_button (GtkFileSelection *filesel)
160{
161 return filesel->ok_button;
162}
163
164GtkWidget*
165gtk_file_selection_get_cancel_button (GtkFileSelection *filesel)
166{
167 return filesel->cancel_button;
168}
169
170
171/* Color selection */
172
560af5c5 173gtk_color_selection_set_color_by_values (GtkColorSelection *colorsel,
174 gdouble red,
175 gdouble green,
176 gdouble blue,
177 gdouble opacity)
178{
179 gdouble color[4];
180
181 color[0] = red;
182 color[1] = green;
183 color[2] = blue;
184 color[3] = opacity;
185
186 gtk_color_selection_set_color (colorsel, color);
187}
188
189void
190gtk_color_selection_get_color_as_values (GtkColorSelection *colorsel,
191 gdouble *red,
192 gdouble *green,
193 gdouble *blue,
194 gdouble *opacity)
195{
196 gdouble color[4];
197
198 gtk_color_selection_get_color (colorsel, color);
199
200 *red = color[0];
201 *green = color[1];
202 *blue = color[2];
203 *opacity = color[3];
204}
205
206
207/* Combo */
208
209GtkWidget*
210gtk_combo_get_entry (GtkCombo *combo)
211{
212 return combo->entry;
213}
214
215gboolean
216gtk_combo_get_use_arrows (GtkCombo *combo)
217{
218 return combo->use_arrows;
219}
220
221gboolean
222gtk_combo_get_use_arrows_always (GtkCombo *combo)
223{
224 return combo->use_arrows_always;
225}
226
227gboolean
228gtk_combo_get_case_sensitive (GtkCombo *combo)
229{
230 return combo->case_sensitive;
231}
232
233
560af5c5 234/* Paned */
235
236GtkWidget*
237gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
238{
239 *resize = paned->child1_resize;
240 *shrink = paned->child1_shrink;
241
242 return paned->child1;
243}
244
245
246GtkWidget*
247gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
248{
249 *resize = paned->child2_resize;
250 *shrink = paned->child2_shrink;
251
252 return paned->child2;
253}
254
255gint
256gtk_paned_get_position (GtkPaned *paned)
257{
258 if (paned->position_set == TRUE)
259 return paned->child1_size;
260 else
261 return -1;
262}
263
264
265/* Layout */
266
560af5c5 267GdkWindow*
268gtk_layout_get_bin_window (GtkLayout *layout)
269{
270 return layout->bin_window;
271}
272
560af5c5 273
be0a901d 274/* List */
275
276GList*
277gtk_list_selection (GtkList *list)
560af5c5 278{
be0a901d 279 return list->selection;
560af5c5 280}
281
282
be0a901d 283
560af5c5 284/* Toolbar */
285
286gint
287gtk_toolbar_num_children (GtkToolbar *toolbar)
288{
289 return toolbar->num_children;
290}
291
c11e33f7 292gint
293gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
294{
295 return toolbar->tooltips->enabled;
296}
297
560af5c5 298
560af5c5 299/* Drawing area */
300
301void
302gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
303{
304 GtkWidget *widget;
305
306 widget = GTK_WIDGET (darea);
307 *width = widget->allocation.width;
308 *height = widget->allocation.height;
309}
310
311
312/* Progress */
313
314gchar*
315gtk_progress_get_format_string (GtkProgress *progress)
316{
317 return progress->format;
318}
319
320GtkAdjustment*
321gtk_progress_get_adjustment (GtkProgress *progress)
322{
323 return progress->adjustment;
324}
325
326
560af5c5 327/* Tooltips */
328
c11e33f7 329gboolean
330gtk_tooltips_get_enabled (GtkTooltips *tooltips)
331{
332 return tooltips->enabled;
333}
560af5c5 334
335
336/* GtkStyle accessor functions */
337
338typedef enum {
339 GTK_COLOR_FG,
340 GTK_COLOR_BG,
341 GTK_COLOR_LIGHT,
342 GTK_COLOR_DARK,
343 GTK_COLOR_MID,
344 GTK_COLOR_TEXT,
345 GTK_COLOR_BASE,
346 GTK_COLOR_WHITE,
347 GTK_COLOR_BLACK
348} GtkColorType;
349
350GdkColor*
351gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
352 GtkStateType state)
353{
354 switch (color_type)
355 {
356 case GTK_COLOR_WHITE:
357 return &style->white;
358 case GTK_COLOR_BLACK:
359 return &style->black;
360 case GTK_COLOR_FG:
361 return &style->fg[state];
362 case GTK_COLOR_BG:
363 return &style->bg[state];
364 case GTK_COLOR_LIGHT:
365 return &style->light[state];
366 case GTK_COLOR_DARK:
367 return &style->dark[state];
368 case GTK_COLOR_MID:
369 return &style->mid[state];
370 case GTK_COLOR_TEXT:
371 return &style->text[state];
372 case GTK_COLOR_BASE:
373 return &style->base[state];
374 }
375}
376
377
378GdkColor*
379gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
380 GtkStateType state, GdkColor *color)
381{
382 switch (color_type)
383 {
384 case GTK_COLOR_WHITE:
385 style->white = *color; break;
386 case GTK_COLOR_BLACK:
387 style->black = *color; break;
388 case GTK_COLOR_FG:
389 style->fg[state] = *color; break;
390 case GTK_COLOR_BG:
391 style->bg[state] = *color; break;
392 case GTK_COLOR_LIGHT:
393 style->light[state] = *color; break;
394 case GTK_COLOR_DARK:
395 style->dark[state] = *color; break;
396 case GTK_COLOR_MID:
397 style->mid[state] = *color; break;
398 case GTK_COLOR_TEXT:
399 style->text[state] = *color; break;
400 case GTK_COLOR_BASE:
401 style->base[state] = *color; break;
402 }
403
404 return gtk_style_get_color (style, color_type, state);
405}
406
be0a901d 407/*
560af5c5 408GdkFont*
409gtk_style_get_font (GtkStyle *style)
410{
411 return style->font;
412}
413
414
415GdkFont*
416gtk_style_set_font (GtkStyle *style, GdkFont *font)
417{
418 return style->font = font;
419}
be0a901d 420*/
560af5c5 421
422GdkGC*
423gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
424{
425 switch (color_type)
426 {
427 case GTK_COLOR_WHITE:
428 return style->white_gc;
429 case GTK_COLOR_BLACK:
430 return style->black_gc;
431 case GTK_COLOR_FG:
432 return style->fg_gc[state];
433 case GTK_COLOR_BG:
434 return style->bg_gc[state];
435 case GTK_COLOR_LIGHT:
436 return style->light_gc[state];
437 case GTK_COLOR_DARK:
438 return style->dark_gc[state];
439 case GTK_COLOR_MID:
440 return style->mid_gc[state];
441 case GTK_COLOR_TEXT:
442 return style->text_gc[state];
443 case GTK_COLOR_BASE:
444 return style->base_gc[state];
445 }
446}