1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-29 09:59:41 +02:00

Converted public fields of LinkApp to private.

Although exposing a read/write reference to a private field is not much better than having a public field.
Well, at least we are explicit about the nasty stuff now.
This commit is contained in:
Maarten ter Huurne 2010-07-27 21:26:02 +02:00
parent 8a9aac028b
commit 0cd6b8264c
4 changed files with 19 additions and 11 deletions

View File

@ -1404,7 +1404,7 @@ void GMenu2X::editLink() {
if (menu->selLinkApp()==NULL) return; if (menu->selLinkApp()==NULL) return;
vector<string> pathV; vector<string> pathV;
split(pathV,menu->selLinkApp()->file,"/"); split(pathV,menu->selLinkApp()->getFile(),"/");
string oldSection = ""; string oldSection = "";
if (pathV.size()>1) if (pathV.size()>1)
oldSection = pathV[pathV.size()-2]; oldSection = pathV[pathV.size()-2];
@ -1447,8 +1447,8 @@ void GMenu2X::editLink() {
sd.addSetting(new MenuSettingDir(this,tr["Selector Screenshots"],tr["Directory of the screenshots for the selector"],&linkSelScreens)); sd.addSetting(new MenuSettingDir(this,tr["Selector Screenshots"],tr["Directory of the screenshots for the selector"],&linkSelScreens));
sd.addSetting(new MenuSettingFile(this,tr["Selector Aliases"],tr["File containing a list of aliases for the selector"],&linkSelAliases)); sd.addSetting(new MenuSettingFile(this,tr["Selector Aliases"],tr["File containing a list of aliases for the selector"],&linkSelAliases));
//G //G
sd.addSetting(new MenuSettingBool(this,tr["Wrapper"],tr["Explicitly relaunch GMenu2X after this link's execution ends"],&menu->selLinkApp()->wrapper)); sd.addSetting(new MenuSettingBool(this,tr["Wrapper"],tr["Explicitly relaunch GMenu2X after this link's execution ends"],&menu->selLinkApp()->needsWrapperRef()));
sd.addSetting(new MenuSettingBool(this,tr["Don't Leave"],tr["Don't quit GMenu2X when launching this link"],&menu->selLinkApp()->dontleave)); sd.addSetting(new MenuSettingBool(this,tr["Don't Leave"],tr["Don't quit GMenu2X when launching this link"],&menu->selLinkApp()->runsInBackgroundRef()));
if (sd.exec() && sd.edited()) { if (sd.exec() && sd.edited()) {
ledOn(); ledOn();
@ -1484,8 +1484,8 @@ void GMenu2X::editLink() {
newFileName = "sections/"+newSection+"/"+linkTitle+id; newFileName = "sections/"+newSection+"/"+linkTitle+id;
x++; x++;
} }
rename(menu->selLinkApp()->file.c_str(),newFileName.c_str()); rename(menu->selLinkApp()->getFile().c_str(),newFileName.c_str());
menu->selLinkApp()->file = newFileName; menu->selLinkApp()->renameFile(newFileName);
#ifdef DEBUG #ifdef DEBUG
cout << "New section index: " << newSectionIndex - menu->getSections().begin() << endl; cout << "New section index: " << newSectionIndex - menu->getSections().begin() << endl;
#endif #endif

View File

@ -575,3 +575,7 @@ void LinkApp::setAliasFile(const string &aliasfile) {
edited = true; edited = true;
} }
} }
void LinkApp::renameFile(const string &name) {
file = name;
}

View File

@ -49,6 +49,10 @@ private:
void drawRun(); void drawRun();
string aliasfile; string aliasfile;
string file;
bool wrapper;
bool dontleave;
public: public:
LinkApp(GMenu2X *gmenu2x, const char* linkfile); LinkApp(GMenu2X *gmenu2x, const char* linkfile);
@ -75,8 +79,6 @@ public:
const string &getAliasFile(); const string &getAliasFile();
void setAliasFile(const string &aliasfile); void setAliasFile(const string &aliasfile);
string file;
int clock(); int clock();
const string &clockStr(int maxClock); const string &clockStr(int maxClock);
void setClock(int mhz); void setClock(int mhz);
@ -95,15 +97,17 @@ public:
void setBacklight(int val); void setBacklight(int val);
// /G // /G
bool wrapper;
bool dontleave;
bool save(); bool save();
void run(); void run();
void showManual(); void showManual();
void selector(int startSelection=0, const string &selectorDir=""); void selector(int startSelection=0, const string &selectorDir="");
void launch(const string &selectedFile="", const string &selectedDir=""); void launch(const string &selectedFile="", const string &selectedDir="");
bool targetExists(); bool targetExists();
const string &getFile() { return file; }
void renameFile(const string &name);
bool &needsWrapperRef() { return wrapper; }
bool &runsInBackgroundRef() { return dontleave; }
}; };
#endif #endif

View File

@ -299,7 +299,7 @@ void Menu::deleteSelectedLink() {
cout << "\033[0;34mGMENU2X:\033[0m Deleting link " << selLink()->getTitle() << endl; cout << "\033[0;34mGMENU2X:\033[0m Deleting link " << selLink()->getTitle() << endl;
#endif #endif
if (selLinkApp()!=NULL) if (selLinkApp()!=NULL)
unlink(selLinkApp()->file.c_str()); unlink(selLinkApp()->getFile().c_str());
gmenu2x->sc.del(selLink()->getIconPath()); gmenu2x->sc.del(selLink()->getIconPath());
sectionLinks()->erase( sectionLinks()->begin() + selLinkIndex() ); sectionLinks()->erase( sectionLinks()->begin() + selLinkIndex() );
setLinkIndex(selLinkIndex()); setLinkIndex(selLinkIndex());