protected class PolygenRun : Gtk.VBox
{
- protected Gtk.Label text;
- protected Gtk.Button text_button;
+ public Gtk.ScrolledWindow scroll;
+ protected Gtk.TextBuffer text_buffer;
+ protected Gtk.TextView text;
private string _grammar;
public string grammar {
public PolygenRun()
{
_grammar = "";
- text = new Gtk.Label("");
- text.use_markup = true;
- text.wrap = true;
- text_button = new Gtk.Button();
- text_button.set_image(text);
- pack_start(text_button, true, true, 0);
- text_button.clicked += on_clicked;
+ text_buffer = new Gtk.TextBuffer(null);
+ text = new Gtk.TextView.with_buffer(text_buffer);
+ text.wrap_mode = Gtk.WrapMode.WORD;
+ text.cursor_visible = false;
+ text.editable = false;
+ text.add_events(Gdk.EventMask.BUTTON_PRESS_MASK);
+ text.button_press_event += on_button_press;
+ scroll = new Gtk.ScrolledWindow (null, null);
+ scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
+ scroll.add(text);
+ pack_start(scroll, true, true, 0);
}
- public void on_clicked(Gtk.Button button) { update(); }
+ public bool on_button_press(Gdk.EventButton event)
+ {
+ update();
+ return true;
+ }
public void update()
{
- text.label = "ciao " + _grammar;
+ string[] args = new string[3];
+ args[0] = "/usr/bin/polygen";
+ args[1] = "/usr/share/polygen/" + _grammar + ".grm";
+ args[2] = null;
+ int pipe_out;
+ Process.spawn_async_with_pipes(config.homedir, args, null, 0, null, null, null, out pipe_out, null);
+ IOChannel ch = new IOChannel.unix_new(pipe_out);
+ string result;
+ ch.read_to_end(out result, null);
+ ch.shutdown(false);
+
+ text_buffer.text = result;
+ Gtk.TextIter iter;
+ text_buffer.get_iter_at_offset(out iter, 0);
+ Gtk.TextMark mark = text_buffer.create_mark(null, iter, true);
+ text.scroll_mark_onscreen(mark);
}
}