__init__.py 2 KB
Newer Older
Daiki Ueno's avatar
Daiki Ueno committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# Copyright (C) 2011 Daiki Ueno <ueno@unixuser.org>
# Copyright (C) 2011 Red Hat, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program 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
# 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/>.

from gi.repository import Eek, EekXkl, Gio

from eekboard import Eekboard
from context import Context

Keyboard = Eek.Keyboard
Section = Eek.Section
Key = Eek.Key
Symbol = Eek.Symbol
Keysym = Eek.Keysym
28
SymbolMatrix = Eek.SymbolMatrix
Daiki Ueno's avatar
Daiki Ueno committed
29 30 31 32 33 34 35 36

MODIFIER_BEHAVIOR_NONE, \
MODIFIER_BEHAVIOR_LOCK, \
MODIFIER_BEHAVIOR_LATCH = \
(Eek.ModifierBehavior.NONE,
 Eek.ModifierBehavior.LOCK,
 Eek.ModifierBehavior.LATCH)

37 38
SymbolCategory = Eek.SymbolCategory

Daiki Ueno's avatar
Daiki Ueno committed
39 40 41 42 43 44 45 46
CSW = 640
CSH = 480

def XmlKeyboard(path, modifier_behavior=MODIFIER_BEHAVIOR_NONE):
    _file = Gio.file_new_for_path(path)
    layout = Eek.XmlLayout.new(_file.read())
    keyboard = Eek.Keyboard.new(layout, CSW, CSH)
    keyboard.set_modifier_behavior(modifier_behavior)
Daiki Ueno's avatar
Daiki Ueno committed
47
    keyboard.set_alt_gr_mask(Eek.ModifierType.MOD5_MASK)
Daiki Ueno's avatar
Daiki Ueno committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
    return keyboard

def XklKeyboard(modifier_behavior=MODIFIER_BEHAVIOR_NONE):
    layout = EekXkl.Layout.new()
    keyboard = Eek.Keyboard.new(layout, CSW, CSH)
    keyboard.set_modifier_behavior(modifier_behavior)
    return keyboard

__all__ = ['Eekboard',
           'Context',
           'Keyboard',
           'Section',
           'Key',
           'Symbol',
           'Keysym',
           'MODIFIER_BEHAVIOR_NONE',
           'MODIFIER_BEHAVIOR_LOCK',
           'MODIFIER_BEHAVIOR_LATCH',
           'XmlKeyboard',
           'XklKeyboard']