lib/iconify.rb in iconify-0.1.2 vs lib/iconify.rb in iconify-0.2.0
- old
+ new
@@ -1,7 +1,7 @@
-require 'gtk2'
-require 'vte'
+require 'gtk3'
+require 'vte3'
require "iconify/version"
require "iconify/program"
module Iconify
@@ -18,42 +18,45 @@
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 = VBox.new
- hbox = HButtonBox.new
- rerun_button = Button.new("Rerun")
+ vbox = Box.new(:vertical)
+ hbox = ButtonBox.new(:horizontal)
+ rerun_button = Button.new(label: "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 = Button.new(label: "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 = Button.new(label: "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)
+ vbox.pack_start(hbox, expand: false)
+ vbox.pack_start(@terminal, expand: true, fill: true)
add vbox
@terminal.signal_connect('child-exited') do
@state = :stopped
@@ -62,11 +65,11 @@
signal_emit('changed')
end
end
def exec
- @pid = @terminal.fork_command(argv: @argv)
+ @pid = @terminal.spawn(argv: @argv)
@state = :running
signal_emit('changed')
end
end
@@ -93,14 +96,16 @@
end
redraw
end
def redraw
- pixmap = Gdk::Pixmap.new(nil, 64, 64, 24)
+ # pixmap = Gdk::Pixmap.new(nil, 64, 64, 24)
- cr = pixmap.create_cairo_context
+ image_surface = Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, 64, 64)
+ cr = Cairo::Context.new(image_surface)
+
cr.set_source_rgb(0.8, 0.8, 0.8)
cr.set_operator(Cairo::OPERATOR_SOURCE)
cr.paint
cr.set_source_rgb(*@background_color)
@@ -112,11 +117,13 @@
cr.set_source_rgba(*@foreground_color, 1)
cr.show_text(@name)
cr.destroy
- buf = Gdk::Pixbuf.from_drawable(nil, pixmap, 0, 0, 64, 64)
+ buf = image_surface.to_pixbuf(0, 0, 64, 64)
self.pixbuf = buf
+
+ image_surface.destroy
end
end
end