Removed obsoleted code and added a few accessor functions
[clg] / gtk / gtkglue.c
1 /* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2000 Espen S. Johnsen <esj@stud.cs.uit.no>
3 *
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.
8 *
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.
13 *
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
17 */
18
19 /* $Id: gtkglue.c,v 1.7 2001-10-21 23:22:53 espen Exp $ */
20
21
22 #include <gtk/gtk.h>
23
24
25 /*
26 *
27 * Gtk helper functions
28 *
29 */
30
31 void
32 gtk_query_version (guint *major, guint *minor, guint *micro)
33 {
34 *major = gtk_major_version;
35 *minor = gtk_minor_version;
36 *micro = gtk_micro_version;
37 }
38
39
40 /* Is this necessary? */
41
42 GtkType
43 gtk_object_type (GtkObject *obj)
44 {
45 return GTK_OBJECT_TYPE (obj);
46 }
47
48
49
50 /* Widget */
51
52 GdkWindow*
53 gtk_widget_get_window (GtkWidget *widget)
54 {
55 return widget->window;
56 }
57
58 GtkStateType
59 gtk_widget_get_state (GtkWidget *widget)
60 {
61 return widget->state;
62 }
63
64 gboolean
65 gtk_widget_mapped_p (GtkWidget *widget)
66 {
67 return GTK_WIDGET_MAPPED (widget);
68 }
69
70 void
71 gtk_widget_allocation (GtkWidget *widget, int *width, int *height)
72 {
73 *width = widget->allocation.width;
74 *height = widget->allocation.height;
75 }
76
77
78 /* Container */
79
80 GtkWidget*
81 gtk_container_get_focus_child (GtkContainer *container)
82 {
83 return container->focus_child;
84 }
85
86
87 /* Dialog */
88
89 GtkWidget*
90 gtk_dialog_get_vbox (GtkDialog *dialog)
91 {
92 return dialog->vbox;
93 }
94
95 GtkWidget*
96 gtk_dialog_get_action_area (GtkDialog *dialog)
97 {
98 return dialog->action_area;
99 }
100
101
102
103 /* Menu item */
104
105 GtkSubmenuPlacement
106 gtk_menu_item_get_placement (GtkMenuItem* menu_item)
107 {
108 return menu_item->submenu_placement;
109 }
110
111 gint
112 gtk_menu_item_get_show_submenu (GtkMenuItem* menu_item)
113 {
114 return menu_item->show_submenu_indicator;
115 }
116
117 void
118 gtk_menu_item_set_show_submenu (GtkMenuItem* menu_item, guint show)
119 {
120 menu_item->show_submenu_indicator = show;
121 }
122
123
124
125 /* Check menu item */
126
127 gboolean
128 gtk_check_menu_item_get_active (GtkCheckMenuItem* check_menu_item)
129 {
130 return check_menu_item->active;
131 }
132
133 gboolean
134 gtk_check_menu_item_get_show_toggle (GtkCheckMenuItem* check_menu_item)
135 {
136 return check_menu_item->always_show_toggle;
137 }
138
139
140 /* Window */
141
142 void
143 gtk_window_wmclass (GtkWindow* window, gchar* name, gchar* class)
144 {
145 name = window->wmclass_name;
146 class = window->wmclass_class;
147 }
148
149
150 /* File selection */
151
152 GtkWidget*
153 gtk_file_selection_get_action_area (GtkFileSelection *filesel)
154 {
155 return filesel->action_area;
156 }
157
158 GtkWidget*
159 gtk_file_selection_get_ok_button (GtkFileSelection *filesel)
160 {
161 return filesel->ok_button;
162 }
163
164 GtkWidget*
165 gtk_file_selection_get_cancel_button (GtkFileSelection *filesel)
166 {
167 return filesel->cancel_button;
168 }
169
170
171 /* Color selection */
172
173 gtk_color_selection_set_color_by_values (GtkColorSelection *colorsel,
174 gdouble red,
175 gdouble green,
176 gdouble blue,
177 gdouble opacity)
178 {
179 gdouble color[4];
180
181 color[0] = red;
182 color[1] = green;
183 color[2] = blue;
184 color[3] = opacity;
185
186 gtk_color_selection_set_color (colorsel, color);
187 }
188
189 void
190 gtk_color_selection_get_color_as_values (GtkColorSelection *colorsel,
191 gdouble *red,
192 gdouble *green,
193 gdouble *blue,
194 gdouble *opacity)
195 {
196 gdouble color[4];
197
198 gtk_color_selection_get_color (colorsel, color);
199
200 *red = color[0];
201 *green = color[1];
202 *blue = color[2];
203 *opacity = color[3];
204 }
205
206
207 /* Combo */
208
209 GtkWidget*
210 gtk_combo_get_entry (GtkCombo *combo)
211 {
212 return combo->entry;
213 }
214
215 gboolean
216 gtk_combo_get_use_arrows (GtkCombo *combo)
217 {
218 return combo->use_arrows;
219 }
220
221 gboolean
222 gtk_combo_get_use_arrows_always (GtkCombo *combo)
223 {
224 return combo->use_arrows_always;
225 }
226
227 gboolean
228 gtk_combo_get_case_sensitive (GtkCombo *combo)
229 {
230 return combo->case_sensitive;
231 }
232
233
234 /* Paned */
235
236 GtkWidget*
237 gtk_paned_child1 (GtkPaned *paned, guint *resize, guint *shrink)
238 {
239 *resize = paned->child1_resize;
240 *shrink = paned->child1_shrink;
241
242 return paned->child1;
243 }
244
245
246 GtkWidget*
247 gtk_paned_child2 (GtkPaned *paned, guint *resize, guint *shrink)
248 {
249 *resize = paned->child2_resize;
250 *shrink = paned->child2_shrink;
251
252 return paned->child2;
253 }
254
255 gint
256 gtk_paned_get_position (GtkPaned *paned)
257 {
258 if (paned->position_set == TRUE)
259 return paned->child1_size;
260 else
261 return -1;
262 }
263
264
265 /* Layout */
266
267 GdkWindow*
268 gtk_layout_get_bin_window (GtkLayout *layout)
269 {
270 return layout->bin_window;
271 }
272
273 guint
274 gtk_layout_get_xoffset (GtkLayout *layout)
275 {
276 return layout->xoffset;
277 }
278
279 void
280 gtk_layout_set_xoffset (GtkLayout *layout, guint xoffset)
281 {
282 return layout->xoffset = xoffset;
283 }
284
285 guint
286 gtk_layout_get_yoffset (GtkLayout *layout)
287 {
288 return layout->yoffset;
289 }
290
291 void
292 gtk_layout_set_yoffset (GtkLayout *layout, guint yoffset)
293 {
294 return layout->yoffset = yoffset;
295 }
296
297 /* List */
298
299 GList*
300 gtk_list_selection (GtkList *list)
301 {
302 return list->selection;
303 }
304
305
306
307 /* Toolbar */
308
309 gint
310 gtk_toolbar_num_children (GtkToolbar *toolbar)
311 {
312 return toolbar->num_children;
313 }
314
315 gint
316 gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
317 {
318 return toolbar->tooltips->enabled;
319 }
320
321
322 /* Drawing area */
323
324 void
325 gtk_drawing_area_get_size (GtkDrawingArea *darea, gint *width, gint *height)
326 {
327 GtkWidget *widget;
328
329 widget = GTK_WIDGET (darea);
330 *width = widget->allocation.width;
331 *height = widget->allocation.height;
332 }
333
334
335 /* Progress */
336
337 gchar*
338 gtk_progress_get_format_string (GtkProgress *progress)
339 {
340 return progress->format;
341 }
342
343 GtkAdjustment*
344 gtk_progress_get_adjustment (GtkProgress *progress)
345 {
346 return progress->adjustment;
347 }
348
349
350 /* Tooltips */
351
352 gboolean
353 gtk_tooltips_get_enabled (GtkTooltips *tooltips)
354 {
355 return tooltips->enabled;
356 }
357
358
359 /* GtkStyle accessor functions */
360
361 typedef enum {
362 GTK_COLOR_FG,
363 GTK_COLOR_BG,
364 GTK_COLOR_LIGHT,
365 GTK_COLOR_DARK,
366 GTK_COLOR_MID,
367 GTK_COLOR_TEXT,
368 GTK_COLOR_BASE,
369 GTK_COLOR_WHITE,
370 GTK_COLOR_BLACK
371 } GtkColorType;
372
373 GdkColor*
374 gtk_style_get_color (GtkStyle *style, GtkColorType color_type,
375 GtkStateType state)
376 {
377 switch (color_type)
378 {
379 case GTK_COLOR_WHITE:
380 return &style->white;
381 case GTK_COLOR_BLACK:
382 return &style->black;
383 case GTK_COLOR_FG:
384 return &style->fg[state];
385 case GTK_COLOR_BG:
386 return &style->bg[state];
387 case GTK_COLOR_LIGHT:
388 return &style->light[state];
389 case GTK_COLOR_DARK:
390 return &style->dark[state];
391 case GTK_COLOR_MID:
392 return &style->mid[state];
393 case GTK_COLOR_TEXT:
394 return &style->text[state];
395 case GTK_COLOR_BASE:
396 return &style->base[state];
397 }
398 }
399
400
401 GdkColor*
402 gtk_style_set_color (GtkStyle *style, GtkColorType color_type,
403 GtkStateType state, GdkColor *color)
404 {
405 switch (color_type)
406 {
407 case GTK_COLOR_WHITE:
408 style->white = *color; break;
409 case GTK_COLOR_BLACK:
410 style->black = *color; break;
411 case GTK_COLOR_FG:
412 style->fg[state] = *color; break;
413 case GTK_COLOR_BG:
414 style->bg[state] = *color; break;
415 case GTK_COLOR_LIGHT:
416 style->light[state] = *color; break;
417 case GTK_COLOR_DARK:
418 style->dark[state] = *color; break;
419 case GTK_COLOR_MID:
420 style->mid[state] = *color; break;
421 case GTK_COLOR_TEXT:
422 style->text[state] = *color; break;
423 case GTK_COLOR_BASE:
424 style->base[state] = *color; break;
425 }
426
427 return gtk_style_get_color (style, color_type, state);
428 }
429
430 /*
431 GdkFont*
432 gtk_style_get_font (GtkStyle *style)
433 {
434 return style->font;
435 }
436
437
438 GdkFont*
439 gtk_style_set_font (GtkStyle *style, GdkFont *font)
440 {
441 return style->font = font;
442 }
443 */
444
445 GdkGC*
446 gtk_style_get_gc (GtkStyle *style, GtkColorType color_type, GtkStateType state)
447 {
448 switch (color_type)
449 {
450 case GTK_COLOR_WHITE:
451 return style->white_gc;
452 case GTK_COLOR_BLACK:
453 return style->black_gc;
454 case GTK_COLOR_FG:
455 return style->fg_gc[state];
456 case GTK_COLOR_BG:
457 return style->bg_gc[state];
458 case GTK_COLOR_LIGHT:
459 return style->light_gc[state];
460 case GTK_COLOR_DARK:
461 return style->dark_gc[state];
462 case GTK_COLOR_MID:
463 return style->mid_gc[state];
464 case GTK_COLOR_TEXT:
465 return style->text_gc[state];
466 case GTK_COLOR_BASE:
467 return style->base_gc[state];
468 }
469 }