Forum: Ruby-Gnome 2 New FileTreeView update on visualruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0d130f179f85401f248e6ebc2ef8292f?d=identicon&s=25 Eric C. (eric_c)
on 2016-05-30 21:49
Hi:

I just updated the FileTreeView class in visualruby.  For those of you
who aren't familiar with it, its a great class that automatically
creates a tree of folders and files that is expandable and clickable
etc.  All you need to do is pass the folder path as an argument, and you
have a "windows explorer" like file tree on the screen.  You can pass a
glob to designate what files to include and pass a code block that will
further exclude files.

Thanks to my correspondence with the user cediemo, I realized that it
was a little bit difficult to open a folder in visualruby because the
user must choose a folder that contains a visualruby project in it.  So
my FileTreeView must show only folders with a hidden file,
(.vr_settings.yaml) in it.  This task was easy with the new
FileTreeView:


@ftv = VR::FileTreeView.new(path, "*/**/")
@ftv.test_block = { |folder| has_settings_file?(folder) }

...

  def has_settings_file?(path)
    Find.find(path) do |file|
      if File.basename(file) == VR_ENV::SETTINGS_FILE
        return true
      end
    end
    return false
  end

Now visualruby has a beautiful custom project selector that only shows
valid visualruby project folders.


This is available on github.

https://github.com/Beagle123/visualruby

Best,
Eric
This topic is locked and can not be replied to.