1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* IBus - The Input Bus
4 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2008-2010 Red Hat, Inc.
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.
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.
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
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
28 * SECTION: ibuslookuptable
29 * @short_description: Candidate word/phrase lookup table.
31 * @see_also: #IBusEngine
33 * An IBusLookuptable stores the candidate words or phrases for users to choose from.
35 * Use ibus_engine_update_lookup_table(), ibus_engine_show_lookup_table(),
36 * and ibus_engine_hide_lookup_table() to update, show and hide the lookup
39 #ifndef __IBUS_LOOKUP_TABLE_H_
40 #define __IBUS_LOOKUP_TABLE_H_
42 #include "ibusserializable.h"
48 /* define IBusLookupTable macros */
49 #define IBUS_TYPE_LOOKUP_TABLE \
50 (ibus_lookup_table_get_type ())
51 #define IBUS_LOOKUP_TABLE(obj) \
52 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_LOOKUP_TABLE, IBusLookupTable))
53 #define IBUS_LOOKUP_TABLE_CLASS(klass) \
54 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_LOOKUP_TABLE, IBusLookupTableClass))
55 #define IBUS_IS_LOOKUP_TABLE(obj) \
56 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_LOOKUP_TABLE))
57 #define IBUS_IS_LOOKUP_TABLE_CLASS(klass) \
58 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_LOOKUP_TABLE))
59 #define IBUS_LOOKUP_TABLE_GET_CLASS(obj) \
60 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_LOOKUP_TABLE, IBusLookupTableClass))
65 typedef struct _IBusLookupTable IBusLookupTable;
66 typedef struct _IBusLookupTableClass IBusLookupTableClass;
70 * @page_size: number of candidate shown per page.
71 * @cursor_pos: position index of cursor.
72 * @cursor_visible: whether the cursor is visible.
73 * @round: TRUE for lookup table wrap around.
74 * @orientation: orientation of the table.
75 * @candidates: Candidate words/phrases.
76 * @labels: Candidate labels which identify individual candidates in the same page. Default is 1, 2, 3, 4 ...
78 * An IBusLookuptable stores the candidate words or phrases for users to choose from.
79 * Note that some input methods allow you to select candidate by pressing non-numeric
80 * keys such as "asdfghjkl;".
81 * Developers of these input methods should change the labels with
82 * ibus_lookup_table_append_label().
84 struct _IBusLookupTable {
85 IBusSerializable parent;
90 gboolean cursor_visible;
98 struct _IBusLookupTableClass {
99 IBusSerializableClass parent;
103 GType ibus_lookup_table_get_type (void);
106 * ibus_lookup_table_new:
107 * @page_size: number of candidate shown per page, the max value is 16.
108 * @cursor_pos: position index of cursor.
109 * @cursor_visible: whether the cursor is visible.
110 * @round: TRUE for lookup table wrap around.
111 * @returns: A newly allocated IBusLookupTable.
113 * New a IBusLookupTable.
115 IBusLookupTable *ibus_lookup_table_new (guint page_size,
117 gboolean cursor_visible,
121 * ibus_lookup_table_append_candidate:
122 * @table: An IBusLookupTable.
123 * @text: candidate word/phrase to be appended (in IBusText format).
125 * Append a candidate word/phrase to IBusLookupTable, and increase reference.
127 void ibus_lookup_table_append_candidate
128 (IBusLookupTable *table,
132 * ibus_lookup_table_get_number_of_candidates:
133 * @table: An IBusLookupTable.
134 * @returns: The number of candidates in the table
136 * Return the number of candidate in the table.
138 guint ibus_lookup_table_get_number_of_candidates
139 (IBusLookupTable *table);
142 * ibus_lookup_table_get_candidate:
143 * @table: An IBusLookupTable.
144 * @index: Index in the Lookup table.
145 * @returns: (transfer none): IBusText at the given index; NULL if no such IBusText.
147 * Return IBusText at the given index. Borrowed reference.
149 IBusText *ibus_lookup_table_get_candidate
150 (IBusLookupTable *table,
154 * ibus_lookup_table_append_label:
155 * @table: An IBusLookupTable.
156 * @text: A candidate label to be appended (in IBusText format).
158 * Append a candidate word/phrase to IBusLookupTable, and increase reference.
159 * This function is needed if the input method select candidate with
160 * non-numeric keys such as "asdfghjkl;".
162 void ibus_lookup_table_append_label
163 (IBusLookupTable *table,
167 * ibus_lookup_table_set_label:
168 * @table: An IBusLookupTable.
169 * @index: Intex in the Lookup table.
170 * @text: A candidate label to be appended (in IBusText format).
172 * Append a candidate word/phrase to IBusLookupTable, and increase reference.
173 * This function is needed if the input method select candidate with
174 * non-numeric keys such as "asdfghjkl;".
176 void ibus_lookup_table_set_label
177 (IBusLookupTable *table,
182 * ibus_lookup_table_get_label:
183 * @table: An IBusLookupTable.
184 * @index: Index in the Lookup table.
185 * @returns: (transfer none): IBusText at the given index; NULL if no such IBusText.
187 * Return IBusText at the given index. Borrowed reference.
189 IBusText *ibus_lookup_table_get_label
190 (IBusLookupTable *table,
195 * ibus_lookup_table_set_cursor_pos:
196 * @table: An IBusLookupTable.
197 * @cursor_pos: The position of cursor.
199 * Set the cursor position of IBusLookupTable.
201 void ibus_lookup_table_set_cursor_pos
202 (IBusLookupTable *table,
206 * ibus_lookup_table_get_cursor_pos:
207 * @table: An IBusLookupTable.
208 * @returns: The position of cursor.
210 * Get the cursor position of IBusLookupTable.
212 guint ibus_lookup_table_get_cursor_pos
213 (IBusLookupTable *table);
216 * ibus_lookup_table_set_cursor_visible:
217 * @table: An IBusLookupTable.
218 * @visible: Whether to make the cursor of @table visible.
220 * Set whether to make the cursor of an IBusLookupTable visible or not.
222 void ibus_lookup_table_set_cursor_visible
223 (IBusLookupTable *table,
227 * ibus_lookup_table_is_cursor_visible:
228 * @table: An IBusLookupTable.
229 * @returns: Whether the cursor of @table is visible.
231 * Returns whether the cursor of an IBusLookupTable is visible.
233 gboolean ibus_lookup_table_is_cursor_visible
234 (IBusLookupTable *table);
237 * ibus_lookup_table_get_cursor_in_page:
238 * @table: An IBusLookupTable.
239 * @returns: The position of cursor in current page.
241 * Get the cursor position in current page of IBusLookupTable.
243 guint ibus_lookup_table_get_cursor_in_page
244 (IBusLookupTable *table);
247 * ibus_lookup_table_set_page_size:
248 * @table: An IBusLookupTable.
249 * @page_size: number of candidate shown per page.
251 * Set the number of candidate shown per page.
253 void ibus_lookup_table_set_page_size
254 (IBusLookupTable *table,
257 * ibus_lookup_table_get_page_size:
258 * @table: An IBusLookupTable.
259 * @returns: Page size, i.e., number of candidate shown per page.
261 * Get the number of candidate shown per page.
263 guint ibus_lookup_table_get_page_size
264 (IBusLookupTable *table);
267 * ibus_lookup_table_set_round:
268 * @table: An IBusLookupTable.
269 * @round: Whether to make @table round.
271 * Set whether to make the IBusLookupTable round or not.
273 void ibus_lookup_table_set_round
274 (IBusLookupTable *table,
277 * ibus_lookup_table_is_round:
278 * @table: An IBusLookupTable.
279 * @returns: Whether the @table is round.
281 * Returns whether the IBusLookupTable is round.
283 gboolean ibus_lookup_table_is_round (IBusLookupTable *table);
286 * ibus_lookup_table_set_orientation:
287 * @table: An IBusLookupTable.
290 * Set the orientation.
292 void ibus_lookup_table_set_orientation
293 (IBusLookupTable *table,
297 * ibus_lookup_table_get_orientation:
298 * @table: An IBusLookupTable.
299 * @returns: The orientation of the @table.
301 * Returns the orientation of the IBusLookupTable.
303 gint ibus_lookup_table_get_orientation
304 (IBusLookupTable *table);
308 * ibus_lookup_table_clear:
309 * @table: An IBusLookupTable.
311 * Clear and remove all candidate from an IBusLookupTable.
313 void ibus_lookup_table_clear (IBusLookupTable *table);
316 * ibus_lookup_table_page_up:
317 * @table: An IBusLookupTable.
318 * @returns: TRUE if succeed.
320 * Go to previous page of an IBusLookupTable.
322 * It returns FALSE if it is already at the first page,
323 * unless <code>table>-round==TRUE</code>, where it will go
326 gboolean ibus_lookup_table_page_up (IBusLookupTable *table);
329 * ibus_lookup_table_page_down:
330 * @table: An IBusLookupTable.
331 * @returns: TRUE if succeed.
333 * Go to next page of an IBusLookupTable.
335 * It returns FALSE if it is already at the last page,
336 * unless <code>table>-round==TRUE</code>, where it will go
339 gboolean ibus_lookup_table_page_down(IBusLookupTable *table);
342 * ibus_lookup_table_cursor_up:
343 * @table: An IBusLookupTable.
344 * @returns: TRUE if succeed.
346 * Go to previous candidate of an IBusLookupTable.
348 * It returns FALSE if it is already at the first candidate,
349 * unless <code>table>-round==TRUE</code>, where it will go
350 * to the last candidate.
352 gboolean ibus_lookup_table_cursor_up(IBusLookupTable *table);
355 * ibus_lookup_table_cursor_down:
356 * @table: An IBusLookupTable.
357 * @returns: TRUE if succeed.
359 * Go to next candidate of an IBusLookupTable.
361 * It returns FALSE if it is already at the last candidate,
362 * unless <code>table>-round==TRUE</code>, where it will go
363 * to the first candidate.
365 gboolean ibus_lookup_table_cursor_down
366 (IBusLookupTable *table);