Class: Mireru::Window

Inherits:
Gtk::Window
  • Object
show all
Defined in:
lib/mireru/window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files, options = {}) ⇒ Window

Returns a new instance of Window.



24
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 24

def initialize(files, options={})
  super()
  @files = files
  @font = options[:font]

  @paned = Gtk::Paned.new(:horizontal)
  add(@paned)

  @navigator = Navigator.new(self, files, options)
  @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

#fileObject

Returns the value of attribute file.



23
24
25
# File 'lib/mireru/window.rb', line 23

def file
  @file
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.add_with_viewport(@widget)
  end
  show_all
end

#runObject



66
67
68
69
# File 'lib/mireru/window.rb', line 66

def run
  show_all
  Gtk.main
end