From: Yasushi Shoji Date: 2000-06-01T19:37:36-04:00 Subject: [ruby-talk:03081] Glade/Ruby: some idea for API hi, I was just thinking about changing API for Glade/ruby last night. this is more like talking to myself ;) but of cause any comments will be really appreciated. methods are: glade = Glade.new('file_name') create new glade object which contain all information the file 'file_name' has. glade = Glade.new('file_name', 'base') create new glade object which contain all information under an object 'base' in file 'file_name'. glade.include?('obj_name') check to see glade has information of object name 'obj_name' [] = glade.toplevels returns array of toplevel object names, which is usually Gtk::Window. base_obj = glade.generate create all gtk object which glade has information of. # what if glade has more than one toplevel object? # should it generate array of objects? or just make it error? base_obj = glade.generate('base') create new gtk object(s) under the object 'base' # this is guaranteed to work. base_obj = glade.generate('signal_handler_{hash,module}) base_obj = glade.generate('base', 'signal_handler_{hash,module}') took the idea from [ruby-talk:03001] (thanks Conrad!). I don't know which is better. module with functions for callback, or Proc object hash with function name as the key? Marshal.dump(glade) well, this is not glade API but you can dump glade object. glade = Marshal.load(port) load dumped glade object. hope it's faster than parsing xml file. MyClass = glade.new_class('base') create new subclass of object 'base'. instance of class 'MyClass' will contain all the object which base has. if you keep creating and deleting Gtk object, you can define method in the subclass rather than defining singleton method to each time. don't know yet how to retrieve an object once you generated with Glade#generate. should I add singleton method 'retrieve' to toplevel widget when generated? so that we can do: glade = Glade.new('file') window = glade.generate l = window.retrieve('label') l.signal_connect.... or just let Gtk to handle this? l = window.child.child.child.child.child l.signal_connect.... regards, -- yashi