From 129f0fa9049b590059cc73aead2f324d5e93c8e3 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Thu, 14 Jun 2012 13:49:50 +0200 Subject: [PATCH] Move Growl::GNTP handling to Slic3r::GUI to allow notifications from both Slic3r::GUI::SkeinPanel and Slic3r::GUI::Plater. --- lib/Slic3r/GUI.pm | 19 +++++++++++++++++++ lib/Slic3r/GUI/Plater.pm | 6 +----- lib/Slic3r/GUI/SkeinPanel.pm | 13 +------------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 600708bfb..44cea26a0 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -12,6 +12,8 @@ use Wx 0.9901 qw(:sizer :frame wxID_EXIT wxID_ABOUT); use Wx::Event qw(EVT_MENU); use base 'Wx::App'; +my $growler; + sub OnInit { my $self = shift; @@ -27,6 +29,14 @@ sub OnInit { my $box = Wx::BoxSizer->new(wxVERTICAL); $box->Add($panel, 0); + if (eval "use Growl::GNTP; 1") { + # register growl notifications + eval { + $growler = Growl::GNTP->new(AppName => 'Slic3r', AppIcon => "$Slic3r::var/Slic3r.png"); + $growler->register([{Name => 'SKEIN_DONE', DisplayName => 'Slicing Done'}]); + }; + } + # menubar my $menubar = Wx::MenuBar->new; $frame->SetMenuBar($menubar); @@ -98,6 +108,15 @@ sub warning_catcher { }; } +sub notify { + my ($message) = @_; + + eval { + $growler->notify(Event => 'SKEIN_DONE', Title => 'Slicing Done!', Message => $message) + if $growler; + }; +} + package Slic3r::GUI::ProgressStatusBar; use base 'Wx::StatusBar'; diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index b8bbe8d9b..c9d460f30 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -519,11 +519,7 @@ sub export_gcode2 { $print->processing_time - int($print->processing_time/60)*60 if $print->processing_time; $message .= "."; - eval { - # TODO: fix it as we don't have $self->{growler} - $self->{growler}->notify(Event => 'SKEIN_DONE', Title => 'Slicing Done!', Message => $message) - if ($self->{growler}); - }; + Slic3r::GUI::notify($message); $params{on_completed}->($message); $print->cleanup; }; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 6cff1d0c0..b5977ab38 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -86,14 +86,6 @@ sub new { }, ); $self->{panels} = \%panels; - - if (eval "use Growl::GNTP; 1") { - # register growl notifications - eval { - $self->{growler} = Growl::GNTP->new(AppName => 'Slic3r', AppIcon => "$Slic3r::var/Slic3r.png"); - $self->{growler}->register([{Name => 'SKEIN_DONE', DisplayName => 'Slicing Done'}]); - }; - } my $tabpanel = Wx::Notebook->new($self, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, &Wx::wxNB_TOP); my $make_tab = sub { @@ -272,10 +264,7 @@ sub do_slice { $print->processing_time - int($print->processing_time/60)*60 if $print->processing_time; $message .= "."; - eval { - $self->{growler}->notify(Event => 'SKEIN_DONE', Title => 'Slicing Done!', Message => $message) - if ($self->{growler}); - }; + Slic3r::GUI::notify($message); Wx::MessageDialog->new($self, $message, 'Done!', wxOK | wxICON_INFORMATION)->ShowModal; };