Class: Druzy::LittleFrame::FileChooserView

Inherits:
MVC::View
  • Object
show all
Defined in:
lib/druzy/little_frame/file_chooser.rb

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ FileChooserView

Returns a new instance of FileChooserView.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/druzy/little_frame/file_chooser.rb', line 67

def initialize(controller)
  super(controller)
  Gtk.init
  @window =Gtk::Window.new
  @window.signal_connect('destroy') do
    Thread.new do
      @controller.notify_action(self,:destroy)
    end
  end
  
  @open = Gtk::Button.new(:label => "Ouvrir")
  @open.signal_connect("clicked") do
    Thread.new do
      @controller.notify_action(self,:open_clicked, :files => @chooser.filenames)
    end
  end
  
  @cancel = Gtk::Button.new(:label => "Annuler")  
  @cancel.signal_connect("clicked") do
    Thread.new do
      @controller.notify_action(self,:destroy)
    end
  end
  
  @chooser = Gtk::FileChooserWidget.new(Gtk::FileChooser::Action::OPEN)
  @chooser.select_multiple = true
  for filter in @controller.model.filters_mime_type
    f=Gtk::FileFilter.new
    f.add_mime_type(filter)
    f.name = filter
    @chooser.add_filter(f)
  end
  
  @main_vbox = Gtk::Box.new(:vertical,0)
  
  @button_hbox = Gtk::Box.new(:horizontal,0)
  
  #ajout des composants 
  @window.add(@main_vbox)
  
  @main_vbox.pack_start(@chooser)
  @main_vbox.pack_start(@button_hbox, :expand => false, :padding => 20)
  
  @button_hbox.pack_end(@open, :expand => false, :padding => 20)
  @button_hbox.pack_end(@cancel, :expand => false)
  
  
  Thread.new do
    Gtk.main
  end
end

Instance Method Details

#closeObject



123
124
125
# File 'lib/druzy/little_frame/file_chooser.rb', line 123

def close
  Gtk.main_quit
end

#displayObject



119
120
121
# File 'lib/druzy/little_frame/file_chooser.rb', line 119

def display
  @window.show_all
end