1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 2 /* vim:set et sts=4: */ 3 /* bus - The Input Bus 4 * Copyright (C) 2018-2019 Takao Fujiwara <takao.fujiwara1@gmail.com> 5 * Copyright (C) 2018-2019 Red Hat, Inc. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 20 * USA 21 */ 22 23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION) 24 #error "Only <ibus.h> can be included directly" 25 #endif 26 27 #ifndef __IBUS_UNICODE_H_ 28 #define __IBUS_UNICODE_H_ 29 30 /** 31 * SECTION: ibusunicode 32 * @short_description: unicode utility. 33 * @stability: Unstable 34 * 35 * miscellaneous unicode APIs. 36 */ 37 38 #include <gio/gio.h> 39 #include "ibusserializable.h" 40 41 /* 42 * Type macros. 43 */ 44 /* define GOBJECT macros */ 45 #define IBUS_TYPE_UNICODE_DATA (ibus_unicode_data_get_type ()) 46 #define IBUS_UNICODE_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ 47 IBUS_TYPE_UNICODE_DATA, IBusUnicodeData)) 48 #define IBUS_UNICODE_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ 49 IBUS_TYPE_UNICODE_DATA, \ 50 IBusUnicodeDataClass)) 51 #define IBUS_IS_UNICODE_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ 52 IBUS_TYPE_UNICODE_DATA)) 53 #define IBUS_TYPE_UNICODE_BLOCK (ibus_unicode_block_get_type ()) 54 #define IBUS_UNICODE_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ 55 IBUS_TYPE_UNICODE_BLOCK, \ 56 IBusUnicodeBlock)) 57 #define IBUS_UNICODE_BLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \ 58 IBUS_TYPE_UNICODE_BLOCK, \ 59 IBusUnicodeBlockClass)) 60 #define IBUS_IS_UNICODE_BLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ 61 IBUS_TYPE_UNICODE_BLOCK)) 62 63 64 G_BEGIN_DECLS 65 66 typedef struct _IBusUnicodeData IBusUnicodeData; 67 typedef struct _IBusUnicodeDataPrivate IBusUnicodeDataPrivate; 68 typedef struct _IBusUnicodeDataClass IBusUnicodeDataClass; 69 typedef struct _IBusUnicodeBlock IBusUnicodeBlock; 70 typedef struct _IBusUnicodeBlockPrivate IBusUnicodeBlockPrivate; 71 typedef struct _IBusUnicodeBlockClass IBusUnicodeBlockClass; 72 73 /** 74 * IBusUnicodeDataLoadAsyncFinish: 75 * @data_list: (transfer full) (element-type IBusUnicodeData): 76 * 77 * This callback can receive the list of #IBusUnicodeData. 78 */ 79 typedef void (*IBusUnicodeDataLoadAsyncFinish) (GSList *data_list, 80 gpointer user_data); 81 82 /** 83 * IBusUnicodeData: 84 * 85 * Unicode data likes code, name, alias, block-name. 86 * You can get extended values with g_object_get_properties. 87 */ 88 struct _IBusUnicodeData { 89 IBusSerializable parent; 90 /* instance members */ 91 92 /*< public >*/ 93 /*< private >*/ 94 IBusUnicodeDataPrivate *priv; 95 }; 96 97 struct _IBusUnicodeDataClass { 98 IBusSerializableClass parent; 99 /* class members */ 100 }; 101 102 struct _IBusUnicodeBlock { 103 IBusSerializable parent; 104 /* instance members */ 105 106 /*< public >*/ 107 /*< private >*/ 108 IBusUnicodeBlockPrivate *priv; 109 }; 110 111 struct _IBusUnicodeBlockClass { 112 IBusSerializableClass parent; 113 /* class members */ 114 }; 115 116 GType ibus_unicode_data_get_type (void); 117 GType ibus_unicode_block_get_type (void); 118 119 /** 120 * ibus_unicode_data_new: 121 * @first_property_name: Name of the first property. 122 * @...: the NULL-terminated arguments of the properties and values. 123 * 124 * Creates a new #IBusUnicodeData. 125 * code property is required. e.g. 126 * ibus_unicode_data_new ("code", 0x3042, NULL) 127 * 128 * Returns: A newly allocated #IBusUnicodeData. 129 */ 130 IBusUnicodeData * ibus_unicode_data_new (const gchar *first_property_name, 131 ...); 132 133 /** 134 * ibus_unicode_data_get_code: 135 * @unicode: An #IBusUnicodeData 136 * 137 * Gets the code point in #IBusUnicodeData. 138 * 139 * Returns: code property in #IBusUnicodeData 140 */ 141 gunichar ibus_unicode_data_get_code (IBusUnicodeData *unicode); 142 143 /** 144 * ibus_unicode_data_get_name: 145 * @unicode: An #IBusUnicodeData 146 * 147 * Gets the name in #IBusUnicodeData. It should not be freed. 148 * 149 * Returns: name property in #IBusUnicodeData 150 */ 151 const gchar * ibus_unicode_data_get_name (IBusUnicodeData *unicode); 152 153 /** 154 * ibus_unicode_data_get_alias: 155 * @unicode: An #IBusUnicodeData 156 * 157 * Gets the alias in #IBusUnicodeData. It should not be freed. 158 * 159 * Returns: alias property in #IBusUnicodeData 160 */ 161 const gchar * ibus_unicode_data_get_alias (IBusUnicodeData *unicode); 162 163 /** 164 * ibus_unicode_data_get_block_name: 165 * @unicode: An #IBusUnicodeData 166 * 167 * Gets the block name in #IBusUnicodeData. It should not be freed. 168 * 169 * Returns: block-name property in #IBusUnicodeData 170 */ 171 const gchar * ibus_unicode_data_get_block_name 172 (IBusUnicodeData *unicode); 173 174 /** 175 * ibus_unicode_data_set_block_name: 176 * @unicode: An #IBusUnicodeData 177 * @block_name: A block name 178 * 179 * Sets the block name in #IBusUnicodeData. 180 */ 181 void ibus_unicode_data_set_block_name 182 (IBusUnicodeData *unicode, 183 const gchar *block_name); 184 185 /** 186 * ibus_unicode_data_save: 187 * @path: A path of the saved Unicode data. 188 * @list: (element-type IBusUnicodeData) (transfer none): A list of unicode 189 * data. 190 * 191 * Save the list of #IBusUnicodeData to the cache file. 192 */ 193 void ibus_unicode_data_save (const gchar *path, 194 GSList *list); 195 196 /** 197 * ibus_unicode_data_load: 198 * @path: A path of the saved dictionary file. 199 * @object: (nullable): If the #GObject has "unicode-deserialize-progress" 200 * signal, this function will emit (the number of desrialized 201 * #IBusUnicodeData, * the total number of #IBusUnicodeData) of uint values 202 * with that signal by 100 times. Otherwise %NULL. 203 * 204 * Returns: (element-type IBusUnicodeData) (transfer full): 205 * An #IBusUnicodeData list loaded from the saved cache file. 206 */ 207 GSList * ibus_unicode_data_load (const gchar *path, 208 GObject *object); 209 210 /** 211 * ibus_unicode_data_load_async: 212 * @path: A path of the saved dictionary file. 213 * @object: (nullable): If the #GObject has "unicode-deserialize-progress" 214 * signal, this function will emit (the number of desrialized 215 * #IBusUnicodeData, * the total number of #IBusUnicodeData) of uint values 216 * with that signal by 100 times. Otherwise %NULL. 217 * @cancellable: cancellable. 218 * @callback: (scope notified): IBusUnicodeDataLoadAsyncFinish. 219 * @user_data: User data. 220 * 221 * IBusUnicodeDataLoadAsyncFinish can receive the list of #IBusUnicodeData. 222 */ 223 void ibus_unicode_data_load_async 224 (const gchar *path, 225 GObject *object, 226 GCancellable *cancellable, 227 IBusUnicodeDataLoadAsyncFinish 228 callback, 229 gpointer user_data); 230 231 /** 232 * ibus_unicode_block_new: 233 * @first_property_name: Name of the first property. 234 * @...: the NULL-terminated arguments of the properties and values. 235 * 236 * Creates a new #IBusUnicodeBlock. 237 * block property is required. e.g. 238 * ibus_unicode_block_new ("start", 0x0000, "end", "0x007f", "name", "basic", 239 * NULL) 240 * 241 * Returns: A newly allocated #IBusUnicodeBlock. 242 */ 243 IBusUnicodeBlock *ibus_unicode_block_new (const gchar *first_property_name, 244 ...); 245 246 /** 247 * ibus_unicode_block_get_start: 248 * @block: An #IBusUnicodeData 249 * 250 * Gets the start code point in #IBusUnicodeBlock. 251 * 252 * Returns: start property in #IBusUnicodeBlock 253 */ 254 gunichar ibus_unicode_block_get_start 255 (IBusUnicodeBlock *block); 256 257 /** 258 * ibus_unicode_block_get_end: 259 * @block: An #IBusUnicodeData 260 * 261 * Gets the end code point in #IBusUnicodeBlock. 262 * 263 * Returns: end property in #IBusUnicodeBlock 264 */ 265 gunichar ibus_unicode_block_get_end 266 (IBusUnicodeBlock *block); 267 268 /** 269 * ibus_unicode_block_get_name: 270 * @block: An #IBusUnicodeBlock 271 * 272 * Gets the name in #IBusUnicodeBlock. It should not be freed. 273 * 274 * Returns: name property in #IBusUnicodeBlock 275 */ 276 const gchar * ibus_unicode_block_get_name (IBusUnicodeBlock *block); 277 278 /** 279 * ibus_unicode_block_save: 280 * @path: A path of the saved Unicode block. 281 * @list: (element-type IBusUnicodeBlock) (transfer none): A list of unicode 282 * block. 283 * 284 * Save the list of #IBusUnicodeBlock to the cache file. 285 */ 286 void ibus_unicode_block_save (const gchar *path, 287 GSList *list); 288 289 /** 290 * ibus_unicode_block_load: 291 * @path: A path of the saved dictionary file. 292 * 293 * Returns: (element-type IBusUnicodeBlock) (transfer full): 294 * An #IBusUnicodeBlock list loaded from the saved cache file. 295 */ 296 GSList * ibus_unicode_block_load (const gchar *path); 297 298 G_END_DECLS 299 #endif 300