Class: Y2Network::Dialogs::AddInterface

Inherits:
CWM::Dialog
  • Object
show all
Defined in:
src/lib/y2network/dialogs/add_interface.rb

Overview

Dialog which starts new device creation

Instance Method Summary collapse

Constructor Details

#initialize(default: nil) ⇒ AddInterface

Returns a new instance of AddInterface.


31
32
33
34
35
# File 'src/lib/y2network/dialogs/add_interface.rb', line 31

def initialize(default: nil)
  @type_widget = Widgets::InterfaceType.new(default: default ? default.short_name : nil)

  textdomain "network"
end

Instance Method Details

#abort_buttonObject

as it is a sub dialog it can only cancel and cannot abort


75
76
77
# File 'src/lib/y2network/dialogs/add_interface.rb', line 75

def abort_button
  Yast::Label.CancelButton
end

#back_buttonObject

no back button for add dialog


70
71
72
# File 'src/lib/y2network/dialogs/add_interface.rb', line 70

def back_button
  ""
end

#contentsObject


42
43
44
45
46
47
48
49
50
# File 'src/lib/y2network/dialogs/add_interface.rb', line 42

def contents
  HVCenter(
    HSquash(
      HBox(
        @type_widget
      )
    )
  )
end

#runY2Network::InterfaceConfigBuilder?

Returns new builder when type selected or nil if canceled

Returns:


54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'src/lib/y2network/dialogs/add_interface.rb', line 54

def run
  ret = super
  log.info "AddInterface result #{ret}"
  ret = :back if ret == :abort

  return if ret == :back

  # TODO: use factory to get proper builder
  builder = InterfaceConfigBuilder.for(InterfaceType.from_short_name(@type_widget.result))
  proposed_name = Yast::Lan.yast_config.interfaces.free_name(@type_widget.result)
  builder.name = proposed_name

  builder
end

#should_open_dialog?Boolean

always open new dialog

Returns:

  • (Boolean)

80
81
82
# File 'src/lib/y2network/dialogs/add_interface.rb', line 80

def should_open_dialog?
  true
end

#titleObject


37
38
39
40
# File 'src/lib/y2network/dialogs/add_interface.rb', line 37

def title
  # Translators: Dialog headline: adding a configuration of a network interface
  _("Add Interface Configuration")
end