summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-01-12 15:46:58 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-01-12 15:46:58 +0000
commit062c493f675e9682ca15f1838af0c0c6d7e1a4b7 (patch)
tree3b176cfbd447eac939ad00a81daaaec21afe38ce /perl-install
parent37b6a43a6253f6066adda9ebc5ca08cd8cb41a81 (diff)
downloaddrakx-062c493f675e9682ca15f1838af0c0c6d7e1a4b7.tar
drakx-062c493f675e9682ca15f1838af0c0c6d7e1a4b7.tar.gz
drakx-062c493f675e9682ca15f1838af0c0c6d7e1a4b7.tar.bz2
drakx-062c493f675e9682ca15f1838af0c0c6d7e1a4b7.tar.xz
drakx-062c493f675e9682ca15f1838af0c0c6d7e1a4b7.zip
new layout with subdialogs
Diffstat (limited to 'perl-install')
-rwxr-xr-xperl-install/standalone/drakfont355
1 files changed, 141 insertions, 214 deletions
diff --git a/perl-install/standalone/drakfont b/perl-install/standalone/drakfont
index a838aa693..185d4f3f9 100755
--- a/perl-install/standalone/drakfont
+++ b/perl-install/standalone/drakfont
@@ -87,7 +87,7 @@ use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-use ugtk2 qw(:helpers :wrappers :create);
+use ugtk2 qw(:create :dialogs :helpers :wrappers);
use common;
require_root_capability();
@@ -106,12 +106,13 @@ my @application;
my @install;
my @uninstall;
my $interactive;
+my $dialog;
my $pbar;
my $pbar1;
my $pbar2;
my $pbar3;
+my $window1;
my $font_box;
-my $central_widget;
my $model;
my $list;
my $list_all_font_path;
@@ -208,7 +209,7 @@ sub search_windows_font() {
if ($nb_dir) {
progress($pbar, 0.25 / $nb_dir, N("parse all fonts"));
} else {
- display_error(N("no fonts found"));
+ err_dialog(N("Error"), N("no fonts found"));
return 0;
}
}
@@ -260,7 +261,7 @@ sub search_dir_font() {
interactive_progress($pbar, 0.50 / @install, N("Reselect correct fonts"));
}
interactive_progress($pbar, 1, N("done"));
- !@font_list && $interactive and display_error(N("could not find any font.\n"));
+ !@font_list && $interactive and err_dialog(N("Error"), N("could not find any font.\n"));
}
sub search_dir_font_uninstall {
@@ -468,36 +469,16 @@ sub backend_mod() {
}
sub create_fontsel() {
- my $font_sel;
- gtkpack($font_box, $font_sel = Gtk2::FontSelection->new,);
- $central_widget = \$font_sel;
-}
-
-sub display_error {
- my ($message) = @_;
- my $error_box;
- $$central_widget->destroy;
- gtkpack($font_box,
- $error_box = gtkpack_(Gtk2::VBox->new(0, 0),
- 1, Gtk2::Label->new($message),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("OK")),
- clicked => sub { $$central_widget->destroy; create_fontsel() }
- ),
- ),
- )
- );
- $central_widget = \$error_box;
+ Gtk2::FontSelection->new;
}
sub interactive_mode() {
- my $font_sel;
$interactive = 1;
- my $window1 = ugtk2->new('drakfont');
+ $window1 = ugtk2->new('drakfont');
$window1->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
unless ($::isEmbedded) {
$window1->{rwindow}->set_position('center');
- $window1->{rwindow}->set_title(N("Import Fonts"));
+ $window1->{rwindow}->set_title(N("DrakFont"));
}
my $button = {};
@@ -506,52 +487,19 @@ sub interactive_mode() {
gtkadd($window1->{window},
gtkpack_(Gtk2::VBox->new(0, 2),
if_(!$::isEmbedded, 0, gtkcreate_img("drakfont.620x57")),
- 1, gtkpack_(Gtk2::HBox->new(0, 2),
- 1, gtkpack_(Gtk2::VBox->new(0, 2),
- 1, gtkpack($font_box = Gtk2::VBox->new(0, 5), $font_sel = Gtk2::FontSelection->new,),
- 0, gtkpack_(Gtk2::HBox->new(0, 2),
- 0, gtkadd(gtkset_layout(Gtk2::VButtonBox->new, 'end'),
- gtksignal_connect($button->{windows} = Gtk2::Button->new(N("Get Windows Fonts")),
- clicked => sub {
- $disable->('windows');
- $$central_widget->destroy;
- $windows = 1;
- appli_choice();
- }),
- gtksignal_connect($button->{uninstall} = Gtk2::Button->new(N("Uninstall Fonts")),
- clicked => sub {
- $disable->('uninstall');
- $$central_widget->destroy;
- uninstall();
- }),
- ),
- 0, gtkadd(gtkset_layout(Gtk2::VButtonBox->new, 'end'),
- gtksignal_connect($button->{adv_option} = Gtk2::Button->new(N("Advanced Options")),
- clicked => sub {
- $disable->('adv_option');
- $$central_widget->destroy;
- $windows = 0;
- advanced_install();
- }),
- gtksignal_connect($button->{font_list} = Gtk2::Button->new(N("Font List")),
- clicked => sub {
- $disable->('font_list');
- $$central_widget->destroy;
- create_fontsel();
- }),
- ),
- 1, Gtk2::HBox->new(0, 2),
- 0, gtkadd(gtkset_layout(Gtk2::VButtonBox->new, 'end'),
- gtksignal_connect(Gtk2::Button->new(N("About")), clicked => \&help),
- gtksignal_connect(Gtk2::Button->new(N("Close")), clicked => sub { Gtk2->main_quit }),
- ),
- ),
- ),
- ),
+ 0, Gtk2::WrappedLabel->new(N("Font List")),
+ 1, create_fontsel(),
+ 0, gtkpack(gtkset_layout(Gtk2::HButtonBox->new, 'end'),
+ gtksignal_connect(Gtk2::Button->new(N("About")), clicked => \&help),
+ gtksignal_connect(Gtk2::Button->new(N("Options")), clicked => \&appli_choice),
+ gtksignal_connect(Gtk2::Button->new(N("Uninstall")), clicked => \&uninstall),
+ gtksignal_connect(Gtk2::Button->new(N("Import")), clicked => \&advanced_install),
+ Gtk2::Label->new(" "),
+ gtksignal_connect(Gtk2::Button->new(N("Close")), clicked => sub { Gtk2->main_quit }),
+ ),
),
);
- $central_widget = \$font_sel;
$disable->('font_list');
$window1->{rwindow}->show_all;
$window1->{rwindow}->realize;
@@ -561,24 +509,6 @@ sub interactive_mode() {
$list_all_font_path || $xlsfonts || $windows || @install || @uninstall ? backend_mod() : interactive_mode();
-sub text_view {
- my ($text) = @_;
- my $box;
- gtkpack($font_box,
- $box = gtkpack_(Gtk2::VBox->new(0,10),
- 1, gtkpack(Gtk2::HBox->new(0,0),
- create_scrolled_window(gtktext_insert(Gtk2::TextView->new, [ [ $text ] ]))
- ),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("OK")),
- clicked => sub { $$central_widget->destroy }),
- ),
- )
- );
- $central_widget = \$box;
- $font_box->show_all;
-}
-
sub help() {
ugtk2::create_dialog(N("Help"), formatAlaTeX(N("Copyright (C) 2001-2002 by MandrakeSoft
@@ -622,44 +552,33 @@ sub help() {
}
sub appli_choice() {
- my $choice_box;
my %checks;
- gtkpack($font_box,
- $choice_box = gtkpack__(Gtk2::VBox->new,
- N("Choose the applications that will support the fonts:"),
- Gtk2::WrappedLabel->new(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.")),
- (map {
- gtkpack_(Gtk2::HBox->new,
- 0, $_->[0],
- 1, Gtk2::HBox->new,
- 0, $checks{$_->[1]} = Gtk2::CheckButton->new,
- ),
- } ([ N("Ghostscript"), "11" ],
- [ N("StarOffice"), "22" ],
- [ N("Abiword"), "33" ],
- [ N("Generic Printers"), "44" ],
- ),
- ),
- gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("OK")),
- clicked => sub {
- $$central_widget->destroy;
- import_status();
- }),
- gtksignal_connect(Gtk2::Button->new(N("Cancel")),
- clicked => sub {
- @install = ();
- $$central_widget->destroy;
- create_fontsel();
- }),
- ),
- ),
- );
- foreach ([ $checks{11}, \$gs ], [ $checks{22}, \$so ], [ $checks{33}, \$abi ], [ $checks{44}, \$printer ]) {
- my $ref = $_->[1];
- gtksignal_connect(gtkset_active($_->[0], $$ref), toggled => sub { $$ref = $$ref ? 0 : 1 });
- }
- $central_widget = \$choice_box;
+ dialog(N("Options"),
+ [
+ 0, N("Choose the applications that will support the fonts:"),
+ 0, Gtk2::WrappedLabel->new(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.")),
+ (map {
+ my ($label, $ref) = @$_;
+ (0, gtkpack_(Gtk2::HBox->new,
+ 0, $label,
+ 1, Gtk2::HBox->new,
+ # BUG: that code never had supported canceling
+ 0, gtksignal_connect(gtkset_active(Gtk2::CheckButton->new, $ref), toggled => sub { $$ref = $$ref ? 0 : 1 }),
+ ),
+ );
+ } ([ N("Ghostscript"), $gs ],
+ [ N("StarOffice"), $so ],
+ [ N("Abiword"), $abi ],
+ [ N("Generic Printers"), $printer ],
+ ),
+ ),
+ ],
+ [
+ gtksignal_connect(Gtk2::Button->new(N("OK")),
+ clicked => \&exitdialog,
+ ),
+ ],
+ );
}
my $select_font_msg;
@@ -667,16 +586,17 @@ my $select_font_msg;
sub font_choice() {
my $file_dialog;
$select_font_msg = N("Select the font file or directory and click on 'Add'");
- $file_dialog = gtksignal_connect(Gtk2::FileSelection->new(N("File Selection")), destroy => sub { $file_dialog->destroy });
+ $file_dialog = Gtk2::FileSelection->new(N("File Selection"));
$file_dialog->ok_button->signal_connect(clicked => \&file_ok_sel, $file_dialog);
$file_dialog->ok_button->set_label(N("Add"));
$file_dialog->cancel_button->signal_connect(clicked => sub { $file_dialog->destroy });
$file_dialog->cancel_button->set_label(N("Close"));
$file_dialog->show;
+ $file_dialog->run;
}
sub file_ok_sel {
- my ($_widget, $file_selection) = @_;
+ my ($_w, $file_selection) = @_;
my $file_name = $file_selection->get_filename;
if ($file_name =~ /\Q$select_font_msg/) {
create_dialog(N("Error"), N("You've not selected any font"));
@@ -687,6 +607,7 @@ sub file_ok_sel {
$model->append_set(undef, [ 0 => $file_name ]);
}
}
+ Gtk2->main;
}
sub list_remove() { #- TODO : multi-selection
@@ -698,8 +619,28 @@ sub list_remove() { #- TODO : multi-selection
$treeStore->remove($iter);
}
+sub exitdialog { Gtk2->main_quit };
+
+sub dialog {
+ my ($title, $widgets, $buttons, $o_main_loop) = @_;
+ $dialog = _create_dialog($title);
+ $dialog->signal_connect(delete_event => \&exitdialog);
+ gtkpack_($dialog->vbox, @$widgets);
+ gtkpack($dialog->action_area, @$buttons) if $buttons;
+ $dialog->show_all;
+ $window1->{rwindow}->set_sensitive(0);
+ if ($o_main_loop) {
+ gtkflush();
+ $o_main_loop->();
+ } else {
+ Gtk2->main;
+ }
+ $dialog->destroy if $dialog;
+ undef $dialog;
+ $window1->{rwindow}->set_sensitive(1);
+}
+
sub advanced_install() {
- my $adv_box;
$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));
@@ -707,24 +648,20 @@ sub advanced_install() {
$list->get_selection->set_mode('browse');
$list->set_rules_hint(1);
- gtkpack($font_box,
- $adv_box = gtkpack_(Gtk2::VBox->new(0, 10),
- 1, gtkpack_(Gtk2::HBox->new(0, 4), 1, create_scrolled_window($list),),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("Add")), clicked => \&font_choice),
- gtksignal_connect(Gtk2::Button->new(N("Remove Selected")), clicked => \&list_remove),
- gtksignal_connect(Gtk2::Button->new(N("Install List")),
- clicked => sub {
- if (@install) {
- $$central_widget->destroy;
- appli_choice();
- }
- })
- )
- )
- );
- $central_widget = \$adv_box;
- $adv_box->show_all;
+ 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(Gtk2::Button->new(N("Install List")),
+ clicked => sub {
+ $dialog->destroy;
+ undef $dialog;
+ import_status() if @install;
+ }),
+ gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => \&exitdialog),
+ ],
+ );
}
sub list_to_remove() {
@@ -733,12 +670,10 @@ sub list_to_remove() {
my (@tux) = $left_list->get_selection->get_selected_rows; #- 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 ?
- $$central_widget->destroy;
show_list_to_remove();
}
sub show_list_to_remove() {
- my $show_box;
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));
@@ -748,24 +683,18 @@ sub show_list_to_remove() {
$model->append_set(undef, [ 0 => $_ ]) foreach @uninstall;
- gtkpack($font_box,
- $show_box = gtkpack_(Gtk2::VBox->new(0, 10),
- 1, gtkpack_(Gtk2::HBox->new(0, 4), 1, create_scrolled_window($list)),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("click here if you are sure.")),
- clicked => sub {
- $$central_widget->destroy;
- import_status_uninstall();
- }),
- gtksignal_connect(Gtk2::Button->new(N("here if no.")),
- clicked =>
- sub { $$central_widget->destroy; create_fontsel() }
- ),
- ),
- )
- );
- $central_widget = \$show_box;
- $show_box->show_all;
+ dialog(N("Uninstall"),
+ [
+ 1, gtkpack_(Gtk2::HBox->new(0, 4), 1, create_scrolled_window($list)),
+ ],
+ [
+ gtksignal_connect(Gtk2::Button->new(N("click here if you are sure.")),
+ clicked => sub { import_status_uninstall(); exitdialog() }),
+ gtksignal_connect(Gtk2::Button->new(N("here if no.")),
+ clicked => \&exitdialog
+ ),
+ ],
+ );
}
sub uninstall() { #- TODO : add item to right list with gtksignal_connect
@@ -793,67 +722,65 @@ sub uninstall() { #- TODO : add item to right list with gtksignal_connect
$right_list->get_selection->set_mode('multiple');
$right_list->set_rules_hint(1);
- gtkpack($font_box,
- $uninst_box = gtkpack_(Gtk2::VBox->new(0, 10),
- 1, gtkpack_(Gtk2::HBox->new(0, 4),
- 1, create_scrolled_window($left_list),
- #1, create_scrolled_window($right_list)
- ),
- 0, gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'spread'),
- gtksignal_connect(Gtk2::Button->new(N("Unselected All")),
- clicked => sub { $left_list->get_selection->unselect_all }
- ),
- gtksignal_connect(Gtk2::Button->new(N("Selected All")),
- clicked => sub { $left_list->get_selection->select_all }
- ),
- gtksignal_connect(Gtk2::Button->new(N("Remove List")), clicked => sub { list_to_remove() }),
- ),
- )
- );
- $central_widget = \$uninst_box;
- $uninst_box->show_all;
+ dialog(N("Uninstall"),
+ [
+ 1, gtkpack_(Gtk2::HBox->new(0, 4),
+ 1, create_scrolled_window($left_list),
+ #1, create_scrolled_window($right_list)
+ ),
+ ],
+ [
+ gtksignal_connect(Gtk2::Button->new(N("Unselected All")),
+ clicked => sub { $left_list->get_selection->unselect_all }
+ ),
+ gtksignal_connect(Gtk2::Button->new(N("Selected 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),
+ ],
+ );
}
sub import_status() {
- my $table;
$pbar = Gtk2::ProgressBar->new;
$pbar1 = Gtk2::ProgressBar->new;
$pbar2 = Gtk2::ProgressBar->new;
$pbar3 = Gtk2::ProgressBar->new;
- gtkpack(
- $font_box,
- $table = create_packtable({ col_spacings => 10, row_spacings => 50 },
- [ "", "" ],
- [ N("Initial tests"), $pbar, $pbar->set_text(' ') ],
- [ N("Copy fonts on your system"), $pbar1, $pbar1->set_text(' ') ],
- [ N("Install & convert Fonts"), $pbar2, $pbar2->set_text(' ') ],
- [ N("Post Install"), $pbar3, $pbar3->set_text(' ') ],
- ),
- );
- $central_widget = \$table;
- $font_box->show_all;
- gtkflush();
- backend_mod();
+ dialog(N("Importing fonts"),
+ [
+ 0, create_packtable({ col_spacings => 10, row_spacings => 50 },
+ [ "", "" ],
+ [ N("Initial tests"), $pbar, $pbar->set_text(' ') ],
+ [ N("Copy fonts on your system"), $pbar1, $pbar1->set_text(' ') ],
+ [ N("Install & convert Fonts"), $pbar2, $pbar2->set_text(' ') ],
+ [ N("Post Install"), $pbar3, $pbar3->set_text(' ') ],
+ ),
+ ],
+ [
+ ],
+ \&backend_mod,
+ );
}
sub import_status_uninstall() {
- my $table;
$pbar = Gtk2::ProgressBar->new;
$pbar1 = Gtk2::ProgressBar->new;
$pbar2 = Gtk2::ProgressBar->new;
- gtkpack(
- $font_box,
- $table = create_packtable({ col_spacings => 10, row_spacings => 50 },
- [ "", "" ],
- [ "", "" ],
- [ N("Initial tests"), $pbar, $pbar->set_text(' ') ],
- [ N("Remove fonts on your system"), $pbar1, $pbar1->set_text(' ') ],
- [ N("Post Uninstall"), $pbar2, $pbar2->set_text(' ') ],
- ),
- );
- $central_widget = \$table;
- $font_box->show_all;
- backend_mod();
+ dialog(N("Importing fonts"),
+ [
+ 0, create_packtable({ col_spacings => 10, row_spacings => 50 },
+ [ "", "" ],
+ [ "", "" ],
+ [ N("Initial tests"), $pbar, $pbar->set_text(' ') ],
+ [ N("Remove fonts on your system"), $pbar1, $pbar1->set_text(' ') ],
+ [ N("Post Uninstall"), $pbar2, $pbar2->set_text(' ') ],
+ ),
+ ],
+ [
+ ],
+ \&backend_mod,
+ );
}
sub progress {