Gtk3

 view release on metacpan or  search on metacpan

t/overrides.t  view on Meta::CPAN

  is ($dialog->get_action, 'save');
}

note('Gtk3::FontButton::new');
{
  my $button = Gtk3::FontButton->new;
  # $button->get_font_name can be anything
  $button = Gtk3::FontButton->new ('Sans');
  ok (defined $button->get_font_name);
}

note('Gtk3::LinkButton::new');
{
  my ($host, $label) = ('http://localhost', 'Local');
  my $button = Gtk3::LinkButton->new ($host);
  is ($button->get_label, $host);
  $button = Gtk3::LinkButton->new ($host, $label);
  is ($button->get_label, $label);
}

SKIP: {
  skip 'Gtk3::ListStore; tree model ctors not properly supported', 10
    unless check_gi_version(1, 29, 17);

  note('Gtk3::ListStore::new, set and get, insert_with_values');
  my $model = Gtk3::ListStore->new ([qw/Glib::String Glib::Int/]);
  my $iter = $model->append;
  $model->set ($iter, [0, 1], ['Foo', 23]);
  is_deeply ([$model->get ($iter)], ['Foo', 23]);
  is_deeply ([$model->get ($iter, 0,1)], ['Foo', 23]);
  is (scalar $model->get ($iter, 0,1), 23);

  $iter = $model->append;
  $model->set ($iter, 0 => 'Bar', 1 => 42);
  is_deeply ([$model->get ($iter)], ['Bar', 42]);
  is_deeply ([$model->get ($iter, 0,1)], ['Bar', 42]);
  is (scalar $model->get ($iter, 0,1), 42);

  {
    local $@;
    eval { $model->set ($iter, 0) };
    like ($@, qr/Usage/);
  }

  $iter = $model->insert_with_values (-1, [0, 1], ['FooFoo', 2323]);
  is_deeply ([$model->get ($iter)], ['FooFoo', 2323]);
  $iter = $model->insert_with_values (-1, 0 => 'BarBar', 1 => 4242);
  is_deeply ([$model->get ($iter)], ['BarBar', 4242]);

  {
    local $@;
    eval { $model->insert_with_values (-1, 0); };
    like ($@, qr/Usage/);
  }
}

SKIP: {
  skip 'Gtk3::Menu; incorrect annotations', 2
    unless Gtk3::CHECK_VERSION (3, 2, 0);

  note('Gtk3::Menu::popup and popup_for_device');
  {
    my $menu = Gtk3::Menu->new;
    my $position_callback;
    if (Gtk3::CHECK_VERSION (3, 16, 0)) {
      $position_callback = sub {
        my ($menu, $x, $y, $data) = @_;
        isa_ok ($menu, "Gtk3::Menu");
        return @$data;
      };
    } else {
      $position_callback = sub {
        my ($menu, $data) = @_;
        isa_ok ($menu, "Gtk3::Menu");
        return @$data;
      };
    }
    $menu->popup (undef, undef, $position_callback, [50, 50], 1, 0);
    $menu->popup_for_device (undef, undef, undef, $position_callback, [50, 50, Glib::TRUE], 1, 0);
  }

  # Test this separately to ensure that specifying no callback does not lead to
  # an invalid invocation of the destroy notify func.
  {
    my $menu = Gtk3::Menu->new;
    $menu->popup (undef, undef, undef, undef, 1, 0);
  }
}

note('Gtk2::MenuItem::new, Gtk2::CheckMenuItem::new, Gtk2::ImageMenuItem::new');
{
  foreach my $class (qw/Gtk3::MenuItem Gtk3::CheckMenuItem Gtk3::ImageMenuItem/) {
    my $item;

    $item = $class->new;
    isa_ok ($item, $class);
    ok (!$item->get_label); # might be '' or undef

    $item = $class->new ('_Test');
    isa_ok ($item, $class);
    is ($item->get_label, '_Test');

    $item = $class->new_with_mnemonic ('_Test');
    isa_ok ($item, $class);
    is ($item->get_label, '_Test');
  }
}

note('Gtk3::SizeGroup');
{
  my $group = Gtk3::SizeGroup->new ("vertical");

  my @widgets = $group->get_widgets;
  ok (!@widgets);

  my ($uno, $dos, $tres, $cuatro) =
    (Gtk3::Label->new ("Tinky-Winky"),
     Gtk3::Label->new ("Dipsy"),
     Gtk3::Label->new ("La La"),
     Gtk3::Label->new ("Po"));

  $group->add_widget ($uno);
  $group->add_widget ($dos);
  $group->add_widget ($tres);
  $group->add_widget ($cuatro);
  @widgets = $group->get_widgets;
  is (scalar @widgets, 4);
}

note('Gtk3::Stock');
{
  ok (grep { $_ eq 'gtk-ok' } Gtk3::Stock::list_ids ());
  my $item = Gtk3::Stock::lookup ('gtk-ok');
  is ($item->{stock_id}, 'gtk-ok');
  note('Gtk3::Stock::add and add_static do not work yet');
  Gtk3::Stock::set_translate_func ('perl-domain', sub {}, 42);
}

note('Gtk3::StyleContext::get');
{
  my $l = Gtk3::Label->new ('Test');
  my $c = $l->get_style_context;
  my @v = $c->get ('normal', Gtk3::STYLE_PROPERTY_COLOR, Gtk3::STYLE_PROPERTY_FONT);
  is (scalar @v, 2, 'two items returned');
}



( run in 0.773 second using v1.01-cache-2.11-cpan-364913b4093 )