[perl-gtk3: 1/2] Reimplement varargs Gtk3::MessageDialog methods




commit 317934aa2b0fd142052fa7ca3f90a10e0953bdfe
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Jan 9 22:13:00 2021 +0000

    Reimplement varargs Gtk3::MessageDialog methods
    
    The new_with_markup, format_secondary_text, and format_secondary_markup
    methods use variadic arguments in C.
    
    Based on a patch by: Thomas Funk <t funk web de>

 lib/Gtk3.pm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
---
diff --git a/lib/Gtk3.pm b/lib/Gtk3.pm
index 52a2a6b..c632797 100644
--- a/lib/Gtk3.pm
+++ b/lib/Gtk3.pm
@@ -1430,6 +1430,39 @@ sub Gtk3::MessageDialog::new {
   return $dialog;
 }
 
+=item * A Perl reimplementation of C<Gtk3::MessageDialog::new_with_markup> is provided.
+
+=cut
+
+sub Gtk3::MessageDialog::new_with_markup {
+  my ($class, $parent, $flags, $type, $buttons, $format, @args) = @_;
+  my $dialog = Gtk3::MessageDialog::new ($class, $parent, $flags, $type, $buttons, undef);
+  if (defined $format) {
+    my $markup = sprintf $format, @args;
+    $dialog->set_markup ($markup);
+  }
+  return $dialog;
+}
+
+=item * A Perl reimplementation of C<Gtk3::MessageDialog::format_secondary_text> and
+C<Gtk3::MessageDialog::format_secondary_markup> is provided
+
+=cut
+
+sub Gtk3::MessageDialog::format_secondary_text {
+  my ($dialog, $format, @args) = @_;
+
+  my $text = sprintf $format, @args;
+  $dialog->set ('secondary-text' => $text, 'secondary-use-markup' => 0);
+}
+
+sub Gtk3::MessageDialog::format_secondary_markup {
+  my ($dialog, $format, @args) = @_;
+
+  my $text = sprintf $format, @args;
+  $dialog->set ('secondary-text' => $text, 'secondary-use-markup' => 1);
+}
+
 =item * The group handling in the constructors and accessors of
 Gtk3::RadioAction, Gtk3::RadioButton, Gtk3::RadioMenuItem and
 Gtk3::RadioToolButton is amended to work correctly when given array refs of


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]