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, Google Inc. All rights reserved.
5 * Copyright (C) 2010 Peng Huang <shawn.p.huang@gmail.com>
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 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
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
22 #include "ibusshare.h"
23 #include "ibuspanelservice.h"
24 #include "ibusmarshalers.h"
25 #include "ibusinternal.h"
29 UPDATE_AUXILIARY_TEXT,
36 CURSOR_UP_LOOKUP_TABLE,
37 CURSOR_DOWN_LOOKUP_TABLE,
43 PAGE_DOWN_LOOKUP_TABLE,
58 static guint panel_signals[LAST_SIGNAL] = { 0 };
60 /* functions prototype */
61 static void ibus_panel_service_set_property (IBusPanelService *panel,
65 static void ibus_panel_service_get_property (IBusPanelService *panel,
69 static void ibus_panel_service_real_destroy (IBusPanelService *panel);
70 static void ibus_panel_service_service_method_call (IBusService *service,
71 GDBusConnection *connection,
73 const gchar *object_path,
74 const gchar *interface_name,
75 const gchar *method_name,
77 GDBusMethodInvocation *invocation);
78 static GVariant *ibus_panel_service_service_get_property (IBusService *service,
79 GDBusConnection *connection,
81 const gchar *object_path,
82 const gchar *interface_name,
83 const gchar *property_name,
85 static gboolean ibus_panel_service_service_set_property (IBusService *service,
86 GDBusConnection *connection,
88 const gchar *object_path,
89 const gchar *interface_name,
90 const gchar *property_name,
93 static void ibus_panel_service_not_implemented (IBusPanelService *panel);
94 static void ibus_panel_service_focus_in (IBusPanelService *panel,
95 const gchar *input_context_path);
96 static void ibus_panel_service_focus_out (IBusPanelService *panel,
97 const gchar *input_context_path);
98 static void ibus_panel_service_register_properties (IBusPanelService *panel,
99 IBusPropList *prop_list);
100 static void ibus_panel_service_set_cursor_location (IBusPanelService *panel,
105 static void ibus_panel_service_update_auxiliary_text (IBusPanelService *panel,
108 static void ibus_panel_service_update_lookup_table (IBusPanelService *panel,
109 IBusLookupTable *lookup_table,
111 static void ibus_panel_service_update_preedit_text (IBusPanelService *panel,
115 static void ibus_panel_service_update_property (IBusPanelService *panel,
118 G_DEFINE_TYPE (IBusPanelService, ibus_panel_service, IBUS_TYPE_SERVICE)
120 static const gchar introspection_xml[] =
122 " <interface name='org.freedesktop.IBus.Panel'>"
124 " <method name='UpdatePreeditText'>"
125 " <arg direction='in' type='v' name='text' />"
126 " <arg direction='in' type='u' name='cursor_pos' />"
127 " <arg direction='in' type='b' name='visible' />"
129 " <method name='ShowPreeditText' />"
130 " <method name='HidePreeditText' />"
131 " <method name='UpdateAuxiliaryText'>"
132 " <arg direction='in' type='v' name='text' />"
133 " <arg direction='in' type='b' name='visible' />"
135 " <method name='ShowAuxiliaryText' />"
136 " <method name='HideAuxiliaryText' />"
137 " <method name='UpdateLookupTable'>"
138 " <arg direction='in' type='v' name='table' />"
139 " <arg direction='in' type='b' name='visible' />"
141 " <method name='ShowLookupTable' />"
142 " <method name='HideLookupTable' />"
143 " <method name='CursorUpLookupTable' />"
144 " <method name='CursorDownLookupTable' />"
145 " <method name='PageUpLookupTable' />"
146 " <method name='PageDownLookupTable' />"
147 " <method name='RegisterProperties'>"
148 " <arg direction='in' type='v' name='props' />"
150 " <method name='UpdateProperty'>"
151 " <arg direction='in' type='v' name='prop' />"
153 " <method name='FocusIn'>"
154 " <arg direction='in' type='o' name='ic' />"
156 " <method name='FocusOut'>"
157 " <arg direction='in' type='o' name='ic' />"
159 " <method name='SetCursorLocation'>"
160 " <arg direction='in' type='i' name='x' />"
161 " <arg direction='in' type='i' name='y' />"
162 " <arg direction='in' type='i' name='w' />"
163 " <arg direction='in' type='i' name='h' />"
165 " <method name='Reset' />"
166 " <method name='StartSetup' />"
167 " <method name='StateChanged' />"
168 " <method name='HideLanguageBar' />"
169 " <method name='ShowLanguageBar' />"
171 " <signal name='CursorUp' />"
172 " <signal name='CursorDown' />"
173 " <signal name='PageUp' />"
174 " <signal name='PageDown' />"
175 " <signal name='PropertyActivate'>"
176 " <arg type='s' name='prop_name' />"
177 " <arg type='i' name='prop_state' />"
179 " <signal name='PropertyShow'>"
180 " <arg type='s' name='prop_name' />"
182 " <signal name='PropertyHide'>"
183 " <arg type='s' name='prop_name' />"
185 " <signal name='CandidateClicked'>"
186 " <arg type='u' name='index' />"
187 " <arg type='u' name='button' />"
188 " <arg type='u' name='state' />"
194 ibus_panel_service_class_init (IBusPanelServiceClass *class)
196 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
197 ibus_panel_service_parent_class = IBUS_SERVICE_CLASS (g_type_class_peek_parent (class));
199 gobject_class->set_property = (GObjectSetPropertyFunc) ibus_panel_service_set_property;
200 gobject_class->get_property = (GObjectGetPropertyFunc) ibus_panel_service_get_property;
202 IBUS_OBJECT_CLASS (gobject_class)->destroy = (IBusObjectDestroyFunc) ibus_panel_service_real_destroy;
204 IBUS_SERVICE_CLASS (class)->service_method_call = ibus_panel_service_service_method_call;
205 IBUS_SERVICE_CLASS (class)->service_get_property = ibus_panel_service_service_get_property;
206 IBUS_SERVICE_CLASS (class)->service_set_property = ibus_panel_service_service_set_property;
208 ibus_service_class_add_interfaces (IBUS_SERVICE_CLASS (class), introspection_xml);
210 class->focus_in = ibus_panel_service_focus_in;
211 class->focus_out = ibus_panel_service_focus_out;
212 class->register_properties = ibus_panel_service_register_properties;
213 class->set_cursor_location = ibus_panel_service_set_cursor_location;
214 class->update_lookup_table = ibus_panel_service_update_lookup_table;
215 class->update_auxiliary_text = ibus_panel_service_update_auxiliary_text;
216 class->update_preedit_text = ibus_panel_service_update_preedit_text;
217 class->update_property = ibus_panel_service_update_property;
219 class->cursor_down_lookup_table = ibus_panel_service_not_implemented;
220 class->cursor_up_lookup_table = ibus_panel_service_not_implemented;
221 class->hide_auxiliary_text = ibus_panel_service_not_implemented;
222 class->hide_language_bar = ibus_panel_service_not_implemented;
223 class->hide_lookup_table = ibus_panel_service_not_implemented;
224 class->hide_preedit_text = ibus_panel_service_not_implemented;
225 class->page_down_lookup_table = ibus_panel_service_not_implemented;
226 class->page_up_lookup_table = ibus_panel_service_not_implemented;
227 class->reset = ibus_panel_service_not_implemented;
228 class->show_auxiliary_text = ibus_panel_service_not_implemented;
229 class->show_language_bar = ibus_panel_service_not_implemented;
230 class->show_lookup_table = ibus_panel_service_not_implemented;
231 class->show_preedit_text = ibus_panel_service_not_implemented;
232 class->start_setup = ibus_panel_service_not_implemented;
233 class->state_changed = ibus_panel_service_not_implemented;
235 /* install signals */
237 * IBusPanelService::update-preedit-text:
238 * @text: A preedit text to be updated.
239 * @cursor_pos: The cursor position of the text.
240 * @visible: Whether the update is visible.
242 * Emitted when the client application get the update-preedit-text.
243 * Implement the member function update_preedit_text() in extended class to receive this signal.
245 * <note><para>Argument @user_data is ignored in this function.</para></note>
247 panel_signals[UPDATE_PREEDIT_TEXT] =
248 g_signal_new (I_("update-preedit-text"),
249 G_TYPE_FROM_CLASS (gobject_class),
251 G_STRUCT_OFFSET (IBusPanelServiceClass, update_preedit_text),
253 _ibus_marshal_VOID__OBJECT_UINT_BOOLEAN,
261 * IBusPanelService::update-auxiliary-text:
262 * @text: A preedit text to be updated.
263 * @visible: Whether the update is visible.
265 * Emitted when the client application get the update-auxiliary-text.
266 * Implement the member function update_auxiliary_text() in extended class to receive this signal.
268 * <note><para>Argument @user_data is ignored in this function.</para></note>
270 panel_signals[UPDATE_AUXILIARY_TEXT] =
271 g_signal_new (I_("update-auxiliary-text"),
272 G_TYPE_FROM_CLASS (gobject_class),
274 G_STRUCT_OFFSET (IBusPanelServiceClass, update_auxiliary_text),
276 _ibus_marshal_VOID__OBJECT_BOOLEAN,
283 * IBusPanelService::update-lookup-table:
284 * @lookup_table: A lookup table to be updated.
285 * @visible: Whether the update is visible.
287 * Emitted when the client application get the update-lookup-table.
288 * Implement the member function update_lookup_table() in extended class to receive this signal.
290 * <note><para>Argument @user_data is ignored in this function.</para></note>
292 panel_signals[UPDATE_LOOKUP_TABLE] =
293 g_signal_new (I_("update-lookup-table"),
294 G_TYPE_FROM_CLASS (gobject_class),
296 G_STRUCT_OFFSET (IBusPanelServiceClass, update_lookup_table),
298 _ibus_marshal_VOID__OBJECT_BOOLEAN,
301 IBUS_TYPE_LOOKUP_TABLE,
305 * IBusPanelService::focus-in:
306 * @input_context_path: Object path of InputContext.
308 * Emitted when the client application get the focus-in.
309 * Implement the member function focus_in() in extended class to receive this signal.
311 * <note><para>Argument @user_data is ignored in this function.</para></note>
313 panel_signals[FOCUS_IN] =
314 g_signal_new (I_("focus-in"),
315 G_TYPE_FROM_CLASS (gobject_class),
317 G_STRUCT_OFFSET (IBusPanelServiceClass, focus_in),
319 _ibus_marshal_VOID__STRING,
325 * IBusPanelService::focus-out:
326 * @input_context_path: Object path of InputContext.
328 * Emitted when the client application get the focus-out.
329 * Implement the member function focus_out() in extended class to receive this signal.
331 * <note><para>Argument @user_data is ignored in this function.</para></note>
333 panel_signals[FOCUS_OUT] =
334 g_signal_new (I_("focus-out"),
335 G_TYPE_FROM_CLASS (gobject_class),
337 G_STRUCT_OFFSET (IBusPanelServiceClass, focus_out),
339 _ibus_marshal_VOID__STRING,
345 * IBusPanelService::register-properties:
346 * @prop_list: An IBusPropList that contains properties.
348 * Emitted when the client application get the register-properties.
349 * Implement the member function register_properties() in extended class to receive this signal.
351 * <note><para>Argument @user_data is ignored in this function.</para></note>
353 panel_signals[REGISTER_PROPERTIES] =
354 g_signal_new (I_("register-properties"),
355 G_TYPE_FROM_CLASS (gobject_class),
357 G_STRUCT_OFFSET (IBusPanelServiceClass, register_properties),
359 _ibus_marshal_VOID__OBJECT,
362 IBUS_TYPE_PROP_LIST);
365 * IBusPanelService::update-property:
366 * @prop: The IBusProperty to be updated.
368 * Emitted when the client application get the update-property.
369 * Implement the member function update_property() in extended class to receive this signal.
371 * <note><para>Argument @user_data is ignored in this function.</para></note>
373 panel_signals[UPDATE_PROPERTY] =
374 g_signal_new (I_("update-property"),
375 G_TYPE_FROM_CLASS (gobject_class),
377 G_STRUCT_OFFSET (IBusPanelServiceClass, update_property),
379 _ibus_marshal_VOID__OBJECT,
385 * IBusPanelService::set-cursor-location:
386 * @x: X coordinate of the cursor.
387 * @y: Y coordinate of the cursor.
388 * @w: Width of the cursor.
389 * @h: Height of the cursor.
391 * Emitted when the client application get the set-cursor-location.
392 * Implement the member function set_cursor_location() in extended class to receive this signal.
394 * <note><para>Argument @user_data is ignored in this function.</para></note>
396 panel_signals[SET_CURSOR_LOCATION] =
397 g_signal_new (I_("set-cursor-location"),
398 G_TYPE_FROM_CLASS (gobject_class),
400 G_STRUCT_OFFSET (IBusPanelServiceClass, set_cursor_location),
402 _ibus_marshal_VOID__INT_INT_INT_INT,
411 * IBusPanelService::cursor-up-lookup-table:
413 * Emitted when the client application get the cursor-up-lookup-table.
414 * Implement the member function cursor_up_lookup_table() in extended class to receive this signal.
416 * <note><para>Argument @user_data is ignored in this function.</para></note>
418 panel_signals[CURSOR_UP_LOOKUP_TABLE] =
419 g_signal_new (I_("cursor-up-lookup-table"),
420 G_TYPE_FROM_CLASS (gobject_class),
422 G_STRUCT_OFFSET (IBusPanelServiceClass, cursor_up_lookup_table),
424 _ibus_marshal_VOID__VOID,
428 * IBusPanelService::cursor-down-lookup-table:
430 * Emitted when the client application get the cursor-down-lookup-table.
431 * Implement the member function cursor_down_lookup_table() in extended class to receive this signal.
433 * <note><para>Argument @user_data is ignored in this function.</para></note>
435 panel_signals[CURSOR_DOWN_LOOKUP_TABLE] =
436 g_signal_new (I_("cursor-down-lookup-table"),
437 G_TYPE_FROM_CLASS (gobject_class),
439 G_STRUCT_OFFSET (IBusPanelServiceClass, cursor_down_lookup_table),
441 _ibus_marshal_VOID__VOID,
445 * IBusPanelService::hide-auxiliary-text:
447 * Emitted when the client application get the hide-auxiliary-text.
448 * Implement the member function hide_auxiliary_text() in extended class to receive this signal.
450 * <note><para>Argument @user_data is ignored in this function.</para></note>
452 panel_signals[HIDE_AUXILIARY_TEXT] =
453 g_signal_new (I_("hide-auxiliary-text"),
454 G_TYPE_FROM_CLASS (gobject_class),
456 G_STRUCT_OFFSET (IBusPanelServiceClass, hide_auxiliary_text),
458 _ibus_marshal_VOID__VOID,
462 * IBusPanelService::hide-language-bar:
464 * Emitted when the client application get the hide-language-bar.
465 * Implement the member function hide_language_bar() in extended class to receive this signal.
467 * <note><para>Argument @user_data is ignored in this function.</para></note>
469 panel_signals[HIDE_LANGUAGE_BAR] =
470 g_signal_new (I_("hide-language-bar"),
471 G_TYPE_FROM_CLASS (gobject_class),
473 G_STRUCT_OFFSET (IBusPanelServiceClass, hide_language_bar),
475 _ibus_marshal_VOID__VOID,
479 * IBusPanelService::hide-lookup-table:
481 * Emitted when the client application get the hide-lookup-table.
482 * Implement the member function hide_lookup_table() in extended class to receive this signal.
484 * <note><para>Argument @user_data is ignored in this function.</para></note>
486 panel_signals[HIDE_LOOKUP_TABLE] =
487 g_signal_new (I_("hide-lookup-table"),
488 G_TYPE_FROM_CLASS (gobject_class),
490 G_STRUCT_OFFSET (IBusPanelServiceClass, hide_lookup_table),
492 _ibus_marshal_VOID__VOID,
496 * IBusPanelService::hide-preedit-text:
498 * Emitted when the client application get the hide-preedit-text.
499 * Implement the member function hide_preedit_text() in extended class to receive this signal.
501 * <note><para>Argument @user_data is ignored in this function.</para></note>
503 panel_signals[HIDE_PREEDIT_TEXT] =
504 g_signal_new (I_("hide-preedit-text"),
505 G_TYPE_FROM_CLASS (gobject_class),
507 G_STRUCT_OFFSET (IBusPanelServiceClass, hide_preedit_text),
509 _ibus_marshal_VOID__VOID,
513 * IBusPanelService::page-up-lookup-table:
515 * Emitted when the client application get the page-up-lookup-table.
516 * Implement the member function page_up_lookup_table() in extended class to receive this signal.
518 * <note><para>Argument @user_data is ignored in this function.</para></note>
520 panel_signals[PAGE_UP_LOOKUP_TABLE] =
521 g_signal_new (I_("page-up-lookup-table"),
522 G_TYPE_FROM_CLASS (gobject_class),
524 G_STRUCT_OFFSET (IBusPanelServiceClass, page_up_lookup_table),
526 _ibus_marshal_VOID__VOID,
530 * IBusPanelService::page-down-lookup-table:
532 * Emitted when the client application get the page-down-lookup-table.
533 * Implement the member function page_down_lookup_table() in extended class to receive this signal.
535 * <note><para>Argument @user_data is ignored in this function.</para></note>
537 panel_signals[PAGE_DOWN_LOOKUP_TABLE] =
538 g_signal_new (I_("page-down-lookup-table"),
539 G_TYPE_FROM_CLASS (gobject_class),
541 G_STRUCT_OFFSET (IBusPanelServiceClass, page_down_lookup_table),
543 _ibus_marshal_VOID__VOID,
547 * IBusPanelService::reset:
549 * Emitted when the client application get the reset.
550 * Implement the member function reset() in extended class to receive this signal.
552 * <note><para>Argument @user_data is ignored in this function.</para></note>
554 panel_signals[RESET] =
555 g_signal_new (I_("reset"),
556 G_TYPE_FROM_CLASS (gobject_class),
558 G_STRUCT_OFFSET (IBusPanelServiceClass, reset),
560 _ibus_marshal_VOID__VOID,
564 * IBusPanelService::show-auxiliary-text:
566 * Emitted when the client application get the show-auxiliary-text.
567 * Implement the member function show_auxiliary_text() in extended class to receive this signal.
569 * <note><para>Argument @user_data is ignored in this function.</para></note>
571 panel_signals[SHOW_AUXILIARY_TEXT] =
572 g_signal_new (I_("show-auxiliary-text"),
573 G_TYPE_FROM_CLASS (gobject_class),
575 G_STRUCT_OFFSET (IBusPanelServiceClass, show_auxiliary_text),
577 _ibus_marshal_VOID__VOID,
581 * IBusPanelService::show-language-bar:
583 * Emitted when the client application get the show-language-bar.
584 * Implement the member function show_language_bar() in extended class to receive this signal.
586 * <note><para>Argument @user_data is ignored in this function.</para></note>
588 panel_signals[SHOW_LANGUAGE_BAR] =
589 g_signal_new (I_("show-language-bar"),
590 G_TYPE_FROM_CLASS (gobject_class),
592 G_STRUCT_OFFSET (IBusPanelServiceClass, show_language_bar),
594 _ibus_marshal_VOID__VOID,
598 * IBusPanelService::show-lookup-table:
600 * Emitted when the client application get the show-lookup-table.
601 * Implement the member function show_lookup_table() in extended class to receive this signal.
603 * <note><para>Argument @user_data is ignored in this function.</para></note>
605 panel_signals[SHOW_LOOKUP_TABLE] =
606 g_signal_new (I_("show-lookup-table"),
607 G_TYPE_FROM_CLASS (gobject_class),
609 G_STRUCT_OFFSET (IBusPanelServiceClass, show_lookup_table),
611 _ibus_marshal_VOID__VOID,
615 * IBusPanelService::show-preedit-text:
617 * Emitted when the client application get the show-preedit-text.
618 * Implement the member function show_preedit_text() in extended class to receive this signal.
620 * <note><para>Argument @user_data is ignored in this function.</para></note>
622 panel_signals[SHOW_PREEDIT_TEXT] =
623 g_signal_new (I_("show-preedit-text"),
624 G_TYPE_FROM_CLASS (gobject_class),
626 G_STRUCT_OFFSET (IBusPanelServiceClass, show_preedit_text),
628 _ibus_marshal_VOID__VOID,
632 * IBusPanelService::start-setup:
634 * Emitted when the client application get the start-setup.
635 * Implement the member function start_setup() in extended class to receive this signal.
637 * <note><para>Argument @user_data is ignored in this function.</para></note>
639 panel_signals[START_SETUP] =
640 g_signal_new (I_("start-setup"),
641 G_TYPE_FROM_CLASS (gobject_class),
643 G_STRUCT_OFFSET (IBusPanelServiceClass, start_setup),
645 _ibus_marshal_VOID__VOID,
649 * IBusPanelService::state-changed:
651 * Emitted when the client application get the state-changed.
652 * Implement the member function state_changed() in extended class to receive this signal.
654 * <note><para>Argument @user_data is ignored in this function.</para></note>
656 panel_signals[STATE_CHANGED] =
657 g_signal_new (I_("state-changed"),
658 G_TYPE_FROM_CLASS (gobject_class),
660 G_STRUCT_OFFSET (IBusPanelServiceClass, state_changed),
662 _ibus_marshal_VOID__VOID,
667 ibus_panel_service_init (IBusPanelService *panel)
672 ibus_panel_service_set_property (IBusPanelService *panel,
679 G_OBJECT_WARN_INVALID_PROPERTY_ID (panel, prop_id, pspec);
684 ibus_panel_service_get_property (IBusPanelService *panel,
691 G_OBJECT_WARN_INVALID_PROPERTY_ID (panel, prop_id, pspec);
696 ibus_panel_service_real_destroy (IBusPanelService *panel)
698 IBUS_OBJECT_CLASS(ibus_panel_service_parent_class)->destroy (IBUS_OBJECT (panel));
703 _g_object_unref_if_floating (gpointer instance)
705 if (g_object_is_floating (instance))
706 g_object_unref (instance);
710 ibus_panel_service_service_method_call (IBusService *service,
711 GDBusConnection *connection,
713 const gchar *object_path,
714 const gchar *interface_name,
715 const gchar *method_name,
716 GVariant *parameters,
717 GDBusMethodInvocation *invocation)
719 IBusPanelService *panel = IBUS_PANEL_SERVICE (service);
721 if (g_strcmp0 (interface_name, IBUS_INTERFACE_PANEL) != 0) {
722 IBUS_SERVICE_CLASS (ibus_panel_service_parent_class)->
723 service_method_call (service,
734 if (g_strcmp0 (method_name, "UpdatePreeditText") == 0) {
735 GVariant *variant = NULL;
737 gboolean visible = FALSE;
739 g_variant_get (parameters, "(vub)", &variant, &cursor, &visible);
740 IBusText *text = IBUS_TEXT (ibus_serializable_deserialize (variant));
741 g_variant_unref (variant);
743 g_signal_emit (panel, panel_signals[UPDATE_PREEDIT_TEXT], 0, text, cursor, visible);
744 _g_object_unref_if_floating (text);
745 g_dbus_method_invocation_return_value (invocation, NULL);
749 if (g_strcmp0 (method_name, "UpdateAuxiliaryText") == 0) {
750 GVariant *variant = NULL;
751 gboolean visible = FALSE;
753 g_variant_get (parameters, "(vb)", &variant, &visible);
754 IBusText *text = IBUS_TEXT (ibus_serializable_deserialize (variant));
755 g_variant_unref (variant);
757 g_signal_emit (panel, panel_signals[UPDATE_AUXILIARY_TEXT], 0, text, visible);
758 _g_object_unref_if_floating (text);
759 g_dbus_method_invocation_return_value (invocation, NULL);
763 if (g_strcmp0 (method_name, "UpdateLookupTable") == 0) {
764 GVariant *variant = NULL;
765 gboolean visible = FALSE;
767 g_variant_get (parameters, "(vb)", &variant, &visible);
768 IBusLookupTable *table = IBUS_LOOKUP_TABLE (ibus_serializable_deserialize (variant));
769 g_variant_unref (variant);
771 g_signal_emit (panel, panel_signals[UPDATE_LOOKUP_TABLE], 0, table, visible);
772 _g_object_unref_if_floating (table);
773 g_dbus_method_invocation_return_value (invocation, NULL);
777 if (g_strcmp0 (method_name, "FocusIn") == 0) {
779 g_variant_get (parameters, "(&o)", &path);
780 g_signal_emit (panel, panel_signals[FOCUS_IN], 0, path);
781 g_dbus_method_invocation_return_value (invocation, NULL);
785 if (g_strcmp0 (method_name, "FocusOut") == 0) {
787 g_variant_get (parameters, "(&o)", &path);
788 g_signal_emit (panel, panel_signals[FOCUS_OUT], 0, path);
789 g_dbus_method_invocation_return_value (invocation, NULL);
793 if (g_strcmp0 (method_name, "RegisterProperties") == 0) {
794 GVariant *variant = g_variant_get_child_value (parameters, 0);
795 IBusPropList *prop_list = IBUS_PROP_LIST (ibus_serializable_deserialize (variant));
796 g_variant_unref (variant);
798 g_signal_emit (panel, panel_signals[REGISTER_PROPERTIES], 0, prop_list);
799 _g_object_unref_if_floating (prop_list);
800 g_dbus_method_invocation_return_value (invocation, NULL);
804 if (g_strcmp0 (method_name, "UpdateProperty") == 0) {
805 GVariant *variant = g_variant_get_child_value (parameters, 0);
806 IBusProperty *property = IBUS_PROPERTY (ibus_serializable_deserialize (variant));
807 g_variant_unref (variant);
809 g_signal_emit (panel, panel_signals[UPDATE_PROPERTY], 0, property);
810 _g_object_unref_if_floating (property);
811 g_dbus_method_invocation_return_value (invocation, NULL);
815 if (g_strcmp0 (method_name, "SetCursorLocation") == 0) {
817 g_variant_get (parameters, "(iiii)", &x, &y, &w, &h);
818 g_signal_emit (panel, panel_signals[SET_CURSOR_LOCATION], 0, x, y, w, h);
819 g_dbus_method_invocation_return_value (invocation, NULL);
823 const static struct {
825 const gint signal_id;
826 } no_arg_methods [] = {
827 { "CursorUpLookupTable", CURSOR_UP_LOOKUP_TABLE },
828 { "CursorDownLookupTable", CURSOR_DOWN_LOOKUP_TABLE },
829 { "HideAuxiliaryText", HIDE_AUXILIARY_TEXT },
830 { "HideLanguageBar", HIDE_LANGUAGE_BAR },
831 { "HideLookupTable", HIDE_LOOKUP_TABLE },
832 { "HidePreeditText", HIDE_PREEDIT_TEXT },
833 { "PageUpLookupTable", PAGE_UP_LOOKUP_TABLE },
834 { "PageDownLookupTable", PAGE_DOWN_LOOKUP_TABLE },
836 { "ShowAuxiliaryText", SHOW_AUXILIARY_TEXT },
837 { "ShowLanguageBar", SHOW_LANGUAGE_BAR },
838 { "ShowLookupTable", SHOW_LOOKUP_TABLE },
839 { "ShowPreeditText", SHOW_PREEDIT_TEXT },
840 { "StartSetup", START_SETUP },
841 { "StateChanged", STATE_CHANGED },
845 for (i = 0; i < G_N_ELEMENTS (no_arg_methods); i++) {
846 if (g_strcmp0 (method_name, no_arg_methods[i].name) == 0) {
847 if (no_arg_methods[i].signal_id >= 0) {
848 g_signal_emit (panel, panel_signals[no_arg_methods[i].signal_id], 0);
850 g_dbus_method_invocation_return_value (invocation, NULL);
855 /* should not be reached */
856 g_return_if_reached ();
860 ibus_panel_service_service_get_property (IBusService *service,
861 GDBusConnection *connection,
863 const gchar *object_path,
864 const gchar *interface_name,
865 const gchar *property_name,
868 return IBUS_SERVICE_CLASS (ibus_panel_service_parent_class)->
869 service_get_property (service,
879 ibus_panel_service_service_set_property (IBusService *service,
880 GDBusConnection *connection,
882 const gchar *object_path,
883 const gchar *interface_name,
884 const gchar *property_name,
888 return IBUS_SERVICE_CLASS (ibus_panel_service_parent_class)->
889 service_set_property (service,
901 ibus_panel_service_not_implemented (IBusPanelService *panel)
903 /* g_debug ("not implemented"); */
907 ibus_panel_service_focus_in (IBusPanelService *panel,
908 const gchar *input_context_path)
910 ibus_panel_service_not_implemented(panel);
914 ibus_panel_service_focus_out (IBusPanelService *panel,
915 const gchar *input_context_path)
917 ibus_panel_service_not_implemented(panel);
921 ibus_panel_service_register_properties (IBusPanelService *panel,
922 IBusPropList *prop_list)
924 ibus_panel_service_not_implemented(panel);
928 ibus_panel_service_set_cursor_location (IBusPanelService *panel,
934 ibus_panel_service_not_implemented(panel);
938 ibus_panel_service_update_auxiliary_text (IBusPanelService *panel,
942 ibus_panel_service_not_implemented(panel);
946 ibus_panel_service_update_lookup_table (IBusPanelService *panel,
947 IBusLookupTable *lookup_table,
950 ibus_panel_service_not_implemented(panel);
954 ibus_panel_service_update_preedit_text (IBusPanelService *panel,
959 ibus_panel_service_not_implemented(panel);
963 ibus_panel_service_update_property (IBusPanelService *panel,
966 ibus_panel_service_not_implemented(panel);
970 ibus_panel_service_new (GDBusConnection *connection)
972 g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
974 GObject *object = g_object_new (IBUS_TYPE_PANEL_SERVICE,
975 "object-path", IBUS_PATH_PANEL,
976 "connection", connection,
979 return IBUS_PANEL_SERVICE (object);
983 ibus_panel_service_candidate_clicked (IBusPanelService *panel,
988 g_return_if_fail (IBUS_IS_PANEL_SERVICE (panel));
989 ibus_service_emit_signal ((IBusService *) panel,
991 IBUS_INTERFACE_PANEL,
993 g_variant_new ("(uuu)", index, button, state),
998 ibus_panel_service_property_activate (IBusPanelService *panel,
999 const gchar *prop_name,
1002 g_return_if_fail (IBUS_IS_PANEL_SERVICE (panel));
1003 ibus_service_emit_signal ((IBusService *) panel,
1005 IBUS_INTERFACE_PANEL,
1007 g_variant_new ("(su)", prop_name, prop_state),
1012 ibus_panel_service_property_show (IBusPanelService *panel,
1013 const gchar *prop_name)
1015 g_return_if_fail (IBUS_IS_PANEL_SERVICE (panel));
1016 ibus_service_emit_signal ((IBusService *) panel,
1018 IBUS_INTERFACE_PANEL,
1020 g_variant_new ("(s)", prop_name),
1025 ibus_panel_service_property_hide (IBusPanelService *panel,
1026 const gchar *prop_name)
1028 g_return_if_fail (IBUS_IS_PANEL_SERVICE (panel));
1029 ibus_service_emit_signal ((IBusService *) panel,
1031 IBUS_INTERFACE_PANEL,
1033 g_variant_new ("(s)", prop_name),
1037 #define DEFINE_FUNC(name, Name) \
1039 ibus_panel_service_##name (IBusPanelService *panel) \
1041 g_return_if_fail (IBUS_IS_PANEL_SERVICE (panel)); \
1042 ibus_service_emit_signal ((IBusService *) panel, \
1044 IBUS_INTERFACE_PANEL, \
1049 DEFINE_FUNC (cursor_down, CursorDown)
1050 DEFINE_FUNC (cursor_up, CursorUp)
1051 DEFINE_FUNC (page_down, PageDown)
1052 DEFINE_FUNC (page_up, PageUp)