Sha256: 46592e6df4a22006756c5f492680329ff686cf9b7b729efe6b0cc318a339cb72

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'Context/Gtk/Widget'
require 'jldrill/contexts/GetFilenameContext'
require 'gtk2'

module JLDrill::Gtk
    class SelectorWindow < Gtk::FileChooserDialog
        include Context::Gtk::Widget

        attr_reader :chosenFilename, :chosenDirectory
        attr_writer :chosenFilename, :chosenDirectory
    
        def initialize(type)
            @chosenFilename = nil
            @chosenDirectory = nil
            if (type == JLDrill::GetFilenameContext::SAVE)
                super("Save File", nil,
                      Gtk::FileChooser::ACTION_SAVE, nil,
                      [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
                      [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
            else
                super("Open File", nil,
                      Gtk::FileChooser::ACTION_OPEN, nil,
                      [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
                      [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
            end
        end
        
        # The following 2 routines are only here because I couldn't
        # figure out a way to set the filename and folder in my tests.
        def getFilename
            self.filename
        end
        
        def getCurrentFolder
            self.current_folder
        end
    
        def execute
            if run == Gtk::Dialog::RESPONSE_ACCEPT
                @chosenFilename = getFilename
                @chosenDirectory = getCurrentFolder
                return @chosenFilename
            else
                return nil
            end
        end
    end	    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.5.1.7 lib/jldrill/views/gtk/widgets/SelectorWindow.rb