Class: UI::Dialog

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

Overview

Base class for dialogs in Yast. Includes useful modules and provides glue between them

Examples:

simple OK/cancel dialog

class OKDialog < UI::Dialog
  def initialize
    super
    textdomain "example"
  end

  def dialog_content
    HBox(
      PushButton(Id(:ok), _("OK")),
      PushButton(Id(:cancel), _("Cancel"))
    )
  end

  def ok_handler
    finish_dialog(:ok)
    log.info "OK button pressed"
  end
end

# run dialog
OKDialog.run

Direct Known Subclasses

InstallationDialog

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EventDispatcher

#cancel_handler, #event_loop, #finish_dialog, #user_input

Constructor Details

#initializeDialog

Returns a new instance of Dialog



45
46
47
# File 'library/general/src/lib/ui/dialog.rb', line 45

def initialize
  Yast.import "UI"
end

Class Method Details

.runObject

Runs dialog and return value of last handler from EventDispatcher



41
42
43
# File 'library/general/src/lib/ui/dialog.rb', line 41

def self.run
  new.run
end

Instance Method Details

#runObject



49
50
51
52
53
54
55
56
57
# File 'library/general/src/lib/ui/dialog.rb', line 49

def run
  raise "Failed to create dialog. See logs" unless create_dialog

  begin
    event_loop
  ensure
    close_dialog
  end
end