From d2758a873a848fc4113a4087d53446f73c6543cb Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Tue, 7 Sep 2021 01:25:17 +0200 Subject: Split X11 and Lomiri backends - CMakeLists.txt: Add separate dependencies for the X11 backend - src/keyboard.c: Fork into keyboard-x11.c and keyboard-lomiri.c - src/CMakeLists.txt: Build backend libraries - src/keyboard-lomiri.c: Add some mock defaults for Lomiri - src/service.c: Load appropriate backend during runtime - data/org.ayatana.indicator.keyboard: Move icon to leftmost position --- src/keyboard-lomiri.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/keyboard-lomiri.c (limited to 'src/keyboard-lomiri.c') diff --git a/src/keyboard-lomiri.c b/src/keyboard-lomiri.c new file mode 100644 index 00000000..0ae0b4a2 --- /dev/null +++ b/src/keyboard-lomiri.c @@ -0,0 +1,93 @@ +/* + * Copyright 2021 Robert Tari + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include +#include "languages.h" +#include "keyboard.h" + +enum +{ + LAYOUT_CHANGED, + CONFIG_CHANGED, + LAST_SIGNAL +}; + +static guint m_lSignals[LAST_SIGNAL]; + +struct _KeyboardPrivate +{ + guint nLayout; +}; + +typedef KeyboardPrivate priv_t; + +G_DEFINE_TYPE_WITH_PRIVATE(Keyboard, keyboard, G_TYPE_OBJECT) + +void keyboard_AddSource(Keyboard *pKeyboard) +{ + return; +} + +guint keyboard_GetNumLayouts(Keyboard *pKeyboard) +{ + return 1; +} + +void keyboard_GetLayout(Keyboard *pKeyboard, gint nLayout, gchar **pLanguage, gchar **pDescription) +{ + if (nLayout == -1) + { + nLayout = pKeyboard->pPrivate->nLayout; + } + + *pLanguage = g_strdup("En"); + + if (pDescription != NULL) + { + *pDescription = g_strdup("English"); + } +} + +void keyboard_SetLayout(Keyboard *pKeyboard, gint nLayout) +{ + g_signal_emit(pKeyboard, m_lSignals[LAYOUT_CHANGED], 0); +} + +static void onDispose(GObject *pObject) +{ + G_OBJECT_CLASS(keyboard_parent_class)->dispose(pObject); +} + +static void keyboard_class_init(KeyboardClass *klass) +{ + GObjectClass *pClass = G_OBJECT_CLASS(klass); + pClass->dispose = onDispose; + m_lSignals[LAYOUT_CHANGED] = g_signal_new(KEYBOARD_LAYOUT_CHANGED, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + m_lSignals[CONFIG_CHANGED] = g_signal_new(KEYBOARD_CONFIG_CHANGED, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); +} + +Keyboard* keyboard_new() +{ + GObject *pObject = g_object_new(G_TYPE_KEYBOARD, NULL); + + return G_KEYBOARD(pObject); +} + +static void keyboard_init(Keyboard *self) +{ + self->pPrivate = keyboard_get_instance_private(self); + self->pPrivate->nLayout = 0; +} -- cgit v1.2.3