]> Pileus Git - ~andy/gtk/blob - modules/input/imcedilla.c
Fixes #136082 and #135265, patch by Morten Welinder.
[~andy/gtk] / modules / input / imcedilla.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2000 Red Hat Software
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library 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  * Author: Owen Taylor <otaylor@redhat.com>
20  *
21  */
22
23 #include <config.h>
24 #include <string.h>
25
26 #include <gdk/gdkkeysyms.h>
27
28 #include "gtk/gtkintl.h"
29 #include "gtk/gtkimcontextsimple.h"
30 #include "gtk/gtkimmodule.h"
31
32 GType type_cedilla = 0;
33
34 static void cedilla_class_init (GtkIMContextSimpleClass *class);
35 static void cedilla_init (GtkIMContextSimple *im_context);
36
37 static void
38 cedilla_register_type (GTypeModule *module)
39 {
40   static const GTypeInfo object_info =
41   {
42     sizeof (GtkIMContextSimpleClass),
43     (GBaseInitFunc) NULL,
44     (GBaseFinalizeFunc) NULL,
45     (GClassInitFunc) cedilla_class_init,
46     NULL,           /* class_finalize */
47     NULL,           /* class_data */
48     sizeof (GtkIMContextSimple),
49     0,
50     (GInstanceInitFunc) cedilla_init,
51   };
52
53   type_cedilla = 
54     g_type_module_register_type (module,
55                                  GTK_TYPE_IM_CONTEXT_SIMPLE,
56                                  "GtkIMContextCedillaTranslit",
57                                  &object_info, 0);
58 }
59
60 /* The difference between this and the default input method is the handling
61  * of C+acute - this method produces C WITH CEDILLA rather than C WITH ACUTE.
62  * For languages that use CCedilla and not acute, this is the preferred mapping,
63  * and is particularly important for pt_BR, where the us-intl keyboard is
64  * used extensively.
65  */
66 static guint16 cedilla_compose_seqs[] = {
67   GDK_dead_acute,       GDK_C,  0,      0,      0,      0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
68   GDK_dead_acute,       GDK_c,  0,      0,      0,      0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
69   GDK_Multi_key,        GDK_apostrophe, GDK_C,  0,      0,      0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
70   GDK_Multi_key,        GDK_apostrophe, GDK_c,  0,      0,      0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
71   GDK_Multi_key,        GDK_C,  GDK_apostrophe, 0,      0,      0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
72   GDK_Multi_key,        GDK_c,  GDK_apostrophe, 0,      0,      0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
73 };
74
75 static void
76 cedilla_class_init (GtkIMContextSimpleClass *class)
77 {
78 }
79
80 static void
81 cedilla_init (GtkIMContextSimple *im_context)
82 {
83   gtk_im_context_simple_add_table (im_context,
84                                    cedilla_compose_seqs,
85                                    4,
86                                    G_N_ELEMENTS (cedilla_compose_seqs) / (4 + 2));
87 }
88
89 static const GtkIMContextInfo cedilla_info = { 
90   "cedilla",                       /* ID */
91   N_("Cedilla"),                   /* Human readable name */
92   "gtk+",                          /* Translation domain */
93    GTK_LOCALEDIR,                  /* Dir for bindtextdomain (not strictly needed for "gtk+") */
94   "az:ca:co:fr:gv:oc:pt:sq:tr:wa"  /* Languages for which this module is the default */
95 };
96
97 static const GtkIMContextInfo *info_list[] = {
98   &cedilla_info
99 };
100
101 void
102 im_module_init (GTypeModule *module)
103 {
104   cedilla_register_type (module);
105 }
106
107 void 
108 im_module_exit (void)
109 {
110 }
111
112 void 
113 im_module_list (const GtkIMContextInfo ***contexts,
114                 int                      *n_contexts)
115 {
116   *contexts = info_list;
117   *n_contexts = G_N_ELEMENTS (info_list);
118 }
119
120 GtkIMContext *
121 im_module_create (const gchar *context_id)
122 {
123   if (strcmp (context_id, "cedilla") == 0)
124     return GTK_IM_CONTEXT (g_object_new (type_cedilla, NULL));
125   else
126     return NULL;
127 }