Class: Zerenity::Base

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

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.build(dialog, options) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/zerenity/base.rb', line 19

def self.build(dialog, options)
  options[:ok_button] = dialog.add_button(options[:ok_button]||Gtk::Stock::OK, 
                                          Gtk::Dialog::RESPONSE_OK)
  options[:cancel_button] = dialog.add_button(options[:cancel_button]||Gtk::Stock::CANCEL,
                                              Gtk::Dialog::RESPONSE_CANCEL)
  dialog.set_default_response(Gtk::Dialog::RESPONSE_OK) if options[:activatesDefault] 
end

.check(options) ⇒ Object



13
14
15
16
17
# File 'lib/zerenity/base.rb', line 13

def self.check(options)
  options[:activatesDefault] = (options[:activatesDefault].nil? || options[:activatesDefault]) 
  options[:title] ||= ""
  options[:text] ||= ""
end

.retrieve_selection(dialog, options) ⇒ Object



47
48
# File 'lib/zerenity/base.rb', line 47

def self.retrieve_selection(dialog,options)
end

.run(options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/zerenity/base.rb', line 27

def self.run(options)
  Gtk.init
  self.check(options)
  dialog = Gtk::Dialog.new(options[:title])
  self.build(dialog,options)
  result = nil
  options[:ok_button].signal_connect(CLICKED) do
    result = self.retrieve_selection(dialog,options)
    dialog.destroy
    Gtk.main_quit
  end
  options[:cancel_button].signal_connect(CLICKED) do
    dialog.destroy
    Gtk.main_quit
  end
  dialog.show_all
  Gtk.main
  return result 
end