Class: Mir::ViewerWindow

Inherits:
Gtk::ApplicationWindow
  • Object
show all
Defined in:
lib/mir/02_viewer.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, image) ⇒ ViewerWindow

Returns a new instance of ViewerWindow.



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
59
60
# File 'lib/mir/02_viewer.rb', line 34

def initialize app,image
  super(app)
  set_title image.name||"Mir::Viewer"
  if image.size.x < 200
    size=[200,100]
  else
    size=*image.size
  end
  set_default_size *size
  set_window_position(:center)
  signal_connect(:destroy){Gtk.main_quit}
  # Create a box to hold the contents of the window
  box = Gtk::Box.new(:vertical,0)
  # Add a button to the window to quit the application
  button = Gtk::Button.new(label: 'Quit')
  button.signal_connect('clicked') { application.quit }

  board = PixelBoard.new(image)

  # Add the button to the box
  box.pack_start(board, :expand => true, :fill => true, :padding => 0)
  box.pack_start(button, :expand => false, :fill => true, :padding => 0)

  # Add the box to the window
  add(box)
  show_all
end