From 0cd6b8264c5d78dee7889748886c00971b562860 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Tue, 27 Jul 2010 21:26:02 +0200 Subject: [PATCH] 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. --- src/gmenu2x.cpp | 10 +++++----- src/linkapp.cpp | 4 ++++ src/linkapp.h | 14 +++++++++----- src/menu.cpp | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 00bfddc..507fc9b 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -1404,7 +1404,7 @@ void GMenu2X::editLink() { if (menu->selLinkApp()==NULL) return; vector pathV; - split(pathV,menu->selLinkApp()->file,"/"); + split(pathV,menu->selLinkApp()->getFile(),"/"); string oldSection = ""; if (pathV.size()>1) 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 MenuSettingFile(this,tr["Selector Aliases"],tr["File containing a list of aliases for the selector"],&linkSelAliases)); //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["Don't Leave"],tr["Don't quit GMenu2X when launching this link"],&menu->selLinkApp()->dontleave)); + 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()->runsInBackgroundRef())); if (sd.exec() && sd.edited()) { ledOn(); @@ -1484,8 +1484,8 @@ void GMenu2X::editLink() { newFileName = "sections/"+newSection+"/"+linkTitle+id; x++; } - rename(menu->selLinkApp()->file.c_str(),newFileName.c_str()); - menu->selLinkApp()->file = newFileName; + rename(menu->selLinkApp()->getFile().c_str(),newFileName.c_str()); + menu->selLinkApp()->renameFile(newFileName); #ifdef DEBUG cout << "New section index: " << newSectionIndex - menu->getSections().begin() << endl; #endif diff --git a/src/linkapp.cpp b/src/linkapp.cpp index 9f68854..290c3f0 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -575,3 +575,7 @@ void LinkApp::setAliasFile(const string &aliasfile) { edited = true; } } + +void LinkApp::renameFile(const string &name) { + file = name; +} diff --git a/src/linkapp.h b/src/linkapp.h index fe67731..1b57760 100644 --- a/src/linkapp.h +++ b/src/linkapp.h @@ -49,6 +49,10 @@ private: void drawRun(); string aliasfile; + string file; + + bool wrapper; + bool dontleave; public: LinkApp(GMenu2X *gmenu2x, const char* linkfile); @@ -75,8 +79,6 @@ public: const string &getAliasFile(); void setAliasFile(const string &aliasfile); - string file; - int clock(); const string &clockStr(int maxClock); void setClock(int mhz); @@ -95,15 +97,17 @@ public: void setBacklight(int val); // /G - bool wrapper; - bool dontleave; - bool save(); void run(); void showManual(); void selector(int startSelection=0, const string &selectorDir=""); void launch(const string &selectedFile="", const string &selectedDir=""); bool targetExists(); + + const string &getFile() { return file; } + void renameFile(const string &name); + bool &needsWrapperRef() { return wrapper; } + bool &runsInBackgroundRef() { return dontleave; } }; #endif diff --git a/src/menu.cpp b/src/menu.cpp index 6d560ae..5d42a7d 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -299,7 +299,7 @@ void Menu::deleteSelectedLink() { cout << "\033[0;34mGMENU2X:\033[0m Deleting link " << selLink()->getTitle() << endl; #endif if (selLinkApp()!=NULL) - unlink(selLinkApp()->file.c_str()); + unlink(selLinkApp()->getFile().c_str()); gmenu2x->sc.del(selLink()->getIconPath()); sectionLinks()->erase( sectionLinks()->begin() + selLinkIndex() ); setLinkIndex(selLinkIndex());