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