[perl-gtk3] Correctly handle flags argument in Gtk3::Dialog::new and Gtk3::MessageDialog::new
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-gtk3] Correctly handle flags argument in Gtk3::Dialog::new and Gtk3::MessageDialog::new
- Date: Sat, 16 Jan 2021 18:01:57 +0000 (UTC)
commit 3e101a55bcd2a499de3916a3510cd6aaa4088747
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Sat Jan 16 18:58:24 2021 +0100
Correctly handle flags argument in Gtk3::Dialog::new and Gtk3::MessageDialog::new
The flags argument was assumed to always be of type Gtk3::DialogFlags. If it
was a bare array ref, which it usually is, all dialogs were being set modal and
destroy-with-parent.
https://gitlab.gnome.org/GNOME/perl-gtk3/-/issues/6
lib/Gtk3.pm | 6 ++++++
t/zz-GtkDialog.t | 25 ++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index c632797..1036625 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -1132,6 +1132,9 @@ sub Gtk3::Dialog::new {
my $dialog = Gtk3::Dialog->new;
defined $title and $dialog->set_title ($title);
defined $parent and $dialog->set_transient_for ($parent);
+ if (! eval { $flags->isa ('Gtk3::DialogFlags'); }) {
+ $flags = Gtk3::DialogFlags->new ($flags);
+ }
$flags & 'modal' and $dialog->set_modal (Glib::TRUE);
$flags & 'destroy-with-parent' and $dialog->set_destroy_with_parent (Glib::TRUE);
$dialog->add_buttons (@rest);
@@ -1421,6 +1424,9 @@ sub Gtk3::MessageDialog::new {
if (defined $parent) {
$dialog->set_transient_for ($parent);
}
+ if (! eval { $flags->isa ('Gtk3::DialogFlags'); }) {
+ $flags = Gtk3::DialogFlags->new ($flags);
+ }
if ($flags & 'modal') {
$dialog->set_modal (Glib::TRUE);
}
diff --git a/t/zz-GtkDialog.t b/t/zz-GtkDialog.t
index efdaf38..95bc945 100644
--- a/t/zz-GtkDialog.t
+++ b/t/zz-GtkDialog.t
@@ -7,7 +7,7 @@ BEGIN { require './t/inc/setup.pl' };
use strict;
use warnings;
-plan tests => 17;
+plan tests => 49;
my $win = Gtk3::Window->new ('toplevel');
@@ -102,3 +102,26 @@ SKIP: {
ok (defined Gtk3::alternative_dialog_button_order (undef));
ok (defined Gtk3::alternative_dialog_button_order);
}
+
+{
+ my @expectations = (
+ [[], Glib::FALSE, Glib::FALSE],
+ [['modal'], Glib::TRUE, Glib::FALSE],
+ [['destroy-with-parent'], Glib::FALSE, Glib::TRUE],
+ [['modal', 'destroy-with-parent'], Glib::TRUE, Glib::TRUE],
+ [Gtk3::DialogFlags->new ([]), Glib::FALSE, Glib::FALSE],
+ [Gtk3::DialogFlags->new (['modal']), Glib::TRUE, Glib::FALSE],
+ [Gtk3::DialogFlags->new (['destroy-with-parent']), Glib::FALSE, Glib::TRUE],
+ [Gtk3::DialogFlags->new (['modal', 'destroy-with-parent']), Glib::TRUE, Glib::TRUE],
+ );
+ foreach my $e (@expectations) {
+ my $d = Gtk3::Dialog->new ('Test Dialog', $win, $e->[0], 'gtk-ok', 1);
+ is ($d->get_modal, $e->[1]);
+ is ($d->get_destroy_with_parent, $e->[2]);
+ }
+ foreach my $e (@expectations) {
+ my $d = Gtk3::MessageDialog->new ($win, $e->[0], 'info', 'ok');
+ is ($d->get_modal, $e->[1]);
+ is ($d->get_destroy_with_parent, $e->[2]);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]