Module: Gtk
- Defined in:
- lib/rugui/framework_adapters/GTK.rb
Constant Summary collapse
- GTK_PENDING_BLOCKS =
[]
- GTK_PENDING_BLOCKS_LOCK =
Monitor.new
Class Method Summary collapse
- .get_style_file_contents(path, filename) ⇒ Object
- .is_style_file?(path, filename) ⇒ Boolean
- .load_style_paths ⇒ Object
- .queue(&block) ⇒ Object
-
.queue_timeout(timeout) ⇒ Object
Adds a timeout to execute pending blocks in a queue.
Class Method Details
.get_style_file_contents(path, filename) ⇒ Object
68 69 70 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 68 def Gtk.get_style_file_contents(path, filename) IO.read(File.join(path, filename)).gsub('{ROOT_PATH}', RuGUI.configuration.root_path.to_s) end |
.is_style_file?(path, filename) ⇒ Boolean
64 65 66 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 64 def Gtk.is_style_file?(path, filename) File.extname(filename) == '.rc' or /gtkrc/.match(filename) if File.file?(File.join(path, filename)) end |
.load_style_paths ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 55 def Gtk.load_style_paths styles_paths = RuGUI.configuration.styles_paths.select { |path| File.directory?(path) } styles_paths.each do |path| Dir.new(path).each do |entry| Gtk::RC.parse_string(get_style_file_contents(path, entry)) if is_style_file?(path, entry) end end end |
.queue(&block) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 32 def Gtk.queue(&block) if Thread.current == Thread.main block.call else GTK_PENDING_BLOCKS_LOCK.synchronize do GTK_PENDING_BLOCKS << block end end end |
.queue_timeout(timeout) ⇒ Object
Adds a timeout to execute pending blocks in a queue.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rugui/framework_adapters/GTK.rb', line 43 def Gtk.queue_timeout(timeout) Gtk.timeout_add timeout do GTK_PENDING_BLOCKS_LOCK.synchronize do GTK_PENDING_BLOCKS.each do |block| block.call end GTK_PENDING_BLOCKS.clear end true end end |