move keyboard controller to new world
This commit is contained in:
parent
aac00dad6c
commit
45a85c554e
|
@ -2,10 +2,12 @@
|
|||
subiquity/client/client.py
|
||||
subiquity/client/controller.py
|
||||
subiquity/client/controllers/__init__.py
|
||||
subiquity/client/controllers/keyboard.py
|
||||
subiquity/client/controllers/progress.py
|
||||
subiquity/client/controllers/refresh.py
|
||||
subiquity/client/controllers/welcome.py
|
||||
subiquity/client/__init__.py
|
||||
subiquity/client/keyboard.py
|
||||
subiquity/client/keycodes.py
|
||||
subiquity/cmd/common.py
|
||||
subiquity/cmd/__init__.py
|
||||
|
@ -31,7 +33,6 @@ subiquity/controller.py
|
|||
subiquity/controllers/filesystem.py
|
||||
subiquity/controllers/identity.py
|
||||
subiquity/controllers/__init__.py
|
||||
subiquity/controllers/keyboard.py
|
||||
subiquity/controllers/mirror.py
|
||||
subiquity/controllers/network.py
|
||||
subiquity/controllers/proxy.py
|
||||
|
@ -97,7 +98,6 @@ subiquitycore/utils.py
|
|||
subiquitycore/view.py
|
||||
subiquity/__init__.py
|
||||
subiquity/journald.py
|
||||
subiquity/keyboard.py
|
||||
subiquity/lockfile.py
|
||||
subiquity/__main__.py
|
||||
subiquity/models/filesystem.py
|
||||
|
@ -120,6 +120,7 @@ subiquity/server/controllers/cmdlist.py
|
|||
subiquity/server/controllers/debconf.py
|
||||
subiquity/server/controllers/__init__.py
|
||||
subiquity/server/controllers/install.py
|
||||
subiquity/server/controllers/keyboard.py
|
||||
subiquity/server/controllers/locale.py
|
||||
subiquity/server/controllers/package.py
|
||||
subiquity/server/controllers/refresh.py
|
||||
|
|
|
@ -92,6 +92,7 @@ class SubiquityClient(TuiApplication):
|
|||
controllers = [
|
||||
"Welcome",
|
||||
"Refresh",
|
||||
"Keyboard",
|
||||
"Progress",
|
||||
]
|
||||
|
||||
|
|
|
@ -13,11 +13,13 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from .keyboard import KeyboardController
|
||||
from .progress import ProgressController
|
||||
from .refresh import RefreshController
|
||||
from .welcome import WelcomeController
|
||||
|
||||
__all__ = [
|
||||
'KeyboardController',
|
||||
'ProgressController',
|
||||
'RefreshController',
|
||||
'WelcomeController',
|
||||
|
|
|
@ -13,57 +13,32 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
import attr
|
||||
|
||||
from subiquitycore.context import with_context
|
||||
|
||||
from subiquity.common.keyboard import set_keyboard
|
||||
from subiquity.controller import SubiquityTuiController
|
||||
from subiquity.keyboard import KeyboardList
|
||||
from subiquity.models.keyboard import KeyboardSetting
|
||||
from subiquity.client.controller import SubiquityTuiController
|
||||
from subiquity.client.keyboard import KeyboardList
|
||||
from subiquity.common.types import KeyboardSetting
|
||||
from subiquity.common.keyboard import (
|
||||
set_keyboard,
|
||||
)
|
||||
from subiquity.ui.views import KeyboardView
|
||||
|
||||
log = logging.getLogger('subiquity.controllers.keyboard')
|
||||
log = logging.getLogger('subiquity.client.controllers.keyboard')
|
||||
|
||||
|
||||
class KeyboardController(SubiquityTuiController):
|
||||
|
||||
autoinstall_key = model_name = "keyboard"
|
||||
autoinstall_schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'layout': {'type': 'string'},
|
||||
'variant': {'type': 'string'},
|
||||
'toggle': {'type': ['string', 'null']},
|
||||
},
|
||||
'required': ['layout'],
|
||||
'additionalProperties': False,
|
||||
}
|
||||
endpoint_name = 'keyboard'
|
||||
|
||||
signals = [
|
||||
('l10n:language-selected', 'language_selected'),
|
||||
]
|
||||
|
||||
def __init__(self, app):
|
||||
self.needs_set_keyboard = False
|
||||
super().__init__(app)
|
||||
self.keyboard_list = KeyboardList()
|
||||
|
||||
def load_autoinstall_data(self, data):
|
||||
if data is None:
|
||||
return
|
||||
setting = KeyboardSetting(**data)
|
||||
if self.model.setting != setting:
|
||||
self.needs_set_keyboard = True
|
||||
self.model.setting = setting
|
||||
|
||||
@with_context()
|
||||
async def apply_autoinstall_config(self, context):
|
||||
if self.needs_set_keyboard:
|
||||
await set_keyboard(
|
||||
self.app.root, self.model.setting, self.opts.dry_run)
|
||||
|
||||
def language_selected(self, code):
|
||||
log.debug("language_selected %s", code)
|
||||
if not self.keyboard_list.has_language(code):
|
||||
|
@ -73,10 +48,12 @@ class KeyboardController(SubiquityTuiController):
|
|||
log.debug("loading language %s", code)
|
||||
self.keyboard_list.load_language(code)
|
||||
|
||||
def make_ui(self):
|
||||
async def make_ui(self):
|
||||
if self.keyboard_list.current_lang is None:
|
||||
self.keyboard_list.load_language('C')
|
||||
return KeyboardView(self, self.model.setting)
|
||||
initial_setting = await self.endpoint.GET()
|
||||
view = KeyboardView(self, initial_setting)
|
||||
return view
|
||||
|
||||
def run_answers(self):
|
||||
if 'layout' in self.answers:
|
||||
|
@ -93,12 +70,7 @@ class KeyboardController(SubiquityTuiController):
|
|||
if apply:
|
||||
self.app.aio_loop.create_task(self.set_keyboard(setting))
|
||||
else:
|
||||
self.model.setting = setting
|
||||
self.configured()
|
||||
self.app.next_screen()
|
||||
self.app.next_screen(self.endpoint.POST(setting))
|
||||
|
||||
def cancel(self):
|
||||
self.app.prev_screen()
|
||||
|
||||
def make_autoinstall(self):
|
||||
return attr.asdict(self.model.setting)
|
|
@ -20,6 +20,7 @@ from subiquity.common.types import (
|
|||
ApplicationState,
|
||||
ApplicationStatus,
|
||||
ErrorReportRef,
|
||||
KeyboardSetting,
|
||||
InstallState,
|
||||
InstallStatus,
|
||||
RefreshStatus,
|
||||
|
@ -30,6 +31,7 @@ from subiquity.common.types import (
|
|||
class API:
|
||||
"""The API offered by the subiquity installer process."""
|
||||
locale = simple_endpoint(str)
|
||||
keyboard = simple_endpoint(KeyboardSetting)
|
||||
|
||||
class meta:
|
||||
class status:
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
from ..controller import RepeatedController
|
||||
from .filesystem import FilesystemController
|
||||
from .identity import IdentityController
|
||||
from .keyboard import KeyboardController
|
||||
from .mirror import MirrorController
|
||||
from .network import NetworkController
|
||||
from .proxy import ProxyController
|
||||
|
@ -28,7 +27,6 @@ from .zdev import ZdevController
|
|||
__all__ = [
|
||||
'FilesystemController',
|
||||
'IdentityController',
|
||||
'KeyboardController',
|
||||
'MirrorController',
|
||||
'NetworkController',
|
||||
'ProxyController',
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
from .cmdlist import EarlyController, LateController, ErrorController
|
||||
from .debconf import DebconfController
|
||||
from .install import InstallController
|
||||
from .keyboard import KeyboardController
|
||||
from .locale import LocaleController
|
||||
from .package import PackageController
|
||||
from .refresh import RefreshController
|
||||
|
@ -27,6 +28,7 @@ __all__ = [
|
|||
'EarlyController',
|
||||
'ErrorController',
|
||||
'InstallController',
|
||||
'KeyboardController',
|
||||
'LateController',
|
||||
'LocaleController',
|
||||
'PackageController',
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
|
||||
import attr
|
||||
|
||||
from subiquitycore.context import with_context
|
||||
|
||||
from subiquity.common.apidef import API
|
||||
from subiquity.common.types import KeyboardSetting
|
||||
from subiquity.common.keyboard import (
|
||||
set_keyboard,
|
||||
)
|
||||
from subiquity.server.controller import SubiquityController
|
||||
|
||||
log = logging.getLogger('subiquity.server.controllers.keyboard')
|
||||
|
||||
|
||||
class KeyboardController(SubiquityController):
|
||||
|
||||
endpoint = API.keyboard
|
||||
|
||||
autoinstall_key = model_name = "keyboard"
|
||||
autoinstall_schema = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'layout': {'type': 'string'},
|
||||
'variant': {'type': 'string'},
|
||||
'toggle': {'type': ['string', 'null']},
|
||||
},
|
||||
'required': ['layout'],
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
||||
def __init__(self, app):
|
||||
self.needs_set_keyboard = False
|
||||
super().__init__(app)
|
||||
|
||||
def load_autoinstall_data(self, data):
|
||||
if data is None:
|
||||
return
|
||||
setting = KeyboardSetting(**data)
|
||||
if self.model.setting != setting:
|
||||
self.needs_set_keyboard = True
|
||||
self.model.setting = setting
|
||||
|
||||
@with_context()
|
||||
async def apply_autoinstall_config(self, context):
|
||||
if self.needs_set_keyboard:
|
||||
await set_keyboard(
|
||||
self.app.root, self.model.setting, self.opts.dry_run)
|
||||
|
||||
def make_autoinstall(self):
|
||||
return attr.asdict(self.model.setting)
|
||||
|
||||
async def GET(self) -> KeyboardSetting:
|
||||
return self.model.setting
|
||||
|
||||
async def POST(self, data: KeyboardSetting):
|
||||
self.model.setting = data
|
||||
self.configured()
|
|
@ -120,6 +120,7 @@ class SubiquityServer(Application):
|
|||
"Debconf",
|
||||
"Locale",
|
||||
"Refresh",
|
||||
"Keyboard",
|
||||
"Install",
|
||||
"Late",
|
||||
]
|
||||
|
|
|
@ -44,8 +44,8 @@ from subiquitycore.ui.stretchy import (
|
|||
from subiquitycore.ui.utils import button_pile, Color, Padding, screen
|
||||
from subiquitycore.view import BaseView
|
||||
|
||||
from subiquity.client.keyboard import latinizable, for_ui
|
||||
from subiquity.common.types import KeyboardSetting
|
||||
from subiquity.keyboard import latinizable, for_ui
|
||||
from subiquity.ui.views import pc105
|
||||
|
||||
log = logging.getLogger("subiquity.ui.views.keyboard")
|
||||
|
|
Loading…
Reference in New Issue