Skip to content

Commit

Permalink
Factored out popupInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Jul 8, 2015
1 parent c21fee7 commit 867d162
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions src/NCPkgMenuDeps.cc
Expand Up @@ -137,13 +137,20 @@ bool NCPkgMenuDeps::handleEvent( const NCursesEvent & event)
return true;
}

bool NCPkgMenuDeps::checkDependencies()
static
void popupInfo(const wsze size, const std::string & text)
{
NCPopupInfo * info = new NCPopupInfo( wpos( (NCurses::lines()-5)/2, (NCurses::cols()-35)/2 ), "",
_( "All package dependencies are OK." ),
wpos pos((NCurses::lines() - size.H) / 2, (NCurses::cols() - size.W) / 2);
NCPopupInfo * info = new NCPopupInfo( pos,
"", text,
NCPkgStrings::OKLabel() );
info->setPreferredSize( 35, 5 );
info->setPreferredSize(size.W, size.H);
info->showInfoPopup();
YDialog::deleteTopmostDialog();
}

bool NCPkgMenuDeps::checkDependencies()
{
bool ok = false;

if ( pkg->DepsPopup() )
Expand All @@ -154,8 +161,7 @@ bool NCPkgMenuDeps::checkDependencies()

if ( ok )
{
info->showInfoPopup();
YDialog::deleteTopmostDialog();
popupInfo(wsze(5, 35), _( "All package dependencies are OK." ));
}

// update the package list and the disk space info
Expand All @@ -175,15 +181,10 @@ bool NCPkgMenuDeps::generateTestcase()

if ( success )
{
NCPopupInfo * info = new NCPopupInfo( wpos( (NCurses::lines()-8)/2, (NCurses::cols()-40)/2 ),
"",
_( "Dependency resolver test case written to " ) + "<br>"
+ testCaseDir
);
info->setPreferredSize( 40, 8 );
info->showInfoPopup( );

YDialog::deleteTopmostDialog();
popupInfo(wsze(8, 40),
_( "Dependency resolver test case written to " ) + "<br>"
+ testCaseDir
);
}
return success;

Expand Down Expand Up @@ -260,14 +261,7 @@ bool NCPkgMenuDeps::verify()
if ( ok && input == NCursesEvent::button )
{
// dependencies OK, no automatic changes/the user has accepted the changes
NCPopupInfo * info = new NCPopupInfo( wpos( (NCurses::lines()-5)/2, (NCurses::cols()-30)/2 ),
"",
_( "System dependencies verify OK." ),
NCPkgStrings::OKLabel()
);
info->setPreferredSize( 35, 5 );
info->showInfoPopup();
YDialog::deleteTopmostDialog();
popupInfo(wsze(5, 35), _( "System dependencies verify OK." ));
}

YDialog::deleteTopmostDialog(); // delete NCPopupInfo dialog
Expand Down

0 comments on commit 867d162

Please sign in to comment.