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) 2017 Takao Fujiwara <takao.fujiwara1@gmail.com>
5 * Copyright (C) 2017 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_EMOJI_H_
28#define __IBUS_EMOJI_H_
29
30/**
31 * SECTION: ibusemoji
32 * @short_description: emoji utility.
33 * @stability: Unstable
34 *
35 * miscellaneous emoji APIs.
36 */
37
38#include "ibusserializable.h"
39
40/*
41 * Type macros.
42 */
43/* define GOBJECT macros */
44#define IBUS_TYPE_EMOJI_DATA (ibus_emoji_data_get_type ())
45#define IBUS_EMOJI_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
46 IBUS_TYPE_EMOJI_DATA, IBusEmojiData))
47#define IBUS_EMOJI_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
48 IBUS_TYPE_EMOJI_DATA, IBusEmojiDataClass))
49#define IBUS_IS_EMOJI_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
50 IBUS_TYPE_EMOJI_DATA))
51
52
53G_BEGIN_DECLS
54
55typedef struct _IBusEmojiData IBusEmojiData;
56typedef struct _IBusEmojiDataPrivate IBusEmojiDataPrivate;
57typedef struct _IBusEmojiDataClass IBusEmojiDataClass;
58
59/**
60 * IBusEmojiData:
61 *
62 * Emoji data likes emoji unicode, annotations, description, category.
63 * You can get extended values with g_object_get_properties.
64 */
65struct _IBusEmojiData {
66 IBusSerializable parent;
67 /* instance members */
68
69 /*< public >*/
70 /*< private >*/
71 IBusEmojiDataPrivate *priv;
72};
73
74struct _IBusEmojiDataClass {
75 IBusSerializableClass parent;
76 /* class members */
77};
78
79GType ibus_emoji_data_get_type (void);
80
81/**
82 * ibus_emoji_data_new:
83 * @first_property_name: Name of the first property.
84 * @...: the NULL-terminated arguments of the properties and values.
85 *
86 * Creates a new #IBusEmojiData.
87 * emoji property is required. e.g.
88 * ibus_emoji_data_new ("emoji", "😁", NULL)
89 *
90 * Returns: A newly allocated #IBusEmojiData.
91 */
92IBusEmojiData * ibus_emoji_data_new (const gchar *first_property_name,
93 ...);
94
95/**
96 * ibus_emoji_data_get_emoji:
97 * @emoji : An #IBusEmojiData
98 *
99 * Gets the emoji character in #IBusEmojiData. It should not be freed.
100 *
101 * Returns: emoji property in #IBusEmojiData
102 */
103const gchar * ibus_emoji_data_get_emoji (IBusEmojiData *emoji);
104
105/**
106 * ibus_emoji_data_get_annotations:
107 * @emoji : An #IBusEmojiData
108 *
109 * Gets the annotation list in #IBusEmojiData. It should not be freed.
110 *
111 * Returns: (transfer none) (element-type utf8):
112 * annotation list property in #IBusEmojiData
113 */
114GSList * ibus_emoji_data_get_annotations (IBusEmojiData *emoji);
115
116/**
117 * ibus_emoji_data_set_annotations:
118 * @emoji : An #IBusEmojiData
119 * @annotations: (transfer full) (element-type utf8): List of emoji annotations
120 *
121 * Sets the annotation list in #IBusEmojiData.
122 */
123void ibus_emoji_data_set_annotations (IBusEmojiData *emoji,
124 GSList *annotations);
125
126/**
127 * ibus_emoji_data_get_description:
128 * @emoji : An #IBusEmojiData
129 *
130 * Gets the emoji description in #IBusEmojiData. It should not be freed.
131 *
132 * Returns: description property in #IBusEmojiData
133 */
134const gchar * ibus_emoji_data_get_description (IBusEmojiData *emoji);
135
136/**
137 * ibus_emoji_data_set_description:
138 * @emoji : An #IBusEmojiData
139 * @description: An emoji description
140 *
141 * Sets the description in #IBusEmojiData.
142 */
143void ibus_emoji_data_set_description (IBusEmojiData *emoji,
144 const gchar *description);
145
146
147/**
148 * ibus_emoji_data_get_category:
149 * @emoji : An #IBusEmojiData
150 *
151 * Gets the emoji category in #IBusEmojiData. It should not be freed.
152 *
153 * Returns: category property in #IBusEmojiData
154 */
155const gchar * ibus_emoji_data_get_category (IBusEmojiData *emoji);
156
157
158/**
159 * ibus_emoji_dict_save:
160 * @path: A path of the saved dictionary file.
161 * @dict: (element-type utf8 gpointer) (transfer none): An Emoji dictionary
162 *
163 * Saves the Emoji dictionary to the cache file.
164 * Recommend to use ibus_emoji_data_save() instead becase GSList in
165 * GHashTable does not work with Gir and Vala.
166 * Calls ibus_emoji_data_save() internally. The format of the hash table
167 * changed and now is { emoji character, #IBusEmojiData object }.
168 */
169void ibus_emoji_dict_save (const gchar *path,
170 GHashTable *dict);
171/**
172 * ibus_emoji_dict_load:
173 * @path: A path of the saved dictionary file.
174 *
175 * Returns: (element-type utf8 gpointer) (transfer none): An Emoji dictionary
176 * file loaded from the saved cache file.
177 *
178 * A hash table of { emoji character, #IBusEmojiData object } is loaded
179 * from the saved cache file.
180 * Recommend to use ibus_emoji_data_load() instead becase GSList in
181 * GHashTable does not work with Gir and Vala.
182 * Calls ibus_emoji_data_load() internally.
183 */
184GHashTable * ibus_emoji_dict_load (const gchar *path);
185
186/**
187 * ibus_emoji_dict_lookup:
188 * @dict: (element-type utf8 IBusEmojiData) (transfer full): An Emoji dictionary
189 * @emoji: an emoji character
190 *
191 * Returns: (transfer none): An #IBusEmojiData of @emoji.
192 * This API was prepared for the old dict foramat with Gir and Vala
193 * but no longer needed.
194 * Use ibus_emoji_data_load() instead.
195 */
196IBusEmojiData * ibus_emoji_dict_lookup (GHashTable *dict,
197 const gchar *emoji);
198/**
199 * ibus_emoji_data_save:
200 * @path: A path of the saved emoji data.
201 * @list: (element-type IBusEmojiData) (transfer none): A list of emoji data.
202 *
203 * Save the list of #IBusEmojiData to the cache file.
204 */
205void ibus_emoji_data_save (const gchar *path,
206 GSList *list);
207
208/**
209 * ibus_emoji_data_load:
210 * @path: A path of the saved dictionary file.
211 *
212 * Returns: (element-type IBusEmojiData) (transfer container):
213 * An #IBusEmojiData list loaded from the saved cache file.
214 */
215GSList * ibus_emoji_data_load (const gchar *path);
216
217G_END_DECLS
218#endif
219