Date: | 2014-08-11 01:11:13 (9 years 7 months ago) |
---|---|
Author: | Nebuleon Fumika |
Commit: | d6b2643610a5dc847def9b48200d1786903edfe8 |
Message: | Remove unnecessary file existence check in GMenu2X::setSkin(2) The existence of modifications to the skin configuration in the home directory is now checked with ifstream::is_open, and the system's skin configuration is used if that returns false. |
Files: |
src/gmenu2x.cpp (2 diffs) src/gmenu2x.h (1 diff) |
Change Details
src/gmenu2x.cpp | ||
---|---|---|
783 | 783 | |
784 | 784 | /* Load skin settings from user directory if present, |
785 | 785 | * or from the system directory. */ |
786 | string skinconfname = getHome() + "/skins/" + skin + "/skin.conf"; | |
787 | if (!fileExists(skinconfname)) | |
788 | skinconfname = GMENU2X_SYSTEM_DIR "/skins/" + skin + "/skin.conf"; | |
789 | ||
790 | if (fileExists(skinconfname)) { | |
791 | ifstream skinconf(skinconfname.c_str(), ios_base::in); | |
792 | if (skinconf.is_open()) { | |
793 | string line; | |
794 | while (getline(skinconf, line, '\n')) { | |
795 | line = trim(line); | |
796 | DEBUG("skinconf: '%s'\n", line.c_str()); | |
797 | string::size_type pos = line.find("="); | |
798 | string name = trim(line.substr(0,pos)); | |
799 | string value = trim(line.substr(pos+1,line.length())); | |
800 | ||
801 | if (value.length()>0) { | |
802 | if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"') | |
803 | skinConfStr[name] = value.substr(1,value.length()-2); | |
804 | else if (value.at(0) == '#') | |
805 | skinConfColors[stringToColor(name)] = | |
806 | RGBAColor::fromString(value.substr(1, value.length())); | |
807 | else | |
808 | skinConfInt[name] = atoi(value.c_str()); | |
809 | } | |
810 | } | |
811 | skinconf.close(); | |
786 | if (!readSkinConfig(getHome() + "/skins/" + skin + "/skin.conf")) { | |
787 | readSkinConfig(GMENU2X_SYSTEM_DIR "/skins/" + skin + "/skin.conf"); | |
788 | } | |
812 | 789 | |
813 | if (setWallpaper && !skinConfStr["wallpaper"].empty()) { | |
814 | string fp = sc.getSkinFilePath("wallpapers/" + skinConfStr["wallpaper"]); | |
815 | if (!fp.empty()) | |
816 | confStr["wallpaper"] = fp; | |
817 | else | |
818 | WARNING("Unable to find wallpaper defined on skin %s\n", skin.c_str()); | |
819 | } | |
820 | } | |
790 | if (setWallpaper && !skinConfStr["wallpaper"].empty()) { | |
791 | string fp = sc.getSkinFilePath("wallpapers/" + skinConfStr["wallpaper"]); | |
792 | if (!fp.empty()) | |
793 | confStr["wallpaper"] = fp; | |
794 | else | |
795 | WARNING("Unable to find wallpaper defined on skin %s\n", skin.c_str()); | |
821 | 796 | } |
822 | 797 | |
823 | 798 | evalIntConf(skinConfInt, "topBarHeight", 50, 32, 120); |
... | ... | |
834 | 809 | initFont(); |
835 | 810 | } |
836 | 811 | |
812 | bool GMenu2X::readSkinConfig(const string& conffile) | |
813 | { | |
814 | ifstream skinconf(conffile.c_str(), ios_base::in); | |
815 | if (skinconf.is_open()) { | |
816 | string line; | |
817 | while (getline(skinconf, line, '\n')) { | |
818 | line = trim(line); | |
819 | DEBUG("skinconf: '%s'\n", line.c_str()); | |
820 | string::size_type pos = line.find("="); | |
821 | string name = trim(line.substr(0,pos)); | |
822 | string value = trim(line.substr(pos+1,line.length())); | |
823 | ||
824 | if (value.length()>0) { | |
825 | if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"') | |
826 | skinConfStr[name] = value.substr(1,value.length()-2); | |
827 | else if (value.at(0) == '#') | |
828 | skinConfColors[stringToColor(name)] = | |
829 | RGBAColor::fromString(value.substr(1, value.length())); | |
830 | else | |
831 | skinConfInt[name] = atoi(value.c_str()); | |
832 | } | |
833 | } | |
834 | skinconf.close(); | |
835 | return true; | |
836 | } else { | |
837 | return false; | |
838 | } | |
839 | } | |
840 | ||
837 | 841 | void GMenu2X::showManual() { |
838 | 842 | menu->selLinkApp()->showManual(); |
839 | 843 | } |
src/gmenu2x.h | ||
---|---|---|
154 | 154 | //Configuration settings |
155 | 155 | bool useSelectionPng; |
156 | 156 | void setSkin(const std::string &skin, bool setWallpaper = true); |
157 | bool readSkinConfig(const std::string& conffile); | |
157 | 158 | |
158 | 159 | SurfaceCollection sc; |
159 | 160 | Translator tr; |
Branches:
install_locations
master
opkrun
packages