Class: Zerenity::MessageDialog

Inherits:
Base
  • Object
show all
Defined in:
lib/zerenity/messagedialog.rb

Overview

:nodoc:

Direct Known Subclasses

Error, Info, Question, Warning

Class Method Summary collapse

Methods inherited from Base

check, retrieve_selection

Class Method Details

.build(dialog, options) ⇒ Object



5
6
7
8
# File 'lib/zerenity/messagedialog.rb', line 5

def self.build(dialog,options)
  options[:ok_button] = dialog.add_button(Gtk::Stock::OK,Gtk::Dialog::RESPONSE_OK)
  dialog.set_default_response(Gtk::Dialog::RESPONSE_OK)
end

.run(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zerenity/messagedialog.rb', line 10

def self.run(options={})
  Gtk.init
  self.check(options)
  dialog = Gtk::MessageDialog.new(nil,Gtk::Dialog::MODAL,options[:type],Gtk::MessageDialog::BUTTONS_NONE,options[:text])
  self.build(dialog,options)
  dialog.set_title(options[:title]) if options[:title]
  result = nil
  if options[:cancel_button]
    options[:cancel_button].signal_connect(CLICKED) do
      dialog.destroy
      Gtk.main_quit
    end
  end

  options[:ok_button].signal_connect(CLICKED) do
    result = true
    dialog.destroy
    Gtk.main_quit
  end
  dialog.show_all
  Gtk.main
  return result
end