1 /* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2000 Espen S. Johnsen <esj@stud.cs.uit.no>
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.9 2002-03-22 22:34:45 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
);
53 gtk_widget_get_window (GtkWidget
*widget
)
55 return widget
->window
;
59 gtk_widget_get_state (GtkWidget
*widget
)
65 gtk_widget_mapped_p (GtkWidget
*widget
)
67 return GTK_WIDGET_MAPPED (widget
);
71 gtk_widget_allocation (GtkWidget
*widget
, int *width
, int *height
)
73 *width
= widget
->allocation
.width
;
74 *height
= widget
->allocation
.height
;
81 gtk_container_get_focus_child (GtkContainer
*container
)
83 return container
->focus_child
;
90 gtk_dialog_get_vbox (GtkDialog
*dialog
)
96 gtk_dialog_get_action_area (GtkDialog
*dialog
)
98 return dialog
->action_area
;
106 gtk_menu_item_get_placement (GtkMenuItem
* menu_item
)
108 return menu_item
->submenu_placement
;
112 gtk_menu_item_get_show_submenu (GtkMenuItem
* menu_item
)
114 return menu_item
->show_submenu_indicator
;
118 gtk_menu_item_set_show_submenu (GtkMenuItem
* menu_item
, guint show
)
120 menu_item
->show_submenu_indicator
= show
;
125 /* Check menu item */
128 gtk_check_menu_item_get_active (GtkCheckMenuItem
* check_menu_item
)
130 return check_menu_item
->active
;
134 gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem
* check_menu_item
)
136 return check_menu_item
->always_show_toggle
;
143 gtk_window_wmclass (GtkWindow
* window
, gchar
* name
, gchar
* class)
145 name
= window
->wmclass_name
;
146 class = window
->wmclass_class
;
153 gtk_file_selection_get_action_area (GtkFileSelection
*filesel
)
155 return filesel
->action_area
;
159 gtk_file_selection_get_ok_button (GtkFileSelection
*filesel
)
161 return filesel
->ok_button
;
165 gtk_file_selection_get_cancel_button (GtkFileSelection
*filesel
)
167 return filesel
->cancel_button
;
171 /* Color selection */
173 gtk_color_selection_set_color_by_values (GtkColorSelection
*colorsel
,
186 gtk_color_selection_set_color (colorsel
, color
);
190 gtk_color_selection_get_color_as_values (GtkColorSelection
*colorsel
,
198 gtk_color_selection_get_color (colorsel
, color
);
210 gtk_combo_get_entry (GtkCombo
*combo
)
216 gtk_combo_get_use_arrows (GtkCombo
*combo
)
218 return combo
->use_arrows
;
222 gtk_combo_get_use_arrows_always (GtkCombo
*combo
)
224 return combo
->use_arrows_always
;
228 gtk_combo_get_case_sensitive (GtkCombo
*combo
)
230 return combo
->case_sensitive
;
237 gtk_paned_child1 (GtkPaned
*paned
, guint
*resize
, guint
*shrink
)
239 *resize
= paned
->child1_resize
;
240 *shrink
= paned
->child1_shrink
;
242 return paned
->child1
;
247 gtk_paned_child2 (GtkPaned
*paned
, guint
*resize
, guint
*shrink
)
249 *resize
= paned
->child2_resize
;
250 *shrink
= paned
->child2_shrink
;
252 return paned
->child2
;
256 gtk_paned_get_position (GtkPaned
*paned
)
258 if (paned
->position_set
== TRUE
)
259 return paned
->child1_size
;
268 gtk_layout_get_bin_window (GtkLayout
*layout
)
270 return layout
->bin_window
;
277 gtk_list_selection (GtkList
*list
)
279 return list
->selection
;
287 gtk_toolbar_num_children (GtkToolbar
*toolbar
)
289 return toolbar
->num_children
;
293 gtk_toolbar_get_tooltips (GtkToolbar
*toolbar
)
295 return toolbar
->tooltips
->enabled
;
302 gtk_drawing_area_get_size (GtkDrawingArea
*darea
, gint
*width
, gint
*height
)
306 widget
= GTK_WIDGET (darea
);
307 *width
= widget
->allocation
.width
;
308 *height
= widget
->allocation
.height
;
315 gtk_progress_get_format_string (GtkProgress
*progress
)
317 return progress
->format
;
321 gtk_progress_get_adjustment (GtkProgress
*progress
)
323 return progress
->adjustment
;
330 gtk_tooltips_get_enabled (GtkTooltips
*tooltips
)
332 return tooltips
->enabled
;
336 /* GtkStyle accessor functions */
351 gtk_style_get_color (GtkStyle
*style
, GtkColorType color_type
,
356 case GTK_COLOR_WHITE
:
357 return &style
->white
;
358 case GTK_COLOR_BLACK
:
359 return &style
->black
;
361 return &style
->fg
[state
];
363 return &style
->bg
[state
];
364 case GTK_COLOR_LIGHT
:
365 return &style
->light
[state
];
367 return &style
->dark
[state
];
369 return &style
->mid
[state
];
371 return &style
->text
[state
];
373 return &style
->base
[state
];
379 gtk_style_set_color (GtkStyle
*style
, GtkColorType color_type
,
380 GtkStateType state
, GdkColor
*color
)
384 case GTK_COLOR_WHITE
:
385 style
->white
= *color
; break;
386 case GTK_COLOR_BLACK
:
387 style
->black
= *color
; break;
389 style
->fg
[state
] = *color
; break;
391 style
->bg
[state
] = *color
; break;
392 case GTK_COLOR_LIGHT
:
393 style
->light
[state
] = *color
; break;
395 style
->dark
[state
] = *color
; break;
397 style
->mid
[state
] = *color
; break;
399 style
->text
[state
] = *color
; break;
401 style
->base
[state
] = *color
; break;
404 return gtk_style_get_color (style
, color_type
, state
);
409 gtk_style_get_font (GtkStyle *style)
416 gtk_style_set_font (GtkStyle *style, GdkFont *font)
418 return style->font = font;
423 gtk_style_get_gc (GtkStyle
*style
, GtkColorType color_type
, GtkStateType state
)
427 case GTK_COLOR_WHITE
:
428 return style
->white_gc
;
429 case GTK_COLOR_BLACK
:
430 return style
->black_gc
;
432 return style
->fg_gc
[state
];
434 return style
->bg_gc
[state
];
435 case GTK_COLOR_LIGHT
:
436 return style
->light_gc
[state
];
438 return style
->dark_gc
[state
];
440 return style
->mid_gc
[state
];
442 return style
->text_gc
[state
];
444 return style
->base_gc
[state
];