1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* ibus-anthy - The Anthy engine for IBus
4  * Copyright (c) 2012-2019 Takao Fujiwara <takao.fujiwara1@gmail.com>
5  * Copyright (c) 2012 Peng Huang <shawn.p.huang@gmail.com>
6  * Copyright (c) 2012-2013 Red Hat, Inc.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ANTHY_GCONTEXT_H_
24 #define __ANTHY_GCONTEXT_H_
25 
26 #include <glib-object.h>
27 #include <anthy/anthy.h>
28 
29 /*
30  * Type macros.
31  */
32 #define ANTHY_TYPE_GCONTEXT             \
33     (anthy_gcontext_get_type ())
34 #define ANTHY_GCONTEXT(obj)             \
35     (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANTHY_TYPE_GCONTEXT, AnthyGContext))
36 #define ANTHY_GCONTEXT_CLASS(class)     \
37     (G_TYPE_CHECK_CLASS_CAST ((class), ANTHY_TYPE_GCONTEXT, AnthyGContextClass))
38 #define ANTHY_IS_GCONTEXT(obj)          \
39     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANTHY_TYPE_GCONTEXT))
40 #define ANTHY_IS_GCONTEXT_CLASS(class)  \
41     (G_TYPE_CHECK_CLASS_TYPE ((class), ANTHY_TYPE_GCONTEXT))
42 #define ANTHY_GCONTEXT_GET_CLASS(obj)   \
43     (G_TYPE_INSTANCE_GET_CLASS ((obj), ANTHY_TYPE_GCONTEXT, AnthyGContextClass))
44 
45 typedef struct _AnthyGContext AnthyGContext;
46 typedef struct _AnthyGContextPrivate AnthyGContextPrivate;
47 typedef struct _AnthyGContextClass AnthyGContextClass;
48 
49 G_BEGIN_DECLS
50 
51 /**
52  * AnthyGContext:
53  *
54  * An #AnthyGContext is an object that handles conversion strings.
55  */
56 struct _AnthyGContext {
57     GInitiallyUnowned parent;
58 
59     AnthyGContextPrivate *priv;
60 
61     /*< private >*/
62     gpointer pdummy[8];
63 };
64 
65 struct _AnthyGContextClass {
66     GInitiallyUnownedClass parent;
67 
68     /*< private >*/
69     gpointer pdummy[8];
70 };
71 
72 GType           anthy_gcontext_get_type           (void);
73 
74 /**
75  * anthy_gcontext_new:
76  * @returns: A newly allocated #AnthyGContext
77  *
78  * New an #AnthyGobject.
79  */
80 AnthyGContext   *anthy_gcontext_new               (void);
81 
82 /**
83  * anthy_gcontext_set_encoding:
84  * @encoding: An encoding
85  *
86  * Set an encoding.
87  */
88 int             anthy_gcontext_set_encoding       (AnthyGContext *obj,
89                                                    int encoding);
90 
91 /**
92  * anthy_gcontext_init_personality:
93  *
94  * Initialize the personal dictionaries.
95  */
96 void            anthy_gcontext_init_personality   (AnthyGContext *obj);
97 
98 /**
99  * anthy_gcontext_do_set_personality:
100  * @dict_name: a Dictionary name
101  *
102  * Set a personal dictionary.
103  */
104 int             anthy_gcontext_do_set_personality (AnthyGContext *obj,
105                                                    const gchar  *dict_name);
106 
107 /**
108  * anthy_gcontext_resize_segment:
109  * @nth: nth segment
110  * @resize: size
111  *
112  * Resize the nth segment.
113  */
114 void            anthy_gcontext_resize_segment     (AnthyGContext *obj,
115                                                    int           nth,
116                                                    int           resize);
117 /**
118  * anthy_gcontext_set_string:
119  * @string: A conversion string
120  *
121  * Set a conversion string.
122  */
123 int             anthy_gcontext_set_string         (AnthyGContext *obj,
124                                                    const gchar * string);
125 /**
126  * anthy_gcontext_get_nr_segments:
127  * @returns: The number of the converted segments
128  *
129  * The number of the converted segments
130  */
131 int             anthy_gcontext_get_nr_segments    (AnthyGContext *obj);
132 
133 /**
134  * anthy_gcontext_get_segment:
135  * @nth_seg: Nth segment
136  * @nth_lookup: Nth lookup
137  * @returns: A newly assigned string.
138  *
139  * A newly assigned string with @ntg_seg and @nth_lookup .
140  */
141 gchar *         anthy_gcontext_get_segment        (AnthyGContext *obj,
142                                                    int           nth_seg,
143                                                    int           nth_lookup);
144 
145 /**
146  * anthy_gcontext_commit_segment:
147  * @nth_seg: Nth segment
148  * @nth_lookup: Nth lookup
149  *
150  * Commit a string with @ntg_seg and @nth_lookup.
151  */
152 int             anthy_gcontext_commit_segment     (AnthyGContext *obj,
153                                                    int           nth_seg,
154                                                    int           nth_lookup);
155 
156 /**
157  * anthy_gcontext_get_nr_candidates:
158  * @returns: The number of the candidates
159  *
160  * The number of the candidates
161  */
162 int             anthy_gcontext_get_nr_candidates  (AnthyGContext *obj,
163                                                    int           nth_seg);
164 
165 /**
166  * anthy_gcontext_set_prediction_string:
167  * @string: A prediction string
168  *
169  * Set a prediction string.
170  */
171 int             anthy_gcontext_set_prediction_string
172                                                   (AnthyGContext *obj,
173                                                    const gchar * string);
174 
175 /**
176  * anthy_gcontext_get_nr_predictions:
177  * @returns: The number of the converted segments in the current
178  *        prediction string.
179  *
180  * The number of the converted segments in the current prediction string.
181  */
182 int             anthy_gcontext_get_nr_predictions
183                                                  (AnthyGContext *obj);
184 
185 /**
186  * anthy_gcontext_get_prediction:
187  * @nth_seg: Nth segment
188  * @returns: A newly assigned string.
189  *
190  * A newly assigned string with @ntg_seg .
191  */
192 gchar *         anthy_gcontext_get_prediction    (AnthyGContext *obj,
193                                                   int nth_seg);
194 
195 /**
196  * anthy_gcontext_commit_prediction:
197  * @nth_seg: Nth segment
198  *
199  * Commit a prediction string with @ntg_seg .
200  */
201 int             anthy_gcontext_commit_prediction (AnthyGContext *obj,
202                                                   int nth_seg);
203 
204 /**
205  * anthy_gcontext_set_logger:
206  * @level: Log level
207  *
208  * Set Anthy log level.
209  */
210 void            anthy_gcontext_set_logger        (int level);
211 G_END_DECLS
212 #endif
213