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.4 2000-11-09 20:30:16 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_tree_item_get_subtree (GtkTreeItem* tree_item)
136 return GTK_TREE_ITEM_SUBTREE (tree_item);
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;
238 gtk_clist_selection (GtkCList *clist)
240 return clist->selection;
244 gtk_clist_get_titles_visible (GtkCList *clist)
246 return (clist->title_window && GTK_WIDGET_VISIBLE (clist->title_window));
250 gtk_clist_get_n_rows (GtkCList *clist)
256 gtk_clist_get_focus_row (GtkCList *clist)
258 return clist->focus_row;
262 gtk_clist_get_sort_column (GtkCList *clist)
264 return clist->sort_column;
268 gtk_clist_column_justification (GtkCList *clist,
271 return clist->column[column].justification;
275 gtk_clist_column_visible_p (GtkCList *clist,
278 return clist->column[column].visible;
282 gtk_clist_column_resizeable_p (GtkCList *clist,
285 return clist->column[column].resizeable;
289 gtk_clist_column_auto_resize_p (GtkCList *clist,
292 return clist->column[column].auto_resize;
296 gtk_clist_column_width (GtkCList *clist,
299 return clist->column[column].width;
303 gtk_clist_auto_sort_p (GtkCList *clist)
305 return GTK_CLIST_AUTO_SORT (clist);
313 gtk_ctree_node_leaf_p (GtkCTreeNode* node)
315 return GTK_CTREE_ROW (node)->is_leaf;
319 gtk_ctree_node_child (GtkCTreeNode* node)
321 return GTK_CTREE_ROW (node)->children;
325 gtk_ctree_node_parent (GtkCTreeNode* node)
327 return GTK_CTREE_ROW (node)->parent;
331 gtk_ctree_node_sibling (GtkCTreeNode* node)
333 return GTK_CTREE_ROW (node)->sibling;
337 gtk_ctree_node_level (GtkCTreeNode* node)
339 return GTK_CTREE_ROW (node)->level;
346 gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
348 *resize = paned->child1_resize;
349 *shrink = paned->child1_shrink;
351 return paned->child1;
356 gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
358 *resize = paned->child2_resize;
359 *shrink = paned->child2_shrink;
361 return paned->child2;
365 gtk_paned_get_position (GtkPaned *paned)
367 if (paned->position_set == TRUE)
368 return paned->child1_size;
377 gtk_layout_get_size (GtkLayout *layout, gint *width, gint *height)
380 *width = layout->width;
381 *height = layout->height;
385 gtk_layout_get_bin_window (GtkLayout *layout)
387 return layout->bin_window;
394 gtk_list_selection (GtkList *list)
396 return list->selection;
403 gtk_menu_get_tearoff_state (GtkMenu *menu)
405 return menu->torn_off;
409 gtk_menu_get_title (GtkMenu *menu)
411 return g_strdup (gtk_object_get_data (GTK_OBJECT (menu), "gtk-menu-title"));
418 gtk_table_row_spacing (GtkTable *table,
421 return table->rows[row].spacing;
425 gtk_table_column_spacing (GtkTable *table,
428 return table->cols[col].spacing;
435 gtk_toolbar_num_children (GtkToolbar *toolbar)
437 return toolbar->num_children;
441 gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
443 return toolbar->tooltips->enabled;
450 gtk_tree_get_selection_mode (GtkTree *tree)
452 return tree->selection_mode;
456 gtk_tree_get_view_mode (GtkTree *tree)
458 return tree->view_mode;
462 gtk_tree_get_view_lines (GtkTree *tree)
464 return tree->view_mode;
468 gtk_tree_get_root_tree (GtkTree *tree)
470 return GTK_TREE_ROOT_TREE (tree);
474 gtk_tree_selection (GtkTree *tree)
476 return GTK_TREE_SELECTION (tree);
483 gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
487 widget = GTK_WIDGET (darea);
488 *width = widget->allocation.width;
489 *height = widget->allocation.height;
496 gtk_progress_get_format_string (GtkProgress *progress)
498 return progress->format;
502 gtk_progress_get_adjustment (GtkProgress *progress)
504 return progress->adjustment;
508 /* Scrolled window */
511 gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow *window)
513 return window->hscrollbar;
517 gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow *window)
519 return window->vscrollbar;
527 gtk_tooltips_get_delay (GtkTooltips *tooltips)
529 return tooltips->delay;
533 gtk_tooltips_get_enabled (GtkTooltips *tooltips)
535 return tooltips->enabled;
539 /* GtkStyle accessor functions */
554 gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
559 case GTK_COLOR_WHITE:
560 return &style->white;
561 case GTK_COLOR_BLACK:
562 return &style->black;
564 return &style->fg[state];
566 return &style->bg[state];
567 case GTK_COLOR_LIGHT:
568 return &style->light[state];
570 return &style->dark[state];
572 return &style->mid[state];
574 return &style->text[state];
576 return &style->base[state];
582 gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
583 GtkStateType state, GdkColor *color)
587 case GTK_COLOR_WHITE:
588 style->white = *color; break;
589 case GTK_COLOR_BLACK:
590 style->black = *color; break;
592 style->fg[state] = *color; break;
594 style->bg[state] = *color; break;
595 case GTK_COLOR_LIGHT:
596 style->light[state] = *color; break;
598 style->dark[state] = *color; break;
600 style->mid[state] = *color; break;
602 style->text[state] = *color; break;
604 style->base[state] = *color; break;
607 return gtk_style_get_color (style, color_type, state);
612 gtk_style_get_font (GtkStyle *style)
619 gtk_style_set_font (GtkStyle *style, GdkFont *font)
621 return style->font = font;
626 gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
630 case GTK_COLOR_WHITE:
631 return style->white_gc;
632 case GTK_COLOR_BLACK:
633 return style->black_gc;
635 return style->fg_gc[state];
637 return style->bg_gc[state];
638 case GTK_COLOR_LIGHT:
639 return style->light_gc[state];
641 return style->dark_gc[state];
643 return style->mid_gc[state];
645 return style->text_gc[state];
647 return style->base_gc[state];