eekboard-context-service: Drop private struct
There's no point having it for a final type and it only makes the code harder to read.
This commit is contained in:
@ -55,11 +55,8 @@ static guint signals[LAST_SIGNAL] = { 0, };
|
|||||||
*/
|
*/
|
||||||
struct _EekboardContextService {
|
struct _EekboardContextService {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
EekboardContextServicePrivate *priv;
|
|
||||||
struct squeek_layout_state *layout; // Unowned
|
struct squeek_layout_state *layout; // Unowned
|
||||||
};
|
|
||||||
|
|
||||||
struct _EekboardContextServicePrivate {
|
|
||||||
LevelKeyboard *keyboard; // currently used keyboard
|
LevelKeyboard *keyboard; // currently used keyboard
|
||||||
GSettings *settings; // Owned reference
|
GSettings *settings; // Owned reference
|
||||||
|
|
||||||
@ -70,7 +67,7 @@ struct _EekboardContextServicePrivate {
|
|||||||
struct submission *submission; // unowned
|
struct submission *submission; // unowned
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (EekboardContextService, eekboard_context_service, G_TYPE_OBJECT);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_context_service_set_property (GObject *object,
|
eekboard_context_service_set_property (GObject *object,
|
||||||
@ -96,7 +93,7 @@ eekboard_context_service_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_KEYBOARD:
|
case PROP_KEYBOARD:
|
||||||
g_value_set_object (value, context->priv->keyboard);
|
g_value_set_object (value, context->keyboard);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -157,12 +154,12 @@ eekboard_context_service_use_layout(EekboardContextService *context, struct sque
|
|||||||
struct squeek_layout *layout = squeek_load_layout(layout_name, state->arrangement);
|
struct squeek_layout *layout = squeek_load_layout(layout_name, state->arrangement);
|
||||||
LevelKeyboard *keyboard = level_keyboard_new(layout);
|
LevelKeyboard *keyboard = level_keyboard_new(layout);
|
||||||
// set as current
|
// set as current
|
||||||
LevelKeyboard *previous_keyboard = context->priv->keyboard;
|
LevelKeyboard *previous_keyboard = context->keyboard;
|
||||||
context->priv->keyboard = keyboard;
|
context->keyboard = keyboard;
|
||||||
// Update the keymap if necessary.
|
// Update the keymap if necessary.
|
||||||
// TODO: Update submission on change event
|
// TODO: Update submission on change event
|
||||||
if (context->priv->submission) {
|
if (context->submission) {
|
||||||
submission_set_keyboard(context->priv->submission, keyboard, timestamp);
|
submission_set_keyboard(context->submission, keyboard, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update UI
|
// Update UI
|
||||||
@ -177,7 +174,7 @@ eekboard_context_service_use_layout(EekboardContextService *context, struct sque
|
|||||||
static void eekboard_context_service_update_settings_layout(EekboardContextService *context) {
|
static void eekboard_context_service_update_settings_layout(EekboardContextService *context) {
|
||||||
g_autofree gchar *keyboard_layout = NULL;
|
g_autofree gchar *keyboard_layout = NULL;
|
||||||
g_autofree gchar *keyboard_type = NULL;
|
g_autofree gchar *keyboard_type = NULL;
|
||||||
settings_get_layout(context->priv->settings,
|
settings_get_layout(context->settings,
|
||||||
&keyboard_type, &keyboard_layout);
|
&keyboard_type, &keyboard_layout);
|
||||||
|
|
||||||
if (g_strcmp0(context->layout->layout_name, keyboard_layout) != 0 || context->layout->overlay_name) {
|
if (g_strcmp0(context->layout->layout_name, keyboard_layout) != 0 || context->layout->overlay_name) {
|
||||||
@ -255,8 +252,6 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
|
|||||||
static void
|
static void
|
||||||
eekboard_context_service_init (EekboardContextService *self)
|
eekboard_context_service_init (EekboardContextService *self)
|
||||||
{
|
{
|
||||||
self->priv = eekboard_context_service_get_instance_private (self);
|
|
||||||
|
|
||||||
const char *schema_name = "org.gnome.desktop.input-sources";
|
const char *schema_name = "org.gnome.desktop.input-sources";
|
||||||
GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default();
|
GSettingsSchemaSource *ssrc = g_settings_schema_source_get_default();
|
||||||
g_autoptr(GSettingsSchema) schema = NULL;
|
g_autoptr(GSettingsSchema) schema = NULL;
|
||||||
@ -270,8 +265,8 @@ eekboard_context_service_init (EekboardContextService *self)
|
|||||||
if (schema) {
|
if (schema) {
|
||||||
// Not referencing the found schema directly,
|
// Not referencing the found schema directly,
|
||||||
// because it's not clear how...
|
// because it's not clear how...
|
||||||
self->priv->settings = g_settings_new (schema_name);
|
self->settings = g_settings_new (schema_name);
|
||||||
gulong conn_id = g_signal_connect(self->priv->settings, "change-event",
|
gulong conn_id = g_signal_connect(self->settings, "change-event",
|
||||||
G_CALLBACK(settings_handle_layout_changed),
|
G_CALLBACK(settings_handle_layout_changed),
|
||||||
self);
|
self);
|
||||||
if (conn_id == 0) {
|
if (conn_id == 0) {
|
||||||
@ -307,7 +302,7 @@ eekboard_context_service_destroy (EekboardContextService *context)
|
|||||||
LevelKeyboard *
|
LevelKeyboard *
|
||||||
eekboard_context_service_get_keyboard (EekboardContextService *context)
|
eekboard_context_service_get_keyboard (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
return context->priv->keyboard;
|
return context->keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
|
void eekboard_context_service_set_hint_purpose(EekboardContextService *context,
|
||||||
@ -347,13 +342,13 @@ EekboardContextService *eekboard_context_service_new(struct squeek_layout_state
|
|||||||
}
|
}
|
||||||
|
|
||||||
void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission) {
|
void eekboard_context_service_set_submission(EekboardContextService *context, struct submission *submission) {
|
||||||
context->priv->submission = submission;
|
context->submission = submission;
|
||||||
if (context->priv->submission) {
|
if (context->submission) {
|
||||||
uint32_t time = gdk_event_get_time(NULL);
|
uint32_t time = gdk_event_get_time(NULL);
|
||||||
submission_set_keyboard(context->priv->submission, context->priv->keyboard, time);
|
submission_set_keyboard(context->submission, context->keyboard, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui) {
|
void eekboard_context_service_set_ui(EekboardContextService *context, ServerContextService *ui) {
|
||||||
context->priv->ui = ui;
|
context->ui = ui;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,6 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
#define EEKBOARD_TYPE_CONTEXT_SERVICE (eekboard_context_service_get_type())
|
#define EEKBOARD_TYPE_CONTEXT_SERVICE (eekboard_context_service_get_type())
|
||||||
|
|
||||||
typedef struct _EekboardContextServicePrivate EekboardContextServicePrivate;
|
|
||||||
G_DECLARE_FINAL_TYPE(EekboardContextService, eekboard_context_service, EEKBOARD, CONTEXT_SERVICE, GObject)
|
G_DECLARE_FINAL_TYPE(EekboardContextService, eekboard_context_service, EEKBOARD, CONTEXT_SERVICE, GObject)
|
||||||
|
|
||||||
EekboardContextService *eekboard_context_service_new(struct squeek_layout_state *state);
|
EekboardContextService *eekboard_context_service_new(struct squeek_layout_state *state);
|
||||||
|
|||||||
Reference in New Issue
Block a user