summaryrefslogtreecommitdiff
path: root/src/ibusunicode.h
blob: 99de94516dcbda64d7bd626c7fee64b2920d237d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* bus - The Input Bus
 * Copyright (C) 2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
 * Copyright (C) 2018 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

#if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
#error "Only <ibus.h> can be included directly"
#endif

#ifndef __IBUS_UNICODE_H_
#define __IBUS_UNICODE_H_

/**
 * SECTION: ibusunicode
 * @short_description: unicode utility.
 * @stability: Unstable
 *
 * miscellaneous unicode APIs.
 */

#include <gio/gio.h>
#include "ibusserializable.h"

/*
 * Type macros.
 */
/* define GOBJECT macros */
#define IBUS_TYPE_UNICODE_DATA       (ibus_unicode_data_get_type ())
#define IBUS_UNICODE_DATA(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
                                      IBUS_TYPE_UNICODE_DATA, IBusUnicodeData))
#define IBUS_UNICODE_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
                                      IBUS_TYPE_UNICODE_DATA, \
                                      IBusUnicodeDataClass))
#define IBUS_IS_UNICODE_DATA(obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
                                      IBUS_TYPE_UNICODE_DATA))
#define IBUS_TYPE_UNICODE_BLOCK      (ibus_unicode_block_get_type ())
#define IBUS_UNICODE_BLOCK(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
                                      IBUS_TYPE_UNICODE_BLOCK, \
                                      IBusUnicodeBlock))
#define IBUS_UNICODE_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
                                      IBUS_TYPE_UNICODE_BLOCK, \
                                      IBusUnicodeBlockClass))
#define IBUS_IS_UNICODE_BLOCK(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
                                      IBUS_TYPE_UNICODE_BLOCK))


G_BEGIN_DECLS

typedef struct _IBusUnicodeData IBusUnicodeData;
typedef struct _IBusUnicodeDataPrivate IBusUnicodeDataPrivate;
typedef struct _IBusUnicodeDataClass IBusUnicodeDataClass;
typedef struct _IBusUnicodeBlock IBusUnicodeBlock;
typedef struct _IBusUnicodeBlockPrivate IBusUnicodeBlockPrivate;
typedef struct _IBusUnicodeBlockClass IBusUnicodeBlockClass;

/**
 * IBusUnicodeDataLoadAsyncFinish:
 * @data_list: (transfer full) (element-type IBusUnicodeData):
 *
 * This callback can receive the list of #IBusUnicodeData.
 */
typedef void (*IBusUnicodeDataLoadAsyncFinish) (GSList  *data_list,
                                                gpointer user_data);

/**
 * IBusUnicodeData:
 *
 * Unicode data likes code, name, alias, block-name.
 * You can get extended values with g_object_get_properties.
 */
struct _IBusUnicodeData {
    IBusSerializable parent;
    /* instance members */

    /*< public >*/
    /*< private >*/
    IBusUnicodeDataPrivate *priv;
};

struct _IBusUnicodeDataClass {
    IBusSerializableClass parent;
    /* class members */
};

struct _IBusUnicodeBlock {
    IBusSerializable parent;
    /* instance members */

    /*< public >*/
    /*< private >*/
    IBusUnicodeBlockPrivate *priv;
};

struct _IBusUnicodeBlockClass {
    IBusSerializableClass parent;
    /* class members */
};

GType           ibus_unicode_data_get_type    (void);
GType           ibus_unicode_block_get_type   (void);

/**
 * ibus_unicode_data_new:
 * @first_property_name: Name of the first property.
 * @...: the NULL-terminated arguments of the properties and values.
 *
 * Creates a new #IBusUnicodeData.
 * code property is required. e.g.
 * ibus_unicode_data_new ("code", 0x3042, NULL)
 *
 * Returns: A newly allocated #IBusUnicodeData.
 */
IBusUnicodeData * ibus_unicode_data_new       (const gchar *first_property_name,
                                               ...);

/**
 * ibus_unicode_data_get_code:
 * @unicode: An #IBusUnicodeData
 *
 * Gets the code point in #IBusUnicodeData.
 *
 * Returns: code property in #IBusUnicodeData
 */
gunichar          ibus_unicode_data_get_code  (IBusUnicodeData    *unicode);

/**
 * ibus_unicode_data_get_name:
 * @unicode: An #IBusUnicodeData
 *
 * Gets the name in #IBusUnicodeData. It should not be freed.
 *
 * Returns: name property in #IBusUnicodeData
 */
const gchar *     ibus_unicode_data_get_name  (IBusUnicodeData    *unicode);

/**
 * ibus_unicode_data_get_alias:
 * @unicode: An #IBusUnicodeData
 *
 * Gets the alias in #IBusUnicodeData. It should not be freed.
 *
 * Returns: alias property in #IBusUnicodeData
 */
const gchar *     ibus_unicode_data_get_alias (IBusUnicodeData    *unicode);

/**
 * ibus_unicode_data_get_block_name:
 * @unicode: An #IBusUnicodeData
 *
 * Gets the block name in #IBusUnicodeData. It should not be freed.
 *
 * Returns: block-name property in #IBusUnicodeData
 */
const gchar *     ibus_unicode_data_get_block_name
                                              (IBusUnicodeData    *unicode);

/**
 * ibus_unicode_data_set_block_name:
 * @unicode: An #IBusUnicodeData
 * @block_name: A block name
 *
 * Sets the block name in #IBusUnicodeData.
 */
void              ibus_unicode_data_set_block_name
                                              (IBusUnicodeData    *unicode,
                                               const gchar        *block_name);

/**
 * ibus_unicode_data_save:
 * @path: A path of the saved Unicode data.
 * @list: (element-type IBusUnicodeData) (transfer none): A list of unicode
 *  data.
 *
 * Save the list of #IBusUnicodeData to the cache file.
 */
void              ibus_unicode_data_save      (const gchar        *path,
                                               GSList             *list);

/**
 * ibus_unicode_data_load:
 * @path: A path of the saved dictionary file.
 * @object: (nullable): If the #GObject has "unicode-deserialize-progress"
 *    signal, this function will emit (the number of desrialized
 *    #IBusUnicodeData, * the total number of #IBusUnicodeData) of uint values
 *    with that signal by 100 times. Otherwise %NULL.
 *
 * Returns: (element-type IBusUnicodeData) (transfer container):
 * An #IBusUnicodeData list loaded from the saved cache file.
 */
GSList *          ibus_unicode_data_load      (const gchar        *path,
                                               GObject            *object);

/**
 * ibus_unicode_data_load_async:
 * @path: A path of the saved dictionary file.
 * @object: (nullable): If the #GObject has "unicode-deserialize-progress"
 *    signal, this function will emit (the number of desrialized
 *    #IBusUnicodeData, * the total number of #IBusUnicodeData) of uint values
 *    with that signal by 100 times. Otherwise %NULL.
 * @cancellable: cancellable.
 * @callback: (scope notified): IBusUnicodeDataLoadAsyncFinish.
 * @user_data: User data.
 *
 * IBusUnicodeDataLoadAsyncFinish can receive the list of #IBusUnicodeData.
 */
void              ibus_unicode_data_load_async
                                              (const gchar        *path,
                                               GObject            *object,
                                               GCancellable       *cancellable,
                                               IBusUnicodeDataLoadAsyncFinish
                                                                   callback,
                                               gpointer            user_data);

/**
 * ibus_unicode_block_new:
 * @first_property_name: Name of the first property.
 * @...: the NULL-terminated arguments of the properties and values.
 *
 * Creates a new #IBusUnicodeBlock.
 * block property is required. e.g.
 * ibus_unicode_block_new ("start", 0x0000, "end", "0x007f", "name", "basic",
 * NULL)
 *
 * Returns: A newly allocated #IBusUnicodeBlock.
 */
IBusUnicodeBlock *ibus_unicode_block_new      (const gchar *first_property_name,
                                               ...);

/**
 * ibus_unicode_block_get_start:
 * @block: An #IBusUnicodeData
 *
 * Gets the start code point in #IBusUnicodeBlock.
 *
 * Returns: start property in #IBusUnicodeBlock
 */
gunichar          ibus_unicode_block_get_start
                                              (IBusUnicodeBlock   *block);

/**
 * ibus_unicode_block_get_end:
 * @block: An #IBusUnicodeData
 *
 * Gets the end code point in #IBusUnicodeBlock.
 *
 * Returns: end property in #IBusUnicodeBlock
 */
gunichar          ibus_unicode_block_get_end
                                              (IBusUnicodeBlock   *block);

/**
 * ibus_unicode_block_get_name:
 * @block: An #IBusUnicodeBlock
 *
 * Gets the name in #IBusUnicodeBlock. It should not be freed.
 *
 * Returns: name property in #IBusUnicodeBlock
 */
const gchar *     ibus_unicode_block_get_name (IBusUnicodeBlock   *block);

/**
 * ibus_unicode_block_save:
 * @path: A path of the saved Unicode block.
 * @list: (element-type IBusUnicodeBlock) (transfer none): A list of unicode
 *  block.
 *
 * Save the list of #IBusUnicodeBlock to the cache file.
 */
void              ibus_unicode_block_save     (const gchar        *path,
                                               GSList             *list);

/**
 * ibus_unicode_block_load:
 * @path: A path of the saved dictionary file.
 *
 * Returns: (element-type IBusUnicodeBlock) (transfer container):
 * An #IBusUnicodeBlock list loaded from the saved cache file.
 */
GSList *          ibus_unicode_block_load     (const gchar        *path);

G_END_DECLS
#endif