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" ) );
84 webpinSearch =
new YMenuItem( _(
"Search Packages on &Web") );
86 items.push_back( repoManager );
87 items.push_back( onlineUpdate );
89 if (! exitAction.empty())
91 items.push_back( actionOnExit );
93 restart =
new YMenuItem( actionOnExit, CHECK_BOX + _(
"&Restart Package Manager" ) );
94 close =
new YMenuItem( actionOnExit,CHECK_BOX + _(
"&Close Package Manager" ) );
95 showSummary =
new YMenuItem( actionOnExit, CHECK_BOX + _(
"&Show Summary" ) );
97 idToItemPtr[
"restart"] = restart;
98 idToItemPtr[
"close"] = close;
99 idToItemPtr[
"summary"] = showSummary;
101 setSelected( idToItemPtr[ exitAction ],
true);
103 items.push_back( webpinSearch );
109 bool NCPkgMenuConfig::handleEvent(
const NCursesEvent & event)
111 if (!event.selection)
114 if ( event.selection == repoManager )
117 const_cast<NCursesEvent &
>(event).result =
"repo_mgr";
118 yuiMilestone() <<
"Launching repository manager " << endl;
123 else if ( event.selection == onlineUpdate )
126 const_cast<NCursesEvent &
>(event).result =
"online_update_configuration";
127 yuiMilestone() <<
"Launching YOU configuration " << endl;
131 else if ( event.selection == webpinSearch )
134 const_cast<NCursesEvent &
>(event).result =
"webpin";
135 yuiMilestone() <<
"Launching webpin search " << endl;
143 std::string old = exitAction;
145 if ( event.selection == restart )
147 exitAction =
"restart";
149 else if ( event.selection == close )
151 exitAction =
"close";
153 else if ( event.selection == showSummary )
155 exitAction =
"summary";
158 setSelected(idToItemPtr[old],
false);
159 setSelected(idToItemPtr[exitAction],
true);
160 pkg->setActionAtExit( exitAction );