Class: CcFileSelect

Inherits:
FlexCocoa show all
Defined in:
lib/flex_cocoa/cc_file_select.rb

Instance Attribute Summary

Attributes inherited from FlexCocoa

#exec, #output

Instance Method Summary collapse

Methods inherited from FlexCocoa

#button_response, #buttons_template, #parts_init, #post_initialize, set_path

Constructor Details

#initialize(title, message, args = {}) ⇒ CcFileSelect

Returns a new instance of CcFileSelect.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/flex_cocoa/cc_file_select.rb', line 9

def initialize (title, message, args = {})
  super()
  args = args

  if args[:flags].nil?
    args[:flags] = [:packages_as_dir]
  end

  @exec << " fileselect --title \"#{title}\" --text\"#{message}\""
  @exec << " --select-directories" if args[:flags].include?(:select_dir)
  @exec << " --select-only-directories" if args[:flags].include?(:only_dir)
  @exec << " --packages-as-directories" if args[:flags].include?(:packages_as_dir)
  @exec << "-select-multiple" if args[:flags].include?(:select_multiple)

  unless args[:extensions].nil?
    @exec << " --with-extensions"
    args[:extensions].each { |ext|
      @exec << " #{ext}"
    }
  end
  @exec << " --with-directory #{args[:dir]}" unless args[:dir].nil?
  @exec << " --with-file #{args[:file]}" unless args[:dir].nil?

  post_initialize
  response = @stdout.read.strip
  @output = response
end