Class: Iconify::TerminalWindow

Inherits:
Gtk::Window
  • Object
show all
Includes:
Gtk
Defined in:
lib/iconify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ TerminalWindow

Returns a new instance of TerminalWindow.



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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/iconify.rb', line 17

def initialize(argv)
  super()

  @argv = argv

  @terminal = Vte::Terminal.new

  self.title = "iconify - #{argv[0]}"

  @state = :stopped

  vbox = VBox.new
  hbox = HButtonBox.new
  rerun_button = Button.new("Rerun")
  rerun_button.signal_connect('clicked') do
    self.exec
  end
  signal_connect('changed') do
    rerun_button.sensitive = (@state == :stopped)
  end

  kill_button = Button.new("Kill")
  kill_button.signal_connect('clicked') do 
    Process.kill("KILL", @pid) if @pid
  end
  signal_connect('changed') do
    kill_button.sensitive = (@state == :running)
  end

  quit_button = Button.new("Quit")
  quit_button.signal_connect('clicked') do
    Gtk.main_quit
  end
  hbox.pack_start(rerun_button)
  hbox.pack_start(kill_button)
  hbox.pack_start(quit_button)
  vbox.pack_start(hbox, false)
  vbox.pack_start(@terminal)

  add vbox

  @terminal.signal_connect('child-exited') do
    @state = :stopped
    @pid = nil
    rerun_button.sensitive = true
    signal_emit('changed')
  end
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



15
16
17
# File 'lib/iconify.rb', line 15

def state
  @state
end

Instance Method Details

#execObject



66
67
68
69
70
# File 'lib/iconify.rb', line 66

def exec
  @pid = @terminal.fork_command(argv: @argv)
  @state = :running
  signal_emit('changed')
end