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.5 2001/04/29 20:12:12 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;
229 gtk_clist_selection (GtkCList *clist)
231 return clist->selection;
235 gtk_clist_get_titles_visible (GtkCList *clist)
237 return (clist->title_window && GTK_WIDGET_VISIBLE (clist->title_window));
241 gtk_clist_get_n_rows (GtkCList *clist)
247 gtk_clist_get_focus_row (GtkCList *clist)
249 return clist->focus_row;
253 gtk_clist_get_sort_column (GtkCList *clist)
255 return clist->sort_column;
259 gtk_clist_column_justification (GtkCList *clist,
262 return clist->column[column].justification;
266 gtk_clist_column_visible_p (GtkCList *clist,
269 return clist->column[column].visible;
273 gtk_clist_column_resizeable_p (GtkCList *clist,
276 return clist->column[column].resizeable;
280 gtk_clist_column_auto_resize_p (GtkCList *clist,
283 return clist->column[column].auto_resize;
287 gtk_clist_column_width (GtkCList *clist,
290 return clist->column[column].width;
294 gtk_clist_auto_sort_p (GtkCList *clist)
296 return GTK_CLIST_AUTO_SORT (clist);
304 gtk_ctree_node_leaf_p (GtkCTreeNode* node)
306 return GTK_CTREE_ROW (node)->is_leaf;
310 gtk_ctree_node_child (GtkCTreeNode* node)
312 return GTK_CTREE_ROW (node)->children;
316 gtk_ctree_node_parent (GtkCTreeNode* node)
318 return GTK_CTREE_ROW (node)->parent;
322 gtk_ctree_node_sibling (GtkCTreeNode* node)
324 return GTK_CTREE_ROW (node)->sibling;
328 gtk_ctree_node_level (GtkCTreeNode* node)
330 return GTK_CTREE_ROW (node)->level;
337 gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
339 *resize = paned->child1_resize;
340 *shrink = paned->child1_shrink;
342 return paned->child1;
347 gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
349 *resize = paned->child2_resize;
350 *shrink = paned->child2_shrink;
352 return paned->child2;
356 gtk_paned_get_position (GtkPaned *paned)
358 if (paned->position_set == TRUE)
359 return paned->child1_size;
368 gtk_layout_get_size (GtkLayout *layout, gint *width, gint *height)
371 *width = layout->width;
372 *height = layout->height;
376 gtk_layout_get_bin_window (GtkLayout *layout)
378 return layout->bin_window;
385 gtk_list_selection (GtkList *list)
387 return list->selection;
394 gtk_menu_get_tearoff_state (GtkMenu *menu)
396 return menu->torn_off;
400 gtk_menu_get_title (GtkMenu *menu)
402 return g_strdup (gtk_object_get_data (GTK_OBJECT (menu), "gtk-menu-title"));
409 gtk_table_row_spacing (GtkTable *table,
412 return table->rows[row].spacing;
416 gtk_table_column_spacing (GtkTable *table,
419 return table->cols[col].spacing;
426 gtk_toolbar_num_children (GtkToolbar *toolbar)
428 return toolbar->num_children;
432 gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
434 return toolbar->tooltips->enabled;
441 gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
445 widget = GTK_WIDGET (darea);
446 *width = widget->allocation.width;
447 *height = widget->allocation.height;
454 gtk_progress_get_format_string (GtkProgress *progress)
456 return progress->format;
460 gtk_progress_get_adjustment (GtkProgress *progress)
462 return progress->adjustment;
466 /* Scrolled window */
469 gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *window)
471 return window->hscrollbar;
475 gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *window)
477 return window->vscrollbar;
485 gtk_tooltips_get_delay (GtkTooltips *tooltips)
487 return tooltips->delay;
491 gtk_tooltips_get_enabled (GtkTooltips *tooltips)
493 return tooltips->enabled;
497 /* GtkStyle accessor functions */
512 gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
517 case GTK_COLOR_WHITE:
518 return &style->white;
519 case GTK_COLOR_BLACK:
520 return &style->black;
522 return &style->fg[state];
524 return &style->bg[state];
525 case GTK_COLOR_LIGHT:
526 return &style->light[state];
528 return &style->dark[state];
530 return &style->mid[state];
532 return &style->text[state];
534 return &style->base[state];
540 gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
541 GtkStateType state, GdkColor *color)
545 case GTK_COLOR_WHITE:
546 style->white = *color; break;
547 case GTK_COLOR_BLACK:
548 style->black = *color; break;
550 style->fg[state] = *color; break;
552 style->bg[state] = *color; break;
553 case GTK_COLOR_LIGHT:
554 style->light[state] = *color; break;
556 style->dark[state] = *color; break;
558 style->mid[state] = *color; break;
560 style->text[state] = *color; break;
562 style->base[state] = *color; break;
565 return gtk_style_get_color (style, color_type, state);
570 gtk_style_get_font (GtkStyle *style)
577 gtk_style_set_font (GtkStyle *style, GdkFont *font)
579 return style->font = font;
584 gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
588 case GTK_COLOR_WHITE:
589 return style->white_gc;
590 case GTK_COLOR_BLACK:
591 return style->black_gc;
593 return style->fg_gc[state];
595 return style->bg_gc[state];
596 case GTK_COLOR_LIGHT:
597 return style->light_gc[state];
599 return style->dark_gc[state];
601 return style->mid_gc[state];
603 return style->text_gc[state];
605 return style->base_gc[state];