Skip to content

Commit

Permalink
Merge pull request #103 from yast/casp_merge
Browse files Browse the repository at this point in the history
Casp merge
  • Loading branch information
jreidinger committed Dec 15, 2016
2 parents 8749e31 + a9cf12f commit 1de54a1
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 15 deletions.
7 changes: 6 additions & 1 deletion keyboard/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ ydata_DATA = \
desktop_DATA = \
desktop/keyboard.desktop

EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) $(schemafiles_DATA) $(ydata_DATA) $(desktop_DATA)
ylibdir = @ylibdir@/y2country
ylib_DATA = \
lib/y2country/widgets.rb

EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) \
$(schemafiles_DATA) $(ydata_DATA) $(desktop_DATA) $(ylib_DATA)

include $(top_srcdir)/Makefile.am.common
84 changes: 84 additions & 0 deletions keyboard/src/lib/y2country/widgets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
#
# 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 Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail, you may find
# current contact information at www.novell.com.
# ------------------------------------------------------------------------------

require "yast"
require "cwm/widget"

Yast.import "Keyboard"

module Y2Country
module Widgets
class KeyboardSelection < CWM::SelectionBox
# param default [String] ID for default keyboard layout if not selected.
# Allowed values are defined in /usr/share/YaST2/data/keyboard_raw.ycp
def initialize(default)
textdomain "country"
@default = default
end

def label
# widget label
_("&Keyboard Layout")
end

# forces widget to report immediatelly after value changed.
def opt
[:notify]
end

def init
if Yast::Keyboard.user_decision
self.value = Yast::Keyboard.current_kbd
else
self.value = @default
Yast::Keyboard.Set(value)
end
end

def handle
Yast::Keyboard.Set(value)
end

def store
handle
end

def items
# a bit tricky as method return incompatible data
Yast::Keyboard.GetKeyboardItems.map do |item|
id, name, _enabled = item.params
id = id.params.first
[id, name]
end
end

def help
# help text for keyboard selection widget
_(
"<p>\n" \
"Choose the <b>Keyboard layout</b> to be used during\n" \
"installation and on the installed system.\n" \
"</p>\n"
)
end
end
end
end
1 change: 1 addition & 0 deletions keyboard/src/modules/Keyboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ def Selection
end

# Return item list of keyboard items, sorted according to current language
# @return [Array<Term>] Item(Id(...), String name, Boolean selected)
def GetKeyboardItems
ret = Builtins.maplist(Selection()) do |code, name|
Item(Id(code), name, @current_kbd == code)
Expand Down
69 changes: 69 additions & 0 deletions keyboard/test/widgets_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env rspec

require_relative 'test_helper'
require "y2country/widgets"

describe Y2Country::Widgets::KeyboardSelection do
subject { described_class.new("english-us") }
it "has label" do
expect(subject.label).to be_a(::String)
end

it "has help" do
expect(subject.help).to be_a(::String)
end

it "enlists all available keyboard layoout" do
expect(subject.items).to include(["english-us", "English (US)"])
end

it "changes keyboard layout when value changed" do
expect(Yast::Keyboard).to receive(:Set)

subject.handle
end

it "passes notify option to widget" do
expect(subject.opt).to eq [:notify]
end

it "stores keyboard layout" do
expect(Yast::Keyboard).to receive(:Set)

subject.store
end

context "when keyboard layout already set" do
before do
allow(Yast::Keyboard).to receive(:user_decision).and_return(true)
end

it "initizalizes widget to previous selection" do
allow(Yast::Keyboard).to receive(:current_kbd).and_return("english-uk")

expect(subject).to receive(:value=).with("english-uk")

subject.init
end
end

context "when keyboard layout not yet set" do
before do
allow(Yast::Keyboard).to receive(:user_decision).and_return(false)
end

it "initizalizes widget to english us layout" do
expect(subject).to receive(:value=).with("english-us")

subject.init
end

it "initializes that default layout" do
expect(subject).to receive(:value).and_return("english-us")

expect(Yast::Keyboard).to receive(:Set).with("english-us")

subject.init
end
end
end
11 changes: 11 additions & 0 deletions package/yast2-country.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
-------------------------------------------------------------------
Thu Dec 15 10:15:51 UTC 2016 - jreidinger@suse.com

merge CASP changes:

- fix notification on new keyboard widget, so keyboard layout is
immediatelly changed (FATE#321754)
- Add reusable keyboard widget
(FATE#321754)
- 3.2.5

-------------------------------------------------------------------
Tue Dec 13 09:03:47 UTC 2016 - igonzalezsosa@suse.com

Expand Down
35 changes: 21 additions & 14 deletions package/yast2-country.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# spec file for package yast2-country
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
Expand All @@ -17,47 +17,53 @@


Name: yast2-country
Version: 3.2.4
Version: 3.2.5
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: %{name}-%{version}.tar.bz2

Group: System/YaST
License: GPL-2.0
#policy files for YaPI dbus interface
Source1: org.opensuse.yast.modules.yapi.time.policy
Source2: org.opensuse.yast.modules.yapi.language.policy
BuildRequires: perl-XML-Writer update-desktop-files yast2-testsuite yast2 yast2-perl-bindings
BuildRequires: yast2-devtools >= 3.1.10
BuildRequires: perl-XML-Writer
BuildRequires: polkit-devel
BuildRequires: update-desktop-files
BuildRequires: yast2
BuildRequires: yast2-devtools >= 3.1.10
BuildRequires: yast2-perl-bindings
BuildRequires: yast2-testsuite
# For tests
BuildRequires: rubygem(rspec)
# Fix to bnc#891053 (proper reading of ".target.yast2" on chroots)
BuildRequires: yast2-core >= 3.1.12
# RSpec extensions for YaST
BuildRequires: yast2-ruby-bindings >= 3.1.26

Requires: yast2-trans-stats yast2-perl-bindings timezone
Requires: timezone
Requires: yast2-perl-bindings
Requires: yast2-trans-stats
# XVersion.ycp
# Message.updating_configuration, Message.takes_a_while
Requires: yast2 >= 3.1.94
Requires: yast2 >= 3.1.94
# Pkg::SetPackageLocale, Pkg::GetTextLocale
Requires: yast2-pkg-bindings >= 2.15.3
# IconPath support for MultiSelectionBox
Requires: yast2-core >= 2.16.28
Requires: yast2-core >= 2.16.28
# new API of ntp-client_proposal.ycp
Conflicts: yast2-ntp-client < 2.18.0
Conflicts: yast2-ntp-client < 2.18.0
# wrapper_storage.ycp
Requires: yast2-packager >= 2.23.3
# VMware detection (.probe.is_vmware)
Requires: yast2-hardware-detection >= 3.1.6

Requires: yast2-country-data
Requires: yast2-country-data

Requires: yast2-ruby-bindings >= 1.0.0

Summary: YaST2 - Country Settings (Language, Keyboard, and Timezone)
Summary: YaST2 - Country Settings (Language, Keyboard, and Timezone)
License: GPL-2.0
Group: System/YaST

%description
Country specific data and configuration modules (language, keyboard,
Expand All @@ -81,7 +87,6 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/polkit-1/actions
install -m 0644 %SOURCE1 $RPM_BUILD_ROOT/usr/share/polkit-1/actions/
install -m 0644 %SOURCE2 $RPM_BUILD_ROOT/usr/share/polkit-1/actions/


# common
%files
%defattr(-,root,root)
Expand All @@ -94,6 +99,7 @@ install -m 0644 %SOURCE2 $RPM_BUILD_ROOT/usr/share/polkit-1/actions/
%{yast_moduledir}/YaPI/TIME.pm
%{yast_moduledir}/YaPI/LANGUAGE.pm
%{yast_clientdir}/*.rb
%{yast_libdir}/y2country
%{yast_ydatadir}/*.ycp
%{yast_yncludedir}/keyboard/
%{yast_yncludedir}/timezone/
Expand All @@ -111,7 +117,7 @@ install -m 0644 %SOURCE2 $RPM_BUILD_ROOT/usr/share/polkit-1/actions/
%package data
Requires: yast2-ruby-bindings >= 1.0.0

Summary: YaST2 - Data files for Country settings
Summary: YaST2 - Data files for Country settings
Group: System/YaST

%description data
Expand All @@ -124,3 +130,4 @@ functions (Language module)
%{yast_ydatadir}/languages/*.ycp
%{yast_moduledir}/Language.rb

%changelog

0 comments on commit 1de54a1

Please sign in to comment.