# Selection and inclusion of the native toolkit for GUtopIa. # # Author: Kero van Gelder # Copyright: Kero van Gelder, Sep 2002 # License: GNU Lesser General Public License, # see http://www.gnu.org/licenses/lgpl.html # First version: 4 Sep 2002 Toolkits = ["gtk", "qt", "wise"] $available = Toolkits.select { |tk_name| begin load("#{tk_name}.rb", true) # in anonymous module, so gc can discard true rescue LoadError false end } p $available if $available.empty? raise "No toolkit in #{Toolkits.inspect} available, GUtopIa failed." end ## Reorder $available based on environment? ## for each existing toolkit, try to connect to some environment of it, ## i.e. Gnome for Gtk, KDE(?) for Qt, X for Wise ## It is the responsibility of each Gutopia-binding to provide such a test. ## ## NB: How do we call the method without permanently wasting memory on the ## toolkit? module GUtopIa # start the so-called mainloop. Call will block until the UI is terminated # entirely. def GUtopIa::start() Serialize::serialize() end ## Need an equivalent of TkAfter # ??? def GUtopIa::stop() end # include the whole widget set, providing Window, Button, Layout etc. binding = $available.shift while not eval("require 'gutopia/#{binding}'") binding = $available.shift unless binding; break; end end unless binding puts "Failed to load GUtopIa binding for #{binding} :(" exit(1) end if __FILE__ == $0 # Do a bit of demoing ## Wise only, since I don't believe the other bindings match :/ Label.new("Succesfully loaded #{binding}!", :title=>"GUtopIa showoff") GUtopIa.start() end end