Commit 0aa46e6c authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

Modal dialog that prevents closing the Main Window

parent 4ea99189
package Tk::FIJIModalDialog;
use Log::Log4perl qw(get_logger);
use Tk;
use Tk::widgets qw(LabFrame Label Entry Button DialogBox);
use Tk::PNG;
use File::Spec;
use base qw(Tk::DialogBox);
Construct Tk::Widget 'FIJIModalDialog';
sub ClassInit {
my ($class, $mw) = @_;
$class->SUPER::ClassInit($mw);
my $self = bless {}, $class;
return $self;
}
sub Populate {
my $logger = get_logger("");
my ($self, $args) = @_;
$self->{'delete_mw'} = delete $args->{'-delete_mw'};
$self->{'mw'} = delete $args->{'-mw'};
my $image = delete $args->{'-image'};
my $text = delete $args->{'-text'};
my $wraplength = delete $args->{'-wraplength'};
$self->SUPER::Populate($args);
$self->{'label'} = $self->add('Label', -text => $text, -justify => 'left', )->pack(-side => 'right') if (defined $text);
$self->{'label'}->configure(-wraplength => $wraplength) if (defined $wraplength);
$self->{'image'} = $self->add('Label', -image => $image)->pack(-side => 'left') if (defined $image);
}
sub Show {
my ($self) = @_;
if (defined $self->{'mw'} && defined $self->{'delete_mw'}) {
$self->{'mw'}->protocol('WM_DELETE_WINDOW' => sub {return 1});
}
my $rv = $self->SUPER::Show();
if (defined $self->{'mw'} && defined $self->{'delete_mw'}) {
$self->{'mw'}->protocol('WM_DELETE_WINDOW' => $self->{'delete_mw'});
}
return $rv;
}
\ No newline at end of file
......@@ -34,6 +34,7 @@ use FIJI::Utils;
use Tk;
use Tk::widgets qw(LabFrame Balloon Label Entry Pane Button Dialog DialogBox Checkbutton CompleteEntry NoteBook StatusBar FIJISettingsCanvas);
use Tk::DynaMouseWheelBind;
use Tk::FIJIModalDialog;
use constant RESOURCES_REGS_LOWER => 0.1;
use constant RESOURCES_LUTS_LOWER => 0.1;
......@@ -82,6 +83,9 @@ sub Populate {
my ($self, $args) = @_;
my $settings = delete $args->{'-settings'};
$self->{'changes_callback'} = delete $args->{'-changes_callback'};
$self->{'delete_mw'} = delete $args->{'-delete_mw'};
$self->{'mw'} = delete $args->{'-mw'};
my $icon_path = delete $args->{'-icon_path'};
if (!defined($settings) || !blessed($settings) || !$settings->isa("FIJI::Settings")) {
......@@ -113,7 +117,7 @@ sub Populate {
-resources => [qw/METHOD resources Resources/, undef],
);
$self->update();
$self->{'mw'} = $self->toplevel;
$delete_image = $self->Photo(-file => File::Spec->catfile($icon_path, 'delete_48x48.xpm'), -format => 'XPM');
$error_image = $self->Photo(-file => File::Spec->catfile($icon_path, 'stop_48x48.xpm'), -format => 'XPM');
$alert_image = $self->Photo(-file => File::Spec->catfile($icon_path, 'alert_48x48.xpm'), -format => 'XPM');
......@@ -148,11 +152,17 @@ sub netlist {
if ($self->{'nets_ok'} != 1) {
my $msg = "Some nets defined in the specified netlist do not match the loaded settings.";
$logger->error($msg);
my $d = $self->DialogBox(-title => 'Warning', -buttons => ["Yes", "No"]);
$d->add('Label', -text => $msg . "\n" . "Proceed with new netlist nevertheless?", -justify => 'left', -wraplength => 200)->pack(-side => 'right');
$d->add('Label', -image => $alert_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $alert_image,
-text => $msg . "\n" . "Proceed with new netlist nevertheless?",
-wraplength => 200,
-title => 'Warning',
-buttons => [qw/Yes No/]);
my $rv = $d->Show();
if ($rv eq "No") {
if (!defined $rv || $rv eq "No") {
$logger->info("Using original netlist");
$self->{'nets'} = $old_nets;
$self->{'netlist'} = $old_netlist;
......@@ -189,11 +199,17 @@ sub settings {
if (defined $self->{'nets'} && $self->{'nets_ok'} != 1) {
my $msg = "Some nets defined in the specified settings do not match the loaded netlist.";
$logger->info($msg);
my $d = $self->DialogBox(-title => 'Warning', -buttons => ["Yes", "No"]);
$d->add('Label', -text => $msg . "\n" . "Proceed with new settings nevertheless?", -justify => 'left', -wraplength => 200)->pack(-side => 'right');
$d->add('Label', -image => $alert_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $alert_image,
-text => $msg . "\n" . "Proceed with new netlist nevertheless?",
-wraplength => 200,
-title => 'Warning',
-buttons => [qw/Yes No/]);
my $rv = $d->Show();
if ($rv eq "No") {
if (!defined $rv || $rv eq "No") {
$logger->info("Using original settings");
$self->{'settings'} = $old_settings;
$self->{'original_settings'} = clone($old_settings);
......@@ -261,9 +277,15 @@ sub update {
if (!defined($k)) {
my $msg = "Could not find FIJI definition for constant named \"$name\"";
$logger->error($msg);
my $d = $self->DialogBox(-title => 'Warning', -buttons => ["OK"]);
$d->add('Label', -text => 'Something went horribly wrong!', -justify => 'left', -wraplength => 200)->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-text => 'Something went horribly wrong!',
-wraplength => 200,
-title => 'Warning',
-buttons => ["OK"]);
$d->Show();
return;
}
......@@ -437,16 +459,22 @@ sub _populate_widget {
} elsif ($^O eq "linux") {
$ret = FIJI::Utils::system("xdg-open " . FIJI_DOCUMENTATION_PATH);
} else {
my $d = $self->DialogBox(-title => "Open Documentation", -buttons => ["OK"]);
$d->add('Label', -text => "No default PDF viewer for OS \"" . $^O . "\"...", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-text => "No default PDF viewer for OS \"" . $^O . "\"...",
-title => "Open Documentation failed",
-buttons => ["OK"]);
$d->Show();
return;
}
if (defined($ret)) {
my $d = $self->DialogBox(-title => "Open Documentation failed", -buttons => ["OK"]);
$d->add('Label', -text => "$ret", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-text => $ret,
-title => "Open Documentation failed",
-buttons => ["OK"]);
$d->Show();
}
}
......@@ -890,9 +918,14 @@ sub _add_fiu ($$) {
-command => sub {
my $rv = $self->_select_driver_dialog($i);
if (defined $rv) {
my $d = $self->DialogBox(-title => 'Error', -buttons => ["OK"]);
$d->add('Label', -text => $rv, -justify => 'left', -wraplength => $fr_fiu->screenwidth)->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => $fr_fiu->screenwidth
-text => $rv,
-title => "Error",
-buttons => ["OK"]);
$d->Show();
}
$self->_check_change();
......@@ -1066,9 +1099,14 @@ sub _set_fields_by_button {
$logger->error("Type mismatch: 'forbidden_by' must only include boolean values");
} elsif (${$button->cget('-variable')} && ${$f->cget('-variable')}) {
${$button->cget('-variable')} = 0;
my $d = $self->DialogBox(-title => 'Warning', -buttons => ["OK"]);
$d->add('Label', -text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".", -justify => 'left', -wraplength => 200)->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => 200,
-text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".",
-title => "Error",
-buttons => ["OK"]);
$d->Show();
}
}
......
......@@ -42,6 +42,7 @@ use Tk;
use Tk::Adjuster;
use Tk::widgets qw(LabFrame ROText Balloon Label Entry Pane Button DialogBox Checkbutton CompleteEntry StatusBar NoteBook);
use Tk::FIJITestFrame;
use Tk::FIJIModalDialog;
use Tk::DynaMouseWheelBind;
use base qw(Tk::Frame);
......@@ -112,6 +113,8 @@ sub Populate {
my $settings = delete $args->{'-settings'};
my $tests = delete $args->{'-tests'};
$self->{'changes_callback'} = delete $args->{'-changes_callback'};
$self->{'delete_mw'} = delete $args->{'-delete_mw'};
$self->{'mw'} = delete $args->{'-mw'};
$self->{'worker'} = delete $args->{'-worker'};
$self->{'queue_to_worker'} = delete $args->{'-queue_to_worker'};
$self->{'queue_from_worker'} = delete $args->{'-queue_from_worker'};
......@@ -298,9 +301,14 @@ sub _download {
for my $k (keys(%{$rmsg_error_strings})) {
$text .= RMSG_ERROR_STRINGS->{$k} . "\n" if $rmsg->{'error'}->{$k};
}
my $d = $self->DialogBox(-title => "Error while downloading.");
$d->add('Label', -text => $text, -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-text => $text,
-title => "Error while downloading.",
-buttons => [qw/OK/]);
$d->Show();
}
if (defined $msg->{'testref'} && ref($msg->{'testref'}) eq "FIJI::Tests") {
......@@ -313,9 +321,14 @@ sub _download {
$rv = $msg->{'testref'}->save($new_name) if defined $new_name;
if(defined $rv) {
$logger->error($rv);
my $d = $self->DialogBox(-title => "Error saving tests.");
$d->add('Label', -text => $rv, -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-text => $rv,
-title => "Error saving tests.",
-buttons => [qw/OK/]);
$d->Show();
}
}
......@@ -327,9 +340,12 @@ sub _download {
$rv = $msg->{'testref'}->export_tb($tb_name,$self->{'settings'});
if(defined $rv) {
$logger->error($rv);
my $d = $self->DialogBox(-title => "Error saving testbench.");
$d->add('Label', -text => $rv, -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-text => $rv,
-title => "Error saving testbench.",
-buttons => [qw/OK/]);
$d->Show();
}
}
......@@ -1015,9 +1031,12 @@ sub _set_fields_by_button {
$logger->error("Type mismatch: 'forbidden_by' must only include boolean values");
} elsif (${$button->cget('-variable')} && ${$f->cget('-variable')}) {
${$button->cget('-variable')} = 0;
my $d = $self->DialogBox(-title => "Error.", -buttons => ["OK"]);
$d->add('Label', -text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".",, -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => $self->{'delete_mw'},
-mw => $self->{'mw'},
-image => $error_image,
-text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".",
-title => "Error.",
-buttons => [qw/OK/]);
$d->Show();
}
}
......
......@@ -34,6 +34,7 @@ use Log::Log4perl qw(get_logger);
use Tk;
use Tk::widgets qw(LabFrame Label Entry Button DialogBox FBox Checkbutton);
use Tk::PNG;
use Tk::FIJIModalDialog;
use Clone qw(clone);
use File::Spec;
use FIJI::Utils;
......@@ -241,9 +242,13 @@ sub main {
if (!ref($tmp_settings)) {
my $msg = "settings file $filename could not be loaded correctly: $tmp_settings";
$logger->error($msg);
my $d = $mw->DialogBox(-title => 'Open FIJI settings failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left', -wraplength => "200")->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => "200",
-text => $msg,
-title => 'Open FIJI Settings failed!',
-buttons => ["OK"]);
$d->Show();
$ret = 1;
goto bailout;
......@@ -270,9 +275,13 @@ sub main {
if (!ref($tmp_tests)) {
my $msg = "Tests file $filename could not be loaded correctly: $tmp_tests";
$logger->error($msg);
my $d = $mw->DialogBox(-title => 'Open FIJI Tests failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left', -wraplength => "200")->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => "200",
-text => $msg,
-title => 'Open FIJI Tests failed!',
-buttons => ["OK"]);
$d->Show();
$ret = 1;
goto bailout;
......@@ -303,11 +312,13 @@ sub main {
$mw->toplevel()->bind("<Control-s>" => sub { $self->_save; });
$mw->toplevel()->bind("<Control-Shift-S>" => sub { $self->_save_as; });
$mw->toplevel()->bind("<F1>" => sub { $self->_show_documentation; });
$mw->toplevel()->bind("<Control-q>" => sub { $self->_onexit($mw); });
$mw->toplevel()->bind("<Control-q>" => sub { $self->_onexit(); });
$self->{'documentation_path'} = File::Spec->catfile($ugdir, 'fiji_user_guide.pdf');
$self->{'FIJITestsViewer'} = $mw->FIJITestsViewer(
-changes_callback => sub { my $set = shift; _indicate_changes($self, $set) },
-mw => $self->{'mw'},
-delete_mw => [\&_onexit, $self],
-icon_path => $libdir,
-tests => $self->{'tests'},
-settings => $self->{'settings'},
......@@ -321,7 +332,7 @@ sub main {
'-expand' => 1
);
$mw->protocol('WM_DELETE_WINDOW' => [\&_onexit, $self, $mw]);
$mw->protocol('WM_DELETE_WINDOW' => [\&_onexit, $self]);
$mw->deiconify();
$mw->raise();
......@@ -434,9 +445,13 @@ sub _load_settings_prompt {
if (!ref($tmp_settings)) {
my $msg = "tests file $filename could not be loaded correctly: $tmp_settings";
$logger->error($msg);
my $d = $fr->DialogBox(-title => 'Open FIJI Tests failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left', -wraplength => "200")->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => "200",
-text => $msg,
-title => 'Open FIJI Tests failed!',
-buttons => ["OK"]);
$d->Show();
}
}
......@@ -532,16 +547,22 @@ sub _show_documentation {
} elsif ($^O eq "linux") {
$ret = FIJI::Utils::system("xdg-open " . FIJI_DOCUMENTATION_PATH);
} else {
my $d = $mw->DialogBox(-title => "Open Documentation failed", -buttons => ["OK"]);
$d->add('Label', -text => "No default PDF viewer for OS \"" . $^O . "\"...", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-text => "No default PDF viewer for OS \"" . $^O . "\"...",
-title => "Open Documentation failed",
-buttons => ["OK"]);
$d->Show();
return;
}
if (defined($ret)) {
my $d = $mw->DialogBox(-title => "Open Documentation failed", -buttons => ["OK"]);
$d->add('Label', -text => "$ret", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-text => $ret,
-title => "Open Documentation failed",
-buttons => ["OK"]);
$d->Show();
}
}
......@@ -568,18 +589,26 @@ sub _open_tests_file {
if (!ref($tmp_tests)) {
my $msg = "tests file $filename could not be loaded correctly: $tmp_tests";
$logger->error($msg);
my $d = $mw->DialogBox(-title => 'Open FIJI tests failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left', -wraplength => "200")->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => "200",
-text => $msg,
-title => 'Open FIJI Tests failed!',
-buttons => ["OK"]);
$d->Show();
return;
}
if (!defined($self->{'FIJITestsViewer'}->configure(-tests => $tmp_tests))) {
my $msg = "Could not update GUI correctly with new tests.";
$logger->error($msg);
my $d = $mw->DialogBox(-title => 'Open FIJI tests failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left', -wraplength => "200")->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => "200",
-text => $msg,
-title => 'Open FIJI Tests failed!',
-buttons => ["OK"]);
$d->Show();
return;
}
......@@ -594,11 +623,14 @@ sub _overwrite_existing_file ($) {
if (!-e $filename) {
return 1;
}
my $d = $self->{'mw'}->DialogBox(-title => 'Really overwrite?', -buttons => ["Yes", "No"]);
$d->add('Label', -text => "File \"$filename\" already exists.\nDo you want to overwrite it?", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $alert_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $alert_image,
-text => "File \"$filename\" already exists.\nDo you want to overwrite it?",
-title => 'Really overwrite?',
-buttons => ["Yes", "No"]);
my $reply = $d->Show();
return (lc($reply) eq 'yes');
return (defined $reply && lc($reply) eq 'yes');
}
sub _save_file {
......@@ -611,9 +643,12 @@ sub _save_file {
if (defined($err)) {
my $msg = "Saving to file $filename failed!\n$err";
$logger->error($msg);
my $d = $self->DialogBox(-title => 'Save failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-text => $msg,
-title => 'Save failed!',
-buttons => ["OK"]);
$d->Show();
return;
}
......@@ -641,7 +676,10 @@ sub _save_as {
-defaultextension => 'cfg',
-filetypes => TESTS_FILE_TYPES_CFG,
-initialdir => $current_dir,
-initialfile => 'fiji.tst'
-initialfile => 'fiji.tst',
-force => 1, # prevent FBox's "overwrite?" dialog
# because we have our own check and a nicer dialog
# AND we want to prevent showing the dialog twice
)->Show();
if (!defined($filename)) {
......@@ -653,16 +691,22 @@ sub _save_as {
sub _onexit {
my $logger = get_logger("");
my ($self, $mw) = @_;
my ($self) = @_;
my $mw = $self->{'mw'};
return if (defined $self->{'already_clicked'} && $self->{'already_clicked'} == 1);
$self->{'already_clicked'} = 1;
my $response;
if ($unsaved_changes == 1) {
my $d = $mw->DialogBox(-title => 'Really quit?', -buttons => ["Save", "Cancel", "Quit"]);
$d->add('Label', -text => "Unsaved changes.\nDo you really want to quit?", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $alert_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $alert_image,
-text => "Unsaved changes.\nDo you really want to quit?",
-wraplength => 350,
-title => 'Really quit?',
-buttons => ["Save", "Cancel", "Quit"]);
$response = $d->Show();
$self->{'already_clicked'} = 0;
$logger->info("Settings changed. Asking to save.") if ($unsaved_changes == 1);
......
......@@ -173,9 +173,11 @@ sub main {
$mw->toplevel()->bind("<Control-s>" => sub { $self->_save; });
$mw->toplevel()->bind("<Control-Shift-S>" => sub { $self->_save_as; });
$mw->toplevel()->bind("<F1>" => sub { $self->_show_documentation; });
$mw->toplevel()->bind("<Control-q>" => sub { $self->_onexit($mw); });
$mw->toplevel()->bind("<Control-q>" => sub { $self->_onexit; });
$self->{'FIJISettingsViewer'} = $mw->FIJISettingsViewer(
-mw => $self->{'mw'},
-delete_mw => [\&_onexit, $self],
-settings => $self->{'settings'},
-icon_path => $libdir,
-changes_callback => sub { my $set = shift; _indicate_changes($self, $set) },
......@@ -184,7 +186,7 @@ sub main {
'-expand' => 1
);
$mw->protocol('WM_DELETE_WINDOW' => [\&_onexit, $self, $mw]);
$mw->protocol('WM_DELETE_WINDOW' => [\&_onexit, $self]);
Tk::FIJIUtils::set_icon($mw, $libdir);
......@@ -211,18 +213,26 @@ sub main {
if (!ref($tmp_settings)) {
my $msg = "Settings file $filename could not be loaded correctly: $tmp_settings";
$logger->error($msg);
my $d = $fr->DialogBox(-title => 'Open FIJI Settings failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left', -wraplength => "200")->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => "200",
-text => $msg,
-title => 'Open FIJI Settings failed!',
-buttons => ["OK"]);
$d->Show();
return;
}
if (!defined($self->{'FIJISettingsViewer'}->settings($tmp_settings))) {
my $msg = "Could not update GUI correctly with new settings.";
$logger->error($msg);
my $d = $fr->DialogBox(-title => 'Open FIJI Settings failed!', -buttons => ["OK"]);
$d->add('Label', -text => $msg, -justify => 'left', -wraplength => "200")->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-wraplength => "200",
-text => $msg,
-title => 'Open FIJI Settings failed!',
-buttons => ["OK"]);
$d->Show();
return;
}
......@@ -431,16 +441,22 @@ sub _show_documentation {
} elsif ($^O eq "linux") {
$ret = FIJI::Utils::system("xdg-open " . FIJI_DOCUMENTATION_PATH);
} else {
my $d = $mw->DialogBox(-title => "Open Documentation failed", -buttons => ["OK"]);
$d->add('Label', -text => "No default PDF viewer for OS \"" . $^O . "\"...", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],
-mw => $self->{'mw'},
-image => $error_image,
-text => "No default PDF viewer for OS \"" . $^O . "\"...",
-title => "Open Documentation failed",
-buttons => ["OK"]);
$d->Show();
return;
}
if (defined($ret)) {
my $d = $mw->DialogBox(-title => "Open Documentation failed", -buttons => ["OK"]);
$d->add('Label', -text => "$ret", -justify => 'left')->pack(-side => 'right');
$d->add('Label', -image => $error_image)->pack(-side => 'left');
my $d = $self->{'mw'}->FIJIModalDialog(-delete_mw => [\&_onexit, $self],