462
|
1 ;;; widgets-gtk.el --- Embedded widget support for XEmacs w/GTK primitives
|
|
2
|
|
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Maintainer: William M. Perry <wmperry@gnu.org>
|
|
6 ;; Keywords: extensions, internal, dumped
|
|
7
|
|
8 ;; This file is part of XEmacs.
|
|
9
|
|
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)
|
|
13 ;; any later version.
|
|
14
|
|
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.
|
|
19
|
|
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.
|
|
24
|
|
25 ;;; Synched up with: Not in FSF.
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
|
29 ;; This file is dumped with XEmacs (when embedded widgets are compiled in).
|
|
30
|
502
|
31 (globally-declare-fboundp
|
|
32 '(gtk-button-new-with-label
|
|
33 gtk-signal-connect
|
|
34 gtk-radio-button-new-with-label gtk-radio-button-group
|
|
35 gtk-toggle-button-set-active gtk-check-button-new-with-label
|
|
36 gtk-widget-show-all gtk-notebook-new gtk-notebook-append-page
|
|
37 gtk-vbox-new gtk-label-new gtk-adjustment-new
|
|
38 gtk-progress-bar-new-with-adjustment gtk-adjustment-set-value
|
|
39 gtk-entry-new gtk-entry-set-text gtk-widget-set-style
|
|
40 gtk-widget-get-style))
|
|
41
|
462
|
42 (defvar foo)
|
|
43
|
|
44 (defun gtk-widget-instantiate-button-internal (plist callback)
|
|
45 (let* ((type (or (plist-get plist :style) 'button))
|
|
46 (label (or (plist-get plist :descriptor) (symbol-name type)))
|
|
47 (widget nil))
|
|
48 (case type
|
|
49 (button
|
|
50 (setq widget (gtk-button-new-with-label label))
|
|
51 (gtk-signal-connect widget 'clicked (lambda (wid real-cb)
|
|
52 (if (functionp real-cb)
|
|
53 (funcall real-cb)
|
|
54 (eval real-cb)))
|
|
55 callback))
|
|
56 (radio
|
|
57 (let ((aux nil)
|
|
58 (selected-p (plist-get plist :selected)))
|
|
59 (setq widget (gtk-radio-button-new-with-label nil label)
|
|
60 aux (gtk-radio-button-new-with-label
|
|
61 (gtk-radio-button-group widget)
|
|
62 "bogus sibling"))
|
|
63 (gtk-toggle-button-set-active widget (eval selected-p))
|
|
64 (gtk-signal-connect widget 'toggled
|
|
65 (lambda (wid data)
|
|
66 ;; data is (real-cb . sibling)
|
|
67 )
|
|
68 (cons callback aux))))
|
|
69 (otherwise
|
|
70 ;; Check boxes
|
|
71 (setq widget (gtk-check-button-new-with-label label))
|
|
72 (gtk-toggle-button-set-active widget
|
|
73 (eval (plist-get plist :selected)))
|
|
74 (gtk-signal-connect widget 'toggled
|
|
75 (lambda (wid real-cb)
|
|
76 (if (functionp real-cb)
|
|
77 (funcall real-cb)
|
|
78 (eval real-cb)))
|
|
79 callback)))
|
|
80
|
|
81 (gtk-widget-show-all widget)
|
|
82 widget))
|
|
83
|
|
84 (defun gtk-widget-instantiate-notebook-internal (plist callback)
|
|
85 (let ((widget (gtk-notebook-new))
|
|
86 (items (plist-get plist :items)))
|
|
87 (while items
|
|
88 (gtk-notebook-append-page widget
|
|
89 (gtk-vbox-new nil 3)
|
|
90 (gtk-label-new (aref (car items) 0)))
|
|
91 (setq items (cdr items)))
|
|
92 widget))
|
|
93
|
|
94 (defun gtk-widget-instantiate-progress-internal (plist callback)
|
|
95 (let* ((adj (gtk-adjustment-new 0.0 0.0 100.0 1.0 5.0 5.0))
|
|
96 (widget (gtk-progress-bar-new-with-adjustment adj)))
|
|
97 (gtk-adjustment-set-value adj (or (plist-get plist :value) 0.0))
|
|
98 widget))
|
|
99
|
|
100 (defun gtk-widget-instantiate-entry-internal (plist callback)
|
|
101 (let* ((widget (gtk-entry-new))
|
|
102 (default (plist-get plist :descriptor)))
|
|
103 (cond
|
|
104 ((stringp default)
|
|
105 nil)
|
|
106 ((sequencep default)
|
|
107 (setq default (mapconcat 'identity default "")))
|
|
108 (t
|
|
109 (error "Invalid default value: %S" default)))
|
|
110 (gtk-entry-set-text widget default)
|
|
111 widget))
|
|
112
|
|
113 (put 'button 'instantiator 'gtk-widget-instantiate-button-internal)
|
|
114 (put 'tab-control 'instantiator 'gtk-widget-instantiate-notebook-internal)
|
|
115 (put 'progress-gauge 'instantiator 'gtk-widget-instantiate-progress-internal)
|
|
116 (put 'tree-view 'instantiator 'ignore)
|
|
117 (put 'edit-field 'instantiator 'gtk-widget-instantiate-entry-internal)
|
|
118 (put 'combo-box 'instantiator 'ignore)
|
|
119 (put 'label 'instantiator 'ignore)
|
|
120 (put 'layout 'instantiator 'ignore)
|
|
121
|
|
122 (defun gtk-widget-instantiate-internal (instance
|
|
123 instantiator
|
|
124 pointer-fg
|
|
125 pointer-bg
|
|
126 domain)
|
|
127 "The lisp side of widget/glyph instantiation code."
|
|
128 (let* ((type (aref instantiator 0))
|
|
129 (plist (cdr (map 'list 'identity instantiator)))
|
|
130 (widget (funcall (or (get type 'instantiator) 'ignore)
|
|
131 plist (or (plist-get plist :callback) 'ignore))))
|
|
132 (add-timeout 0.1 (lambda (obj)
|
|
133 (gtk-widget-set-style obj
|
|
134 (gtk-widget-get-style
|
|
135 (frame-property nil 'text-widget))))
|
|
136 widget)
|
|
137 widget))
|
|
138
|
|
139 (defun gtk-widget-property-internal ()
|
|
140 nil)
|
|
141
|
|
142 (defun gtk-widget-redisplay-internal ()
|
|
143 nil)
|
|
144
|
|
145 (provide 'widgets-gtk)
|