Class: Y2Network::Widgets::PathWidget

Inherits:
CWM::CustomWidget
  • Object
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

Direct Known Subclasses

ClientCertPath, ClientKeyPath, ServerCAPath

Instance Method Summary collapse

Constructor Details

#initializePathWidget

Returns a new instance of PathWidget.


27
28
29
# File 'src/lib/y2network/widgets/path_widget.rb', line 27

def initialize
  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.


75
76
77
# File 'src/lib/y2network/widgets/path_widget.rb', line 75

def ask_method(directory)
  Yast::UI.AskForExistingFile(directory, "*", browse_label)
end

#button_idObject


64
65
66
# File 'src/lib/y2network/widgets/path_widget.rb', line 64

def button_id
  widget_id + "_browse"
end

#button_labelObject


68
69
70
# File 'src/lib/y2network/widgets/path_widget.rb', line 68

def button_label
  "..."
end

#contentsObject


34
35
36
37
38
39
40
41
42
# File 'src/lib/y2network/widgets/path_widget.rb', line 34

def contents
  HBox(
    InputField(Id(text_id), Opt(:hstretch), label),
    VBox(
      VSpacing(1),
      PushButton(Id(button_id), button_label)
    )
  )
end

#handleObject


44
45
46
47
48
49
50
# File 'src/lib/y2network/widgets/path_widget.rb', line 44

def handle
  directory = File.dirname(value)
  file = ask_method(directory)
  self.value = file if file

  nil
end

#text_idObject


60
61
62
# File 'src/lib/y2network/widgets/path_widget.rb', line 60

def text_id
  widget_id + "_path"
end

#valueObject


52
53
54
# File 'src/lib/y2network/widgets/path_widget.rb', line 52

def value
  Yast::UI.QueryWidget(Id(text_id), :Value)
end

#value=(path) ⇒ Object


56
57
58
# File 'src/lib/y2network/widgets/path_widget.rb', line 56

def value=(path)
  Yast::UI.ChangeWidget(Id(text_id), :Value, path)
end