module Gtk

this file is part of manqod-server-console manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Public Class Methods

ask(question) click to toggle source
# File lib/Gtk.rb, line 34
def self.ask(question)
                print question,": "
                dialog=Gtk::MessageDialog.new(nil,Gtk::Dialog::Flags::MODAL,Gtk::MessageDialog::QUESTION,Gtk::MessageDialog::ButtonsType::YES_NO,question)
#              dialog.set_size_request(400,300)
                dialog.show_all
                ret=dialog.run == Gtk::Dialog::ResponseType::YES
                dialog.destroy
                print ret,"\n"
        ret
end
warn(subject,details=nil,level=INFO,canretry=false) click to toggle source
# File lib/Gtk.rb, line 6
def self.warn(subject,details=nil,level=INFO,canretry=false)
        subject="#{subject}\n#{details.message}" if details && details.class != String
        print "#{subject}\n"
        details="#{details.backtrace.join("\n\t")}" if details && details.class != String
        print "#{details}\n" unless details.nil?

                dialog=Gtk::MessageDialog.new(nil,Gtk::Dialog::Flags::MODAL,
                        case level
                                when ERROR then Gtk::MessageDialog::ERROR
                                when WARNING then Gtk::MessageDialog::WARNING
                                when INFO then Gtk::MessageDialog::INFO
                                else Gtk::MessageDialog::OTHER
                        end,
                        if canretry
                                Gtk::MessageDialog::ButtonsType::YES_NO
                                else
                                Gtk::MessageDialog::ButtonsType::CLOSE
                        end,
                        subject)
#              dialog.set_secondary_text("please report it!")
                dialog.vbox.pack_start(expander=Gtk::Expander.new("details",true).add(Gtk::TextView.new(Gtk::TextBuffer.new.set_text(details)))) unless details.nil?
                dialog.vbox.pack_end(Gtk::Label.new("retry?"),false,false) if canretry
#              dialog.set_size_request(400,300)
                dialog.show_all
                ret=dialog.run
                dialog.destroy
                ret == Gtk::Dialog::ResponseType::YES
end