3 ** Description: Interface to `libglade' for XEmacs/GTK
5 ** Created by: William M. Perry <wmperry@gnu.org>
7 ** Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk>
8 ** Copyright (c) 2000 Free Software Foundation
12 #if defined(HAVE_GLADE_H) || defined(HAVE_GLADE_GLADE_H)
14 /* For COMPILED_FUNCTIONP */
17 #ifdef HAVE_GLADE_GLADE_H
18 #include <glade/glade.h>
25 /* This is based on the code from rep-gtk 0.11 in libglade-support.c */
28 connector (const gchar *handler_name, GtkObject *object,
29 const gchar *signal_name, const gchar *signal_data,
30 GtkObject *connect_object, gboolean after, gpointer user_data)
33 Lisp_Object lisp_data = Qnil;
35 VOID_TO_LISP (func, user_data);
39 /* Look for a lisp function called HANDLER_NAME */
40 func = intern (handler_name);
43 if (signal_data && signal_data[0])
45 lisp_data = Feval (Fread (build_string (signal_data)));
48 /* obj, name, func, cb_data, object_signal, after_p */
49 Fgtk_signal_connect (build_gtk_object (object),
53 connect_object ? Qt : Qnil,
57 /* This differs from lisp/subr.el (functionp) definition by allowing
58 ** symbol names that may not necessarily be fboundp yet.
60 static int __almost_functionp (Lisp_Object obj)
62 return (SYMBOLP (obj) ||
64 COMPILED_FUNCTIONP (obj) ||
65 EQ (Fcar_safe (obj), Qlambda));
68 DEFUN ("glade-xml-signal-connect", Fglade_xml_signal_connect, 3, 3, 0, /*
69 Connect a glade handler.
71 (xml, handler_name, func))
73 CHECK_GTK_OBJECT (xml);
74 CHECK_STRING (handler_name);
76 if (!__almost_functionp (func))
78 func = wrong_type_argument (intern ("functionp"), func);
81 glade_xml_signal_connect_full (GLADE_XML (XGTK_OBJECT (xml)->object),
82 XSTRING_DATA (handler_name),
83 connector, LISP_TO_VOID (func));
87 DEFUN ("glade-xml-signal-autoconnect", Fglade_xml_signal_autoconnect, 1, 1, 0, /*
88 Connect all glade handlers.
92 CHECK_GTK_OBJECT (xml);
94 glade_xml_signal_autoconnect_full (GLADE_XML (XGTK_OBJECT (xml)->object),
95 connector, LISP_TO_VOID (Qnil));
99 DEFUN ("glade-xml-textdomain", Fglade_xml_textdomain, 1, 1, 0, /*
100 Return the textdomain of a GladeXML object.
104 gchar *the_domain = NULL;
106 CHECK_GTK_OBJECT (xml);
108 if (!GLADE_IS_XML (XGTK_OBJECT (xml)->object))
110 signal_simple_error ("Object is not a GladeXML type.", xml);
113 #ifdef LIBGLADE_XML_TXTDOMAIN
114 the_domain = GLADE_XML (XGTK_OBJECT (xml)->object)->txtdomain;
116 the_domain = GLADE_XML (XGTK_OBJECT (xml)->object)->textdomain;
118 return (build_string (the_domain));
121 void syms_of_glade (void)
123 DEFSUBR (Fglade_xml_signal_connect);
124 DEFSUBR (Fglade_xml_signal_autoconnect);
125 DEFSUBR (Fglade_xml_textdomain);
128 void vars_of_glade (void)
130 Fprovide (intern ("glade"));
133 #else /* !(HAVE_GLADE_H || HAVE_GLADE_GLADE_H) */
134 #define syms_of_glade()
135 #define vars_of_glade()