class Etti::MessageDialog
Public Class Methods
new(parent, flags=nil)
click to toggle source
Calls superclass method
# File lib/etti/ui/message-dialog.rb, line 10 def initialize parent, flags=nil super() self.transient_for = parent self.window_position = :center self.modal = true self.destroy_with_parent = true @vbox = Gtk::Box.new :vertical add @vbox @hbox = Gtk::Box.new :horizontal @vbox.pack_start @hbox, :expand => true, :fill => true, :padding => 12 self.title = flags[:title] if flags[:title] if flags[:buttons] @buttonBox = Gtk::Box.new :horizontal @buttonBox.homogeneous = true @vbox.pack_end @buttonBox, :expand => false, :fill => false flags[:buttons].each do |btn| stock = case btn when :yes Gtk::Stock::YES when :no Gtk::Stock::NO when :cancel Gtk::Stock::CANCEL when :close Gtk::Stock::CLOSE else warn "unknown button type %s" % btn.to_s nil end if stock button = Gtk::Button.new :stock_id => stock button.child.border_width = 4 button.signal_connect(:clicked) {signal_emit :response, btn} @buttonBox.pack_end button, :expand => true, :fill => true end end end if flags[:type] stock = case flags[:type] when :info Gtk::Stock::DIALOG_INFO when :warning Gtk::Stock::DIALOG_WARNING when :error Gtk::Stock::DIALOG_ERROR else warn "unknown dialog type %s" % flags[:type].to_s nil end if stock img = Gtk::Image.new :stock => stock, :size => :dialog img.set_padding 12, 6 @hbox.pack_start img end end if flags[:message] label = Gtk::Label.new flags[:message] @hbox.pack_start label, :expand => true, :fill => true, :padding => 12 end if flags[:additional] label = Gtk::Label.new flags[:additional] @vbox.pack_start label, :expand => true, :fill => true, :padding => 12 end if flags[:remind] end end
Public Instance Methods
run()
click to toggle source
# File lib/etti/ui/message-dialog.rb, line 93 def run self.show_all resp = nil self.signal_connect(:response) do |wid, res| resp = res Gtk.main_quit self.destroy end Gtk.main resp end
signal_do_response(foo;)
click to toggle source
# File lib/etti/ui/message-dialog.rb, line 7 def signal_do_response foo; end
Private Instance Methods
warn(warning)
click to toggle source
# File lib/etti/ui/message-dialog.rb, line 106 def warn warning printf "%s:%i: %s\n", __FILE__, __LINE__, warning end