Class: Y2Network::Widgets::PathWidget
- Inherits:
-
CWM::CustomWidget
- Object
- CWM::CustomWidget
- Y2Network::Widgets::PathWidget
show all
- Defined in:
- src/lib/y2network/widgets/path_widget.rb
Overview
Generic widget for path with browse button
TODO: add to CWM as generic widget
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PathWidget.
27
28
29
30
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 27
def initialize
super()
textdomain "network"
end
|
Instance Method Details
#ask_method(directory) ⇒ Object
UI method responsible for asking for file/directory. By default uses
Yast::UI.AskForExistingFile with "*" filter. Redefine if different popup is needed or
specific filter required.
76
77
78
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 76
def ask_method(directory)
Yast::UI.AskForExistingFile(directory, "*", browse_label)
end
|
65
66
67
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 65
def button_id
widget_id + "_browse"
end
|
69
70
71
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 69
def button_label
"..."
end
|
#contents ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 35
def contents
HBox(
InputField(Id(text_id), Opt(:hstretch), label),
VBox(
VSpacing(1),
PushButton(Id(button_id), button_label)
)
)
end
|
#handle ⇒ Object
45
46
47
48
49
50
51
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 45
def handle
directory = File.dirname(value)
file = ask_method(directory)
self.value = file if file
nil
end
|
#text_id ⇒ Object
61
62
63
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 61
def text_id
widget_id + "_path"
end
|
#value ⇒ Object
53
54
55
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 53
def value
Yast::UI.QueryWidget(Id(text_id), :Value)
end
|
#value=(path) ⇒ Object
57
58
59
|
# File 'src/lib/y2network/widgets/path_widget.rb', line 57
def value=(path)
Yast::UI.ChangeWidget(Id(text_id), :Value, path)
end
|