Class: JLDrill::Gtk::SelectorWindow

Inherits:
Gtk::FileChooserDialog
  • Object
show all
Includes:
Context::Gtk::Widget
Defined in:
lib/jldrill/views/gtk/widgets/SelectorWindow.rb

Instance Attribute Summary collapse

Attributes included from Context::Gtk::Widget

#gtkWidgetMainWindow

Instance Method Summary collapse

Methods included from Context::Gtk::Widget

#addToThisWidget, #afterWidgetIsAdded, #afterWidgetIsRemoved, #expandWidgetHeight, #expandWidgetHeight?, #expandWidgetWidth, #expandWidgetWidth?, #gtkAddWidget, #gtkRemoveWidget, #isAMainWindow, #isInTests?, #removeFromThisWidget, #setupWidget, #widgetWasAddedTo, #widgetWasRemovedFrom

Constructor Details

#initialize(type) ⇒ SelectorWindow

Returns a new instance of SelectorWindow.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jldrill/views/gtk/widgets/SelectorWindow.rb', line 13

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

Instance Attribute Details

#chosenDirectoryObject

Returns the value of attribute chosenDirectory.



10
11
12
# File 'lib/jldrill/views/gtk/widgets/SelectorWindow.rb', line 10

def chosenDirectory
  @chosenDirectory
end

#chosenFilenameObject

Returns the value of attribute chosenFilename.



10
11
12
# File 'lib/jldrill/views/gtk/widgets/SelectorWindow.rb', line 10

def chosenFilename
  @chosenFilename
end

Instance Method Details

#executeObject



39
40
41
42
43
44
45
46
47
# File 'lib/jldrill/views/gtk/widgets/SelectorWindow.rb', line 39

def execute
    if run == Gtk::Dialog::RESPONSE_ACCEPT
        @chosenFilename = getFilename
        @chosenDirectory = getCurrentFolder
        return @chosenFilename
    else
        return nil
    end
end

#getCurrentFolderObject



35
36
37
# File 'lib/jldrill/views/gtk/widgets/SelectorWindow.rb', line 35

def getCurrentFolder
    self.current_folder
end

#getFilenameObject

The following 2 routines are only here because I couldn’t figure out a way to set the filename and folder in my tests.



31
32
33
# File 'lib/jldrill/views/gtk/widgets/SelectorWindow.rb', line 31

def getFilename
    self.filename
end