462
|
1 ;;; gtk-init.el --- initialization code for mswindows
|
|
2 ;; Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc.
|
|
3 ;; Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
4 ;; Copyright (C) 1995, 1996 Ben Wing.
|
|
5
|
|
6 ;; Author: various
|
|
7 ;; Rewritten for Gtk by: William Perry
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
11 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
12 ;; under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
14 ;; any later version.
|
|
15
|
|
16 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
|
24 ;; Boston, MA 02111-1307, USA.
|
|
25
|
502
|
26 (globally-declare-boundp
|
|
27 '(gtk-initial-argv-list
|
506
|
28 gtk-initial-geometry))
|
|
29
|
|
30 (globally-declare-fboundp
|
|
31 '(gtk-keysym-on-keyboard-p))
|
502
|
32
|
462
|
33 (defvar gtk-win-initted nil)
|
|
34 (defvar gtk-pre-win-initted nil)
|
|
35 (defvar gtk-post-win-initted nil)
|
|
36
|
|
37 (defvar gtk-command-switch-alist
|
|
38 '(
|
|
39 ;; GNOME Options
|
|
40 ("--disable-sound" . nil)
|
|
41 ("--enable-sound" . nil)
|
|
42 ("--espeaker" . t)
|
|
43
|
|
44 ;; GTK Options
|
|
45 ("--gdk-debug" . t)
|
|
46 ("--gdk-no-debug" . t)
|
|
47 ("--display" . t)
|
|
48 ("--sync" . nil)
|
|
49 ("--no-xshm" . nil)
|
|
50 ("--name" . t)
|
|
51 ("--class" . t)
|
|
52 ("--gxid_host" . t)
|
|
53 ("--gxid_port" . t)
|
|
54 ("--xim-preedit" . t)
|
|
55 ("--xim-status" . t)
|
|
56 ("--gtk-debug" . t)
|
|
57 ("--gtk-no-debug" . t)
|
|
58 ("--gtk-module" . t)
|
|
59
|
|
60 ;; Glib options
|
|
61 ("--g-fatal-warnings" . nil)
|
|
62
|
|
63 ;; Session management options
|
|
64 ("--sm-client-id" . t)
|
|
65 ("--sm-config-prefix" . t)
|
|
66 ("--sm-disable" . t)
|
|
67 )
|
|
68
|
|
69 "An assoc list of command line arguments that should in gtk-initial-argv-list.
|
|
70 This is necessary because GTK and GNOME consider it a fatal error if they receive
|
|
71 unknown command line arguments (perfectly reasonable). But this means that if
|
|
72 the user specifies a file name on the command line they will be unable to start.
|
|
73 So we filter the command line and allow only items in this list in.
|
|
74
|
|
75 The CDR of the assoc list is whether it accepts an argument. All options are in
|
|
76 GNU long form though.")
|
|
77
|
|
78 (defun init-pre-gtk-win ()
|
|
79 "Initialize Gtk GUI at startup (pre). Don't call this."
|
|
80 (when (not gtk-pre-win-initted)
|
|
81 (setq initial-frame-plist (if initial-frame-unmapped-p
|
|
82 '(initially-unmapped t)
|
|
83 nil)
|
|
84 gtk-pre-win-initted t)))
|
|
85
|
|
86 (defun gtk-init-handle-geometry (arg)
|
|
87 "Set up initial geometry info for GTK devices."
|
|
88 (setq gtk-initial-geometry (pop command-line-args-left)))
|
|
89
|
|
90 (defun gtk-filter-arguments ()
|
|
91 (let ((accepted nil)
|
|
92 (rejected nil)
|
|
93 (todo nil))
|
|
94 (setq todo (mapcar (lambda (argdesc)
|
|
95 (if (cdr argdesc)
|
|
96 ;; Need to look for --foo=bar
|
|
97 (concat "^" (car argdesc) "=")
|
|
98 ;; Just a simple arg
|
|
99 (concat "^" (regexp-quote (car argdesc)) "$")))
|
|
100 gtk-command-switch-alist))
|
|
101
|
|
102 (while command-line-args-left
|
|
103 (if (catch 'found
|
|
104 (mapc (lambda (r)
|
|
105 (if (string-match r (car command-line-args-left))
|
|
106 (throw 'found t))) todo)
|
|
107 (mapc (lambda (argdesc)
|
|
108 (if (cdr argdesc)
|
|
109 ;; This time we only care about argument items
|
|
110 ;; that take an argument. We'll check to see if
|
|
111 ;; someone used --foo bar instead of --foo=bar
|
|
112 (if (string-match (concat "^" (car argdesc) "$") (car command-line-args-left))
|
|
113 ;; Yup! Need to push
|
|
114 (progn
|
|
115 (push (pop command-line-args-left) accepted)
|
|
116 (throw 'found t)))))
|
|
117 gtk-command-switch-alist)
|
|
118 nil)
|
|
119 (push (pop command-line-args-left) accepted)
|
|
120 (push (pop command-line-args-left) rejected)))
|
|
121 (setq command-line-args-left (nreverse rejected))
|
|
122 (nreverse accepted)))
|
|
123
|
|
124 (defun init-gtk-win ()
|
|
125 "Initialize Gtk GUI at startup. Don't call this."
|
|
126 (unless gtk-win-initted
|
|
127 (init-pre-gtk-win)
|
|
128 (setq gtk-initial-argv-list (cons (car command-line-args) (gtk-filter-arguments))
|
|
129 gtk-initial-geometry (nth 1 (member "-geometry" command-line-args-left)))
|
|
130 (make-gtk-device)
|
|
131 (init-post-gtk-win)
|
|
132 (setq gtk-win-initted t)))
|
|
133
|
|
134 (defun init-post-gtk-win ()
|
|
135 (unless gtk-post-win-initted
|
|
136 (setq gtk-post-win-initted t)))
|
|
137
|
|
138 (push '("-geometry" . gtk-init-handle-geometry) command-switch-alist)
|
|
139
|
|
140 ;;; Stuff to get compose keys working on GTK
|
|
141 (eval-when-compile
|
|
142 (defmacro gtk-define-dead-key (key map)
|
|
143 `(when (gtk-keysym-on-keyboard-p ',key)
|
|
144 (define-key function-key-map [,key] ',map))))
|
|
145
|
|
146 (defun gtk-initialize-compose ()
|
|
147 "Enable compose processing"
|
|
148 (autoload 'compose-map "gtk-compose" nil t 'keymap)
|
|
149 (autoload 'compose-acute-map "gtk-compose" nil t 'keymap)
|
|
150 (autoload 'compose-grave-map "gtk-compose" nil t 'keymap)
|
|
151 (autoload 'compose-cedilla-map "gtk-compose" nil t 'keymap)
|
|
152 (autoload 'compose-diaeresis-map "gtk-compose" nil t 'keymap)
|
|
153 (autoload 'compose-circumflex-map "gtk-compose" nil t 'keymap)
|
|
154 (autoload 'compose-tilde-map "gtk-compose" nil t 'keymap)
|
|
155
|
|
156 (when (gtk-keysym-on-keyboard-p 'multi-key)
|
|
157 (define-key function-key-map [multi-key] 'compose-map))
|
|
158
|
|
159 ;; The dead keys might really be called just about anything, depending
|
|
160 ;; on the vendor. MIT thinks that the prefixes are "SunFA_", "D", and
|
|
161 ;; "hpmute_" for Sun, DEC, and HP respectively. However, OpenWindows 3
|
|
162 ;; thinks that the prefixes are "SunXK_FA_", "DXK_", and "hpXK_mute_".
|
|
163 ;; And HP (who don't mention Sun and DEC at all) use "XK_mute_".
|
|
164 ;; Go figure.
|
|
165
|
|
166 ;; Presumably if someone is running OpenWindows, they won't be using
|
|
167 ;; the DEC or HP keysyms, but if they are defined then that is possible,
|
|
168 ;; so in that case we accept them all.
|
|
169
|
|
170 ;; If things seem not to be working, you might want to check your
|
|
171 ;; /usr/lib/X11/XKeysymDB file to see if your vendor has an equally
|
|
172 ;; mixed up view of what these keys should be called.
|
|
173
|
|
174 ;; Canonical names:
|
|
175 (gtk-define-dead-key acute compose-acute-map)
|
|
176 (gtk-define-dead-key grave compose-grave-map)
|
|
177 (gtk-define-dead-key cedilla compose-cedilla-map)
|
|
178 (gtk-define-dead-key diaeresis compose-diaeresis-map)
|
|
179 (gtk-define-dead-key circumflex compose-circumflex-map)
|
|
180 (gtk-define-dead-key tilde compose-tilde-map)
|
|
181 (gtk-define-dead-key degree compose-ring-map)
|
|
182
|
|
183 ;; Sun according to MIT:
|
|
184 (gtk-define-dead-key SunFA_Acute compose-acute-map)
|
|
185 (gtk-define-dead-key SunFA_Grave compose-grave-map)
|
|
186 (gtk-define-dead-key SunFA_Cedilla compose-cedilla-map)
|
|
187 (gtk-define-dead-key SunFA_Diaeresis compose-diaeresis-map)
|
|
188 (gtk-define-dead-key SunFA_Circum compose-circumflex-map)
|
|
189 (gtk-define-dead-key SunFA_Tilde compose-tilde-map)
|
|
190
|
|
191 ;; Sun according to OpenWindows 2:
|
|
192 (gtk-define-dead-key Dead_Grave compose-grave-map)
|
|
193 (gtk-define-dead-key Dead_Circum compose-circumflex-map)
|
|
194 (gtk-define-dead-key Dead_Tilde compose-tilde-map)
|
|
195
|
|
196 ;; Sun according to OpenWindows 3:
|
|
197 (gtk-define-dead-key SunXK_FA_Acute compose-acute-map)
|
|
198 (gtk-define-dead-key SunXK_FA_Grave compose-grave-map)
|
|
199 (gtk-define-dead-key SunXK_FA_Cedilla compose-cedilla-map)
|
|
200 (gtk-define-dead-key SunXK_FA_Diaeresis compose-diaeresis-map)
|
|
201 (gtk-define-dead-key SunXK_FA_Circum compose-circumflex-map)
|
|
202 (gtk-define-dead-key SunXK_FA_Tilde compose-tilde-map)
|
|
203
|
|
204 ;; DEC according to MIT:
|
|
205 (gtk-define-dead-key Dacute_accent compose-acute-map)
|
|
206 (gtk-define-dead-key Dgrave_accent compose-grave-map)
|
|
207 (gtk-define-dead-key Dcedilla_accent compose-cedilla-map)
|
|
208 (gtk-define-dead-key Dcircumflex_accent compose-circumflex-map)
|
|
209 (gtk-define-dead-key Dtilde compose-tilde-map)
|
|
210 (gtk-define-dead-key Dring_accent compose-ring-map)
|
|
211
|
|
212 ;; DEC according to OpenWindows 3:
|
|
213 (gtk-define-dead-key DXK_acute_accent compose-acute-map)
|
|
214 (gtk-define-dead-key DXK_grave_accent compose-grave-map)
|
|
215 (gtk-define-dead-key DXK_cedilla_accent compose-cedilla-map)
|
|
216 (gtk-define-dead-key DXK_circumflex_accent compose-circumflex-map)
|
|
217 (gtk-define-dead-key DXK_tilde compose-tilde-map)
|
|
218 (gtk-define-dead-key DXK_ring_accent compose-ring-map)
|
|
219
|
|
220 ;; HP according to MIT:
|
|
221 (gtk-define-dead-key hpmute_acute compose-acute-map)
|
|
222 (gtk-define-dead-key hpmute_grave compose-grave-map)
|
|
223 (gtk-define-dead-key hpmute_diaeresis compose-diaeresis-map)
|
|
224 (gtk-define-dead-key hpmute_asciicircum compose-circumflex-map)
|
|
225 (gtk-define-dead-key hpmute_asciitilde compose-tilde-map)
|
|
226
|
|
227 ;; Empirically discovered on Linux XFree86 MetroX:
|
|
228 (gtk-define-dead-key usldead_acute compose-acute-map)
|
|
229 (gtk-define-dead-key usldead_grave compose-grave-map)
|
|
230 (gtk-define-dead-key usldead_diaeresis compose-diaeresis-map)
|
|
231 (gtk-define-dead-key usldead_asciicircum compose-circumflex-map)
|
|
232 (gtk-define-dead-key usldead_asciitilde compose-tilde-map)
|
|
233
|
|
234 ;; HP according to OpenWindows 3:
|
|
235 (gtk-define-dead-key hpXK_mute_acute compose-acute-map)
|
|
236 (gtk-define-dead-key hpXK_mute_grave compose-grave-map)
|
|
237 (gtk-define-dead-key hpXK_mute_diaeresis compose-diaeresis-map)
|
|
238 (gtk-define-dead-key hpXK_mute_asciicircum compose-circumflex-map)
|
|
239 (gtk-define-dead-key hpXK_mute_asciitilde compose-tilde-map)
|
|
240
|
|
241 ;; HP according to HP-UX 8.0:
|
|
242 (gtk-define-dead-key XK_mute_acute compose-acute-map)
|
|
243 (gtk-define-dead-key XK_mute_grave compose-grave-map)
|
|
244 (gtk-define-dead-key XK_mute_diaeresis compose-diaeresis-map)
|
|
245 (gtk-define-dead-key XK_mute_asciicircum compose-circumflex-map)
|
|
246 (gtk-define-dead-key XK_mute_asciitilde compose-tilde-map)
|
|
247
|
|
248 ;; Xfree86 seems to use lower case and a hyphen
|
|
249 (gtk-define-dead-key dead-acute compose-acute-map)
|
|
250 (gtk-define-dead-key dead-grave compose-grave-map)
|
|
251 (gtk-define-dead-key dead-cedilla compose-cedilla-map)
|
|
252 (gtk-define-dead-key dead-diaeresis compose-diaeresis-map)
|
|
253 (gtk-define-dead-key dead-circum compose-circumflex-map)
|
|
254 (gtk-define-dead-key dead-circumflex compose-circumflex-map)
|
|
255 (gtk-define-dead-key dead-tilde compose-tilde-map)
|
|
256 )
|
|
257
|
|
258 (when (featurep 'gtk)
|
|
259 (add-hook
|
|
260 'create-console-hook
|
|
261 (lambda (console)
|
|
262 (letf (((selected-console) console))
|
|
263 (when (eq 'gtk (console-type console))
|
|
264 (gtk-initialize-compose))))))
|