module VR::Dialog

Public Class Methods

folder_box(builder) click to toggle source
# File lib/Dialog.rb, line 73
      def Dialog.folder_box(builder)
    dialog = Gtk::FileChooserDialog.new("Select Folder...",
                   builder['window1'],
                   Gtk::FileChooser::ACTION_SELECT_FOLDER,
                   nil,
                   [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
                   [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])

#             if pattern != nil
#                     filter = Gtk::FileFilter.new
#                     filter.add_pattern(pattern)
#                     filter.name = "VR Project Folders"        
#                     dialog.add_filter(filter)
#             end
    if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
      ret =  dialog.current_folder
              else
                      ret = false
    end 
    dialog.destroy
              return ret
  end
input_box(message, default="", title = "Visual Ruby") click to toggle source
# File lib/Dialog.rb, line 37
def Dialog.input_box(message, default="", title = "Visual Ruby")
dialog = Gtk::MessageDialog.new(
  nil,
  Gtk::Dialog::MODAL,
  Gtk::MessageDialog::QUESTION,
  Gtk::MessageDialog::BUTTONS_OK_CANCEL,
  message)
                dialog.title = title
                input = Gtk::Entry.new
                dialog.vbox.add(input)
                dialog.show_all
                ret = ""
dialog.run do |response|
                        if response == Gtk::Dialog::RESPONSE_OK
                                ret = input.buffer.text
                        else
                                ret = false
                        end
                end
dialog.destroy
                return ret
end
message_box(message, title = "Visual Ruby") click to toggle source
def Dialog.calendar(datetime)

dialog = Gtk::Dialog.new(

"Select Date", nil,
Gtk::Dialog::MODAL,
[Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT],
[Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT])
                     c = Gtk::Calendar.new
                     c.select_month(datetime.month, datetime.year)
                     c.select_day(datetime.day)
                     c.mark_day(datetime.day)                           
                     dialog.vbox.add(c)
                     dialog.show_all

ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? DateTime.new(*c.date) : nil

dialog.destroy
        return ret
end
# File lib/Dialog.rb, line 24
def Dialog.message_box(message, title = "Visual Ruby")
dialog = Gtk::MessageDialog.new(
nil,
Gtk::Dialog::MODAL,
Gtk::MessageDialog::INFO,
Gtk::MessageDialog::BUTTONS_OK,
message)
        dialog.title = title
        dialog.show_all
        dialog.run
        dialog.destroy
end
ok_box(message, title = "Visual Ruby") click to toggle source
# File lib/Dialog.rb, line 60
def Dialog.ok_box(message, title = "Visual Ruby")
dialog = Gtk::MessageDialog.new(
  nil,
  Gtk::Dialog::MODAL,
  Gtk::MessageDialog::QUESTION,
  Gtk::MessageDialog::BUTTONS_OK_CANCEL,
  message)
                dialog.title = title
ret = (dialog.run == Gtk::Dialog::RESPONSE_OK)
dialog.destroy
                return ret
end