chiark / gitweb /
Updated for gtk+-1.3.9 and misc changes
[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
5fd4bed0 19/* $Id: gtkglue.c,v 1.6 2001-05-29 16:01:40 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
87
88/* Menu item */
89
90GtkWidget*
91gtk_menu_item_get_submenu (GtkMenuItem* menu_item)
92{
93 return menu_item->submenu;
94}
95
c11e33f7 96GtkSubmenuPlacement
97gtk_menu_item_get_placement (GtkMenuItem* menu_item)
98{
99 return menu_item->submenu_placement;
100}
101
560af5c5 102gint
103gtk_menu_item_get_show_toggle (GtkMenuItem* menu_item)
104{
105 return menu_item->show_toggle_indicator;
106}
107
108gint
109gtk_menu_item_get_show_submenu (GtkMenuItem* menu_item)
110{
111 return menu_item->show_submenu_indicator;
112}
113
114
115
116/* Check menu item */
117
118gboolean
119gtk_check_menu_item_get_active (GtkCheckMenuItem* check_menu_item)
120{
121 return check_menu_item->active;
122}
123
124gboolean
125gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem* check_menu_item)
126{
127 return check_menu_item->always_show_toggle;
128}
129
130
560af5c5 131/* Window */
132
133void
134gtk_window_wmclass (GtkWindow* window, gchar* name, gchar* class)
135{
136 name = window->wmclass_name;
137 class = window->wmclass_class;
138}
139
140
560af5c5 141/* File selection */
142
143GtkWidget*
144gtk_file_selection_get_action_area (GtkFileSelection *filesel)
145{
146 return filesel->action_area;
147}
148
149GtkWidget*
150gtk_file_selection_get_ok_button (GtkFileSelection *filesel)
151{
152 return filesel->ok_button;
153}
154
155GtkWidget*
156gtk_file_selection_get_cancel_button (GtkFileSelection *filesel)
157{
158 return filesel->cancel_button;
159}
160
161
162/* Color selection */
163
560af5c5 164gtk_color_selection_set_color_by_values (GtkColorSelection *colorsel,
165 gdouble red,
166 gdouble green,
167 gdouble blue,
168 gdouble opacity)
169{
170 gdouble color[4];
171
172 color[0] = red;
173 color[1] = green;
174 color[2] = blue;
175 color[3] = opacity;
176
177 gtk_color_selection_set_color (colorsel, color);
178}
179
180void
181gtk_color_selection_get_color_as_values (GtkColorSelection *colorsel,
182 gdouble *red,
183 gdouble *green,
184 gdouble *blue,
185 gdouble *opacity)
186{
187 gdouble color[4];
188
189 gtk_color_selection_get_color (colorsel, color);
190
191 *red = color[0];
192 *green = color[1];
193 *blue = color[2];
194 *opacity = color[3];
195}
196
197
198/* Combo */
199
200GtkWidget*
201gtk_combo_get_entry (GtkCombo *combo)
202{
203 return combo->entry;
204}
205
206gboolean
207gtk_combo_get_use_arrows (GtkCombo *combo)
208{
209 return combo->use_arrows;
210}
211
212gboolean
213gtk_combo_get_use_arrows_always (GtkCombo *combo)
214{
215 return combo->use_arrows_always;
216}
217
218gboolean
219gtk_combo_get_case_sensitive (GtkCombo *combo)
220{
221 return combo->case_sensitive;
222}
223
224
560af5c5 225/* Paned */
226
227GtkWidget*
228gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
229{
230 *resize = paned->child1_resize;
231 *shrink = paned->child1_shrink;
232
233 return paned->child1;
234}
235
236
237GtkWidget*
238gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
239{
240 *resize = paned->child2_resize;
241 *shrink = paned->child2_shrink;
242
243 return paned->child2;
244}
245
246gint
247gtk_paned_get_position (GtkPaned *paned)
248{
249 if (paned->position_set == TRUE)
250 return paned->child1_size;
251 else
252 return -1;
253}
254
255
256/* Layout */
257
258gint
2f779f71 259gtk_layout_get_size (GtkLayout *layout, gint *width, gint *height)
560af5c5 260
261{
262 *width = layout->width;
263 *height = layout->height;
264}
265
560af5c5 266GdkWindow*
267gtk_layout_get_bin_window (GtkLayout *layout)
268{
269 return layout->bin_window;
270}
271
272
273/* List */
274
275GList*
276gtk_list_selection (GtkList *list)
277{
278 return list->selection;
279}
280
281
c11e33f7 282/* Menu */
283
284gboolean
285gtk_menu_get_tearoff_state (GtkMenu *menu)
286{
287 return menu->torn_off;
288}
289
290gchar*
291gtk_menu_get_title (GtkMenu *menu)
292{
293 return g_strdup (gtk_object_get_data (GTK_OBJECT (menu), "gtk-menu-title"));
294}
295
296
560af5c5 297/* Table */
298
299guint
300gtk_table_row_spacing (GtkTable *table,
301 guint row)
302{
303 return table->rows[row].spacing;
304}
305
306guint
307gtk_table_column_spacing (GtkTable *table,
308 guint col)
309{
310 return table->cols[col].spacing;
311}
312
313
314/* Toolbar */
315
316gint
317gtk_toolbar_num_children (GtkToolbar *toolbar)
318{
319 return toolbar->num_children;
320}
321
c11e33f7 322gint
323gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
324{
325 return toolbar->tooltips->enabled;
326}
327
560af5c5 328
560af5c5 329/* Drawing area */
330
331void
332gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
333{
334 GtkWidget *widget;
335
336 widget = GTK_WIDGET (darea);
337 *width = widget->allocation.width;
338 *height = widget->allocation.height;
339}
340
341
342/* Progress */
343
344gchar*
345gtk_progress_get_format_string (GtkProgress *progress)
346{
347 return progress->format;
348}
349
350GtkAdjustment*
351gtk_progress_get_adjustment (GtkProgress *progress)
352{
353 return progress->adjustment;
354}
355
356
357/* Scrolled window */
358
359GtkWidget*
360gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *window)
361{
362 return window->hscrollbar;
363}
364
365GtkWidget*
366gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *window)
367{
368 return window->vscrollbar;
369}
370
371
372
373/* Tooltips */
374
375guint
376gtk_tooltips_get_delay (GtkTooltips *tooltips)
377{
378 return tooltips->delay;
379}
380
c11e33f7 381gboolean
382gtk_tooltips_get_enabled (GtkTooltips *tooltips)
383{
384 return tooltips->enabled;
385}
560af5c5 386
387
388/* GtkStyle accessor functions */
389
390typedef enum {
391 GTK_COLOR_FG,
392 GTK_COLOR_BG,
393 GTK_COLOR_LIGHT,
394 GTK_COLOR_DARK,
395 GTK_COLOR_MID,
396 GTK_COLOR_TEXT,
397 GTK_COLOR_BASE,
398 GTK_COLOR_WHITE,
399 GTK_COLOR_BLACK
400} GtkColorType;
401
402GdkColor*
403gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
404 GtkStateType state)
405{
406 switch (color_type)
407 {
408 case GTK_COLOR_WHITE:
409 return &style->white;
410 case GTK_COLOR_BLACK:
411 return &style->black;
412 case GTK_COLOR_FG:
413 return &style->fg[state];
414 case GTK_COLOR_BG:
415 return &style->bg[state];
416 case GTK_COLOR_LIGHT:
417 return &style->light[state];
418 case GTK_COLOR_DARK:
419 return &style->dark[state];
420 case GTK_COLOR_MID:
421 return &style->mid[state];
422 case GTK_COLOR_TEXT:
423 return &style->text[state];
424 case GTK_COLOR_BASE:
425 return &style->base[state];
426 }
427}
428
429
430GdkColor*
431gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
432 GtkStateType state, GdkColor *color)
433{
434 switch (color_type)
435 {
436 case GTK_COLOR_WHITE:
437 style->white = *color; break;
438 case GTK_COLOR_BLACK:
439 style->black = *color; break;
440 case GTK_COLOR_FG:
441 style->fg[state] = *color; break;
442 case GTK_COLOR_BG:
443 style->bg[state] = *color; break;
444 case GTK_COLOR_LIGHT:
445 style->light[state] = *color; break;
446 case GTK_COLOR_DARK:
447 style->dark[state] = *color; break;
448 case GTK_COLOR_MID:
449 style->mid[state] = *color; break;
450 case GTK_COLOR_TEXT:
451 style->text[state] = *color; break;
452 case GTK_COLOR_BASE:
453 style->base[state] = *color; break;
454 }
455
456 return gtk_style_get_color (style, color_type, state);
457}
458
459
460GdkFont*
461gtk_style_get_font (GtkStyle *style)
462{
463 return style->font;
464}
465
466
467GdkFont*
468gtk_style_set_font (GtkStyle *style, GdkFont *font)
469{
470 return style->font = font;
471}
472
473
474GdkGC*
475gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
476{
477 switch (color_type)
478 {
479 case GTK_COLOR_WHITE:
480 return style->white_gc;
481 case GTK_COLOR_BLACK:
482 return style->black_gc;
483 case GTK_COLOR_FG:
484 return style->fg_gc[state];
485 case GTK_COLOR_BG:
486 return style->bg_gc[state];
487 case GTK_COLOR_LIGHT:
488 return style->light_gc[state];
489 case GTK_COLOR_DARK:
490 return style->dark_gc[state];
491 case GTK_COLOR_MID:
492 return style->mid_gc[state];
493 case GTK_COLOR_TEXT:
494 return style->text_gc[state];
495 case GTK_COLOR_BASE:
496 return style->base_gc[state];
497 }
498}