minimal.pl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. use Glib::Object::Introspection;
  2. Glib::Object::Introspection->setup(
  3. basename => 'Gtk',
  4. version => '3.0',
  5. package => 'Gtk');
  6. Glib::Object::Introspection->setup(
  7. basename => 'GFlow',
  8. version => '0.2',
  9. package => 'GFlow');
  10. Glib::Object::Introspection->setup(
  11. basename => 'GtkFlow',
  12. version => '0.2',
  13. package => 'GtkFlow');
  14. Gtk::init(\@ARGV);
  15. my $win = Gtk::Window->new('toplevel');
  16. my $button = Gtk::Button->new_with_label("Foo");
  17. my $vbox = Gtk::VBox->new('horizontal',0);
  18. my $sw = Gtk::ScrolledWindow->new;
  19. my $nodeview = GtkFlow::NodeView->new();
  20. my $node, $wrap1, $wrap2, $source, $sink;
  21. $button->signal_connect(clicked=>sub{
  22. my $n = create_node();
  23. print $n;
  24. $nodeview->add_node($n);
  25. });
  26. sub create_node {
  27. $node = new GFlow::SimpleNode;
  28. $wrap1 = Glib::Object::Introspection::GValueWrapper->new("Glib::Int", 0);
  29. $wrap2 = Glib::Object::Introspection::GValueWrapper->new("Glib::Int", 0);
  30. $source = GFlow::SimpleSource->new($wrap2);
  31. $source->set_name("source");
  32. $sink = GFlow::SimpleSink->new($wrap1);
  33. $sink->set_name("sink");
  34. $node->add_source($source);
  35. $node->add_sink($sink);
  36. $node->set_name("foo");
  37. return $node
  38. }
  39. $sw->add($nodeview);
  40. $vbox->pack_start($button, 0, 0, 0);
  41. $vbox->pack_start($sw, 1, 1, 1);
  42. $win->add($vbox);
  43. $win->show_all;
  44. Gtk::main();
  45. exit 0;