41 #define YUILogComponent "ncurses-pkg"
44 #include <boost/format.hpp>
46 #include "NCPkgFilterLocale.h"
54 NCPkgLocaleTag::NCPkgLocaleTag ( zypp::sat::LocaleSupport loc, std::string status )
55 : YTableCell( status )
62 NCPkgLocaleTable::NCPkgLocaleTable( YWidget *parent, YTableHeader *tableHeader,
NCPackageSelector *pkg )
63 :NCTable( parent, tableHeader )
71 void NCPkgLocaleTable::fillHeader()
73 std::vector <std::string> header;
76 header.push_back( NCPkgStrings::PkgStatus() );
77 header.push_back( NCPkgStrings::LangCode() );
78 header.push_back( NCPkgStrings::LangName() );
84 void NCPkgLocaleTable::addLine ( zypp::sat::LocaleSupport l,
const std::vector <std::string> & cols, std::string status )
87 YTableItem *tabItem =
new YTableItem();
93 for (
const std::string& s: cols )
103 std::string NCPkgLocaleTable::status( zypp::Locale lang )
107 if ( zypp::getZYpp()->pool().isRequestedLocale( lang ) )
125 void NCPkgLocaleTable::fillLocaleList()
127 std::vector <std::string> oneLine;
129 const zypp::LocaleSet & available_locales( zypp::ResPool::instance().getAvailableLocales() );
130 for_( it, available_locales.begin(), available_locales.end() )
133 zypp::sat::LocaleSupport myLocale( *it );
134 oneLine.push_back( myLocale.locale().code() );
135 oneLine.push_back( myLocale.locale().name() );
136 addLine( myLocale, oneLine, status(*it) );
145 NCTableLine *line = myPad()->ModifyLine( index );
151 YTableItem *it =
dynamic_cast<YTableItem*
> (line->origItem() );
153 YTableCell *tcell = it->cell(0);
160 zypp::sat::LocaleSupport NCPkgLocaleTable::getLocale(
int index )
164 return t->getLocale();
168 void NCPkgLocaleTable::showLocalePackages()
170 int index = getCurrentItem();
171 zypp::sat::LocaleSupport myLocale = getLocale( index );
173 NCPkgTable * packageList = packager->PackageList();
176 yuiMilestone() <<
"Packages supporting locale '" << myLocale.locale() <<
"':" << endl;
177 for_( it, myLocale.selectableBegin(), myLocale.selectableEnd() )
179 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
183 std::ostringstream s;
185 s << boost::format( _(
"Translations, dictionaries and other language-related files for <b>%s</b> locale" )) % myLocale.locale().code();
186 packager->FilterDescription()->setText( s.str() );
188 packageList->scrollToFirstItem();
194 void NCPkgLocaleTable::cycleStatus()
196 int index = getCurrentItem();
197 zypp::sat::LocaleSupport myLocale = getLocale( index );
199 NCTableLine *line = myPad()->ModifyLine( index );
204 yuiMilestone() <<
"Toggle status of: " << myLocale.locale().code() << endl;
206 if ( zypp::getZYpp()->pool().isRequestedLocale( myLocale.locale() ) )
208 zypp::getZYpp()->pool().eraseRequestedLocale( myLocale.locale() );
212 zypp::getZYpp()->pool().addRequestedLocale( myLocale.locale() );
216 NCTableCol * cell = line->GetCol( 0 );
217 cell->SetLabel( NCstring( status( myLocale.locale() ) ) );
221 NCursesEvent NCPkgLocaleTable::wHandleInput( wint_t ch )
223 NCursesEvent ret = NCursesEvent::none;
234 ret = NCursesEvent::handled;
235 showLocalePackages();
240 ret = NCursesEvent::handled;
242 showLocalePackages();
246 ret = NCTable::wHandleInput( ch );