Class: Interphase::Window
- Defined in:
- lib/interphase/widgets/window.rb
Overview
An application window.
Instance Attribute Summary
Attributes inherited from Container
Attributes inherited from Widget
Instance Method Summary collapse
-
#in_background(&block) ⇒ Object
Binds a block to run as a
Thread
; it begins executing immediately. -
#initialize(title, **options, &block) ⇒ Window
constructor
Creates a new window.
-
#on_delete(&block) ⇒ Object
The given block will trigger when this window is closed.
-
#quit ⇒ Object
Quits the entire Interphase application, killing all its threads.
-
#quit! ⇒ Object
Force-quits the entire Interphase application, including the Ruby Kernel.
-
#quit_on_delete! ⇒ Object
Registers an #on_delete block which calls #quit.
-
#run ⇒ Object
Runs the entire Interphase application.
Methods inherited from Container
#add, #method_missing, #respond_to_missing?, #show_all
Methods inherited from Widget
#destroy, #method_missing, #on, #respond_to_missing?, #show, #size
Constructor Details
#initialize(title, **options, &block) ⇒ Window
Creates a new window.
9 10 11 |
# File 'lib/interphase/widgets/window.rb', line 9 def initialize(title, **, &block) super(Gtk::Window.new(title), , &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Interphase::Container
Instance Method Details
#in_background(&block) ⇒ Object
Binds a block to run as a Thread
; it begins executing immediately. Destroying the window kills all threads. TOOD DOES IT?
49 50 51 52 53 54 |
# File 'lib/interphase/widgets/window.rb', line 49 def in_background(&block) @threads ||= [] thread = Thread.new(&block) thread.abort_on_exception = true @threads << thread end |
#on_delete(&block) ⇒ Object
The given block will trigger when this window is closed.
14 15 16 |
# File 'lib/interphase/widgets/window.rb', line 14 def on_delete(&block) on('delete-event', &block) end |
#quit ⇒ Object
Quits the entire Interphase application, killing all its threads.
31 32 33 34 |
# File 'lib/interphase/widgets/window.rb', line 31 def quit @threads&.each(&:kill) Gtk.main_quit end |
#quit! ⇒ Object
Force-quits the entire Interphase application, including the Ruby Kernel. If your GUI quits but your terminal stays occupied after #quit, this will probably solve that issue. Having to use this is usually the sign of a badly-written program!
40 41 42 43 44 |
# File 'lib/interphase/widgets/window.rb', line 40 def quit! @threads&.each(&:kill) Gtk.main_quit exit! end |
#quit_on_delete! ⇒ Object
Registers an #on_delete block which calls #quit.
19 20 21 22 23 |
# File 'lib/interphase/widgets/window.rb', line 19 def quit_on_delete! on_delete do quit end end |
#run ⇒ Object
Runs the entire Interphase application.
26 27 28 |
# File 'lib/interphase/widgets/window.rb', line 26 def run Gtk.main end |