1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
2 /*
3 * nimf-m17n-si.c
4 * This file is part of Nimf.
5 *
6 * Copyright (C) 2019 Hodong Kim <cogniti@gmail.com>
7 *
8 * Nimf is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published
10 * by the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Nimf is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "nimf-m17n.h"
23
24 #define NIMF_TYPE_M17N_SI (nimf_m17n_si_get_type ())
25 #define NIMF_M17N_SI(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), NIMF_TYPE_M17N_SI, NimfM17nSi))
26 #define NIMF_M17N_SI_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), NIMF_TYPE_M17N_SI, NimfM17nSiClass))
27 #define NIMF_IS_M17N_SI(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), NIMF_TYPE_M17N_SI))
28 #define NIMF_IS_M17N_SI_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), NIMF_TYPE_M17N_SI))
29 #define NIMF_M17N_SI_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), NIMF_TYPE_M17N_SI, NimfM17nSiClass))
30
31 typedef struct _NimfM17nSi NimfM17nSi;
32 typedef struct _NimfM17nSiClass NimfM17nSiClass;
33
34 struct _NimfM17nSi
35 {
36 NimfM17n parent_instance;
37 };
38
39 struct _NimfM17nSiClass
40 {
41 /*< private >*/
42 NimfM17nClass parent_class;
43 };
44
45 G_DEFINE_DYNAMIC_TYPE (NimfM17nSi, nimf_m17n_si, NIMF_TYPE_M17N);
46
47 static void
nimf_m17n_si_init(NimfM17nSi * si)48 nimf_m17n_si_init (NimfM17nSi *si)
49 {
50 g_debug (G_STRLOC ": %s", G_STRFUNC);
51
52 NimfM17n *m17n = NIMF_M17N (si);
53
54 m17n->id = g_strdup ("nimf-m17n-si");
55 m17n->settings = g_settings_new ("org.nimf.engines.nimf-m17n-si");
56 m17n->method = g_settings_get_string (m17n->settings, "get-method-infos");
57 m17n->preedit_attrs = g_malloc_n (2, sizeof (NimfPreeditAttr *));
58
59 nimf_m17n_open_im (m17n);
60
61 g_signal_connect (m17n->settings, "changed::get-method-infos",
62 G_CALLBACK (on_changed_method), m17n);
63 }
64
65 static void
nimf_m17n_si_class_init(NimfM17nSiClass * class)66 nimf_m17n_si_class_init (NimfM17nSiClass *class)
67 {
68 g_debug (G_STRLOC ": %s", G_STRFUNC);
69 }
70
71 static void
nimf_m17n_si_class_finalize(NimfM17nSiClass * class)72 nimf_m17n_si_class_finalize (NimfM17nSiClass *class)
73 {
74 g_debug (G_STRLOC ": %s", G_STRFUNC);
75 }
76
77 NimfMethodInfo **
nimf_m17n_si_get_method_infos()78 nimf_m17n_si_get_method_infos ()
79 {
80 g_debug (G_STRLOC ": %s", G_STRFUNC);
81
82 NimfMethodInfo *info;
83 GPtrArray *array;
84 gchar *methods[] = {"samanala", "wijesekera", "transliteration", "phonetic-dynamic", "singlish", "sumihiri", NULL};
85 gint i;
86
87 array = g_ptr_array_new ();
88
89 for (i = 0; methods[i]; i++)
90 {
91 info = nimf_method_info_new ();
92 info->method_id = g_strdup_printf ("si:%s", methods[i]);
93 info->label = g_strdup (methods[i]);
94 g_ptr_array_add (array, info);
95 }
96
97 g_ptr_array_add (array, NULL);
98
99 return (NimfMethodInfo **) g_ptr_array_free (array, FALSE);
100 }
101
module_register_type(GTypeModule * type_module)102 void module_register_type (GTypeModule *type_module)
103 {
104 g_debug (G_STRLOC ": %s", G_STRFUNC);
105
106 nimf_m17n_si_register_type (type_module);
107 }
108
module_get_type()109 GType module_get_type ()
110 {
111 g_debug (G_STRLOC ": %s", G_STRFUNC);
112
113 return nimf_m17n_si_get_type ();
114 }
115