view src/ui-byhand.c @ 2367:ecf1ebac70d8

[xemacs-hg @ 2004-11-04 23:05:23 by ben] commit mega-patch configure.in: Turn off -Winline and -Wchar-subscripts. Use the right set of cflags when compiling modules. Rewrite ldap configuration to separate the inclusion of lber (needed in recent Cygwin) from the basic checks for the needed libraries. add a function for MAKE_JUNK_C; initially code was added to generate xemacs.def using this, but it will need to be rewritten. add an rm -f for junk.c to avoid weird Cygwin bug with cp -f onto an existing file. Sort list of auto-detected functions and eliminate unused checks for stpcpy, setlocale and getwd. Add autodetection of Cygwin scanf problems BETA: Rewrite section on configure to indicate what flags are important and what not. digest-doc.c, make-dump-id.c, profile.c, sorted-doc.c: Add proper decls for main(). make-msgfile.c: Document that this is old junk. Move proposal to text.c. make-msgfile.lex: Move proposal to text.c. make-mswin-unicode.pl: Convert error-generating code so that the entire message will be seen as a single unrecognized token. mule/mule-ccl.el: Update docs. lispref/mule.texi: Update CCL docs. ldap/eldap.c: Mule-ize. Use EXTERNAL_LIST_LOOP_2 instead of deleted EXTERNAL_LIST_LOOP. * XEmacs 21.5.18 "chestnut" is released. --------------------------------------------------------------- MULE-RELATED WORK: --------------------------------------------------------------- --------------------------- byte-char conversion --------------------------- buffer.c, buffer.h, insdel.c, text.c: Port FSF algorithm for byte-char conversion, replacing broken previous version. Track the char position of the gap. Add functions to do char-byte conversion downwards as well as upwards. Move comments about algorithm workings to internals manual. --------------------------- work on types --------------------------- alloc.c, console-x-impl.h, dump-data.c, dump-data.h, dumper.c, dialog-msw.c, dired-msw.c, doc.c, editfns.c, esd.c, event-gtk.h, event-msw.c, events.c, file-coding.c, file-coding.h, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-x.c, glyphs.c, glyphs.h, gui.c, hpplay.c, imgproc.c, intl-win32.c, lrecord.h, lstream.c, keymap.c, lisp.h, libsst.c, linuxplay.c, miscplay.c, miscplay.h, mule-coding.c, nas.c, nt.c, ntheap.c, ntplay.c, objects-msw.c, objects-tty.c, objects-x.c, print.c, process-nt.c, process.c, redisplay.h, select-common.h, select-gtk.c, select-x.c, sgiplay.c, sound.c, sound.h, sunplay.c, sysfile.h, sysdep.c, syswindows.h, text.c, unexnt.c, win32.c, xgccache.c: Further work on types. This creates a full set of types for all the basic semantics of `char' that I have so far identified, so that its semantics can always be identified for the purposes of proper Mule-safe code, and the raw use of `char' always avoided. (1) More type renaming, for consistency of naming. Char_ASCII -> Ascbyte UChar_ASCII -> UAscbyte Char_Binary -> CBinbyte UChar_Binary -> Binbyte SChar_Binary -> SBinbyte (2) Introduce Rawbyte, CRawbyte, Boolbyte, Chbyte, UChbyte, and Bitbyte and use them. (3) New types Itext, Wexttext and Textcount for separating out the concepts of bytes and textual units (different under UTF-16 and UTF-32, which are potential internal encodings). (4) qxestr*_c -> qxestr*_ascii. lisp.h: New; goes with other qxe() functions. #### Maybe goes in a different section. lisp.h: Group generic int-type defs together with EMACS_INT defs. lisp.h: * lisp.h (WEXTTEXT_IS_WIDE) New defns. lisp.h: New type to replace places where int occurs as a boolean. It's signed because occasionally people may want to use -1 as an error value, and because unsigned ints are viral -- see comments in the internals manual against using them. dynarr.c: int -> Bytecount. --------------------------- Mule-izing --------------------------- device-x.c: Partially Mule-ize. dumper.c, dumper.h: Mule-ize. Use Rawbyte. Use stderr_out not printf. Use wext_*(). sysdep.c, syswindows.h, text.c: New Wexttext API for manipulation of external text that may be Unicode (e.g. startup code under Windows). emacs.c: Mule-ize. Properly deal with argv in external encoding. Use wext_*() and Wexttext. Use Rawbyte. #if 0 some old junk on SCO that is unlikely to be correct. Rewrite allocation code in run-temacs. emacs.c, symsinit.h, win32.c: Rename win32 init function and call it even earlier, to initialize mswindows_9x_p even earlier, for use in startup code (XEUNICODE_P). process.c: Use _wenviron not environ under Windows, to get Unicode environment variables. event-Xt.c: Mule-ize drag-n-drop related stuff. dragdrop.c, dragdrop.h, frame-x.c: Mule-ize. text.h: Add some more stand-in defines for particular kinds of conversion; use in Mule-ization work in frame-x.c etc. --------------------------- Freshening --------------------------- intl-auto-encap-win32.c, intl-auto-encap-win32.h: Regenerate. --------------------------- Unicode-work --------------------------- intl-win32.c, syswindows.h: Factor out common options to MultiByteToWideChar and WideCharToMultiByte. Add convert_unicode_to_multibyte_malloc() and convert_unicode_to_multibyte_dynarr() and use. Add stuff for alloca() conversion of multibyte/unicode. alloc.c: Use dfc_external_data_len() in case of unicode coding system. alloc.c, mule-charset.c: Don't zero out and reinit charset Unicode tables. This fucks up dump-time loading. Anyway, either we load them at dump time or run time, never both. unicode.c: Dump the blank tables as well. --------------------------------------------------------------- DOCUMENTATION, MOSTLY MULE-RELATED: --------------------------------------------------------------- EmacsFrame.c, emodules.c, event-Xt.c, fileio.c, input-method-xlib.c, mule-wnnfns.c, redisplay-gtk.c, redisplay-tty.c, redisplay-x.c, regex.c, sysdep.c: Add comment about Mule work needed. text.h: Add more documentation describing why DFC routines were not written to return their value. Add some other DFC documentation. console-msw.c, console-msw.h: Add pointer to docs in win32.c. emacs.c: Add comments on sources of doc info. text.c, charset.h, unicode.c, intl-win32.c, intl-encap-win32.c, text.h, file-coding.c, mule-coding.c: Collect background comments and related to text matters and internationalization, and proposals for work to be done, in text.c or Internals manual, stuff related to specific textual API's in text.h, and stuff related to internal implementation of Unicode conversion in unicode.c. Put lots of pointers to the comments to make them easier to find. s/mingw32.h, s/win32-common.h, s/win32-native.h, s/windowsnt.h, win32.c: Add bunches of new documentation on the different kinds of builds and environments under Windows and how they work. Collect this info in win32.c. Add pointers to these docs in the relevant s/* files. emacs.c: Document places with long comments. Remove comment about exiting, move to internals manual, put in pointer. event-stream.c: Move docs about event queues and focus to internals manual, put in pointer. events.h: Move docs about event stream callbacks to internals manual, put in pointer. profile.c, redisplay.c, signal.c: Move documentation to the Internals manual. process-nt.c: Add pointer to comment in win32-native.el. lisp.h: Add comments about some comment conventions. lisp.h: Add comment about the second argument. device-msw.c, redisplay-msw.c: @@#### comments are out-of-date. --------------------------------------------------------------- PDUMP WORK (MOTIVATED BY UNICODE CHANGES) --------------------------------------------------------------- alloc.c, buffer.c, bytecode.c, console-impl.h, console.c, device.c, dumper.c, lrecord.h, elhash.c, emodules.h, events.c, extents.c, frame.c, glyphs.c, glyphs.h, mule-charset.c, mule-coding.c, objects.c, profile.c, rangetab.c, redisplay.c, specifier.c, specifier.h, window.c, lstream.c, file-coding.h, file-coding.c: PDUMP: Properly implement dump_add_root_block(), which never worked before, and is necessary for dumping Unicode tables. Pdump name changes for accuracy: XD_STRUCT_PTR -> XD_BLOCK_PTR. XD_STRUCT_ARRAY -> XD_BLOCK_ARRAY. XD_C_STRING -> XD_ASCII_STRING. *_structure_* -> *_block_*. lrecord.h: some comments added about dump_add_root_block() vs dump_add_root_block_ptr(). extents.c: remove incorrect comment about pdump problems with gap array. --------------------------------------------------------------- ALLOCATION --------------------------------------------------------------- abbrev.c, alloc.c, bytecode.c, casefiddle.c, device-msw.c, device-x.c, dired-msw.c, doc.c, doprnt.c, dragdrop.c, editfns.c, emodules.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-msw.c, gui-x.c, imgproc.c, intl-win32.c, lread.c, menubar-gtk.c, menubar.c, nt.c, objects-msw.c, objects-x.c, print.c, process-nt.c, process-unix.c, process.c, realpath.c, redisplay.c, search.c, select-common.c, symbols.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: New macros {alloca,xnew}_{itext,{i,ext,raw,bin,asc}bytes} for more convenient allocation of these commonly requested items. Modify functions to use alloca_ibytes, alloca_array, alloca_extbytes, xnew_ibytes, etc. also XREALLOC_ARRAY, xnew. alloc.c: Rewrite the allocation functions to factor out repeated code. Add assertions for freeing dumped data. lisp.h: Moved down and consolidated with other allocation stuff. lisp.h, dynarr.c: New functions for allocation that's very efficient when mostly in LIFO order. lisp.h, text.c, text.h: Factor out some stuff for general use by alloca()-conversion funs. text.h, lisp.h: Fill out convenience routines for allocating various kinds of bytes and put them in lisp.h. Use them in place of xmalloc(), ALLOCA(). text.h: Fill out the convenience functions so the _MALLOC() kinds match the alloca() kinds. --------------------------------------------------------------- ERROR-CHECKING --------------------------------------------------------------- text.h: Create ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN() from similar Eistring checkers and change the Eistring checkers to use them instead. --------------------------------------------------------------- MACROS IN LISP.H --------------------------------------------------------------- lisp.h: Redo GCPRO declarations. Create a "base" set of functions that can be used to generate any kind of gcpro sets -- regular, ngcpro, nngcpro, private ones used in GC_EXTERNAL_LIST_LOOP_2. buffer.c, callint.c, chartab.c, console-msw.c, device-x.c, dialog-msw.c, dired.c, extents.c, ui-gtk.c, rangetab.c, nt.c, mule-coding.c, minibuf.c, menubar-msw.c, menubar.c, menubar-gtk.c, lread.c, lisp.h, gutter.c, glyphs.c, glyphs-widget.c, fns.c, fileio.c, file-coding.c, specifier.c: Eliminate EXTERNAL_LIST_LOOP, which does not check for circularities. Use EXTERNAL_LIST_LOOP_2 instead or EXTERNAL_LIST_LOOP_3 or EXTERNAL_PROPERTY_LIST_LOOP_3 or GC_EXTERNAL_LIST_LOOP_2 (new macro). Removed/redid comments on EXTERNAL_LIST_LOOP. --------------------------------------------------------------- SPACING FIXES --------------------------------------------------------------- callint.c, hftctl.c, number-gmp.c, process-unix.c: Spacing fixes. --------------------------------------------------------------- FIX FOR GEOMETRY PROBLEM IN FIRST FRAME --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. toolbar.c: bug fix for problem of initial frame being 77 chars wide on Windows. will be overridden by my other ws. --------------------------------------------------------------- FIX FOR LEAKING PROCESS HANDLES: --------------------------------------------------------------- process-nt.c: Fixes for leaking handles. Inspired by work done by Adrian Aichner <adrian@xemacs.org>. --------------------------------------------------------------- FIX FOR CYGWIN BUG (Unicode-related): --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. --------------------------------------------------------------- WARNING FIXES: --------------------------------------------------------------- console-stream.c: `reinit' is unused. compiler.h, event-msw.c, frame-msw.c, intl-encap-win32.c, text.h: Add stuff to deal with ANSI-aliasing warnings I got. regex.c: Gather includes together to avoid warning. --------------------------------------------------------------- CHANGES TO INITIALIZATION ROUTINES: --------------------------------------------------------------- buffer.c, emacs.c, console.c, debug.c, device-x.c, device.c, dragdrop.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, font-lock.c, frame-msw.c, glyphs-widget.c, glyphs.c, gui-x.c, insdel.c, lread.c, lstream.c, menubar-gtk.c, menubar-x.c, minibuf.c, mule-wnnfns.c, objects-msw.c, objects.c, print.c, scrollbar-x.c, search.c, select-x.c, text.c, undo.c, unicode.c, window.c, symsinit.h: Call reinit_*() functions directly from emacs.c, for clarity. Factor out some redundant init code. Move disallowed stuff that had crept into vars_of_glyphs() into complex_vars_of_glyphs(). Call init_eval_semi_early() from eval.c not in the middle of vars_of_() in emacs.c since there should be no order dependency in the latter calls. --------------------------------------------------------------- ARMAGEDDON: --------------------------------------------------------------- alloc.c, emacs.c, lisp.h, print.c: Rename inhibit_non_essential_printing_operations to inhibit_non_essential_conversion_operations. text.c: Assert on !inhibit_non_essential_conversion_operations. console-msw.c, print.c: Don't do conversion in SetConsoleTitle or FindWindow to avoid problems during armageddon. Put #errors for NON_ASCII_INTERNAL_FORMAT in places where problems would arise. --------------------------------------------------------------- CHANGES TO THE BUILD PROCEDURE: --------------------------------------------------------------- config.h.in, s/cxux.h, s/usg5-4-2.h, m/powerpc.h: Add comment about correct ordering of this file. Rearrange everything to follow this -- put all #undefs together and before the s&m files. Add undefs for HAVE_ALLOCA, C_ALLOCA, BROKEN_ALLOCA_IN_FUNCTION_CALLS, STACK_DIRECTION. Remove unused HAVE_STPCPY, HAVE_GETWD, HAVE_SETLOCALE. m/gec63.h: Deleted; totally broken, not used at all, not in FSF. m/7300.h, m/acorn.h, m/alliant-2800.h, m/alliant.h, m/altos.h, m/amdahl.h, m/apollo.h, m/att3b.h, m/aviion.h, m/celerity.h, m/clipper.h, m/cnvrgnt.h, m/convex.h, m/cydra5.h, m/delta.h, m/delta88k.h, m/dpx2.h, m/elxsi.h, m/ews4800r.h, m/gould.h, m/hp300bsd.h, m/hp800.h, m/hp9000s300.h, m/i860.h, m/ibmps2-aix.h, m/ibmrs6000.h, m/ibmrt-aix.h, m/ibmrt.h, m/intel386.h, m/iris4d.h, m/iris5d.h, m/iris6d.h, m/irist.h, m/isi-ov.h, m/luna88k.h, m/m68k.h, m/masscomp.h, m/mg1.h, m/mips-nec.h, m/mips-siemens.h, m/mips.h, m/news.h, m/nh3000.h, m/nh4000.h, m/ns32000.h, m/orion105.h, m/pfa50.h, m/plexus.h, m/pmax.h, m/powerpc.h, m/pyrmips.h, m/sequent-ptx.h, m/sequent.h, m/sgi-challenge.h, m/symmetry.h, m/tad68k.h, m/tahoe.h, m/targon31.h, m/tekxd88.h, m/template.h, m/tower32.h, m/tower32v3.h, m/ustation.h, m/vax.h, m/wicat.h, m/xps100.h: Delete C_ALLOCA, HAVE_ALLOCA, STACK_DIRECTION, BROKEN_ALLOCA_IN_FUNCTION_CALLS. All of this is auto-detected. When in doubt, I followed recent FSF sources, which also have these things deleted.
author ben
date Thu, 04 Nov 2004 23:08:28 +0000
parents 04bc9d2f42c7
children db7068430402
line wrap: on
line source

/* I really wish this entire file could go away, but there is
   currently no way to do the following in the Foreign Function
   Interface:

   1) Deal with return values in the parameter list (ie: int *foo)

   So we have to code a few functions by hand.  Ick.

   William M. Perry 5/8/00
*/

#include "gui.h"

DEFUN ("gtk-box-query-child-packing", Fgtk_box_query_child_packing, 2, 2,0, /*
Returns information about how CHILD is packed into BOX.
Return value is a list of (EXPAND FILL PADDING PACK_TYPE).
*/
       (box, child))
{
  gboolean expand, fill;
  guint padding;
  GtkPackType pack_type;
  Lisp_Object result = Qnil;
  
  CHECK_GTK_OBJECT (box);
  CHECK_GTK_OBJECT (child);

  if (!GTK_IS_BOX (XGTK_OBJECT (box)->object))
    {
      wtaerror ("Object is not a GtkBox", box);
    }

  if (!GTK_IS_WIDGET (XGTK_OBJECT (child)->object))
    {
      wtaerror ("Child is not a GtkWidget", child);
    }

  gtk_box_query_child_packing (GTK_BOX (XGTK_OBJECT (box)->object),
			       GTK_WIDGET (XGTK_OBJECT (child)->object),
			       &expand, &fill, &padding, &pack_type);

  result = Fcons (make_int (pack_type), result);
  result = Fcons (make_int (padding), result);
  result = Fcons (fill ? Qt : Qnil, result);
  result = Fcons (expand ? Qt : Qnil, result);

  return (result);
}

/* void gtk_button_box_get_child_size_default (gint *min_width, gint *min_height); */
DEFUN ("gtk-button-box-get-child-size-default",
       Fgtk_button_box_get_child_size_default, 0, 0, 0, /*
Return a cons cell (WIDTH . HEIGHT) of the default button box child size.
*/
       ())
{
  gint width, height;

  gtk_button_box_get_child_size_default (&width, &height);

  return (Fcons (make_int (width), make_int (height)));
}

/* void gtk_button_box_get_child_ipadding_default (gint *ipad_x, gint *ipad_y);  */
DEFUN ("gtk-button-box-get-child-ipadding-default",
       Fgtk_button_box_get_child_ipadding_default, 0, 0, 0, /*
Return a cons cell (X . Y) of the default button box ipadding.
*/
       ())
{
  gint x, y;

  gtk_button_box_get_child_ipadding_default (&x, &y);

  return (Fcons (make_int (x), make_int (y)));
}

/* void gtk_button_box_get_child_size (GtkButtonBox *widget,
   gint *min_width, gint *min_height); */
DEFUN ("gtk-button-box-get-child-size", Fgtk_button_box_get_child_size, 1, 1, 0, /*
Get the current size of a child in the buttonbox BOX.
*/
       (box))
{
  gint width, height;

  CHECK_GTK_OBJECT (box);

  if (!GTK_IS_BUTTON_BOX (XGTK_OBJECT (box)->object))
    {
      wtaerror ("Not a GtkBox object", box);
    }

  gtk_button_box_get_child_size (GTK_BUTTON_BOX (XGTK_OBJECT (box)->object),
				 &width, &height);

  return (Fcons (make_int (width), make_int (height)));
}

/* void gtk_button_box_get_child_ipadding (GtkButtonBox *widget, gint *ipad_x, gint *ipad_y); */
DEFUN ("gtk-button-box-get-child-ipadding",
       Fgtk_button_box_get_child_ipadding, 1, 1, 0, /*
Return a cons cell (X . Y) of the current buttonbox BOX ipadding.
*/
       (box))
{
  gint x, y;

  CHECK_GTK_OBJECT (box);

  if (!GTK_IS_BUTTON_BOX (XGTK_OBJECT (box)->object))
    {
      wtaerror ("Not a GtkBox object", box);
    }

  gtk_button_box_get_child_ipadding (GTK_BUTTON_BOX (XGTK_OBJECT (box)->object),
				     &x, &y);

  return (Fcons (make_int (x), make_int (y)));
}

/*void	   gtk_calendar_get_date	(GtkCalendar *calendar, 
					 guint	     *year,
					 guint	     *month,
					 guint	     *day);
*/
DEFUN ("gtk-calendar-get-date", Fgtk_calendar_get_date, 1, 1, 0, /*
Return a list of (YEAR MONTH DAY) from the CALENDAR object.
*/
       (calendar))
{
  guint year, month, day;

  CHECK_GTK_OBJECT (calendar);

  if (!GTK_IS_CALENDAR (XGTK_OBJECT (calendar)->object))
    {
      wtaerror ("Not a GtkCalendar object", calendar);
    }

  gtk_calendar_get_date (GTK_CALENDAR (XGTK_OBJECT (calendar)->object),
			 &year, &month, &day);

  return (list3 (make_int (year), make_int (month), make_int (day)));
}

/* gint gtk_clist_get_text (GtkCList  *clist,
			 gint       row,
			 gint       column,
			 gchar    **text);
*/
DEFUN ("gtk-clist-get-text", Fgtk_clist_get_text, 3, 3, 0, /*
Returns the text from GtkCList OBJ cell at coordinates ROW, COLUMN.
*/
       (obj, row, column))
{
  gchar *text = NULL;
  Lisp_Object rval = Qnil;

  CHECK_GTK_OBJECT (obj);
  CHECK_INT (row);
  CHECK_INT (column);

  if (!GTK_IS_CLIST (XGTK_OBJECT (obj)->object))
    {
      wtaerror ("Object is not a GtkCList", obj);
    }

  gtk_clist_get_text (GTK_CLIST (XGTK_OBJECT (obj)->object), XINT (row), XINT (column), &text);

  if (text)
    {
      rval = build_string (text);
      /* NOTE: This is NOT a memory leak.  GtkCList returns a pointer
	 to internally used memory, not a copy of it.
	 g_free (text);
      */
    }

  return (rval);
}

/* gint gtk_clist_get_selection_info (GtkCList *clist,
			     	   gint      x,
			     	   gint      y,
			     	   gint     *row,
			     	   gint *column); */
DEFUN ("gtk-clist-get-selection-info", Fgtk_clist_get_selection, 3, 3, 0, /*
Returns a cons cell of (ROW . COLUMN) of the GtkCList OBJ at coordinates X, Y.
*/
       (obj, x, y))
{
  gint row, column;

  CHECK_GTK_OBJECT (obj);
  CHECK_INT (x);
  CHECK_INT (y);

  if (!GTK_IS_CLIST (XGTK_OBJECT (obj)->object))
    {
      wtaerror ("Object is not a GtkCList", obj);
    }

  gtk_clist_get_selection_info (GTK_CLIST (XGTK_OBJECT (obj)->object),
				XINT (x), XINT (y), &row, &column);

  return (Fcons (make_int (row), make_int (column)));
}

DEFUN ("gtk-clist-get-pixmap", Fgtk_clist_get_pixmap, 3, 3, 0, /*
Return a cons of (pixmap . mask) at ROW,COLUMN in CLIST.
*/
       (clist, row, column))
{
  GdkPixmap *pixmap = NULL;
  GdkBitmap *mask = NULL;

  CHECK_GTK_OBJECT (clist);
  CHECK_INT (row);
  CHECK_INT (column);

  if (!GTK_IS_CLIST (XGTK_OBJECT (clist)->object))
    {
      wtaerror ("Object is not a GtkCList", clist);
    }

  gtk_clist_get_pixmap (GTK_CLIST (XGTK_OBJECT (clist)->object),
			XINT (row), XINT (column),
			&pixmap, &mask);

  return (Fcons (pixmap ? build_gtk_boxed (pixmap, GTK_TYPE_GDK_WINDOW) : Qnil,
		 mask ? build_gtk_boxed (mask, GTK_TYPE_GDK_WINDOW) : Qnil));
}

DEFUN ("gtk-clist-get-pixtext", Fgtk_clist_get_pixtext, 3, 3, 0, /*
Return a list of (pixmap mask text) at ROW,COLUMN in CLIST.
*/
       (clist, row, column))
{
  GdkPixmap *pixmap = NULL;
  GdkBitmap *mask = NULL;
  char *text = NULL;
  guint8 spacing;

  CHECK_GTK_OBJECT (clist);
  CHECK_INT (row);
  CHECK_INT (column);

  if (!GTK_IS_CLIST (XGTK_OBJECT (clist)->object))
    {
      wtaerror ("Object is not a GtkCList", clist);
    }

  gtk_clist_get_pixtext (GTK_CLIST (XGTK_OBJECT (clist)->object),
			 XINT (row), XINT (column), &text, &spacing,
			 &pixmap, &mask);

  return (list3 (pixmap ? build_gtk_boxed (pixmap, GTK_TYPE_GDK_WINDOW) : Qnil,
		 mask ? build_gtk_boxed (mask, GTK_TYPE_GDK_WINDOW) : Qnil,
		 (text && text[0]) ? build_string (text) : Qnil));
}

/* void gtk_color_selection_get_color(GtkColorSelection *colorsel, gdouble *color); */
DEFUN ("gtk-color-selection-get-color", Fgtk_color_selection_get_color, 1, 1, 0, /*
Return a list of (RED GREEN BLUE ALPHA) from the GtkColorSelection OBJECT.
*/
       (object))
{
  gdouble rgba[4];

  CHECK_GTK_OBJECT (object);

  if (!GTK_IS_COLOR_SELECTION (XGTK_OBJECT (object)->object))
    {
      wtaerror ("Object is not a GtkColorSelection", object);
    }

  gtk_color_selection_get_color (GTK_COLOR_SELECTION (XGTK_OBJECT (object)), rgba);

  return (list4 (make_float (rgba[0]),
		 make_float (rgba[1]),
		 make_float (rgba[2]),
		 make_float (rgba[3])));
}

/* (gtk-import-function nil "gtk_editable_insert_text" 'GtkEditable 'GtkString 'gint 'pointer-to-gint) */
DEFUN ("gtk-editable-insert-text", Fgtk_editable_insert_text, 3, 3, 0, /*
Insert text STRINT at POS in GtkEditable widget OBJ.
Returns the new position of the cursor in the widget.
*/
       (obj, string, pos))
{
  gint the_pos;

  CHECK_GTK_OBJECT (obj);
  CHECK_STRING (string);
  CHECK_INT (pos);

  the_pos = XINT (pos);

  if (!GTK_IS_EDITABLE (XGTK_OBJECT (obj)->object))
    {
      wtaerror ("Object is not a GtkEditable", obj);
    }

  gtk_editable_insert_text (GTK_EDITABLE (XGTK_OBJECT (obj)->object),
			    (char *) XSTRING_DATA (string),
			    XSTRING_LENGTH (string),
			    &the_pos);

  return (make_int (the_pos));
}

DEFUN ("gtk-pixmap-get", Fgtk_pixmap_get, 1, 1, 0, /*
Return a cons cell of (PIXMAP . MASK) from GtkPixmap OBJECT.
*/
	 (object))
{
  GdkPixmap *pixmap, *mask;

  CHECK_GTK_OBJECT (object);

  if (!GTK_IS_PIXMAP (XGTK_OBJECT (object)->object))
    {
      wtaerror ("Object is not a GtkPixmap", object);
    }

  gtk_pixmap_get (GTK_PIXMAP (XGTK_OBJECT (object)->object), &pixmap, &mask);

  return (Fcons (pixmap ? build_gtk_object (GTK_OBJECT (pixmap)) : Qnil,
		 mask ? build_gtk_object (GTK_OBJECT (mask)) : Qnil));
}

DEFUN ("gtk-curve-get-vector", Fgtk_curve_get_vector, 2, 2, 0, /*
Returns a vector of LENGTH points representing the curve of CURVE.
*/
       (curve, length))
{
  gfloat *vector = NULL;
  Lisp_Object lisp_vector = Qnil;
  int i;

  CHECK_GTK_OBJECT (curve);
  CHECK_INT (length);

  if (!GTK_IS_CURVE (XGTK_OBJECT (curve)->object))
    {
      wtaerror ("Object is not a GtkCurve", curve);
    }

  vector = alloca_array (gfloat, XINT (length));

  gtk_curve_get_vector (GTK_CURVE (XGTK_OBJECT (curve)->object), XINT (length), vector);
  lisp_vector = make_vector (XINT (length), Qnil);

  for (i = 0; i < XINT (length); i++)
    {
      XVECTOR_DATA (lisp_vector)[i] = make_float (vector[i]);
    }

  return (lisp_vector);
}

DEFUN ("gtk-curve-set-vector", Fgtk_curve_set_vector, 2, 2, 0, /*
Set the vector of points on CURVE to VECTOR.
*/
       (curve, vector))
{
  gfloat *c_vector = NULL;
  int vec_length = 0;
  int i;

  CHECK_GTK_OBJECT (curve);
  CHECK_VECTOR (vector);

  vec_length = XVECTOR_LENGTH (vector);

  if (!GTK_IS_CURVE (XGTK_OBJECT (curve)->object))
    {
      wtaerror ("Object is not a GtkCurve", curve);
    }

  c_vector = alloca_array (gfloat, vec_length);

  for (i = 0; i < vec_length; i++)
    {
      CHECK_FLOAT (XVECTOR_DATA (vector)[i]);
      c_vector[i] = extract_float (XVECTOR_DATA (vector)[i]);
    }

  gtk_curve_set_vector (GTK_CURVE (XGTK_OBJECT (curve)->object), vec_length, c_vector);
  return (Qt);
}

DEFUN ("gtk-label-get", Fgtk_label_get, 1, 1, 0, /*
Return the text of LABEL.
*/
       (label))
{
  gchar *string;

  CHECK_GTK_OBJECT (label);

  if (!GTK_IS_LABEL (XGTK_OBJECT (label)->object))
    {
      wtaerror ("Object is not a GtkLabel", label);
    }

  gtk_label_get (GTK_LABEL (XGTK_OBJECT (label)->object), &string);

  return (build_string (string));
}

DEFUN ("gtk-notebook-query-tab-label-packing", Fgtk_notebook_query_tab_label_packing, 2, 2, 0, /*
Return a list of packing information (EXPAND FILL PACK_TYPE) for CHILD in NOTEBOOK.
*/
       (notebook, child))
{
  gboolean expand, fill;
  GtkPackType pack_type;

  CHECK_GTK_OBJECT (notebook);
  CHECK_GTK_OBJECT (child);

  if (!GTK_IS_NOTEBOOK (XGTK_OBJECT (notebook)->object))
    {
      wtaerror ("Object is not a GtkLabel", notebook);
    }

  if (!GTK_IS_WIDGET (XGTK_OBJECT (child)->object))
    {
      wtaerror ("Object is not a GtkWidget", child);
    }

  gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (XGTK_OBJECT (notebook)->object),
					GTK_WIDGET (XGTK_OBJECT (child)->object),
					&expand, &fill, &pack_type);

  return (list3 (expand ? Qt : Qnil, fill ? Qt : Qnil, make_int (pack_type)));
}

DEFUN ("gtk-widget-get-pointer", Fgtk_widget_get_pointer, 1, 1, 0, /*
Return the pointer position relative to WIDGET as a cons of (X . Y).
*/
       (widget))
{
  gint x,y;
  CHECK_GTK_OBJECT (widget);

  if (!GTK_IS_WIDGET (XGTK_OBJECT (widget)->object))
    {
      wtaerror ("Object is not a GtkWidget", widget);
    }

  gtk_widget_get_pointer (GTK_WIDGET (XGTK_OBJECT (widget)->object), &x, &y);

  return (Fcons (make_int (x), make_int (y)));
}

/* This is called whenever an item with a GUI_ID associated with it is
   destroyed.  This allows us to remove the references in gui-gtk.c
   that made sure callbacks and such were GCPRO-ed
*/
static void
__remove_gcpro_by_id (gpointer user_data)
{
  ungcpro_popup_callbacks ((GUI_ID) user_data);
}

static void
__generic_toolbar_callback (GtkWidget *UNUSED (item), gpointer user_data)
{
  Lisp_Object callback;
  Lisp_Object lisp_user_data;

  callback = VOID_TO_LISP (user_data);

  lisp_user_data = XCAR (callback);
  callback = XCDR (callback);

  signal_special_gtk_user_event (Qnil, callback, lisp_user_data);
}

static Lisp_Object
generic_toolbar_insert_item (Lisp_Object toolbar,
			     Lisp_Object text,
			     Lisp_Object tooltip_text,
			     Lisp_Object tooltip_private_text,
			     Lisp_Object icon,
			     Lisp_Object callback,
			     Lisp_Object data,
			     Lisp_Object prepend_p,
			     Lisp_Object position)
{
  GUI_ID id;
  GtkWidget *w = NULL;

  CHECK_GTK_OBJECT (toolbar);
  CHECK_GTK_OBJECT (icon);
  CHECK_STRING (text);
  CHECK_STRING (tooltip_text);
  CHECK_STRING (tooltip_private_text);

  if (!SYMBOLP (callback) && !LISTP (callback))
    {
      wtaerror ("Callback must be symbol or eval-able form", callback);
    }

  if (!GTK_IS_TOOLBAR (XGTK_OBJECT (toolbar)->object))
    {
      wtaerror ("Object is not a GtkToolbar", toolbar);
    }

  if (!GTK_IS_WIDGET (XGTK_OBJECT (icon)->object))
    {
      wtaerror ("Object is not a GtkWidget", icon);
    }

  callback = Fcons (data, callback);

  id = new_gui_id ();
  gcpro_popup_callbacks (id, callback);
  gtk_object_weakref (XGTK_OBJECT (toolbar)->object, __remove_gcpro_by_id,
		      (gpointer) id);

  if (NILP (position))
    {
      w = (NILP (prepend_p) ? gtk_toolbar_append_item : gtk_toolbar_prepend_item)
	(GTK_TOOLBAR (XGTK_OBJECT (toolbar)->object),
	 (char*) XSTRING_DATA (text),
	 (char*) XSTRING_DATA (tooltip_text),
	 (char*) XSTRING_DATA (tooltip_private_text),
	 GTK_WIDGET (XGTK_OBJECT (icon)->object),
	 GTK_SIGNAL_FUNC (__generic_toolbar_callback),
	 LISP_TO_VOID (callback));
    }
  else
    {
      w = gtk_toolbar_insert_item (GTK_TOOLBAR (XGTK_OBJECT (toolbar)->object),
				   (char*) XSTRING_DATA (text),
				   (char*) XSTRING_DATA (tooltip_text),
				   (char*) XSTRING_DATA (tooltip_private_text),
				   GTK_WIDGET (XGTK_OBJECT (icon)->object),
				   GTK_SIGNAL_FUNC (__generic_toolbar_callback),
				   LISP_TO_VOID (callback),
				   XINT (position));
    }


  return (w ? build_gtk_object (GTK_OBJECT (w)) : Qnil);
}

DEFUN ("gtk-toolbar-append-item", Fgtk_toolbar_append_item, 6, 7, 0, /*
Appends a new button to the given toolbar.
*/
	   (toolbar, text, tooltip_text, tooltip_private_text, icon, callback, data))
{
  return (generic_toolbar_insert_item (toolbar,text,tooltip_text,tooltip_private_text,icon,callback,data,Qnil,Qnil));
}

DEFUN ("gtk-toolbar-prepend-item", Fgtk_toolbar_prepend_item, 6, 7, 0, /*
Adds a new button to the beginning (left or top edges) of the given toolbar.
*/
	   (toolbar, text, tooltip_text, tooltip_private_text, icon, callback, data))
{
  return (generic_toolbar_insert_item (toolbar,text,tooltip_text,tooltip_private_text,icon,callback,data,Qt,Qnil));
}

DEFUN ("gtk-toolbar-insert-item", Fgtk_toolbar_insert_item, 7, 8, 0, /*
Adds a new button to the beginning (left or top edges) of the given toolbar.
*/
	   (toolbar, text, tooltip_text, tooltip_private_text, icon, callback, position, data))
{
  CHECK_INT (position);

  return (generic_toolbar_insert_item (toolbar,text,tooltip_text,tooltip_private_text,icon,callback,data,Qnil,position));
}

/* GtkCTree is an abomination in the eyes of the object system. */
static void
__emacs_gtk_ctree_recurse_internal (GtkCTree *ctree, GtkCTreeNode *node, gpointer user_data)
{
  Lisp_Object closure;

  closure = VOID_TO_LISP (user_data);

  call3 (XCAR (closure),
	 build_gtk_object (GTK_OBJECT (ctree)),
	 build_gtk_boxed (node, GTK_TYPE_CTREE_NODE),
	 XCDR (closure));
}

DEFUN ("gtk-ctree-recurse", Fgtk_ctree_recurse, 3, 6, 0, /*
Recursively apply FUNC to all nodes of CTREE at or below NODE.
FUNC is called with three arguments: CTREE, a GtkCTreeNode, and DATA.
The return value of FUNC is ignored.

If optional 5th argument CHILDFIRSTP is non-nil, then
the function is called for each node after it has been
called for that node's children.

Optional 6th argument DEPTH limits how deeply to recurse.

This function encompasses all the following Gtk functions:

void gtk_ctree_post_recursive                    (GtkCTree     *ctree, 
						  GtkCTreeNode *node,
						  GtkCTreeFunc  func,
						  gpointer      data);
void gtk_ctree_post_recursive_to_depth           (GtkCTree     *ctree, 
						  GtkCTreeNode *node,
						  gint          depth,
						  GtkCTreeFunc  func,
						  gpointer      data);
void gtk_ctree_pre_recursive                     (GtkCTree     *ctree, 
						  GtkCTreeNode *node,
						  GtkCTreeFunc  func,
						  gpointer      data);
void gtk_ctree_pre_recursive_to_depth            (GtkCTree     *ctree, 
						  GtkCTreeNode *node,
						  gint          depth,
						  GtkCTreeFunc  func,
						  gpointer      data);
*/
       (ctree, node, func, data, childfirstp, depth))
{
  struct gcpro gcpro1, gcpro2, gcpro3;
  Lisp_Object closure = Qnil;

  CHECK_GTK_OBJECT (ctree);

  if (!NILP (node))
    {
      CHECK_GTK_BOXED (node);
    }

  if (!NILP (depth))
    {
      CHECK_INT (depth);
    }

  closure = Fcons (func, data);

  GCPRO3 (ctree, node, closure);

  if (NILP (depth))
    {
      (NILP (childfirstp) ? gtk_ctree_post_recursive : gtk_ctree_pre_recursive)
	(GTK_CTREE (XGTK_OBJECT (ctree)->object),
	 NILP (node) ? NULL : (GtkCTreeNode *) XGTK_BOXED (node)->object,
	 __emacs_gtk_ctree_recurse_internal,
	 LISP_TO_VOID (closure));
    }
  else
    {
      (NILP (childfirstp) ? gtk_ctree_post_recursive_to_depth : gtk_ctree_pre_recursive_to_depth)
	(GTK_CTREE (XGTK_OBJECT (ctree)->object),
	 NILP (node) ? NULL : (GtkCTreeNode *) XGTK_BOXED (node)->object,
	 XINT (depth),
	 __emacs_gtk_ctree_recurse_internal,
	 LISP_TO_VOID (closure));
    }

  UNGCPRO;
  return (Qnil);
}

void syms_of_ui_byhand (void)
{
  DEFSUBR (Fgtk_toolbar_append_item);
  DEFSUBR (Fgtk_toolbar_insert_item);
  DEFSUBR (Fgtk_toolbar_prepend_item);
  DEFSUBR (Fgtk_box_query_child_packing);
  DEFSUBR (Fgtk_button_box_get_child_size_default);
  DEFSUBR (Fgtk_button_box_get_child_ipadding_default);
  DEFSUBR (Fgtk_button_box_get_child_size);
  DEFSUBR (Fgtk_button_box_get_child_ipadding);
  DEFSUBR (Fgtk_calendar_get_date);
  DEFSUBR (Fgtk_clist_get_text);
  DEFSUBR (Fgtk_clist_get_selection);
  DEFSUBR (Fgtk_clist_get_pixmap);
  DEFSUBR (Fgtk_clist_get_pixtext);
  DEFSUBR (Fgtk_color_selection_get_color);
  DEFSUBR (Fgtk_editable_insert_text);
  DEFSUBR (Fgtk_pixmap_get);
  DEFSUBR (Fgtk_curve_get_vector);
  DEFSUBR (Fgtk_curve_set_vector);
  DEFSUBR (Fgtk_label_get);
  DEFSUBR (Fgtk_notebook_query_tab_label_packing);
  DEFSUBR (Fgtk_widget_get_pointer);
  DEFSUBR (Fgtk_ctree_recurse);
}