Sha256: 7c3585b72aad269bcfda9ffbe6fd62f124832d68f0cd593216d2e2f3d851073d

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8
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.6.0.1 lib/jldrill/views/gtk/widgets/SelectorWindow.rb