Skip to content

Commit

Permalink
changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Dec 13, 2016
1 parent a0bf428 commit 1fb0714
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 38 deletions.
3 changes: 2 additions & 1 deletion keyboard/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ 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)
EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) \
$(schemafiles_DATA) $(ydata_DATA) $(desktop_DATA) $(ylib_DATA)

include $(top_srcdir)/Makefile.am.common
77 changes: 41 additions & 36 deletions keyboard/src/lib/y2country/widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,55 @@
Yast.import "Keyboard"

module Y2Country
class KeyboardSelectionWidget < CWM::SelectionBox
def initialize
textdomain "country"
end
module Widgets
class KeyboardSelectionWidget < 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
def label
# widget label
_("&Keyboard Layout")
end

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

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

def store
handle
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]
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
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"
)
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
3 changes: 2 additions & 1 deletion keyboard/test/widgets_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
require_relative 'test_helper'
require "y2country/widgets"

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

0 comments on commit 1fb0714

Please sign in to comment.