From: Joao P. <joa...@ya...> - 2003-02-16 16:49:16
|
Howdy, > Could you re-send here your sample script which is > executable? > > Because your sample was only a module and a class. > I can use it, but I don't know how you used this > class and > how occured your problem. > It is difficult for me to guess how you occured your > problem. https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en Sorry :-) Here it is. ---bof leak.rb--- require 'gtk2' require 'gtk2_tools' include Gtk Gtk.init w = Window.new(Window::TOPLEVEL) w.set_size_request(500,400) list = Gtk2_Tools::List.new('column1') Gtk.timeout_add(50) { (1..100).each { list.append('any_value') list.remove('any_value') } } w.add(list) w.show_all Gtk.main ---eof leak.rb--- ---bof gtk2_tools.rb--- require 'gtk2' include Gtk module Gtk2_Tools class List < ScrolledWindow attr_reader :model, :column, :treeview def initialize(titulo="Data") super() @model = ListStore.new(String) @column = TreeViewColumn.new(titulo, CellRendererText.new, {:text => 0}) @treeview = TreeView.new(model) @treeview.append_column(column) @treeview.selection.set_mode(SELECTION_SINGLE) set_policy(POLICY_NEVER, POLICY_ALWAYS) add_with_viewport(@treeview) end def find(s) r = -1 #p @model.get_iter("0").methods.sort =begin (0..100000).each { |j| i = @model.get_iter("#{j}") break if i == nil if i.get_value(0) == s then r = j break end } =end #p @model.methods.sort @model.each { |a,b,c| if c.get_value(0) == s then r = b.to_s.to_i break end } r end def remove(s) r = true if s.class == String then i = find(s) if i != nil then r = @model.remove(@model.get_iter(i.to_s)) end else r = @model.remove(@model.get_iter(s.to_s)) end r end def append(s) @model.append.set_value(0,s) end def insert(i,s) @model.insert(i).set_value(0,s) end def get(i) @model.get_iter(i.to_s).get_value(0) end def clear @model.clear end end end ---eof gtk2_tools.rb--- Thanks, Joao __________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com |