Module: JLDrill::StoryFunctionality::Gtk

Defined in:
lib/jldrill/spec/storyFunctionality/Gtk.rb

Instance Method Summary collapse

Instance Method Details

#override_method(object, method, &block) ⇒ Object

Overrides the method on the object with the closure that’s passed in.



26
27
28
29
30
# File 'lib/jldrill/spec/storyFunctionality/Gtk.rb', line 26

def override_method(object, method, &block)
    class << object
        self
    end.send(:define_method, method, &block)
end

#pressButtonAfterEntry(dialog, button, &block) ⇒ Object

Override the run method in views that contain dialogs so that once the context has been entered the specified button is pressed.



35
36
37
38
39
40
41
42
# File 'lib/jldrill/spec/storyFunctionality/Gtk.rb', line 35

def pressButtonAfterEntry(dialog, button, &block)
    override_method(dialog, :run) do
        if !block.nil?
            block.call
        end
        button
    end
end

#pressCancelAfterEntry(dialog, &block) ⇒ Object

Enter a dialog and press Cancel



51
52
53
54
# File 'lib/jldrill/spec/storyFunctionality/Gtk.rb', line 51

def pressCancelAfterEntry(dialog, &block)
    pressButtonAfterEntry(dialog, ::Gtk::Dialog::RESPONSE_CANCEL, 
                          &block)
end

#pressOKAfterEntry(dialog, &block) ⇒ Object

Enter a dialog and press OK



45
46
47
48
# File 'lib/jldrill/spec/storyFunctionality/Gtk.rb', line 45

def pressOKAfterEntry(dialog, &block)
    pressButtonAfterEntry(dialog, ::Gtk::Dialog::RESPONSE_ACCEPT, 
                          &block)
end

#startGtk(&block) ⇒ Object

Starts Gtk and runs the code in the block. Note it doesn’t quit the main loop, so you will have to call ::Gtk::main_quit somewhere in the block. See UserLoadsDictionary_story.rb for an example of usage.



17
18
19
20
21
22
# File 'lib/jldrill/spec/storyFunctionality/Gtk.rb', line 17

def startGtk(&block)
	::Gtk.init_add do
		block.call
	end
	::Gtk.main
end