Class: Alexandria::UI::AlertDialog

Inherits:
Gtk::Dialog
  • Object
show all
Defined in:
lib/alexandria/ui/dialogs/alert_dialog.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, title, stock_icon, buttons, message = nil) ⇒ AlertDialog

Returns a new instance of AlertDialog.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/alexandria/ui/dialogs/alert_dialog.rb', line 24

def initialize(parent, title, stock_icon, buttons, message = nil)
  super(title: '', parent: parent, flags: :destroy_with_parent, buttons: buttons)

  self.border_width = 6
  self.resizable = false
  child.spacing = 12

  hbox = Gtk::Box.new(:horizontal, 12)
  hbox.homogeneous = false
  hbox.border_width = 6
  child.pack_start(hbox)

  image = Gtk::Image.new(stock: stock_icon,
                         size: Gtk::IconSize::DIALOG)
  image.set_alignment(0.5, 0)
  hbox.pack_start(image)

  vbox = Gtk::Box.new(:vertical, 6)
  vbox.homogeneous = false
  hbox.pack_start(vbox)

  label = Gtk::Label.new
  label.set_alignment(0, 0)
  label.wrap = label.selectable = true
  label.markup = "<b><big>#{title}</big></b>"
  vbox.pack_start(label)

  if message
    label = Gtk::Label.new
    label.set_alignment(0, 0)
    label.wrap = label.selectable = true
    label.markup = message.strip
    vbox.pack_start(label)
  end
end