Class: MainApp
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- MainApp
- Defined in:
- lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb
Defined Under Namespace
Classes: ButtonPanel
Instance Method Summary collapse
-
#initialize ⇒ MainApp
constructor
A new instance of MainApp.
- #open_zip(filename) ⇒ Object
- #show_file_selector ⇒ Object
Constructor Details
#initialize ⇒ MainApp
Returns a new instance of MainApp.
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 36 37 38 39 40 41 42 43 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb', line 11 def initialize super() set_usize(400, 256) set_title("rubyzip") signal_connect(Gtk::Window::SIGNAL_DESTROY) { Gtk.main_quit } box = Gtk::VBox.new(false, 0) add(box) @zipfile = nil = ButtonPanel.new .openButton.signal_connect(Gtk::Button::SIGNAL_CLICKED) { show_file_selector } .extractButton.signal_connect(Gtk::Button::SIGNAL_CLICKED) { puts "Not implemented!" } box.pack_start(, false, false, 0) sw = Gtk::ScrolledWindow.new sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) box.pack_start(sw, true, true, 0) @clist = Gtk::CList.new(["Name", "Size", "Compression"]) @clist.set_selection_mode(Gtk::SELECTION_BROWSE) @clist.set_column_width(0, 120) @clist.set_column_width(1, 120) @clist.signal_connect(Gtk::CList::SIGNAL_SELECT_ROW) { |w, row, column, event| @selected_row = row } sw.add(@clist) end |
Instance Method Details
#open_zip(filename) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb', line 70 def open_zip(filename) @zipfile = Zip::File.open(filename) @clist.clear @zipfile.each { |entry| @clist.append([ entry.name, entry.size.to_s, (100.0*entry.compressedSize/entry.size).to_s+"%" ]) } end |
#show_file_selector ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb', line 58 def show_file_selector @fileSelector = Gtk::FileSelection.new("Open zip file") @fileSelector.show @fileSelector..signal_connect(Gtk::Button::SIGNAL_CLICKED) { open_zip(@fileSelector.filename) @fileSelector.destroy } @fileSelector..signal_connect(Gtk::Button::SIGNAL_CLICKED) { @fileSelector.destroy } end |