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