Merge branch 'honor-a11y-setting' into 'master'
Honor org.gnome.desktop.a11y.applications screen-keyboard-enabled Closes #222 See merge request Librem5/squeekboard!370
This commit is contained in:
@ -31,6 +31,7 @@
|
|||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_VISIBLE,
|
PROP_VISIBLE,
|
||||||
|
PROP_ENABLED,
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ struct _ServerContextService {
|
|||||||
struct ui_manager *manager; // unowned
|
struct ui_manager *manager; // unowned
|
||||||
|
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
|
gboolean enabled;
|
||||||
PhoshLayerSurface *window;
|
PhoshLayerSurface *window;
|
||||||
GtkWidget *widget; // nullable
|
GtkWidget *widget; // nullable
|
||||||
guint hiding;
|
guint hiding;
|
||||||
@ -208,6 +210,9 @@ on_hide (ServerContextService *self)
|
|||||||
static void
|
static void
|
||||||
server_context_service_real_show_keyboard (ServerContextService *self)
|
server_context_service_real_show_keyboard (ServerContextService *self)
|
||||||
{
|
{
|
||||||
|
if (!self->enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (self->hiding) {
|
if (self->hiding) {
|
||||||
g_source_remove (self->hiding);
|
g_source_remove (self->hiding);
|
||||||
self->hiding = 0;
|
self->hiding = 0;
|
||||||
@ -263,7 +268,9 @@ server_context_service_set_property (GObject *object,
|
|||||||
case PROP_VISIBLE:
|
case PROP_VISIBLE:
|
||||||
self->visible = g_value_get_boolean (value);
|
self->visible = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_ENABLED:
|
||||||
|
server_context_service_set_enabled (self, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -319,11 +326,43 @@ server_context_service_class_init (ServerContextServiceClass *klass)
|
|||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_VISIBLE,
|
PROP_VISIBLE,
|
||||||
pspec);
|
pspec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ServerContextServie:keyboard:
|
||||||
|
*
|
||||||
|
* Does the user want the keyboard to show up automatically?
|
||||||
|
*/
|
||||||
|
pspec =
|
||||||
|
g_param_spec_boolean ("enabled",
|
||||||
|
"Enabled",
|
||||||
|
"Whether the keyboard is enabled",
|
||||||
|
TRUE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_ENABLED,
|
||||||
|
pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
server_context_service_init (ServerContextService *self) {
|
server_context_service_init (ServerContextService *self) {
|
||||||
(void)self;
|
const char *schema_name = "org.gnome.desktop.a11y.applications";
|
||||||
|
GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default();
|
||||||
|
g_autoptr(GSettingsSchema) schema = NULL;
|
||||||
|
|
||||||
|
self->enabled = TRUE;
|
||||||
|
if (!ssrc) {
|
||||||
|
g_warning("No gsettings schemas installed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
schema = g_settings_schema_source_lookup(ssrc, schema_name, TRUE);
|
||||||
|
if (schema) {
|
||||||
|
g_autoptr(GSettings) settings = g_settings_new (schema_name);
|
||||||
|
g_settings_bind (settings, "screen-keyboard-enabled",
|
||||||
|
self, "enabled", G_SETTINGS_BIND_GET);
|
||||||
|
} else {
|
||||||
|
g_warning("Gsettings schema %s is not installed on the system. "
|
||||||
|
"Enabling by default.", schema_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerContextService *
|
ServerContextService *
|
||||||
@ -336,3 +375,18 @@ server_context_service_new (EekboardContextService *self, struct submission *sub
|
|||||||
ui->manager = uiman;
|
ui->manager = uiman;
|
||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
server_context_service_set_enabled (ServerContextService *self, gboolean enabled)
|
||||||
|
{
|
||||||
|
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
|
||||||
|
|
||||||
|
if (enabled == self->enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
self->enabled = enabled;
|
||||||
|
if (self->enabled)
|
||||||
|
server_context_service_show_keyboard (self);
|
||||||
|
else
|
||||||
|
server_context_service_hide_keyboard (self);
|
||||||
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ ServerContextService *server_context_service_new(EekboardContextService *self, s
|
|||||||
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *);
|
enum squeek_arrangement_kind server_context_service_get_layout_type(ServerContextService *);
|
||||||
void server_context_service_show_keyboard (ServerContextService *self);
|
void server_context_service_show_keyboard (ServerContextService *self);
|
||||||
void server_context_service_hide_keyboard (ServerContextService *self);
|
void server_context_service_hide_keyboard (ServerContextService *self);
|
||||||
|
void server_context_service_set_enabled (ServerContextService *self, gboolean enabled);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* SERVER_CONTEXT_SERVICE_H */
|
#endif /* SERVER_CONTEXT_SERVICE_H */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user