chiark / gitweb /
Changes in widget initialization
[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
be0a901d 19/* $Id: gtkglue.c,v 1.7 2001-10-21 23:22:53 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
be0a901d 273guint
274gtk_layout_get_xoffset (GtkLayout *layout)
560af5c5 275{
be0a901d 276 return layout->xoffset;
560af5c5 277}
278
be0a901d 279void
280gtk_layout_set_xoffset (GtkLayout *layout, guint xoffset)
c11e33f7 281{
be0a901d 282 return layout->xoffset = xoffset;
c11e33f7 283}
284
be0a901d 285guint
286gtk_layout_get_yoffset (GtkLayout *layout)
c11e33f7 287{
be0a901d 288 return layout->yoffset;
c11e33f7 289}
290
be0a901d 291void
292gtk_layout_set_yoffset (GtkLayout *layout, guint yoffset)
560af5c5 293{
be0a901d 294 return layout->yoffset = yoffset;
560af5c5 295}
296
be0a901d 297/* List */
298
299GList*
300gtk_list_selection (GtkList *list)
560af5c5 301{
be0a901d 302 return list->selection;
560af5c5 303}
304
305
be0a901d 306
560af5c5 307/* Toolbar */
308
309gint
310gtk_toolbar_num_children (GtkToolbar *toolbar)
311{
312 return toolbar->num_children;
313}
314
c11e33f7 315gint
316gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
317{
318 return toolbar->tooltips->enabled;
319}
320
560af5c5 321
560af5c5 322/* Drawing area */
323
324void
325gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
326{
327 GtkWidget *widget;
328
329 widget = GTK_WIDGET (darea);
330 *width = widget->allocation.width;
331 *height = widget->allocation.height;
332}
333
334
335/* Progress */
336
337gchar*
338gtk_progress_get_format_string (GtkProgress *progress)
339{
340 return progress->format;
341}
342
343GtkAdjustment*
344gtk_progress_get_adjustment (GtkProgress *progress)
345{
346 return progress->adjustment;
347}
348
349
560af5c5 350/* Tooltips */
351
c11e33f7 352gboolean
353gtk_tooltips_get_enabled (GtkTooltips *tooltips)
354{
355 return tooltips->enabled;
356}
560af5c5 357
358
359/* GtkStyle accessor functions */
360
361typedef enum {
362 GTK_COLOR_FG,
363 GTK_COLOR_BG,
364 GTK_COLOR_LIGHT,
365 GTK_COLOR_DARK,
366 GTK_COLOR_MID,
367 GTK_COLOR_TEXT,
368 GTK_COLOR_BASE,
369 GTK_COLOR_WHITE,
370 GTK_COLOR_BLACK
371} GtkColorType;
372
373GdkColor*
374gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
375 GtkStateType state)
376{
377 switch (color_type)
378 {
379 case GTK_COLOR_WHITE:
380 return &style->white;
381 case GTK_COLOR_BLACK:
382 return &style->black;
383 case GTK_COLOR_FG:
384 return &style->fg[state];
385 case GTK_COLOR_BG:
386 return &style->bg[state];
387 case GTK_COLOR_LIGHT:
388 return &style->light[state];
389 case GTK_COLOR_DARK:
390 return &style->dark[state];
391 case GTK_COLOR_MID:
392 return &style->mid[state];
393 case GTK_COLOR_TEXT:
394 return &style->text[state];
395 case GTK_COLOR_BASE:
396 return &style->base[state];
397 }
398}
399
400
401GdkColor*
402gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
403 GtkStateType state, GdkColor *color)
404{
405 switch (color_type)
406 {
407 case GTK_COLOR_WHITE:
408 style->white = *color; break;
409 case GTK_COLOR_BLACK:
410 style->black = *color; break;
411 case GTK_COLOR_FG:
412 style->fg[state] = *color; break;
413 case GTK_COLOR_BG:
414 style->bg[state] = *color; break;
415 case GTK_COLOR_LIGHT:
416 style->light[state] = *color; break;
417 case GTK_COLOR_DARK:
418 style->dark[state] = *color; break;
419 case GTK_COLOR_MID:
420 style->mid[state] = *color; break;
421 case GTK_COLOR_TEXT:
422 style->text[state] = *color; break;
423 case GTK_COLOR_BASE:
424 style->base[state] = *color; break;
425 }
426
427 return gtk_style_get_color (style, color_type, state);
428}
429
be0a901d 430/*
560af5c5 431GdkFont*
432gtk_style_get_font (GtkStyle *style)
433{
434 return style->font;
435}
436
437
438GdkFont*
439gtk_style_set_font (GtkStyle *style, GdkFont *font)
440{
441 return style->font = font;
442}
be0a901d 443*/
560af5c5 444
445GdkGC*
446gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
447{
448 switch (color_type)
449 {
450 case GTK_COLOR_WHITE:
451 return style->white_gc;
452 case GTK_COLOR_BLACK:
453 return style->black_gc;
454 case GTK_COLOR_FG:
455 return style->fg_gc[state];
456 case GTK_COLOR_BG:
457 return style->bg_gc[state];
458 case GTK_COLOR_LIGHT:
459 return style->light_gc[state];
460 case GTK_COLOR_DARK:
461 return style->dark_gc[state];
462 case GTK_COLOR_MID:
463 return style->mid_gc[state];
464 case GTK_COLOR_TEXT:
465 return style->text_gc[state];
466 case GTK_COLOR_BASE:
467 return style->base_gc[state];
468 }
469}