/* * 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; }