Fix email address
[clawsker.git] / clawsker
index 05d8dba1d40b554292aba236fb5389af724abf3c..6b5ff7d120dd6d4cd446dac79cc75b20004204fb 100755 (executable)
--- a/clawsker
+++ b/clawsker
@@ -42,9 +42,6 @@ setlocale (LC_ALL, $locale);
 bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
 textdomain ($NAME);
 
-my $SHOWHINTS = FALSE;
-$SHOWHINTS = TRUE if ($Gtk3::VERSION >= 1.040 and Gtk3->CHECK_VERSION (2, 12, 0));
-
 sub _ {
     my $str = shift;
     my %par = @_;
@@ -60,10 +57,10 @@ sub _ {
 # default messages
 %xl::s = (
     win_title => _('Claws Mail Hidden Preferences'),
-    about => _('About...'),
     about_title => _('Clawsker :: A Claws Mail Tweaker'),
-    about_license => _('License:'),
-    about_version => _('Version:'),
+    about_web_label => _("Visit Clawsker's web page"),
+
+    error_title => _('Clawsker error'),
 
     exit_title => _('Clawsker warning'),
     exit_fact => _('There are unapplied modifications.'),
@@ -383,32 +380,32 @@ sub handle_nchar_value {
         if defined $$dataref->[IVALUE];
 }
 
-sub gdk_color_from_str {
+sub gdk_rgba_from_str {
     my ($str) = @_;
     my ($rr, $gg, $bb) = (0, 0 ,0);
     $_ = uc ($str);
     if (/\#([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])([A-F0-9][A-F0-9])/) {
-        $rr = hex($1) * 256;
-        $gg = hex($2) * 256;
-        $bb = hex($3) * 256;
+        $rr = hex($1) / 256;
+        $gg = hex($2) / 256;
+        $bb = hex($3) / 256;
     }
-    my $color = Gtk3::Gdk::Color->new ($rr, $gg, $bb);
+    my $color = Gtk3::Gdk::RGBA->new ($rr, $gg, $bb, 1.0);
     return $color;
 }
 
-sub str_from_gdk_color {
+sub str_from_gdk_rgba {
     my ($color) = @_;
-    my $rr = $color->red / 256;
-    my $gg = $color->green / 256;
-    my $bb = $color->blue / 256;
+    my $rr = $color->red * 256;
+    my $gg = $color->green * 256;
+    my $bb = $color->blue * 256;
     my $str = sprintf ("#%.2x%.2x%.2x", $rr, $gg, $bb);
     return $str;
 }
 
 sub handle_color_value {
     my ($widget, $event, $dataref) = @_;
-    my $newcol = $widget->get_color;
-    $$dataref->[VALUE] = str_from_gdk_color ($newcol);
+    my $newcol = $widget->get_rgba;
+    $$dataref->[VALUE] = str_from_gdk_rgba ($newcol);
     $MODIFIED += $$dataref->[VALUE] ne $$dataref->[IVALUE]? 1: -1
         if defined $$dataref->[IVALUE];
 }
@@ -450,12 +447,37 @@ sub log_message {
     }
 }
 
+sub message_dialog {
+    my ($parent, $title, $markup, $type, $buttons) = @_;
+    my $flags = [qw/modal destroy-with-parent/];
+    my $dialog = Gtk3::Dialog->new_with_buttons (
+        $title, $parent, $flags, @$buttons
+    );
+    my $label = Gtk3::Label->new;
+    $label->set_markup ($markup);
+    my $icon = undef;
+    if ($type eq 'error') {
+      $icon = Gtk3::Image->new_from_icon_name('dialog-error', 'GTK_ICON_SIZE_DIALOG');
+    } elsif ($type eq 'warning') {
+      $icon = Gtk3::Image->new_from_icon_name('dialog-warning', 'GTK_ICON_SIZE_DIALOG');
+    } elsif ($type eq 'question') {
+      $icon = Gtk3::Image->new_from_icon_name('dialog-question', 'GTK_ICON_SIZE_DIALOG');
+    }
+    my $hbox = Gtk3::Box->new ('horizontal', 5);
+    $hbox->pack_start ($icon, FALSE, FALSE, 5) if defined $icon;
+    $hbox->pack_start ($label, FALSE, FALSE, 5);
+    my $dialogbox = $dialog->get_content_area;
+    $dialogbox->add ($hbox);
+    $dialogbox->show_all;
+    return $dialog;
+}
+
 sub error_dialog {
     my ($emsg) = @_;
     my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
-    my $errordlg = Gtk3::MessageDialog->new ($main_window, 'modal', 'error', 'cancel');
-    $errordlg->set_markup ($markup);
-    $errordlg->set_title (_('Clawsker error'));
+    my $errordlg = message_dialog (
+        $main_window, $xl::s{error_title}, $markup, 'error', [ 'gtk-cancel', 0 ]
+    );
     $errordlg->run;
     $errordlg->destroy;
 }
@@ -493,11 +515,9 @@ sub check_rc_file {
 }
 
 sub set_widget_hint {
-    if ($SHOWHINTS) {
-        my ($wdgt, $hint) = @_;
-        $wdgt->set_tooltip_text ($hint);
-        $wdgt->set_has_tooltip (TRUE);
-    }
+    my ($wdgt, $hint) = @_;
+    $wdgt->set_tooltip_text ($hint);
+    $wdgt->set_has_tooltip (TRUE);
 }
 
 sub set_widget_sens {
@@ -606,9 +626,9 @@ sub new_color_button_for($$$) {
     #
     my $value = $$vhash{$name}[VALUE];
     $value //= $$hash{$key}[CMDEF];
-    my $col = gdk_color_from_str ($value);
+    my $col = gdk_rgba_from_str ($value);
     my $glabel = Gtk3::Label->new ($label);
-    my $button = Gtk3::ColorButton->new_with_color ($col);
+    my $button = Gtk3::ColorButton->new_with_rgba ($col);
     $button->set_title ($label);
     $button->set_relief ('none');
     $button->signal_connect ('color-set' => sub {
@@ -2750,60 +2770,67 @@ sub new_notebook {
 # create an about dialog
 sub new_about_dialog {
     my ($parent) = @_;
-    my $title = $xl::s{about_title};
-    my $lic = $xl::s{about_license};
-    my $vers = $xl::s{about_version} . " $VERSION";
-    my $license =
-"This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.";
-    my $year = "2007-2018";
-    my $holder = "Ricardo Mones &lt;ricardo\@mones.org&gt;";
-    my $url = "http://www.claws-mail.org/clawsker.php";
-
-    my $dialog = Gtk3::MessageDialog->new ($parent,
-        [qw/modal destroy-with-parent/], 'info', 'close');
-    $dialog->set_markup (
-        "<span size=\"x-large\" weight=\"bold\">$title</span>\n"
-        . "<span size=\"large\">$vers</span>\n\n"
-        . "<span color=\"blue\" size=\"large\">$url</span>\n\n"
-        . "<span>Copyright $year by $holder</span>\n\n"
-        . "<span size=\"large\">$lic</span>\n\n"
-        . "<span size=\"small\">$license</span>");
-    $dialog->set_title ($xl::s{about});
-    if (Gtk3->CHECK_VERSION (2, 10, 0)) {
-        my @icons = get_app_icons ();
-        my $image = Gtk3::Image->new_from_pixbuf ($icons[-1]);
-        $image->show ();
-        $image->set_alignment (0, 0);
-        $dialog->set_image ($image);
-    }
-    #
+    my $year = '2007-2018';
+    my $holder = 'Ricardo Mones <ricardo@mones.org>';
+    my $url = 'http://www.claws-mail.org/clawsker.php';
+    my $icons = &get_app_icons;
+
+    my $dialog = Gtk3::AboutDialog->new;
+    $dialog->set_transient_for ($parent);
+    $dialog->set_program_name ('Clawsker');
+    $dialog->set_version ($VERSION);
+    $dialog->set_copyright ("Copyright © $year $holder");
+    $dialog->set_license_type ('gpl-3-0');
+    $dialog->set_website ($url);
+    $dialog->set_website_label ($xl::s{about_web_label});
+    # committers, by number of commits
+    $dialog->set_authors ([
+        $holder,
+        'Tristan Chabredier (wwp) <subscript@free.fr>',
+        'Andreas Rönnquist <andreas@ronnquist.net>',
+        'Christian Hesse <mail@eworm.de>',
+    ]);
+    $dialog->set_artists ([
+        'Jesper Schultz <jesper@schultz-net.dk>',
+        $holder,
+    ]);
+    $dialog->set_documenters ([
+        $holder,
+        'Paul Mangan <paul@claws-mail.org>',
+    ]);
+    # active translators, in alphabetical order
+    $dialog->set_translator_credits (join ("\n",
+        'Andreas Rönnquist <andreas@ronnquist.net>',
+        'Axel Köllhofer <AxelKoellhofer@web.de>',
+        'David Medina <opensusecatala@gmail.com>',
+        'Erik P. Olsen <erik@epo.dk>',
+        'Frederico Goncalves Guimaraes <frederico@teia.bio.br>',
+        'Marcel Pol <marcel@timelord.nl>',
+        'Mark Chang <mark.cyj@gmail.com>',
+        'M. Sulchan Darmawan <bleketux@gmail.com>',
+        'Numan Demirdöğen <if.gnu.linux@gmail.com>',
+        'Petter Adsen <petter@synth.no>',
+        $holder,
+        'Tristan Chabredier (wwp) <subscript@free.fr>',
+    ));
+    $dialog->set_title ($xl::s{about_title});
+    $dialog->set_logo ($icons->[-1]);
+
     return $dialog;
 }
 
 sub exit_handler {
   my ($parent) = @_;
   if ($MODIFIED != 0 and not $READONLY) {
-    my $fact = $xl::s{exit_fact};
-    my $question = $xl::s{exit_question};
-    my $dialog = Gtk3::MessageDialog->new ($parent,
-        [qw/modal destroy-with-parent/], 'warning', 'yes-no');
-    $dialog->set_markup ("<span>$fact</span>\n\n"
-        . "<span weight=\"bold\">$question</span>");
-    $dialog->set_title ($xl::s{exit_title});
+    my $markup = "<span>" . $xl::s{exit_fact} . "</span>\n\n"
+        . "<span weight=\"bold\">" . $xl::s{exit_question} . "</span>\n";
+    my $dialog = message_dialog (
+        $parent, $xl::s{exit_title}, $markup, 'question',
+        [ 'gtk-no', 1, 'gtk-yes', 0 ]
+    );
     my $resp = $dialog->run;
     $dialog->hide;
-    return TRUE if ($resp eq 'no');
+    return TRUE if ($resp == 1);
   }
   Gtk3->main_quit;
 }