]> Pileus Git - ~andy/gtk/blob - modules/input/imcedilla.c
Revert name change
[~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 "gtk/gtk.h"
27 #include "gdk/gdkkeysyms.h"
28
29 #include "gtk/gtkimmodule.h"
30 #include "gtk/gtkintl.h"
31
32
33 GType type_cedilla = 0;
34
35 static void cedilla_class_init (GtkIMContextSimpleClass *class);
36 static void cedilla_init (GtkIMContextSimple *im_context);
37
38 static void
39 cedilla_register_type (GTypeModule *module)
40 {
41   static const GTypeInfo object_info =
42   {
43     sizeof (GtkIMContextSimpleClass),
44     (GBaseInitFunc) NULL,
45     (GBaseFinalizeFunc) NULL,
46     (GClassInitFunc) cedilla_class_init,
47     NULL,           /* class_finalize */
48     NULL,           /* class_data */
49     sizeof (GtkIMContextSimple),
50     0,
51     (GInstanceInitFunc) cedilla_init,
52   };
53
54   type_cedilla = 
55     g_type_module_register_type (module,
56                                  GTK_TYPE_IM_CONTEXT_SIMPLE,
57                                  "GtkIMContextCedillaTranslit",
58                                  &object_info, 0);
59 }
60
61 /* The difference between this and the default input method is the handling
62  * of C+acute - this method produces C WITH CEDILLA rather than C WITH ACUTE.
63  * For languages that use CCedilla and not acute, this is the preferred mapping,
64  * and is particularly important for pt_BR, where the us-intl keyboard is
65  * used extensively.
66  */
67 static guint16 cedilla_compose_seqs[] = {
68   GDK_dead_acute,       GDK_C,  0,      0,      0,      0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
69   GDK_dead_acute,       GDK_c,  0,      0,      0,      0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
70   GDK_Multi_key,        GDK_apostrophe, GDK_C,  0,      0,      0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
71   GDK_Multi_key,        GDK_apostrophe, GDK_c,  0,      0,      0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
72   GDK_Multi_key,        GDK_C,  GDK_apostrophe, 0,      0,      0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
73   GDK_Multi_key,        GDK_c,  GDK_apostrophe, 0,      0,      0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
74 };
75
76 static void
77 cedilla_class_init (GtkIMContextSimpleClass *class)
78 {
79 }
80
81 static void
82 cedilla_init (GtkIMContextSimple *im_context)
83 {
84   gtk_im_context_simple_add_table (im_context,
85                                    cedilla_compose_seqs,
86                                    4,
87                                    G_N_ELEMENTS (cedilla_compose_seqs) / (4 + 2));
88 }
89
90 static const GtkIMContextInfo cedilla_info = { 
91   "cedilla",                       /* ID */
92   N_("Cedilla"),                   /* Human readable name */
93   GETTEXT_PACKAGE,                 /* Translation domain */
94   GTK_LOCALEDIR,                   /* Dir for bindtextdomain */
95   "az:ca:co:fr:gv:oc:pt:sq:tr:wa"  /* Languages for which this module is the default */
96 };
97
98 static const GtkIMContextInfo *info_list[] = {
99   &cedilla_info
100 };
101
102 #ifndef INCLUDE_IM_cedilla
103 #define MODULE_ENTRY(type, function) G_MODULE_EXPORT type im_module_ ## function
104 #else
105 #define MODULE_ENTRY(type, function) type _gtk_immodule_cedilla_ ## function
106 #endif
107
108 MODULE_ENTRY (void, init) (GTypeModule *module)
109 {
110   cedilla_register_type (module);
111 }
112
113 MODULE_ENTRY (void, exit) (void)
114 {
115 }
116
117 MODULE_ENTRY (void, list) (const GtkIMContextInfo ***contexts,
118                            int                      *n_contexts)
119 {
120   *contexts = info_list;
121   *n_contexts = G_N_ELEMENTS (info_list);
122 }
123
124 MODULE_ENTRY (GtkIMContext *, create) (const gchar *context_id)
125 {
126   if (strcmp (context_id, "cedilla") == 0)
127     return g_object_new (type_cedilla, NULL);
128   else
129     return NULL;
130 }