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.6 2001/05/29 16:01:40 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 /* Is this necessary? */
43 gtk_object_type (GtkObject *obj)
45 return GTK_OBJECT_TYPE (obj);
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;
91 gtk_menu_item_get_submenu (GtkMenuItem* menu_item)
93 return menu_item->submenu;
97 gtk_menu_item_get_placement (GtkMenuItem* menu_item)
99 return menu_item->submenu_placement;
103 gtk_menu_item_get_show_toggle (GtkMenuItem* menu_item)
105 return menu_item->show_toggle_indicator;
109 gtk_menu_item_get_show_submenu (GtkMenuItem* menu_item)
111 return menu_item->show_submenu_indicator;
116 /* Check menu item */
119 gtk_check_menu_item_get_active (GtkCheckMenuItem* check_menu_item)
121 return check_menu_item->active;
125 gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem* check_menu_item)
127 return check_menu_item->always_show_toggle;
134 gtk_window_wmclass (GtkWindow* window, gchar* name, gchar* class)
136 name = window->wmclass_name;
137 class = window->wmclass_class;
144 gtk_file_selection_get_action_area (GtkFileSelection *filesel)
146 return filesel->action_area;
150 gtk_file_selection_get_ok_button (GtkFileSelection *filesel)
152 return filesel->ok_button;
156 gtk_file_selection_get_cancel_button (GtkFileSelection *filesel)
158 return filesel->cancel_button;
162 /* Color selection */
164 gtk_color_selection_set_color_by_values (GtkColorSelection *colorsel,
177 gtk_color_selection_set_color (colorsel, color);
181 gtk_color_selection_get_color_as_values (GtkColorSelection *colorsel,
189 gtk_color_selection_get_color (colorsel, color);
201 gtk_combo_get_entry (GtkCombo *combo)
207 gtk_combo_get_use_arrows (GtkCombo *combo)
209 return combo->use_arrows;
213 gtk_combo_get_use_arrows_always (GtkCombo *combo)
215 return combo->use_arrows_always;
219 gtk_combo_get_case_sensitive (GtkCombo *combo)
221 return combo->case_sensitive;
228 gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
230 *resize = paned->child1_resize;
231 *shrink = paned->child1_shrink;
233 return paned->child1;
238 gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
240 *resize = paned->child2_resize;
241 *shrink = paned->child2_shrink;
243 return paned->child2;
247 gtk_paned_get_position (GtkPaned *paned)
249 if (paned->position_set == TRUE)
250 return paned->child1_size;
259 gtk_layout_get_size (GtkLayout *layout, gint *width, gint *height)
262 *width = layout->width;
263 *height = layout->height;
267 gtk_layout_get_bin_window (GtkLayout *layout)
269 return layout->bin_window;
276 gtk_list_selection (GtkList *list)
278 return list->selection;
285 gtk_menu_get_tearoff_state (GtkMenu *menu)
287 return menu->torn_off;
291 gtk_menu_get_title (GtkMenu *menu)
293 return g_strdup (gtk_object_get_data (GTK_OBJECT (menu), "gtk-menu-title"));
300 gtk_table_row_spacing (GtkTable *table,
303 return table->rows[row].spacing;
307 gtk_table_column_spacing (GtkTable *table,
310 return table->cols[col].spacing;
317 gtk_toolbar_num_children (GtkToolbar *toolbar)
319 return toolbar->num_children;
323 gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
325 return toolbar->tooltips->enabled;
332 gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
336 widget = GTK_WIDGET (darea);
337 *width = widget->allocation.width;
338 *height = widget->allocation.height;
345 gtk_progress_get_format_string (GtkProgress *progress)
347 return progress->format;
351 gtk_progress_get_adjustment (GtkProgress *progress)
353 return progress->adjustment;
357 /* Scrolled window */
360 gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *window)
362 return window->hscrollbar;
366 gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *window)
368 return window->vscrollbar;
376 gtk_tooltips_get_delay (GtkTooltips *tooltips)
378 return tooltips->delay;
382 gtk_tooltips_get_enabled (GtkTooltips *tooltips)
384 return tooltips->enabled;
388 /* GtkStyle accessor functions */
403 gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
408 case GTK_COLOR_WHITE:
409 return &style->white;
410 case GTK_COLOR_BLACK:
411 return &style->black;
413 return &style->fg[state];
415 return &style->bg[state];
416 case GTK_COLOR_LIGHT:
417 return &style->light[state];
419 return &style->dark[state];
421 return &style->mid[state];
423 return &style->text[state];
425 return &style->base[state];
431 gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
432 GtkStateType state, GdkColor *color)
436 case GTK_COLOR_WHITE:
437 style->white = *color; break;
438 case GTK_COLOR_BLACK:
439 style->black = *color; break;
441 style->fg[state] = *color; break;
443 style->bg[state] = *color; break;
444 case GTK_COLOR_LIGHT:
445 style->light[state] = *color; break;
447 style->dark[state] = *color; break;
449 style->mid[state] = *color; break;
451 style->text[state] = *color; break;
453 style->base[state] = *color; break;
456 return gtk_style_get_color (style, color_type, state);
461 gtk_style_get_font (GtkStyle *style)
468 gtk_style_set_font (GtkStyle *style, GdkFont *font)
470 return style->font = font;
475 gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
479 case GTK_COLOR_WHITE:
480 return style->white_gc;
481 case GTK_COLOR_BLACK:
482 return style->black_gc;
484 return style->fg_gc[state];
486 return style->bg_gc[state];
487 case GTK_COLOR_LIGHT:
488 return style->light_gc[state];
490 return style->dark_gc[state];
492 return style->mid_gc[state];
494 return style->text_gc[state];
496 return style->base_gc[state];