minimal.pl 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/perl
  2. # XXX:This example is outdated and uses libgtkflow in a pre-0.8-way
  3. # TODO: fix this example. use the .with_type-constructor of Sources and Sinks
  4. use Glib::Object::Introspection;
  5. Glib::Object::Introspection->setup(
  6. basename => 'Gtk',
  7. version => '3.0',
  8. package => 'Gtk');
  9. Glib::Object::Introspection->setup(
  10. basename => 'GFlow',
  11. version => '0.2',
  12. package => 'GFlow');
  13. Glib::Object::Introspection->setup(
  14. basename => 'GtkFlow',
  15. version => '0.2',
  16. package => 'GtkFlow');
  17. Gtk::init(\@ARGV);
  18. my $win = Gtk::Window->new('toplevel');
  19. my $button = Gtk::Button->new_with_label("Foo");
  20. my $vbox = Gtk::VBox->new('horizontal',0);
  21. my $sw = Gtk::ScrolledWindow->new;
  22. my $nodeview = GtkFlow::NodeView->new();
  23. my $node, $wrap1, $wrap2, $source, $sink;
  24. $button->signal_connect(clicked=>sub{
  25. my $n = create_node();
  26. print $n;
  27. $nodeview->add_node($n);
  28. });
  29. sub create_node {
  30. $node = new GFlow::SimpleNode;
  31. $wrap1 = Glib::Object::Introspection::GValueWrapper->new("Glib::Int", 0);
  32. $wrap2 = Glib::Object::Introspection::GValueWrapper->new("Glib::Int", 0);
  33. $source = GFlow::SimpleSource->new($wrap2);
  34. $source->set_name("source");
  35. $sink = GFlow::SimpleSink->new($wrap1);
  36. $sink->set_name("sink");
  37. $node->add_source($source);
  38. $node->add_sink($sink);
  39. $node->set_name("foo");
  40. return $node
  41. }
  42. $sw->add($nodeview);
  43. $vbox->pack_start($button, 0, 0, 0);
  44. $vbox->pack_start($sw, 1, 1, 1);
  45. $win->add($vbox);
  46. $win->show_all;
  47. Gtk::main();
  48. exit 0;