1 /* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2000 Espen S. Johnsen <espejohn@online.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.2 2000-08-15 19:41:26 espen Exp $ */
27 extern lispobj
funcall1(lispobj function
, lispobj arg0
);
28 extern lispobj
funcall3(lispobj function
, lispobj arg0
,
29 lispobj arg1
, lispobj arg2
);
31 lispobj callback_trampoline
;
32 lispobj destroy_user_data
;
36 void callback_marshal (GtkObject
*object
,
42 funcall3 (callback_trampoline
, alloc_number ((unsigned long)data
),
43 alloc_number (n_args
), alloc_sap (args
));
45 /* lispobj lisp_args[4];
47 lisp_args[0] = alloc_sap (object);
48 lisp_args[1] = alloc_number ((unsigned long)data);
49 lisp_args[2] = alloc_number (n_args);
50 lisp_args[3] = alloc_sap (args);
52 call_into_lisp (callback_trampoline, lisp_args, 4);*/
54 callback_trampoline ((unsigned long)data
, n_args
, (unsigned int) args
);
59 void destroy_marshal (gpointer data
)
62 funcall1 (destroy_user_data
, alloc_number ((unsigned long)data
));
64 destroy_user_data ((unsigned long)data
);
70 callback_marshal_address ()
72 return (void*)callback_marshal
;
76 destroy_marshal_address ()
78 return (void*)destroy_marshal
;
85 * Gtk helper functions
90 gtk_query_version (guint
*major
, guint
*minor
, guint
*micro
)
92 *major
= gtk_major_version
;
93 *minor
= gtk_minor_version
;
94 *micro
= gtk_micro_version
;
98 /* Is this necessary? */
101 gtk_object_type (GtkObject
*obj
)
103 return GTK_OBJECT_TYPE (obj
);
111 gtk_widget_get_window (GtkWidget
*widget
)
113 return widget
->window
;
117 gtk_widget_get_state (GtkWidget
*widget
)
119 return widget
->state
;
123 gtk_widget_mapped_p (GtkWidget
*widget
)
125 return GTK_WIDGET_MAPPED (widget
);
129 gtk_widget_allocation (GtkWidget
*widget
, int *width
, int *height
)
131 *width
= widget
->allocation
.width
;
132 *height
= widget
->allocation
.height
;
139 gtk_container_get_focus_child (GtkContainer
*container
)
141 return container
->focus_child
;
149 gtk_menu_item_get_submenu (GtkMenuItem
* menu_item
)
151 return menu_item
->submenu
;
155 gtk_menu_item_get_placement (GtkMenuItem
* menu_item
)
157 return menu_item
->submenu_placement
;
161 gtk_menu_item_get_show_toggle (GtkMenuItem
* menu_item
)
163 return menu_item
->show_toggle_indicator
;
167 gtk_menu_item_get_show_submenu (GtkMenuItem
* menu_item
)
169 return menu_item
->show_submenu_indicator
;
174 /* Check menu item */
177 gtk_check_menu_item_get_active (GtkCheckMenuItem
* check_menu_item
)
179 return check_menu_item
->active
;
183 gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem
* check_menu_item
)
185 return check_menu_item
->always_show_toggle
;
192 gtk_tree_item_get_subtree (GtkTreeItem
* tree_item
)
194 return GTK_TREE_ITEM_SUBTREE (tree_item
);
201 gtk_window_wmclass (GtkWindow
* window
, gchar
* name
, gchar
* class)
203 name
= window
->wmclass_name
;
204 class = window
->wmclass_class
;
208 /* Color selection dialog */
211 gtk_color_selection_dialog_get_colorsel (GtkColorSelectionDialog
* dialog
)
213 return dialog
->colorsel
;
217 /* gtk_color_selection_dialog_get_main_vbox (GtkColorSelectionDialog* dialog) */
219 /* return dialog->main_vbox; */
223 gtk_color_selection_dialog_get_ok_button (GtkColorSelectionDialog
* dialog
)
225 return dialog
->ok_button
;
229 /* gtk_color_selection_dialog_get_reset_button (GtkColorSelectionDialog* dialog) */
231 /* return dialog->reset_button; */
235 gtk_color_selection_dialog_get_cancel_button (GtkColorSelectionDialog
* dialog
)
237 return dialog
->cancel_button
;
241 gtk_color_selection_dialog_get_help_button (GtkColorSelectionDialog
* dialog
)
243 return dialog
->help_button
;
250 gtk_dialog_get_action_area (GtkDialog
*dialog
)
252 return dialog
->action_area
;
257 gtk_dialog_get_vbox (GtkDialog
*dialog
)
266 gtk_file_selection_get_action_area (GtkFileSelection
*filesel
)
268 return filesel
->action_area
;
272 gtk_file_selection_get_ok_button (GtkFileSelection
*filesel
)
274 return filesel
->ok_button
;
278 gtk_file_selection_get_cancel_button (GtkFileSelection
*filesel
)
280 return filesel
->cancel_button
;
284 /* Color selection */
287 gtk_color_selection_set_color_by_values (GtkColorSelection
*colorsel
,
300 gtk_color_selection_set_color (colorsel
, color
);
304 gtk_color_selection_get_color_as_values (GtkColorSelection
*colorsel
,
312 gtk_color_selection_get_color (colorsel
, color
);
324 gtk_combo_get_entry (GtkCombo
*combo
)
330 gtk_combo_get_use_arrows (GtkCombo
*combo
)
332 return combo
->use_arrows
;
336 gtk_combo_get_use_arrows_always (GtkCombo
*combo
)
338 return combo
->use_arrows_always
;
342 gtk_combo_get_case_sensitive (GtkCombo
*combo
)
344 return combo
->case_sensitive
;
352 gtk_clist_selection (GtkCList
*clist
)
354 return clist
->selection
;
358 gtk_clist_get_titles_visible (GtkCList
*clist
)
360 return (clist
->title_window
&& GTK_WIDGET_VISIBLE (clist
->title_window
));
364 gtk_clist_get_n_rows (GtkCList
*clist
)
370 gtk_clist_get_focus_row (GtkCList
*clist
)
372 return clist
->focus_row
;
376 gtk_clist_get_sort_column (GtkCList
*clist
)
378 return clist
->sort_column
;
382 gtk_clist_column_justification (GtkCList
*clist
,
385 return clist
->column
[column
].justification
;
389 gtk_clist_column_visible_p (GtkCList
*clist
,
392 return clist
->column
[column
].visible
;
396 gtk_clist_column_resizeable_p (GtkCList
*clist
,
399 return clist
->column
[column
].resizeable
;
403 gtk_clist_column_auto_resize_p (GtkCList
*clist
,
406 return clist
->column
[column
].auto_resize
;
410 gtk_clist_column_width (GtkCList
*clist
,
413 return clist
->column
[column
].width
;
417 gtk_clist_auto_sort_p (GtkCList
*clist
)
419 return GTK_CLIST_AUTO_SORT (clist
);
427 gtk_ctree_node_leaf_p (GtkCTreeNode
* node
)
429 return GTK_CTREE_ROW (node
)->is_leaf
;
433 gtk_ctree_node_child (GtkCTreeNode
* node
)
435 return GTK_CTREE_ROW (node
)->children
;
439 gtk_ctree_node_parent (GtkCTreeNode
* node
)
441 return GTK_CTREE_ROW (node
)->parent
;
445 gtk_ctree_node_sibling (GtkCTreeNode
* node
)
447 return GTK_CTREE_ROW (node
)->sibling
;
451 gtk_ctree_node_level (GtkCTreeNode
* node
)
453 return GTK_CTREE_ROW (node
)->level
;
460 gtk_paned_child1 (GtkPaned
*paned
, guint
*resize
, guint
*shrink
)
462 *resize
= paned
->child1_resize
;
463 *shrink
= paned
->child1_shrink
;
465 return paned
->child1
;
470 gtk_paned_child2 (GtkPaned
*paned
, guint
*resize
, guint
*shrink
)
472 *resize
= paned
->child2_resize
;
473 *shrink
= paned
->child2_shrink
;
475 return paned
->child2
;
479 gtk_paned_get_position (GtkPaned
*paned
)
481 if (paned
->position_set
== TRUE
)
482 return paned
->child1_size
;
491 gtk_layout_size (GtkLayout
*layout
, gint
*width
, gint
*height
)
494 *width
= layout
->width
;
495 *height
= layout
->height
;
499 gtk_layout_offset (GtkLayout
*layout
, gint
*x
, gint
*y
)
501 *x
= layout
->xoffset
;
502 *y
= layout
->yoffset
;
507 gtk_layout_get_bin_window (GtkLayout
*layout
)
509 return layout
->bin_window
;
516 gtk_list_selection (GtkList
*list
)
518 return list
->selection
;
525 gtk_menu_get_tearoff_state (GtkMenu
*menu
)
527 return menu
->torn_off
;
531 gtk_menu_get_title (GtkMenu
*menu
)
533 return g_strdup (gtk_object_get_data (GTK_OBJECT (menu
), "gtk-menu-title"));
540 gtk_table_row_spacing (GtkTable
*table
,
543 return table
->rows
[row
].spacing
;
547 gtk_table_column_spacing (GtkTable
*table
,
550 return table
->cols
[col
].spacing
;
557 gtk_toolbar_num_children (GtkToolbar
*toolbar
)
559 return toolbar
->num_children
;
563 gtk_toolbar_get_tooltips (GtkToolbar
*toolbar
)
565 return toolbar
->tooltips
->enabled
;
572 gtk_tree_get_selection_mode (GtkTree
*tree
)
574 return tree
->selection_mode
;
578 gtk_tree_get_view_mode (GtkTree
*tree
)
580 return tree
->view_mode
;
584 gtk_tree_get_view_lines (GtkTree
*tree
)
586 return tree
->view_mode
;
590 gtk_tree_get_root_tree (GtkTree
*tree
)
592 return GTK_TREE_ROOT_TREE (tree
);
596 gtk_tree_selection (GtkTree
*tree
)
598 return GTK_TREE_SELECTION (tree
);
605 gtk_drawing_area_get_size (GtkDrawingArea
*darea
, gint
*width
, gint
*height
)
609 widget
= GTK_WIDGET (darea
);
610 *width
= widget
->allocation
.width
;
611 *height
= widget
->allocation
.height
;
618 gtk_progress_get_format_string (GtkProgress
*progress
)
620 return progress
->format
;
624 gtk_progress_get_adjustment (GtkProgress
*progress
)
626 return progress
->adjustment
;
630 /* Scrolled window */
633 gtk_scrolled_window_get_hscrollbar (GtkScrolledWindow
*window
)
635 return window
->hscrollbar
;
639 gtk_scrolled_window_get_vscrollbar (GtkScrolledWindow
*window
)
641 return window
->vscrollbar
;
649 gtk_tooltips_get_delay (GtkTooltips
*tooltips
)
651 return tooltips
->delay
;
655 gtk_tooltips_get_enabled (GtkTooltips
*tooltips
)
657 return tooltips
->enabled
;
661 /* GtkStyle accessor functions */
676 gtk_style_get_color (GtkStyle
*style
, GtkColorType color_type
,
681 case GTK_COLOR_WHITE
:
682 return &style
->white
;
683 case GTK_COLOR_BLACK
:
684 return &style
->black
;
686 return &style
->fg
[state
];
688 return &style
->bg
[state
];
689 case GTK_COLOR_LIGHT
:
690 return &style
->light
[state
];
692 return &style
->dark
[state
];
694 return &style
->mid
[state
];
696 return &style
->text
[state
];
698 return &style
->base
[state
];
704 gtk_style_set_color (GtkStyle
*style
, GtkColorType color_type
,
705 GtkStateType state
, GdkColor
*color
)
709 case GTK_COLOR_WHITE
:
710 style
->white
= *color
; break;
711 case GTK_COLOR_BLACK
:
712 style
->black
= *color
; break;
714 style
->fg
[state
] = *color
; break;
716 style
->bg
[state
] = *color
; break;
717 case GTK_COLOR_LIGHT
:
718 style
->light
[state
] = *color
; break;
720 style
->dark
[state
] = *color
; break;
722 style
->mid
[state
] = *color
; break;
724 style
->text
[state
] = *color
; break;
726 style
->base
[state
] = *color
; break;
729 return gtk_style_get_color (style
, color_type
, state
);
734 gtk_style_get_font (GtkStyle
*style
)
741 gtk_style_set_font (GtkStyle
*style
, GdkFont
*font
)
743 return style
->font
= font
;
748 gtk_style_get_gc (GtkStyle
*style
, GtkColorType color_type
, GtkStateType state
)
752 case GTK_COLOR_WHITE
:
753 return style
->white_gc
;
754 case GTK_COLOR_BLACK
:
755 return style
->black_gc
;
757 return style
->fg_gc
[state
];
759 return style
->bg_gc
[state
];
760 case GTK_COLOR_LIGHT
:
761 return style
->light_gc
[state
];
763 return style
->dark_gc
[state
];
765 return style
->mid_gc
[state
];
767 return style
->text_gc
[state
];
769 return style
->base_gc
[state
];