Neutrino: rework COnOffNotifier and use it if possible, ported from tuxbox cvs

Origin commit data
------------------
Branch: ni/coolstream
Commit: 7b06b3fd38
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2012-10-11 (Thu, 11 Oct 2012)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Jacek Jendrzej
2012-10-11 14:11:05 +02:00
parent 6e29073d35
commit 4c8475e5ba
7 changed files with 28 additions and 87 deletions

View File

@@ -282,7 +282,9 @@ void CMiscMenue::showMiscSettingsMenuEnergy(CMenuWidget *ms_energy)
CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_shutdown_count); CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_shutdown_count);
m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT); m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT);
miscNotifier = new CMiscNotifier( m1, m2 ); miscNotifier = new COnOffNotifier(1);
miscNotifier->addItem(m1);
miscNotifier->addItem(m2);
CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL, &g_settings.shutdown_real, OPTIONS_OFF1_ON0_OPTIONS, OPTIONS_OFF1_ON0_OPTION_COUNT, true, miscNotifier); CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL, &g_settings.shutdown_real, OPTIONS_OFF1_ON0_OPTIONS, OPTIONS_OFF1_ON0_OPTION_COUNT, true, miscNotifier);
mc->setHint("", LOCALE_MENU_HINT_SHUTDOWN_REAL); mc->setHint("", LOCALE_MENU_HINT_SHUTDOWN_REAL);

View File

@@ -40,7 +40,7 @@ class CMiscMenue : public CMenuTarget
private: private:
CFanControlNotifier *fanNotifier; CFanControlNotifier *fanNotifier;
CSectionsdConfigNotifier* sectionsdConfigNotifier; CSectionsdConfigNotifier* sectionsdConfigNotifier;
CMiscNotifier* miscNotifier; COnOffNotifier* miscNotifier;
int width; int width;

View File

@@ -2977,7 +2977,8 @@ bool CMovieBrowser::showMenu(MI_MOVIE_INFO* /*movie_info*/)
{ {
dirInput[i] = new CFileChooser(&m_settings.storageDir[i]); dirInput[i] = new CFileChooser(&m_settings.storageDir[i]);
forwarder[i] = new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.storageDirUsed[i], m_settings.storageDir[i], dirInput[i]); forwarder[i] = new CMenuForwarder(LOCALE_MOVIEBROWSER_DIR, m_settings.storageDirUsed[i], m_settings.storageDir[i], dirInput[i]);
notifier[i] = new COnOffNotifier(forwarder[i]); notifier[i] = new COnOffNotifier();
notifier[i]->addItem(forwarder[i]);
chooser[i] = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR , &m_settings.storageDirUsed[i] , MESSAGEBOX_YES_NO_OPTIONS, MESSAGEBOX_YES_NO_OPTIONS_COUNT, true,notifier[i]); chooser[i] = new CMenuOptionChooser(LOCALE_MOVIEBROWSER_USE_DIR , &m_settings.storageDirUsed[i] , MESSAGEBOX_YES_NO_OPTIONS, MESSAGEBOX_YES_NO_OPTIONS_COUNT, true,notifier[i]);
optionsMenuDir.addItem(chooser[i] ); optionsMenuDir.addItem(chooser[i] );
optionsMenuDir.addItem(forwarder[i] ); optionsMenuDir.addItem(forwarder[i] );

View File

@@ -51,37 +51,9 @@
#include <pthread.h> #include <pthread.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <unistd.h> #include <unistd.h>
#include <neutrino.h>
#include <zapit/client/zapittools.h> #include <zapit/client/zapittools.h>
class CNFSMountGuiNotifier : public CChangeObserver
{
private:
CMenuForwarder *m_opt1,*m_opt2, *m_user, *m_pass;
int *m_type;
public:
CNFSMountGuiNotifier( CMenuForwarder* a3, CMenuForwarder* a4 , int* type)
{
m_user = a3;
m_pass = a4;
m_type = type;
}
bool changeNotify(const neutrino_locale_t /*OptionName*/, void *)
{
if(*m_type == (int)CFSMounter::NFS)
{
m_user->setActive (false);
m_pass->setActive (false);
}
else
{
m_user->setActive (true);
m_pass->setActive (true);
}
return true;
}
};
CNFSMountGui::CNFSMountGui() CNFSMountGui::CNFSMountGui()
{ {
// FIXME #warning move probing from exec() to fsmounter // FIXME #warning move probing from exec() to fsmounter
@@ -266,7 +238,9 @@ int CNFSMountGui::menuEntry(int nr)
CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput); CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput);
CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL, this, cmd); CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, true, NULL, this, cmd);
mountnow_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); mountnow_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
CNFSMountGuiNotifier notifier(username_fwd, password_fwd, type); COnOffNotifier notifier(CFSMounter::NFS);
notifier.addItem(username_fwd);
notifier.addItem(password_fwd);
mountMenuEntryW.addItem(new CMenuOptionChooser(LOCALE_NFS_TYPE, type, NFS_TYPE_OPTIONS, NFS_TYPE_OPTION_COUNT, typeEnabled, &notifier)); mountMenuEntryW.addItem(new CMenuOptionChooser(LOCALE_NFS_TYPE, type, NFS_TYPE_OPTIONS, NFS_TYPE_OPTION_COUNT, typeEnabled, &notifier));
mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_IP , true, g_settings.network_nfs_ip[nr], &ipInput )); mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_IP , true, g_settings.network_nfs_ip[nr], &ipInput ));

View File

@@ -90,15 +90,4 @@ class COsdSetup : public CMenuTarget, public CChangeObserver
int showContextChanlistMenu(); int showContextChanlistMenu();
}; };
class COsdSetupChannelLogoNotifier : public CChangeObserver
{
private:
CMenuForwarder* toDisable1;
CMenuOptionChooser* toDisable2;
public:
COsdSetupChannelLogoNotifier( CMenuForwarder*, CMenuOptionChooser* );
bool changeNotify(const neutrino_locale_t, void * Data);
};
#endif #endif

View File

@@ -88,43 +88,24 @@ extern cDemux *pcrDemux;
extern "C" int pinghost( const char *hostname ); extern "C" int pinghost( const char *hostname );
// gui/moviebrowser.cpp COnOffNotifier::COnOffNotifier(int OffValue)
COnOffNotifier::COnOffNotifier( CMenuItem* a1,CMenuItem* a2,CMenuItem* a3,CMenuItem* a4,CMenuItem* a5)
{ {
number = 0; offValue = OffValue;
if(a1 != NULL){ toDisable[0] =a1;number++;};
if(a2 != NULL){ toDisable[1] =a2;number++;};
if(a3 != NULL){ toDisable[2] =a3;number++;};
if(a4 != NULL){ toDisable[3] =a4;number++;};
if(a5 != NULL){ toDisable[4] =a5;number++;};
} }
bool COnOffNotifier::changeNotify(const neutrino_locale_t, void *Data) bool COnOffNotifier::changeNotify(const neutrino_locale_t, void *Data)
{ {
if(*(int*)(Data) == 0) bool active = (*(int*)(Data) != offValue);
{
for (int i=0; i<number ; i++) for (std::vector<CMenuItem*>::iterator it = toDisable.begin(); it != toDisable.end(); it++)
toDisable[i]->setActive(false); (*it)->setActive(active);
}
else
{
for (int i=0; i<number ; i++)
toDisable[i]->setActive(true);
}
return false; return false;
} }
//used in gui/miscsettings_menu.cpp void COnOffNotifier::addItem(CMenuItem* menuItem)
CMiscNotifier::CMiscNotifier( CMenuItem* i1, CMenuItem* i2)
{ {
toDisable[0]=i1; toDisable.push_back(menuItem);
toDisable[1]=i2;
}
bool CMiscNotifier::changeNotify(const neutrino_locale_t, void *)
{
toDisable[0]->setActive(!g_settings.shutdown_real);
toDisable[1]->setActive(!g_settings.shutdown_real);
return false;
} }
bool CSectionsdConfigNotifier::changeNotify(const neutrino_locale_t, void *) bool CSectionsdConfigNotifier::changeNotify(const neutrino_locale_t, void *)

View File

@@ -57,20 +57,14 @@ class CGenericMenuActivate
class COnOffNotifier : public CChangeObserver class COnOffNotifier : public CChangeObserver
{ {
private: private:
int number; int offValue;
CMenuItem* toDisable[5]; std::vector<CMenuItem*> toDisable;
public:
COnOffNotifier (CMenuItem* a1,CMenuItem* a2 = NULL,CMenuItem* a3 = NULL,CMenuItem* a4 = NULL,CMenuItem* a5 = NULL);
bool changeNotify(const neutrino_locale_t, void *Data);
};
class CMiscNotifier : public CChangeObserver
{
private:
CMenuItem* toDisable[2];
public: public:
CMiscNotifier( CMenuItem*, CMenuItem* ); COnOffNotifier(int OffValue = 0);
bool changeNotify(const neutrino_locale_t, void *); bool changeNotify(const neutrino_locale_t, void *Data);
void addItem(CMenuItem* menuItem);
}; };
class CSectionsdConfigNotifier : public CChangeObserver class CSectionsdConfigNotifier : public CChangeObserver