Fix some mistakes.
This commit is contained in:
@ -115,10 +115,8 @@ eekboard_client_class_init (EekboardClientClass *klass)
|
||||
static void
|
||||
eekboard_client_init (EekboardClient *self)
|
||||
{
|
||||
EekboardClientPrivate *priv;
|
||||
|
||||
priv = self->priv = EEKBOARD_CLIENT_GET_PRIVATE(self);
|
||||
priv->context_hash =
|
||||
self->priv = EEKBOARD_CLIENT_GET_PRIVATE(self);
|
||||
self->priv->context_hash =
|
||||
g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
(GDestroyNotify)g_free,
|
||||
@ -191,9 +189,7 @@ on_context_destroyed (EekboardContext *context,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardClient *client = user_data;
|
||||
EekboardClientPrivate *priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
||||
|
||||
g_hash_table_remove (priv->context_hash,
|
||||
g_hash_table_remove (client->priv->context_hash,
|
||||
g_dbus_proxy_get_object_path (G_DBUS_PROXY(context)));
|
||||
}
|
||||
|
||||
@ -215,7 +211,6 @@ eekboard_client_create_context (EekboardClient *client,
|
||||
GVariant *variant;
|
||||
const gchar *object_path;
|
||||
EekboardContext *context;
|
||||
EekboardClientPrivate *priv;
|
||||
GError *error;
|
||||
GDBusConnection *connection;
|
||||
|
||||
@ -244,8 +239,7 @@ eekboard_client_create_context (EekboardClient *client,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
||||
g_hash_table_insert (priv->context_hash,
|
||||
g_hash_table_insert (client->priv->context_hash,
|
||||
g_strdup (object_path),
|
||||
g_object_ref (context));
|
||||
g_signal_connect (context, "destroyed",
|
||||
@ -285,7 +279,6 @@ eekboard_client_push_context (EekboardClient *client,
|
||||
EekboardContext *context,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardClientPrivate *priv;
|
||||
const gchar *object_path;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
||||
@ -293,8 +286,8 @@ eekboard_client_push_context (EekboardClient *client,
|
||||
|
||||
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
||||
|
||||
priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
||||
context = g_hash_table_lookup (priv->context_hash, object_path);
|
||||
context = g_hash_table_lookup (client->priv->context_hash,
|
||||
object_path);
|
||||
if (!context)
|
||||
return;
|
||||
|
||||
@ -364,15 +357,13 @@ eekboard_client_destroy_context (EekboardClient *client,
|
||||
EekboardContext *context,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardClientPrivate *priv;
|
||||
const gchar *object_path;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
||||
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
||||
g_hash_table_remove (priv->context_hash, object_path);
|
||||
g_hash_table_remove (client->priv->context_hash, object_path);
|
||||
|
||||
send_destroy_context (client, context, cancellable);
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ eekboard_context_service_real_create_keyboard (EekboardContextService *self,
|
||||
error = NULL;
|
||||
layout = eek_xml_layout_new (keyboard_type, &error);
|
||||
if (layout == NULL) {
|
||||
g_warning ("can't create keyboard: %s",
|
||||
g_warning ("can't create keyboard %s: %s",
|
||||
keyboard_type, error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
@ -206,41 +206,40 @@ eekboard_context_service_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
GDBusConnection *connection;
|
||||
gboolean was_visible;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_OBJECT_PATH:
|
||||
if (priv->object_path)
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = g_strdup (g_value_get_string (value));
|
||||
if (context->priv->object_path)
|
||||
g_free (context->priv->object_path);
|
||||
context->priv->object_path = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CONNECTION:
|
||||
connection = g_value_get_object (value);
|
||||
if (priv->connection)
|
||||
g_object_unref (priv->connection);
|
||||
priv->connection = g_object_ref (connection);
|
||||
if (context->priv->connection)
|
||||
g_object_unref (context->priv->connection);
|
||||
context->priv->connection = g_object_ref (connection);
|
||||
break;
|
||||
case PROP_CLIENT_NAME:
|
||||
if (priv->client_name)
|
||||
g_free (priv->client_name);
|
||||
priv->client_name = g_strdup (g_value_get_string (value));
|
||||
if (context->priv->client_name)
|
||||
g_free (context->priv->client_name);
|
||||
context->priv->client_name = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_KEYBOARD:
|
||||
if (priv->keyboard)
|
||||
g_object_unref (priv->keyboard);
|
||||
priv->keyboard = g_value_get_object (value);
|
||||
if (context->priv->keyboard)
|
||||
g_object_unref (context->priv->keyboard);
|
||||
context->priv->keyboard = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
was_visible = priv->visible;
|
||||
priv->visible = g_value_get_boolean (value);
|
||||
if (was_visible != priv->visible)
|
||||
emit_visibility_changed_signal (EEKBOARD_CONTEXT_SERVICE(object),
|
||||
priv->visible);
|
||||
was_visible = context->priv->visible;
|
||||
context->priv->visible = g_value_get_boolean (value);
|
||||
if (was_visible != context->priv->visible)
|
||||
emit_visibility_changed_signal (context,
|
||||
context->priv->visible);
|
||||
break;
|
||||
case PROP_FULLSCREEN:
|
||||
priv->fullscreen = g_value_get_boolean (value);
|
||||
context->priv->fullscreen = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -255,26 +254,25 @@ eekboard_context_service_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_OBJECT_PATH:
|
||||
g_value_set_string (value, priv->object_path);
|
||||
g_value_set_string (value, context->priv->object_path);
|
||||
break;
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_object (value, priv->connection);
|
||||
g_value_set_object (value, context->priv->connection);
|
||||
break;
|
||||
case PROP_CLIENT_NAME:
|
||||
g_value_set_string (value, priv->client_name);
|
||||
g_value_set_string (value, context->priv->client_name);
|
||||
break;
|
||||
case PROP_KEYBOARD:
|
||||
g_value_set_object (value, priv->keyboard);
|
||||
g_value_set_object (value, context->priv->keyboard);
|
||||
break;
|
||||
case PROP_VISIBLE:
|
||||
g_value_set_boolean (value, priv->visible);
|
||||
g_value_set_boolean (value, context->priv->visible);
|
||||
break;
|
||||
case PROP_FULLSCREEN:
|
||||
g_value_set_boolean (value, priv->fullscreen);
|
||||
g_value_set_boolean (value, context->priv->fullscreen);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -286,63 +284,61 @@ static void
|
||||
eekboard_context_service_dispose (GObject *object)
|
||||
{
|
||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (priv->keyboard_hash) {
|
||||
g_hash_table_destroy (priv->keyboard_hash);
|
||||
priv->keyboard_hash = NULL;
|
||||
if (context->priv->keyboard_hash) {
|
||||
g_hash_table_destroy (context->priv->keyboard_hash);
|
||||
context->priv->keyboard_hash = NULL;
|
||||
}
|
||||
|
||||
if (priv->connection) {
|
||||
if (priv->registration_id > 0) {
|
||||
g_dbus_connection_unregister_object (priv->connection,
|
||||
priv->registration_id);
|
||||
priv->registration_id = 0;
|
||||
if (context->priv->connection) {
|
||||
if (context->priv->registration_id > 0) {
|
||||
g_dbus_connection_unregister_object (context->priv->connection,
|
||||
context->priv->registration_id);
|
||||
context->priv->registration_id = 0;
|
||||
}
|
||||
|
||||
g_object_unref (priv->connection);
|
||||
priv->connection = NULL;
|
||||
g_object_unref (context->priv->connection);
|
||||
context->priv->connection = NULL;
|
||||
}
|
||||
|
||||
if (priv->introspection_data) {
|
||||
g_dbus_node_info_unref (priv->introspection_data);
|
||||
priv->introspection_data = NULL;
|
||||
if (context->priv->introspection_data) {
|
||||
g_dbus_node_info_unref (context->priv->introspection_data);
|
||||
context->priv->introspection_data = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (eekboard_context_service_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (eekboard_context_service_parent_class)->
|
||||
dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_context_service_finalize (GObject *object)
|
||||
{
|
||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
g_free (priv->object_path);
|
||||
g_free (priv->client_name);
|
||||
g_free (context->priv->object_path);
|
||||
g_free (context->priv->client_name);
|
||||
|
||||
G_OBJECT_CLASS (eekboard_context_service_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (eekboard_context_service_parent_class)->
|
||||
finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_context_service_constructed (GObject *object)
|
||||
{
|
||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE (object);
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (priv->connection && priv->object_path) {
|
||||
if (context->priv->connection && context->priv->object_path) {
|
||||
GError *error = NULL;
|
||||
|
||||
priv->registration_id = g_dbus_connection_register_object
|
||||
(priv->connection,
|
||||
priv->object_path,
|
||||
priv->introspection_data->interfaces[0],
|
||||
context->priv->registration_id = g_dbus_connection_register_object
|
||||
(context->priv->connection,
|
||||
context->priv->object_path,
|
||||
context->priv->introspection_data->interfaces[0],
|
||||
&interface_vtable,
|
||||
context,
|
||||
NULL,
|
||||
&error);
|
||||
|
||||
if (priv->registration_id == 0) {
|
||||
if (context->priv->registration_id == 0) {
|
||||
g_warning ("failed to register context object: %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
@ -489,57 +485,53 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_context_service_init (EekboardContextService *context)
|
||||
eekboard_context_service_init (EekboardContextService *self)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
GError *error;
|
||||
|
||||
self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self);
|
||||
error = NULL;
|
||||
priv->introspection_data =
|
||||
self->priv->introspection_data =
|
||||
g_dbus_node_info_new_for_xml (introspection_xml, &error);
|
||||
if (priv->introspection_data == NULL) {
|
||||
if (self->priv->introspection_data == NULL) {
|
||||
g_warning ("failed to parse D-Bus XML: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
priv->keyboard_hash =
|
||||
self->priv->keyboard_hash =
|
||||
g_hash_table_new_full (g_direct_hash,
|
||||
g_direct_equal,
|
||||
NULL,
|
||||
(GDestroyNotify)g_object_unref);
|
||||
|
||||
priv->settings = g_settings_new ("org.fedorahosted.eekboard");
|
||||
self->priv->settings = g_settings_new ("org.fedorahosted.eekboard");
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_keyboard_signals (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (g_signal_handler_is_connected (priv->keyboard,
|
||||
priv->key_pressed_handler))
|
||||
g_signal_handler_disconnect (priv->keyboard,
|
||||
priv->key_pressed_handler);
|
||||
if (g_signal_handler_is_connected (priv->keyboard,
|
||||
priv->key_released_handler))
|
||||
g_signal_handler_disconnect (priv->keyboard,
|
||||
priv->key_released_handler);
|
||||
if (g_signal_handler_is_connected (context->priv->keyboard,
|
||||
context->priv->key_pressed_handler))
|
||||
g_signal_handler_disconnect (context->priv->keyboard,
|
||||
context->priv->key_pressed_handler);
|
||||
if (g_signal_handler_is_connected (context->priv->keyboard,
|
||||
context->priv->key_released_handler))
|
||||
g_signal_handler_disconnect (context->priv->keyboard,
|
||||
context->priv->key_released_handler);
|
||||
}
|
||||
|
||||
static void
|
||||
emit_visibility_changed_signal (EekboardContextService *context,
|
||||
gboolean visible)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (priv->connection && priv->enabled) {
|
||||
if (context->priv->connection && context->priv->enabled) {
|
||||
GError *error = NULL;
|
||||
gboolean retval;
|
||||
|
||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
||||
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||
NULL,
|
||||
priv->object_path,
|
||||
context->priv->object_path,
|
||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||
"VisibilityChanged",
|
||||
g_variant_new ("(b)", visible),
|
||||
@ -557,15 +549,13 @@ static void
|
||||
emit_group_changed_signal (EekboardContextService *context,
|
||||
gint group)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (priv->connection && priv->enabled) {
|
||||
if (context->priv->connection && context->priv->enabled) {
|
||||
GError *error = NULL;
|
||||
gboolean retval;
|
||||
|
||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
||||
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||
NULL,
|
||||
priv->object_path,
|
||||
context->priv->object_path,
|
||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||
"GroupChanged",
|
||||
g_variant_new ("(i)", group),
|
||||
@ -583,12 +573,10 @@ static void
|
||||
emit_key_activated_dbus_signal (EekboardContextService *context,
|
||||
EekKey *key)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (priv->connection && priv->enabled) {
|
||||
if (context->priv->connection && context->priv->enabled) {
|
||||
const gchar *keyname = eek_element_get_name (EEK_ELEMENT(key));
|
||||
EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
|
||||
guint modifiers = eek_keyboard_get_modifiers (priv->keyboard);
|
||||
guint modifiers = eek_keyboard_get_modifiers (context->priv->keyboard);
|
||||
GVariant *variant;
|
||||
GError *error;
|
||||
gboolean retval;
|
||||
@ -596,9 +584,9 @@ emit_key_activated_dbus_signal (EekboardContextService *context,
|
||||
variant = eek_serializable_serialize (EEK_SERIALIZABLE(symbol));
|
||||
|
||||
error = NULL;
|
||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
||||
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||
NULL,
|
||||
priv->object_path,
|
||||
context->priv->object_path,
|
||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||
"KeyActivated",
|
||||
g_variant_new ("(svu)",
|
||||
@ -606,7 +594,6 @@ emit_key_activated_dbus_signal (EekboardContextService *context,
|
||||
variant,
|
||||
modifiers),
|
||||
&error);
|
||||
g_variant_unref (variant);
|
||||
if (!retval) {
|
||||
g_warning ("failed to emit KeyActivated signal: %s",
|
||||
error->message);
|
||||
@ -621,14 +608,13 @@ static gboolean on_repeat_timeout (EekboardContextService *context);
|
||||
static gboolean
|
||||
on_repeat_timeout (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
guint delay;
|
||||
|
||||
g_settings_get (priv->settings, "repeat-interval", "u", &delay);
|
||||
g_settings_get (context->priv->settings, "repeat-interval", "u", &delay);
|
||||
|
||||
emit_key_activated_dbus_signal (context, priv->repeat_key);
|
||||
emit_key_activated_dbus_signal (context, context->priv->repeat_key);
|
||||
|
||||
priv->repeat_timeout_id =
|
||||
context->priv->repeat_timeout_id =
|
||||
g_timeout_add (delay,
|
||||
(GSourceFunc)on_repeat_timeout,
|
||||
context);
|
||||
@ -639,25 +625,23 @@ on_repeat_timeout (EekboardContextService *context)
|
||||
static gboolean
|
||||
on_repeat_timeout_init (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
emit_key_activated_dbus_signal (context, priv->repeat_key);
|
||||
emit_key_activated_dbus_signal (context, context->priv->repeat_key);
|
||||
|
||||
/* FIXME: clear modifiers for further key repeat; better not
|
||||
depend on modifier behavior is LATCH */
|
||||
eek_keyboard_set_modifiers (priv->keyboard, 0);
|
||||
eek_keyboard_set_modifiers (context->priv->keyboard, 0);
|
||||
|
||||
/* reschedule repeat timeout only when "repeat" option is set */
|
||||
if (g_settings_get_boolean (priv->settings, "repeat")) {
|
||||
if (g_settings_get_boolean (context->priv->settings, "repeat")) {
|
||||
guint delay;
|
||||
|
||||
g_settings_get (priv->settings, "repeat-interval", "u", &delay);
|
||||
priv->repeat_timeout_id =
|
||||
g_settings_get (context->priv->settings, "repeat-interval", "u", &delay);
|
||||
context->priv->repeat_timeout_id =
|
||||
g_timeout_add (delay,
|
||||
(GSourceFunc)on_repeat_timeout,
|
||||
context);
|
||||
} else
|
||||
priv->repeat_timeout_id = 0;
|
||||
context->priv->repeat_timeout_id = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -668,18 +652,17 @@ on_key_pressed (EekKeyboard *keyboard,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardContextService *context = user_data;
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
guint delay;
|
||||
|
||||
g_settings_get (priv->settings, "repeat-delay", "u", &delay);
|
||||
g_settings_get (context->priv->settings, "repeat-delay", "u", &delay);
|
||||
|
||||
if (priv->repeat_timeout_id) {
|
||||
g_source_remove (priv->repeat_timeout_id);
|
||||
priv->repeat_timeout_id = 0;
|
||||
if (context->priv->repeat_timeout_id) {
|
||||
g_source_remove (context->priv->repeat_timeout_id);
|
||||
context->priv->repeat_timeout_id = 0;
|
||||
}
|
||||
|
||||
priv->repeat_key = key;
|
||||
priv->repeat_timeout_id =
|
||||
context->priv->repeat_key = key;
|
||||
context->priv->repeat_timeout_id =
|
||||
g_timeout_add (delay,
|
||||
(GSourceFunc)on_repeat_timeout_init,
|
||||
context);
|
||||
@ -691,28 +674,26 @@ on_key_released (EekKeyboard *keyboard,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardContextService *context = user_data;
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
if (priv->repeat_timeout_id > 0) {
|
||||
g_source_remove (priv->repeat_timeout_id);
|
||||
priv->repeat_timeout_id = 0;
|
||||
if (context->priv->repeat_timeout_id > 0) {
|
||||
g_source_remove (context->priv->repeat_timeout_id);
|
||||
context->priv->repeat_timeout_id = 0;
|
||||
|
||||
/* KeyActivated signal has not been emitted in repeat handler */
|
||||
emit_key_activated_dbus_signal (context, priv->repeat_key);
|
||||
emit_key_activated_dbus_signal (context,
|
||||
context->priv->repeat_key);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
connect_keyboard_signals (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
|
||||
priv->key_pressed_handler =
|
||||
g_signal_connect (priv->keyboard, "key-pressed",
|
||||
context->priv->key_pressed_handler =
|
||||
g_signal_connect (context->priv->keyboard, "key-pressed",
|
||||
G_CALLBACK(on_key_pressed),
|
||||
context);
|
||||
priv->key_released_handler =
|
||||
g_signal_connect (priv->keyboard, "key-released",
|
||||
context->priv->key_released_handler =
|
||||
g_signal_connect (context->priv->keyboard, "key-released",
|
||||
G_CALLBACK(on_key_released),
|
||||
context);
|
||||
}
|
||||
@ -728,7 +709,6 @@ handle_method_call (GDBusConnection *connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardContextService *context = user_data;
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context);
|
||||
|
||||
if (g_strcmp0 (method_name, "AddKeyboard") == 0) {
|
||||
@ -751,7 +731,7 @@ handle_method_call (GDBusConnection *connection,
|
||||
EEK_MODIFIER_BEHAVIOR_LATCH);
|
||||
|
||||
keyboard_id++;
|
||||
g_hash_table_insert (priv->keyboard_hash,
|
||||
g_hash_table_insert (context->priv->keyboard_hash,
|
||||
GUINT_TO_POINTER(keyboard_id),
|
||||
keyboard);
|
||||
g_object_set_data (G_OBJECT(keyboard),
|
||||
@ -769,15 +749,15 @@ handle_method_call (GDBusConnection *connection,
|
||||
g_variant_get (parameters, "(u)", &keyboard_id);
|
||||
|
||||
current_keyboard_id =
|
||||
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT(priv->keyboard),
|
||||
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT(context->priv->keyboard),
|
||||
"keyboard-id"));
|
||||
if (keyboard_id == current_keyboard_id) {
|
||||
disconnect_keyboard_signals (context);
|
||||
priv->keyboard = NULL;
|
||||
context->priv->keyboard = NULL;
|
||||
g_object_notify (G_OBJECT(context), "keyboard");
|
||||
}
|
||||
|
||||
g_hash_table_remove (priv->keyboard_hash,
|
||||
g_hash_table_remove (context->priv->keyboard_hash,
|
||||
GUINT_TO_POINTER(keyboard_id));
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
return;
|
||||
@ -790,7 +770,7 @@ handle_method_call (GDBusConnection *connection,
|
||||
|
||||
g_variant_get (parameters, "(u)", &keyboard_id);
|
||||
|
||||
keyboard = g_hash_table_lookup (priv->keyboard_hash,
|
||||
keyboard = g_hash_table_lookup (context->priv->keyboard_hash,
|
||||
GUINT_TO_POINTER(keyboard_id));
|
||||
if (!keyboard) {
|
||||
g_dbus_method_invocation_return_error (invocation,
|
||||
@ -800,20 +780,20 @@ handle_method_call (GDBusConnection *connection,
|
||||
return;
|
||||
}
|
||||
|
||||
if (keyboard == priv->keyboard) {
|
||||
if (keyboard == context->priv->keyboard) {
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->keyboard)
|
||||
if (context->priv->keyboard)
|
||||
disconnect_keyboard_signals (context);
|
||||
|
||||
priv->keyboard = keyboard;
|
||||
context->priv->keyboard = keyboard;
|
||||
connect_keyboard_signals (context);
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
|
||||
group = eek_element_get_group (EEK_ELEMENT(priv->keyboard));
|
||||
group = eek_element_get_group (EEK_ELEMENT(context->priv->keyboard));
|
||||
emit_group_changed_signal (context, group);
|
||||
|
||||
g_object_notify (G_OBJECT(context), "keyboard");
|
||||
@ -825,11 +805,11 @@ handle_method_call (GDBusConnection *connection,
|
||||
|
||||
g_variant_get (parameters, "(b)", &fullscreen);
|
||||
|
||||
if (priv->fullscreen == fullscreen) {
|
||||
if (context->priv->fullscreen == fullscreen) {
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
return;
|
||||
}
|
||||
priv->fullscreen = fullscreen;
|
||||
context->priv->fullscreen = fullscreen;
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
|
||||
g_object_notify (G_OBJECT(context), "fullscreen");
|
||||
@ -839,7 +819,7 @@ handle_method_call (GDBusConnection *connection,
|
||||
if (g_strcmp0 (method_name, "SetGroup") == 0) {
|
||||
gint group;
|
||||
|
||||
if (!priv->keyboard) {
|
||||
if (!context->priv->keyboard) {
|
||||
g_dbus_method_invocation_return_error (invocation,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED_HANDLED,
|
||||
@ -848,14 +828,14 @@ handle_method_call (GDBusConnection *connection,
|
||||
}
|
||||
|
||||
g_variant_get (parameters, "(i)", &group);
|
||||
eek_element_set_group (EEK_ELEMENT(priv->keyboard), group);
|
||||
eek_element_set_group (EEK_ELEMENT(context->priv->keyboard), group);
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
emit_group_changed_signal (context, group);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (method_name, "ShowKeyboard") == 0) {
|
||||
if (!priv->keyboard) {
|
||||
if (!context->priv->keyboard) {
|
||||
g_dbus_method_invocation_return_error (invocation,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED_HANDLED,
|
||||
@ -881,7 +861,7 @@ handle_method_call (GDBusConnection *connection,
|
||||
EekKey *key;
|
||||
guint keycode;
|
||||
|
||||
if (!priv->keyboard) {
|
||||
if (!context->priv->keyboard) {
|
||||
g_dbus_method_invocation_return_error (invocation,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED_HANDLED,
|
||||
@ -890,7 +870,7 @@ handle_method_call (GDBusConnection *connection,
|
||||
}
|
||||
|
||||
g_variant_get (parameters, "(u)", &keycode);
|
||||
key = eek_keyboard_find_key_by_keycode (priv->keyboard, keycode);
|
||||
key = eek_keyboard_find_key_by_keycode (context->priv->keyboard, keycode);
|
||||
|
||||
if (!key) {
|
||||
g_dbus_method_invocation_return_error (invocation,
|
||||
@ -902,17 +882,17 @@ handle_method_call (GDBusConnection *connection,
|
||||
}
|
||||
|
||||
if (g_strcmp0 (method_name, "PressKeycode") == 0) {
|
||||
g_signal_handler_block (priv->keyboard,
|
||||
priv->key_pressed_handler);
|
||||
g_signal_handler_block (context->priv->keyboard,
|
||||
context->priv->key_pressed_handler);
|
||||
g_signal_emit_by_name (key, "pressed");
|
||||
g_signal_handler_unblock (priv->keyboard,
|
||||
priv->key_pressed_handler);
|
||||
g_signal_handler_unblock (context->priv->keyboard,
|
||||
context->priv->key_pressed_handler);
|
||||
} else {
|
||||
g_signal_handler_block (priv->keyboard,
|
||||
priv->key_released_handler);
|
||||
g_signal_handler_block (context->priv->keyboard,
|
||||
context->priv->key_released_handler);
|
||||
g_signal_emit_by_name (key, "released");
|
||||
g_signal_handler_unblock (priv->keyboard,
|
||||
priv->key_released_handler);
|
||||
g_signal_handler_unblock (context->priv->keyboard,
|
||||
context->priv->key_released_handler);
|
||||
}
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
@ -932,21 +912,20 @@ handle_method_call (GDBusConnection *connection,
|
||||
void
|
||||
eekboard_context_service_enable (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
GError *error;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
||||
g_return_if_fail (priv->connection);
|
||||
g_return_if_fail (context->priv->connection);
|
||||
|
||||
if (!priv->enabled) {
|
||||
if (!context->priv->enabled) {
|
||||
gboolean retval;
|
||||
|
||||
priv->enabled = TRUE;
|
||||
context->priv->enabled = TRUE;
|
||||
|
||||
error = NULL;
|
||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
||||
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||
NULL,
|
||||
priv->object_path,
|
||||
context->priv->object_path,
|
||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||
"Enabled",
|
||||
NULL,
|
||||
@ -957,7 +936,7 @@ eekboard_context_service_enable (EekboardContextService *context)
|
||||
g_error_free (error);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
g_signal_emit_by_name (context, "enabled", NULL);
|
||||
g_signal_emit (context, signals[ENABLED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -971,21 +950,20 @@ eekboard_context_service_enable (EekboardContextService *context)
|
||||
void
|
||||
eekboard_context_service_disable (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
GError *error;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
||||
g_return_if_fail (priv->connection);
|
||||
g_return_if_fail (context->priv->connection);
|
||||
|
||||
if (priv->enabled) {
|
||||
if (context->priv->enabled) {
|
||||
gboolean retval;
|
||||
|
||||
priv->enabled = FALSE;
|
||||
context->priv->enabled = FALSE;
|
||||
|
||||
error = NULL;
|
||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
||||
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||
NULL,
|
||||
priv->object_path,
|
||||
context->priv->object_path,
|
||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||
"Disabled",
|
||||
NULL,
|
||||
@ -996,7 +974,7 @@ eekboard_context_service_disable (EekboardContextService *context)
|
||||
g_error_free (error);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
g_signal_emit_by_name (context, "disabled", NULL);
|
||||
g_signal_emit (context, signals[DISABLED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1010,8 +988,7 @@ eekboard_context_service_disable (EekboardContextService *context)
|
||||
EekKeyboard *
|
||||
eekboard_context_service_get_keyboard (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
return priv->keyboard;
|
||||
return context->priv->keyboard;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1024,8 +1001,7 @@ eekboard_context_service_get_keyboard (EekboardContextService *context)
|
||||
gboolean
|
||||
eekboard_context_service_get_fullscreen (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
return priv->fullscreen;
|
||||
return context->priv->fullscreen;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1038,6 +1014,5 @@ eekboard_context_service_get_fullscreen (EekboardContextService *context)
|
||||
const gchar *
|
||||
eekboard_context_service_get_client_name (EekboardContextService *context)
|
||||
{
|
||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
||||
return priv->client_name;
|
||||
return context->priv->client_name;
|
||||
}
|
||||
|
||||
@ -69,15 +69,14 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
GVariant *parameters)
|
||||
{
|
||||
EekboardContext *context = EEKBOARD_CONTEXT (self);
|
||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
|
||||
if (g_strcmp0 (signal_name, "Enabled") == 0) {
|
||||
g_signal_emit_by_name (context, "enabled");
|
||||
g_signal_emit (context, signals[ENABLED], 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (signal_name, "Disabled") == 0) {
|
||||
g_signal_emit_by_name (context, "disabled");
|
||||
g_signal_emit (context, signals[DISABLED], 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -87,7 +86,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
guint modifiers = 0;
|
||||
EekSerializable *serializable;
|
||||
|
||||
g_variant_get (parameters, "(&svu)", &keyname, &variant, &modifiers);
|
||||
g_variant_get (parameters, "(&svu)",
|
||||
&keyname, &variant, &modifiers);
|
||||
g_return_if_fail (variant != NULL);
|
||||
|
||||
serializable = eek_serializable_deserialize (variant);
|
||||
@ -95,8 +95,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
|
||||
g_return_if_fail (EEK_IS_SYMBOL(serializable));
|
||||
|
||||
g_signal_emit_by_name (context, "key-pressed",
|
||||
keyname, EEK_SYMBOL(serializable), modifiers);
|
||||
g_signal_emit (context, signals[KEY_PRESSED], 0,
|
||||
keyname, EEK_SYMBOL(serializable), modifiers);
|
||||
g_object_unref (serializable);
|
||||
|
||||
return;
|
||||
@ -106,8 +106,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
gboolean visible = FALSE;
|
||||
|
||||
g_variant_get (parameters, "(b)", &visible);
|
||||
if (visible != priv->visible) {
|
||||
priv->visible = visible;
|
||||
if (visible != context->priv->visible) {
|
||||
context->priv->visible = visible;
|
||||
g_object_notify (G_OBJECT(context), "visible");
|
||||
}
|
||||
return;
|
||||
@ -117,9 +117,9 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
gint group = 0;
|
||||
|
||||
g_variant_get (parameters, "(i)", &group);
|
||||
if (group != priv->group) {
|
||||
priv->group = group;
|
||||
//g_object_notify (G_OBJECT(context), "group");
|
||||
if (group != context->priv->group) {
|
||||
context->priv->group = group;
|
||||
/* g_object_notify (G_OBJECT(context), "group"); */
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -130,15 +130,13 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
||||
static void
|
||||
eekboard_context_real_enabled (EekboardContext *self)
|
||||
{
|
||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
|
||||
priv->enabled = TRUE;
|
||||
self->priv->enabled = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_context_real_disabled (EekboardContext *self)
|
||||
{
|
||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
|
||||
priv->enabled = FALSE;
|
||||
self->priv->enabled = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -160,15 +158,13 @@ eekboard_context_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(object);
|
||||
EekboardContext *context = EEKBOARD_CONTEXT(object);
|
||||
switch (prop_id) {
|
||||
case PROP_VISIBLE:
|
||||
g_value_set_boolean (value, priv->visible);
|
||||
g_value_set_boolean (value, context->priv->visible);
|
||||
break;
|
||||
default:
|
||||
g_object_get_property (object,
|
||||
g_param_spec_get_name (pspec),
|
||||
value);
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -295,7 +291,7 @@ context_name_vanished_callback (GDBusConnection *connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardContext *context = user_data;
|
||||
g_signal_emit_by_name (context, "destroyed", NULL);
|
||||
g_signal_emit (context, signals[DESTROYED], 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,8 +312,8 @@ eekboard_context_new (GDBusConnection *connection,
|
||||
GInitable *initable;
|
||||
GError *error;
|
||||
|
||||
g_assert (object_path != NULL);
|
||||
g_assert (G_IS_DBUS_CONNECTION(connection));
|
||||
g_return_val_if_fail (object_path != NULL, NULL);
|
||||
g_return_val_if_fail (G_IS_DBUS_CONNECTION(connection), NULL);
|
||||
|
||||
error = NULL;
|
||||
initable =
|
||||
@ -481,13 +477,9 @@ eekboard_context_set_group (EekboardContext *context,
|
||||
gint group,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
|
||||
if (priv->group != group) {
|
||||
if (context->priv->group != group) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"SetGroup",
|
||||
g_variant_new ("(i)", group),
|
||||
@ -510,12 +502,8 @@ gint
|
||||
eekboard_context_get_group (EekboardContext *context,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), 0);
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
return priv->group;
|
||||
return context->priv->group;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -530,22 +518,18 @@ void
|
||||
eekboard_context_show_keyboard (EekboardContext *context,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
if (!priv->enabled)
|
||||
return;
|
||||
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"ShowKeyboard",
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
if (context->priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"ShowKeyboard",
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -559,22 +543,18 @@ void
|
||||
eekboard_context_hide_keyboard (EekboardContext *context,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
if (!priv->enabled)
|
||||
return;
|
||||
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"HideKeyboard",
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
if (context->priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"HideKeyboard",
|
||||
NULL,
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -590,22 +570,18 @@ eekboard_context_press_keycode (EekboardContext *context,
|
||||
guint keycode,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
if (!priv->enabled)
|
||||
return;
|
||||
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"PressKeycode",
|
||||
g_variant_new ("(u)", keycode),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
if (context->priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"PressKeycode",
|
||||
g_variant_new ("(u)", keycode),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -621,22 +597,18 @@ eekboard_context_release_keycode (EekboardContext *context,
|
||||
guint keycode,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
if (!priv->enabled)
|
||||
return;
|
||||
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"ReleaseKeycode",
|
||||
g_variant_new ("(u)", keycode),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
if (context->priv->enabled) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"ReleaseKeycode",
|
||||
g_variant_new ("(u)", keycode),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
cancellable,
|
||||
context_async_ready_callback,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -648,12 +620,8 @@ eekboard_context_release_keycode (EekboardContext *context,
|
||||
gboolean
|
||||
eekboard_context_is_visible (EekboardContext *context)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_assert (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
return priv->enabled && priv->visible;
|
||||
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), FALSE);
|
||||
return context->priv->enabled && context->priv->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -669,12 +637,8 @@ void
|
||||
eekboard_context_set_enabled (EekboardContext *context,
|
||||
gboolean enabled)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_assert (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
priv->enabled = enabled;
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
context->priv->enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -686,12 +650,8 @@ eekboard_context_set_enabled (EekboardContext *context,
|
||||
gboolean
|
||||
eekboard_context_is_enabled (EekboardContext *context)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_assert (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
return priv->enabled;
|
||||
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), FALSE);
|
||||
return context->priv->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -707,12 +667,8 @@ eekboard_context_set_fullscreen (EekboardContext *context,
|
||||
gboolean fullscreen,
|
||||
GCancellable *cancellable)
|
||||
{
|
||||
EekboardContextPrivate *priv;
|
||||
|
||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||
|
||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
||||
if (priv->fullscreen != fullscreen) {
|
||||
if (context->priv->fullscreen != fullscreen) {
|
||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||
"SetFullscreen",
|
||||
g_variant_new ("(b)", fullscreen),
|
||||
|
||||
@ -101,20 +101,19 @@ eekboard_service_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
||||
GDBusConnection *connection;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_OBJECT_PATH:
|
||||
if (priv->object_path)
|
||||
g_free (priv->object_path);
|
||||
priv->object_path = g_strdup (g_value_get_string (value));
|
||||
if (service->priv->object_path)
|
||||
g_free (service->priv->object_path);
|
||||
service->priv->object_path = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CONNECTION:
|
||||
connection = g_value_get_object (value);
|
||||
if (priv->connection)
|
||||
g_object_unref (priv->connection);
|
||||
priv->connection = g_object_ref (connection);
|
||||
if (service->priv->connection)
|
||||
g_object_unref (service->priv->connection);
|
||||
service->priv->connection = g_object_ref (connection);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -129,14 +128,13 @@ eekboard_service_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_OBJECT_PATH:
|
||||
g_value_set_string (value, priv->object_path);
|
||||
g_value_set_string (value, service->priv->object_path);
|
||||
break;
|
||||
case PROP_CONNECTION:
|
||||
g_value_set_object (value, priv->connection);
|
||||
g_value_set_object (value, service->priv->connection);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -148,34 +146,33 @@ static void
|
||||
eekboard_service_dispose (GObject *object)
|
||||
{
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
||||
GSList *head;
|
||||
|
||||
if (priv->context_hash) {
|
||||
g_hash_table_destroy (priv->context_hash);
|
||||
priv->context_hash = NULL;
|
||||
if (service->priv->context_hash) {
|
||||
g_hash_table_destroy (service->priv->context_hash);
|
||||
service->priv->context_hash = NULL;
|
||||
}
|
||||
|
||||
for (head = priv->context_stack; head; head = priv->context_stack) {
|
||||
for (head = service->priv->context_stack; head; head = service->priv->context_stack) {
|
||||
g_object_unref (head->data);
|
||||
priv->context_stack = g_slist_next (head);
|
||||
service->priv->context_stack = g_slist_next (head);
|
||||
g_slist_free1 (head);
|
||||
}
|
||||
|
||||
if (priv->connection) {
|
||||
if (priv->registration_id > 0) {
|
||||
g_dbus_connection_unregister_object (priv->connection,
|
||||
priv->registration_id);
|
||||
priv->registration_id = 0;
|
||||
if (service->priv->connection) {
|
||||
if (service->priv->registration_id > 0) {
|
||||
g_dbus_connection_unregister_object (service->priv->connection,
|
||||
service->priv->registration_id);
|
||||
service->priv->registration_id = 0;
|
||||
}
|
||||
|
||||
g_object_unref (priv->connection);
|
||||
priv->connection = NULL;
|
||||
g_object_unref (service->priv->connection);
|
||||
service->priv->connection = NULL;
|
||||
}
|
||||
|
||||
if (priv->introspection_data) {
|
||||
g_dbus_node_info_unref (priv->introspection_data);
|
||||
priv->introspection_data = NULL;
|
||||
if (service->priv->introspection_data) {
|
||||
g_dbus_node_info_unref (service->priv->introspection_data);
|
||||
service->priv->introspection_data = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (eekboard_service_parent_class)->dispose (object);
|
||||
@ -184,9 +181,9 @@ eekboard_service_dispose (GObject *object)
|
||||
static void
|
||||
eekboard_service_finalize (GObject *object)
|
||||
{
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(object);
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
|
||||
g_free (priv->object_path);
|
||||
g_free (service->priv->object_path);
|
||||
|
||||
G_OBJECT_CLASS (eekboard_service_parent_class)->finalize (object);
|
||||
}
|
||||
@ -194,20 +191,20 @@ eekboard_service_finalize (GObject *object)
|
||||
static void
|
||||
eekboard_service_constructed (GObject *object)
|
||||
{
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(object);
|
||||
if (priv->connection && priv->object_path) {
|
||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||
if (service->priv->connection && service->priv->object_path) {
|
||||
GError *error = NULL;
|
||||
|
||||
priv->registration_id = g_dbus_connection_register_object
|
||||
(priv->connection,
|
||||
priv->object_path,
|
||||
priv->introspection_data->interfaces[0],
|
||||
service->priv->registration_id = g_dbus_connection_register_object
|
||||
(service->priv->connection,
|
||||
service->priv->object_path,
|
||||
service->priv->introspection_data->interfaces[0],
|
||||
&interface_vtable,
|
||||
object,
|
||||
NULL,
|
||||
&error);
|
||||
|
||||
if (priv->registration_id == 0) {
|
||||
if (service->priv->registration_id == 0) {
|
||||
g_warning ("failed to register context object: %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
@ -279,23 +276,22 @@ eekboard_service_class_init (EekboardServiceClass *klass)
|
||||
}
|
||||
|
||||
static void
|
||||
eekboard_service_init (EekboardService *service)
|
||||
eekboard_service_init (EekboardService *self)
|
||||
{
|
||||
EekboardServicePrivate *priv;
|
||||
GError *error;
|
||||
|
||||
priv = service->priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
||||
self->priv = EEKBOARD_SERVICE_GET_PRIVATE(self);
|
||||
|
||||
error = NULL;
|
||||
priv->introspection_data =
|
||||
self->priv->introspection_data =
|
||||
g_dbus_node_info_new_for_xml (introspection_xml, &error);
|
||||
if (priv->introspection_data == NULL) {
|
||||
if (self->priv->introspection_data == NULL) {
|
||||
g_warning ("failed to parse D-Bus XML: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
priv->context_hash =
|
||||
self->priv->context_hash =
|
||||
g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
(GDestroyNotify)g_free,
|
||||
@ -306,17 +302,16 @@ static void
|
||||
remove_context_from_stack (EekboardService *service,
|
||||
EekboardContextService *context)
|
||||
{
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
||||
GSList *head;
|
||||
|
||||
head = g_slist_find (priv->context_stack, context);
|
||||
head = g_slist_find (service->priv->context_stack, context);
|
||||
if (head) {
|
||||
priv->context_stack = g_slist_remove_link (priv->context_stack, head);
|
||||
service->priv->context_stack = g_slist_remove_link (service->priv->context_stack, head);
|
||||
g_object_unref (head->data);
|
||||
g_slist_free1 (head);
|
||||
}
|
||||
if (priv->context_stack)
|
||||
eekboard_context_service_enable (priv->context_stack->data);
|
||||
if (service->priv->context_stack)
|
||||
eekboard_context_service_enable (service->priv->context_stack->data);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -325,25 +320,24 @@ service_name_vanished_callback (GDBusConnection *connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardService *service = user_data;
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
||||
GSList *head;
|
||||
GHashTableIter iter;
|
||||
gpointer k, v;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->context_hash);
|
||||
g_hash_table_iter_init (&iter, service->priv->context_hash);
|
||||
while (g_hash_table_iter_next (&iter, &k, &v)) {
|
||||
const gchar *owner = g_object_get_data (G_OBJECT(v), "owner");
|
||||
if (g_strcmp0 (owner, name) == 0)
|
||||
g_hash_table_iter_remove (&iter);
|
||||
}
|
||||
|
||||
for (head = priv->context_stack; head; ) {
|
||||
for (head = service->priv->context_stack; head; ) {
|
||||
const gchar *owner = g_object_get_data (G_OBJECT(head->data), "owner");
|
||||
GSList *next = g_slist_next (head);
|
||||
|
||||
if (g_strcmp0 (owner, name) == 0) {
|
||||
priv->context_stack =
|
||||
g_slist_remove_link (priv->context_stack, head);
|
||||
service->priv->context_stack =
|
||||
g_slist_remove_link (service->priv->context_stack, head);
|
||||
g_object_unref (head->data);
|
||||
g_slist_free1 (head);
|
||||
}
|
||||
@ -351,8 +345,8 @@ service_name_vanished_callback (GDBusConnection *connection,
|
||||
head = next;
|
||||
}
|
||||
|
||||
if (priv->context_stack)
|
||||
eekboard_context_service_enable (priv->context_stack->data);
|
||||
if (service->priv->context_stack)
|
||||
eekboard_context_service_enable (service->priv->context_stack->data);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -366,7 +360,6 @@ handle_method_call (GDBusConnection *connection,
|
||||
gpointer user_data)
|
||||
{
|
||||
EekboardService *service = user_data;
|
||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
||||
EekboardServiceClass *klass = EEKBOARD_SERVICE_GET_CLASS(service);
|
||||
|
||||
if (g_strcmp0 (method_name, "CreateContext") == 0) {
|
||||
@ -382,12 +375,12 @@ handle_method_call (GDBusConnection *connection,
|
||||
g_object_set_data_full (G_OBJECT(context),
|
||||
"owner", g_strdup (sender),
|
||||
(GDestroyNotify)g_free);
|
||||
g_hash_table_insert (priv->context_hash,
|
||||
g_hash_table_insert (service->priv->context_hash,
|
||||
object_path,
|
||||
context);
|
||||
|
||||
/* the vanished callback is called when clients are disconnected */
|
||||
g_bus_watch_name_on_connection (priv->connection,
|
||||
g_bus_watch_name_on_connection (service->priv->connection,
|
||||
sender,
|
||||
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||
NULL,
|
||||
@ -405,7 +398,7 @@ handle_method_call (GDBusConnection *connection,
|
||||
EekboardContextService *context;
|
||||
|
||||
g_variant_get (parameters, "(&s)", &object_path);
|
||||
context = g_hash_table_lookup (priv->context_hash, object_path);
|
||||
context = g_hash_table_lookup (service->priv->context_hash, object_path);
|
||||
if (!context) {
|
||||
g_dbus_method_invocation_return_error (invocation,
|
||||
G_IO_ERROR,
|
||||
@ -413,9 +406,9 @@ handle_method_call (GDBusConnection *connection,
|
||||
"context not found");
|
||||
return;
|
||||
}
|
||||
if (priv->context_stack)
|
||||
eekboard_context_service_disable (priv->context_stack->data);
|
||||
priv->context_stack = g_slist_prepend (priv->context_stack,
|
||||
if (service->priv->context_stack)
|
||||
eekboard_context_service_disable (service->priv->context_stack->data);
|
||||
service->priv->context_stack = g_slist_prepend (service->priv->context_stack,
|
||||
g_object_ref (context));
|
||||
eekboard_context_service_enable (context);
|
||||
|
||||
@ -424,8 +417,8 @@ handle_method_call (GDBusConnection *connection,
|
||||
}
|
||||
|
||||
if (g_strcmp0 (method_name, "PopContext") == 0) {
|
||||
if (priv->context_stack) {
|
||||
EekboardContextService *context = priv->context_stack->data;
|
||||
if (service->priv->context_stack) {
|
||||
EekboardContextService *context = service->priv->context_stack->data;
|
||||
gchar *object_path;
|
||||
const gchar *owner;
|
||||
|
||||
@ -443,9 +436,9 @@ handle_method_call (GDBusConnection *connection,
|
||||
g_free (object_path);
|
||||
|
||||
eekboard_context_service_disable (context);
|
||||
priv->context_stack = g_slist_next (priv->context_stack);
|
||||
if (priv->context_stack)
|
||||
eekboard_context_service_enable (priv->context_stack->data);
|
||||
service->priv->context_stack = g_slist_next (service->priv->context_stack);
|
||||
if (service->priv->context_stack)
|
||||
eekboard_context_service_enable (service->priv->context_stack->data);
|
||||
}
|
||||
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
@ -458,7 +451,7 @@ handle_method_call (GDBusConnection *connection,
|
||||
const gchar *owner;
|
||||
|
||||
g_variant_get (parameters, "(&s)", &object_path);
|
||||
context = g_hash_table_lookup (priv->context_hash, object_path);
|
||||
context = g_hash_table_lookup (service->priv->context_hash, object_path);
|
||||
if (!context) {
|
||||
g_dbus_method_invocation_return_error (invocation,
|
||||
G_IO_ERROR,
|
||||
@ -479,13 +472,13 @@ handle_method_call (GDBusConnection *connection,
|
||||
}
|
||||
|
||||
remove_context_from_stack (service, context);
|
||||
g_hash_table_remove (priv->context_hash, object_path);
|
||||
g_hash_table_remove (service->priv->context_hash, object_path);
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (method_name, "Destroy") == 0) {
|
||||
g_signal_emit_by_name (service, "destroyed", NULL);
|
||||
g_signal_emit (service, signals[DESTROYED], 0);
|
||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user