[perl-Gtk3] Add overrides for some Gtk3::RadioMenuItem constructors
- From: Torsten SchÃnfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Gtk3] Add overrides for some Gtk3::RadioMenuItem constructors
- Date: Sat, 7 Jul 2012 19:25:38 +0000 (UTC)
commit 7d35e35dddd8fb68d0a315a65227f064650ec9a2
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date: Sat Jul 7 21:16:20 2012 +0200
Add overrides for some Gtk3::RadioMenuItem constructors
Original patch Dave M.
lib/Gtk3.pm | 20 ++++++++++++++
t/zz-GtkRadioMenuItem.t | 67 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index c6bf3b0..5a4d58c 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -553,6 +553,26 @@ sub Gtk3::MessageDialog::new {
return $dialog;
}
+# Gtk3::RadioMenuItem constructors.
+{
+ no strict qw(refs);
+ foreach my $ctor (qw/new new_with_label new_with_mnemonic/) {
+ *{'Gtk3::RadioMenuItem::' . $ctor} = sub {
+ my ($class, $group_or_member, @rest) = @_;
+ my $real_ctor = $ctor;
+ {
+ local $@;
+ if (eval { $group_or_member->isa ('Gtk3::RadioMenuItem') }) {
+ $real_ctor .= '_from_widget';
+ }
+ }
+ return Glib::Object::Introspection->invoke (
+ $_GTK_BASENAME, 'RadioMenuItem', $real_ctor,
+ $class, $group_or_member, @rest);
+ }
+ }
+}
+
sub Gtk3::TreeModel::get {
my ($model, $iter, @columns) = @_;
my @values = map { $model->get_value ($iter, $_) } @columns;
diff --git a/t/zz-GtkRadioMenuItem.t b/t/zz-GtkRadioMenuItem.t
new file mode 100644
index 0000000..b0ee316
--- /dev/null
+++ b/t/zz-GtkRadioMenuItem.t
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+# Based on Gtk2/t/GtkRadioMenuItem.t
+
+BEGIN { require './t/inc/setup.pl' }
+
+use strict;
+use warnings;
+
+plan tests => 11;
+
+SKIP: {
+ skip 'the list-based API is broken currently', 9
+ unless 0; # FIXME: <https://bugzilla.gnome.org/show_bug.cgi?id=679563>
+
+ my $item_one = Gtk3::RadioMenuItem -> new();
+ isa_ok($item_one, "Gtk3::RadioMenuItem");
+
+ my $item_two = Gtk3::RadioMenuItem -> new($item_one -> get_group());
+ isa_ok($item_two, "Gtk3::RadioMenuItem");
+
+ my $item_three = Gtk3::RadioMenuItem -> new_with_label([], "Bla");
+ isa_ok($item_three, "Gtk3::RadioMenuItem");
+
+ my $item_four = Gtk3::RadioMenuItem -> new_with_mnemonic([$item_one, $item_two], "_Bla");
+ isa_ok($item_four, "Gtk3::RadioMenuItem");
+
+ $item_three -> set_group($item_one -> get_group());
+ is_deeply($item_one -> get_group(),
+ [$item_one, $item_two, $item_three, $item_four]);
+
+ my $item_five = Gtk3::RadioMenuItem -> new_from_widget($item_one);
+ isa_ok($item_five, "Gtk3::RadioMenuItem");
+
+ my $item_six = Gtk3::RadioMenuItem -> new_with_label_from_widget($item_two, "Bla");
+ isa_ok($item_six, "Gtk3::RadioMenuItem");
+
+ my $item_seven = Gtk3::RadioMenuItem -> new_with_mnemonic_from_widget($item_three, "_Bla");
+ isa_ok($item_seven, "Gtk3::RadioMenuItem");
+
+ is_deeply($item_one -> get_group(),
+ [$item_one, $item_two, $item_three, $item_four,
+ $item_five, $item_six, $item_seven]);
+}
+
+SKIP: {
+ skip 'the item-based API is not bootstrap-able', 2
+ unless 0; # FIXME: <https://bugzilla.gnome.org/show_bug.cgi?id=679563>
+
+ my $item_one = Gtk3::RadioMenuItem -> new_from_widget(undef);
+ my $item_two = Gtk3::RadioMenuItem -> new($item_one);
+ my $item_three = Gtk3::RadioMenuItem -> new_with_label($item_one, "Bla");
+ my $item_four = Gtk3::RadioMenuItem -> new_with_mnemonic($item_one, "_Bla");
+ is_deeply($item_one -> get_group(), [$item_one, $item_two, $item_three, $item_four]);
+
+ my $item_five = Gtk3::RadioMenuItem -> new_from_widget($item_one);
+ my $item_six = Gtk3::RadioMenuItem -> new_with_label_from_widget($item_two, "Bla");
+ my $item_seven = Gtk3::RadioMenuItem -> new_with_mnemonic_from_widget($item_three, "_Bla");
+ is_deeply($item_seven -> get_group(),
+ [$item_one, $item_two, $item_three, $item_four,
+ $item_five, $item_six, $item_seven]);
+}
+
+__END__
+
+Copyright (C) 2003-2012 by the gtk2-perl team (see the file AUTHORS for the
+full list). See LICENSE for more information.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]