Class: MittensUi::Alert

Inherits:
Object
  • Object
show all
Defined in:
lib/mittens_ui/alert.rb

Overview

A modal alert dialog that displays a message and an OK button. Wraps Gtk::AlertDialog. Opens immediately on instantiation and blocks until dismissed. Optionally accepts a block that runs after the user closes the dialog.

Examples:

Basic alert

MittensUi::Alert.new("Something happened!")

With custom title

MittensUi::Alert.new("File saved.", title: "Success")

With block

MittensUi::Alert.new("Are you sure?") do
  puts "User acknowledged"
end

Instance Method Summary collapse

Constructor Details

#initialize(message, options = {}) { ... } ⇒ Alert

Creates and immediately displays an alert dialog.

Parameters:

  • message (String)

    the message to display

  • options (Hash) (defaults to: {})

    configuration options

Options Hash (options):

  • :title (String) — default: "Alert"

    the dialog window title

Yields:

  • optional block called after the user dismisses the dialog



29
30
31
32
# File 'lib/mittens_ui/alert.rb', line 29

def initialize(message, options = {}, &block)
  title = options[:title] || 'Alert'
  open_dialog(message, title, &block)
end