Commit 7f88b00e authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Get rid of superfluous $self->{'mw'} members

FIJISettingsViewer and FIJITestsViewer are widgets and can refere to
their root windows via $self->MainWindow thus there is no need to
store them additionally.
parent a4616570
......@@ -83,7 +83,6 @@ sub Populate {
my ($self, $args) = @_;
my $settings = delete $args->{'-settings'};
$self->{'changes_callback'} = delete $args->{'-changes_callback'};
$self->{'mw'} = delete $args->{'-mw'};
my $lib_path = delete $args->{'-lib_path'};
......@@ -116,7 +115,6 @@ sub Populate {
-resources => [qw/METHOD resources Resources/, undef],
);
$self->update();
$self->{'mw'} = $self->toplevel;
}
sub netlist {
......@@ -220,8 +218,8 @@ sub update {
my $msg = "Could not find FIJI definition for constant named \"$name\"";
$logger->error($msg);
my $error_dialog = $self->{'mw'}->FIJIModalDialog(
-image => Tk::FIJIUtils::error_image($self->{'mw'}),
my $error_dialog = $self->MainWindow->FIJIModalDialog(
-image => Tk::FIJIUtils::error_image($self->MainWindow),
-text => 'Something went horribly wrong!',
-wraplength => $self->MainWindow->screenwidth,
-title => 'Error',
......@@ -794,7 +792,7 @@ sub _add_fiu_panel {
'-sticky' => 'nwse',
);
Tk::FIJIUtils::bind_mousewheel($self->{'mw'},$fr_fius_scroll);
Tk::FIJIUtils::bind_mousewheel($self->MainWindow,$fr_fius_scroll);
$fr_fius_scroll->pack(
'-expand' => 1,
......@@ -873,7 +871,7 @@ sub _add_fius {
}
my $msg = '';
$self->{'mw'}->Busy;
$self->MainWindow->Busy;
my $prev_cnt = $self->_fiu_cnt(); # we will append this FIU
for my $netname (@{$netnames}) {
# create the FIU and add it to the panel
......@@ -888,9 +886,9 @@ sub _add_fius {
# Not assigning is only an option if multiple nets are selected.
# If there is only one net we better show the driver selection immediately.
if (scalar(@{$netnames}) > 1) {
my $d = $self->{'mw'}->FIJIModalDialog(-text => "Do you want to assign drivers for all these nets?",
-title => 'Assign drivers?',
-buttons => ["~Yes", "~No"]);
my $d = $self->MainWindow->FIJIModalDialog(-text => "Do you want to assign drivers for all these nets?",
-title => 'Assign drivers?',
-buttons => ["~Yes", "~No"]);
my $reply = $d->Show();
$assign_drivers = (defined($reply) && lc($reply) eq 'yes');
......@@ -919,7 +917,7 @@ sub _add_fius {
chomp($msg);
Tk::FIJIUtils::show_warning($self, $msg);
}
$self->{'mw'}->Unbusy;
$self->MainWindow->Unbusy;
$self->_check_change(); # update change indicator etc.
$self->{'settings_canvas'}->update(); # update Block Diagram
......@@ -1093,14 +1091,14 @@ sub _add_fiu_widgets {
);
# Buttons to reorder FIUs
my $up_button = $fr_fiu->Button(-image => Tk::FIJIUtils::up_image($self->{'mw'}), -command => [\&swap_fiu, $self, $i, $i-1]);
my $up_button = $fr_fiu->Button(-image => Tk::FIJIUtils::up_image($self->MainWindow), -command => [\&swap_fiu, $self, $i, $i-1]);
$self->{'balloon'}->attach(
$up_button,
-balloonposition => 'mouse',
-msg => "Move FIU $i up."
);
my $down_button = $fr_fiu->Button(-image => Tk::FIJIUtils::down_image($self->{'mw'}), -command => [\&swap_fiu, $self, $i, $i+1]);
my $down_button = $fr_fiu->Button(-image => Tk::FIJIUtils::down_image($self->MainWindow), -command => [\&swap_fiu, $self, $i, $i+1]);
$self->{'balloon'}->attach(
$down_button,
-balloonposition => 'mouse',
......@@ -1110,7 +1108,7 @@ sub _add_fiu_widgets {
# Button to rename the FIU
my $rename_button = $fr_fiu->Button(
#-text => 'Rename',
-image => Tk::FIJIUtils::rename_image($self->{'mw'}),
-image => Tk::FIJIUtils::rename_image($self->MainWindow),
-command => [\&_rename_fiu_dialog, $self, $i, $fr_fiu],
);
$self->{'balloon'}->attach(
......@@ -1123,7 +1121,7 @@ sub _add_fiu_widgets {
my $del_button = $fr_fiu->Button(
#-text => 'Delete',
-image => Tk::FIJIUtils::delete_image($self->{'mw'}),
-image => Tk::FIJIUtils::delete_image($self->MainWindow),
-command => [\&remove_fiu, $self, $i],
);
$self->{'balloon'}->attach(
......@@ -1210,7 +1208,7 @@ sub _add_fiu_widgets {
sub _rename_fiu_dialog {
my ($self, $i, $labframe) = @_;
my $rename_dialog = $self->{'mw'}->FIJIModalDialog(
my $rename_dialog = $self->MainWindow->FIJIModalDialog(
-wraplength => $labframe->screenwidth,
-title => "Name for FIU $i",
-buttons => [qw(OK Cancel)]
......@@ -1290,8 +1288,8 @@ sub _set_fields_by_button {
} elsif (${$button->cget('-variable')} && ${$f->cget('-variable')}) {
${$button->cget('-variable')} = 0;
my $error_dialog = $self->{'mw'}->FIJIModalDialog(
-image => Tk::FIJIUtils::error_image($self->{'mw'}),
my $error_dialog = $self->MainWindow->FIJIModalDialog(
-image => Tk::FIJIUtils::error_image($self->MainWindow),
-wraplength => $self->MainWindow->screenwidth,
-text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".",
-title => "Error",
......@@ -1535,8 +1533,8 @@ sub _select_driver_dialog($) {
$logger->info($msg);
if ($show_single_driver_info == 1) {
my $info_dialog = $self->{'mw'}->FIJIModalDialog(
-image => Tk::FIJIUtils::info_image($self->{'mw'}),
my $info_dialog = $self->MainWindow->FIJIModalDialog(
-image => Tk::FIJIUtils::info_image($self->MainWindow),
-text => "$msg",
-wraplength => $self->MainWindow->screenwidth,
-title => "Info",
......
......@@ -114,7 +114,6 @@ sub Populate {
my $tests = delete $args->{'-tests'};
$self->{'changes_callback'} = delete $args->{'-changes_callback'};
$self->{'test_callback'} = delete $args->{'-test_callback'};
$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'};
......@@ -250,13 +249,13 @@ sub _download {
$downloader_reply = $worker_msg->{'rmsg'};
if ($worker_msg->{'state'} eq "dying") {
my $d = $self->{'mw'}->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->{'mw'}),
-wraplength => "400",
-text => $downloader_reply,
-title => 'Download worker thread died!',);
my $d = $self->MainWindow->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->MainWindow),
-wraplength => "400",
-text => $downloader_reply,
-title => 'Download worker thread died!',);
$d->Show();
# FIXME: convey this error to the main thread instead of simply closing the GUI
$self->{'mw'}->destroy();
$self->MainWindow->destroy();
}
# process message
......@@ -292,9 +291,9 @@ sub _download {
$text .= RMSG_ERROR_STRINGS->{$k} . "\n" if $downloader_reply->{'error'}->{$k};
}
my $d = $self->{'mw'}->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->{'mw'}),
-text => $text,
-title => "Error while downloading.",);
my $d = $self->MainWindow->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->MainWindow),
-text => $text,
-title => "Error while downloading.",);
$d->Show();
}
......@@ -330,10 +329,10 @@ sub get_last_test {
if (!defined $self->{'last_test'}) {
my $msg = "Could not determine last test case.";
$logger->error($msg);
my $d = $self->{'mw'}->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->{'mw'}),
-wraplength => "200",
-text => $msg,
-title => 'Export failed!',);
my $d = $self->MainWindow->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->MainWindow),
-wraplength => "200",
-text => $msg,
-title => 'Export failed!',);
$d->Show();
} else {
$lt = $self->{'last_test'};
......@@ -1059,7 +1058,7 @@ sub edit_test {
my $original_test = @{$self->{'tests'}->{'tests'}}[$i];
my $test = clone($original_test);
my $db = $self->{'mw'}->FIJIModalDialog(
my $db = $self->MainWindow->FIJIModalDialog(
-title => "Edit Test $i",
-buttons => [qw/OK Cancel/],
-scrollable => 0,
......@@ -1107,7 +1106,7 @@ sub _add_test ($$) {
);
my $up_button = $self->{'fr_tests'}->Button(
-image => Tk::FIJIUtils::up_image($self->{'mw'}),
-image => Tk::FIJIUtils::up_image($self->MainWindow),
-command => [\&swap_test, $self, $i, $i-1],
);
$self->{'balloon'}->attach(
......@@ -1117,7 +1116,7 @@ sub _add_test ($$) {
);
my $down_button = $self->{'fr_tests'}->Button(
-image => Tk::FIJIUtils::down_image($self->{'mw'}),
-image => Tk::FIJIUtils::down_image($self->MainWindow),
-command => [\&swap_test, $self, $i, $i+1],
);
$self->{'balloon'}->attach(
......@@ -1269,9 +1268,9 @@ 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->{'mw'}->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->{'mw'}),
-text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".",
-title => "Error.",);
my $d = $self->MainWindow->FIJIModalDialog(-image => Tk::FIJIUtils::error_image($self->MainWindow),
-text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".",
-title => "Error.",);
$d->Show();
}
}
......
......@@ -282,7 +282,6 @@ sub main {
$self->{'FIJITestsViewer'} = $mw->FIJITestsViewer(
-changes_callback => sub { my $value = shift; _indicate_changes($self, $value) },
-test_callback => sub { my $value = shift; $self->{'export_menuentry'}->configure(-state => ($value > 0) ? "normal" : "disabled")},
-mw => $self->{'mw'},
-tests => $self->{'tests'},
-settings => $self->{'settings'},
-worker => $worker_tid,
......
......@@ -130,7 +130,6 @@ sub main {
$mw->toplevel()->bind("<F1>" => sub { Tk::FIJIUtils::show_documentation($mw); });
$self->{'FIJISettingsViewer'} = $mw->FIJISettingsViewer(
-mw => $self->{'mw'},
-settings => $self->{'settings'},
-changes_callback => sub { my $set = shift; _indicate_changes($self, $set) },
)->pack(
......@@ -429,9 +428,7 @@ sub _open_netlist_file {
my $logger = get_logger("");
my $self = shift;
my $mw = $self->{'mw'};
my $fb = $mw->FBox(
my $fb = $self->{'mw'}->FBox(
-type => 'open',
-title => 'Open netlist file',
-filetypes => FILE_TYPES_NETLIST,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment