Fix missing people in AUTHORS
[clawsker.git] / clawsker
index 01735b3273dad273933e0aecb6f3ef6d7cbafc48..5f63b7c0274d8d972d85cdbe8168b1e9941ecd48 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,11 +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_with_markup ($main_window, 'modal', 'error', 'cancel', $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;
 }
@@ -492,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 {
@@ -566,8 +587,8 @@ sub new_text_box_for_int($$$) {
         });
     set_widget_hint ($gentry, $$hash{$key}[DESC]);
     set_widget_sens ($gentry, $$hash{$key}[CMVER]);
-    $glabel->set_sensitive ($gentry->sensitive);
-    $gunits->set_sensitive ($gentry->sensitive) if ($gunits);
+    $glabel->set_sensitive ($gentry->get_sensitive);
+    $gunits->set_sensitive ($gentry->get_sensitive) if ($gunits);
     #
     return new_hbox_spaced_pack ($glabel, $gentry, $gunits) if ($gunits);
     return new_hbox_spaced_pack ($glabel, $gentry);
@@ -593,7 +614,7 @@ sub new_text_box_for_nchar($$$) {
         });
     set_widget_hint ($gentry, $$hash{$key}[DESC]);
     set_widget_sens ($gentry, $$hash{$key}[CMVER]);
-    $glabel->set_sensitive ($gentry->sensitive);
+    $glabel->set_sensitive ($gentry->get_sensitive);
     #
     return new_hbox_spaced_pack ($glabel, $gentry);
 }
@@ -605,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 {
@@ -616,7 +637,7 @@ sub new_color_button_for($$$) {
         });
     set_widget_hint ($button, $$hash{$key}[DESC]);
     set_widget_sens ($button, $$hash{$key}[CMVER]);
-    $glabel->set_sensitive ($button->sensitive);
+    $glabel->set_sensitive ($button->get_sensitive);
     #
     return new_hbox_spaced_pack ($button, $glabel);
 }
@@ -627,11 +648,11 @@ sub new_selection_box_for($$$) {
     my $label = $$hash{$key}[LABEL];
     #
     my $glabel = Gtk3::Label->new ($label);
-    my $combo = Gtk3::ComboBox->new_text;
+    my $combo = Gtk3::ComboBoxText->new;
     my @options = split (';', $$hash{$key}[TYPE]);
     foreach my $opt (@options) {
         my ($index, $textkey) = split ('=', $opt);
-        $combo->insert_text ($index, $xl::s{$textkey});
+        $combo->insert (-1, $index, $xl::s{$textkey});
     }
     $combo->signal_connect ('changed' => sub {
             my ($w, $e) = @_;
@@ -642,7 +663,7 @@ sub new_selection_box_for($$$) {
     $combo->set_active ($value);
     set_widget_hint ($combo, $$hash{$key}[DESC]);
     set_widget_sens ($combo, $$hash{$key}[CMVER]);
-    $glabel->set_sensitive ($combo->sensitive);
+    $glabel->set_sensitive ($combo->get_sensitive);
     #
     return new_hbox_spaced_pack ($glabel, $combo);
 }
@@ -2000,16 +2021,26 @@ sub new_winpos_subpage_misc() {
 sub new_winpos_page() {
     my $winbook = Gtk3::Notebook->new;
     $winbook->set_tab_pos ('right');
-    $winbook->append_page (new_winpos_subpage_main, _('Main'));
-    $winbook->append_page (new_winpos_subpage_msgs, _('Message'));
-    $winbook->append_page (new_winpos_subpage_sendrecv, _('Send/Receive'));
-    $winbook->append_page (new_winpos_subpage_fold, _('Folder'));
-    $winbook->append_page (new_winpos_subpage_addrbook, _('Addressbook'));
-    $winbook->append_page (new_winpos_subpage_accounts, _('Accounts'));
-    $winbook->append_page (new_winpos_subpage_filtering, _('Filtering'));
-    $winbook->append_page (new_winpos_subpage_useractions, _('User Actions'));
-    $winbook->append_page (new_winpos_subpage_prefs, _('Preferences'));
-    $winbook->append_page (new_winpos_subpage_misc, _('Other'));
+    $winbook->append_page (new_winpos_subpage_main,
+        Gtk3::Label->new (_('Main')));
+    $winbook->append_page (new_winpos_subpage_msgs,
+        Gtk3::Label->new (_('Message')));
+    $winbook->append_page (new_winpos_subpage_sendrecv,
+        Gtk3::Label->new (_('Send/Receive')));
+    $winbook->append_page (new_winpos_subpage_fold,
+        Gtk3::Label->new (_('Folder')));
+    $winbook->append_page (new_winpos_subpage_addrbook,
+        Gtk3::Label->new (_('Addressbook')));
+    $winbook->append_page (new_winpos_subpage_accounts,
+        Gtk3::Label->new (_('Accounts')));
+    $winbook->append_page (new_winpos_subpage_filtering,
+        Gtk3::Label->new (_('Filtering')));
+    $winbook->append_page (new_winpos_subpage_useractions,
+        Gtk3::Label->new (_('User Actions')));
+    $winbook->append_page (new_winpos_subpage_prefs,
+        Gtk3::Label->new (_('Preferences')));
+    $winbook->append_page (new_winpos_subpage_misc,
+        Gtk3::Label->new (_('Other')));
     return $winbook;
 }
 
@@ -2053,7 +2084,8 @@ sub new_accounts_page() {
         my $name = $ACPREFS{$_}{'account_name'};
         my $isdef = ($ACPREFS{$_}{'is_default'} eq '1');
         my $page = new_account_subpage ($_);
-        $accbook->append_page ($page, $isdef? '<b>' . $name . '</b>': $name);
+        $accbook->append_page ($page,
+            Gtk3::Label->new ($isdef? '<b>' . $name . '</b>': $name));
         if ($isdef) {
             my $label = $accbook->get_tab_label ($page);
             $label->set_use_markup (TRUE);
@@ -2256,7 +2288,7 @@ sub new_hotkeys_list {
             my ($col, $renderer, $model, $iter, $data) = @_;
             my $hkey = $model->get_value ($iter, C_HOTKEY);
             $hkey =~ s/\"//g;
-            my ($acckey, $accmod) = Gtk3::Accelerator->parse ($hkey);
+            my ($acckey, $accmod) = Gtk3::accelerator_parse ($hkey);
             $renderer->set_property ('accel-key' => $acckey);
             $renderer->set_property ('accel-mods' => $accmod);
             $renderer->set_property (
@@ -2713,15 +2745,24 @@ sub save_preferences {
 sub new_notebook {
     my $nb = Gtk3::Notebook->new;
     #
-    $nb->append_page (new_behaviour_page (), $xl::s{tab_behaviour});
-    $nb->append_page (new_colours_page (), $xl::s{tab_colours});
-    $nb->append_page (new_gui_page (), $xl::s{tab_gui});
-    $nb->append_page (new_other_page (), $xl::s{tab_other});
-    $nb->append_page (new_winpos_page (), $xl::s{tab_winpos});
-    $nb->append_page (new_accounts_page (), $xl::s{tab_accounts});
-    $nb->append_page (new_plugins_page (), $xl::s{tab_plugins});
-    $nb->append_page (new_hotkeys_page (), $xl::s{tab_hotkeys});
-    $nb->append_page (new_info_page (), $xl::s{tab_info});
+    $nb->append_page (new_behaviour_page (),
+        Gtk3::Label->new ($xl::s{tab_behaviour}));
+    $nb->append_page (new_colours_page (),
+        Gtk3::Label->new ($xl::s{tab_colours}));
+    $nb->append_page (new_gui_page (),
+        Gtk3::Label->new ($xl::s{tab_gui}));
+    $nb->append_page (new_other_page (),
+        Gtk3::Label->new ($xl::s{tab_other}));
+    $nb->append_page (new_winpos_page (),
+        Gtk3::Label->new ($xl::s{tab_winpos}));
+    $nb->append_page (new_accounts_page (),
+        Gtk3::Label->new ($xl::s{tab_accounts}));
+    $nb->append_page (new_plugins_page (),
+        Gtk3::Label->new ($xl::s{tab_plugins}));
+    $nb->append_page (new_hotkeys_page (),
+        Gtk3::Label->new ($xl::s{tab_hotkeys}));
+    $nb->append_page (new_info_page (),
+        Gtk3::Label->new ($xl::s{tab_info}));
 
     return $nb;
 }
@@ -2729,61 +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_with_markup ($parent,
-                    [qw/modal destroy-with-parent/],
-                    'info', 'close',
-                    "<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 <gusnan@openmailbox.org>',
+        '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_with_markup ($parent,
-                    [qw/modal destroy-with-parent/],
-                    'warning', 'yes-no',
-                    "<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;
 }
@@ -2813,7 +2860,7 @@ sub new_button_box {
 }
 
 sub get_app_icons {
-    return @APPICONS if (@APPICONS);
+    return \@APPICONS if (@APPICONS);
     my @names;
     if (-d $DATADIR) { # installed
         my $dir = $DATADIR . '/icons/hicolor';
@@ -2830,12 +2877,12 @@ sub get_app_icons {
         $icon = Gtk3::Gdk::Pixbuf->new_from_file($_) if (-f $_);
         push @APPICONS, $icon if ($icon);
     }
-    return @APPICONS;
+    return \@APPICONS;
 }
 
 sub escape_key_handler {
     my ($widget, $event) = @_;
-    if ($event->keyval == Gtk3::Gdk->keyval_from_name('Escape')) {
+    if ($event->keyval == Gtk3::Gdk::keyval_from_name('Escape')) {
         exit_handler($widget);
     }
 }
@@ -2849,7 +2896,7 @@ exit unless init_hidden_preferences ();
 # create main GUI
 my $box = Gtk3::VBox->new (FALSE, 5);
 $box->set_border_width(3);
-my $about = new_about_dialog ();
+my $about = new_about_dialog ($main_window);
 $box->pack_start (new_notebook (), TRUE, TRUE, 0);
 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
 $main_window->signal_connect (delete_event => sub { exit_handler($main_window) });