Class: VR::Alert

Inherits:
Object
  • Object
show all
Includes:
GladeGUI
Defined in:
lib/Alert.rb

Overview

Class that the #alert method uses. This class is note useful by itself. See #alert method instead.

See Also:

Defined Under Namespace

Classes: DialogAnswer

Instance Attribute Summary collapse

Attributes included from GladeGUI

#builder

Instance Method Summary collapse

Methods included from GladeGUI

#buttonCancel__clicked, #extract_key, #get_glade_active_record, #get_glade_all, #get_glade_variables, #load_glade, #parse_signals, #set_drag_drop, #set_glade_active_record, #set_glade_all, #set_glade_hash, #set_glade_variables, #show_glade, #try_to_select_text_in_combobox, #window1__destroy, #window1__key_press_event

Constructor Details

#initialize(message, answer, flags = {}) ⇒ Alert

Just passes on values from #alert method.

See Also:



15
16
17
18
19
20
21
# File 'lib/Alert.rb', line 15

def initialize(message, answer, flags = {})
  @flags = flags
  @answer = answer
  @message = message
  @p = nil

end

Instance Attribute Details

#answerObject

Returns the value of attribute answer



8
9
10
# File 'lib/Alert.rb', line 8

def answer
  @answer
end

Instance Method Details

#before_showObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/Alert.rb', line 23

def before_show
  @flags[:title] = @flags[:title] ? @flags[:title] : @flags[:headline]
  @builder[:window1].title = @flags[:title] if @flags[:title]
  @builder[:window1].resize(@flags[:width],100) if @flags[:width].to_i > 100
  @builder[:headline].show if @flags[:headline]

  if text = @flags[:input_text]
    @flags[:button_yes] ||= "Save"
    @flags[:button_no] ||= "Cancel"
    @builder[:input_text].show 
  end 

  @builder[:button_no].show if @flags[:button_no]
  @builder[:button_cancel].show if @flags[:button_cancel]
   set_glade_hash(@flags)
end

#button_cancel__clicked(but) ⇒ Object

answer stays nil



50
51
52
# File 'lib/Alert.rb', line 50

def button_cancel__clicked(but) #answer stays nil  
  @builder[:window1].destroy
end

#button_no__clicked(but) ⇒ Object



45
46
47
48
# File 'lib/Alert.rb', line 45

def button_no__clicked(but)
  @answer.answer = false    
  @builder[:window1].destroy
end

#button_yes__clicked(but) ⇒ Object



40
41
42
43
# File 'lib/Alert.rb', line 40

def button_yes__clicked(but)
  @answer.answer = @flags[:input_text] ? @builder[:input_text].text : true
  @builder[:window1].destroy
end