Sha256: a2613ed52a41ce9d7aefc7b646e90dc193b495a1f3260e71b8458a890d4fa39d
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
# encoding: utf-8 require 'jldrill/spec/StoryMemento' require 'gtk2' require 'Context/require_all' # We're requiring all the gtk views here since that's # what the app would normally be doing. require_all 'jldrill/views/gtk/*.rb' # Story functionality for Gtk. Used as a mixin within a # StoryMemento module JLDrill::StoryFunctionality module Gtk # 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. def startGtk(&block) ::Gtk.init_add do block.call end ::Gtk.main end # Overrides the method on the object with the closure # that's passed in. def override_method(object, method, &block) class << object self end.send(:define_method, method, &block) end # Override the run method in views that contain # dialogs so that once the context has been entered # the specified button is pressed. def pressButtonAfterEntry(dialog, button, &block) override_method(dialog, :run) do if !block.nil? block.call end button end end # Enter a dialog and press OK def pressOKAfterEntry(dialog, &block) pressButtonAfterEntry(dialog, ::Gtk::Dialog::RESPONSE_ACCEPT, &block) end # Enter a dialog and press Cancel def pressCancelAfterEntry(dialog, &block) pressButtonAfterEntry(dialog, ::Gtk::Dialog::RESPONSE_CANCEL, &block) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jldrill-0.6.0.1 | lib/jldrill/spec/storyFunctionality/Gtk.rb |