Module: Gutkumber
- Defined in:
- lib/gutkumber.rb,
lib/gutkumber/finders.rb
Constant Summary collapse
- TICK_SIZE =
ENV["GUTKUMBER_TICK_SIZE"] || 0.3
Class Method Summary collapse
- .dialogs ⇒ Object
- .find_all_gtk_windows ⇒ Object
- .find_button(window, button_label) ⇒ Object
- .find_gtk_window(title) ⇒ Object
- .in_test_process? ⇒ Boolean
- .label_texts(widget) ⇒ Object
- .tick ⇒ Object
- .wait_tick ⇒ Object
- .window_buttons(window) ⇒ Object
Class Method Details
.dialogs ⇒ Object
15 16 17 18 19 |
# File 'lib/gutkumber/finders.rb', line 15 def self.dialogs Gtk::Window.toplevels.select do |window| window.class.ancestors.include?(Gtk::Dialog) end end |
.find_all_gtk_windows ⇒ Object
21 22 23 |
# File 'lib/gutkumber/finders.rb', line 21 def self.find_all_gtk_windows Gtk::Window.toplevels end |
.find_button(window, button_label) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/gutkumber/finders.rb', line 36 def self.(window, ) = window.(Gtk::Button) .each do || label = .(Gtk::Label).map{|la| la.text}.join(" ") return if label =~ Regexp.new(Regexp.escape()) end nil end |
.find_gtk_window(title) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/gutkumber/finders.rb', line 5 def self.find_gtk_window(title) Gtk::Window.toplevels.detect do |window| if title.is_a?(Regexp) window.title =~ title else window.title =~ Regexp.new(Regexp.escape(title)) end end end |
.in_test_process? ⇒ Boolean
22 23 24 |
# File 'lib/gutkumber.rb', line 22 def self.in_test_process? true end |
.label_texts(widget) ⇒ Object
30 31 32 33 34 |
# File 'lib/gutkumber/finders.rb', line 30 def self.label_texts() .(Gtk::Label).map do |label| label.text end end |
.tick ⇒ Object
45 46 47 |
# File 'lib/gutkumber/finders.rb', line 45 def self.tick Gtk.main_iteration while Gtk.events_pending? end |
.wait_tick ⇒ Object
49 50 51 52 |
# File 'lib/gutkumber/finders.rb', line 49 def self.wait_tick tick sleep TICK_SIZE end |