Class: Iconify::TerminalWindow
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- Iconify::TerminalWindow
- Includes:
- Gtk
- Defined in:
- lib/iconify.rb
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #exec ⇒ Object
-
#initialize(argv) ⇒ TerminalWindow
constructor
A new instance of TerminalWindow.
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 65 66 67 |
# File 'lib/iconify.rb', line 17 def initialize(argv) super() @argv = argv @terminal = Vte::Terminal.new @terminal.font = Pango::FontDescription.new("monospace 14") @terminal.set_size_request(@terminal.char_width * 80, @terminal.char_height * 24) @terminal.cursor_blink_mode = Vte::CursorBlinkMode::OFF self.title = "iconify - #{argv[0]}" @state = :stopped vbox = Box.new(:vertical) hbox = ButtonBox.new(:horizontal) = Button.new(label: "Rerun") .signal_connect('clicked') do self.exec end signal_connect('changed') do .sensitive = (@state == :stopped) end = Button.new(label: "Kill") .signal_connect('clicked') do Process.kill("KILL", @pid) if @pid end signal_connect('changed') do .sensitive = (@state == :running) end = Button.new(label: "Quit") .signal_connect('clicked') do Gtk.main_quit end hbox.pack_start() hbox.pack_start() hbox.pack_start() vbox.pack_start(hbox, expand: false) vbox.pack_start(@terminal, expand: true, fill: true) add vbox @terminal.signal_connect('child-exited') do @state = :stopped @pid = nil .sensitive = true signal_emit('changed') end end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
15 16 17 |
# File 'lib/iconify.rb', line 15 def state @state end |
Instance Method Details
#exec ⇒ Object
69 70 71 72 73 |
# File 'lib/iconify.rb', line 69 def exec @pid = @terminal.spawn(argv: @argv) @state = :running signal_emit('changed') end |