Class: CWM::Dialog

Inherits:
Object
  • Object
show all
Includes:
Yast::I18n, Yast::Logger, Yast::UIShortcuts
Defined in:
library/cwm/src/lib/cwm/dialog.rb

Overview

An OOP API and the pieces missing from Yast::CWM.show:

  • creating and closing a wizard dialog
  • Back/Abort/Next buttons
  • Help introduction for dialog

Direct Known Subclasses

Popup

Defined Under Namespace

Classes: FakeHelp

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, **kws) ⇒ Dialog

Constructor (empty to just allow passing extra options)



30
# File 'library/cwm/src/lib/cwm/dialog.rb', line 30

def initialize(*args, **kws); end

Class Method Details

.run(*args, **kws) ⇒ Object

A shortcut for .new(*args).run



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'library/cwm/src/lib/cwm/dialog.rb', line 33

def self.run(*args, **kws)
  # Argument delegation is handled differently since ruby 2.7:
  #
  # An empty Hash argument is automatically converted and absorbed into **kws, and the delegation
  # call removes the empty keyword hash, so no argument is passed to target. In ruby 2.6 and before,
  # an empty hash is passed:
  #
  # * Ruby 2.6 or before: run("foo") passes new("foo", {})
  # * Ruby 2.7 or later:  run("foo") passes new("foo")
  #
  # See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
  dialog = kws.empty? ? new(*args) : new(*args, **kws)
  dialog.run
end

Instance Method Details

#abort_buttonString?

The :abort button

Returns:

  • (String, nil)

    button label, nil to use the default label, "" to omit the button



73
74
75
# File 'library/cwm/src/lib/cwm/dialog.rb', line 73

def abort_button
  nil
end

#abort_handlerBoolean

Handler when the abort button is used

If returns false, then it does not abort.

Returns:

  • (Boolean)


118
119
120
# File 'library/cwm/src/lib/cwm/dialog.rb', line 118

def abort_handler
  true
end

#back_buttonString?

The :back button

Returns:

  • (String, nil)

    button label, nil to use the default label, "" to omit the button



66
67
68
# File 'library/cwm/src/lib/cwm/dialog.rb', line 66

def back_button
  nil
end

#back_handlerBoolean

Handler when the back button is used

If returns false, then it does not go back.

Returns:

  • (Boolean)


109
110
111
# File 'library/cwm/src/lib/cwm/dialog.rb', line 109

def back_handler
  true
end

#contentsCWM::WidgetTerm

Returns:



27
# File 'library/cwm/src/lib/cwm/dialog.rb', line 27

abstract_method :contents

#disable_buttonsArray<Symbol>

Returns Buttons to disable (:back, :next.

Returns:

  • (Array<Symbol>)

    Buttons to disable (:back, :next



91
92
93
# File 'library/cwm/src/lib/cwm/dialog.rb', line 91

def disable_buttons
  []
end

#helpString

Note:

text should be marked for translation

Introduction for help. This help text will be displayed before widget specific help. Default implementation is empty. If dialog want its help it need to overwrite the method with own text.

Returns:

  • (String)

    help text with rich text formatting



127
128
129
# File 'library/cwm/src/lib/cwm/dialog.rb', line 127

def help
  ""
end

#next_buttonString?

The :next button

Returns:

  • (String, nil)

    button label, nil to use the default label, "" to omit the button



80
81
82
# File 'library/cwm/src/lib/cwm/dialog.rb', line 80

def next_button
  nil
end

#next_handlerBoolean

Handler when the next button is used

If returns false, then it does not go next.

Returns:

  • (Boolean)


100
101
102
# File 'library/cwm/src/lib/cwm/dialog.rb', line 100

def next_handler
  true
end

#runSymbol

The entry point. Will open (and close) a wizard dialog unless one already exists.

Returns:

  • (Symbol)


51
52
53
54
55
56
57
# File 'library/cwm/src/lib/cwm/dialog.rb', line 51

def run
  if should_open_dialog?
    wizard_create_dialog { cwm_show }
  else
    cwm_show
  end
end

#should_open_dialog?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'library/cwm/src/lib/cwm/dialog.rb', line 59

def should_open_dialog?
  !Yast::Wizard.IsWizardDialog
end

#skip_store_forArray<Symbol>

Returns Events for which store won't be called, see Yast::CWMClass#show.

Returns:



86
87
88
# File 'library/cwm/src/lib/cwm/dialog.rb', line 86

def skip_store_for
  []
end

#titleString?

Returns The dialog title. nil: keep the existing title.

Returns:

  • (String, nil)

    The dialog title. nil: keep the existing title.



22
23
24
# File 'library/cwm/src/lib/cwm/dialog.rb', line 22

def title
  nil
end