Class: Mireru::Window
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- Mireru::Window
- Defined in:
- lib/mireru/window.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
- #add_from_file(file, chupa = false) ⇒ Object
-
#initialize(files, options = {}) ⇒ Window
constructor
A new instance of Window.
- #run ⇒ Object
Constructor Details
#initialize(files, options = {}) ⇒ Window
Returns a new instance of Window.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/mireru/window.rb', line 25 def initialize(files, ={}) super() @files = files @font = [:font] @paned = Gtk::Paned.new(:horizontal) add(@paned) @navigator = Navigator.new(self, files, ) @paned.add(@navigator) @main_vbox = Gtk::Box.new(:vertical) @paned.add(@main_vbox) @scroll = Gtk::ScrolledWindow.new @scroll.set_policy(:automatic, :automatic) @main_vbox.pack_start(@scroll, :expand => true, :fill => true, :padding => 0) @status_bar = StatusBar.new @main_vbox.pack_end(@status_bar, :expand => false, :fill => false, :padding => 0) @default_width = [:width] || 800 @default_height = [:height] || 600 set_default_size(@default_width, @default_height) signal_connect("destroy") do Gtk.main_quit end define_keybind end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
24 25 26 |
# File 'lib/mireru/window.rb', line 24 def file @file end |
Instance Method Details
#add_from_file(file, chupa = false) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mireru/window.rb', line 60 def add_from_file(file, chupa=false) @scroll.hadjustment.value = 0 @scroll.vadjustment.value = 0 @scroll.each do |child| @scroll.remove(child) child.destroy end width = @scroll.allocated_width - 10 height = @scroll.allocated_height - 10 @widget = Mireru::Widget.create(file, width, height, chupa) @widget.override_font(Pango::FontDescription.new(@font)) if @font if @widget.is_a?(Gtk::Scrollable) @scroll.add(@widget) else @scroll.(@widget) end @status_bar.set_file(file) show_all end |
#run ⇒ Object
80 81 82 83 |
# File 'lib/mireru/window.rb', line 80 def run show_all Gtk.main end |