annotate src/objects-gtk.c @ 2241:6984d5d2c340

[xemacs-hg @ 2004-08-27 21:50:22 by viteno] Update xemacs_extra_name.
author viteno
date Fri, 27 Aug 2004 21:50:22 +0000
parents 91d4c8c65a0f
children 04bc9d2f42c7
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 /* X-specific Lisp objects.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4 Copyright (C) 1995 Tinker Systems.
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
5 Copyright (C) 1995, 1996, 2002 Ben Wing.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems, Inc.
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 the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 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 WITHOUT
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18 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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 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 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 /* Gtk version by William Perry */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
33 #include "buffer.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
34 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
35 #include "insdel.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
37 #include "console-gtk-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
38 #include "objects-gtk-impl.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 /* sigh */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 #include <gdk/gdkx.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 /* color instances */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 /* Replacement for XAllocColor() that tries to return the nearest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49 available color if the colormap is full. Original was from FSFmacs,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 but rewritten by Jareth Hein <jareth@camelot-soft.com> 97/11/25
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 Modified by Lee Kindness <lkindness@csl.co.uk> 31/08/99 to handle previous
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 total failure which was due to a read/write colorcell being the nearest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 match - tries the next nearest...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 Gdk takes care of all this behind the scenes, so we don't need to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 worry about it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 Return value is 1 for normal success, 2 for nearest color success,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 3 for Non-deallocable sucess. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 allocate_nearest_color (GdkColormap *colormap, GdkVisual *visual,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 GdkColor *color_def)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 int rc;
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 rc = gdk_colormap_alloc_color (colormap, color_def, FALSE, TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 if (rc == TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 return (0);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 int
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
75 gtk_parse_nearest_color (struct device *d, GdkColor *color, Ibyte *name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
76 Bytecount len, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 GdkVisual *visual;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 int result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82 cmap = DEVICE_GTK_COLORMAP(d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 visual = DEVICE_GTK_VISUAL (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 xzero (*color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 const Extbyte *extname;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 578
diff changeset
88 Bytecount extnamelen;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 TO_EXTERNAL_FORMAT (DATA, (name, len), ALLOCA, (extname, extnamelen), Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 result = gdk_color_parse (extname, color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 if (result == FALSE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
97 maybe_invalid_argument ("unrecognized color", make_string (name, len),
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
98 Qcolor, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 result = allocate_nearest_color (cmap, visual, color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 if (!result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
104 maybe_signal_error (Qgui_error, "couldn't allocate color",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
105 make_string (name, len), Qcolor, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 return result;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 gtk_initialize_color_instance (struct Lisp_Color_Instance *c, Lisp_Object name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
114 Lisp_Object device, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 GdkColor color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 int result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 result = gtk_parse_nearest_color (XDEVICE (device), &color,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 XSTRING_DATA (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 XSTRING_LENGTH (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 errb);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 if (!result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 /* Don't allocate the data until we're sure that we will succeed,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 c->data = xnew (struct gtk_color_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 if (result == 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 COLOR_INSTANCE_GTK_DEALLOC (c) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 COLOR_INSTANCE_GTK_DEALLOC (c) = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 gtk_print_color_instance (struct Lisp_Color_Instance *c,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 Lisp_Object printcharfun,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 int escapeflag)
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 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
144 write_fmt_string (printcharfun, " %ld=(%X,%X,%X)",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
145 color->pixel, color->red, color->green, color->blue);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 gtk_finalize_color_instance (struct Lisp_Color_Instance *c)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 if (c->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 if (DEVICE_LIVE_P (XDEVICE (c->device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 if (COLOR_INSTANCE_GTK_DEALLOC (c))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 gdk_colormap_free_colors (DEVICE_GTK_COLORMAP (XDEVICE (c->device)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 COLOR_INSTANCE_GTK_COLOR (c), 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1701
diff changeset
162 xfree (c->data, void *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 c->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 /* Color instances are equal if they resolve to the same color on the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 screen (have the same RGB values). I imagine that
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 "same RGB values" == "same cell in the colormap." Arguably we should
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 be comparing their names or pixel values instead. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 gtk_color_instance_equal (struct Lisp_Color_Instance *c1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 struct Lisp_Color_Instance *c2,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 int depth)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 return (gdk_color_equal (COLOR_INSTANCE_GTK_COLOR (c1),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 COLOR_INSTANCE_GTK_COLOR (c2)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 static unsigned long
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 gtk_color_instance_hash (struct Lisp_Color_Instance *c, int depth)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 return (gdk_color_hash (COLOR_INSTANCE_GTK_COLOR (c), NULL));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 gtk_color_instance_rgb_components (struct Lisp_Color_Instance *c)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 return (list3 (make_int (color->red),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 make_int (color->green),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 make_int (color->blue)));
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 gtk_valid_color_name_p (struct device *d, Lisp_Object color)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 GdkColor c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 const char *extname;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 TO_EXTERNAL_FORMAT (LISP_STRING, color, C_STRING_ALLOCA, extname, Qctext);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 if (gdk_color_parse (extname, &c) != TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 return(0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 return (1);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 /* font instances */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 gtk_initialize_font_instance (struct Lisp_Font_Instance *f, Lisp_Object name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
216 Lisp_Object device, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 GdkFont *gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 XFontStruct *xf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 const char *extname;
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 TO_EXTERNAL_FORMAT (LISP_STRING, f->name, C_STRING_ALLOCA, extname, Qctext);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 gf = gdk_font_load (extname);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 if (!gf)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
228 maybe_signal_error (Qgui_error, "couldn't load font", f->name,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
229 Qfont, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
233 xf = (XFontStruct*) GDK_FONT_XFONT (gf);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 /* Don't allocate the data until we're sure that we will succeed,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 f->data = xnew (struct gtk_font_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 FONT_INSTANCE_GTK_FONT (f) = gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 f->ascent = gf->ascent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 f->descent = gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 f->height = gf->ascent + gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243 /* Now lets figure out the width of the font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 unsigned int def_char = 'n'; /*xf->default_char;*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 unsigned int byte1, byte2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 once_more:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 byte1 = def_char >> 8;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 byte2 = def_char & 0xFF;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 if (xf->per_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 /* Old versions of the R5 font server have garbage (>63k) as
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 def_char. 'n' might not be a valid character. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 if (byte1 < xf->min_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 byte1 > xf->max_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 byte2 < xf->min_char_or_byte2 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 byte2 > xf->max_char_or_byte2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 f->width = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 f->width = xf->per_char[(byte1 - xf->min_byte1) *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 (xf->max_char_or_byte2 -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 xf->min_char_or_byte2 + 1) +
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 (byte2 - xf->min_char_or_byte2)].width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 f->width = xf->max_bounds.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 /* Some fonts have a default char whose width is 0. This is no good.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272 If that's the case, first try 'n' as the default char, and if n has
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 0 width too (unlikely) then just use the max width. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 if (f->width == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 if (def_char == xf->default_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 f->width = xf->max_bounds.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 def_char = xf->default_char;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 goto once_more;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 }
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 /* If all characters don't exist then there could potentially be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 0-width characters lurking out there. Not setting this flag
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 trips an optimization that would make them appear to have width
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 to redisplay. This is bad. So we set it if not all characters
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 have the same width or if not all characters are defined.
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 /* #### This sucks. There is a measurable performance increase
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293 when using proportional width fonts if this flag is not set.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 Unfortunately so many of the fucking X fonts are not fully
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 defined that we could almost just get rid of this damn flag and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 make it an assertion. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 (/* x_handle_non_fully_specified_fonts */ 0 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 !xf->all_chars_exist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 f->width = gdk_char_width (gf, 'n');
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 f->proportional_p = (gdk_char_width (gf, '|') != gdk_char_width (gf, 'W')) ? 1 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 gtk_print_font_instance (struct Lisp_Font_Instance *f,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 Lisp_Object printcharfun,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 int escapeflag)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 {
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
312 write_fmt_string (printcharfun, " 0x%lx",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
313 (unsigned long) gdk_font_id (FONT_INSTANCE_GTK_FONT (f)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 gtk_finalize_font_instance (struct Lisp_Font_Instance *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 if (f->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 if (DEVICE_LIVE_P (XDEVICE (f->device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 gdk_font_unref (FONT_INSTANCE_GTK_FONT (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1701
diff changeset
325 xfree (f->data, void *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 f->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 /* Forward declarations for X specific functions at the end of the file */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 static Lisp_Object __gtk_list_fonts_internal (const char *pattern);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 static Lisp_Object
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
335 gtk_font_instance_truename (struct Lisp_Font_Instance *f, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
337 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
339 FONT_INSTANCE_TRUENAME (f) = __get_gtk_font_truename (FONT_INSTANCE_GTK_FONT (f), 1);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
341 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 /* Ok, just this once, return the font name as the truename.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 (This is only used by Fequal() right now.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 return f->name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
346 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 }
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
348 return (FONT_INSTANCE_TRUENAME (f));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 gtk_font_instance_properties (struct Lisp_Font_Instance *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
353 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 /* There seems to be no way to get this information under Gtk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
360
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
361 static Lisp_Object
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 950
diff changeset
362 gtk_list_fonts (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 const char *patternext;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 TO_EXTERNAL_FORMAT (LISP_STRING, pattern, C_STRING_ALLOCA, patternext, Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
367
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 return (__gtk_list_fonts_internal (patternext));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 gtk_font_spec_matches_charset (struct device *d, Lisp_Object charset,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
375 const Ibyte *nonreloc, Lisp_Object reloc,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
376 Bytecount offset, Bytecount length,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
377 int stage)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
379 if (stage)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
380 return 0;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
381
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 if (UNBOUNDP (charset))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 /* Hack! Short font names don't have the registry in them,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 so we just assume the user knows what they're doing in the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 case of ASCII. For other charsets, you gotta give the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387 long form; sorry buster.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 if (EQ (charset, Vcharset_ascii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
391 const Ibyte *the_nonreloc = nonreloc;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 Bytecount the_length = length;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 if (!the_nonreloc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 the_nonreloc = XSTRING_DATA (reloc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398 the_nonreloc += offset;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 if (!memchr (the_nonreloc, '*', the_length))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 for (i = 0;; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
403 const Ibyte *new_nonreloc = (const Ibyte *)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404 memchr (the_nonreloc, '-', the_length);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 if (!new_nonreloc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 new_nonreloc++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 the_length -= new_nonreloc - the_nonreloc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 the_nonreloc = new_nonreloc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 /* If it has less than 5 dashes, it's a short font.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 Of course, long fonts always have 14 dashes or so, but short
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 fonts never have more than 1 or 2 dashes, so this is some
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 sort of reasonable heuristic. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 if (i < 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 return (fast_string_match (XCHARSET_REGISTRY (charset),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 nonreloc, reloc, offset, length, 1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 ERROR_ME, 0) >= 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 /* find a font spec that matches font spec FONT and also matches
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 (the registry of) CHARSET. */
950
c1a972caf831 [xemacs-hg @ 2002-08-02 15:18:38 by youngs]
youngs
parents: 872
diff changeset
428 static Lisp_Object gtk_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset, int stage);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 #endif /* MULE */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434 /* initialization */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 syms_of_objects_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 console_type_create_objects_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 /* object methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 CONSOLE_HAS_METHOD (gtk, initialize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 CONSOLE_HAS_METHOD (gtk, print_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 CONSOLE_HAS_METHOD (gtk, finalize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 CONSOLE_HAS_METHOD (gtk, color_instance_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 CONSOLE_HAS_METHOD (gtk, color_instance_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 CONSOLE_HAS_METHOD (gtk, color_instance_rgb_components);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 CONSOLE_HAS_METHOD (gtk, valid_color_name_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 CONSOLE_HAS_METHOD (gtk, initialize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 CONSOLE_HAS_METHOD (gtk, print_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 CONSOLE_HAS_METHOD (gtk, finalize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 CONSOLE_HAS_METHOD (gtk, font_instance_truename);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 CONSOLE_HAS_METHOD (gtk, font_instance_properties);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 CONSOLE_HAS_METHOD (gtk, list_fonts);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 CONSOLE_HAS_METHOD (gtk, find_charset_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 CONSOLE_HAS_METHOD (gtk, font_spec_matches_charset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 vars_of_objects_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
470 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 /* #### BILL!!! Try to make this go away eventually */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 /* X Specific stuff */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 #include <X11/Xatom.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 /* Unbounded, for sufficiently small values of infinity... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 #define MAX_FONT_COUNT 5000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 /* find a font spec that matches font spec FONT and also matches
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 (the registry of) CHARSET. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482 static Lisp_Object
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
483 gtk_find_charset_font (Lisp_Object device, Lisp_Object font,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
484 Lisp_Object charset, int stage)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 char **names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 int count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489 const char *patternext;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
492 if (stage)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
493 return Qnil;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
494
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 TO_EXTERNAL_FORMAT (LISP_STRING, font, C_STRING_ALLOCA, patternext, Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497 names = XListFonts (GDK_DISPLAY (),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 patternext, MAX_FONT_COUNT, &count);
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 665
diff changeset
499 /* #### This code seems awfully bogus -- mrb */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 for (i = 0; i < count; i ++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
502 const Ibyte *intname;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 Bytecount intlen;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 TO_INTERNAL_FORMAT (C_STRING, names[i], ALLOCA, (intname, intlen),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 Qctext);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 if (gtk_font_spec_matches_charset (XDEVICE (device), charset,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
508 intname, Qnil, 0, -1, 0))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
509 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
510 result = make_string (intname, intlen);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 /* Check for a short font name. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519 if (NILP (result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 && gtk_font_spec_matches_charset (XDEVICE (device), charset, 0,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
521 font, 0, -1, 0))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
522 return font;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
523
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
524 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
525 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 #endif /* MULE */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528 /* Unbounded, for sufficiently small values of infinity... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529 #define MAX_FONT_COUNT 5000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532 valid_font_name_p (Display *dpy, char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534 /* Maybe this should be implemented by callign XLoadFont and trapping
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 the error. That would be a lot of work, and wasteful as hell, but
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536 might be more correct.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 char **names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540 if (! name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542 names = XListFonts (dpy, name, 1, &nnames);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545 return (nnames != 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548 Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549 __get_gtk_font_truename (GdkFont *gdk_font, int expandp)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 Display *dpy = GDK_FONT_XDISPLAY (gdk_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 GSList *names = ((GdkFontPrivate *) gdk_font)->names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
553 Lisp_Object font_name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555 while (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 if (names->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
559 if (valid_font_name_p (dpy, (char*) names->data))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 if (!expandp)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563 /* They want the wildcarded version */
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
564 font_name = build_string ((char*) names->data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
567 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568 /* Need to expand out */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
569 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570 char **x_font_names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
572 x_font_names = XListFonts (dpy, (char*) names->data, 1, &nnames);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573 if (x_font_names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 font_name = build_string (x_font_names[0]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576 XFreeFontNames (x_font_names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 names = names->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 return (font_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587 static Lisp_Object __gtk_list_fonts_internal (const char *pattern)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 char **names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 int count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 names = XListFonts (GDK_DISPLAY (), pattern, MAX_FONT_COUNT, &count);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 while (count--)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 result = Fcons (build_ext_string (names [count], Qbinary), result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600 }