annotate lisp/generic-widgets.el @ 5887:6eca500211f4

Prototype for X509_check_host() has changed, detect this in configure.ac ChangeLog addition: 2015-04-09 Aidan Kehoe <kehoea@parhasard.net> * configure.ac: If X509_check_host() is available, check the number of arguments it takes. Don't use it if it takes any number of arguments other than five. Also don't use it if <openssl/x509v3.h> does not declare it, since if that is so there is no portable way to tell how many arguments it should take, and so we would end up smashing the stack. * configure: Regenerate. src/ChangeLog addition: 2015-04-09 Aidan Kehoe <kehoea@parhasard.net> * tls.c: #include <openssl/x509v3.h> for its prototype for X509_check_host(). * tls.c (tls_open): Pass the new fifth argument to X509_check_host().
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 09 Apr 2015 14:27:02 +0100
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 ;;; generic-widgets.el --- Generic UI building
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 ;; Copyright (C) 2000 Free Software Foundation
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5 ;; Maintainer: William Perry <wmperry@gnu.org>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 ;; Keywords: extensions, dumped
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
10 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
11 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
12 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
13 ;; option) any later version.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
18 ;; for more details.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 502
diff changeset
21 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 ;;; Synched up with: Not in FSF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25 ;;; Commentary:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 ;; This file is dumped with XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
29 (globally-declare-fboundp
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
30 '(gtk-label-new
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
31 gtk-widget-show-all gtk-signal-connect
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
32 gtk-window-new gtk-container-add gtk-vbox-new gtk-hbox-new
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
33 gtk-box-pack-start gtk-notebook-new
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
34 gtk-notebook-set-homogeneous-tabs gtk-notebook-set-scrollable
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
35 gtk-notebook-set-show-tabs gtk-notebook-set-tab-pos
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
36 gtk-notebook-append-page gtk-text-new gtk-text-set-editable
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
37 gtk-text-set-word-wrap gtk-text-set-line-wrap
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
38 gtk-widget-set-style gtk-text-insert gtk-label-set-line-wrap
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
39 gtk-label-set-justify gtk-radio-button-new
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
40 gtk-radio-button-group gtk-check-button-new
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
41 gtk-toggle-button-new gtk-button-new gtk-progress-bar-new
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
42 gtk-progress-bar-set-orientation gtk-progress-bar-set-bar-style))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
43
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 (defun build-ui (ui)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 (if (null ui)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 (gtk-label-new "[empty]")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 (let ((builder-func (intern-soft (format "build-ui::%s" (car ui))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 (widget nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49 (if (and builder-func (fboundp builder-func))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 (progn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 (setq widget (funcall builder-func ui))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 (setcdr ui (plist-put (cdr ui) :x-internal-widget widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 (error "Unknown ui element: %s" (car ui))))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 (defun show-ui (ui)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 (let ((widget (plist-get (cdr ui) :x-internal-widget)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 (if (not widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 (error "Attempting to show unrealized UI"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 (gtk-widget-show-all widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 (gtk-signal-connect widget 'destroy
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 (lambda (widget ui)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 (setcdr ui (plist-put (cdr ui) :x-internal-widget nil))) ui)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 (defun build-ui::window (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 "Create a top-level window for containing other widgets.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 :items list A list of child UI specs. Only the first is used.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70 :type toplevel/dialog/popup What type of window to create. Window managers
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 can (and usually do) treat each type differently.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 (let ((plist (cdr spec))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 (window nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 (child nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76 (setq window (gtk-window-new (plist-get plist :type 'toplevel))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 child (build-ui (car (plist-get plist :items))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 (gtk-container-add window child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 window))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 (defun build-ui::box (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82 "Create a box for containing other widgets.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84 :items list A list of child UI specs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 :homogeneous t/nil Whether all children are the same width/height.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 :spacing number Spacing between children.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 :orientation horizontal/vertical How the widgets are stacked.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 Additional properties on child widgets:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 :expand t/nil Whether the new child is to be given extra space
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 allocated to box. The extra space will be divided
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 evenly between all children of box that use this
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 option.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 :fill t/nil Whether space given to child by the expand option is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 actually allocated to child, rather than just padding
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 it. This parameter has no effect if :expand is set to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 nil. A child is always allocated the full height of a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 horizontal box and the full width of a vertical box.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 This option affects the other dimension.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 :padding number Extra padding around this widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 (let* ((plist (cdr spec))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 (orientation (plist-get plist :orientation 'horizontal))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 (children (plist-get plist :items))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 (box nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 (child-widget nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 (child-plist nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 (case orientation
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 (vertical (setq box (gtk-vbox-new (plist-get plist :homogeneous)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 (plist-get plist :spacing))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 (horizontal (setq box (gtk-hbox-new (plist-get plist :homogeneous)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 (plist-get plist :spacing))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 (otherwise (error "Unknown orientation for box: %s" orientation)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 (mapc
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 (lambda (child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 (setq child-plist (cdr child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 child-widget (build-ui child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118 (if (listp child-widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 (mapc (lambda (w)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 (gtk-box-pack-start box w
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 (plist-get child-plist :expand)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 (plist-get child-plist :fill)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 (plist-get child-plist :padding))) child-widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 (gtk-box-pack-start box child-widget
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 (plist-get child-plist :expand)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 (plist-get child-plist :fill)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 (plist-get child-plist :padding))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 children)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 box))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 (defun build-ui::tab-control (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 "Create a notebook widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 :items list A list of UI specs to use as notebook pages.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 :homogeneous t/nil Whether all tabs are the same width.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 :orientation top/bottom/left/right Position of tabs
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 :show-tabs t/nil Show the tabs on screen?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 :scrollable t/nil Allow scrolling to view all tab widgets?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 Additional properties on child widgets:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 :tab-label ui A UI spec to use for the tab label.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 (let* ((plist (cdr spec))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 (notebook (gtk-notebook-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 (children (plist-get plist :items))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 (page-counter 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 (label-widget nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 (child-widget nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 (child-plist nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 ;; Set all the properties
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 (gtk-notebook-set-homogeneous-tabs notebook (plist-get plist :homogeneous))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152 (gtk-notebook-set-scrollable notebook (plist-get plist :scrollable t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 (gtk-notebook-set-show-tabs notebook (plist-get plist :show-tabs t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 (gtk-notebook-set-tab-pos notebook (plist-get plist :orientation 'top))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 ;; Now fill in the tabs
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 (mapc
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 (lambda (child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159 (setq child-plist (cdr child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 child-widget (build-ui child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 label-widget (build-ui (plist-get child-plist :tab-label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162 (list 'label :text (format "tab %d" page-counter))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 page-counter (1+ page-counter))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 (gtk-notebook-append-page notebook child-widget label-widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 children)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 notebook))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 (defun build-ui::text (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 "Create a multi-line text widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171 :editable t/nil Whether the user can change the contents
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 :word-wrap t/nil Automatic word wrapping?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 :line-wrap t/nil Automatic line wrapping?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 :text string Initial contents of the widget
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 :file filename File for initial contents (takes precedence over :text)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 :face facename XEmacs face to use in the widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 (let* ((plist (cdr spec))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 (text (gtk-text-new nil nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 (face (plist-get plist :face 'default))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 (info (plist-get plist :text))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 (file (plist-get plist :file)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 (gtk-text-set-editable text (plist-get plist :editable))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 (gtk-text-set-word-wrap text (plist-get plist :word-wrap))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 (gtk-text-set-line-wrap text (plist-get plist :line-wrap))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 (gtk-widget-set-style text 'default)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 ;; Possible convert the file portion
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 (if (and file (not (stringp file)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 (setq file (eval file)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 (if (and info (not (stringp info)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 (setq info (eval info)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195 (if (and file (file-exists-p file) (file-readable-p file))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 (save-excursion
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 (set-buffer (get-buffer-create " *improbable buffer name*"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 (insert-file-contents file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 (setq info (buffer-string))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 (gtk-text-insert text
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 (face-font face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 (face-foreground face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 (face-background face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 info (length info))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 text))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 (defun build-ui::label (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 "Create a label widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 :text string Text inside the label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212 :face facename XEmacs face to use in the widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 :justification right/left/center How to justify the text.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 (let* ((plist (cdr spec))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216 (label (gtk-label-new (plist-get plist :text))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 (gtk-label-set-line-wrap label t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 (gtk-label-set-justify label (plist-get plist :justification))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 (gtk-widget-set-style label (plist-get plist :face 'default))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 (defun build-ui::pixmap (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 "Create a multi-line text widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225 :text string Text inside the label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 :face facename XEmacs face to use in the widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 :justification right/left/center How to justify the text.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229 (let* ((plist (cdr spec))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 (label (gtk-label-new (plist-get plist :text))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 (gtk-label-set-line-wrap label t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 (gtk-label-set-justify label (plist-get plist :justification))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 (gtk-widget-set-style label (plist-get plist :face 'default))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234 label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 (defun build-ui::radio-group (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 "A convenience when specifying a group of radio buttons."
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
238 (declare (special build-ui::radio-group))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 (let ((build-ui::radio-group nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 (mapcar 'build-ui (plist-get (cdr spec) :items))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 (defun build-ui::button (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243 "Create a button widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 :type radio/check/toggle/nil What type of button to create.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 :text string Text in the button.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 :glyph glyph Image in the button.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 :label ui A UI spec to use for the label.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 :relief normal/half/none How to draw button edges.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 NOTE: Radio buttons must be in a radio-group object for them to work.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 "
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
253 (declare (special build-ui::radio-group))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
254 (let* ((plist (cdr spec))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
255 (button nil)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 462
diff changeset
256 (button-type (plist-get plist :type 'normal)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 (case button-type
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 (radio
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 (if (not (boundp 'build-ui::radio-group))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 (error "Attempt to use a radio button outside a radio-group"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 (setq button (gtk-radio-button-new build-ui::radio-group)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 build-ui::radio-group (gtk-radio-button-group button)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 (check
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 (setq button (gtk-check-button-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 (toggle
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 (setq button (gtk-toggle-button-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 (normal
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 (setq button (gtk-button-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 (otherwise
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 (error "Unknown button type: %s" button-type)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 (gtk-container-add
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272 button
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 (build-ui (plist-get plist :label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 (list 'label :text
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 (plist-get plist
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 :text (format "%s button" button-type))))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 button))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 (defun build-ui::progress-gauge (spec)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 "Create a progress meter.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 Properties:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 :orientation left-to-right/right-to-left/top-to-bottom/bottom-to-top
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 :type discrete/continuous
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 (let ((plist (cdr spec))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 (gauge (gtk-progress-bar-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 (gtk-progress-bar-set-orientation gauge (plist-get plist :orientation 'left-to-right))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 (gtk-progress-bar-set-bar-style gauge (plist-get plist :type 'continuous))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 gauge))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 (provide 'generic-widgets)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 (when (featurep 'gtk) ; just loading this file should be OK
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 (gtk-widget-show-all
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 (build-ui
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 '(window :type dialog
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 :items ((tab-control
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 :homogeneous t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 :orientation bottom
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 :items ((box :orientation vertical
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 :tab-label (label :text "vertical")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 :items ((label :text "Vertical")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 (progress-gauge)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 (label :text "Box stacking")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 (box :orientation horizontal
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 :spacing 10
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 :items ((label :text "Horizontal box")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 (label :text "stacking")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 (box :orientation vertical
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 :items
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 ((radio-group
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 :items ((button :type radio
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 :expand nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 :fill nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 :text "Item 1")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 (button :type radio
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 :expand nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 :fill nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 :text "Item 2")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 (button :type radio
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 :expand nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 :fill nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 :text "Item 3")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 (button :type radio
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 :expand nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 :fill nil)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 (box :orientation vertical
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 :items ((button :type check
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 :text "Item 1")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 (button :type check
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 :text "Item 2")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 (button :type normal
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 :text "Item 3")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 (button :type toggle)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 (text :editable t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 :word-wrap t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 :file (locate-data-file "COPYING"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 (text :editable t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 :face display-time-mail-balloon-enhance-face
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 :word-wrap t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 :text "Text with a face on it")))))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 )