summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakfont
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/drakfont')
-rwxr-xr-xperl-install/standalone/drakfont377
1 files changed, 188 insertions, 189 deletions
diff --git a/perl-install/standalone/drakfont b/perl-install/standalone/drakfont
index 987107807..8222810a5 100755
--- a/perl-install/standalone/drakfont
+++ b/perl-install/standalone/drakfont
@@ -1,6 +1,7 @@
#!/usr/bin/perl
+# -*- coding: utf-8 -*-
#
-# Copyright (C) 2001-2005 by Mandriva
+# Copyright (C) 2001-2008 by Mandriva SA
# DUPONT Sebastien
# Damien Chaumette
# Thierry Vignaud
@@ -33,7 +34,6 @@
# - Get fonts on any partitions.
# - UN-installation of any fonts (even if not installed through drakfont)
# - Support
-# - Xfs
# - ghostscript & printer
# - Staroffice & printer
# - abiword
@@ -76,30 +76,33 @@
# - ttf2pt1: by Andrew Weeks, Frank Siegert, Thomas Henlich, Sergey Babkin convert ttf font files to afm and pfb fonts
#
#
-# directory to install fonts /usr/X11R6/lib/X11/fonts/
-# -->> /usr/X11R6/lib/X11/fonts/drakfont
+# directory to install fonts /usr/lib/X11/fonts/
+# -->> /usr/lib/X11/fonts/drakfont
use strict;
use diagnostics;
+use utf8;
use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-use ugtk2 qw(:create :dialogs :helpers :wrappers);
+use mygtk3 qw(gtknew); #- do not import gtkadd which conflicts with ugtk3 version
+use ugtk3 qw(:create :dialogs :helpers :wrappers);
use common;
+use run_program;
require_root_capability();
-$ugtk2::wm_icon = "drakfont";
+$ugtk3::wm_icon = "drakfont";
# global variables needed by each functions
my $xlsfonts = 0;
my $windows = 0;
my $replace;
-my $so = 1;
-my $gs = 1;
-my $abi = 1;
+my $so = to_bool(-f '/usr/bin/ooffice');
+my $gs = to_bool(-f '/usr/bin/gs');
+my $abi = to_bool(-f '/usr/bin/abiword');
my $printer = 1;
my $mode = -1;
my @application;
@@ -144,14 +147,15 @@ foreach my $i (@application) {
}
# PATH and binary full path
-#my $xfs_conffile = '/etc/fonts/fonts.conf';
-my $drakfont_dir = '/usr/X11R6/lib/X11/fonts/drakfont';
+my $font_dir = '/usr/share/fonts';
+my $fontpathd_dir = '/etc/X11/fontpath.d/';
+my $drakfont_dir = "$font_dir/drakfont";
my $ttf2pt1 = '/usr/sbin/ttf2pt1';
my $pfm2afm = '/usr/sbin/pfm2afm';
my $type1inst = '/usr/sbin/type1inst';
my $chkfontpath = '/usr/sbin/chkfontpath';
-# mkttfdir only knows about iso-8859-1, using ttmkfdir -u instead -- pablo
-my $ttmkfdir = '/usr/sbin/ttmkfdir';
+# mkttfdir only knows about iso-8859-1, using ttmkfdir instead -- pablo
+my $ttmkfdir = '/usr/bin/ttmkfdir';
my $fccache = '/usr/bin/fc-cache';
my @font_list; # list of fonts to install
@@ -160,7 +164,8 @@ my @installed_fonts_path; # list of path included in xfs
my @installed_fonts_full_path; # full path list of fonts to uninstall
sub list_fontpath() {
- foreach (grep { /\d+:\s/ } `$chkfontpath -l`) {
+ foreach (uniq((map { expand_symlinks($_) } glob_("$fontpathd_dir/*")),
+ (-x $chkfontpath ? grep { /\d+:\s/ } `$chkfontpath -l` : ()))) {
chomp;
s/\d+:\s//gi;
s/:\w*$//gi;
@@ -171,7 +176,7 @@ sub list_fontpath() {
sub chk_empty_xfs_path() {
foreach my $tmp_path (@installed_fonts_path) {
if (every { /^fonts/ || /^type/ } all($tmp_path)) {
- system("$chkfontpath -r $tmp_path ")
+ system($chkfontpath, '-r', $tmp_path)
or print "PERL::system command failed during chkfontpath\n";
}
}
@@ -194,28 +199,27 @@ sub search_installed_fonts_full_path() {
}
sub search_windows_font() {
- foreach my $fstab_line (grep { /vfat|smbfs|ntfs/ } cat_('/etc/mtab')) {
+ my @fonts;
+ foreach my $fstab_line (grep { /vfat|smbfs|ntfs|fuse/ } cat_('/etc/mtab')) {
my $win_dir = (split('\s', $fstab_line))[1];
- my @list_fonts_win = all("$win_dir/windows/fonts");
- my @list_fonts_winnt = all("$win_dir/winnt/fonts");
- my $nb_dir = @list_fonts_win + @list_fonts_winnt;
- foreach ([ \@list_fonts_win, "windows" ],
- [ \@list_fonts_winnt, "winnt" ]) {
- foreach my $i (@{ $_->[0] }) {
- if ($interactive) {
- if ($nb_dir) {
- progress($pbar, 0.25 / $nb_dir, N("parse all fonts"));
- } else {
- err_dialog(N("Error"), N("No fonts found"));
- return 0;
- }
- }
- !$replace && any { /$i/ } @installed_fonts and next;
- any { /$i$/ } @font_list or push @font_list, "$win_dir/$_->[1]/fonts/$i";
+ foreach my $sys_dir (grep { /^win(nt|dows)$/i } all($win_dir)) {
+ foreach my $font_dir (grep { /^fonts$/i } map { all($_) } "$win_dir/$sys_dir") {
+ push @fonts, map { "$win_dir/$sys_dir/$font_dir/$_" } all("$win_dir/$sys_dir/$font_dir");
}
}
- $interactive && $nb_dir and progress($pbar, 1, N("done"));
+ }
+ my $nb_dir = @fonts;
+ if (!$nb_dir) {
+ err_dialog(N("Error"), N("No fonts found"));
+ return 0;
}
+ foreach my $font (@fonts) {
+ progress($pbar, 0.25 / $nb_dir, N("parse all fonts")) if $interactive;
+ my $font_name = basename($font);
+ !$replace && any { /^\Q$font_name\E$/ } @installed_fonts and next;
+ any { /^\Q$font_name\E$/ } @font_list or push @font_list, $font;
+ }
+ $interactive && $nb_dir and progress($pbar, 1, N("done"));
if (!@font_list) {
print "drakfont:: could not find any font in /win*/fonts \n";
$interactive
@@ -225,7 +229,7 @@ sub search_windows_font() {
1;
}
-my @font_extensions = qw(ttf pfa pfb pcf pcf.gz pfm gsf);
+my @font_extensions = qw(ttf ttc pfa pfb pcf pcf.gz pfm gsf ttc otf);
sub is_a_font($) {
my ($file) = @_;
@@ -250,8 +254,8 @@ sub search_dir_font() {
}
}
elsif (is_a_font($fn)) {
- !$replace && any { /$fn/ } @installed_fonts and next;
- !any { /$fn/ } @installed_fonts and push @font_list, $fn;
+ !$replace && any { /\Q$fn\E/ } @installed_fonts and next;
+ !any { /\Q$fn\E/ } @installed_fonts and push @font_list, $fn;
}
}
interactive_progress($pbar, 0.50 / @install, N("Reselect correct fonts"));
@@ -277,13 +281,12 @@ sub print_list() {
sub dir_created() {
return if $::testing;
- -e $drakfont_dir or mkdir_p($drakfont_dir);
- -e $drakfont_dir . "/Type1" or mkdir_p($drakfont_dir . "/Type1");
- -e $drakfont_dir . "/ttf" or mkdir_p($drakfont_dir . "/ttf");
- -e $drakfont_dir . "/tmp" or mkdir_p($drakfont_dir . "/tmp");
- -e $drakfont_dir . "/tmp/ttf" or mkdir_p($drakfont_dir . "/tmp/ttf");
- -e $drakfont_dir . "/tmp/Type1" or mkdir_p($drakfont_dir . "/tmp/Type1");
- -e $drakfont_dir . "/tmp/tmp" or mkdir_p($drakfont_dir . "/tmp/tmp");
+ foreach (qw(Type1 ttf otf ttc tmp/ttf tmp/Type1 tmp/tmp)) {
+ my $dir = "$drakfont_dir/$_";
+ next if -e $dir;
+ mkdir_p($dir);
+ symlink($dir, "$fontpathd_dir/drakfont_$_:pri=50");
+ }
}
@@ -305,14 +308,24 @@ sub convert_ttf_fonts {
sub move_fonts {
my ($src_dir, $dest_dir, @extensions) = @_;
my @fonts = map { s!.*/!!; $_ } map { glob("$src_dir/*.$_") } @extensions;
- system("cd $src_dir && mv @fonts $dest_dir") if @fonts;
+ return if !@fonts;
+ system('mv', "$src_dir/$_", "$src_dir/$dest_dir") foreach @fonts;
+}
+
+sub my_rm_rf {
+ my ($target) = @_;
+ eval { rm_rf(@_) };
+ if (my $err = $@) {
+ warn "cannot remove $target: $err\n";
+ }
}
sub put_font_dir_real {
my ($subdir, $command, $progress, $title) = @_;
system("cd $drakfont_dir/$subdir && $fccache && $command");
interactive_progress($pbar2, $progress, $title);
- return "$chkfontpath -a $drakfont_dir/$subdir; rm -f /usr/X11R6/lib/X11/fonts/fonts.cache-1";
+ symlinkf("$drakfont_dir/$subdir", "/etc/X11/fontpath.d/drakfont_$subdir");
+ my_rm_rf("$font_dir/fonts.cache-1");
}
sub put_font_dir() {
@@ -320,19 +333,20 @@ sub put_font_dir() {
if (@font_list) {
dir_created();
foreach my $i (@font_list) {
- cp_af($i, $drakfont_dir . "/tmp/tmp");
+ cp_af($i, $drakfont_dir . "/tmp/tmp") if !$::testing;
interactive_progress($pbar1, 1 / @font_list, N("Fonts copy"));
}
interactive_progress($pbar1, 0.01, N("done"));
interactive_progress($pbar2, 0.10, N("True Type fonts installation"));
- foreach my $font (glob("$drakfont_dir/tmp/tmp/*.TTF")) {
+ my $temp_dir = "$drakfont_dir/tmp/tmp/";
+ foreach my $font (glob("$temp_dir/*.TTF")) {
my $newfont = $font;
$newfont =~ s/\.TTF$/.ttf/;
rename($font, $newfont);
}
- system('cd ' . $drakfont_dir . '/tmp/tmp && cp *.ttf ../../ttf; chmod 644 ../../ttf/*ttf');
+ system('cd ' . $temp_dir . ' && cp *.ttf ../../ttf; chmod 644 ../../ttf/*ttf') if glob("$temp_dir/*.ttf");
interactive_progress($pbar2, 0.20, N("please wait during ttmkfdir..."));
- my $update_chkfontpath = put_font_dir_real("ttf", "$ttmkfdir -u > fonts.dir", 0.10, N("True Type install done"));
+ put_font_dir_real("ttf", "$ttmkfdir > fonts.dir", 0.10, N("True Type install done"));
if ($gs) {
convert_ttf_fonts([ glob("$drakfont_dir/tmp/tmp/*.ttf") ], 1);
@@ -341,29 +355,32 @@ sub put_font_dir() {
interactive_progress($pbar2, 0.1, N("type1inst building"));
if ($so) {
-e "$drakfont_dir/tmp/Type1/Fontmap"
- and system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript | grep Fontmap.GS` ");
+ and system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript-common | grep Fontmap.GS` ");
move_fonts("$drakfont_dir/tmp/Type1", "../../Type1", qw(afm gsf pfb pfm));
} else {
- system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript | grep Fontmap.GS` ");
+ system("cd $drakfont_dir/tmp/Type1 && cat Fontmap >> `rpm -ql ghostscript-common | grep Fontmap.GS` ");
move_fonts("$drakfont_dir/tmp/Type1", "../../Type1", qw(afm gsf pfb pfm));
}
- $update_chkfontpath .= "; " . put_font_dir_real("Type1", $type1inst, 0.05, N("Ghostscript referencing"));
+ put_font_dir_real("Type1", $type1inst, 0.05, N("Ghostscript referencing"));
} elsif ($so) {
convert_ttf_fonts([ glob("$drakfont_dir/tmp/tmp/*.ttf") ]);
convert_fonts([ glob("$drakfont_dir/tmp/tmp/*.pfm") ], $pfm2afm, "PFM");
move_fonts("$drakfont_dir/tmp/tmp", "../Type1", qw(afm));
move_fonts("$drakfont_dir/tmp/Type1", "../../Type1", qw(afm));
- $update_chkfontpath .= put_font_dir_real("Type1", $type1inst, 0.14, N("type1inst building"));
+ put_font_dir_real("Type1", $type1inst, 0.14, N("type1inst building"));
+ }
+
+ foreach my $subdir (qw(otf ttc)) {
+ my $dir = "$drakfont_dir/$subdir";
+ move_fonts("$drakfont_dir/tmp/tmp", "../../$subdir", $subdir);
+ run_program::run($_, $dir) foreach qw(mkfontscale mkfontdir), $fccache;
+ symlinkf($dir, '/etc/X11/fontpath.d/drakfont_' . basename($dir));
}
interactive_progress($pbar2, 1, N("done"));
interactive_progress($pbar3, 0.25, N("Suppress Temporary Files"));
- rm_rf("$drakfont_dir/tmp/");
- print "\n\nretarting xfs......\n";
- interactive_progress($pbar3, 0.5, N("Restart XFS"));
- system($update_chkfontpath);
- system('/etc/rc.d/init.d/xfs restart');
- system('xset fp rehash');
+ my_rm_rf("$drakfont_dir/tmp/") if !$::testing;
+ system(qw(xset fp rehash));
interactive_progress($pbar3, 0.30, N("done"));
}
}
@@ -374,7 +391,7 @@ sub remove_gs_fonts() {
if (all("$drakfont_dir/remove")) {
system(" cd $drakfont_dir/remove && $type1inst");
my @Fontmap_out = cat_("$drakfont_dir/remove/Fontmap");
- my $FontmapGS = `rpm -ql ghostscript | grep Fontmap.GS`;
+ my $FontmapGS = `rpm -ql ghostscript-common | grep Fontmap.GS`;
chomp($FontmapGS);
my @FontmapGS_list = cat_($FontmapGS);
foreach my $font_gs (@FontmapGS_list) {
@@ -395,14 +412,14 @@ sub remove_fonts() {
foreach my $i (@font_list) {
local $_ = $i;
if (/.pfb$/ || /.gsf$/ || /.pfm$/ || /.pfa$/) {
- system("mv $_ $drakfont_dir/remove ");
+ system('mv', $_, "$drakfont_dir/remove");
} else {
next if $::testing;
if (/.ttf$/) {
- rm_rf($_);
+ my_rm_rf($_);
# rebuild of the fonts.dir and fc-cache files
- system("cd `dirname $_` && $fccache && $ttmkfdir -u > fonts.dir");
- } else { rm_rf($i) }
+ system("cd `dirname $_` && $fccache && $ttmkfdir > fonts.dir");
+ } else { my_rm_rf($i) }
}
$i =~ s!/\w*\.\w*!!gi;
any { $i } @list_dir or push @list_dir, $i;
@@ -411,30 +428,23 @@ sub remove_fonts() {
interactive_progress($pbar1, 0.01, N("done"));
-e "/usr/share/ghostscript" and remove_gs_fonts();
foreach my $i (@list_dir) {
- if (listlength all($i) < 3) {
- system("chkfontpath -r $i") or print "PERL::system command failed during chkfontpath\n";
- } else {
- system("cd $i && type1inst") or print "PERL::system command failed during cd or type1inst\n";
- }
+ system("cd $i && type1inst") or print "PERL::system command failed during cd or type1inst\n";
interactive_progress($pbar2, 1 / @list_dir, N("Suppress Fonts Files"));
}
- interactive_progress($pbar2, 0.01, N("xfs restart"));
- system("/etc/rc.d/init.d/xfs restart");
- system('xset fp rehash');
- -e "/usr/share/ghostscript" and rm_rf("$drakfont_dir/remove") if !$::testing;
+ system(qw(xset fp rehash));
+ -e "/usr/share/ghostscript" and my_rm_rf("$drakfont_dir/remove") if !$::testing;
interactive_progress($pbar2, 0.01, N("done"));
}
sub license_msg() {
- print N("Before installing any fonts, be sure that you have the right to use and install them on your system.\n\nYou can install the fonts the normal way. In rare cases, bogus fonts may hang up your X Server.") . "\n";
+ N("Before installing any fonts, be sure that you have the right to use and install them on your system.\n\nYou can install the fonts the normal way. In rare cases, bogus fonts may hang up your X Server.") . "\n";
}
sub backend_mod() {
$xlsfonts and system("xlsfonts");
- $list_all_font_path and system($chkfontpath);
if ($windows) {
- license_msg();
+ print license_msg();
print "\nWindows fonts Installation........\n";
search_installed_fonts();
if (search_windows_font()) {
@@ -445,7 +455,7 @@ sub backend_mod() {
}
if (@install) {
- license_msg();
+ print license_msg();
print "\nInstall Specifics Fonts...........\n";
search_installed_fonts();
search_dir_font();
@@ -466,27 +476,25 @@ sub backend_mod() {
sub interactive_mode() {
$interactive = 1;
- $window1 = ugtk2->new('drakfont');
- $window1->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
- if (!$::isEmbedded) {
- $window1->{rwindow}->set_position('center');
- $window1->{rwindow}->set_title(N("DrakFont"));
- }
+ $window1 = ugtk3->new(N("Font Installation"));
+ mygtk3::register_main_window($window1->{real_window});
+ $window1->{rwindow}->signal_connect(delete_event => sub { ugtk3->exit(0) });
+ $window1->{rwindow}->set_position('center') if !$::isEmbedded;
my $button = {};
my $disable = sub { my ($b) = @_; $button->{$_}->set_sensitive($_ ne $b) foreach keys %$button };
local $::Wizard_no_previous = 1;
gtkadd($window1->{window},
- gtkpack_(Gtk2::VBox->new(0, 2),
- if_(!$::isEmbedded, 0, Gtk2::Banner->new("drakfont", N("DrakFont"))),
- 0, Gtk2::WrappedLabel->new(N("Font List")),
- 1, Gtk2::FontSelection->new,
+ gtkpack_(Gtk3::VBox->new(0, 2),
+ if_(!$::isEmbedded, 0, Gtk3::Banner->new("drakfont", N("DrakFont"))),
+ 0, gtknew('Title2', label => N("Font List")),
+ 1, Gtk3::FontSelection->new,
0, gtkadd(create_hbox(),
- gtksignal_connect(Gtk2::Button->new(N("Get Windows Fonts")), clicked => sub { $windows = 1; import_status(); $windows = 0 }),
+ gtksignal_connect(Gtk3::Button->new(N("Get Windows Fonts")), clicked => sub { $windows = 1; import_status(); $windows = 0 }),
),
0, create_okcancel(my $oc = {
- ok_clicked => sub { Gtk2->main_quit },
+ ok_clicked => sub { Gtk3->main_quit },
},
undef, undef, '',
if_(0, [ N("About"), \&help, 1 ]),
@@ -502,78 +510,54 @@ sub interactive_mode() {
$window1->{rwindow}->show_all;
$window1->{rwindow}->realize;
$window1->main;
- ugtk2->exit(0);
+ ugtk3->exit(0);
}
$list_all_font_path || $xlsfonts || $windows || @install || @uninstall ? backend_mod() : interactive_mode();
sub help() {
- ugtk2::create_dialog(N("Help"), formatAlaTeX(
- #-PO: keep the double empty lines between sections, this is formatted a la LaTeX
- N("Copyright (C) 2001-2002 by Mandriva
-
-
- DUPONT Sebastien (original version)
-
- CHAUMETTE Damien <dchaumette\@mandriva.com>
-
- VIGNAUD Thierry <tvignaud\@mandriva.com>")
-
-. "\n\n\n" . N("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 2, 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
-
-. "\n\n\n" . N("Thanks:
-
- - pfm2afm:
- by Ken Borgendale:
- Convert a Windows .pfm file to a .afm (Adobe Font Metrics)
-
- - type1inst:
- by James Macnicol:
- type1inst generates files fonts.dir fonts.scale & Fontmap.
-
- - ttf2pt1:
- by Andrew Weeks, Frank Siegert, Thomas Henlich, Sergey Babkin
- Convert ttf font files to afm and pfb fonts
-")));
+ my $license = formatAlaTeX(translate($::license));
+ $license =~ s/\n/\n\n/sg; # nicer formatting
+ my $w = gtknew('AboutDialog', name => N("Drakfont"),
+ version => mageia_release_info()->{version},
+ copyright => N("Copyright (C) %s by %s", 'Mandriva', '2001-2008') . "\n" . N("Copyright (C) %s by %s", N("Mageia"), '2011') . "\n",
+ license => $license, wrap_license => 1,
+ comments => N("Font installer."),
+ website => 'http://www.mageia.org',
+ website_label => N("Mageia"),
+ authors => [ 'Sébastien Dupont', 'Damien Chaumette', 'Thierry Vignaud <thierry.vignaud.com>' ],
+ translator_credits =>
+ #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith <jsmith@nowhere.com>")
+ N("_: Translator(s) name(s) & email(s)\n"),
+ transient_for => $window1->{real_window}, modal => 1, position_policy => 'center-on-parent',
+ );
+ $w->show_all;
+ $w->run;
}
sub appli_choice() {
dialog(N("Options"),
[
- 0, N("Choose the applications that will support the fonts:"),
- 0, Gtk2::WrappedLabel->new(license_msg()),
+ 0, gtknew('Title2', label => N("Choose the applications that will support the fonts:")),
+ 0, Gtk3::WrappedLabel->new(formatAlaTeX(license_msg())),
(map {
my ($label, $ref) = @$_;
- (0, gtkpack_(Gtk2::HBox->new,
+ (0, gtkpack_(Gtk3::HBox->new,
0, $label,
- 1, Gtk2::HBox->new,
+ 1, Gtk3::HBox->new,
# BUG: that code never had supported canceling
- 0, gtksignal_connect(gtkset_active(Gtk2::CheckButton->new, $$ref), toggled => sub { $$ref = $$ref ? 0 : 1 }),
+ 0, gtksignal_connect(gtkset_active(Gtk3::CheckButton->new, $$ref), toggled => sub { $$ref = $$ref ? 0 : 1 }),
),
);
} ([ N("Ghostscript"), \$gs ],
- [ N("StarOffice"), \$so ],
+ [ N("LibreOffice"), \$so ],
[ N("Abiword"), \$abi ],
[ N("Generic Printers"), \$printer ],
),
),
],
[
- gtksignal_connect(Gtk2::Button->new(N("Ok")),
+ gtksignal_connect(Gtk3::Button->new(N("Ok")),
clicked => \&exitdialog,
),
],
@@ -583,12 +567,12 @@ sub appli_choice() {
sub font_choice() {
my $file_dialog;
my $_select_font_msg = N("Select the font file or directory and click on 'Add'");
- $file_dialog = Gtk2::FileChooserDialog->new(N("File Selection"), $window1->{real_window}, 'open', N("Cancel") => 'cancel', N("Ok") => 'ok'); # 'select_folder'
+ $file_dialog = Gtk3::FileChooserDialog->new(N("File Selection"), $::main_window, 'open', N("Cancel") => 'cancel', N("Ok") => 'ok'); # 'select_folder'
$file_dialog->set_select_multiple(1);
- my $filter = Gtk2::FileFilter->new;
+ my $filter = Gtk3::FileFilter->new;
$filter->set_name(N("Fonts"));
- $filter->add_pattern("*.$_") foreach @font_extensions;
+ $filter->add_pattern("*.$_") foreach @font_extensions, map { uc($_) } @font_extensions;
$file_dialog->add_filter($filter);
$file_dialog->set_filter($filter);
@@ -598,8 +582,8 @@ sub font_choice() {
$file_dialog->destroy;
return;
} elsif ($answer eq 'ok') {
- my @files = $file_dialog->get_filenames;
- foreach my $file_name (difference2(\@files, \@install)) {
+ my $files = $file_dialog->get_filenames;
+ foreach my $file_name (difference2($files, \@install)) {
push @install, $file_name;
$model->append_set(undef, [ 0 => $file_name ]);
}
@@ -618,79 +602,91 @@ sub list_remove() { #- TODO : multi-selection
$treeStore->remove($iter);
}
-sub exitdialog() { Gtk2->main_quit }
+sub exitdialog() { Gtk3->main_quit }
sub dialog {
- my ($title, $widgets, $buttons, $o_main_loop) = @_;
- my $dialog = _create_dialog($title, { transient => $window1->{real_window} });
+ my ($title, $widgets, $buttons, $o_main_loop, $o_options) = @_;
+ $o_options ||= {};
+ my $dialog = _create_dialog($title, { transient => $::main_window });
+ local $::main_window = $dialog;
$dialog->signal_connect(delete_event => \&exitdialog);
- gtkpack_($dialog->vbox, @$widgets);
- gtkpack($dialog->action_area, @$buttons) if $buttons;
+ $dialog->set_size_request(@{$o_options->{size}}) if ref $o_options->{size};
+ gtkpack_($dialog->get_child, @$widgets);
+ gtkpack($dialog->get_action_area, @$buttons) if $buttons;
$dialog->show_all;
- $window1->{rwindow}->set_sensitive(0);
if ($o_main_loop) {
gtkflush();
$o_main_loop->();
} else {
- Gtk2->main;
+ Gtk3->main;
}
$dialog->destroy if $dialog;
undef $dialog;
- $window1->{rwindow}->set_sensitive(1);
}
sub advanced_install() {
my $button;
- $model = Gtk2::TreeStore->new("Glib::String");
- $list = Gtk2::TreeView->new_with_model($model);
- $list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
+ $model = Gtk3::TreeStore->new("Glib::String");
+ $list = Gtk3::TreeView->new_with_model($model);
+ $list->append_column(Gtk3::TreeViewColumn->new_with_attributes('', Gtk3::CellRendererText->new, 'text' => 0));
$list->set_headers_visible(0);
$list->get_selection->set_mode('browse');
$list->set_rules_hint(1);
$model->signal_connect("row-inserted" => sub { $button and $button->set_sensitive(1) });
- $model->signal_connect("row-deleted" => sub { $button and $button->set_sensitive($model->get_iter_first) });
+ $model->signal_connect("row-deleted" => sub { $button and $button->set_sensitive($model->get_iter_first || 0) });
dialog(N("Import fonts"),
- [ 1, create_scrolled_window($list) ],
[
- gtksignal_connect(Gtk2::Button->new(N("Add")), clicked => \&font_choice),
- gtksignal_connect(Gtk2::Button->new(N("Remove Selected")), clicked => \&list_remove),
- gtksignal_connect($button = gtkset_sensitive(Gtk2::Button->new(N("Install fonts")), 0),
+ 0, gtknew('Title2', label => N("Font List")),
+ 1, gtknew('HBox', children => [
+ 1, create_scrolled_window($list),
+ 0, gtknew('VBox', children_tight => [
+ gtksignal_connect(Gtk3::Button->new(N("Add")), clicked => \&font_choice),
+ gtksignal_connect(Gtk3::Button->new(N("Remove")), clicked => \&list_remove),
+ ]),
+ ]),
+ ],
+ [
+ gtksignal_connect(Gtk3::Button->new(N("Cancel")), clicked => \&exitdialog),
+ gtksignal_connect($button = gtkset_sensitive(Gtk3::Button->new(N("Install")), 0),
clicked => sub {
import_status() if @install;
}),
- gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&exitdialog),
],
+ undef,
+ { size => [ 300, 200 ] },
);
}
sub list_to_remove() {
#my @files_path = grep(!/fonts/, all($current_path)); garbage ?
gtkflush();
- my (@tux) = $left_list->get_selection->get_selected_rows; #- get tree & paths
+ my ($indices) = $left_list->get_selection->get_selected_rows;
+ my (@tux) = @$indices; #- get tree & paths
push @uninstall, map { $left_model->get($left_model->get_iter($_), 0) } @tux;
#push @uninstall, $current_path . "/" . $files_path[$_] foreach @number_to_remove; garbage ?
show_list_to_remove();
}
sub show_list_to_remove() {
- my $model = Gtk2::TreeStore->new("Glib::String");
- my $list = Gtk2::TreeView->new_with_model($model);
- $list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
+ my $model = Gtk3::TreeStore->new("Glib::String");
+ my $list = Gtk3::TreeView->new_with_model($model);
+ $list->append_column(Gtk3::TreeViewColumn->new_with_attributes('', Gtk3::CellRendererText->new, 'text' => 0));
$list->set_headers_visible(0);
$list->get_selection->set_mode('browse');
$list->set_rules_hint(1);
- $model->append_set(undef, [ 0 => $_ ]) foreach @uninstall;
+ $model->append_set(undef, [ 0 => $_ ]) foreach sort @uninstall;
- dialog(N("Uninstall"),
+ dialog(N("Warning"),
[
- 1, gtkpack_(Gtk2::HBox->new(0, 4), 1, create_scrolled_window($list)),
+ 0, Gtk3::Label->new(N("Are you sure you want to uninstall the following fonts?")),
+ 1, gtkpack_(Gtk3::HBox->new(0, 4), 1, create_scrolled_window($list)),
],
[
- gtksignal_connect(Gtk2::Button->new(N("click here if you are sure.")),
+ gtksignal_connect(Gtk3::Button->new(N("Yes")),
clicked => sub { import_status_uninstall(); exitdialog() }),
- gtksignal_connect(Gtk2::Button->new(N("here if no.")),
+ gtksignal_connect(Gtk3::Button->new(N("No")),
clicked => \&exitdialog
),
],
@@ -704,48 +700,51 @@ sub uninstall() { #- TODO : add item to right list with gtksignal_connect
chk_empty_xfs_path();
#- left part
- $left_model = Gtk2::TreeStore->new("Glib::String");
- $left_list = Gtk2::TreeView->new_with_model($left_model);
- $left_list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
+ $left_model = Gtk3::TreeStore->new("Glib::String");
+ $left_list = Gtk3::TreeView->new_with_model($left_model);
+ $left_list->append_column(Gtk3::TreeViewColumn->new_with_attributes('', Gtk3::CellRendererText->new, 'text' => 0));
$left_list->set_headers_visible(0);
$left_list->set_rules_hint(1);
$left_list->get_selection->set_mode('multiple');
- $left_model->append_set(undef, [ 0 => $_ ]) foreach @installed_fonts_path;
+ $left_model->append_set(undef, [ 0 => $_ ]) foreach sort @installed_fonts_path;
#- right part
- $right_model = Gtk2::TreeStore->new("Glib::String");
- $right_list = Gtk2::TreeView->new_with_model($right_model);
- $right_list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
+ $right_model = Gtk3::TreeStore->new("Glib::String");
+ $right_list = Gtk3::TreeView->new_with_model($right_model);
+ $right_list->append_column(Gtk3::TreeViewColumn->new_with_attributes('', Gtk3::CellRendererText->new, 'text' => 0));
$right_list->set_headers_visible(0);
$right_list->get_selection->set_mode('multiple');
$right_list->set_rules_hint(1);
dialog(N("Uninstall"),
[
- 1, gtkpack_(Gtk2::HBox->new(0, 4),
+ 1, gtkpack_(Gtk3::HBox->new(0, 4),
1, create_scrolled_window($left_list),
#1, create_scrolled_window($right_list)
),
],
[
- gtksignal_connect(Gtk2::Button->new(N("Unselected All")),
+ gtksignal_connect(Gtk3::Button->new(N("Unselect All")),
clicked => sub { $left_list->get_selection->unselect_all }
),
- gtksignal_connect(Gtk2::Button->new(N("Selected All")),
+ gtksignal_connect(Gtk3::Button->new(N("Select All")),
clicked => sub { $left_list->get_selection->select_all }
),
- gtksignal_connect(Gtk2::Button->new(N("Remove List")), clicked => sub { exitdialog(); list_to_remove() }),
- gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&exitdialog),
+ gtksignal_connect(Gtk3::Button->new(N("Remove")), clicked => sub { exitdialog(); list_to_remove() }),
+ gtksignal_connect(Gtk3::Button->new(N("Cancel")), clicked => \&exitdialog),
],
+ undef,
+ { size => [ -1, 300 ] }
+
);
}
sub import_status() {
- $pbar = Gtk2::ProgressBar->new;
- $pbar1 = Gtk2::ProgressBar->new;
- $pbar2 = Gtk2::ProgressBar->new;
- $pbar3 = Gtk2::ProgressBar->new;
+ $pbar = Gtk3::ProgressBar->new;
+ $pbar1 = Gtk3::ProgressBar->new;
+ $pbar2 = Gtk3::ProgressBar->new;
+ $pbar3 = Gtk3::ProgressBar->new;
dialog(N("Importing fonts"),
[
0, create_packtable({ col_spacings => 10, row_spacings => 50 },
@@ -762,10 +761,10 @@ sub import_status() {
}
sub import_status_uninstall() {
- $pbar = Gtk2::ProgressBar->new;
- $pbar1 = Gtk2::ProgressBar->new;
- $pbar2 = Gtk2::ProgressBar->new;
- dialog(N("Importing fonts"),
+ $pbar = Gtk3::ProgressBar->new;
+ $pbar1 = Gtk3::ProgressBar->new;
+ $pbar2 = Gtk3::ProgressBar->new;
+ dialog(N("Removing fonts"),
[
0, create_packtable({ col_spacings => 10, row_spacings => 50 },
[ "", "" ],