annotate lisp/widgets-gtk.el @ 462:0784d089fdc9 r21-2-46

Import from CVS: tag r21-2-46
author cvs
date Mon, 13 Aug 2007 11:44:37 +0200
parents
children 7039e6323819
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 ;;; widgets-gtk.el --- Embedded widget support for XEmacs w/GTK primitives
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) 2001 Free Software Foundation, Inc.
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 M. Perry <wmperry@gnu.org>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 ;; Keywords: extensions, internal, 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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 ;; any later version.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18 ;; General Public License for more details.
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
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 ;;; Synched up with: Not in FSF.
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 ;;; Commentary:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 ;; This file is dumped with XEmacs (when embedded widgets are compiled in).
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 (defvar foo)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 (defun gtk-widget-instantiate-button-internal (plist callback)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 (let* ((type (or (plist-get plist :style) 'button))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35 (label (or (plist-get plist :descriptor) (symbol-name type)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36 (widget nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 (case type
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38 (button
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 (setq widget (gtk-button-new-with-label label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 (gtk-signal-connect widget 'clicked (lambda (wid real-cb)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 (if (functionp real-cb)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 (funcall real-cb)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 (eval real-cb)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 callback))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 (radio
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 (let ((aux nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 (selected-p (plist-get plist :selected)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 (setq widget (gtk-radio-button-new-with-label nil label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49 aux (gtk-radio-button-new-with-label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 (gtk-radio-button-group widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 "bogus sibling"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 (gtk-toggle-button-set-active widget (eval selected-p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 (gtk-signal-connect widget 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 (lambda (wid data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 ;; data is (real-cb . sibling)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 )
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 (cons callback aux))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 (otherwise
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 ;; Check boxes
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 (setq widget (gtk-check-button-new-with-label label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 (gtk-toggle-button-set-active widget
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 (eval (plist-get plist :selected)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 (gtk-signal-connect widget 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 (lambda (wid real-cb)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 (if (functionp real-cb)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 (funcall real-cb)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 (eval real-cb)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 callback)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70 (gtk-widget-show-all widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 widget))
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 (defun gtk-widget-instantiate-notebook-internal (plist callback)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 (let ((widget (gtk-notebook-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 (items (plist-get plist :items)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76 (while items
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 (gtk-notebook-append-page widget
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 (gtk-vbox-new nil 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 (gtk-label-new (aref (car items) 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 (setq items (cdr items)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 (defun gtk-widget-instantiate-progress-internal (plist callback)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84 (let* ((adj (gtk-adjustment-new 0.0 0.0 100.0 1.0 5.0 5.0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 (widget (gtk-progress-bar-new-with-adjustment adj)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 (gtk-adjustment-set-value adj (or (plist-get plist :value) 0.0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 widget))
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 (defun gtk-widget-instantiate-entry-internal (plist callback)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 (let* ((widget (gtk-entry-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 (default (plist-get plist :descriptor)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 (cond
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 ((stringp default)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 ((sequencep default)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 (setq default (mapconcat 'identity default "")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 (t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 (error "Invalid default value: %S" default)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 (gtk-entry-set-text widget default)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 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 (put 'button 'instantiator 'gtk-widget-instantiate-button-internal)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 (put 'tab-control 'instantiator 'gtk-widget-instantiate-notebook-internal)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 (put 'progress-gauge 'instantiator 'gtk-widget-instantiate-progress-internal)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 (put 'tree-view 'instantiator 'ignore)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 (put 'edit-field 'instantiator 'gtk-widget-instantiate-entry-internal)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 (put 'combo-box 'instantiator 'ignore)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 (put 'label 'instantiator 'ignore)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 (put 'layout 'instantiator 'ignore)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 (defun gtk-widget-instantiate-internal (instance
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 instantiator
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 pointer-fg
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 pointer-bg
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 "The lisp side of widget/glyph instantiation code."
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 (let* ((type (aref instantiator 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118 (plist (cdr (map 'list 'identity instantiator)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 (widget (funcall (or (get type 'instantiator) 'ignore)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 plist (or (plist-get plist :callback) 'ignore))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 (add-timeout 0.1 (lambda (obj)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 (gtk-widget-set-style obj
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 (gtk-widget-get-style
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 (frame-property nil 'text-widget))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 (setq x widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 (defun gtk-widget-property-internal ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 (defun gtk-widget-redisplay-internal ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 (provide 'widgets-gtk)