41 #define YUILogComponent "ncurses-pkg" 44 #include "NCPkgMenuConfig.h" 45 #include "NCPackageSelector.h" 47 #define CHECK_BOX "[ ] " 56 NCPkgMenuConfig::NCPkgMenuConfig (YWidget *parent, std::string label,
NCPackageSelector *pkger)
57 : NCMenuButton( parent, label)
63 NCPkgMenuConfig::~NCPkgMenuConfig()
68 void NCPkgMenuConfig::setSelected( YMenuItem *item,
bool selected)
70 std::string oldLabel = item->label();
72 std::string newLabel = oldLabel.replace(1,1,1, selected ?
'x' :
' ');
74 item->setLabel( newLabel);
77 void NCPkgMenuConfig::createLayout()
79 exitAction = pkg->ActionAtExit();
81 repoManager =
new YMenuItem( _(
"Launch &Repository Manager") );
82 onlineUpdate =
new YMenuItem( _(
"Launch &Online Update Configuration" ) );
83 actionOnExit =
new YMenuItem( _(
"&Action after Package Installation" ) );
85 items.push_back( repoManager );
86 items.push_back( onlineUpdate );
88 if (! exitAction.empty())
90 items.push_back( actionOnExit );
92 restart =
new YMenuItem( actionOnExit, CHECK_BOX + _(
"&Restart Package Manager" ) );
93 close =
new YMenuItem( actionOnExit,CHECK_BOX + _(
"&Close Package Manager" ) );
94 showSummary =
new YMenuItem( actionOnExit, CHECK_BOX + _(
"&Show Summary" ) );
96 idToItemPtr[
"restart"] = restart;
97 idToItemPtr[
"close"] = close;
98 idToItemPtr[
"summary"] = showSummary;
100 setSelected( idToItemPtr[ exitAction ],
true);
107 bool NCPkgMenuConfig::handleEvent(
const NCursesEvent & event)
109 if (!event.selection)
112 if ( event.selection == repoManager )
115 const_cast<NCursesEvent &
>(event).result =
"repo_mgr";
116 yuiMilestone() <<
"Launching repository manager " << endl;
121 else if ( event.selection == onlineUpdate )
124 const_cast<NCursesEvent &
>(event).result =
"online_update_configuration";
125 yuiMilestone() <<
"Launching YOU configuration " << endl;
131 std::string old = exitAction;
133 if ( event.selection == restart )
135 exitAction =
"restart";
137 else if ( event.selection == close )
139 exitAction =
"close";
141 else if ( event.selection == showSummary )
143 exitAction =
"summary";
146 setSelected(idToItemPtr[old],
false);
147 setSelected(idToItemPtr[exitAction],
true);
148 pkg->setActionAtExit( exitAction );