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


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.


72
73
74
# File 'src/lib/y2network/widgets/path_widget.rb', line 72

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

#button_idObject


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

def button_id
  widget_id + "_browse"
end

#button_labelObject


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

def button_label
  "..."
end

#contentsObject


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

def contents
  HBox(
    InputField(Id(text_id), label),
    PushButton(Id(button_id), button_label)
  )
end

#handleObject


41
42
43
44
45
46
47
# File 'src/lib/y2network/widgets/path_widget.rb', line 41

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

  nil
end

#text_idObject


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

def text_id
  widget_id + "_path"
end

#valueObject


49
50
51
# File 'src/lib/y2network/widgets/path_widget.rb', line 49

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

#value=(path) ⇒ Object


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

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