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