summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2014-04-03 12:19:47 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2014-04-03 12:19:47 +0900
commit6ca5ddb302c98e52c78326ed0dfaaf90481d4d8c (patch)
tree0fa7b9aa8bda6bd287433def8bce9aa9e113a2c0
parent18612e19fe4e9d3c89cbcf92c6562d48677412d6 (diff)
Send panel input purpose.
gnome-shell gets input purpose so that disables IME with password mode. Review URL: https://codereview.appspot.com/81770044
-rw-r--r--bus/inputcontext.c16
-rw-r--r--bus/inputcontext.h158
-rw-r--r--bus/panelproxy.c22
-rw-r--r--bus/panelproxy.h8
-rw-r--r--src/ibuspanelservice.c56
-rw-r--r--src/ibuspanelservice.h7
6 files changed, 199 insertions, 68 deletions
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
index a2d1d52c..512a0ec3 100644
--- a/bus/inputcontext.c
+++ b/bus/inputcontext.c
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright (C) 2008-2013 Red Hat, Inc.
+ * Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2014 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
@@ -2459,3 +2459,15 @@ bus_input_context_get_client (BusInputContext *context)
g_assert (BUS_IS_INPUT_CONTEXT (context));
return context->client;
}
+
+void
+bus_input_context_get_content_type (BusInputContext *context,
+ guint *purpose,
+ guint *hints)
+{
+ g_assert (BUS_IS_INPUT_CONTEXT (context));
+ g_return_if_fail (purpose != NULL && hints != NULL);
+
+ *purpose = context->purpose;
+ *hints = context->hints;
+}
diff --git a/bus/inputcontext.h b/bus/inputcontext.h
index 50f615f5..f282faee 100644
--- a/bus/inputcontext.h
+++ b/bus/inputcontext.h
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
-/* bus - The Input Bus
- * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright (C) 2008-2010 Red Hat, Inc.
+/* ibus - The Input Bus
+ * Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2014 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
@@ -32,181 +32,223 @@
*/
/* define GOBJECT macros */
-#define BUS_TYPE_INPUT_CONTEXT \
+#define BUS_TYPE_INPUT_CONTEXT \
(bus_input_context_get_type ())
-#define BUS_INPUT_CONTEXT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUS_TYPE_INPUT_CONTEXT, BusInputContext))
-#define BUS_INPUT_CONTEXT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), BUS_TYPE_INPUT_CONTEXT, BusInputContextClass))
-#define BUS_IS_INPUT_CONTEXT(obj) \
+#define BUS_INPUT_CONTEXT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ BUS_TYPE_INPUT_CONTEXT, \
+ BusInputContext))
+#define BUS_INPUT_CONTEXT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ BUS_TYPE_INPUT_CONTEXT, \
+ BusInputContextClass))
+#define BUS_IS_INPUT_CONTEXT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUS_TYPE_INPUT_CONTEXT))
-#define BUS_IS_INPUT_CONTEXT_CLASS(klass) \
+#define BUS_IS_INPUT_CONTEXT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), BUS_TYPE_INPUT_CONTEXT))
-#define BUS_INPUT_CONTEXT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), BUS_TYPE_INPUT_CONTEXT, BusInputContextClass))
+#define BUS_INPUT_CONTEXT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ BUS_TYPE_INPUT_CONTEXT, \
+ BusInputContextClass))
G_BEGIN_DECLS
typedef struct _BusInputContext BusInputContext;
typedef struct _BusInputContextClass BusInputContextClass;
-GType bus_input_context_get_type (void);
-BusInputContext *bus_input_context_new (BusConnection *connection,
- const gchar *client);
+GType bus_input_context_get_type (void);
+BusInputContext *bus_input_context_new (BusConnection *connection,
+ const gchar *client);
/**
* bus_input_context_focus_in:
*
- * Give a focus to the context. Call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods of the engine for the context,
- * and then emit glib signals to the context object. This function does nothing if the context already has a focus.
+ * Give a focus to the context. Call FocusIn, Enable, SetCapabilities,
+ * and SetCursorLocation methods of the engine for the context,
+ * and then emit glib signals to the context object. This function does
+ * nothing if the context already has a focus.
*/
-void bus_input_context_focus_in (BusInputContext *context);
+void bus_input_context_focus_in (BusInputContext *context);
/**
* bus_input_context_focus_out:
*
- * Remove a focus from the context. Call FocusOut method of the engine for the context.
+ * Remove a focus from the context. Call FocusOut method of the engine for
+ * the context.
* This function does nothing if the context does not have a focus.
*/
-void bus_input_context_focus_out (BusInputContext *context);
+void bus_input_context_focus_out
+ (BusInputContext *context);
/**
* bus_input_context_has_focus:
* @returns: context->has_focus.
*/
-gboolean bus_input_context_has_focus (BusInputContext *context);
+gboolean bus_input_context_has_focus
+ (BusInputContext *context);
/**
* bus_input_context_enable:
*
- * Enable the current engine for the context. Request an engine (if needed), call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
- * of the engine for the context, and then emit glib and D-Bus "enabled" signals.
+ * Enable the current engine for the context. Request an engine (if needed),
+ * call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
+ * of the engine for the context, and then emit glib and D-Bus "enabled"
+ * signals.
*/
-void bus_input_context_enable (BusInputContext *context);
+void bus_input_context_enable (BusInputContext *context);
/**
* bus_input_context_disable:
*
- * Disable the current engine for the context. Request an engine (if needed), call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
- * of the engine for the context, and then emit glib and D-Bus "enabled" signals.
+ * Disable the current engine for the context. Request an engine (if needed),
+ * call FocusIn, Enable, SetCapabilities, and SetCursorLocation methods
+ * of the engine for the context, and then emit glib and D-Bus "enabled"
+ * signals.
*/
-void bus_input_context_disable (BusInputContext *context);
+void bus_input_context_disable (BusInputContext *context);
/**
* bus_input_context_page_up:
*
* Call page_up method of the current engine proxy.
*/
-void bus_input_context_page_up (BusInputContext *context);
+void bus_input_context_page_up (BusInputContext *context);
/**
* bus_input_context_page_down:
*
* Call page_down method of the current engine proxy.
*/
-void bus_input_context_page_down (BusInputContext *context);
+void bus_input_context_page_down
+ (BusInputContext *context);
/**
* bus_input_context_cursor_up:
*
* Call cursor_up method of the current engine proxy.
*/
-void bus_input_context_cursor_up (BusInputContext *context);
+void bus_input_context_cursor_up
+ (BusInputContext *context);
/**
* bus_input_context_cursor_down:
*
* Call cursor_down method of the current engine proxy.
*/
-void bus_input_context_cursor_down (BusInputContext *context);
+void bus_input_context_cursor_down
+ (BusInputContext *context);
/**
* bus_input_context_candidate_clicked:
*
* Call candidate_clicked method of the current engine proxy.
*/
-void bus_input_context_candidate_clicked(BusInputContext *context,
- guint index,
- guint button,
- guint state);
+void bus_input_context_candidate_clicked
+ (BusInputContext *context,
+ guint index,
+ guint button,
+ guint state);
/**
* bus_input_context_set_engine:
*
* Use the engine on the context.
*/
-void bus_input_context_set_engine (BusInputContext *context,
- BusEngineProxy *engine);
+void bus_input_context_set_engine
+ (BusInputContext *context,
+ BusEngineProxy *engine);
/**
* bus_input_context_set_engine_by_desc:
* @desc: the engine to use on the context.
* @timeout: timeout (in ms) for D-Bus calls.
- * @callback: a function to be called when bus_input_context_set_engine_by_desc is finished. if NULL, the default callback
- * function, which just calls bus_input_context_set_engine_by_desc_finish, is used.
+ * @callback: a function to be called when bus_input_context_set_engine_by_desc
+ * is finished. if NULL, the default callback
+ * function, which just calls
+ * bus_input_context_set_engine_by_desc_finish, is used.
*
* Create a new BusEngineProxy object and use it on the context.
*/
void bus_input_context_set_engine_by_desc
- (BusInputContext *context,
- IBusEngineDesc *desc,
- gint timeout,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
+ (BusInputContext *context,
+ IBusEngineDesc *desc,
+ gint timeout,
+ GCancellable
+ *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
/**
* bus_input_context_set_engine_by_desc_finish:
*
- * A function to be called by the GAsyncReadyCallback function for bus_input_context_set_engine_by_desc.
+ * A function to be called by the GAsyncReadyCallback function for
+ * bus_input_context_set_engine_by_desc.
*/
gboolean bus_input_context_set_engine_by_desc_finish
- (BusInputContext *context,
- GAsyncResult *res,
- GError **error);
+ (BusInputContext *context,
+ GAsyncResult *res,
+ GError **error);
/**
* bus_input_context_get_engine:
*
* Get a BusEngineProxy object of the current engine.
*/
-BusEngineProxy *bus_input_context_get_engine (BusInputContext *context);
+BusEngineProxy *bus_input_context_get_engine
+ (BusInputContext *context);
/**
* bus_input_context_get_engine_desc:
*
* Get an IBusEngineDesc object of the current engine.
*/
-IBusEngineDesc *bus_input_context_get_engine_desc (BusInputContext *context);
+IBusEngineDesc *bus_input_context_get_engine_desc
+ (BusInputContext *context);
/**
* bus_input_context_property_activate:
*
* Call property_activate method of the current engine proxy.
*/
-void bus_input_context_property_activate(BusInputContext *context,
- const gchar *prop_name,
- gint prop_state);
+void bus_input_context_property_activate
+ (BusInputContext *context,
+ const gchar *prop_name,
+ gint
+ prop_state);
/**
* bus_input_context_get_capabilities:
* @returns: context->capabilities.
*/
-guint bus_input_context_get_capabilities (BusInputContext *context);
+guint bus_input_context_get_capabilities
+ (BusInputContext *context);
/**
* bus_input_context_set_capabilities:
*
* Call set_capabilities method of the current engine proxy.
*/
-void bus_input_context_set_capabilities (BusInputContext *context,
- guint capabilities);
+void bus_input_context_set_capabilities
+ (BusInputContext *context,
+ guint
+ capabilities);
/**
* bus_input_context_get_client:
* @returns: context->client.
*/
-const gchar *bus_input_context_get_client (BusInputContext *context);
+const gchar *bus_input_context_get_client
+ (BusInputContext *context);
+
+/**
+ * bus_input_context_get_content_type:
+ * @purpose: Input purpose.
+ * @hints: Input hints.
+ */
+void bus_input_context_get_content_type
+ (BusInputContext *context,
+ guint *purpose,
+ guint *hints);
G_END_DECLS
#endif
diff --git a/bus/panelproxy.c b/bus/panelproxy.c
index d49f1e10..cdb3d20c 100644
--- a/bus/panelproxy.c
+++ b/bus/panelproxy.c
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright (C) 2008-2013 Red Hat, Inc.
+ * Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2014 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
@@ -398,6 +398,20 @@ bus_panel_proxy_update_property (BusPanelProxy *panel,
-1, NULL, NULL, NULL);
}
+void
+bus_panel_proxy_set_content_type (BusPanelProxy *panel,
+ guint purpose,
+ guint hints)
+{
+ g_assert (BUS_IS_PANEL_PROXY (panel));
+
+ g_dbus_proxy_call ((GDBusProxy *)panel,
+ "ContentType",
+ g_variant_new ("(uu)", purpose, hints),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, NULL, NULL);
+}
+
#define DEFINE_FUNC(name) \
static void \
bus_panel_proxy_##name (BusPanelProxy *panel) \
@@ -663,6 +677,10 @@ bus_panel_proxy_focus_in (BusPanelProxy *panel,
input_context_signals[i].callback,
panel);
}
+
+ guint purpose, hints;
+ bus_input_context_get_content_type (context, &purpose, &hints);
+ bus_panel_proxy_set_content_type (panel, purpose, hints);
}
void
diff --git a/bus/panelproxy.h b/bus/panelproxy.h
index ff7e5ceb..57cf9db3 100644
--- a/bus/panelproxy.h
+++ b/bus/panelproxy.h
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright (C) 2008-2013 Red Hat, Inc.
+ * Copyright (C) 2008-2014 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2014 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
@@ -109,6 +109,10 @@ void bus_panel_proxy_register_properties
void bus_panel_proxy_update_property
(BusPanelProxy *panel,
IBusProperty *prop);
+void bus_panel_proxy_set_content_type
+ (BusPanelProxy *panel,
+ guint purpose,
+ guint hints);
G_END_DECLS
#endif
diff --git a/src/ibuspanelservice.c b/src/ibuspanelservice.c
index ef3b9804..3a804032 100644
--- a/src/ibuspanelservice.c
+++ b/src/ibuspanelservice.c
@@ -1,8 +1,8 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (c) 2009-2013 Google Inc. All rights reserved.
- * Copyright (C) 2010-2013 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (c) 2009-2014 Google Inc. All rights reserved.
+ * Copyright (C) 2010-2014 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
@@ -49,6 +49,7 @@ enum {
START_SETUP,
STATE_CHANGED,
DESTROY_CONTEXT,
+ SET_CONTENT_TYPE,
LAST_SIGNAL,
};
@@ -133,6 +134,10 @@ static void ibus_panel_service_update_preedit_text
static void ibus_panel_service_update_property
(IBusPanelService *panel,
IBusProperty *prop);
+static void ibus_panel_service_set_content_type
+ (IBusPanelService *panel,
+ guint purpose,
+ guint hints);
G_DEFINE_TYPE (IBusPanelService, ibus_panel_service, IBUS_TYPE_SERVICE)
@@ -189,6 +194,10 @@ static const gchar introspection_xml[] =
" <method name='StateChanged' />"
" <method name='HideLanguageBar' />"
" <method name='ShowLanguageBar' />"
+ " <method name='ContentType'>"
+ " <arg direction='in' type='u' name='purpose' />"
+ " <arg direction='in' type='u' name='hints' />"
+ " </method>"
/* Signals */
" <signal name='CursorUp' />"
" <signal name='CursorDown' />"
@@ -246,6 +255,7 @@ ibus_panel_service_class_init (IBusPanelServiceClass *class)
class->update_auxiliary_text = ibus_panel_service_update_auxiliary_text;
class->update_preedit_text = ibus_panel_service_update_preedit_text;
class->update_property = ibus_panel_service_update_property;
+ class->set_content_type = ibus_panel_service_set_content_type;
class->cursor_down_lookup_table = ibus_panel_service_not_implemented;
class->cursor_up_lookup_table = ibus_panel_service_not_implemented;
@@ -784,6 +794,31 @@ ibus_panel_service_class_init (IBusPanelServiceClass *class)
G_TYPE_NONE,
1,
G_TYPE_STRING);
+
+ /**
+ * IBusPanelService::set-content-type:
+ * @panel: An #IBusPanelService
+ * @purpose: Input purpose.
+ * @hints: Input hints.
+ *
+ * Emitted when the client application get the set-content-type.
+ * Implement the member function set_content_type() in extended class to
+ * receive this signal.
+ *
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
+ */
+ panel_signals[SET_CONTENT_TYPE] =
+ g_signal_new (I_("set-content-type"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IBusPanelServiceClass, set_content_type),
+ NULL, NULL,
+ _ibus_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_UINT,
+ G_TYPE_UINT);
}
static void
@@ -951,6 +986,15 @@ ibus_panel_service_service_method_call (IBusService *service,
return;
}
+ if (g_strcmp0 (method_name, "ContentType") == 0) {
+ guint purpose, hints;
+ g_variant_get (parameters, "(uu)", &purpose, &hints);
+ g_signal_emit (panel, panel_signals[SET_CONTENT_TYPE], 0,
+ purpose, hints);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ return;
+ }
+
const static struct {
const gchar *name;
const gint signal_id;
@@ -1104,6 +1148,14 @@ ibus_panel_service_update_property (IBusPanelService *panel,
ibus_panel_service_not_implemented(panel);
}
+static void
+ibus_panel_service_set_content_type (IBusPanelService *panel,
+ guint purpose,
+ guint hints)
+{
+ ibus_panel_service_not_implemented(panel);
+}
+
IBusPanelService *
ibus_panel_service_new (GDBusConnection *connection)
{
diff --git a/src/ibuspanelservice.h b/src/ibuspanelservice.h
index e88a3a77..0399a2f3 100644
--- a/src/ibuspanelservice.h
+++ b/src/ibuspanelservice.h
@@ -1,7 +1,7 @@
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (c) 2009-2013 Google Inc. All rights reserved.
+ * Copyright (c) 2009-2014 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -118,10 +118,13 @@ struct _IBusPanelServiceClass {
void (* destroy_context) (IBusPanelService *panel,
const gchar
*input_context_path);
+ void (* set_content_type) (IBusPanelService *panel,
+ guint purpose,
+ guint hints);
/*< private >*/
/* padding */
- gpointer pdummy[7]; // We can add 8 pointers without breaking the ABI.
+ gpointer pdummy[6]; // We can add 8 pointers without breaking the ABI.
};
GType ibus_panel_service_get_type (void);