-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6218249
commit b113d82
Showing
3 changed files
with
140 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright (c) [2022] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License 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 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, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "dbus" | ||
|
||
module Yast2 | ||
module DBus | ||
# YaST D-Bus object (/org/opensuse/YaST/Installer1) | ||
# | ||
# @see https://rubygems.org/gems/ruby-dbus | ||
class Language < ::DBus::Object | ||
# @param installer [Yast2::Installer] YaST installer instance | ||
def initialize(installer, logger) | ||
@installer = installer | ||
@logger = logger | ||
|
||
super(PATH) | ||
end | ||
|
||
dbus_interface YAST_LANGUAGE_INTERFACE do | ||
dbus_reader :available_languages, "a(ssa{sv})" | ||
attr_writer :available_languages | ||
dbus_watcher :available_languages | ||
|
||
dbus_reader :marked_for_install, "as" | ||
|
||
dbus_method :ToInstall, "in LangIDs:as" do |lang_ids| | ||
logger.info "ToInstall #{lang_ids.inspect}" | ||
select_to_install(lang_ids) | ||
|
||
self[DBus::PROPERTY_INTERFACE].PropertiesChanged(LANGUAGE_INTERFACE, {"MarkedForInstall" => lang_ids}, []) | ||
end | ||
end | ||
|
||
private | ||
|
||
PATH = "/org/opensuse/Yast/Language1".freeze | ||
private_constant :PATH | ||
|
||
YAST_LANGUAGE_INTERFACE = "org.opensuse.YaST.Language1".freeze | ||
private_constant :LANGUAGE_INTERFACE | ||
|
||
attr_reader :installer, :logger | ||
|
||
def available_languages | ||
@available_languages ||= installer.languages.map { |k,v| [k, v.first, {}] } | ||
end | ||
|
||
def marked_for_install | ||
# TODO: change when installer support multiple target languages | ||
[installer.language] | ||
end | ||
|
||
def select_to_install(lang_ids) | ||
# TODO: adapt installer API to allow more languages to install | ||
installer.language = lang_ids.first | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters