]> Pileus Git - ~andy/gtk/blob - gdk/linux-fb/gdkim-fb.c
d2a7f2d897e617953468c46e2cc8aba44ca96cad
[~andy/gtk] / gdk / linux-fb / gdkim-fb.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #include "gdki18n.h"
28 #include "gdkinternals.h"
29 #include "gdkprivate-fb.h"
30
31 #if HAVE_CONFIG_H
32 #  include <config.h>
33 #  if STDC_HEADERS
34 #    include <string.h>
35 #  endif
36 #endif
37
38 #include <locale.h>
39
40 /* If this variable is FALSE, it indicates that we should
41  * avoid trying to use multibyte conversion functions and
42  * assume everything is 1-byte per character
43  */
44 static gboolean gdk_use_mb;
45
46 /*
47  *--------------------------------------------------------------
48  * gdk_set_locale
49  *
50  * Arguments:
51  *
52  * Results:
53  *
54  * Side effects:
55  *
56  *--------------------------------------------------------------
57  */
58
59 gchar*
60 gdk_set_locale (void)
61 {
62   wchar_t result;
63   gchar *current_locale;
64
65   gdk_use_mb = FALSE;
66
67   if (!setlocale (LC_ALL,""))
68     g_warning ("locale not supported by C library");
69   
70   current_locale = setlocale (LC_ALL, NULL);
71
72   if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
73     {
74       gdk_use_mb = TRUE;
75
76 #ifndef X_LOCALE
77       /* Detect GNU libc, where mb == UTF8. Not useful unless it's
78        * really a UTF8 locale. The below still probably will
79        * screw up on Greek, Cyrillic, etc, encoded as UTF8.
80        */
81       
82       if ((MB_CUR_MAX == 2) &&
83           (mbstowcs (&result, "\xdd\xa5", 1) > 0) &&
84           result == 0x765)
85         {
86           if ((strlen (current_locale) < 4) ||
87               g_strcasecmp (current_locale + strlen(current_locale) - 4, "utf8"))
88             gdk_use_mb = FALSE;
89         }
90 #endif /* X_LOCALE */
91     }
92
93   GDK_NOTE (MISC,
94             g_message ("%s multi-byte string functions.", 
95                        gdk_use_mb ? "Using" : "Not using"));
96   
97   return current_locale;
98 }
99
100 void 
101 gdk_im_begin (GdkIC *ic, GdkWindow* window)
102 {
103 }
104
105 void 
106 gdk_im_end (void)
107 {
108 }
109
110 GdkIMStyle
111 gdk_im_decide_style (GdkIMStyle supported_style)
112 {
113   return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
114 }
115
116 GdkIMStyle
117 gdk_im_set_best_style (GdkIMStyle style)
118 {
119   return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
120 }
121
122 gint 
123 gdk_im_ready (void)
124 {
125   return FALSE;
126 }
127
128 gint
129 gdk_im_open(void)
130 {
131   return TRUE;
132 }
133
134 void
135 gdk_im_close(void)
136 {
137 }
138
139 GdkIC * 
140 gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
141 {
142   return NULL;
143 }
144
145 void 
146 gdk_ic_destroy (GdkIC *ic)
147 {
148 }
149
150 GdkIMStyle
151 gdk_ic_get_style (GdkIC *ic)
152 {
153   return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
154 }
155
156 void 
157 gdk_ic_set_values (GdkIC *ic, ...)
158 {
159 }
160
161 void 
162 gdk_ic_get_values (GdkIC *ic, ...)
163 {
164 }
165
166 GdkICAttributesType 
167 gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
168 {
169   return 0;
170 }
171
172 GdkICAttributesType 
173 gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
174 {
175   return 0;
176 }
177
178 GdkEventMask 
179 gdk_ic_get_events (GdkIC *ic)
180 {
181   return 0;
182 }
183
184 /*
185  * gdk_wcstombs 
186  *
187  * Returns a multi-byte string converted from the specified array
188  * of wide characters. The string is newly allocated. The array of
189  * wide characters must be null-terminated. If the conversion is
190  * failed, it returns NULL.
191  */
192 gchar *
193 gdk_wcstombs (const GdkWChar *src)
194 {
195   gchar *mbstr;
196
197   gint length = 0;
198   gint i;
199
200   while (src[length] != 0)
201     length++;
202   
203   mbstr = g_new (gchar, length + 1);
204   
205   for (i = 0; i < length + 1; i++)
206     mbstr[i] = src[i];
207
208   return mbstr;
209 }
210   
211 /*
212  * gdk_mbstowcs
213  *
214  * Converts the specified string into wide characters, and, returns the
215  * number of wide characters written. The string 'src' must be
216  * null-terminated. If the conversion is failed, it returns -1.
217  */
218 gint
219 gdk_mbstowcs (GdkWChar *dest, const gchar *src, gint dest_max)
220 {
221   gint i;
222   
223   for (i = 0; i < dest_max && src[i]; i++)
224     dest[i] = src[i];
225
226   return i;
227 }
228
229 void
230 gdk_ic_cleanup(void)
231 {
232 }
233
234 GdkICAttr*   gdk_ic_attr_new       (void)
235 {
236   return NULL;
237 }
238
239 void
240 gdk_ic_attr_destroy   (GdkICAttr *attr)
241 {
242 }