Mercurial > hg > xemacs-beta
annotate src/ui-byhand.c @ 5287:cd167465bf69
More permission consistency.
author | Stephen J. Turnbull <stephen@xemacs.org> |
---|---|
date | Mon, 14 Jun 2010 15:03:08 +0900 |
parents | ba07c880114a |
children | b9167d522a9a |
rev | line source |
---|---|
5287
cd167465bf69
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5231
diff
changeset
|
1 /* ui-byhand.c --- hand-coded GTK functions |
cd167465bf69
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5231
diff
changeset
|
2 |
cd167465bf69
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5231
diff
changeset
|
3 Copyright (C) 2000, 2001 William M. Perry |
cd167465bf69
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5231
diff
changeset
|
4 |
cd167465bf69
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5231
diff
changeset
|
5 I really wish this entire file could go away, but there is |
462 | 6 currently no way to do the following in the Foreign Function |
7 Interface: | |
8 | |
9 1) Deal with return values in the parameter list (ie: int *foo) | |
10 | |
11 So we have to code a few functions by hand. Ick. | |
12 | |
13 William M. Perry 5/8/00 | |
4709
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
14 |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
15 This file is part of XEmacs. |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
16 |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
17 XEmacs is free software; you can redistribute it and/or modify it |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
18 under the terms of the GNU General Public License as published by the |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
19 Free Software Foundation; either version 2, or (at your option) any |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
20 later version. |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
21 |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
22 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
23 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
24 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
25 for more details. |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
26 |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
27 You should have received a copy of the GNU General Public License |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
28 along with XEmacs; see the file COPYING. If not, write to |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
2367
diff
changeset
|
29 the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, |
5231
ba07c880114a
Fix up FSF's Franklin Street address in many files.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5013
diff
changeset
|
30 Boston, MA 02110-1301, USA. |
462 | 31 */ |
32 | |
33 #include "gui.h" | |
34 | |
35 DEFUN ("gtk-box-query-child-packing", Fgtk_box_query_child_packing, 2, 2,0, /* | |
36 Returns information about how CHILD is packed into BOX. | |
37 Return value is a list of (EXPAND FILL PADDING PACK_TYPE). | |
38 */ | |
39 (box, child)) | |
40 { | |
41 gboolean expand, fill; | |
42 guint padding; | |
43 GtkPackType pack_type; | |
44 Lisp_Object result = Qnil; | |
45 | |
46 CHECK_GTK_OBJECT (box); | |
47 CHECK_GTK_OBJECT (child); | |
48 | |
49 if (!GTK_IS_BOX (XGTK_OBJECT (box)->object)) | |
50 { | |
563 | 51 wtaerror ("Object is not a GtkBox", box); |
462 | 52 } |
53 | |
54 if (!GTK_IS_WIDGET (XGTK_OBJECT (child)->object)) | |
55 { | |
563 | 56 wtaerror ("Child is not a GtkWidget", child); |
462 | 57 } |
58 | |
59 gtk_box_query_child_packing (GTK_BOX (XGTK_OBJECT (box)->object), | |
60 GTK_WIDGET (XGTK_OBJECT (child)->object), | |
61 &expand, &fill, &padding, &pack_type); | |
62 | |
63 result = Fcons (make_int (pack_type), result); | |
64 result = Fcons (make_int (padding), result); | |
65 result = Fcons (fill ? Qt : Qnil, result); | |
66 result = Fcons (expand ? Qt : Qnil, result); | |
67 | |
68 return (result); | |
69 } | |
70 | |
71 /* void gtk_button_box_get_child_size_default (gint *min_width, gint *min_height); */ | |
72 DEFUN ("gtk-button-box-get-child-size-default", | |
73 Fgtk_button_box_get_child_size_default, 0, 0, 0, /* | |
74 Return a cons cell (WIDTH . HEIGHT) of the default button box child size. | |
75 */ | |
76 ()) | |
77 { | |
78 gint width, height; | |
79 | |
80 gtk_button_box_get_child_size_default (&width, &height); | |
81 | |
82 return (Fcons (make_int (width), make_int (height))); | |
83 } | |
84 | |
85 /* void gtk_button_box_get_child_ipadding_default (gint *ipad_x, gint *ipad_y); */ | |
86 DEFUN ("gtk-button-box-get-child-ipadding-default", | |
87 Fgtk_button_box_get_child_ipadding_default, 0, 0, 0, /* | |
88 Return a cons cell (X . Y) of the default button box ipadding. | |
89 */ | |
90 ()) | |
91 { | |
92 gint x, y; | |
93 | |
94 gtk_button_box_get_child_ipadding_default (&x, &y); | |
95 | |
96 return (Fcons (make_int (x), make_int (y))); | |
97 } | |
98 | |
99 /* void gtk_button_box_get_child_size (GtkButtonBox *widget, | |
100 gint *min_width, gint *min_height); */ | |
101 DEFUN ("gtk-button-box-get-child-size", Fgtk_button_box_get_child_size, 1, 1, 0, /* | |
102 Get the current size of a child in the buttonbox BOX. | |
103 */ | |
104 (box)) | |
105 { | |
106 gint width, height; | |
107 | |
108 CHECK_GTK_OBJECT (box); | |
109 | |
110 if (!GTK_IS_BUTTON_BOX (XGTK_OBJECT (box)->object)) | |
111 { | |
563 | 112 wtaerror ("Not a GtkBox object", box); |
462 | 113 } |
114 | |
115 gtk_button_box_get_child_size (GTK_BUTTON_BOX (XGTK_OBJECT (box)->object), | |
116 &width, &height); | |
117 | |
118 return (Fcons (make_int (width), make_int (height))); | |
119 } | |
120 | |
121 /* void gtk_button_box_get_child_ipadding (GtkButtonBox *widget, gint *ipad_x, gint *ipad_y); */ | |
122 DEFUN ("gtk-button-box-get-child-ipadding", | |
123 Fgtk_button_box_get_child_ipadding, 1, 1, 0, /* | |
124 Return a cons cell (X . Y) of the current buttonbox BOX ipadding. | |
125 */ | |
126 (box)) | |
127 { | |
128 gint x, y; | |
129 | |
130 CHECK_GTK_OBJECT (box); | |
131 | |
132 if (!GTK_IS_BUTTON_BOX (XGTK_OBJECT (box)->object)) | |
133 { | |
563 | 134 wtaerror ("Not a GtkBox object", box); |
462 | 135 } |
136 | |
137 gtk_button_box_get_child_ipadding (GTK_BUTTON_BOX (XGTK_OBJECT (box)->object), | |
138 &x, &y); | |
139 | |
140 return (Fcons (make_int (x), make_int (y))); | |
141 } | |
142 | |
143 /*void gtk_calendar_get_date (GtkCalendar *calendar, | |
144 guint *year, | |
145 guint *month, | |
146 guint *day); | |
147 */ | |
148 DEFUN ("gtk-calendar-get-date", Fgtk_calendar_get_date, 1, 1, 0, /* | |
149 Return a list of (YEAR MONTH DAY) from the CALENDAR object. | |
150 */ | |
151 (calendar)) | |
152 { | |
153 guint year, month, day; | |
154 | |
155 CHECK_GTK_OBJECT (calendar); | |
156 | |
157 if (!GTK_IS_CALENDAR (XGTK_OBJECT (calendar)->object)) | |
158 { | |
563 | 159 wtaerror ("Not a GtkCalendar object", calendar); |
462 | 160 } |
161 | |
162 gtk_calendar_get_date (GTK_CALENDAR (XGTK_OBJECT (calendar)->object), | |
163 &year, &month, &day); | |
164 | |
165 return (list3 (make_int (year), make_int (month), make_int (day))); | |
166 } | |
167 | |
168 /* gint gtk_clist_get_text (GtkCList *clist, | |
169 gint row, | |
170 gint column, | |
171 gchar **text); | |
172 */ | |
173 DEFUN ("gtk-clist-get-text", Fgtk_clist_get_text, 3, 3, 0, /* | |
174 Returns the text from GtkCList OBJ cell at coordinates ROW, COLUMN. | |
175 */ | |
176 (obj, row, column)) | |
177 { | |
178 gchar *text = NULL; | |
179 Lisp_Object rval = Qnil; | |
180 | |
181 CHECK_GTK_OBJECT (obj); | |
182 CHECK_INT (row); | |
183 CHECK_INT (column); | |
184 | |
185 if (!GTK_IS_CLIST (XGTK_OBJECT (obj)->object)) | |
186 { | |
563 | 187 wtaerror ("Object is not a GtkCList", obj); |
462 | 188 } |
189 | |
190 gtk_clist_get_text (GTK_CLIST (XGTK_OBJECT (obj)->object), XINT (row), XINT (column), &text); | |
191 | |
192 if (text) | |
193 { | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
194 rval = build_cistring (text); |
462 | 195 /* NOTE: This is NOT a memory leak. GtkCList returns a pointer |
196 to internally used memory, not a copy of it. | |
197 g_free (text); | |
198 */ | |
199 } | |
200 | |
201 return (rval); | |
202 } | |
203 | |
204 /* gint gtk_clist_get_selection_info (GtkCList *clist, | |
205 gint x, | |
206 gint y, | |
207 gint *row, | |
208 gint *column); */ | |
209 DEFUN ("gtk-clist-get-selection-info", Fgtk_clist_get_selection, 3, 3, 0, /* | |
210 Returns a cons cell of (ROW . COLUMN) of the GtkCList OBJ at coordinates X, Y. | |
211 */ | |
212 (obj, x, y)) | |
213 { | |
214 gint row, column; | |
215 | |
216 CHECK_GTK_OBJECT (obj); | |
217 CHECK_INT (x); | |
218 CHECK_INT (y); | |
219 | |
220 if (!GTK_IS_CLIST (XGTK_OBJECT (obj)->object)) | |
221 { | |
563 | 222 wtaerror ("Object is not a GtkCList", obj); |
462 | 223 } |
224 | |
225 gtk_clist_get_selection_info (GTK_CLIST (XGTK_OBJECT (obj)->object), | |
226 XINT (x), XINT (y), &row, &column); | |
227 | |
228 return (Fcons (make_int (row), make_int (column))); | |
229 } | |
230 | |
231 DEFUN ("gtk-clist-get-pixmap", Fgtk_clist_get_pixmap, 3, 3, 0, /* | |
232 Return a cons of (pixmap . mask) at ROW,COLUMN in CLIST. | |
233 */ | |
234 (clist, row, column)) | |
235 { | |
236 GdkPixmap *pixmap = NULL; | |
237 GdkBitmap *mask = NULL; | |
238 | |
239 CHECK_GTK_OBJECT (clist); | |
240 CHECK_INT (row); | |
241 CHECK_INT (column); | |
242 | |
243 if (!GTK_IS_CLIST (XGTK_OBJECT (clist)->object)) | |
244 { | |
563 | 245 wtaerror ("Object is not a GtkCList", clist); |
462 | 246 } |
247 | |
248 gtk_clist_get_pixmap (GTK_CLIST (XGTK_OBJECT (clist)->object), | |
249 XINT (row), XINT (column), | |
250 &pixmap, &mask); | |
251 | |
252 return (Fcons (pixmap ? build_gtk_boxed (pixmap, GTK_TYPE_GDK_WINDOW) : Qnil, | |
253 mask ? build_gtk_boxed (mask, GTK_TYPE_GDK_WINDOW) : Qnil)); | |
254 } | |
255 | |
256 DEFUN ("gtk-clist-get-pixtext", Fgtk_clist_get_pixtext, 3, 3, 0, /* | |
257 Return a list of (pixmap mask text) at ROW,COLUMN in CLIST. | |
258 */ | |
259 (clist, row, column)) | |
260 { | |
261 GdkPixmap *pixmap = NULL; | |
262 GdkBitmap *mask = NULL; | |
263 char *text = NULL; | |
264 guint8 spacing; | |
265 | |
266 CHECK_GTK_OBJECT (clist); | |
267 CHECK_INT (row); | |
268 CHECK_INT (column); | |
269 | |
270 if (!GTK_IS_CLIST (XGTK_OBJECT (clist)->object)) | |
271 { | |
563 | 272 wtaerror ("Object is not a GtkCList", clist); |
462 | 273 } |
274 | |
275 gtk_clist_get_pixtext (GTK_CLIST (XGTK_OBJECT (clist)->object), | |
276 XINT (row), XINT (column), &text, &spacing, | |
277 &pixmap, &mask); | |
278 | |
279 return (list3 (pixmap ? build_gtk_boxed (pixmap, GTK_TYPE_GDK_WINDOW) : Qnil, | |
280 mask ? build_gtk_boxed (mask, GTK_TYPE_GDK_WINDOW) : Qnil, | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
281 (text && text[0]) ? build_cistring (text) : Qnil)); |
462 | 282 } |
283 | |
284 /* void gtk_color_selection_get_color(GtkColorSelection *colorsel, gdouble *color); */ | |
285 DEFUN ("gtk-color-selection-get-color", Fgtk_color_selection_get_color, 1, 1, 0, /* | |
286 Return a list of (RED GREEN BLUE ALPHA) from the GtkColorSelection OBJECT. | |
287 */ | |
288 (object)) | |
289 { | |
290 gdouble rgba[4]; | |
291 | |
292 CHECK_GTK_OBJECT (object); | |
293 | |
294 if (!GTK_IS_COLOR_SELECTION (XGTK_OBJECT (object)->object)) | |
295 { | |
563 | 296 wtaerror ("Object is not a GtkColorSelection", object); |
462 | 297 } |
298 | |
299 gtk_color_selection_get_color (GTK_COLOR_SELECTION (XGTK_OBJECT (object)), rgba); | |
300 | |
301 return (list4 (make_float (rgba[0]), | |
302 make_float (rgba[1]), | |
303 make_float (rgba[2]), | |
304 make_float (rgba[3]))); | |
305 } | |
306 | |
307 /* (gtk-import-function nil "gtk_editable_insert_text" 'GtkEditable 'GtkString 'gint 'pointer-to-gint) */ | |
308 DEFUN ("gtk-editable-insert-text", Fgtk_editable_insert_text, 3, 3, 0, /* | |
309 Insert text STRINT at POS in GtkEditable widget OBJ. | |
310 Returns the new position of the cursor in the widget. | |
311 */ | |
312 (obj, string, pos)) | |
313 { | |
314 gint the_pos; | |
315 | |
316 CHECK_GTK_OBJECT (obj); | |
317 CHECK_STRING (string); | |
318 CHECK_INT (pos); | |
319 | |
320 the_pos = XINT (pos); | |
321 | |
322 if (!GTK_IS_EDITABLE (XGTK_OBJECT (obj)->object)) | |
323 { | |
563 | 324 wtaerror ("Object is not a GtkEditable", obj); |
462 | 325 } |
326 | |
327 gtk_editable_insert_text (GTK_EDITABLE (XGTK_OBJECT (obj)->object), | |
328 (char *) XSTRING_DATA (string), | |
329 XSTRING_LENGTH (string), | |
330 &the_pos); | |
331 | |
332 return (make_int (the_pos)); | |
333 } | |
334 | |
335 DEFUN ("gtk-pixmap-get", Fgtk_pixmap_get, 1, 1, 0, /* | |
336 Return a cons cell of (PIXMAP . MASK) from GtkPixmap OBJECT. | |
337 */ | |
338 (object)) | |
339 { | |
340 GdkPixmap *pixmap, *mask; | |
341 | |
342 CHECK_GTK_OBJECT (object); | |
343 | |
344 if (!GTK_IS_PIXMAP (XGTK_OBJECT (object)->object)) | |
345 { | |
563 | 346 wtaerror ("Object is not a GtkPixmap", object); |
462 | 347 } |
348 | |
349 gtk_pixmap_get (GTK_PIXMAP (XGTK_OBJECT (object)->object), &pixmap, &mask); | |
350 | |
351 return (Fcons (pixmap ? build_gtk_object (GTK_OBJECT (pixmap)) : Qnil, | |
352 mask ? build_gtk_object (GTK_OBJECT (mask)) : Qnil)); | |
353 } | |
354 | |
355 DEFUN ("gtk-curve-get-vector", Fgtk_curve_get_vector, 2, 2, 0, /* | |
356 Returns a vector of LENGTH points representing the curve of CURVE. | |
357 */ | |
358 (curve, length)) | |
359 { | |
360 gfloat *vector = NULL; | |
361 Lisp_Object lisp_vector = Qnil; | |
362 int i; | |
363 | |
364 CHECK_GTK_OBJECT (curve); | |
365 CHECK_INT (length); | |
366 | |
367 if (!GTK_IS_CURVE (XGTK_OBJECT (curve)->object)) | |
368 { | |
563 | 369 wtaerror ("Object is not a GtkCurve", curve); |
462 | 370 } |
371 | |
2367 | 372 vector = alloca_array (gfloat, XINT (length)); |
462 | 373 |
374 gtk_curve_get_vector (GTK_CURVE (XGTK_OBJECT (curve)->object), XINT (length), vector); | |
375 lisp_vector = make_vector (XINT (length), Qnil); | |
376 | |
377 for (i = 0; i < XINT (length); i++) | |
378 { | |
379 XVECTOR_DATA (lisp_vector)[i] = make_float (vector[i]); | |
380 } | |
381 | |
382 return (lisp_vector); | |
383 } | |
384 | |
385 DEFUN ("gtk-curve-set-vector", Fgtk_curve_set_vector, 2, 2, 0, /* | |
386 Set the vector of points on CURVE to VECTOR. | |
387 */ | |
388 (curve, vector)) | |
389 { | |
390 gfloat *c_vector = NULL; | |
391 int vec_length = 0; | |
392 int i; | |
393 | |
394 CHECK_GTK_OBJECT (curve); | |
395 CHECK_VECTOR (vector); | |
396 | |
397 vec_length = XVECTOR_LENGTH (vector); | |
398 | |
399 if (!GTK_IS_CURVE (XGTK_OBJECT (curve)->object)) | |
400 { | |
563 | 401 wtaerror ("Object is not a GtkCurve", curve); |
462 | 402 } |
403 | |
2367 | 404 c_vector = alloca_array (gfloat, vec_length); |
462 | 405 |
406 for (i = 0; i < vec_length; i++) | |
407 { | |
408 CHECK_FLOAT (XVECTOR_DATA (vector)[i]); | |
409 c_vector[i] = extract_float (XVECTOR_DATA (vector)[i]); | |
410 } | |
411 | |
412 gtk_curve_set_vector (GTK_CURVE (XGTK_OBJECT (curve)->object), vec_length, c_vector); | |
413 return (Qt); | |
414 } | |
415 | |
416 DEFUN ("gtk-label-get", Fgtk_label_get, 1, 1, 0, /* | |
417 Return the text of LABEL. | |
418 */ | |
419 (label)) | |
420 { | |
421 gchar *string; | |
422 | |
423 CHECK_GTK_OBJECT (label); | |
424 | |
425 if (!GTK_IS_LABEL (XGTK_OBJECT (label)->object)) | |
426 { | |
563 | 427 wtaerror ("Object is not a GtkLabel", label); |
462 | 428 } |
429 | |
430 gtk_label_get (GTK_LABEL (XGTK_OBJECT (label)->object), &string); | |
431 | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
432 return (build_cistring (string)); |
462 | 433 } |
434 | |
435 DEFUN ("gtk-notebook-query-tab-label-packing", Fgtk_notebook_query_tab_label_packing, 2, 2, 0, /* | |
436 Return a list of packing information (EXPAND FILL PACK_TYPE) for CHILD in NOTEBOOK. | |
437 */ | |
438 (notebook, child)) | |
439 { | |
440 gboolean expand, fill; | |
441 GtkPackType pack_type; | |
442 | |
443 CHECK_GTK_OBJECT (notebook); | |
444 CHECK_GTK_OBJECT (child); | |
445 | |
446 if (!GTK_IS_NOTEBOOK (XGTK_OBJECT (notebook)->object)) | |
447 { | |
563 | 448 wtaerror ("Object is not a GtkLabel", notebook); |
462 | 449 } |
450 | |
451 if (!GTK_IS_WIDGET (XGTK_OBJECT (child)->object)) | |
452 { | |
563 | 453 wtaerror ("Object is not a GtkWidget", child); |
462 | 454 } |
455 | |
456 gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (XGTK_OBJECT (notebook)->object), | |
457 GTK_WIDGET (XGTK_OBJECT (child)->object), | |
458 &expand, &fill, &pack_type); | |
459 | |
460 return (list3 (expand ? Qt : Qnil, fill ? Qt : Qnil, make_int (pack_type))); | |
461 } | |
462 | |
463 DEFUN ("gtk-widget-get-pointer", Fgtk_widget_get_pointer, 1, 1, 0, /* | |
464 Return the pointer position relative to WIDGET as a cons of (X . Y). | |
465 */ | |
466 (widget)) | |
467 { | |
468 gint x,y; | |
469 CHECK_GTK_OBJECT (widget); | |
470 | |
471 if (!GTK_IS_WIDGET (XGTK_OBJECT (widget)->object)) | |
472 { | |
563 | 473 wtaerror ("Object is not a GtkWidget", widget); |
462 | 474 } |
475 | |
476 gtk_widget_get_pointer (GTK_WIDGET (XGTK_OBJECT (widget)->object), &x, &y); | |
477 | |
478 return (Fcons (make_int (x), make_int (y))); | |
479 } | |
480 | |
481 /* This is called whenever an item with a GUI_ID associated with it is | |
482 destroyed. This allows us to remove the references in gui-gtk.c | |
483 that made sure callbacks and such were GCPRO-ed | |
484 */ | |
485 static void | |
486 __remove_gcpro_by_id (gpointer user_data) | |
487 { | |
488 ungcpro_popup_callbacks ((GUI_ID) user_data); | |
489 } | |
490 | |
491 static void | |
2286 | 492 __generic_toolbar_callback (GtkWidget *UNUSED (item), gpointer user_data) |
462 | 493 { |
494 Lisp_Object callback; | |
495 Lisp_Object lisp_user_data; | |
496 | |
5013 | 497 callback = GET_LISP_FROM_VOID (user_data); |
462 | 498 |
499 lisp_user_data = XCAR (callback); | |
500 callback = XCDR (callback); | |
501 | |
502 signal_special_gtk_user_event (Qnil, callback, lisp_user_data); | |
503 } | |
504 | |
505 static Lisp_Object | |
506 generic_toolbar_insert_item (Lisp_Object toolbar, | |
507 Lisp_Object text, | |
508 Lisp_Object tooltip_text, | |
509 Lisp_Object tooltip_private_text, | |
510 Lisp_Object icon, | |
511 Lisp_Object callback, | |
512 Lisp_Object data, | |
513 Lisp_Object prepend_p, | |
514 Lisp_Object position) | |
515 { | |
516 GUI_ID id; | |
517 GtkWidget *w = NULL; | |
518 | |
519 CHECK_GTK_OBJECT (toolbar); | |
520 CHECK_GTK_OBJECT (icon); | |
521 CHECK_STRING (text); | |
522 CHECK_STRING (tooltip_text); | |
523 CHECK_STRING (tooltip_private_text); | |
524 | |
525 if (!SYMBOLP (callback) && !LISTP (callback)) | |
526 { | |
563 | 527 wtaerror ("Callback must be symbol or eval-able form", callback); |
462 | 528 } |
529 | |
530 if (!GTK_IS_TOOLBAR (XGTK_OBJECT (toolbar)->object)) | |
531 { | |
563 | 532 wtaerror ("Object is not a GtkToolbar", toolbar); |
462 | 533 } |
534 | |
535 if (!GTK_IS_WIDGET (XGTK_OBJECT (icon)->object)) | |
536 { | |
563 | 537 wtaerror ("Object is not a GtkWidget", icon); |
462 | 538 } |
539 | |
540 callback = Fcons (data, callback); | |
541 | |
542 id = new_gui_id (); | |
543 gcpro_popup_callbacks (id, callback); | |
544 gtk_object_weakref (XGTK_OBJECT (toolbar)->object, __remove_gcpro_by_id, | |
545 (gpointer) id); | |
546 | |
547 if (NILP (position)) | |
548 { | |
549 w = (NILP (prepend_p) ? gtk_toolbar_append_item : gtk_toolbar_prepend_item) | |
550 (GTK_TOOLBAR (XGTK_OBJECT (toolbar)->object), | |
2054 | 551 (char*) XSTRING_DATA (text), |
552 (char*) XSTRING_DATA (tooltip_text), | |
553 (char*) XSTRING_DATA (tooltip_private_text), | |
462 | 554 GTK_WIDGET (XGTK_OBJECT (icon)->object), |
555 GTK_SIGNAL_FUNC (__generic_toolbar_callback), | |
5013 | 556 STORE_LISP_IN_VOID (callback)); |
462 | 557 } |
558 else | |
559 { | |
560 w = gtk_toolbar_insert_item (GTK_TOOLBAR (XGTK_OBJECT (toolbar)->object), | |
2054 | 561 (char*) XSTRING_DATA (text), |
562 (char*) XSTRING_DATA (tooltip_text), | |
563 (char*) XSTRING_DATA (tooltip_private_text), | |
462 | 564 GTK_WIDGET (XGTK_OBJECT (icon)->object), |
565 GTK_SIGNAL_FUNC (__generic_toolbar_callback), | |
5013 | 566 STORE_LISP_IN_VOID (callback), |
462 | 567 XINT (position)); |
568 } | |
569 | |
570 | |
571 return (w ? build_gtk_object (GTK_OBJECT (w)) : Qnil); | |
572 } | |
573 | |
574 DEFUN ("gtk-toolbar-append-item", Fgtk_toolbar_append_item, 6, 7, 0, /* | |
575 Appends a new button to the given toolbar. | |
576 */ | |
577 (toolbar, text, tooltip_text, tooltip_private_text, icon, callback, data)) | |
578 { | |
579 return (generic_toolbar_insert_item (toolbar,text,tooltip_text,tooltip_private_text,icon,callback,data,Qnil,Qnil)); | |
580 } | |
581 | |
582 DEFUN ("gtk-toolbar-prepend-item", Fgtk_toolbar_prepend_item, 6, 7, 0, /* | |
583 Adds a new button to the beginning (left or top edges) of the given toolbar. | |
584 */ | |
585 (toolbar, text, tooltip_text, tooltip_private_text, icon, callback, data)) | |
586 { | |
587 return (generic_toolbar_insert_item (toolbar,text,tooltip_text,tooltip_private_text,icon,callback,data,Qt,Qnil)); | |
588 } | |
589 | |
590 DEFUN ("gtk-toolbar-insert-item", Fgtk_toolbar_insert_item, 7, 8, 0, /* | |
591 Adds a new button to the beginning (left or top edges) of the given toolbar. | |
592 */ | |
593 (toolbar, text, tooltip_text, tooltip_private_text, icon, callback, position, data)) | |
594 { | |
595 CHECK_INT (position); | |
596 | |
597 return (generic_toolbar_insert_item (toolbar,text,tooltip_text,tooltip_private_text,icon,callback,data,Qnil,position)); | |
598 } | |
599 | |
600 /* GtkCTree is an abomination in the eyes of the object system. */ | |
601 static void | |
602 __emacs_gtk_ctree_recurse_internal (GtkCTree *ctree, GtkCTreeNode *node, gpointer user_data) | |
603 { | |
604 Lisp_Object closure; | |
605 | |
5013 | 606 closure = GET_LISP_FROM_VOID (user_data); |
462 | 607 |
608 call3 (XCAR (closure), | |
609 build_gtk_object (GTK_OBJECT (ctree)), | |
610 build_gtk_boxed (node, GTK_TYPE_CTREE_NODE), | |
611 XCDR (closure)); | |
612 } | |
613 | |
614 DEFUN ("gtk-ctree-recurse", Fgtk_ctree_recurse, 3, 6, 0, /* | |
615 Recursively apply FUNC to all nodes of CTREE at or below NODE. | |
616 FUNC is called with three arguments: CTREE, a GtkCTreeNode, and DATA. | |
617 The return value of FUNC is ignored. | |
618 | |
619 If optional 5th argument CHILDFIRSTP is non-nil, then | |
620 the function is called for each node after it has been | |
621 called for that node's children. | |
622 | |
623 Optional 6th argument DEPTH limits how deeply to recurse. | |
624 | |
625 This function encompasses all the following Gtk functions: | |
626 | |
627 void gtk_ctree_post_recursive (GtkCTree *ctree, | |
628 GtkCTreeNode *node, | |
629 GtkCTreeFunc func, | |
630 gpointer data); | |
631 void gtk_ctree_post_recursive_to_depth (GtkCTree *ctree, | |
632 GtkCTreeNode *node, | |
633 gint depth, | |
634 GtkCTreeFunc func, | |
635 gpointer data); | |
636 void gtk_ctree_pre_recursive (GtkCTree *ctree, | |
637 GtkCTreeNode *node, | |
638 GtkCTreeFunc func, | |
639 gpointer data); | |
640 void gtk_ctree_pre_recursive_to_depth (GtkCTree *ctree, | |
641 GtkCTreeNode *node, | |
642 gint depth, | |
643 GtkCTreeFunc func, | |
644 gpointer data); | |
645 */ | |
646 (ctree, node, func, data, childfirstp, depth)) | |
647 { | |
648 struct gcpro gcpro1, gcpro2, gcpro3; | |
649 Lisp_Object closure = Qnil; | |
650 | |
651 CHECK_GTK_OBJECT (ctree); | |
652 | |
653 if (!NILP (node)) | |
654 { | |
655 CHECK_GTK_BOXED (node); | |
656 } | |
657 | |
658 if (!NILP (depth)) | |
659 { | |
660 CHECK_INT (depth); | |
661 } | |
662 | |
663 closure = Fcons (func, data); | |
664 | |
665 GCPRO3 (ctree, node, closure); | |
666 | |
667 if (NILP (depth)) | |
668 { | |
669 (NILP (childfirstp) ? gtk_ctree_post_recursive : gtk_ctree_pre_recursive) | |
670 (GTK_CTREE (XGTK_OBJECT (ctree)->object), | |
671 NILP (node) ? NULL : (GtkCTreeNode *) XGTK_BOXED (node)->object, | |
672 __emacs_gtk_ctree_recurse_internal, | |
5013 | 673 STORE_LISP_IN_VOID (closure)); |
462 | 674 } |
675 else | |
676 { | |
677 (NILP (childfirstp) ? gtk_ctree_post_recursive_to_depth : gtk_ctree_pre_recursive_to_depth) | |
678 (GTK_CTREE (XGTK_OBJECT (ctree)->object), | |
679 NILP (node) ? NULL : (GtkCTreeNode *) XGTK_BOXED (node)->object, | |
680 XINT (depth), | |
681 __emacs_gtk_ctree_recurse_internal, | |
5013 | 682 STORE_LISP_IN_VOID (closure)); |
462 | 683 } |
684 | |
685 UNGCPRO; | |
686 return (Qnil); | |
687 } | |
688 | |
689 void syms_of_ui_byhand (void) | |
690 { | |
691 DEFSUBR (Fgtk_toolbar_append_item); | |
692 DEFSUBR (Fgtk_toolbar_insert_item); | |
693 DEFSUBR (Fgtk_toolbar_prepend_item); | |
694 DEFSUBR (Fgtk_box_query_child_packing); | |
695 DEFSUBR (Fgtk_button_box_get_child_size_default); | |
696 DEFSUBR (Fgtk_button_box_get_child_ipadding_default); | |
697 DEFSUBR (Fgtk_button_box_get_child_size); | |
698 DEFSUBR (Fgtk_button_box_get_child_ipadding); | |
699 DEFSUBR (Fgtk_calendar_get_date); | |
700 DEFSUBR (Fgtk_clist_get_text); | |
701 DEFSUBR (Fgtk_clist_get_selection); | |
702 DEFSUBR (Fgtk_clist_get_pixmap); | |
703 DEFSUBR (Fgtk_clist_get_pixtext); | |
704 DEFSUBR (Fgtk_color_selection_get_color); | |
705 DEFSUBR (Fgtk_editable_insert_text); | |
706 DEFSUBR (Fgtk_pixmap_get); | |
707 DEFSUBR (Fgtk_curve_get_vector); | |
708 DEFSUBR (Fgtk_curve_set_vector); | |
709 DEFSUBR (Fgtk_label_get); | |
710 DEFSUBR (Fgtk_notebook_query_tab_label_packing); | |
711 DEFSUBR (Fgtk_widget_get_pointer); | |
712 DEFSUBR (Fgtk_ctree_recurse); | |
713 } |