1 /* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2002 Espen S. Johnsen <espen@users.sourceforge.net>
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.
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.
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
19 /* $Id: gtkglue.c,v 1.12 2002-04-02 15:05:44 espen Exp $ */
27 * Gtk helper functions
32 gtk_query_version (guint
*major
, guint
*minor
, guint
*micro
)
34 *major
= gtk_major_version
;
35 *minor
= gtk_minor_version
;
36 *micro
= gtk_micro_version
;
40 void gtk_callback_marshal (GtkWidget
*widget
, gpointer data
)
44 memset (&arg
, 0, sizeof (GValue
));
45 g_value_init (&arg
, gtk_widget_get_type ());
46 g_value_set_object (&arg
, widget
);
47 callback_marshal ((guint
)data
, NULL
, 1, &arg
);
50 void gtk_menu_position_callback_marshal (GtkMenu
*menu
, gint x
, gint y
,
51 gboolean push_in
, gpointer data
)
55 memset (args
, 0, 3 * sizeof (GValue
));
56 g_value_init (&args
[0], G_TYPE_INT
);
57 g_value_set_int (&args
[0], x
);
58 g_value_init (&args
[1], G_TYPE_INT
);
59 g_value_set_int (&args
[1], y
);
60 g_value_init (&args
[2], G_TYPE_BOOLEAN
);
61 g_value_set_boolean (&args
[2], push_in
);
63 callback_marshal ((guint
)data
, NULL
, 3, args
);
70 gtk_widget_get_window (GtkWidget
*widget
)
72 return widget
->window
;
76 gtk_widget_get_state (GtkWidget
*widget
)
82 gtk_widget_mapped_p (GtkWidget
*widget
)
84 return GTK_WIDGET_MAPPED (widget
);
88 gtk_widget_get_size_allocation (GtkWidget
*widget
, int *width
, int *height
)
90 *width
= widget
->allocation
.width
;
91 *height
= widget
->allocation
.height
;
98 gtk_container_get_focus_child (GtkContainer
*container
)
100 return container
->focus_child
;
107 gtk_dialog_get_vbox (GtkDialog
*dialog
)
113 gtk_dialog_get_action_area (GtkDialog
*dialog
)
115 return dialog
->action_area
;
120 /* Check menu item */
123 gtk_check_menu_item_get_active (GtkCheckMenuItem
* check_menu_item
)
125 return check_menu_item
->active
;
129 gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem
* check_menu_item
)
131 return check_menu_item
->always_show_toggle
;
139 gtk_window_get_default (GtkWindow
*window
)
141 return window
->default_widget
;
148 gtk_file_selection_get_action_area (GtkFileSelection
*filesel
)
150 return filesel
->action_area
;
154 gtk_file_selection_get_ok_button (GtkFileSelection
*filesel
)
156 return filesel
->ok_button
;
160 gtk_file_selection_get_cancel_button (GtkFileSelection
*filesel
)
162 return filesel
->cancel_button
;
166 /* Color selection */
168 gtk_color_selection_set_color_by_values (GtkColorSelection
*colorsel
,
181 gtk_color_selection_set_color (colorsel
, color
);
185 gtk_color_selection_get_color_as_values (GtkColorSelection
*colorsel
,
193 gtk_color_selection_get_color (colorsel
, color
);
205 gtk_combo_get_entry (GtkCombo
*combo
)
211 gtk_combo_get_use_arrows (GtkCombo
*combo
)
213 return combo
->use_arrows
;
217 gtk_combo_get_use_arrows_always (GtkCombo
*combo
)
219 return combo
->use_arrows_always
;
223 gtk_combo_get_case_sensitive (GtkCombo
*combo
)
225 return combo
->case_sensitive
;
232 gtk_paned_child1 (GtkPaned
*paned
, guint
*resize
, guint
*shrink
)
234 *resize
= paned
->child1_resize
;
235 *shrink
= paned
->child1_shrink
;
237 return paned
->child1
;
242 gtk_paned_child2 (GtkPaned
*paned
, guint
*resize
, guint
*shrink
)
244 *resize
= paned
->child2_resize
;
245 *shrink
= paned
->child2_shrink
;
247 return paned
->child2
;
254 gtk_layout_get_bin_window (GtkLayout
*layout
)
256 return layout
->bin_window
;
263 gtk_list_selection (GtkList
*list
)
265 return list
->selection
;
273 gtk_toolbar_get_tooltips (GtkToolbar
*toolbar
)
275 return toolbar
->tooltips
->enabled
;
282 gtk_drawing_area_get_size (GtkDrawingArea
*darea
, gint
*width
, gint
*height
)
286 widget
= GTK_WIDGET (darea
);
287 *width
= widget
->allocation
.width
;
288 *height
= widget
->allocation
.height
;
295 gtk_progress_get_format_string (GtkProgress
*progress
)
297 return progress
->format
;
301 gtk_progress_get_adjustment (GtkProgress
*progress
)
303 return progress
->adjustment
;
310 gtk_tooltips_get_enabled (GtkTooltips
*tooltips
)
312 return tooltips
->enabled
;
316 /* GtkStyle accessor functions */
331 gtk_style_get_color (GtkStyle
*style
, GtkColorType color_type
,
336 case GTK_COLOR_WHITE
:
337 return &style
->white
;
338 case GTK_COLOR_BLACK
:
339 return &style
->black
;
341 return &style
->fg
[state
];
343 return &style
->bg
[state
];
344 case GTK_COLOR_LIGHT
:
345 return &style
->light
[state
];
347 return &style
->dark
[state
];
349 return &style
->mid
[state
];
351 return &style
->text
[state
];
353 return &style
->base
[state
];
359 gtk_style_set_color (GtkStyle
*style
, GtkColorType color_type
,
360 GtkStateType state
, GdkColor
*color
)
364 case GTK_COLOR_WHITE
:
365 style
->white
= *color
; break;
366 case GTK_COLOR_BLACK
:
367 style
->black
= *color
; break;
369 style
->fg
[state
] = *color
; break;
371 style
->bg
[state
] = *color
; break;
372 case GTK_COLOR_LIGHT
:
373 style
->light
[state
] = *color
; break;
375 style
->dark
[state
] = *color
; break;
377 style
->mid
[state
] = *color
; break;
379 style
->text
[state
] = *color
; break;
381 style
->base
[state
] = *color
; break;
384 return gtk_style_get_color (style
, color_type
, state
);
389 gtk_style_get_font (GtkStyle *style)
396 gtk_style_set_font (GtkStyle *style, GdkFont *font)
398 return style->font = font;
403 gtk_style_get_gc (GtkStyle
*style
, GtkColorType color_type
, GtkStateType state
)
407 case GTK_COLOR_WHITE
:
408 return style
->white_gc
;
409 case GTK_COLOR_BLACK
:
410 return style
->black_gc
;
412 return style
->fg_gc
[state
];
414 return style
->bg_gc
[state
];
415 case GTK_COLOR_LIGHT
:
416 return style
->light_gc
[state
];
418 return style
->dark_gc
[state
];
420 return style
->mid_gc
[state
];
422 return style
->text_gc
[state
];
424 return style
->base_gc
[state
];