Class: ActiveWindow::ListedItem
- Inherits:
-
Object
- Object
- ActiveWindow::ListedItem
- Defined in:
- lib/active_window/listed_item.rb
Overview
The ListItem is created on the fly
* to oo-abstract methods to its TreeIter
* for iteration in TreeController
* as object in ActiveTreeStore
Direct Known Subclasses
Class Method Summary collapse
- .build(attrs) ⇒ Object
- .modify_icon(scope, &block) ⇒ Object
-
.new_by_iter(iter) ⇒ Object
New by Gtk::TreeIter.
-
.new_by_reference(reference) ⇒ Object
New by Gtk::TreeRowReference.
Instance Method Summary collapse
- #directory? ⇒ Boolean
- #file? ⇒ Boolean
- #file_or_directory? ⇒ Boolean
-
#hide! ⇒ Object
TODO hide seperator if directory? and Config if iter.next! tree.row_for_iter(iter).show! end end.
- #icon ⇒ Object
- #icon_name ⇒ Object
-
#initialize(opts = {}) ⇒ ListedItem
constructor
A new instance of ListedItem.
- #matches?(str) ⇒ Boolean
- #message? ⇒ Boolean
- #reference ⇒ Object
- #reference=(new_ref) ⇒ Object
- #refresh ⇒ Object
- #separator? ⇒ Boolean
- #show! ⇒ Object
- #sort ⇒ Object
- #to_s ⇒ Object
- #visible? ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ ListedItem
Returns a new instance of ListedItem.
8 9 10 11 |
# File 'lib/active_window/listed_item.rb', line 8 def initialize(opts = {}) @traversed = false self end |
Class Method Details
.build(attrs) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/active_window/listed_item.rb', line 96 def self.build(attrs) if full_path = attrs[:full_path] if ::File.directory? full_path 'ListedDirectory' elsif ::File.file? full_path 'ListedFile' else self end elsif iter = attrs[:iter] and !iter[REFERENCED_TYPE].nil? iter[REFERENCED_TYPE] else self end.constantize.new attrs end |
.modify_icon(scope, &block) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/active_window/listed_item.rb', line 116 def self.modify_icon(scope, &block) with = "icon_name_with_#{scope}" without = "icon_name_without_#{scope}" define_method with do block.call(self) end alias_method without, :icon_name alias_method :icon_name, with end |
.new_by_iter(iter) ⇒ Object
New by Gtk::TreeIter
31 32 33 |
# File 'lib/active_window/listed_item.rb', line 31 def self.new_by_iter(iter) new(:iter => iter) end |
.new_by_reference(reference) ⇒ Object
New by Gtk::TreeRowReference
26 27 28 |
# File 'lib/active_window/listed_item.rb', line 26 def self.new_by_reference(reference) new(:iter => reference.iter) end |
Instance Method Details
#directory? ⇒ Boolean
47 48 49 |
# File 'lib/active_window/listed_item.rb', line 47 def directory? false end |
#file? ⇒ Boolean
43 44 45 |
# File 'lib/active_window/listed_item.rb', line 43 def file? false end |
#file_or_directory? ⇒ Boolean
51 52 53 |
# File 'lib/active_window/listed_item.rb', line 51 def file_or_directory? false end |
#hide! ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/active_window/listed_item.rb', line 64 def hide! self.visible = false # TODO hide seperator #if directory? and Config[:file_directory_separator] # if iter.next! # tree.row_for_iter(iter).hide! # end #end end |
#icon ⇒ Object
21 22 23 |
# File 'lib/active_window/listed_item.rb', line 21 def icon VimMate::Icons.by_name icon_name end |
#icon_name ⇒ Object
17 18 19 |
# File 'lib/active_window/listed_item.rb', line 17 def icon_name nil end |
#matches?(str) ⇒ Boolean
78 79 80 |
# File 'lib/active_window/listed_item.rb', line 78 def matches?(str) name.index(str) end |
#message? ⇒ Boolean
35 36 37 |
# File 'lib/active_window/listed_item.rb', line 35 def referenced_type == 'VimMate::Message' end |
#reference ⇒ Object
85 86 87 |
# File 'lib/active_window/listed_item.rb', line 85 def reference @reference ||= Gtk::TreeRowReference.new(tree.store, iter.path) end |
#reference=(new_ref) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/active_window/listed_item.rb', line 89 def reference=(new_ref) if new_ref @reference = new_ref @iter = tree.store.get_iter(new_ref.path) end end |
#refresh ⇒ Object
82 83 |
# File 'lib/active_window/listed_item.rb', line 82 def refresh end |
#separator? ⇒ Boolean
39 40 41 |
# File 'lib/active_window/listed_item.rb', line 39 def separator? referenced_type == 'VimMate::Separator' end |
#show! ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/active_window/listed_item.rb', line 55 def show! self.visible = true # TODO hide seperator #if directory? and Config[:file_directory_separator] # if iter.next! # tree.row_for_iter(iter).show! # end #end end |
#sort ⇒ Object
13 14 15 |
# File 'lib/active_window/listed_item.rb', line 13 def sort "item-#{iter}" end |
#to_s ⇒ Object
112 113 114 |
# File 'lib/active_window/listed_item.rb', line 112 def to_s "#{self.class} [#{iter.path}]" end |
#visible? ⇒ Boolean
74 75 76 |
# File 'lib/active_window/listed_item.rb', line 74 def visible? visible end |