Class: ServerSelector
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- ServerSelector
- Defined in:
- lib/ServerSelector.rb
Overview
this file is part of manqod-server-console manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Instance Method Summary collapse
-
#initialize ⇒ ServerSelector
constructor
A new instance of ServerSelector.
Constructor Details
#initialize ⇒ ServerSelector
Returns a new instance of ServerSelector.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ServerSelector.rb', line 6 def initialize super() servers={ "localhost" =>{ :uri => "druby://127.0.0.1:5549", :bind => "druby://:0"}} begin path=File::(File.join(File.join(File::dirname(__FILE__),".."),"etc")) conf="" conf=File.new(File::(File.join(path,"server.conf"))).read servers=eval(conf) rescue => err Gtk.warn("no server.conf","#{err}\n\nusing default:\n#{servers.inspect}\n") end add(Gtk::HBox.new. pack_start(Gtk::Label.new("Select server")). pack_start(server_combo=Gtk::ComboBox.new(model=Gtk::ListStore.new(String,String,String)). pack_start(renderer=Gtk::CellRendererText.new,true).add_attribute(renderer,:text,0) ). pack_start(ok=Gtk::Button.new(Gtk::Stock::CONNECT)). pack_start(quit=Gtk::Button.new(Gtk::Stock::QUIT)) ) quit.signal_connect("clicked"){|me| Gtk.main_quit if Gtk::ask("Are you sure, you want to quit?") } ok.signal_connect("clicked"){|me| if i=server_combo.active_iter ServerConsole.new(i[0],i[1],i[2]) hide end } servers.each_pair{|conn,addr| i=model.append i[0]=conn i[1]=addr[:uri] i[2]=addr[:bind] } show_all end |