diff options
author | Robert Tari <robert@tari.in> | 2021-09-07 01:25:17 +0200 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-09-13 22:30:14 +0200 |
commit | d2758a873a848fc4113a4087d53446f73c6543cb (patch) | |
tree | 945d183caf2c627ef353d662536f712d29dd5c38 /src/keyboard-lomiri.c | |
parent | d42da41264e8e7a8939068791e9bb5038bdaf649 (diff) | |
download | ayatana-indicator-keyboard-d2758a873a848fc4113a4087d53446f73c6543cb.tar.gz ayatana-indicator-keyboard-d2758a873a848fc4113a4087d53446f73c6543cb.tar.bz2 ayatana-indicator-keyboard-d2758a873a848fc4113a4087d53446f73c6543cb.zip |
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
Diffstat (limited to 'src/keyboard-lomiri.c')
-rw-r--r-- | src/keyboard-lomiri.c | 93 |
1 files changed, 93 insertions, 0 deletions
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 <robert@tari.in> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#include <glib-object.h> +#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; +} |