diff --git a/data/org.fedorahosted.eekboard.gschema.xml.in b/data/org.fedorahosted.eekboard.gschema.xml.in deleted file mode 100644 index 9cfae422..00000000 --- a/data/org.fedorahosted.eekboard.gschema.xml.in +++ /dev/null @@ -1,60 +0,0 @@ - - - - - ['us'] - Keyboard types - keyboard types. - - - 'atspi' - Use the given focus listener - The name of the focus listener (either 'atspi' or 'ibus') used to detect focus events. - - - true - Hide keyboard automatically when focus is out - If true, hide keyboard automatically when focus is out. - - - 500 - Delay before hiding keyboard - Delay before hiding keyboard in milliseconds. This is useful when focus listener is enabled. - - - true - Key repeat - Generate key-press/release event repeatedly while a key is held down - - - 100 - Key repeat interval - Delay between repeats in milliseconds. - - - 1000 - Initial key repeat delay - Initial key repeat delay in milliseconds. - - - false - Switch to fullscreen mode when startup - If true, switch to fullscreen mode when startup. - - - (1.0, 0.3) - Constraint of the maximum window size on landscape screen - Constraint of maximum window size on landscape screen - - - (1.0, 0.5) - Constraint of the maximum window size on portrait screen - Constraint of maximum window size on portrait screen - - - 'default' - Theme - Base name of the theme to apply. - - - diff --git a/eekboard/eekboard-context-service.c b/eekboard/eekboard-context-service.c index fd5ccf84..2309b22a 100644 --- a/eekboard/eekboard-context-service.c +++ b/eekboard/eekboard-context-service.c @@ -355,16 +355,50 @@ static void emit_group_changed_signal (EekboardContextService *context, gint group); + +static void +settings_get_layout(GSettings *settings, char **type, char **layout) +{ + GVariant *inputs = g_settings_get_value(settings, "sources"); + guint32 index; + g_settings_get(settings, "current", "u", &index); + + GVariantIter *iter; + g_variant_get(inputs, "a(ss)", &iter); + + for (unsigned i = 0; + g_variant_iter_loop(iter, "(ss)", type, layout); + i++) { + if (i == index) { + //printf("Found layout %s %s\n", *type, *layout); + break; + } + } + g_variant_iter_free(iter); +} + + static void eekboard_context_service_constructed (GObject *object) { EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE (object); EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context); static guint keyboard_id = 0; - const gchar *keyboard_type = "us"; // TODO: fetch from gsettings + g_autofree gchar *keyboard_type = NULL; + g_autofree gchar *keyboard_layout = NULL; + + settings_get_layout(context->priv->settings, &keyboard_type, &keyboard_layout); + + if (!keyboard_type) { + keyboard_type = g_strdup("us"); + } + if (!keyboard_layout) { + keyboard_layout = g_strdup("undefined"); + } + EekKeyboard *keyboard; // create a keyboard - keyboard = klass->create_keyboard (context, keyboard_type); + keyboard = klass->create_keyboard (context, keyboard_layout); eek_keyboard_set_modifier_behavior (keyboard, EEK_MODIFIER_BEHAVIOR_LATCH); @@ -564,7 +598,7 @@ eekboard_context_service_init (EekboardContextService *self) NULL, (GDestroyNotify)g_object_unref); - self->priv->settings = g_settings_new ("org.fedorahosted.eekboard"); + self->priv->settings = g_settings_new ("org.gnome.desktop.input-sources"); } static void @@ -668,9 +702,11 @@ static gboolean on_repeat_timeout (EekboardContextService *context); static gboolean on_repeat_timeout (EekboardContextService *context) { - guint delay; + guint delay = 500; // ms - g_settings_get (context->priv->settings, "repeat-interval", "u", &delay); + // hardcoding; needs to connect to yet another settings path because + // org.gnome.desktop.input-sources doesn't control repeating + //g_settings_get (context->priv->settings, "repeat-interval", "u", &delay); emit_key_activated_dbus_signal (context, context->priv->repeat_key); @@ -692,6 +728,10 @@ on_repeat_timeout_init (EekboardContextService *context) eek_keyboard_set_modifiers (context->priv->keyboard, 0); /* reschedule repeat timeout only when "repeat" option is set */ + /* TODO: org.gnome.desktop.input-sources doesn't have repeat info. + * In addition, repeat is only useful when the keyboard is not in text + * input mode */ + /* if (g_settings_get_boolean (context->priv->settings, "repeat")) { guint delay; @@ -700,7 +740,7 @@ on_repeat_timeout_init (EekboardContextService *context) g_timeout_add (delay, (GSourceFunc)on_repeat_timeout, context); - } else + } else */ context->priv->repeat_timeout_id = 0; return FALSE; @@ -712,9 +752,10 @@ on_key_pressed (EekKeyboard *keyboard, gpointer user_data) { EekboardContextService *context = user_data; - guint delay; + guint delay = 500; - g_settings_get (context->priv->settings, "repeat-delay", "u", &delay); + // org.gnome.desktop.input-sources doesn't have delay info + //g_settings_get (context->priv->settings, "repeat-delay", "u", &delay); if (context->priv->repeat_timeout_id) { g_source_remove (context->priv->repeat_timeout_id); @@ -919,8 +960,6 @@ handle_method_call (GDBusConnection *connection, void eekboard_context_service_enable (EekboardContextService *context) { - GError *error; - g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context)); g_return_if_fail (context->priv->connection); diff --git a/src/server-context-service.c b/src/server-context-service.c index e9723622..7bf43d71 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -48,7 +48,6 @@ struct _ServerContextService { gulong notify_visible_handler; - GSettings *settings; gdouble size_constraint_landscape[2]; gdouble size_constraint_portrait[2]; }; @@ -277,7 +276,7 @@ update_widget (ServerContextService *context) EekKeyboard *keyboard; const gchar *client_name; EekBounds bounds; - gchar *theme_name, *theme_filename, *theme_path; + gchar *theme_path; EekTheme *theme; if (context->widget) { @@ -285,12 +284,7 @@ update_widget (ServerContextService *context) context->widget = NULL; } - theme_name = g_settings_get_string (context->settings, "theme"); - theme_filename = g_strdup_printf ("%s.css", theme_name); - g_free (theme_name); - - theme_path = g_build_filename (THEMESDIR, theme_filename, NULL); - g_free (theme_filename); + theme_path = g_build_filename (THEMESDIR, "default.css", NULL); theme = eek_theme_new (theme_path, NULL, NULL); g_free (theme_path); @@ -472,22 +466,6 @@ server_context_service_init (ServerContextService *context) "notify::fullscreen", G_CALLBACK(on_notify_fullscreen), context); - - context->settings = g_settings_new ("org.fedorahosted.eekboard"); - g_settings_bind_with_mapping (context->settings, "size-constraint-landscape", - context, "size-constraint-landscape", - G_SETTINGS_BIND_GET, - (GSettingsBindGetMapping)g_value_set_variant, - NULL, - NULL, - NULL); - g_settings_bind_with_mapping (context->settings, "size-constraint-portrait", - context, "size-constraint-portrait", - G_SETTINGS_BIND_GET, - (GSettingsBindGetMapping)g_value_set_variant, - NULL, - NULL, - NULL); } ServerContextService *