forked from AuroraMiddleware/gtk
Rip out support for multiple locales; that simple doesn't work reliably
Tue Sep 19 10:54:22 2000 Owen Taylor <otaylor@redhat.com> * modules/input/{gtkimcontextxim.[ch],imxim.c}: Rip out support for multiple locales; that simple doesn't work reliably with current Xlib * gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch] gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c: Add support for positioning the cursor within the preedit string. Mon Sep 18 23:56:32 2000 Owen Taylor <otaylor@redhat.com> * modules/input/{imxim.c,gtkimcontextxim.[ch]}: Start at XIM input method module. Sun Sep 17 10:08:16 2000 Owen Taylor <otaylor@redhat.com> * modules/input/Makefile.am (moduledir): remove leftover bin program target. Sat Sep 16 13:05:48 2000 Owen Taylor <otaylor@redhat.com> * modules/input/imcyrillic-translit.c: A sample input method (based on GtkIMContextSimple with an extra table), which demonstrates preedit strings and the module system for input modules
This commit is contained in:
parent
65ba8a26e4
commit
b9d3287313
@ -1 +1 @@
|
||||
SUBDIRS=linux-fb
|
||||
SUBDIRS=linux-fb input
|
||||
|
6
modules/input/.cvsignore
Normal file
6
modules/input/.cvsignore
Normal file
@ -0,0 +1,6 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
.deps
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
42
modules/input/Makefile.am
Normal file
42
modules/input/Makefile.am
Normal file
@ -0,0 +1,42 @@
|
||||
## Makefile.am for gtk+/demos
|
||||
|
||||
INCLUDES = @STRIP_BEGIN@ \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
-DGTK_DISABLE_COMPAT_H \
|
||||
-DGTK_LOCALEDIR=\"$(gtklocaledir)\" \
|
||||
@GTK_DEBUG_FLAGS@ \
|
||||
@GTK_XIM_FLAGS@ \
|
||||
@GTK_LOCALE_FLAGS@ \
|
||||
@PANGO_CFLAGS@ \
|
||||
@GLIB_CFLAGS@ \
|
||||
@more_cflags@ \
|
||||
@STRIP_END@
|
||||
|
||||
DEPS = \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@
|
||||
|
||||
LDADDS = @STRIP_BEGIN@ \
|
||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la \
|
||||
$(top_builddir)/gdk/@gdktargetlib@ \
|
||||
$(top_builddir)/gtk/@gtktargetlib@ \
|
||||
@more_ldflags@ \
|
||||
@more_libs@ \
|
||||
@GDK_WLIBS@ \
|
||||
@PANGO_LIBS@ \
|
||||
@GLIB_LIBS@ \
|
||||
@GTK_LIBS_EXTRA@ \
|
||||
-lm \
|
||||
@STRIP_END@
|
||||
|
||||
moduledir = $(libdir)/gtk+/gtk-2.0/$(GTK_VERSION)/immodules
|
||||
module_LTLIBRARIES = im-cyrillic-translit.la im-xim.la
|
||||
|
||||
im_cyrillic_translit_la_LDFLAGS = -rpath $(libdir) -export-dynamic -avoid-version -module
|
||||
im_cyrillic_translit_la_SOURCES = imcyrillic-translit.c
|
||||
|
||||
im_xim_la_LDFLAGS = -rpath $(libdir) -export-dynamic -avoid-version -module
|
||||
im_xim_la_SOURCES = gtkimcontextxim.c imxim.c
|
||||
|
744
modules/input/gtkimcontextxim.c
Normal file
744
modules/input/gtkimcontextxim.c
Normal file
@ -0,0 +1,744 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "locale.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "gtk/gtksignal.h"
|
||||
#include "gtkimcontextxim.h"
|
||||
|
||||
struct _GtkXIMInfo
|
||||
{
|
||||
XIM im;
|
||||
char *locale;
|
||||
XIMStyle style;
|
||||
};
|
||||
|
||||
static void gtk_im_context_xim_class_init (GtkIMContextXIMClass *class);
|
||||
static void gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim);
|
||||
static void gtk_im_context_xim_finalize (GObject *obj);
|
||||
static void gtk_im_context_xim_set_client_window (GtkIMContext *context,
|
||||
GdkWindow *client_window);
|
||||
static gboolean gtk_im_context_xim_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *key);
|
||||
static void gtk_im_context_xim_reset (GtkIMContext *context);
|
||||
static void gtk_im_context_xim_get_preedit_string (GtkIMContext *context,
|
||||
gchar **str,
|
||||
PangoAttrList **attrs,
|
||||
gint *cursor_pos);
|
||||
|
||||
static XIC gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim);
|
||||
static GObjectClass *parent_class;
|
||||
|
||||
GType gtk_type_im_context_xim = 0;
|
||||
|
||||
static GSList *open_ims = NULL;
|
||||
|
||||
void
|
||||
gtk_im_context_xim_register_type (GTypeModule *type_module)
|
||||
{
|
||||
static const GTypeInfo im_context_xim_info =
|
||||
{
|
||||
sizeof (GtkIMContextXIMClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gtk_im_context_xim_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkIMContextXIM),
|
||||
0,
|
||||
(GtkObjectInitFunc) gtk_im_context_xim_init,
|
||||
};
|
||||
|
||||
gtk_type_im_context_xim =
|
||||
g_type_module_register_type (type_module,
|
||||
GTK_TYPE_IM_CONTEXT,
|
||||
"GtkIMContextXIM",
|
||||
&im_context_xim_info, 0);
|
||||
}
|
||||
|
||||
#define PREEDIT_MASK (XIMPreeditCallbacks | XIMPreeditPosition | \
|
||||
XIMPreeditArea | XIMPreeditNothing | XIMPreeditNone)
|
||||
#define STATUS_MASK (XIMStatusCallbacks | XIMStatusArea | \
|
||||
XIMStatusNothing | XIMStatusNone)
|
||||
#define ALLOWED_MASK (XIMPreeditCallbacks | XIMPreeditNothing | XIMPreeditNone | \
|
||||
XIMStatusCallbacks | XIMStatusNothing | XIMStatusNone)
|
||||
|
||||
static XIMStyle
|
||||
choose_better_style (XIMStyle style1, XIMStyle style2)
|
||||
{
|
||||
XIMStyle s1, s2, u;
|
||||
|
||||
if (style1 == 0) return style2;
|
||||
if (style2 == 0) return style1;
|
||||
if ((style1 & (PREEDIT_MASK | STATUS_MASK))
|
||||
== (style2 & (PREEDIT_MASK | STATUS_MASK)))
|
||||
return style1;
|
||||
|
||||
s1 = style1 & PREEDIT_MASK;
|
||||
s2 = style2 & PREEDIT_MASK;
|
||||
u = s1 | s2;
|
||||
if (s1 != s2) {
|
||||
if (u & XIMPreeditCallbacks)
|
||||
return (s1 == XIMPreeditCallbacks) ? style1 : style2;
|
||||
else if (u & XIMPreeditPosition)
|
||||
return (s1 == XIMPreeditPosition) ? style1 :style2;
|
||||
else if (u & XIMPreeditArea)
|
||||
return (s1 == XIMPreeditArea) ? style1 : style2;
|
||||
else if (u & XIMPreeditNothing)
|
||||
return (s1 == XIMPreeditNothing) ? style1 : style2;
|
||||
} else {
|
||||
s1 = style1 & STATUS_MASK;
|
||||
s2 = style2 & STATUS_MASK;
|
||||
u = s1 | s2;
|
||||
if (u & XIMStatusCallbacks)
|
||||
return (s1 == XIMStatusCallbacks) ? style1 : style2;
|
||||
else if (u & XIMStatusArea)
|
||||
return (s1 == XIMStatusArea) ? style1 : style2;
|
||||
else if (u & XIMStatusNothing)
|
||||
return (s1 == XIMStatusNothing) ? style1 : style2;
|
||||
else if (u & XIMStatusNone)
|
||||
return (s1 == XIMStatusNone) ? style1 : style2;
|
||||
}
|
||||
return 0; /* Get rid of stupid warning */
|
||||
}
|
||||
|
||||
static void
|
||||
setup_im (GtkXIMInfo *info)
|
||||
{
|
||||
XIMStyles *xim_styles;
|
||||
XIMValuesList *ic_values;
|
||||
int i;
|
||||
|
||||
XGetIMValues (info->im,
|
||||
XNQueryInputStyle, &xim_styles,
|
||||
XNQueryICValuesList, &ic_values);
|
||||
|
||||
info->style = 0;
|
||||
for (i = 0; i < xim_styles->count_styles; i++)
|
||||
if ((xim_styles->supported_styles[i] & ALLOWED_MASK) == xim_styles->supported_styles[i])
|
||||
info->style = choose_better_style (info->style,
|
||||
xim_styles->supported_styles[i]);
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < ic_values->count_values; i++)
|
||||
g_print ("%s\n", ic_values->supported_values[i]);
|
||||
for (i = 0; i < xim_styles->count_styles; i++)
|
||||
g_print ("%#x\n", xim_styles->supported_styles[i]);
|
||||
#endif
|
||||
|
||||
XFree (xim_styles);
|
||||
XFree (ic_values);
|
||||
}
|
||||
|
||||
static GtkXIMInfo *
|
||||
get_im (const char *locale)
|
||||
{
|
||||
GSList *tmp_list = open_ims;
|
||||
GtkXIMInfo *info;
|
||||
XIM im = NULL;
|
||||
|
||||
while (tmp_list)
|
||||
{
|
||||
info = tmp_list->data;
|
||||
if (!strcmp (info->locale, locale))
|
||||
return info;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
info = NULL;
|
||||
|
||||
if (XSupportsLocale ())
|
||||
{
|
||||
if (!XSetLocaleModifiers (""))
|
||||
g_warning ("can not set locale modifiers");
|
||||
|
||||
im = XOpenIM (GDK_DISPLAY(), NULL, NULL, NULL);
|
||||
|
||||
if (im)
|
||||
{
|
||||
info = g_new (GtkXIMInfo, 1);
|
||||
open_ims = g_slist_prepend (open_ims, im);
|
||||
|
||||
info->locale = g_strdup (locale);
|
||||
info->im = im;
|
||||
|
||||
setup_im (info);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_xim_class_init (GtkIMContextXIMClass *class)
|
||||
{
|
||||
GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
im_context_class->set_client_window = gtk_im_context_xim_set_client_window;
|
||||
im_context_class->filter_keypress = gtk_im_context_xim_filter_keypress;
|
||||
im_context_class->reset = gtk_im_context_xim_reset;
|
||||
im_context_class->get_preedit_string = gtk_im_context_xim_get_preedit_string;
|
||||
gobject_class->finalize = gtk_im_context_xim_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_xim_finalize (GObject *obj)
|
||||
{
|
||||
GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (obj);
|
||||
|
||||
if (context_xim->ic)
|
||||
{
|
||||
XDestroyIC (context_xim->ic);
|
||||
context_xim->ic = NULL;
|
||||
}
|
||||
|
||||
g_free (context_xim->mb_charset);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_xim_set_client_window (GtkIMContext *context,
|
||||
GdkWindow *client_window)
|
||||
{
|
||||
GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
|
||||
|
||||
if (context_xim->ic)
|
||||
{
|
||||
XDestroyIC (context_xim->ic);
|
||||
context_xim->ic = NULL;
|
||||
}
|
||||
|
||||
context_xim->client_window = client_window;
|
||||
}
|
||||
|
||||
GtkIMContext *
|
||||
gtk_im_context_xim_new (void)
|
||||
{
|
||||
GtkXIMInfo *info;
|
||||
GtkIMContextXIM *result;
|
||||
gchar *charset;
|
||||
|
||||
info = get_im (setlocale (LC_CTYPE, NULL));
|
||||
if (!info)
|
||||
return NULL;
|
||||
|
||||
result = GTK_IM_CONTEXT_XIM (gtk_type_new (GTK_TYPE_IM_CONTEXT_XIM));
|
||||
|
||||
result->im_info = info;
|
||||
|
||||
g_get_charset (&charset);
|
||||
result->mb_charset = g_strdup (charset);
|
||||
|
||||
return GTK_IM_CONTEXT (result);
|
||||
}
|
||||
|
||||
static char *
|
||||
mb_to_utf8 (GtkIMContextXIM *context_xim,
|
||||
const char *str)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *result;
|
||||
|
||||
result = g_convert (str, -1,
|
||||
"UTF-8", context_xim->mb_charset,
|
||||
NULL, NULL, &error);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
g_warning ("Error converting text from IM to UTF-8: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_im_context_xim_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
|
||||
XIC ic = gtk_im_context_xim_get_ic (context_xim);
|
||||
gchar static_buffer[256];
|
||||
gchar *buffer = static_buffer;
|
||||
gint buffer_size = sizeof(static_buffer) - 1;
|
||||
gint num_bytes = 0;
|
||||
KeySym keysym;
|
||||
Status status;
|
||||
gboolean result = FALSE;
|
||||
|
||||
XKeyPressedEvent xevent;
|
||||
|
||||
if (!ic)
|
||||
return FALSE;
|
||||
|
||||
xevent.type = KeyPress;
|
||||
xevent.serial = 0; /* hope it doesn't matter */
|
||||
xevent.send_event = event->send_event;
|
||||
xevent.display = GDK_DRAWABLE_XDISPLAY (event->window);
|
||||
xevent.window = GDK_DRAWABLE_XID (event->window);
|
||||
xevent.root = GDK_ROOT_WINDOW();
|
||||
xevent.subwindow = xevent.window;
|
||||
xevent.time = event->time;
|
||||
xevent.x = xevent.x_root = 0;
|
||||
xevent.y = xevent.y_root = 0;
|
||||
xevent.state = event->state;
|
||||
xevent.keycode = event->keyval ? XKeysymToKeycode (xevent.display, event->keyval) : 0;
|
||||
xevent.same_screen = True;
|
||||
|
||||
if (XFilterEvent ((XEvent *)&xevent, GDK_DRAWABLE_XID (context_xim->client_window)))
|
||||
return TRUE;
|
||||
|
||||
again:
|
||||
num_bytes = XmbLookupString (ic, &xevent, buffer, buffer_size, &keysym, &status);
|
||||
|
||||
if (status == XBufferOverflow)
|
||||
{
|
||||
buffer_size = num_bytes;
|
||||
buffer = g_malloc (num_bytes + 1);
|
||||
goto again;
|
||||
}
|
||||
|
||||
/* I don't know how we should properly handle XLookupKeysym or XLookupBoth
|
||||
* here ... do input methods actually change the keysym? we can't really
|
||||
* feed it back to accelerator processing at this point...
|
||||
*/
|
||||
if (status == XLookupChars || status == XLookupBoth)
|
||||
{
|
||||
char *result_utf8;
|
||||
|
||||
buffer[num_bytes] = '\0';
|
||||
|
||||
result_utf8 = mb_to_utf8 (context_xim, buffer);
|
||||
if (result_utf8)
|
||||
{
|
||||
if ((guchar)result_utf8[0] >= 0x20) /* Some IM have a nasty habit of converting
|
||||
* control characters into strings
|
||||
*/
|
||||
{
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (context), "commit", result_utf8);
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
g_free (result_utf8);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_xim_reset (GtkIMContext *context)
|
||||
{
|
||||
GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
|
||||
XIC ic = gtk_im_context_xim_get_ic (context_xim);
|
||||
gchar *result;
|
||||
|
||||
if (!ic)
|
||||
return;
|
||||
|
||||
result = XmbResetIC (ic);
|
||||
|
||||
if (result)
|
||||
{
|
||||
char *result_utf8 = mb_to_utf8 (context_xim, result);
|
||||
if (result_utf8)
|
||||
{
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (context), "commit", result_utf8);
|
||||
g_free (result_utf8);
|
||||
}
|
||||
}
|
||||
|
||||
if (context_xim->preedit_length)
|
||||
{
|
||||
context_xim->preedit_length = 0;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (context), "preedit-changed");
|
||||
}
|
||||
|
||||
XFree (result);
|
||||
}
|
||||
|
||||
/* Mask of feedback bits that we render
|
||||
*/
|
||||
#define FEEDBACK_MASK (XIMReverse | XIMUnderline)
|
||||
|
||||
static void
|
||||
add_feedback_attr (PangoAttrList *attrs,
|
||||
const gchar *str,
|
||||
XIMFeedback feedback,
|
||||
gint start_pos,
|
||||
gint end_pos)
|
||||
{
|
||||
PangoAttribute *attr;
|
||||
|
||||
gint start_index = g_utf8_offset_to_pointer (str, start_pos) - str;
|
||||
gint end_index = g_utf8_offset_to_pointer (str, end_pos) - str;
|
||||
|
||||
if (feedback & XIMUnderline)
|
||||
{
|
||||
attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
|
||||
attr->start_index = start_index;
|
||||
attr->end_index = end_index;
|
||||
|
||||
pango_attr_list_change (attrs, attr);
|
||||
}
|
||||
|
||||
if (feedback & XIMReverse)
|
||||
{
|
||||
attr = pango_attr_foreground_new (0xffff, 0xffff, 0xffff);
|
||||
attr->start_index = start_index;
|
||||
attr->end_index = end_index;
|
||||
|
||||
pango_attr_list_change (attrs, attr);
|
||||
|
||||
attr = pango_attr_background_new (0, 0, 0);
|
||||
attr->start_index = start_index;
|
||||
attr->end_index = end_index;
|
||||
|
||||
pango_attr_list_change (attrs, attr);
|
||||
}
|
||||
|
||||
if (feedback & ~FEEDBACK_MASK)
|
||||
g_warning ("Unrendered feedback style: %#lx", feedback & ~FEEDBACK_MASK);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_xim_get_preedit_string (GtkIMContext *context,
|
||||
gchar **str,
|
||||
PangoAttrList **attrs,
|
||||
gint *cursor_pos)
|
||||
{
|
||||
GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
|
||||
gchar *utf8 = g_ucs4_to_utf8 (context_xim->preedit_chars, context_xim->preedit_length);
|
||||
|
||||
if (attrs)
|
||||
{
|
||||
int i;
|
||||
XIMFeedback last_feedback = 0;
|
||||
gint start = -1;
|
||||
|
||||
*attrs = pango_attr_list_new ();
|
||||
|
||||
for (i = 0; i < context_xim->preedit_length; i++)
|
||||
{
|
||||
XIMFeedback new_feedback = context_xim->feedbacks[i] & FEEDBACK_MASK;
|
||||
if (new_feedback != last_feedback)
|
||||
{
|
||||
if (start >= 0)
|
||||
add_feedback_attr (*attrs, utf8, last_feedback, start, i);
|
||||
|
||||
last_feedback = new_feedback;
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (start >= 0)
|
||||
add_feedback_attr (*attrs, utf8, last_feedback, start, i);
|
||||
}
|
||||
|
||||
if (str)
|
||||
*str = utf8;
|
||||
else
|
||||
g_free (utf8);
|
||||
|
||||
if (cursor_pos)
|
||||
*cursor_pos = context_xim->preedit_cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
preedit_start_callback (XIC xic,
|
||||
XPointer client_data,
|
||||
XPointer call_data)
|
||||
{
|
||||
GtkIMContext *context = GTK_IM_CONTEXT (client_data);
|
||||
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (context), "preedit_start");
|
||||
g_print ("Starting preedit!\n");
|
||||
}
|
||||
|
||||
static void
|
||||
preedit_done_callback (XIC xic,
|
||||
XPointer client_data,
|
||||
XPointer call_data)
|
||||
{
|
||||
GtkIMContext *context = GTK_IM_CONTEXT (client_data);
|
||||
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (context), "preedit_end");
|
||||
g_print ("Ending preedit!\n");
|
||||
}
|
||||
|
||||
static gint
|
||||
xim_text_to_utf8 (GtkIMContextXIM *context, XIMText *xim_text, gchar **text)
|
||||
{
|
||||
gint text_length = 0;
|
||||
GError *error = NULL;
|
||||
gchar *result = NULL;
|
||||
|
||||
if (xim_text && xim_text->string.multi_byte)
|
||||
{
|
||||
if (xim_text->encoding_is_wchar)
|
||||
{
|
||||
g_warning ("Wide character return from Xlib not currently supported");
|
||||
*text = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = g_convert (xim_text->string.multi_byte,
|
||||
-1,
|
||||
"UTF-8",
|
||||
context->mb_charset,
|
||||
NULL, &text_length, &error);
|
||||
|
||||
if (result)
|
||||
{
|
||||
text_length = g_utf8_strlen (result, -1);
|
||||
|
||||
if (text_length != xim_text->length)
|
||||
{
|
||||
g_warning ("Size mismatch when converting text from input method: supplied length = %d\n, result length = %d", xim_text->length, text_length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Error converting text from IM to UCS-4: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
*text = result;
|
||||
return text_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
*text = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
preedit_draw_callback (XIC xic,
|
||||
XPointer client_data,
|
||||
XIMPreeditDrawCallbackStruct *call_data)
|
||||
{
|
||||
GtkIMContextXIM *context = GTK_IM_CONTEXT_XIM (client_data);
|
||||
|
||||
XIMText *new_xim_text = call_data->text;
|
||||
gint new_text_length;
|
||||
gunichar *new_text = NULL;
|
||||
gint i;
|
||||
gint diff;
|
||||
gint new_length;
|
||||
gchar *tmp;
|
||||
|
||||
gint chg_first = CLAMP (call_data->chg_first, 0, context->preedit_length);
|
||||
gint chg_length = CLAMP (call_data->chg_length, 0, context->preedit_length - chg_first);
|
||||
|
||||
context->preedit_cursor = call_data->caret;
|
||||
|
||||
if (chg_first != call_data->chg_first || chg_length != call_data->chg_length)
|
||||
g_warning ("Invalid change to preedit string, first=%d length=%d (orig length == %d)",
|
||||
call_data->chg_first, call_data->chg_length, context->preedit_length);
|
||||
|
||||
new_text_length = xim_text_to_utf8 (context, new_xim_text, &tmp);
|
||||
if (tmp)
|
||||
{
|
||||
new_text = g_utf8_to_ucs4 (tmp, -1);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
diff = new_text_length - chg_length;
|
||||
new_length = context->preedit_length + diff;
|
||||
|
||||
if (new_length > context->preedit_size)
|
||||
{
|
||||
context->preedit_size = new_length;
|
||||
context->preedit_chars = g_renew (gunichar, context->preedit_chars, new_length);
|
||||
context->feedbacks = g_renew (XIMFeedback, context->feedbacks, new_length);
|
||||
}
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
for (i = chg_first + chg_length ; i < context->preedit_length; i++)
|
||||
{
|
||||
context->preedit_chars[i + diff] = context->preedit_chars[i];
|
||||
context->feedbacks[i + diff] = context->feedbacks[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = context->preedit_length - 1; i >= chg_first + chg_length ; i--)
|
||||
{
|
||||
context->preedit_chars[i + diff] = context->preedit_chars[i];
|
||||
context->feedbacks[i + diff] = context->feedbacks[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < new_text_length; i++)
|
||||
{
|
||||
context->preedit_chars[chg_first + i] = new_text[i];
|
||||
context->feedbacks[chg_first + i] = new_xim_text->feedback[i];
|
||||
}
|
||||
|
||||
context->preedit_length += diff;
|
||||
|
||||
if (new_text)
|
||||
g_free (new_text);
|
||||
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (context), "preedit-changed");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
preedit_caret_callback (XIC xic,
|
||||
XPointer client_data,
|
||||
XIMPreeditCaretCallbackStruct *call_data)
|
||||
{
|
||||
GtkIMContextXIM *context = GTK_IM_CONTEXT_XIM (client_data);
|
||||
|
||||
if (call_data->direction == XIMAbsolutePosition)
|
||||
{
|
||||
context->preedit_cursor = call_data->position;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (context), "preedit-changed");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Caret movement command: %d %d %d not supported",
|
||||
call_data->position, call_data->direction, call_data->style);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
status_start_callback (XIC xic,
|
||||
XPointer client_data,
|
||||
XPointer call_data)
|
||||
{
|
||||
g_print ("Status start\n");
|
||||
}
|
||||
|
||||
static void
|
||||
status_done_callback (XIC xic,
|
||||
XPointer client_data,
|
||||
XPointer call_data)
|
||||
{
|
||||
g_print ("Status done!\n");
|
||||
}
|
||||
|
||||
static void
|
||||
status_draw_callback (XIC xic,
|
||||
XPointer client_data,
|
||||
XIMStatusDrawCallbackStruct *call_data)
|
||||
{
|
||||
GtkIMContextXIM *context = GTK_IM_CONTEXT_XIM (client_data);
|
||||
|
||||
g_print ("Status draw\n");
|
||||
if (call_data->type == XIMTextType)
|
||||
{
|
||||
gchar *text;
|
||||
xim_text_to_utf8 (context, call_data->data.text, &text);
|
||||
|
||||
if (text)
|
||||
g_print (" %s\n", text);
|
||||
}
|
||||
else /* bitmap */
|
||||
{
|
||||
g_print (" bitmap id = %#lx\n", call_data->data.bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
static XIC
|
||||
gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim)
|
||||
{
|
||||
const char *name1 = NULL;
|
||||
XVaNestedList *list1 = NULL;
|
||||
const char *name2 = NULL;
|
||||
XVaNestedList *list2 = NULL;
|
||||
|
||||
if (!context_xim->ic && context_xim->client_window)
|
||||
{
|
||||
if ((context_xim->im_info->style & PREEDIT_MASK) == XIMPreeditCallbacks)
|
||||
{
|
||||
context_xim->preedit_start_callback.client_data = (XPointer)context_xim;
|
||||
context_xim->preedit_start_callback.callback = (XIMProc)preedit_start_callback;
|
||||
context_xim->preedit_done_callback.client_data = (XPointer)context_xim;
|
||||
context_xim->preedit_done_callback.callback = (XIMProc)preedit_done_callback;
|
||||
context_xim->preedit_draw_callback.client_data = (XPointer)context_xim;
|
||||
context_xim->preedit_draw_callback.callback = (XIMProc)preedit_draw_callback;
|
||||
context_xim->preedit_caret_callback.client_data = (XPointer)context_xim;
|
||||
context_xim->preedit_caret_callback.callback = (XIMProc)preedit_caret_callback;
|
||||
|
||||
name1 = XNPreeditAttributes;
|
||||
list1 = XVaCreateNestedList (0,
|
||||
XNPreeditStartCallback, &context_xim->preedit_start_callback,
|
||||
XNPreeditDoneCallback, &context_xim->preedit_done_callback,
|
||||
XNPreeditDrawCallback, &context_xim->preedit_draw_callback,
|
||||
XNPreeditCaretCallback, &context_xim->preedit_caret_callback,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if ((context_xim->im_info->style & STATUS_MASK) == XIMStatusCallbacks)
|
||||
{
|
||||
XVaNestedList *status_attrs;
|
||||
|
||||
context_xim->status_start_callback.client_data = (XPointer)context_xim;
|
||||
context_xim->status_start_callback.callback = (XIMProc)status_start_callback;
|
||||
context_xim->status_done_callback.client_data = (XPointer)context_xim;
|
||||
context_xim->status_done_callback.callback = (XIMProc)status_done_callback;
|
||||
context_xim->status_draw_callback.client_data = (XPointer)context_xim;
|
||||
context_xim->status_draw_callback.callback = (XIMProc)status_draw_callback;
|
||||
|
||||
status_attrs = XVaCreateNestedList (0,
|
||||
XNStatusStartCallback, &context_xim->status_start_callback,
|
||||
XNStatusDoneCallback, &context_xim->status_done_callback,
|
||||
XNStatusDrawCallback, &context_xim->status_draw_callback,
|
||||
NULL);
|
||||
|
||||
if (name1 == NULL)
|
||||
{
|
||||
name1 = XNStatusAttributes;
|
||||
list1 = status_attrs;
|
||||
}
|
||||
else
|
||||
{
|
||||
name2 = XNStatusAttributes;
|
||||
list2 = status_attrs;
|
||||
}
|
||||
}
|
||||
|
||||
context_xim->ic = XCreateIC (context_xim->im_info->im,
|
||||
XNInputStyle, context_xim->im_info->style,
|
||||
XNClientWindow, GDK_DRAWABLE_XID (context_xim->client_window),
|
||||
name1, list1,
|
||||
name2, list2,
|
||||
NULL);
|
||||
|
||||
if (list1)
|
||||
XFree (list1);
|
||||
if (list2)
|
||||
XFree (list2);
|
||||
}
|
||||
|
||||
return context_xim->ic;
|
||||
}
|
88
modules/input/gtkimcontextxim.h
Normal file
88
modules/input/gtkimcontextxim.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2000 Red Hat Software
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_IM_CONTEXT_XIM_H__
|
||||
#define __GTK_IM_CONTEXT_XIM_H__
|
||||
|
||||
#include <gtk/gtkimcontext.h>
|
||||
#include "x11/gdkx.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
extern GType gtk_type_im_context_xim;
|
||||
|
||||
#define GTK_TYPE_IM_CONTEXT_XIM gtk_type_im_context_xim
|
||||
#define GTK_IM_CONTEXT_XIM(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIM))
|
||||
#define GTK_IM_CONTEXT_XIM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIMClass))
|
||||
#define GTK_IS_IM_CONTEXT_XIM(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_IM_CONTEXT_XIM))
|
||||
#define GTK_IS_IM_CONTEXT_XIM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IM_CONTEXT_XIM))
|
||||
#define GTK_IM_CONTEXT_XIM_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_IM_CONTEXT_XIM, GtkIMContextXIMClass))
|
||||
|
||||
|
||||
typedef struct _GtkIMContextXIM GtkIMContextXIM;
|
||||
typedef struct _GtkIMContextXIMClass GtkIMContextXIMClass;
|
||||
|
||||
typedef struct _GtkXIMInfo GtkXIMInfo;
|
||||
|
||||
struct _GtkIMContextXIM
|
||||
{
|
||||
GtkIMContext object;
|
||||
|
||||
GtkXIMInfo *im_info;
|
||||
|
||||
gchar *mb_charset;
|
||||
|
||||
GdkWindow *client_window;
|
||||
|
||||
gint preedit_size;
|
||||
gint preedit_length;
|
||||
gunichar *preedit_chars;
|
||||
XIMFeedback *feedbacks;
|
||||
|
||||
gint preedit_cursor;
|
||||
|
||||
XIMCallback preedit_start_callback;
|
||||
XIMCallback preedit_done_callback;
|
||||
XIMCallback preedit_draw_callback;
|
||||
XIMCallback preedit_caret_callback;
|
||||
|
||||
XIMCallback status_start_callback;
|
||||
XIMCallback status_done_callback;
|
||||
XIMCallback status_draw_callback;
|
||||
|
||||
XIC ic;
|
||||
};
|
||||
|
||||
struct _GtkIMContextXIMClass
|
||||
{
|
||||
GtkIMContextClass parent_class;
|
||||
};
|
||||
|
||||
void gtk_im_context_xim_register_type (GTypeModule *type_module);
|
||||
GtkIMContext *gtk_im_context_xim_new (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GTK_IM_CONTEXT_XIM_H__ */
|
252
modules/input/imcyrillic-translit.c
Normal file
252
modules/input/imcyrillic-translit.c
Normal file
@ -0,0 +1,252 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2000 Red Hat Software
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Owen Taylor <otaylor@redhat.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "gtk/gtkintl.h"
|
||||
#include "gtk/gtkimcontextsimple.h"
|
||||
#include "gtk/gtkimmodule.h"
|
||||
|
||||
GType type_cyrillic_translit = 0;
|
||||
|
||||
static void cyrillic_translit_class_init (GtkIMContextSimpleClass *class);
|
||||
static void cyrillic_translit_init (GtkIMContextSimple *im_context);
|
||||
|
||||
static void
|
||||
cyrillic_translit_register_type (GTypeModule *module)
|
||||
{
|
||||
static const GTypeInfo object_info =
|
||||
{
|
||||
sizeof (GtkIMContextSimpleClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) cyrillic_translit_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkIMContextSimple),
|
||||
0,
|
||||
(GtkObjectInitFunc) cyrillic_translit_init,
|
||||
};
|
||||
|
||||
type_cyrillic_translit =
|
||||
g_type_module_register_type (module,
|
||||
GTK_TYPE_IM_CONTEXT_SIMPLE,
|
||||
"GtkIMContextCyrillicTranslit",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
/* The sequences here match the sequences used in the emacs quail
|
||||
* mode cryllic-translit; they allow entering all characters
|
||||
* in iso-8859-5
|
||||
*/
|
||||
static guint16 cyrillic_compose_seqs[] = {
|
||||
GDK_apostrophe, 0, 0, 0, 0, 0x44C, /* CYRILLIC SMALL LETTER SOFT SIGN */
|
||||
GDK_apostrophe, GDK_apostrophe, 0, 0, 0, 0x42C, /* CYRILLIC CAPITAL LETTER SOFT SIGN */
|
||||
GDK_slash, GDK_C, GDK_H, 0, 0, 0x040B, /* CYRILLIC CAPITAL LETTER TSHE */
|
||||
GDK_slash, GDK_C, GDK_h, 0, 0, 0x040B, /* CYRILLIC CAPITAL LETTER TSHE */
|
||||
GDK_slash, GDK_D, 0, 0, 0, 0x0402, /* CYRILLIC CAPITAL LETTER DJE */
|
||||
GDK_slash, GDK_E, 0, 0, 0, 0x0404, /* CYRILLIC CAPITAL LETTER UKRAINIAN IE */
|
||||
GDK_slash, GDK_G, 0, 0, 0, 0x0403, /* CYRILLIC CAPITAL LETTER GJE */
|
||||
GDK_slash, GDK_I, 0, 0, 0, 0x0406, /* CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */
|
||||
GDK_slash, GDK_J, 0, 0, 0, 0x0408, /* CYRILLIC CAPITAL LETTER JE */
|
||||
GDK_slash, GDK_K, 0, 0, 0, 0x040C, /* CYRILLIC CAPITAL LETTER KJE */
|
||||
GDK_slash, GDK_L, 0, 0, 0, 0x0409, /* CYRILLIC CAPITAL LETTER LJE */
|
||||
GDK_slash, GDK_N, 0, 0, 0, 0x040A, /* CYRILLIC CAPITAL LETTER NJE */
|
||||
GDK_slash, GDK_S, 0, 0, 0, 0x0405, /* CYRILLIC CAPITAL LETTER DZE */
|
||||
GDK_slash, GDK_S, GDK_H, GDK_T, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCH */
|
||||
GDK_slash, GDK_S, GDK_H, GDK_t, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCH */
|
||||
GDK_slash, GDK_S, GDK_h, GDK_t, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCH */
|
||||
GDK_slash, GDK_T, 0, 0, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCH */
|
||||
GDK_slash, GDK_Z, 0, 0, 0, 0x040F, /* CYRILLIC CAPITAL LETTER DZHE */
|
||||
GDK_slash, GDK_c, GDK_h, 0, 0, 0x045B, /* CYRILLIC SMALL LETTER TSHE */
|
||||
GDK_slash, GDK_d, 0, 0, 0, 0x0452, /* CYRILLIC SMALL LETTER DJE */
|
||||
GDK_slash, GDK_e, 0, 0, 0, 0x0454, /* CYRILLIC SMALL LETTER UKRAINIAN IE */
|
||||
GDK_slash, GDK_g, 0, 0, 0, 0x0453, /* CYRILLIC SMALL LETTER GJE */
|
||||
GDK_slash, GDK_i, 0, 0, 0, 0x0456, /* CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */
|
||||
GDK_slash, GDK_j, 0, 0, 0, 0x0458, /* CYRILLIC SMALL LETTER JE */
|
||||
GDK_slash, GDK_k, 0, 0, 0, 0x045C, /* CYRILLIC SMALL LETTER KJE */
|
||||
GDK_slash, GDK_l, 0, 0, 0, 0x0459, /* CYRILLIC SMALL LETTER LJE */
|
||||
GDK_slash, GDK_n, 0, 0, 0, 0x045A, /* CYRILLIC SMALL LETTER NJE */
|
||||
GDK_slash, GDK_s, 0, 0, 0, 0x0455, /* CYRILLIC SMALL LETTER DZE */
|
||||
GDK_slash, GDK_s, GDK_h, GDK_t, 0, 0x0449, /* CYRILLIC SMALL LETTER SHCH */
|
||||
GDK_slash, GDK_t, 0, 0, 0, 0x0449, /* CYRILLIC SMALL LETTER SHCH */
|
||||
GDK_slash, GDK_z, 0, 0, 0, 0x045F, /* CYRILLIC SMALL LETTER DZHE */
|
||||
GDK_A, 0, 0, 0, 0, 0x0410, /* CYRILLIC CAPITAL LETTER A */
|
||||
GDK_B, 0, 0, 0, 0, 0x0411, /* CYRILLIC CAPITAL LETTER BE */
|
||||
GDK_C, 0, 0, 0, 0, 0x0426, /* CYRILLIC CAPITAL LETTER TSE */
|
||||
GDK_C, GDK_H, 0, 0, 0, 0x0427, /* CYRILLIC CAPITAL LETTER CHE */
|
||||
GDK_C, GDK_h, 0, 0, 0, 0x0427, /* CYRILLIC CAPITAL LETTER CHE */
|
||||
GDK_D, 0, 0, 0, 0, 0x0414, /* CYRILLIC CAPITAL LETTER DE */
|
||||
GDK_E, 0, 0, 0, 0, 0x0415, /* CYRILLIC CAPITAL LETTER IE */
|
||||
GDK_E, GDK_apostrophe, 0, 0, 0, 0x042D, /* CYRILLIC CAPITAL LETTER E */
|
||||
GDK_F, 0, 0, 0, 0, 0x0424, /* CYRILLIC CAPITAL LETTER EF */
|
||||
GDK_G, 0, 0, 0, 0, 0x0413, /* CYRILLIC CAPITAL LETTER GE */
|
||||
GDK_H, 0, 0, 0, 0, 0x0425, /* CYRILLIC CAPITAL LETTER HA */
|
||||
GDK_I, 0, 0, 0, 0, 0x0418, /* CYRILLIC CAPITAL LETTER I */
|
||||
GDK_J, 0, 0, 0, 0, 0x0419, /* CYRILLIC CAPITAL LETTER SHORT I */
|
||||
GDK_J, GDK_apostrophe, 0, 0, 0, 0x0419, /* CYRILLIC CAPITAL LETTER SHORT I */
|
||||
GDK_J, GDK_A, 0, 0, 0, 0x042F, /* CYRILLIC CAPITAL LETTER YA */
|
||||
GDK_J, GDK_I, 0, 0, 0, 0x0407, /* CYRILLIC CAPITAL LETTER YI */
|
||||
GDK_J, GDK_O, 0, 0, 0, 0x0401, /* CYRILLIC CAPITAL LETTER YO */
|
||||
GDK_J, GDK_U, 0, 0, 0, 0x042E, /* CYRILLIC CAPITAL LETTER YA */
|
||||
GDK_J, GDK_a, 0, 0, 0, 0x042F, /* CYRILLIC CAPITAL LETTER YA */
|
||||
GDK_J, GDK_i, 0, 0, 0, 0x0407, /* CYRILLIC CAPITAL LETTER YI */
|
||||
GDK_J, GDK_o, 0, 0, 0, 0x0401, /* CYRILLIC CAPITAL LETTER YO */
|
||||
GDK_J, GDK_u, 0, 0, 0, 0x042E, /* CYRILLIC CAPITAL LETTER YA */
|
||||
GDK_K, 0, 0, 0, 0, 0x041A, /* CYRILLIC CAPITAL LETTER KA */
|
||||
GDK_K, GDK_H, 0, 0, 0, 0x0425, /* CYRILLIC CAPITAL LETTER HA */
|
||||
GDK_L, 0, 0, 0, 0, 0x041B, /* CYRILLIC CAPITAL LETTER EL */
|
||||
GDK_M, 0, 0, 0, 0, 0x041C, /* CYRILLIC CAPITAL LETTER EM */
|
||||
GDK_N, 0, 0, 0, 0, 0x041D, /* CYRILLIC CAPITAL LETTER EN */
|
||||
GDK_O, 0, 0, 0, 0, 0x041E, /* CYRILLIC CAPITAL LETTER O */
|
||||
GDK_P, 0, 0, 0, 0, 0x041F, /* CYRILLIC CAPITAL LETTER PE */
|
||||
GDK_Q, 0, 0, 0, 0, 0x042F, /* CYRILLIC CAPITAL LETTER YA */
|
||||
GDK_R, 0, 0, 0, 0, 0x0420, /* CYRILLIC CAPITAL LETTER ER */
|
||||
GDK_S, 0, 0, 0, 0, 0x0421, /* CYRILLIC CAPITAL LETTER ES */
|
||||
GDK_S, GDK_H, 0, 0, 0, 0x0428, /* CYRILLIC CAPITAL LETTER SHA */
|
||||
GDK_S, GDK_H, GDK_C, GDK_H, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCA */
|
||||
GDK_S, GDK_H, GDK_C, GDK_h, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCA */
|
||||
GDK_S, GDK_H, GDK_c, GDK_h, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCA */
|
||||
GDK_S, GDK_H, GDK_c, GDK_h, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCA */
|
||||
GDK_S, GDK_J, 0, 0, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCA */
|
||||
GDK_S, GDK_h, 0, 0, 0, 0x0428, /* CYRILLIC CAPITAL LETTER SHA */
|
||||
GDK_S, GDK_j, 0, 0, 0, 0x0429, /* CYRILLIC CAPITAL LETTER SHCA */
|
||||
GDK_T, 0, 0, 0, 0, 0x0422, /* CYRILLIC CAPITAL LETTER TE */
|
||||
GDK_U, 0, 0, 0, 0, 0x0423, /* CYRILLIC CAPITAL LETTER U */
|
||||
GDK_U, GDK_apostrophe, 0, 0, 0, 0x040E, /* CYRILLIC CAPITAL LETTER SHORT */
|
||||
GDK_V, 0, 0, 0, 0, 0x0412, /* CYRILLIC CAPITAL LETTER VE */
|
||||
GDK_W, 0, 0, 0, 0, 0x0412, /* CYRILLIC CAPITAL LETTER VE */
|
||||
GDK_X, 0, 0, 0, 0, 0x0425, /* CYRILLIC CAPITAL LETTER HA */
|
||||
GDK_Y, 0, 0, 0, 0, 0x042B, /* CYRILLIC CAPITAL LETTER YERU */
|
||||
GDK_Y, GDK_A, 0, 0, 0, 0x042F, /* CYRILLIC CAPITAL LETTER YA */
|
||||
GDK_Y, GDK_I, 0, 0, 0, 0x0407, /* CYRILLIC CAPITAL LETTER YI */
|
||||
GDK_Y, GDK_O, 0, 0, 0, 0x0401, /* CYRILLIC CAPITAL LETTER YO */
|
||||
GDK_Y, GDK_U, 0, 0, 0, 0x042E, /* CYRILLIC CAPITAL LETTER YU */
|
||||
GDK_Y, GDK_a, 0, 0, 0, 0x042F, /* CYRILLIC CAPITAL LETTER YA */
|
||||
GDK_Y, GDK_i, 0, 0, 0, 0x0407, /* CYRILLIC CAPITAL LETTER YI */
|
||||
GDK_Y, GDK_o, 0, 0, 0, 0x0401, /* CYRILLIC CAPITAL LETTER YO */
|
||||
GDK_Y, GDK_u, 0, 0, 0, 0x042E, /* CYRILLIC CAPITAL LETTER YU */
|
||||
GDK_Z, 0, 0, 0, 0, 0x0417, /* CYRILLIC CAPITAL LETTER ZE */
|
||||
GDK_Z, GDK_H, 0, 0, 0, 0x0416, /* CYRILLIC CAPITAL LETTER ZHE */
|
||||
GDK_Z, GDK_h, 0, 0, 0, 0x0416, /* CYRILLIC CAPITAL LETTER ZHE */
|
||||
GDK_a, 0, 0, 0, 0, 0x0430, /* CYRILLIC SMALL LETTER A */
|
||||
GDK_b, 0, 0, 0, 0, 0x0431, /* CYRILLIC SMALL LETTER BE */
|
||||
GDK_c, 0, 0, 0, 0, 0x0446, /* CYRILLIC SMALL LETTER TSE */
|
||||
GDK_c, GDK_h, 0, 0, 0, 0x0447, /* CYRILLIC SMALL LETTER CHE */
|
||||
GDK_d, 0, 0, 0, 0, 0x0434, /* CYRILLIC SMALL LETTER DE */
|
||||
GDK_e, 0, 0, 0, 0, 0x0435, /* CYRILLIC SMALL LETTER IE */
|
||||
GDK_e, GDK_apostrophe, 0, 0, 0, 0x044D, /* CYRILLIC SMALL LETTER E */
|
||||
GDK_f, 0, 0, 0, 0, 0x0444, /* CYRILLIC SMALL LETTER EF */
|
||||
GDK_g, 0, 0, 0, 0, 0x0433, /* CYRILLIC SMALL LETTER GE */
|
||||
GDK_h, 0, 0, 0, 0, 0x0445, /* CYRILLIC SMALL LETTER HA */
|
||||
GDK_i, 0, 0, 0, 0, 0x0438, /* CYRILLIC SMALL LETTER I */
|
||||
GDK_j, 0, 0, 0, 0, 0x0439, /* CYRILLIC SMALL LETTER SHORT I */
|
||||
GDK_j, GDK_apostrophe, 0, 0, 0, 0x0439, /* CYRILLIC SMALL LETTER SHORT I */
|
||||
GDK_j, GDK_a, 0, 0, 0, 0x044F, /* CYRILLIC SMALL LETTER YU */
|
||||
GDK_j, GDK_i, 0, 0, 0, 0x0457, /* CYRILLIC SMALL LETTER YI */
|
||||
GDK_j, GDK_o, 0, 0, 0, 0x0451, /* CYRILLIC SMALL LETTER YO */
|
||||
GDK_j, GDK_u, 0, 0, 0, 0x044E, /* CYRILLIC SMALL LETTER YA */
|
||||
GDK_k, 0, 0, 0, 0, 0x043A, /* CYRILLIC SMALL LETTER KA */
|
||||
GDK_k, GDK_h, 0, 0, 0, 0x0445, /* CYRILLIC SMALL LETTER HA */
|
||||
GDK_l, 0, 0, 0, 0, 0x043B, /* CYRILLIC SMALL LETTER EL */
|
||||
GDK_m, 0, 0, 0, 0, 0x043C, /* CYRILLIC SMALL LETTER EM */
|
||||
GDK_n, 0, 0, 0, 0, 0x043D, /* CYRILLIC SMALL LETTER EN */
|
||||
GDK_o, 0, 0, 0, 0, 0x043E, /* CYRILLIC SMALL LETTER O */
|
||||
GDK_p, 0, 0, 0, 0, 0x043F, /* CYRILLIC SMALL LETTER PE */
|
||||
GDK_q, 0, 0, 0, 0, 0x044F, /* CYRILLIC SMALL LETTER YA */
|
||||
GDK_r, 0, 0, 0, 0, 0x0440, /* CYRILLIC SMALL LETTER ER */
|
||||
GDK_s, 0, 0, 0, 0, 0x0441, /* CYRILLIC SMALL LETTER ES */
|
||||
GDK_s, GDK_h, 0, 0, 0, 0x0448, /* CYRILLIC SMALL LETTER SHA */
|
||||
GDK_s, GDK_h, GDK_c, GDK_h, 0, 0x0449, /* CYRILLIC SMALL LETTER SHCA */
|
||||
GDK_s, GDK_j, 0, 0, 0, 0x0449, /* CYRILLIC SMALL LETTER SHCA */
|
||||
GDK_t, 0, 0, 0, 0, 0x0442, /* CYRILLIC SMALL LETTER TE */
|
||||
GDK_u, 0, 0, 0, 0, 0x0443, /* CYRILLIC SMALL LETTER U */
|
||||
GDK_u, GDK_apostrophe, 0, 0, 0, 0x045E, /* CYRILLIC SMALL LETTER SHORT */
|
||||
GDK_v, 0, 0, 0, 0, 0x0432, /* CYRILLIC SMALL LETTER VE */
|
||||
GDK_w, 0, 0, 0, 0, 0x0432, /* CYRILLIC SMALL LETTER VE */
|
||||
GDK_x, 0, 0, 0, 0, 0x0445, /* CYRILLIC SMALL LETTER HA */
|
||||
GDK_y, 0, 0, 0, 0, 0x044B, /* CYRILLIC SMALL LETTER YERU */
|
||||
GDK_y, GDK_a, 0, 0, 0, 0x044F, /* CYRILLIC SMALL LETTER YU */
|
||||
GDK_y, GDK_i, 0, 0, 0, 0x0457, /* CYRILLIC SMALL LETTER YI */
|
||||
GDK_y, GDK_o, 0, 0, 0, 0x0451, /* CYRILLIC SMALL LETTER YO */
|
||||
GDK_y, GDK_u, 0, 0, 0, 0x044E, /* CYRILLIC SMALL LETTER YA */
|
||||
GDK_z, 0, 0, 0, 0, 0x0437, /* CYRILLIC SMALL LETTER ZE */
|
||||
GDK_z, GDK_h, 0, 0, 0, 0x0436, /* CYRILLIC SMALL LETTER ZHE */
|
||||
GDK_asciitilde, 0, 0, 0, 0, 0x44A, /* CYRILLIC SMALL LETTER HARD SIGN */
|
||||
GDK_asciitilde, GDK_asciitilde, 0, 0, 0, 0x42A, /* CYRILLIC CAPITAL LETTER HARD SIGN */
|
||||
};
|
||||
|
||||
static void
|
||||
cyrillic_translit_class_init (GtkIMContextSimpleClass *class)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
cyrillic_translit_init (GtkIMContextSimple *im_context)
|
||||
{
|
||||
gtk_im_context_simple_add_table (im_context,
|
||||
cyrillic_compose_seqs,
|
||||
4,
|
||||
G_N_ELEMENTS (cyrillic_compose_seqs) / (4 + 2));
|
||||
}
|
||||
|
||||
static const GtkIMContextInfo cyrillic_translit_info = {
|
||||
"cyrillic_translit", /* ID */
|
||||
N_("Cyrillic (Transliterated)"), /* Human readable name */
|
||||
"gtk+", /* Translation domain */
|
||||
GTK_LOCALEDIR, /* Dir for bindtextdomain (not strictly needed for "gtk+") */
|
||||
"" /* Languages for which this module is the default */
|
||||
};
|
||||
|
||||
static const GtkIMContextInfo *info_list[] = {
|
||||
&cyrillic_translit_info
|
||||
};
|
||||
|
||||
void
|
||||
im_module_init (GTypeModule *module)
|
||||
{
|
||||
cyrillic_translit_register_type (module);
|
||||
}
|
||||
|
||||
void
|
||||
im_module_exit (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
im_module_list (const GtkIMContextInfo ***contexts,
|
||||
int *n_contexts)
|
||||
{
|
||||
*contexts = info_list;
|
||||
*n_contexts = G_N_ELEMENTS (info_list);
|
||||
}
|
||||
|
||||
GtkIMContext *
|
||||
im_module_create (const gchar *context_id)
|
||||
{
|
||||
if (strcmp (context_id, "cyrillic_translit") == 0)
|
||||
return GTK_IM_CONTEXT (gtk_type_new (type_cyrillic_translit));
|
||||
else
|
||||
return NULL;
|
||||
}
|
63
modules/input/imxim.c
Normal file
63
modules/input/imxim.c
Normal file
@ -0,0 +1,63 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2000 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gtk/gtkintl.h"
|
||||
#include "gtk/gtkimmodule.h"
|
||||
#include "gtkimcontextxim.h"
|
||||
#include <string.h>
|
||||
|
||||
static const GtkIMContextInfo xim_ja_info = {
|
||||
"xim", /* ID */
|
||||
N_("X Input Method"), /* Human readable name */
|
||||
"gtk+", /* Translation domain */
|
||||
GTK_LOCALEDIR, /* Dir for bindtextdomain (not strictly needed for "gtk+") */
|
||||
"ja" /* Languages for which this module is the default */
|
||||
};
|
||||
|
||||
static const GtkIMContextInfo *info_list[] = {
|
||||
&xim_ja_info
|
||||
};
|
||||
|
||||
void
|
||||
im_module_init (GTypeModule *type_module)
|
||||
{
|
||||
gtk_im_context_xim_register_type (type_module);
|
||||
}
|
||||
|
||||
void
|
||||
im_module_exit (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
im_module_list (const GtkIMContextInfo ***contexts,
|
||||
int *n_contexts)
|
||||
{
|
||||
*contexts = info_list;
|
||||
*n_contexts = G_N_ELEMENTS (info_list);
|
||||
}
|
||||
|
||||
GtkIMContext *
|
||||
im_module_create (const gchar *context_id)
|
||||
{
|
||||
if (strcmp (context_id, "xim") == 0)
|
||||
return gtk_im_context_xim_new ();
|
||||
else
|
||||
return NULL;
|
||||
}
|
Loading…
Reference in New Issue
Block a user