Merge branch 'cleanups' into 'master'
Cleanups See merge request Librem5/squeekboard!164
This commit is contained in:
@ -1,100 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<keyboards version="0.90">
|
||||
<keyboard id="ar" name="ar"
|
||||
geometry="compact" symbols="ar"
|
||||
longname="Arabic" language="ar"/>
|
||||
<keyboard id="be" name="be"
|
||||
geometry="compact" symbols="be"
|
||||
longname="Belarusian" language="be"/>
|
||||
<keyboard id="fa" name="fa"
|
||||
geometry="compact" symbols="fa"
|
||||
longname="Farsi (ISIRI 2901-1994)" language="fa"/>
|
||||
<keyboard id="he" name="he"
|
||||
geometry="compact" symbols="he"
|
||||
longname="Hebrew" language="he"/>
|
||||
<keyboard id="ja" name="ja"
|
||||
geometry="compact" symbols="ja-kana"
|
||||
longname="Japanese (Kana)" language="ja"/>
|
||||
<keyboard id="kk" name="kk"
|
||||
geometry="compact" symbols="kk"
|
||||
longname="Kazakh" language="kk"/>
|
||||
<keyboard id="ks" name="ks"
|
||||
geometry="compact" symbols="ks"
|
||||
longname="Kashmiri" language="ks"/>
|
||||
<keyboard id="my" name="my"
|
||||
geometry="compact" symbols="my"
|
||||
longname="Myanmar" language="my"/>
|
||||
<keyboard id="nb" name="nb"
|
||||
geometry="extended" symbols="nb"
|
||||
longname="Norwegian" language="nb"/>
|
||||
<keyboard id="ru" name="ru"
|
||||
geometry="compact" symbols="us"
|
||||
longname="Russian" language="ru"/>
|
||||
<keyboard id="th" name="th"
|
||||
geometry="compact" symbols="th"
|
||||
longname="Thai" language="th"/>
|
||||
<keyboard id="ua" name="ua"
|
||||
geometry="compact" symbols="ua"
|
||||
longname="Ukrainian" language="ua"/>
|
||||
<keyboard id="ug" name="ug"
|
||||
geometry="compact" symbols="ug"
|
||||
longname="Uyghur" language="ug"/>
|
||||
<keyboard id="us" name="us"
|
||||
geometry="compact" symbols="us"
|
||||
longname="US" language="en"/>
|
||||
<keyboard id="zh-bopomofo" name="zh-bopomofo"
|
||||
geometry="compact" symbols="zh-bopomofo"
|
||||
longname="Chinese (Bopomofo)" language="zh"/>
|
||||
<!-- Indic Inscript keyboards converted from m17n-lib -->
|
||||
<keyboard id="as-inscript" name="as-inscript"
|
||||
geometry="compact" symbols="as-inscript"
|
||||
longname="Assamese (Inscript)" language="as"/>
|
||||
<keyboard id="bn-inscript" name="bn-inscript"
|
||||
geometry="compact" symbols="bn-inscript"
|
||||
longname="Bengali (Inscript)" language="bn"/>
|
||||
<keyboard id="gu-inscript" name="gu-inscript"
|
||||
geometry="compact" symbols="gu-inscript"
|
||||
longname="Gujarati (Inscript)" language="gu"/>
|
||||
<keyboard id="hi-inscript" name="hi-inscript"
|
||||
geometry="compact" symbols="hi-inscript"
|
||||
longname="Hindi (Inscript)" language="hi"/>
|
||||
<keyboard id="kn-inscript" name="kn-inscript"
|
||||
geometry="compact" symbols="kn-inscript"
|
||||
longname="Kannada (Inscript)" language="kn"/>
|
||||
<keyboard id="ks-inscript" name="ks-inscript"
|
||||
geometry="compact" symbols="ks-inscript"
|
||||
longname="Kashmiri Devanagari (Inscript)" language="ks"/>
|
||||
<keyboard id="mai-inscript" name="mai-inscript"
|
||||
geometry="compact" symbols="mai-inscript"
|
||||
longname="Maithili (Inscript)" language="mai"/>
|
||||
<keyboard id="ml-inscript" name="ml-inscript"
|
||||
geometry="compact" symbols="ml-inscript"
|
||||
longname="Malayalam (Inscript)" language="ml-inscript"/>
|
||||
<keyboard id="mr-inscript" name="mr-inscript"
|
||||
geometry="compact" symbols="mr-inscript"
|
||||
longname="Marathi (Inscript)" language="mr"/>
|
||||
<keyboard id="or-inscript" name="or-inscript"
|
||||
geometry="compact" symbols="or-inscript"
|
||||
longname="Oriya (Inscript)" language="or"/>
|
||||
<keyboard id="pa-inscript" name="pa-inscript"
|
||||
geometry="compact" symbols="pa-inscript"
|
||||
longname="Punjabi (Inscript)" language="pa"/>
|
||||
<keyboard id="sd-inscript" name="sd-inscript"
|
||||
geometry="compact" symbols="sd-inscript"
|
||||
longname="Sindhi (Inscript)" language="sd"/>
|
||||
<keyboard id="ta-inscript" name="ta-inscript"
|
||||
geometry="compact" symbols="ta-inscript"
|
||||
longname="Tamil (Inscript)" language="ta"/>
|
||||
<keyboard id="te-inscript" name="te-inscript"
|
||||
geometry="compact" symbols="te-inscript"
|
||||
longname="Telugu (Inscript)" language="te"/>
|
||||
|
||||
<!-- Common keyboards -->
|
||||
<keyboard id="number" name="number"
|
||||
geometry="number-keypad" symbols="special/number"
|
||||
longname="Numeric keypad" language="all"/>
|
||||
<keyboard id="phone" name="phone"
|
||||
geometry="number-keypad" symbols="special/number"
|
||||
longname="Phone keypad" language="all"/>
|
||||
|
||||
</keyboards>
|
||||
@ -2,7 +2,6 @@
|
||||
<gresources>
|
||||
<gresource prefix="/sm/puri/squeekboard">
|
||||
<file compressed="true">style.css</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">keyboards/keyboards.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">keyboards/symbols/ar.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">keyboards/symbols/as-inscript.xml</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">keyboards/symbols/be.xml</file>
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
|
||||
* Copyright (C) 2010-2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:eek-keysym
|
||||
* @short_description: an #EekSymbol represents an X keysym
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "eek-keysym.h"
|
||||
|
||||
/* modifier keys */
|
||||
#define EEK_KEYSYM_Shift_L 0xffe1
|
||||
#define EEK_KEYSYM_Shift_R 0xffe2
|
||||
#define EEK_KEYSYM_ISO_Level3_Shift 0xfe03
|
||||
#define EEK_KEYSYM_Caps_Lock 0xffe5
|
||||
#define EEK_KEYSYM_Shift_Lock 0xffe6
|
||||
#define EEK_KEYSYM_Control_L 0xffe3
|
||||
#define EEK_KEYSYM_Control_R 0xffe4
|
||||
#define EEK_KEYSYM_Alt_L 0xffe9
|
||||
#define EEK_KEYSYM_Alt_R 0xffea
|
||||
#define EEK_KEYSYM_Meta_L 0xffe7
|
||||
#define EEK_KEYSYM_Meta_R 0xffe8
|
||||
#define EEK_KEYSYM_Super_L 0xffeb
|
||||
#define EEK_KEYSYM_Super_R 0xffec
|
||||
#define EEK_KEYSYM_Hyper_L 0xffed
|
||||
#define EEK_KEYSYM_Hyper_R 0xffee
|
||||
|
||||
struct _EekKeysymEntry {
|
||||
guint xkeysym;
|
||||
const gchar *name;
|
||||
};
|
||||
|
||||
typedef struct _EekKeysymEntry EekKeysymEntry;
|
||||
|
||||
#include "eek-xkeysym-keysym-entries.h"
|
||||
|
||||
guint32
|
||||
eek_keysym_from_name (const gchar *name)
|
||||
{
|
||||
for (uint i = 0; i < G_N_ELEMENTS(xkeysym_keysym_entries); i++) {
|
||||
if (g_strcmp0 (xkeysym_keysym_entries[i].name, name) == 0) {
|
||||
return xkeysym_keysym_entries[i].xkeysym;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
|
||||
* Copyright (C) 2010-2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#if !defined(__EEK_H_INSIDE__) && !defined(EEK_COMPILATION)
|
||||
#error "Only <eek/eek.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef EEK_KEYSYM_H
|
||||
#define EEK_KEYSYM_H 1
|
||||
|
||||
#include "glib.h"
|
||||
|
||||
guint32 eek_keysym_from_name (const gchar *name);
|
||||
|
||||
#endif /* EEK_KEYSYM_H */
|
||||
@ -23,243 +23,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gio/gio.h> /* GResource */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "eek-keyboard.h"
|
||||
#include "src/keyboard.h"
|
||||
|
||||
#include "squeekboard-resources.h"
|
||||
#include "src/layout.h"
|
||||
|
||||
#include "eek-xml-layout.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ID,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
static void initable_iface_init (GInitableIface *initable_iface);
|
||||
|
||||
typedef struct _EekXmlLayoutPrivate
|
||||
{
|
||||
gchar *id;
|
||||
gchar *keyboards_dir;
|
||||
EekXmlKeyboardDesc *desc;
|
||||
} EekXmlLayoutPrivate;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (EekXmlLayout, eek_xml_layout, EEK_TYPE_LAYOUT,
|
||||
0, /* GTypeFlags */
|
||||
G_ADD_PRIVATE(EekXmlLayout)
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
||||
initable_iface_init))
|
||||
|
||||
G_DEFINE_BOXED_TYPE(EekXmlKeyboardDesc, eek_xml_keyboard_desc, eek_xml_keyboard_desc_copy, eek_xml_keyboard_desc_free);
|
||||
|
||||
#define BUFSIZE 8192
|
||||
|
||||
static GList *parse_keyboards (const gchar *path,
|
||||
GError **error);
|
||||
|
||||
static gboolean validate (const gchar **valid_path_list,
|
||||
gsize valid_path_list_len,
|
||||
const gchar *element_name,
|
||||
GSList *element_stack,
|
||||
GError **error);
|
||||
|
||||
static gboolean parse (GMarkupParseContext *pcontext,
|
||||
GInputStream *input,
|
||||
GError **error);
|
||||
static const gchar * get_attribute (const gchar **names,
|
||||
const gchar **values,
|
||||
const gchar *name);
|
||||
|
||||
static void
|
||||
keyboard_desc_free (EekXmlKeyboardDesc *desc)
|
||||
{
|
||||
g_free (desc->id);
|
||||
g_free (desc->name);
|
||||
g_free (desc->geometry);
|
||||
g_free (desc->symbols);
|
||||
g_free (desc->longname);
|
||||
g_free (desc->language);
|
||||
g_slice_free (EekXmlKeyboardDesc, desc);
|
||||
}
|
||||
|
||||
struct _KeyboardsParseData {
|
||||
GSList *element_stack;
|
||||
|
||||
GList *keyboards;
|
||||
};
|
||||
typedef struct _KeyboardsParseData KeyboardsParseData;
|
||||
|
||||
static KeyboardsParseData *
|
||||
keyboards_parse_data_new (void)
|
||||
{
|
||||
return g_slice_new0 (KeyboardsParseData);
|
||||
}
|
||||
|
||||
static void
|
||||
keyboards_parse_data_free (KeyboardsParseData *data)
|
||||
{
|
||||
g_list_free_full (data->keyboards, (GDestroyNotify) keyboard_desc_free);
|
||||
g_slice_free (KeyboardsParseData, data);
|
||||
}
|
||||
|
||||
static const gchar *keyboards_valid_path_list[] = {
|
||||
"keyboards",
|
||||
"keyboard/keyboards",
|
||||
};
|
||||
|
||||
static void
|
||||
keyboards_start_element_callback (GMarkupParseContext *pcontext,
|
||||
const gchar *element_name,
|
||||
const gchar **attribute_names,
|
||||
const gchar **attribute_values,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
KeyboardsParseData *data = user_data;
|
||||
|
||||
if (!validate (keyboards_valid_path_list,
|
||||
G_N_ELEMENTS (keyboards_valid_path_list),
|
||||
element_name,
|
||||
data->element_stack,
|
||||
error))
|
||||
return;
|
||||
|
||||
if (g_strcmp0 (element_name, "keyboard") == 0) {
|
||||
EekXmlKeyboardDesc *desc = g_slice_new0 (EekXmlKeyboardDesc);
|
||||
const gchar *attribute;
|
||||
|
||||
data->keyboards = g_list_prepend (data->keyboards, desc);
|
||||
|
||||
attribute = get_attribute (attribute_names, attribute_values,
|
||||
"id");
|
||||
if (attribute == NULL) {
|
||||
g_set_error (error,
|
||||
G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
||||
"no \"id\" attribute for \"keyboard\"");
|
||||
return;
|
||||
}
|
||||
desc->id = g_strdup (attribute);
|
||||
|
||||
attribute = get_attribute (attribute_names, attribute_values,
|
||||
"name");
|
||||
if (attribute)
|
||||
desc->name = g_strdup (attribute);
|
||||
|
||||
attribute = get_attribute (attribute_names, attribute_values,
|
||||
"geometry");
|
||||
if (attribute == NULL) {
|
||||
g_set_error (error,
|
||||
G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
||||
"no \"geometry\" attribute for \"keyboard\"");
|
||||
return;
|
||||
}
|
||||
desc->geometry = g_strdup (attribute);
|
||||
|
||||
attribute = get_attribute (attribute_names, attribute_values,
|
||||
"symbols");
|
||||
if (attribute == NULL) {
|
||||
g_set_error (error,
|
||||
G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
||||
"no \"symbols\" attribute for \"keyboard\"");
|
||||
goto out;
|
||||
}
|
||||
desc->symbols = g_strdup (attribute);
|
||||
|
||||
attribute = get_attribute (attribute_names, attribute_values,
|
||||
"longname");
|
||||
if (attribute)
|
||||
desc->longname = g_strdup (attribute);
|
||||
|
||||
attribute = get_attribute (attribute_names, attribute_values,
|
||||
"language");
|
||||
if (attribute)
|
||||
desc->language = g_strdup (attribute);
|
||||
}
|
||||
|
||||
out:
|
||||
data->element_stack = g_slist_prepend (data->element_stack,
|
||||
g_strdup (element_name));
|
||||
}
|
||||
|
||||
static void
|
||||
keyboards_end_element_callback (GMarkupParseContext *pcontext,
|
||||
const gchar *element_name,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
KeyboardsParseData *data = user_data;
|
||||
GSList *head = data->element_stack;
|
||||
|
||||
g_free (head->data);
|
||||
data->element_stack = g_slist_next (data->element_stack);
|
||||
g_slist_free1 (head);
|
||||
}
|
||||
|
||||
static const GMarkupParser keyboards_parser = {
|
||||
keyboards_start_element_callback,
|
||||
keyboards_end_element_callback,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
struct _GeometryParseData {
|
||||
GSList *element_stack;
|
||||
|
||||
EekBounds bounds;
|
||||
struct squeek_view **views;
|
||||
guint view_idx;
|
||||
struct squeek_row *row;
|
||||
gint num_rows;
|
||||
EekOrientation orientation;
|
||||
gdouble corner_radius;
|
||||
GSList *points;
|
||||
gchar *name;
|
||||
EekOutline outline;
|
||||
gchar *outline_id;
|
||||
guint keycode;
|
||||
|
||||
GString *text;
|
||||
|
||||
GArray *outline_array;
|
||||
|
||||
GHashTable *name_button_hash; // char* -> struct squeek_button*
|
||||
GHashTable *keyname_oref_hash; // char* -> guint
|
||||
GHashTable *outlineid_oref_hash; // char* -> guint
|
||||
};
|
||||
typedef struct _GeometryParseData GeometryParseData;
|
||||
|
||||
struct _SymbolsParseData {
|
||||
GSList *element_stack;
|
||||
GString *text;
|
||||
|
||||
LevelKeyboard *keyboard;
|
||||
struct squeek_view *view;
|
||||
|
||||
gchar *label;
|
||||
gchar *icon;
|
||||
gchar *tooltip;
|
||||
guint keyval;
|
||||
};
|
||||
typedef struct _SymbolsParseData SymbolsParseData;
|
||||
|
||||
|
||||
struct _PrerequisitesParseData {
|
||||
GSList *element_stack;
|
||||
GString *text;
|
||||
|
||||
GList *prerequisites;
|
||||
};
|
||||
typedef struct _PrerequisitesParseData PrerequisitesParseData;
|
||||
|
||||
LevelKeyboard *
|
||||
eek_xml_layout_real_create_keyboard (const char *keyboard_type,
|
||||
EekboardContextService *manager)
|
||||
@ -268,310 +37,3 @@ eek_xml_layout_real_create_keyboard (const char *keyboard_type,
|
||||
squeek_layout_place_contents(layout);
|
||||
return level_keyboard_new(manager, layout);
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xml_layout_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekXmlLayout *layout = EEK_XML_LAYOUT (object);
|
||||
EekXmlLayoutPrivate *priv = eek_xml_layout_get_instance_private (layout);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ID:
|
||||
g_free (priv->id);
|
||||
priv->id = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xml_layout_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
EekXmlLayout *layout = EEK_XML_LAYOUT (object);
|
||||
EekXmlLayoutPrivate *priv = eek_xml_layout_get_instance_private (layout);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ID:
|
||||
g_value_set_string (value, priv->id);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xml_layout_finalize (GObject *object)
|
||||
{
|
||||
EekXmlLayoutPrivate *priv = eek_xml_layout_get_instance_private (
|
||||
EEK_XML_LAYOUT (object));
|
||||
|
||||
g_free (priv->id);
|
||||
|
||||
if (priv->desc)
|
||||
keyboard_desc_free (priv->desc);
|
||||
|
||||
g_free (priv->keyboards_dir);
|
||||
|
||||
G_OBJECT_CLASS (eek_xml_layout_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xml_layout_class_init (EekXmlLayoutClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
gobject_class->set_property = eek_xml_layout_set_property;
|
||||
gobject_class->get_property = eek_xml_layout_get_property;
|
||||
gobject_class->finalize = eek_xml_layout_finalize;
|
||||
|
||||
pspec = g_param_spec_string ("id",
|
||||
"ID",
|
||||
"ID",
|
||||
NULL,
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (gobject_class, PROP_ID, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xml_layout_init (EekXmlLayout *self)
|
||||
{
|
||||
/* void */
|
||||
}
|
||||
|
||||
EekLayout *
|
||||
eek_xml_layout_new (const gchar *id, GError **error)
|
||||
{
|
||||
return (EekLayout *) g_initable_new (EEK_TYPE_XML_LAYOUT,
|
||||
NULL,
|
||||
error,
|
||||
"id", id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
initable_init (GInitable *initable,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
EekXmlLayout *layout = EEK_XML_LAYOUT (initable);
|
||||
EekXmlLayoutPrivate *priv = eek_xml_layout_get_instance_private (layout);
|
||||
GList *keyboards, *p;
|
||||
gchar *path;
|
||||
EekXmlKeyboardDesc *desc;
|
||||
|
||||
priv->keyboards_dir = g_strdup ((gchar *) g_getenv ("EEKBOARD_KEYBOARDSDIR"));
|
||||
|
||||
if (priv->keyboards_dir == NULL)
|
||||
priv->keyboards_dir = g_strdup ("resource:///sm/puri/squeekboard/keyboards/");
|
||||
|
||||
path = g_build_filename (priv->keyboards_dir, "keyboards.xml", NULL);
|
||||
keyboards = parse_keyboards (path, error);
|
||||
g_free (path);
|
||||
if (error && *error)
|
||||
return FALSE;
|
||||
|
||||
for (p = keyboards; p; p = p->next) {
|
||||
desc = p->data;
|
||||
if (g_strcmp0 (desc->id, priv->id) == 0)
|
||||
break;
|
||||
}
|
||||
if (p == NULL) {
|
||||
g_set_error (error,
|
||||
EEK_ERROR,
|
||||
EEK_ERROR_LAYOUT_ERROR,
|
||||
"no such keyboard %s",
|
||||
priv->id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
keyboards = g_list_remove_link (keyboards, p);
|
||||
priv->desc = p->data;
|
||||
g_list_free_1 (p);
|
||||
g_list_free_full (keyboards, (GDestroyNotify) keyboard_desc_free);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
initable_iface_init (GInitableIface *initable_iface)
|
||||
{
|
||||
initable_iface->init = initable_init;
|
||||
}
|
||||
|
||||
/**
|
||||
* eek_xml_list_keyboards:
|
||||
*
|
||||
* List available keyboards.
|
||||
* Returns: (transfer container) (element-type utf8): the list of keyboards
|
||||
*/
|
||||
GList *
|
||||
eek_xml_list_keyboards (void)
|
||||
{
|
||||
const gchar *keyboards_dir;
|
||||
gchar *path;
|
||||
GList *keyboards;
|
||||
|
||||
keyboards_dir = g_getenv ("EEKBOARD_KEYBOARDSDIR");
|
||||
if (keyboards_dir == NULL)
|
||||
keyboards_dir = g_strdup ("resource:///sm/puri/squeekboard/keyboards/");
|
||||
path = g_build_filename (keyboards_dir, "keyboards.xml", NULL);
|
||||
keyboards = parse_keyboards (path, NULL);
|
||||
g_free (path);
|
||||
return keyboards;
|
||||
}
|
||||
|
||||
EekXmlKeyboardDesc *
|
||||
eek_xml_keyboard_desc_copy (EekXmlKeyboardDesc *desc)
|
||||
{
|
||||
return g_slice_dup (EekXmlKeyboardDesc, desc);
|
||||
}
|
||||
|
||||
void
|
||||
eek_xml_keyboard_desc_free (EekXmlKeyboardDesc *desc)
|
||||
{
|
||||
g_free (desc->id);
|
||||
g_free (desc->name);
|
||||
g_free (desc->geometry);
|
||||
g_free (desc->symbols);
|
||||
g_free (desc->language);
|
||||
g_free (desc->longname);
|
||||
g_slice_free (EekXmlKeyboardDesc, desc);
|
||||
}
|
||||
|
||||
static GList *
|
||||
parse_keyboards (const gchar *path, GError **error)
|
||||
{
|
||||
KeyboardsParseData *data;
|
||||
GMarkupParseContext *pcontext;
|
||||
GFile *file;
|
||||
GFileInputStream *input;
|
||||
GList *keyboards;
|
||||
gboolean retval;
|
||||
|
||||
file = g_str_has_prefix (path, "resource://")
|
||||
? g_file_new_for_uri (path)
|
||||
: g_file_new_for_path (path);
|
||||
|
||||
input = g_file_read (file, NULL, error);
|
||||
g_object_unref (file);
|
||||
if (input == NULL)
|
||||
return NULL;
|
||||
|
||||
data = keyboards_parse_data_new ();
|
||||
pcontext = g_markup_parse_context_new (&keyboards_parser,
|
||||
0,
|
||||
data,
|
||||
NULL);
|
||||
retval = parse (pcontext, G_INPUT_STREAM (input), error);
|
||||
g_object_unref (input);
|
||||
g_markup_parse_context_free (pcontext);
|
||||
if (!retval) {
|
||||
keyboards_parse_data_free (data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
keyboards = data->keyboards;
|
||||
data->keyboards = NULL;
|
||||
keyboards_parse_data_free (data);
|
||||
return keyboards;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
validate (const gchar **valid_path_list,
|
||||
gsize valid_path_list_len,
|
||||
const gchar *element_name,
|
||||
GSList *element_stack,
|
||||
GError **error)
|
||||
{
|
||||
guint i;
|
||||
gchar *element_path;
|
||||
GSList *head, *p;
|
||||
GString *string;
|
||||
|
||||
head = g_slist_prepend (element_stack, (gchar *)element_name);
|
||||
string = g_string_sized_new (64);
|
||||
for (p = head; p; p = p->next) {
|
||||
g_string_append (string, p->data);
|
||||
if (g_slist_next (p))
|
||||
g_string_append (string, "/");
|
||||
}
|
||||
element_path = g_string_free (string, FALSE);
|
||||
g_slist_free1 (head);
|
||||
|
||||
for (i = 0; i < valid_path_list_len; i++)
|
||||
if (g_strcmp0 (element_path, valid_path_list[i]) == 0)
|
||||
break;
|
||||
g_free (element_path);
|
||||
|
||||
if (i == valid_path_list_len) {
|
||||
gchar *reverse_element_path;
|
||||
|
||||
head = g_slist_reverse (g_slist_copy (element_stack));
|
||||
string = g_string_sized_new (64);
|
||||
for (p = head; p; p = p->next) {
|
||||
g_string_append (string, p->data);
|
||||
if (g_slist_next (p))
|
||||
g_string_append (string, "/");
|
||||
}
|
||||
reverse_element_path = g_string_free (string, FALSE);
|
||||
|
||||
abort ();
|
||||
g_set_error (error,
|
||||
G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_UNKNOWN_ELEMENT,
|
||||
"%s cannot appear as %s",
|
||||
element_name,
|
||||
reverse_element_path);
|
||||
g_free (reverse_element_path);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse (GMarkupParseContext *pcontext,
|
||||
GInputStream *input,
|
||||
GError **error)
|
||||
{
|
||||
gchar buffer[BUFSIZE];
|
||||
|
||||
while (1) {
|
||||
gssize nread = g_input_stream_read (input,
|
||||
buffer,
|
||||
sizeof (buffer),
|
||||
NULL,
|
||||
error);
|
||||
if (nread < 0)
|
||||
return FALSE;
|
||||
|
||||
if (nread == 0)
|
||||
break;
|
||||
|
||||
if (!g_markup_parse_context_parse (pcontext, buffer, nread, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return g_markup_parse_context_end_parse (pcontext, error);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
get_attribute (const gchar **names, const gchar **values, const gchar *name)
|
||||
{
|
||||
for (; *names && *values; names++, values++) {
|
||||
if (g_strcmp0 (*names, name) == 0)
|
||||
return *values;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -23,45 +23,9 @@
|
||||
#ifndef EEK_XML_LAYOUT_H
|
||||
#define EEK_XML_LAYOUT_H 1
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include "eek-layout.h"
|
||||
#include "eek-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define EEK_TYPE_XML_LAYOUT (eek_xml_layout_get_type())
|
||||
G_DECLARE_DERIVABLE_TYPE (EekXmlLayout, eek_xml_layout, EEK, XML_LAYOUT, EekLayout)
|
||||
|
||||
/**
|
||||
* EekXmlLayoutClass:
|
||||
*/
|
||||
struct _EekXmlLayoutClass
|
||||
{
|
||||
/*< private >*/
|
||||
EekLayoutClass parent_class;
|
||||
|
||||
/* padding */
|
||||
gpointer pdummy[24];
|
||||
};
|
||||
|
||||
struct _EekXmlKeyboardDesc
|
||||
{
|
||||
gchar *id;
|
||||
gchar *name;
|
||||
gchar *geometry;
|
||||
gchar *symbols;
|
||||
gchar *language;
|
||||
gchar *longname;
|
||||
};
|
||||
typedef struct _EekXmlKeyboardDesc EekXmlKeyboardDesc;
|
||||
|
||||
GType eek_xml_layout_get_type (void) G_GNUC_CONST;
|
||||
EekLayout *eek_xml_layout_new (const gchar *id,
|
||||
GError **error);
|
||||
GList *eek_xml_list_keyboards (void);
|
||||
|
||||
EekXmlKeyboardDesc *eek_xml_keyboard_desc_copy (EekXmlKeyboardDesc *desc);
|
||||
void eek_xml_keyboard_desc_free (EekXmlKeyboardDesc *desc);
|
||||
|
||||
LevelKeyboard *
|
||||
eek_xml_layout_real_create_keyboard (const char *keyboard_type,
|
||||
EekboardContextService *manager);
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
|
||||
#include "eek-keyboard.h"
|
||||
#include "eek-layout.h"
|
||||
#include "eek-keysym.h"
|
||||
|
||||
void eek_init (void);
|
||||
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
|
||||
# Copyright (C) 2010-2011 Red Hat, Inc.
|
||||
# Copyright (C) 2019 Purism, SPC
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public License
|
||||
# as published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
|
||||
# This library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301 USA
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
if len(sys.argv) > 3:
|
||||
print("Usage: %s TABLE-NAME [INPUT_FILE]" % sys.argv[0], file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
in_stream = sys.stdin
|
||||
else:
|
||||
in_stream = open(sys.argv[2])
|
||||
|
||||
table = dict()
|
||||
for line in in_stream:
|
||||
match = re.match(r'\s*(0x[0-9A-F]+)\s+"(.*)"\s+(\S*)', line, re.I)
|
||||
if match:
|
||||
table[int(match.group(1), 16)] = (match.group(2), match.group(3))
|
||||
|
||||
sys.stdout.write("static const EekKeysymEntry %s[] = {\n" %
|
||||
sys.argv[1])
|
||||
|
||||
for index, (keysym, (l, c)) in enumerate([(keysym, table[keysym])
|
||||
for keysym in sorted(table.keys())]):
|
||||
sys.stdout.write(" { 0x%X, \"%s\" }" %
|
||||
(keysym, l))
|
||||
if index < len(table) - 1:
|
||||
sys.stdout.write(",")
|
||||
sys.stdout.write("\n")
|
||||
sys.stdout.write("};\n")
|
||||
@ -6,15 +6,3 @@ enum_headers = [
|
||||
|
||||
enums = gnome.mkenums_simple('eek-enumtypes', sources: enum_headers)
|
||||
|
||||
python = find_program('python3')
|
||||
|
||||
gen_keysym_entries_xkeysym = generator(
|
||||
python,
|
||||
arguments: ['@CURRENT_SOURCE_DIR@/gen-keysym-entries.py', 'xkeysym_keysym_entries', '@INPUT@'],
|
||||
capture: true,
|
||||
output: 'eek-@BASENAME@.h',
|
||||
)
|
||||
|
||||
keysym_entries = [
|
||||
gen_keysym_entries_xkeysym.process('./xkeysym-keysym-entries.txt'),
|
||||
]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,6 @@ sources = [
|
||||
'../eek/eek-gtk-keyboard.c',
|
||||
'../eek/eek-keyboard.c',
|
||||
'../eek/eek-keyboard-drawing.c',
|
||||
'../eek/eek-keysym.c',
|
||||
'../eek/eek-layout.c',
|
||||
'../eek/eek-renderer.c',
|
||||
'../eek/eek-types.c',
|
||||
@ -28,7 +27,6 @@ sources = [
|
||||
'../eek/layersurface.c',
|
||||
dbus_src,
|
||||
enums,
|
||||
keysym_entries,
|
||||
'../eekboard/key-emitter.c',
|
||||
'../eekboard/eekboard-context-service.c',
|
||||
'../eekboard/eekboard-context.c',
|
||||
|
||||
Reference in New Issue
Block a user