| 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) 2009-2014 Google Inc. All rights reserved. |
| 5 | * Copyright (c) 2017-2018 Takao Fujiwara <takao.fujiwara1@gmail.com> |
| 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_PANEL_SERVICE_H_ |
| 28 | #define __IBUS_PANEL_SERVICE_H_ |
| 29 | |
| 30 | /** |
| 31 | * SECTION: ibuspanelservice |
| 32 | * @short_description: Panel service back-end. |
| 33 | * @stability: Stable |
| 34 | * |
| 35 | * An IBusPanelService is a base class for UI services. |
| 36 | * Developers can "extend" this class for panel UI development. |
| 37 | */ |
| 38 | #include "ibuslookuptable.h" |
| 39 | #include "ibusservice.h" |
| 40 | #include "ibusproplist.h" |
| 41 | #include "ibusxevent.h" |
| 42 | |
| 43 | /* |
| 44 | * Type macros. |
| 45 | */ |
| 46 | |
| 47 | /* define GOBJECT macros */ |
| 48 | #define IBUS_TYPE_PANEL_SERVICE \ |
| 49 | (ibus_panel_service_get_type ()) |
| 50 | #define IBUS_PANEL_SERVICE(obj) \ |
| 51 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_PANEL_SERVICE, IBusPanelService)) |
| 52 | #define IBUS_PANEL_SERVICE_CLASS(klass) \ |
| 53 | (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_PANEL_SERVICE, IBusPanelServiceClass)) |
| 54 | #define IBUS_IS_PANEL_SERVICE(obj) \ |
| 55 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_PANEL_SERVICE)) |
| 56 | #define IBUS_IS_PANEL_SERVICE_CLASS(klass) \ |
| 57 | (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_PANEL_SERVICE)) |
| 58 | #define IBUS_PANEL_SERVICE_GET_CLASS(obj) \ |
| 59 | (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_PANEL_SERVICE, IBusPanelServiceClass)) |
| 60 | |
| 61 | G_BEGIN_DECLS |
| 62 | |
| 63 | typedef struct _IBusPanelService IBusPanelService; |
| 64 | typedef struct _IBusPanelServiceClass IBusPanelServiceClass; |
| 65 | |
| 66 | /** |
| 67 | * IBusPanelService: |
| 68 | * |
| 69 | * An opaque data type representing an IBusPanelService. |
| 70 | */ |
| 71 | struct _IBusPanelService { |
| 72 | IBusService parent; |
| 73 | /* instance members */ |
| 74 | }; |
| 75 | |
| 76 | struct _IBusPanelServiceClass { |
| 77 | IBusServiceClass parent; |
| 78 | |
| 79 | /* class members */ |
| 80 | void (* focus_in) (IBusPanelService *panel, |
| 81 | const gchar |
| 82 | *input_context_path); |
| 83 | void (* focus_out) (IBusPanelService *panel, |
| 84 | const gchar |
| 85 | *input_context_path); |
| 86 | void (* register_properties) (IBusPanelService *panel, |
| 87 | IBusPropList *prop_list); |
| 88 | void (* set_cursor_location) (IBusPanelService *panel, |
| 89 | gint x, |
| 90 | gint y, |
| 91 | gint w, |
| 92 | gint h); |
| 93 | void (* update_auxiliary_text) (IBusPanelService *panel, |
| 94 | IBusText *text, |
| 95 | gboolean visible); |
| 96 | void (* update_lookup_table) (IBusPanelService *panel, |
| 97 | IBusLookupTable *lookup_table, |
| 98 | gboolean visible); |
| 99 | void (* update_preedit_text) (IBusPanelService *panel, |
| 100 | IBusText *text, |
| 101 | guint cursor_pos, |
| 102 | gboolean visible); |
| 103 | void (* update_property) (IBusPanelService *panel, |
| 104 | IBusProperty *prop); |
| 105 | void (* cursor_down_lookup_table) (IBusPanelService *panel); |
| 106 | void (* cursor_up_lookup_table) (IBusPanelService *panel); |
| 107 | void (* hide_auxiliary_text) (IBusPanelService *panel); |
| 108 | void (* hide_language_bar) (IBusPanelService *panel); |
| 109 | void (* hide_lookup_table) (IBusPanelService *panel); |
| 110 | void (* hide_preedit_text) (IBusPanelService *panel); |
| 111 | void (* page_down_lookup_table) (IBusPanelService *panel); |
| 112 | void (* page_up_lookup_table) (IBusPanelService *panel); |
| 113 | void (* reset) (IBusPanelService *panel); |
| 114 | void (* show_auxiliary_text) (IBusPanelService *panel); |
| 115 | void (* show_language_bar) (IBusPanelService *panel); |
| 116 | void (* show_lookup_table) (IBusPanelService *panel); |
| 117 | void (* show_preedit_text) (IBusPanelService *panel); |
| 118 | void (* start_setup) (IBusPanelService *panel); |
| 119 | void (* state_changed) (IBusPanelService *panel); |
| 120 | void (* destroy_context) (IBusPanelService *panel, |
| 121 | const gchar |
| 122 | *input_context_path); |
| 123 | void (* set_content_type) (IBusPanelService *panel, |
| 124 | guint purpose, |
| 125 | guint hints); |
| 126 | void (* set_cursor_location_relative) |
| 127 | (IBusPanelService *panel, |
| 128 | gint x, |
| 129 | gint y, |
| 130 | gint w, |
| 131 | gint h); |
| 132 | void (* panel_extension_received) |
| 133 | (IBusPanelService *panel, |
| 134 | IBusExtensionEvent *event); |
| 135 | gboolean (* process_key_event) |
| 136 | (IBusPanelService *panel, |
| 137 | guint keyval, |
| 138 | guint keycode, |
| 139 | guint state); |
| 140 | void (* commit_text_received) |
| 141 | (IBusPanelService *panel, |
| 142 | IBusText *text); |
| 143 | void (* candidate_clicked_lookup_table) |
| 144 | (IBusPanelService *panel, |
| 145 | guint index, |
| 146 | guint button, |
| 147 | guint state); |
| 148 | |
| 149 | /*< private >*/ |
| 150 | /* padding */ |
| 151 | gpointer pdummy[2]; // We can add 8 pointers without breaking the ABI. |
| 152 | }; |
| 153 | |
| 154 | GType ibus_panel_service_get_type (void); |
| 155 | |
| 156 | /** |
| 157 | * ibus_panel_service_new: |
| 158 | * @connection: An GDBusConnection. |
| 159 | * |
| 160 | * Creates a new #IBusPanelService from an #GDBusConnection. |
| 161 | * |
| 162 | * Returns: A newly allocated #IBusPanelService. |
| 163 | */ |
| 164 | IBusPanelService *ibus_panel_service_new (GDBusConnection *connection); |
| 165 | |
| 166 | /** |
| 167 | * ibus_panel_service_candidate_clicked: |
| 168 | * @panel: An IBusPanelService |
| 169 | * @index: Index in the Lookup table |
| 170 | * @button: GdkEventButton::button (1: left button, etc.) |
| 171 | * @state: GdkEventButton::state (key modifier flags) |
| 172 | * |
| 173 | * Notify that a candidate is clicked |
| 174 | * by sending a "CandidateClicked" to IBus service. |
| 175 | */ |
| 176 | void ibus_panel_service_candidate_clicked (IBusPanelService *panel, |
| 177 | guint index, |
| 178 | guint button, |
| 179 | guint state); |
| 180 | |
| 181 | /** |
| 182 | * ibus_panel_service_cursor_down: |
| 183 | * @panel: An IBusPanelService |
| 184 | * |
| 185 | * Notify that the cursor is down |
| 186 | * by sending a "CursorDown" to IBus service. |
| 187 | */ |
| 188 | void ibus_panel_service_cursor_down (IBusPanelService *panel); |
| 189 | |
| 190 | /** |
| 191 | * ibus_panel_service_cursor_up: |
| 192 | * @panel: An IBusPanelService |
| 193 | * |
| 194 | * Notify that the cursor is up |
| 195 | * by sending a "CursorUp" to IBus service. |
| 196 | */ |
| 197 | void ibus_panel_service_cursor_up (IBusPanelService *panel); |
| 198 | |
| 199 | /** |
| 200 | * ibus_panel_service_page_down: |
| 201 | * @panel: An IBusPanelService |
| 202 | * |
| 203 | * Notify that the page is down |
| 204 | * by sending a "PageDown" to IBus service. |
| 205 | */ |
| 206 | void ibus_panel_service_page_down (IBusPanelService *panel); |
| 207 | |
| 208 | /** |
| 209 | * ibus_panel_service_page_up: |
| 210 | * @panel: An IBusPanelService |
| 211 | * |
| 212 | * Notify that the page is up |
| 213 | * by sending a "PageUp" to IBus service. |
| 214 | */ |
| 215 | void ibus_panel_service_page_up (IBusPanelService *panel); |
| 216 | |
| 217 | /** |
| 218 | * ibus_panel_service_property_activate: |
| 219 | * @panel: An IBusPanelService |
| 220 | * @prop_name: A property name |
| 221 | * @prop_state: State of the property |
| 222 | * |
| 223 | * Notify that a property is active |
| 224 | * by sending a "PropertyActivate" message to IBus service. |
| 225 | */ |
| 226 | void ibus_panel_service_property_activate (IBusPanelService *panel, |
| 227 | const gchar *prop_name, |
| 228 | guint prop_state); |
| 229 | /** |
| 230 | * ibus_panel_service_property_show: |
| 231 | * @panel: An IBusPanelService |
| 232 | * @prop_name: A property name |
| 233 | * |
| 234 | * Notify that a property is shown |
| 235 | * by sending a "ValueChanged" message to IBus service. |
| 236 | */ |
| 237 | void ibus_panel_service_property_show (IBusPanelService *panel, |
| 238 | const gchar *prop_name); |
| 239 | |
| 240 | /** |
| 241 | * ibus_panel_service_property_hide: |
| 242 | * @panel: An IBusPanelService |
| 243 | * @prop_name: A property name |
| 244 | * |
| 245 | * Notify that a property is hidden |
| 246 | * by sending a "ValueChanged" message to IBus service. |
| 247 | */ |
| 248 | void ibus_panel_service_property_hide (IBusPanelService *panel, |
| 249 | const gchar *prop_name); |
| 250 | |
| 251 | /** |
| 252 | * ibus_panel_service_commit_text: |
| 253 | * @panel: An #IBusPanelService |
| 254 | * @text: An #IBusText |
| 255 | * |
| 256 | * Notify that a text is sent |
| 257 | * by sending a "CommitText" message to IBus service. |
| 258 | */ |
| 259 | void ibus_panel_service_commit_text (IBusPanelService *panel, |
| 260 | IBusText *text); |
| 261 | |
| 262 | /** |
| 263 | * ibus_panel_service_panel_extension: |
| 264 | * @panel: An #IBusPanelService |
| 265 | * @event: (transfer full): A #PanelExtensionEvent which is sent to a |
| 266 | * panel extension. |
| 267 | * |
| 268 | * Enable or disable a panel extension with #IBusExtensionEvent. |
| 269 | * Notify that a data is sent |
| 270 | * by sending a "PanelExtension" message to IBus panel extension service. |
| 271 | */ |
| 272 | void ibus_panel_service_panel_extension (IBusPanelService *panel, |
| 273 | IBusExtensionEvent *event); |
| 274 | |
| 275 | /** |
| 276 | * ibus_panel_service_panel_extension_register_keys: |
| 277 | * @panel: An #IBusPanelService |
| 278 | * @first_property_name: the first name of the shortcut keys. This is %NULL |
| 279 | " terminated. |
| 280 | * |
| 281 | * Register shortcut keys to enable panel extensions with #IBusExtensionEvent. |
| 282 | * Notify that a data is sent |
| 283 | * by sending a "PanelExtensionRegisterKeys" message to IBus panel extension |
| 284 | * service. Seems Vala does not support uint[][3] and use |
| 285 | * IBusProcessKeyEventData[]. E.g. |
| 286 | * IBusProcessKeyEventData[] keys = {{ |
| 287 | * IBUS_KEY_e, 0, IBUS_SHIFT_MASK | IBUS_SUPER_MASK }}; |
| 288 | * ibus_panel_service_panel_extension_register_keys(panel, "emoji", keys, NULL); |
| 289 | */ |
| 290 | void ibus_panel_service_panel_extension_register_keys |
| 291 | (IBusPanelService *panel, |
| 292 | const gchar *first_property_name, |
| 293 | ...); |
| 294 | |
| 295 | /** |
| 296 | * ibus_panel_service_update_preedit_text_received: |
| 297 | * @panel: An #IBusPanelService |
| 298 | * @text: Update content. |
| 299 | * @cursor_pos: Current position of cursor |
| 300 | * @visible: Whether the pre-edit buffer is visible. |
| 301 | * |
| 302 | * Notify that the preedit is updated by the panel extension |
| 303 | * |
| 304 | * (Note: The table object will be released, if it is floating. |
| 305 | * If caller want to keep the object, caller should make the object |
| 306 | * sink by g_object_ref_sink.) |
| 307 | */ |
| 308 | void ibus_panel_service_update_preedit_text_received |
| 309 | (IBusPanelService *panel, |
| 310 | IBusText *text, |
| 311 | guint cursor_pos, |
| 312 | gboolean visible); |
| 313 | |
| 314 | /** |
| 315 | * ibus_panel_service_show_preedit_text_received: |
| 316 | * @panel: An IBusPanelService |
| 317 | * |
| 318 | * Notify that the preedit is shown by the panel extension |
| 319 | */ |
| 320 | void ibus_panel_service_show_preedit_text_received |
| 321 | (IBusPanelService *panel); |
| 322 | |
| 323 | /** |
| 324 | * ibus_panel_service_hide_preedit_text_received: |
| 325 | * @panel: An IBusPanelService |
| 326 | * |
| 327 | * Notify that the preedit is hidden by the panel extension |
| 328 | */ |
| 329 | void ibus_panel_service_hide_preedit_text_received |
| 330 | (IBusPanelService *panel); |
| 331 | |
| 332 | /** |
| 333 | * ibus_panel_service_update_auxiliary_text_received: |
| 334 | * @panel: An #IBusPanelService |
| 335 | * @text: An #IBusText |
| 336 | * @visible: Whether the auxilirary text is visible. |
| 337 | * |
| 338 | * Notify that the auxilirary is updated by the panel extension. |
| 339 | * |
| 340 | * (Note: The table object will be released, if it is floating. |
| 341 | * If caller want to keep the object, caller should make the object |
| 342 | * sink by g_object_ref_sink.) |
| 343 | */ |
| 344 | void ibus_panel_service_update_auxiliary_text_received |
| 345 | (IBusPanelService *panel, |
| 346 | IBusText *text, |
| 347 | gboolean visible); |
| 348 | |
| 349 | /** |
| 350 | * ibus_panel_service_update_lookup_table_received: |
| 351 | * @panel: An #IBusPanelService |
| 352 | * @table: An #IBusLookupTable |
| 353 | * @visible: Whether the lookup table is visible. |
| 354 | * |
| 355 | * Notify that the lookup table is updated by the panel extension. |
| 356 | * |
| 357 | * (Note: The table object will be released, if it is floating. |
| 358 | * If caller want to keep the object, caller should make the object |
| 359 | * sink by g_object_ref_sink.) |
| 360 | */ |
| 361 | void ibus_panel_service_update_lookup_table_received |
| 362 | (IBusPanelService *panel, |
| 363 | IBusLookupTable *table, |
| 364 | gboolean visible); |
| 365 | G_END_DECLS |
| 366 | #endif |
| 367 | |