minimal.vala 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/vala
  2. //Compile $ valac minimal.vala --pkg gtk+-3.0 --pkg gflow-0.2 --pkg gtkflow-0.2
  3. //Run ./minimal.vala --pkg gtk+-3.0 --pkg gtkflow-0.2 --pkg gflow-0.2
  4. using Gtk;
  5. using GFlow;
  6. GtkFlow.NodeView nv;
  7. void main(string[] args)
  8. {
  9. Gtk.init(ref args);
  10. var window = new Window();
  11. window.set_default_size(400, 300);
  12. window.destroy.connect(Gtk.main_quit);
  13. var bar = new HeaderBar();
  14. bar.show_close_button = true;
  15. bar.title = "GTK Flow!";
  16. window.set_titlebar(bar);
  17. var sw = new ScrolledWindow(null,null);
  18. nv = new GtkFlow.NodeView();
  19. var btn = new Button.with_label("Add Node");
  20. var box = new Box(Orientation.VERTICAL,0);
  21. btn.clicked.connect(() => {
  22. var n = new GFlow.SimpleNode ();
  23. var sink_v = Value(Type.INT);
  24. var source_v = Value(Type.INT);
  25. var sink = new GFlow.SimpleSink(sink_v);
  26. var source = new GFlow.SimpleSource(source_v);
  27. sink.name = "sink";
  28. source.name = "source";
  29. n.add_source(source);
  30. n.add_sink(sink);
  31. n.name = "node";
  32. nv.add_node(n);
  33. });
  34. sw.expand = true;
  35. bar.add(btn);
  36. box.add(sw);
  37. sw.add(nv);
  38. window.add(box);
  39. window.show_all();
  40. Gtk.main();
  41. }