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.
-
#font ⇒ Object
Returns the value of attribute font.
Instance Method Summary collapse
- #add_from_file(file, chupa = false) ⇒ Object
-
#initialize(files) ⇒ Window
constructor
A new instance of Window.
- #run ⇒ Object
Constructor Details
#initialize(files) ⇒ 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 |
# File 'lib/mireru/window.rb', line 25 def initialize(files) super() @files = files @paned = Gtk::Paned.new(:horizontal) add(@paned) @navigator = Navigator.new(self, files) @paned.add(@navigator) @scroll = Gtk::ScrolledWindow.new @scroll.set_policy(:automatic, :automatic) @paned.add(@scroll) set_default_size(800, 600) 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 |
#font ⇒ Object
Returns the value of attribute font.
23 24 25 |
# File 'lib/mireru/window.rb', line 23 def font @font end |
Instance Method Details
#add_from_file(file, chupa = false) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mireru/window.rb', line 47 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 show_all end |
#run ⇒ Object
66 67 68 69 |
# File 'lib/mireru/window.rb', line 66 def run show_all Gtk.main end |