Class: VR::FileTreeView::IconHash
- Inherits:
-
Hash
- Object
- Hash
- VR::FileTreeView::IconHash
- Defined in:
- lib/treeview/FileTreeView.rb
Overview
Creates a Hash of icons for VR::FileTreeView. The folder should contain .png files that correspond to file extensions. For example, rb.png would be an icon that displays next to files with an .rb extension. A file named “unknown.png” should be in the folder for file types that aren’t found.
Instance Method Summary collapse
- #get_icon(file_name) ⇒ Object
-
#initialize(path) ⇒ IconHash
constructor
Sets the path to find the icons.
Constructor Details
#initialize(path) ⇒ IconHash
Sets the path to find the icons
146 147 148 149 150 151 |
# File 'lib/treeview/FileTreeView.rb', line 146 def initialize(path) Dir.glob(path + "/*.png").each do |f| ext = File.basename(f, ".png") self[ext] = GdkPixbuf::Pixbuf.new(:file => f) end end |
Instance Method Details
#get_icon(file_name) ⇒ Object
153 154 155 156 |
# File 'lib/treeview/FileTreeView.rb', line 153 def get_icon(file_name) ext = File.extname(file_name).gsub(".", "") self.has_key?(ext) ? self[ext] : self["unknown"] end |