/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright (C) 2008-2010 Red Hat, Inc.
+ * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2013 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#define BUS_PANEL_PROXY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), BUS_TYPE_PANEL_PROXY, BusPanelProxy))
#define BUS_PANEL_PROXY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), BUS_TYPE_PANEL_PROXY, BusPanelProxyClass))
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ BUS_TYPE_PANEL_PROXY, \
+ BusPanelProxyClass))
#define BUS_IS_PANEL_PROXY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUS_TYPE_PANEL_PROXY))
#define BUS_IS_PANEL_PROXY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), BUS_TYPE_PANEL_PROXY))
#define BUS_PANEL_PROXY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), BUS_TYPE_PANEL_PROXY, BusPanelProxyClass))
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ BUS_TYPE_PANEL_PROXY, \
+ BusPanelProxyClass))
G_BEGIN_DECLS
typedef struct _BusPanelProxy BusPanelProxy;
typedef struct _BusPanelProxyClass BusPanelProxyClass;
-GType bus_panel_proxy_get_type (void);
-BusPanelProxy *bus_panel_proxy_new (BusConnection *connection);
+GType bus_panel_proxy_get_type (void);
+BusPanelProxy *bus_panel_proxy_new (BusConnection *connection);
/* functions that invoke D-Bus methods of the panel component. */
-void bus_panel_proxy_focus_in (BusPanelProxy *panel,
- BusInputContext *context);
-void bus_panel_proxy_focus_out (BusPanelProxy *panel,
- BusInputContext *context);
+void bus_panel_proxy_focus_in (BusPanelProxy *panel,
+ BusInputContext *context);
+void bus_panel_proxy_focus_out (BusPanelProxy *panel,
+ BusInputContext *context);
+void bus_panel_proxy_destroy_context
+ (BusPanelProxy *panel,
+ BusInputContext *context);
void bus_panel_proxy_set_cursor_location
- (BusPanelProxy *panel,
- gint32 x,
- gint32 y,
- gint32 w,
- gint32 h);
-void bus_panel_proxy_update_preedit_text(BusPanelProxy *panel,
- IBusText *text,
- guint cursor_pos,
- gboolean visible);
-void bus_panel_proxy_show_preedit_text (BusPanelProxy *panel);
-void bus_panel_proxy_hide_preedit_text (BusPanelProxy *panel);
+ (BusPanelProxy *panel,
+ gint32 x,
+ gint32 y,
+ gint32 w,
+ gint32 h);
+void bus_panel_proxy_update_preedit_text
+ (BusPanelProxy *panel,
+ IBusText *text,
+ guint cursor_pos,
+ gboolean visible);
+void bus_panel_proxy_show_preedit_text
+ (BusPanelProxy *panel);
+void bus_panel_proxy_hide_preedit_text
+ (BusPanelProxy *panel);
void bus_panel_proxy_update_auxiliary_text
- (BusPanelProxy *panel,
- IBusText *text,
- gboolean visible);
-void bus_panel_proxy_show_auxiliary_text(BusPanelProxy *panel);
-void bus_panel_proxy_hide_auxiliary_text(BusPanelProxy *panel);
-void bus_panel_proxy_update_lookup_table(BusPanelProxy *panel,
- IBusLookupTable *table,
- gboolean visible);
-void bus_panel_proxy_show_lookup_table (BusPanelProxy *panel);
-void bus_panel_proxy_hide_lookup_table (BusPanelProxy *panel);
+ (BusPanelProxy *panel,
+ IBusText *text,
+ gboolean visible);
+void bus_panel_proxy_show_auxiliary_text
+ (BusPanelProxy *panel);
+void bus_panel_proxy_hide_auxiliary_text
+ (BusPanelProxy *panel);
+void bus_panel_proxy_update_lookup_table
+ (BusPanelProxy *panel,
+ IBusLookupTable *table,
+ gboolean visible);
+void bus_panel_proxy_show_lookup_table
+ (BusPanelProxy *panel);
+void bus_panel_proxy_hide_lookup_table
+ (BusPanelProxy *panel);
void bus_panel_proxy_page_up_lookup_table
- (BusPanelProxy *panel);
+ (BusPanelProxy *panel);
void bus_panel_proxy_page_down_lookup_table
- (BusPanelProxy *panel);
+ (BusPanelProxy *panel);
void bus_panel_proxy_cursor_up_lookup_table
- (BusPanelProxy *panel);
+ (BusPanelProxy *panel);
void bus_panel_proxy_cursor_down_lookup_table
- (BusPanelProxy *panel);
-void bus_panel_proxy_register_properties(BusPanelProxy *panel,
- IBusPropList *prop_list);
-void bus_panel_proxy_update_property (BusPanelProxy *panel,
- IBusProperty *prop);
+ (BusPanelProxy *panel);
+void bus_panel_proxy_register_properties
+ (BusPanelProxy *panel,
+ IBusPropList *prop_list);
+void bus_panel_proxy_update_property
+ (BusPanelProxy *panel,
+ IBusProperty *prop);
G_END_DECLS
#endif
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (c) 2009, Google Inc. All rights reserved.
- * Copyright (C) 2010 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (c) 2009-2013 Google Inc. All rights reserved.
+ * Copyright (C) 2010-2013 Peng Huang <shawn.p.huang@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
SHOW_PREEDIT_TEXT,
START_SETUP,
STATE_CHANGED,
+ DESTROY_CONTEXT,
LAST_SIGNAL,
};
static guint panel_signals[LAST_SIGNAL] = { 0 };
/* functions prototype */
-static void ibus_panel_service_set_property (IBusPanelService *panel,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void ibus_panel_service_get_property (IBusPanelService *panel,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void ibus_panel_service_real_destroy (IBusPanelService *panel);
-static void ibus_panel_service_service_method_call (IBusService *service,
- GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation);
-static GVariant *ibus_panel_service_service_get_property (IBusService *service,
- GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *property_name,
- GError **error);
-static gboolean ibus_panel_service_service_set_property (IBusService *service,
- GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *property_name,
- GVariant *value,
- GError **error);
-static void ibus_panel_service_not_implemented (IBusPanelService *panel);
-static void ibus_panel_service_focus_in (IBusPanelService *panel,
- const gchar *input_context_path);
-static void ibus_panel_service_focus_out (IBusPanelService *panel,
- const gchar *input_context_path);
-static void ibus_panel_service_register_properties (IBusPanelService *panel,
- IBusPropList *prop_list);
-static void ibus_panel_service_set_cursor_location (IBusPanelService *panel,
- gint x,
- gint y,
- gint w,
- gint h);
-static void ibus_panel_service_update_auxiliary_text (IBusPanelService *panel,
- IBusText *text,
- gboolean visible);
-static void ibus_panel_service_update_lookup_table (IBusPanelService *panel,
- IBusLookupTable *lookup_table,
- gboolean visible);
-static void ibus_panel_service_update_preedit_text (IBusPanelService *panel,
- IBusText *text,
- guint cursor_pos,
- gboolean visible);
-static void ibus_panel_service_update_property (IBusPanelService *panel,
- IBusProperty *prop);
+static void ibus_panel_service_set_property
+ (IBusPanelService *panel,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void ibus_panel_service_get_property
+ (IBusPanelService *panel,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void ibus_panel_service_real_destroy
+ (IBusPanelService *panel);
+static void ibus_panel_service_service_method_call
+ (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation);
+static GVariant *ibus_panel_service_service_get_property
+ (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error);
+static gboolean ibus_panel_service_service_set_property
+ (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GVariant *value,
+ GError **error);
+static void ibus_panel_service_not_implemented
+ (IBusPanelService *panel);
+static void ibus_panel_service_focus_in
+ (IBusPanelService *panel,
+ const gchar *input_context_path);
+static void ibus_panel_service_focus_out
+ (IBusPanelService *panel,
+ const gchar *input_context_path);
+static void ibus_panel_service_destroy_context
+ (IBusPanelService *panel,
+ const gchar *input_context_path);
+static void ibus_panel_service_register_properties
+ (IBusPanelService *panel,
+ IBusPropList *prop_list);
+static void ibus_panel_service_set_cursor_location
+ (IBusPanelService *panel,
+ gint x,
+ gint y,
+ gint w,
+ gint h);
+static void ibus_panel_service_update_auxiliary_text
+ (IBusPanelService *panel,
+ IBusText *text,
+ gboolean visible);
+static void ibus_panel_service_update_lookup_table
+ (IBusPanelService *panel,
+ IBusLookupTable *lookup_table,
+ gboolean visible);
+static void ibus_panel_service_update_preedit_text
+ (IBusPanelService *panel,
+ IBusText *text,
+ guint cursor_pos,
+ gboolean visible);
+static void ibus_panel_service_update_property
+ (IBusPanelService *panel,
+ IBusProperty *prop);
G_DEFINE_TYPE (IBusPanelService, ibus_panel_service, IBUS_TYPE_SERVICE)
" <method name='FocusOut'>"
" <arg direction='in' type='o' name='ic' />"
" </method>"
+ " <method name='DestroyContext'>"
+ " <arg direction='in' type='o' name='ic' />"
+ " </method>"
" <method name='SetCursorLocation'>"
" <arg direction='in' type='i' name='x' />"
" <arg direction='in' type='i' name='y' />"
ibus_panel_service_class_init (IBusPanelServiceClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
- ibus_panel_service_parent_class = IBUS_SERVICE_CLASS (g_type_class_peek_parent (class));
+ ibus_panel_service_parent_class =
+ IBUS_SERVICE_CLASS (g_type_class_peek_parent (class));
- gobject_class->set_property = (GObjectSetPropertyFunc) ibus_panel_service_set_property;
- gobject_class->get_property = (GObjectGetPropertyFunc) ibus_panel_service_get_property;
+ gobject_class->set_property =
+ (GObjectSetPropertyFunc) ibus_panel_service_set_property;
+ gobject_class->get_property =
+ (GObjectGetPropertyFunc) ibus_panel_service_get_property;
- IBUS_OBJECT_CLASS (gobject_class)->destroy = (IBusObjectDestroyFunc) ibus_panel_service_real_destroy;
+ IBUS_OBJECT_CLASS (gobject_class)->destroy =
+ (IBusObjectDestroyFunc) ibus_panel_service_real_destroy;
- IBUS_SERVICE_CLASS (class)->service_method_call = ibus_panel_service_service_method_call;
- IBUS_SERVICE_CLASS (class)->service_get_property = ibus_panel_service_service_get_property;
- IBUS_SERVICE_CLASS (class)->service_set_property = ibus_panel_service_service_set_property;
+ IBUS_SERVICE_CLASS (class)->service_method_call =
+ ibus_panel_service_service_method_call;
+ IBUS_SERVICE_CLASS (class)->service_get_property =
+ ibus_panel_service_service_get_property;
+ IBUS_SERVICE_CLASS (class)->service_set_property =
+ ibus_panel_service_service_set_property;
- ibus_service_class_add_interfaces (IBUS_SERVICE_CLASS (class), introspection_xml);
+ ibus_service_class_add_interfaces (IBUS_SERVICE_CLASS (class),
+ introspection_xml);
class->focus_in = ibus_panel_service_focus_in;
class->focus_out = ibus_panel_service_focus_out;
+ class->destroy_context = ibus_panel_service_destroy_context;
class->register_properties = ibus_panel_service_register_properties;
class->set_cursor_location = ibus_panel_service_set_cursor_location;
class->update_lookup_table = ibus_panel_service_update_lookup_table;
* @visible: Whether the update is visible.
*
* Emitted when the client application get the update-preedit-text.
- * Implement the member function update_preedit_text() in extended class to receive this signal.
+ * Implement the member function update_preedit_text() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[UPDATE_PREEDIT_TEXT] =
g_signal_new (I_("update-preedit-text"),
* @visible: Whether the update is visible.
*
* Emitted when the client application get the update-auxiliary-text.
- * Implement the member function update_auxiliary_text() in extended class to receive this signal.
+ * Implement the member function update_auxiliary_text() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[UPDATE_AUXILIARY_TEXT] =
g_signal_new (I_("update-auxiliary-text"),
* @visible: Whether the update is visible.
*
* Emitted when the client application get the update-lookup-table.
- * Implement the member function update_lookup_table() in extended class to receive this signal.
+ * Implement the member function update_lookup_table() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[UPDATE_LOOKUP_TABLE] =
g_signal_new (I_("update-lookup-table"),
* @input_context_path: Object path of InputContext.
*
* Emitted when the client application get the focus-in.
- * Implement the member function focus_in() in extended class to receive this signal.
+ * Implement the member function focus_in() in extended class to receive
+ * this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[FOCUS_IN] =
g_signal_new (I_("focus-in"),
* @input_context_path: Object path of InputContext.
*
* Emitted when the client application get the focus-out.
- * Implement the member function focus_out() in extended class to receive this signal.
+ * Implement the member function focus_out() in extended class to receive
+ * this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[FOCUS_OUT] =
g_signal_new (I_("focus-out"),
* @prop_list: An IBusPropList that contains properties.
*
* Emitted when the client application get the register-properties.
- * Implement the member function register_properties() in extended class to receive this signal.
+ * Implement the member function register_properties() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[REGISTER_PROPERTIES] =
g_signal_new (I_("register-properties"),
* @prop: The IBusProperty to be updated.
*
* Emitted when the client application get the update-property.
- * Implement the member function update_property() in extended class to receive this signal.
+ * Implement the member function update_property() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[UPDATE_PROPERTY] =
g_signal_new (I_("update-property"),
* @h: Height of the cursor.
*
* Emitted when the client application get the set-cursor-location.
- * Implement the member function set_cursor_location() in extended class to receive this signal.
+ * Implement the member function set_cursor_location() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[SET_CURSOR_LOCATION] =
g_signal_new (I_("set-cursor-location"),
* IBusPanelService::cursor-up-lookup-table:
*
* Emitted when the client application get the cursor-up-lookup-table.
- * Implement the member function cursor_up_lookup_table() in extended class to receive this signal.
+ * Implement the member function cursor_up_lookup_table() in extended
+ * class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[CURSOR_UP_LOOKUP_TABLE] =
g_signal_new (I_("cursor-up-lookup-table"),
* IBusPanelService::cursor-down-lookup-table:
*
* Emitted when the client application get the cursor-down-lookup-table.
- * Implement the member function cursor_down_lookup_table() in extended class to receive this signal.
+ * Implement the member function cursor_down_lookup_table() in extended
+ * class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[CURSOR_DOWN_LOOKUP_TABLE] =
g_signal_new (I_("cursor-down-lookup-table"),
* IBusPanelService::hide-auxiliary-text:
*
* Emitted when the client application get the hide-auxiliary-text.
- * Implement the member function hide_auxiliary_text() in extended class to receive this signal.
+ * Implement the member function hide_auxiliary_text() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[HIDE_AUXILIARY_TEXT] =
g_signal_new (I_("hide-auxiliary-text"),
* IBusPanelService::hide-language-bar:
*
* Emitted when the client application get the hide-language-bar.
- * Implement the member function hide_language_bar() in extended class to receive this signal.
+ * Implement the member function hide_language_bar() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[HIDE_LANGUAGE_BAR] =
g_signal_new (I_("hide-language-bar"),
* IBusPanelService::hide-lookup-table:
*
* Emitted when the client application get the hide-lookup-table.
- * Implement the member function hide_lookup_table() in extended class to receive this signal.
+ * Implement the member function hide_lookup_table() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[HIDE_LOOKUP_TABLE] =
g_signal_new (I_("hide-lookup-table"),
* IBusPanelService::hide-preedit-text:
*
* Emitted when the client application get the hide-preedit-text.
- * Implement the member function hide_preedit_text() in extended class to receive this signal.
+ * Implement the member function hide_preedit_text() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[HIDE_PREEDIT_TEXT] =
g_signal_new (I_("hide-preedit-text"),
* IBusPanelService::page-up-lookup-table:
*
* Emitted when the client application get the page-up-lookup-table.
- * Implement the member function page_up_lookup_table() in extended class to receive this signal.
+ * Implement the member function page_up_lookup_table() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[PAGE_UP_LOOKUP_TABLE] =
g_signal_new (I_("page-up-lookup-table"),
* IBusPanelService::page-down-lookup-table:
*
* Emitted when the client application get the page-down-lookup-table.
- * Implement the member function page_down_lookup_table() in extended class to receive this signal.
+ * Implement the member function page_down_lookup_table() in extended
+ * class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[PAGE_DOWN_LOOKUP_TABLE] =
g_signal_new (I_("page-down-lookup-table"),
* IBusPanelService::reset:
*
* Emitted when the client application get the reset.
- * Implement the member function reset() in extended class to receive this signal.
+ * Implement the member function reset() in extended class to receive this
+ * signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[RESET] =
g_signal_new (I_("reset"),
* IBusPanelService::show-auxiliary-text:
*
* Emitted when the client application get the show-auxiliary-text.
- * Implement the member function show_auxiliary_text() in extended class to receive this signal.
+ * Implement the member function show_auxiliary_text() in extended class
+ * to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[SHOW_AUXILIARY_TEXT] =
g_signal_new (I_("show-auxiliary-text"),
* IBusPanelService::show-language-bar:
*
* Emitted when the client application get the show-language-bar.
- * Implement the member function show_language_bar() in extended class to receive this signal.
+ * Implement the member function show_language_bar() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[SHOW_LANGUAGE_BAR] =
g_signal_new (I_("show-language-bar"),
* IBusPanelService::show-lookup-table:
*
* Emitted when the client application get the show-lookup-table.
- * Implement the member function show_lookup_table() in extended class to receive this signal.
+ * Implement the member function show_lookup_table() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[SHOW_LOOKUP_TABLE] =
g_signal_new (I_("show-lookup-table"),
* IBusPanelService::show-preedit-text:
*
* Emitted when the client application get the show-preedit-text.
- * Implement the member function show_preedit_text() in extended class to receive this signal.
+ * Implement the member function show_preedit_text() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[SHOW_PREEDIT_TEXT] =
g_signal_new (I_("show-preedit-text"),
* IBusPanelService::start-setup:
*
* Emitted when the client application get the start-setup.
- * Implement the member function start_setup() in extended class to receive this signal.
+ * Implement the member function start_setup() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[START_SETUP] =
g_signal_new (I_("start-setup"),
* IBusPanelService::state-changed:
*
* Emitted when the client application get the state-changed.
- * Implement the member function state_changed() in extended class to receive this signal.
+ * Implement the member function state_changed() in extended class to
+ * receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
panel_signals[STATE_CHANGED] =
g_signal_new (I_("state-changed"),
NULL, NULL,
_ibus_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * IBusPanelService::destroy-context:
+ * @input_context_path: Object path of InputContext.
+ *
+ * Emitted when the client application destroys.
+ * Implement the member function destroy_context() in extended class to
+ * receive this signal.
+ *
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
+ */
+ panel_signals[DESTROY_CONTEXT] =
+ g_signal_new (I_("destroy-context"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IBusPanelServiceClass, destroy_context),
+ NULL, NULL,
+ _ibus_marshal_VOID__STRING,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING);
}
static void
return;
}
+ if (g_strcmp0 (method_name, "DestroyContext") == 0) {
+ const gchar *path;
+ g_variant_get (parameters, "(&o)", &path);
+ g_signal_emit (panel, panel_signals[DESTROY_CONTEXT], 0, path);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ return;
+ }
+
if (g_strcmp0 (method_name, "RegisterProperties") == 0) {
GVariant *variant = g_variant_get_child_value (parameters, 0);
IBusPropList *prop_list = IBUS_PROP_LIST (ibus_serializable_deserialize (variant));
}
static void
+ibus_panel_service_destroy_context (IBusPanelService *panel,
+ const gchar *input_context_path)
+{
+ ibus_panel_service_not_implemented(panel);
+}
+
+static void
ibus_panel_service_register_properties (IBusPanelService *panel,
IBusPropList *prop_list)
{
*
* ibus - The Input Bus
*
- * Copyright(c) 2011 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright(c) 2011-2013 Peng Huang <shawn.p.huang@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
private Gtk.Menu m_ime_menu;
private Gtk.Menu m_sys_menu;
private IBus.EngineDesc[] m_engines = {};
+ private GLib.HashTable<string, IBus.EngineDesc> m_engine_contexts =
+ new GLib.HashTable<string, IBus.EngineDesc>(GLib.str_hash,
+ GLib.str_equal);
+ private string m_current_context_path = "";
+ private bool m_use_global_engine = true;
private CandidatePanel m_candidate_panel;
private Switcher m_switcher;
+ private bool m_switcher_is_running = false;
private PropertyManager m_property_manager;
private GLib.Pid m_setup_pid = 0;
private Gtk.AboutDialog m_about_dialog;
set_embed_preedit_text();
});
+ m_settings_general.changed["use-global-engine"].connect((key) => {
+ set_use_global_engine();
+ });
+
m_settings_hotkey.changed["triggers"].connect((key) => {
unbind_switch_shortcut();
bind_switch_shortcut();
m_bus.set_ibus_property("EmbedPreeditText", variant);
}
+ private void set_use_global_engine() {
+ m_use_global_engine =
+ m_settings_general.get_boolean("use-global-engine");
+ }
+
private int compare_versions(string version1, string version2) {
string[] version1_list = version1.split(".");
string[] version2_list = version2.split(".");
// Update m_use_system_keyboard_layout before update_engines()
// is called.
set_use_system_keyboard_layout();
+ set_use_global_engine();
update_engines(m_settings_general.get_strv("preload-engines"),
m_settings_general.get_strv("engines-order"));
unbind_switch_shortcut();
}
}
- private void switch_engine(int i, bool force = false) {
- GLib.assert(i >= 0 && i < m_engines.length);
-
- // Do not need switch
- if (i == 0 && !force)
+ private void engine_contexts_insert(IBus.EngineDesc engine) {
+ if (m_use_global_engine)
return;
- IBus.EngineDesc engine = m_engines[i];
+ if (m_engine_contexts.size() >= 200) {
+ warning ("Contexts by windows are too much counted!");
+ m_engine_contexts.remove_all();
+ }
+
+ m_engine_contexts.replace(m_current_context_path, engine);
+ }
+ private void set_engine(IBus.EngineDesc engine) {
if (!m_bus.set_global_engine(engine.get_name())) {
warning("Switch engine to %s failed.", engine.get_name());
return;
}
+
// set xkb layout
- if (!m_use_system_keyboard_layout) {
+ if (!m_use_system_keyboard_layout)
exec_setxkbmap(engine);
- }
+
+ engine_contexts_insert(engine);
+ }
+
+ private void switch_engine(int i, bool force = false) {
+ GLib.assert(i >= 0 && i < m_engines.length);
+
+ // Do not need switch
+ if (i == 0 && !force)
+ return;
+
+ IBus.EngineDesc engine = m_engines[i];
+
+ set_engine(engine);
}
private void handle_engine_switch(Gdk.Event event, bool revert) {
if (pressed && m_switcher_delay_time >= 0) {
int i = revert ? m_engines.length - 1 : 1;
+
+ /* The flag of m_switcher_is_running avoids the following problem:
+ *
+ * When an IME is chosen on m_switcher, focus_in() is called
+ * for the root window. If an engine is set in focus_in()
+ * during running m_switcher when m_use_global_engine is false,
+ * state_changed() is also called and m_engines[] is modified
+ * in state_changed() and m_switcher.run() returns the index
+ * for m_engines[] but m_engines[] was modified by state_changed()
+ * and the index is not correct. */
+ m_switcher_is_running = true;
i = m_switcher.run(keyval, modifiers, event, m_engines, i);
+ m_switcher_is_running = false;
+
if (i < 0) {
debug("switch cancelled");
} else {
}
public override void focus_in(string input_context_path) {
+ if (m_use_global_engine)
+ return;
+
+ /* Do not change the order of m_engines during running switcher. */
+ if (m_switcher_is_running)
+ return;
+
+ m_current_context_path = input_context_path;
+
+ var engine = m_engine_contexts[m_current_context_path];
+
+ if (engine == null) {
+ /* If engine == null, need to call set_engine(m_engines[0])
+ * here and update m_engine_contexts[] to avoid the
+ * following problem:
+ *
+ * If context1 is focused and does not set an engine and
+ * return here, the current engine1 is used for context1.
+ * When context2 is focused and switch engine1 to engine2,
+ * the current engine becomes engine2.
+ * And when context1 is focused again, context1 still
+ * does not set an engine and return here,
+ * engine2 is used for context2 instead of engine1. */
+ engine = m_engines.length > 0 ? m_engines[0] : null;
+
+ if (engine == null)
+ return;
+ } else {
+ bool in_engines = false;
+
+ foreach (var e in m_engines) {
+ if (engine.get_name() == e.get_name()) {
+ in_engines = true;
+ break;
+ }
+ }
+
+ /* The engine is deleted by ibus-setup before focus_in()
+ * is called. */
+ if (!in_engines)
+ return;
+ }
+
+ set_engine(engine);
}
public override void focus_out(string input_context_path) {
+ if (m_use_global_engine)
+ return;
+
+ /* Do not change the order of m_engines during running switcher. */
+ if (m_switcher_is_running)
+ return;
+
+ m_current_context_path = "";
+ }
+
+ public override void destroy_context(string input_context_path) {
+ if (m_use_global_engine)
+ return;
+
+ m_engine_contexts.remove(input_context_path);
}
public override void register_properties(IBus.PropList props) {
}
public override void state_changed() {
+ /* Do not change the order of m_engines during running switcher. */
+ if (m_switcher_is_running)
+ return;
+
var icon_name = "ibus-keyboard";
var engine = m_bus.get_global_engine();