1 ;;; widgets-gtk.el --- Embedded widget support for XEmacs w/GTK primitives
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
5 ;; Maintainer: William M. Perry <wmperry@gnu.org>
6 ;; Keywords: extensions, internal, dumped
8 ;; This file is part of XEmacs.
10 ;; XEmacs is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; XEmacs is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Synched up with: Not in FSF.
29 ;; This file is dumped with XEmacs (when embedded widgets are compiled in).
33 (defun gtk-widget-instantiate-button-internal (plist callback)
34 (let* ((type (or (plist-get plist :style) 'button))
35 (label (or (plist-get plist :descriptor) (symbol-name type)))
39 (setq widget (gtk-button-new-with-label label))
40 (gtk-signal-connect widget 'clicked (lambda (wid real-cb)
41 (if (functionp real-cb)
47 (selected-p (plist-get plist :selected)))
48 (setq widget (gtk-radio-button-new-with-label nil label)
49 aux (gtk-radio-button-new-with-label
50 (gtk-radio-button-group widget)
52 (gtk-toggle-button-set-active widget (eval selected-p))
53 (gtk-signal-connect widget 'toggled
55 ;; data is (real-cb . sibling)
57 (cons callback aux))))
60 (setq widget (gtk-check-button-new-with-label label))
61 (gtk-toggle-button-set-active widget
62 (eval (plist-get plist :selected)))
63 (gtk-signal-connect widget 'toggled
65 (if (functionp real-cb)
70 (gtk-widget-show-all widget)
73 (defun gtk-widget-instantiate-notebook-internal (plist callback)
74 (let ((widget (gtk-notebook-new))
75 (items (plist-get plist :items)))
77 (gtk-notebook-append-page widget
79 (gtk-label-new (aref (car items) 0)))
80 (setq items (cdr items)))
83 (defun gtk-widget-instantiate-progress-internal (plist callback)
84 (let* ((adj (gtk-adjustment-new 0.0 0.0 100.0 1.0 5.0 5.0))
85 (widget (gtk-progress-bar-new-with-adjustment adj)))
86 (gtk-adjustment-set-value adj (or (plist-get plist :value) 0.0))
89 (defun gtk-widget-instantiate-entry-internal (plist callback)
90 (let* ((widget (gtk-entry-new))
91 (default (plist-get plist :descriptor)))
96 (setq default (mapconcat 'identity default "")))
98 (error "Invalid default value: %S" default)))
99 (gtk-entry-set-text widget default)
102 (put 'button 'instantiator 'gtk-widget-instantiate-button-internal)
103 (put 'tab-control 'instantiator 'gtk-widget-instantiate-notebook-internal)
104 (put 'progress-gauge 'instantiator 'gtk-widget-instantiate-progress-internal)
105 (put 'tree-view 'instantiator 'ignore)
106 (put 'edit-field 'instantiator 'gtk-widget-instantiate-entry-internal)
107 (put 'combo-box 'instantiator 'ignore)
108 (put 'label 'instantiator 'ignore)
109 (put 'layout 'instantiator 'ignore)
111 (defun gtk-widget-instantiate-internal (instance
116 "The lisp side of widget/glyph instantiation code."
117 (let* ((type (aref instantiator 0))
118 (plist (cdr (map 'list 'identity instantiator)))
119 (widget (funcall (or (get type 'instantiator) 'ignore)
120 plist (or (plist-get plist :callback) 'ignore))))
121 (add-timeout 0.1 (lambda (obj)
122 (gtk-widget-set-style obj
123 (gtk-widget-get-style
124 (frame-property nil 'text-widget))))
129 (defun gtk-widget-property-internal ()
132 (defun gtk-widget-redisplay-internal ()
135 (provide 'widgets-gtk)