Skip to content

Commit f712962

Browse files
authored
Merge branch 'master' into keeppanelactive
2 parents 42f919c + 178cb82 commit f712962

File tree

237 files changed

+60703
-5350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+60703
-5350
lines changed

cinnamon.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4748,7 +4748,7 @@ msgid "Cinnamon Version"
47484748
msgstr ""
47494749

47504750
#: files/usr/share/cinnamon/cinnamon-settings/modules/cs_info.py:120
4751-
msgid "Linux Kernel"
4751+
msgid "Kernel"
47524752
msgstr ""
47534753

47544754
#: files/usr/share/cinnamon/cinnamon-settings/modules/cs_info.py:121

data/README.osk-layouts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Gnome-shell OSK layouts are extracted from CLDR layout definitions:
2+
https://www.unicode.org/cldr/charts/latest/keyboards/layouts/index.html
3+
4+
Updating these involves several steps:
5+
6+
1) Downloading and unzipping the tarball found at:
7+
http://www.unicode.org/Public/cldr/latest/keyboards.zip
8+
9+
This file contains XML files describing the keyboard layouts.
10+
11+
2) Cloning the cldr2json script at:
12+
git://repo.or.cz/cldr2json.git
13+
14+
It will be used to convert the XML files into JSON that can be
15+
directly consumed by gnome-shell.
16+
17+
3) Running the script to produce the files:
18+
./cldr2json <input-directory> <output-directory>
19+
20+
We shall usually use the "android" folder, since that's most
21+
complete, and similar to our UI and target sizes. And the target
22+
directory must be data/osk-layouts in this repository.
23+
24+
4) Modify gnome-shell-osk-layouts.gresource.xml to include the files
25+
26+
5) Do git add on the updated/new files, and git commit.
27+
28+
29+
Or alternatively:
30+
31+
1) Run update-osk-layouts.sh
32+
33+
2) Do git add and git commit
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<gresources>
3+
<gresource prefix="/org/cinnamon/osk-layouts">
4+
<file>am.json</file>
5+
<file>ara.json</file>
6+
<file>be.json</file>
7+
<file>bg.json</file>
8+
<file>by.json</file>
9+
<file>ca.json</file>
10+
<file>cz.json</file>
11+
<file>de.json</file>
12+
<file>dk.json</file>
13+
<file>ee.json</file>
14+
<file>epo.json</file>
15+
<file>es+cat.json</file>
16+
<file>es.json</file>
17+
<file>fi.json</file>
18+
<file>fr.json</file>
19+
<file>ge.json</file>
20+
<file>gr.json</file>
21+
<file>hr.json</file>
22+
<file>hu.json</file>
23+
<file>id.json</file>
24+
<file>il.json</file>
25+
<file>in+bolnagri.json</file>
26+
<file>in+mal.json</file>
27+
<file>ir.json</file>
28+
<file>is.json</file>
29+
<file>it.json</file>
30+
<file>ke.json</file>
31+
<file>kg.json</file>
32+
<file>kh.json</file>
33+
<file>la.json</file>
34+
<file>latam.json</file>
35+
<file>lt.json</file>
36+
<file>lv.json</file>
37+
<file>mk.json</file>
38+
<file>mn.json</file>
39+
<file>my.json</file>
40+
<file>nl.json</file>
41+
<file>no.json</file>
42+
<file>ph.json</file>
43+
<file>pl.json</file>
44+
<file>pt.json</file>
45+
<file>ro.json</file>
46+
<file>rs.json</file>
47+
<file>ru.json</file>
48+
<file>se.json</file>
49+
<file>si.json</file>
50+
<file>sk.json</file>
51+
<file>th.json</file>
52+
<file>tr.json</file>
53+
<file>ua.json</file>
54+
<file>uk.json</file>
55+
<file>us.json</file>
56+
<file>vn.json</file>
57+
<file>za.json</file>
58+
<file>emoji.json</file>
59+
<file>keyboard-caps-lock-filled-symbolic.svg</file>
60+
<file>keyboard-enter-symbolic.svg</file>
61+
<file>keyboard-shift-filled-symbolic.svg</file>
62+
</gresource>
63+
</gresources>

data/cinnamon-wayland.desktop.in.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[Desktop Entry]
22
Type=Application
3-
_Name=Cinnamon (Wayland session)
4-
_Comment=Window management and application launching
3+
Name=Cinnamon (Wayland session)
4+
Comment=Window management and application launching
55
Exec=cinnamon --replace
66
X-GNOME-Bugzilla-Bugzilla=GNOME
77
X-GNOME-Bugzilla-Product=cinnamon

data/cinnamon.desktop.in.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[Desktop Entry]
22
Type=Application
3-
_Name=Cinnamon
4-
_Comment=Window management and application launching
3+
Name=Cinnamon
4+
Comment=Window management and application launching
55
Exec=@bindir@/cinnamon-launcher
66
X-GNOME-Bugzilla-Bugzilla=GNOME
77
X-GNOME-Bugzilla-Product=cinnamon

data/cinnamon2d.desktop.in.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[Desktop Entry]
22
Type=Application
3-
_Name=Cinnamon 2D
4-
_Comment=Window management and application launching
3+
Name=Cinnamon 2D
4+
Comment=Window management and application launching
55
Exec=@bindir@/cinnamon2d
66
Categories=GNOME;GTK;System;Core;
77
OnlyShowIn=X-Cinnamon;

data/cldr2json/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cldr2json
2+
=========
3+
4+
This script converts Unicode CLDR android keyboard layouts to JSON usable by
5+
GNOME Shell.
6+
7+
CLDR keyboard layouts can be found at
8+
<http://www.unicode.org/Public/cldr/latest/keyboards.zip>
9+
10+
11+
Usage
12+
=====
13+
14+
./cldr2json <input file or directory> <output directory>
15+
16+
example:
17+
18+
./cldr2json cldr/keyboards/android/ json_layouts/
19+
20+
21+
Keyboard layout mapping
22+
=======================
23+
24+
Unicode CLDR layout identifiers are language codes, while XKB layout
25+
identifiers are... something else. The mapping between the two currently uses
26+
heuristic based on the layout descriptions, in this order:
27+
28+
- if the CLDR layout description matches an XKB layout description, chose its
29+
XKB identifier
30+
- if one word of the CLDR layout description matches an XKB layout
31+
description, chose its XKB identifier
32+
- if the CLDR layout description matches one word of an XKB layout description,
33+
chose its XKB identifier
34+
35+
That doesn't always work. For instance it fails for "en" language, that should
36+
match "us" XKB identifier. For such cases, there is a mapping in
37+
LOCALE_TO_XKB_OVERRIDES at the top of the script. If you discover a weird
38+
mapping of if you get a "failed to find XKB mapping for <locale>" warning then
39+
please consider adding an override there.
40+

data/cldr2json/cldr2json.py

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
#!/usr/bin/python3
2+
#
3+
# Copyright 2015 Daiki Ueno <[email protected]>
4+
# 2016 Parag Nemade <[email protected]>
5+
# 2017 Alan <[email protected]>
6+
#
7+
# This program is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU Lesser General Public License as
9+
# published by the Free Software Foundation; either version 2 of the
10+
# License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful, but
13+
# WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# Lesser General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Lesser General Public
18+
# License along with this program; if not, see
19+
# <http://www.gnu.org/licenses/>.
20+
21+
import glob
22+
import json
23+
import locale
24+
import logging
25+
import os
26+
import re
27+
import sys
28+
import xml.etree.ElementTree
29+
30+
import gi
31+
gi.require_version('GnomeDesktop', '3.0') # NOQA: E402
32+
from gi.repository import GnomeDesktop
33+
34+
ESCAPE_PATTERN = re.compile(r'\\u\{([0-9A-Fa-f]+?)\}')
35+
ISO_PATTERN = re.compile(r'[A-E]([0-9]+)')
36+
37+
LOCALE_TO_XKB_OVERRIDES = {
38+
'af': 'za',
39+
'en': 'us',
40+
'en-GB': 'uk',
41+
'es-US': 'latam',
42+
'fr-CA': 'ca',
43+
'hi': 'in+bolnagri',
44+
'ky': 'kg',
45+
'nl-BE': 'be',
46+
'zu': None
47+
}
48+
49+
50+
def parse_single_key(value):
51+
def unescape(m):
52+
return chr(int(m.group(1), 16))
53+
value = ESCAPE_PATTERN.sub(unescape, value)
54+
return value
55+
56+
57+
def parse_rows(keymap):
58+
unsorted_rows = {}
59+
for _map in keymap.iter('map'):
60+
value = _map.get('to')
61+
key = [parse_single_key(value)]
62+
iso = _map.get('iso')
63+
if not ISO_PATTERN.match(iso):
64+
sys.stderr.write('invalid ISO key name: %s\n' % iso)
65+
continue
66+
if not iso[0] in unsorted_rows:
67+
unsorted_rows[iso[0]] = []
68+
unsorted_rows[iso[0]].append((int(iso[1:]), key))
69+
# add subkeys
70+
longPress = _map.get('longPress')
71+
if longPress:
72+
for value in longPress.split(' '):
73+
subkey = parse_single_key(value)
74+
key.append(subkey)
75+
76+
rows = []
77+
for k, v in sorted(list(unsorted_rows.items()),
78+
key=lambda x: x[0],
79+
reverse=True):
80+
row = []
81+
for key in sorted(v, key=lambda x: x):
82+
row.append(key[1])
83+
rows.append(row)
84+
85+
return rows
86+
87+
88+
def convert_xml(tree):
89+
root = {}
90+
for xml_keyboard in tree.iter("keyboard"):
91+
locale_full = xml_keyboard.get("locale")
92+
locale, sep, end = locale_full.partition("-t-")
93+
root["locale"] = locale
94+
for xml_name in tree.iter("name"):
95+
name = xml_name.get("value")
96+
root["name"] = name
97+
root["levels"] = []
98+
# parse levels
99+
for index, keymap in enumerate(tree.iter('keyMap')):
100+
# FIXME: heuristics here
101+
modifiers = keymap.get('modifiers')
102+
if not modifiers:
103+
mode = 'default'
104+
modifiers = ''
105+
elif 'shift' in modifiers.split(' '):
106+
mode = 'latched'
107+
modifiers = 'shift'
108+
else:
109+
mode = 'locked'
110+
level = {}
111+
level["level"] = modifiers
112+
level["mode"] = mode
113+
level["rows"] = parse_rows(keymap)
114+
root["levels"].append(level)
115+
return root
116+
117+
118+
def locale_to_xkb(locale, name):
119+
if locale in sorted(LOCALE_TO_XKB_OVERRIDES.keys()):
120+
xkb = LOCALE_TO_XKB_OVERRIDES[locale]
121+
logging.debug("override for %s → %s",
122+
locale, xkb)
123+
if xkb:
124+
return xkb
125+
else:
126+
raise KeyError("layout %s explicitely disabled in overrides"
127+
% locale)
128+
xkb_names = sorted(name_to_xkb.keys())
129+
if name in xkb_names:
130+
return name_to_xkb[name]
131+
else:
132+
logging.debug("name %s failed" % name)
133+
for sub_name in name.split(' '):
134+
if sub_name in xkb_names:
135+
xkb = name_to_xkb[sub_name]
136+
logging.debug("dumb mapping failed but match with locale word: "
137+
"%s (%s) → %s (%s)",
138+
locale, name, xkb, sub_name)
139+
return xkb
140+
else:
141+
logging.debug("sub_name failed")
142+
for xkb_name in xkb_names:
143+
for xkb_sub_name in xkb_name.split(' '):
144+
if xkb_sub_name.strip('()') == name:
145+
xkb = name_to_xkb[xkb_name]
146+
logging.debug("dumb mapping failed but match with xkb word: "
147+
"%s (%s) → %s (%s)",
148+
locale, name, xkb, xkb_name)
149+
return xkb
150+
raise KeyError("failed to find XKB mapping for %s" % locale)
151+
152+
153+
def convert_file(source_file, destination_path):
154+
logging.info("Parsing %s", source_file)
155+
156+
itree = xml.etree.ElementTree.ElementTree()
157+
itree.parse(source_file)
158+
159+
root = convert_xml(itree)
160+
161+
try:
162+
xkb_name = locale_to_xkb(root["locale"], root["name"])
163+
except KeyError as e:
164+
logging.warning(e)
165+
return False
166+
destination_file = os.path.join(destination_path, xkb_name + ".json")
167+
168+
try:
169+
with open(destination_file, 'x', encoding="utf-8") as dest_fd:
170+
json.dump(root, dest_fd, ensure_ascii=False, indent=2, sort_keys=True)
171+
except FileExistsError as e:
172+
logging.info("File %s exists, not updating", destination_file)
173+
return False
174+
175+
logging.debug("written %s", destination_file)
176+
177+
178+
def load_xkb_mappings():
179+
xkb = GnomeDesktop.XkbInfo()
180+
layouts = xkb.get_all_layouts()
181+
name_to_xkb = {}
182+
183+
for layout in layouts:
184+
name = xkb.get_layout_info(layout).display_name
185+
name_to_xkb[name] = layout
186+
187+
return name_to_xkb
188+
189+
190+
locale.setlocale(locale.LC_ALL, "C")
191+
name_to_xkb = load_xkb_mappings()
192+
193+
194+
if __name__ == "__main__":
195+
if "DEBUG" in os.environ:
196+
logging.basicConfig(level=logging.DEBUG)
197+
198+
if len(sys.argv) < 2:
199+
print("supply a CLDR keyboard file")
200+
sys.exit(1)
201+
202+
if len(sys.argv) < 3:
203+
print("supply an output directory")
204+
sys.exit(1)
205+
206+
source = sys.argv[1]
207+
destination = sys.argv[2]
208+
if os.path.isfile(source):
209+
convert_file(source, destination)
210+
elif os.path.isdir(source):
211+
for path in glob.glob(source + "/*-t-k0-android.xml"):
212+
convert_file(path, destination)

data/cldr2json/test/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)