Class: Gtk::ImageComboList
- Inherits:
-
ComboBox
- Object
- ComboBox
- Gtk::ImageComboList
- Defined in:
- lib/gui/widgets.rb
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(subd, filename, filetype = "png") ⇒ ImageComboList
constructor
A new instance of ImageComboList.
- #name ⇒ Object
- #selected ⇒ Object
Constructor Details
#initialize(subd, filename, filetype = "png") ⇒ ImageComboList
Returns a new instance of ImageComboList.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/gui/widgets.rb', line 129 def initialize(subd, filename, filetype="png") @subdir = subd @filename = filename @filetype = filetype item_active = 0 model = Gtk::ListStore.new(Gdk::Pixbuf, String) = Gtk::IconSize.lookup(Gtk::IconSize::MENU)[0] pos = 0 for typefile in Dir["#{PIXMAP_PATH}/#{subd}/*#{filetype}"].sort iter = model.append iter[0] = Gdk::Pixbuf.new(typefile, , ) iter[1] = typefile[PIXMAP_PATH.length+subd.length + 2 ,typefile.size - PIXMAP_PATH.length - subd.length - 2 - filetype.length - 1] if filename and iter[1] == filename item_active = pos end pos +=1 end super(model) self.active = item_active # column 1 renderer = Gtk::CellRendererPixbuf.new self.pack_start(renderer, false) self.set_attributes(renderer, :pixbuf => 0) # column 2 renderer = Gtk::CellRendererText.new self.pack_start(renderer, true) self.set_attributes(renderer, :text => 1) #self.signal_connect("changed") do # p self.filename #end end |
Instance Method Details
#filename ⇒ Object
113 114 115 |
# File 'lib/gui/widgets.rb', line 113 def filename return "#{@subdir}/#{self.active_iter[1]}.#{@filetype}" end |
#name ⇒ Object
117 118 119 |
# File 'lib/gui/widgets.rb', line 117 def name return "#{self.active_iter[1]}" end |
#selected ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/gui/widgets.rb', line 121 def selected if self return self.active else return nil end end |