[perl-Gtk3] Add overrides for Gtk3::RecentChooserDialog



commit 59afb4fbf2d13aa73bdb63e2cd6ce242f3ceb2e5
Author: Dave M <dave nerd gmail com>
Date:   Thu Jan 17 19:55:21 2013 +0100

    Add overrides for Gtk3::RecentChooserDialog

 NEWS                          |    1 +
 lib/Gtk3.pm                   |   25 +++++++++++++++++++++
 t/zz-GtkRecentChooserDialog.t |   49 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index e4e2486..0b2c34f 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@
   response IDs to nick names.  This is an API change.
 * Add overrides for Gtk3::Editable.
 * Add overrides for Gtk3::FileChooserDialog.
+* Add overrides for Gtk3::RecentChooserDialog.
 * Add overrides for Gtk3::TextBuffer.
 * Add an override for Gtk3::main_level.
 * Add Gtk3::EVENT_PROPAGATE and Gtk3::EVENT_STOP.
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index dd26bad..f6f07eb 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -864,6 +864,31 @@ sub Gtk3::MessageDialog::new {
   }
 }
 
+sub Gtk3::RecentChooserDialog::new {
+  my ($class, $title, $parent, @buttons) = @_;
+  my $dialog = Glib::Object::new ($class, title => $title);
+  for (my $i = 0; $i < @buttons; $i += 2) {
+    $dialog->add_button ($buttons[$i], $buttons[$i+1]);
+  }
+  if (defined $parent) {
+    $dialog->set_transient_for ($parent);
+  }
+  return $dialog;
+}
+
+sub Gtk3::RecentChooserDialog::new_for_manager {
+  my ($class, $title, $parent, $mgr, @buttons) = @_;
+  my $dialog = Glib::Object::new ($class, title => $title,
+    recent_manager => $mgr);
+  for (my $i = 0; $i < @buttons; $i += 2) {
+    $dialog->add_button ($buttons[$i], $buttons[$i+1]);
+  }
+  if (defined $parent) {
+    $dialog->set_transient_for ($parent);
+  }
+  return $dialog;
+}
+
 sub Gtk3::TextBuffer::create_tag {
   my ($buffer, $tag_name, @rest) = @_;
   if (@rest % 2) {
diff --git a/t/zz-GtkRecentChooserDialog.t b/t/zz-GtkRecentChooserDialog.t
new file mode 100644
index 0000000..ec4938a
--- /dev/null
+++ b/t/zz-GtkRecentChooserDialog.t
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+#
+# Originally copied from Gtk2/t/GtkRecentChooserDialog.t
+#
+
+BEGIN { require './t/inc/setup.pl' }
+
+use strict;
+use warnings;
+
+plan tests => 14;
+
+my $window = Gtk3::Window->new;
+my $manager = Gtk3::RecentManager->new;
+
+my $chooser = Gtk3::RecentChooserDialog->new ('Test', $window);
+isa_ok ($chooser, 'Gtk3::RecentChooser');
+isa_ok ($chooser, 'Gtk3::RecentChooserDialog');
+
+$chooser = Gtk3::RecentChooserDialog->new ('Test', undef);
+isa_ok ($chooser, 'Gtk3::RecentChooser');
+isa_ok ($chooser, 'Gtk3::RecentChooserDialog');
+
+$chooser = Gtk3::RecentChooserDialog->new_for_manager ('Test', $window, $manager);
+isa_ok ($chooser, 'Gtk3::RecentChooser');
+isa_ok ($chooser, 'Gtk3::RecentChooserDialog');
+
+$chooser = Gtk3::RecentChooserDialog->new_for_manager ('Test', undef, $manager);
+isa_ok ($chooser, 'Gtk3::RecentChooser');
+isa_ok ($chooser, 'Gtk3::RecentChooserDialog');
+
+$chooser = Gtk3::RecentChooserDialog->new ('Test', $window, 'gtk-ok' => 'ok');
+isa_ok ($chooser, 'Gtk3::RecentChooser');
+isa_ok ($chooser, 'Gtk3::RecentChooserDialog');
+
+my @buttons = $chooser->get_action_area->get_children;
+is (scalar @buttons, 1);
+
+$chooser = Gtk3::RecentChooserDialog->new_for_manager ('Test', $window, $manager, 'gtk-ok' => 'ok', 'gtk-cancel' => 'cancel');
+isa_ok ($chooser, 'Gtk3::RecentChooser');
+isa_ok ($chooser, 'Gtk3::RecentChooserDialog');
+
+ buttons = $chooser->get_action_area->get_children;
+is (scalar @buttons, 2);
+
+__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]