Date: | 2011-10-23 16:43:56 (12 years 5 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | a01d892eb6df439d463c405750d3cce4c4d4b9ad |
Message: | More header cleanups. This time the focus was on removing namespace imports from headers. |
Files: |
src/browsedialog.cpp (1 diff) src/button.h (3 diffs) src/filedialog.h (2 diffs) src/filelister.cpp (3 diffs) src/filelister.h (2 diffs) src/gmenu2x.cpp (3 diffs) src/gmenu2x.h (12 diffs) src/imagedialog.h (1 diff) src/link.h (3 diffs) src/linkaction.cpp (2 diffs) src/linkaction.h (3 diffs) src/linkapp.h (2 diffs) src/menu.cpp (5 diffs) src/menu.h (5 diffs) src/menusetting.cpp (2 diffs) src/selector.cpp (1 diff) src/selector.h (2 diffs) src/surface.cpp (2 diffs) src/surface.h (4 diffs) src/translator.cpp (2 diffs) src/translator.h (3 diffs) src/utilities.h (1 diff) |
Change Details
src/browsedialog.cpp | ||
---|---|---|
7 | 7 | #include <string> |
8 | 8 | |
9 | 9 | using namespace fastdelegate; |
10 | using std::string; | |
10 | 11 | |
11 | 12 | BrowseDialog::BrowseDialog(GMenu2X *gmenu2x, const string &title, |
12 | 13 | const string &subtitle) |
src/button.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | 20 | |
21 | #ifndef BUTTON_H_ | |
22 | #define BUTTON_H_ | |
21 | #ifndef BUTTON_H | |
22 | #define BUTTON_H | |
23 | 23 | |
24 | #include <string> | |
25 | #include <SDL.h> | |
26 | 24 | #include "FastDelegate.h" |
27 | 25 | |
28 | using std::string; | |
29 | using fastdelegate::FastDelegate0; | |
26 | #include <SDL.h> | |
30 | 27 | |
31 | typedef FastDelegate0<> ButtonAction; | |
28 | typedef fastdelegate::FastDelegate0<> ButtonAction; | |
32 | 29 | class Touchscreen; |
33 | 30 | |
34 | 31 | class Button { |
... | ... | |
61 | 58 | void setAction(ButtonAction action); |
62 | 59 | }; |
63 | 60 | |
64 | #endif /*BUTTON_H_*/ | |
61 | #endif // BUTTON_H |
src/filedialog.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | 20 | |
21 | #ifndef FILEDIALOG_H_ | |
22 | #define FILEDIALOG_H_ | |
23 | ||
24 | #include <string> | |
21 | #ifndef FILEDIALOG_H | |
22 | #define FILEDIALOG_H | |
25 | 23 | |
26 | 24 | #include "browsedialog.h" |
27 | 25 | |
26 | #include <string> | |
28 | 27 | |
29 | 28 | class FileDialog : public BrowseDialog { |
30 | 29 | public: |
31 | FileDialog(GMenu2X *gmenu2x, const string &text, const string &filter="", | |
32 | const string &file="", const string &title = "File Dialog"); | |
30 | FileDialog(GMenu2X *gmenu2x, const std::string &text, | |
31 | const std::string &filter="", const std::string &file="", | |
32 | const std::string &title = "File Dialog"); | |
33 | 33 | virtual ~FileDialog(); |
34 | 34 | bool exec(); |
35 | 35 | }; |
36 | 36 | |
37 | #endif /*INPUTDIALOG_H_*/ | |
37 | #endif // FILEDIALOG_H |
src/filelister.cpp | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | 20 | |
21 | #include "filelister.h" | |
22 | ||
23 | #include "debug.h" | |
24 | #include "utilities.h" | |
25 | ||
21 | 26 | //for browsing the filesystem |
22 | 27 | #include <sys/stat.h> |
23 | 28 | #include <sys/types.h> |
... | ... | |
27 | 32 | #include <algorithm> |
28 | 33 | #include <cstring> |
29 | 34 | |
30 | #include "filelister.h" | |
31 | #include "utilities.h" | |
32 | #include "debug.h" | |
33 | ||
34 | 35 | using namespace std; |
35 | 36 | |
36 | 37 | FileLister::FileLister(const string &startPath, bool showDirectories, |
src/filelister.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | 20 | |
21 | #ifndef FILELISTER_H_ | |
22 | #define FILELISTER_H_ | |
21 | #ifndef FILELISTER_H | |
22 | #define FILELISTER_H | |
23 | 23 | |
24 | 24 | #include <string> |
25 | 25 | #include <vector> |
26 | 26 | |
27 | using std::string; | |
28 | using std::vector; | |
29 | ||
30 | 27 | class FileLister { |
31 | 28 | private: |
32 | string path, filter; | |
29 | std::string path, filter; | |
33 | 30 | bool showDirectories, showFiles; |
34 | 31 | |
35 | vector<string> directories, files, excludes; | |
32 | std::vector<std::string> directories, files, excludes; | |
36 | 33 | |
37 | 34 | public: |
38 | FileLister(const string &startPath = "/boot/local", bool showDirectories = true, bool showFiles = true); | |
35 | FileLister(const std::string &startPath = "/boot/local", bool showDirectories = true, bool showFiles = true); | |
39 | 36 | void browse(bool clean = true); |
40 | 37 | |
41 | 38 | unsigned int size(); |
42 | 39 | unsigned int dirCount(); |
43 | 40 | unsigned int fileCount(); |
44 | string operator[](unsigned int); | |
45 | string at(unsigned int); | |
41 | std::string operator[](unsigned int); | |
42 | std::string at(unsigned int); | |
46 | 43 | bool isFile(unsigned int); |
47 | 44 | bool isDirectory(unsigned int); |
48 | 45 | |
49 | const string &getPath(); | |
50 | void setPath(const string &path, bool doBrowse=true); | |
51 | const string &getFilter(); | |
52 | void setFilter(const string &filter); | |
46 | const std::string &getPath(); | |
47 | void setPath(const std::string &path, bool doBrowse=true); | |
48 | const std::string &getFilter(); | |
49 | void setFilter(const std::string &filter); | |
53 | 50 | |
54 | const vector<string> &getDirectories() { return directories; } | |
55 | const vector<string> &getFiles() { return files; } | |
56 | void insertFile(const string &file); | |
57 | void addExclude(const string &exclude); | |
51 | const std::vector<std::string> &getDirectories() { return directories; } | |
52 | const std::vector<std::string> &getFiles() { return files; } | |
53 | void insertFile(const std::string &file); | |
54 | void addExclude(const std::string &exclude); | |
58 | 55 | }; |
59 | 56 | |
60 | #endif /*FILELISTER_H_*/ | |
57 | #endif // FILELISTER_H |
src/gmenu2x.cpp | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
86 | 86 | //#include <pnd_discovery.h> |
87 | 87 | #endif |
88 | 88 | |
89 | using namespace std; | |
90 | using namespace fastdelegate; | |
91 | ||
89 | 92 | #ifdef _CARD_ROOT |
90 | 93 | const char *CARD_ROOT = _CARD_ROOT; |
91 | 94 | #elif defined(PLATFORM_DINGUX) |
... | ... | |
98 | 101 | static GMenu2X *app; |
99 | 102 | static string gmenu2x_home; |
100 | 103 | |
101 | using namespace std; | |
102 | using namespace fastdelegate; | |
103 | ||
104 | 104 | // Note: Keep this in sync with the enum! |
105 | 105 | static const char *colorNames[NUM_COLORS] = { |
106 | 106 | "topBarBg", |
src/gmenu2x.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
73 | 73 | NUM_COLORS, |
74 | 74 | }; |
75 | 75 | |
76 | using std::string; | |
77 | using std::vector; | |
78 | using fastdelegate::FastDelegate0; | |
79 | ||
80 | typedef FastDelegate0<> MenuAction; | |
81 | typedef unordered_map<string, string, hash<string> > ConfStrHash; | |
82 | typedef unordered_map<string, int, hash<string> > ConfIntHash; | |
76 | typedef fastdelegate::FastDelegate0<> MenuAction; | |
77 | typedef std::tr1::unordered_map<std::string, std::string, std::tr1::hash<std::string> > ConfStrHash; | |
78 | typedef std::tr1::unordered_map<std::string, int, std::tr1::hash<std::string> > ConfIntHash; | |
83 | 79 | |
84 | 80 | typedef struct { |
85 | 81 | unsigned short batt; |
... | ... | |
87 | 83 | } MMSP2ADC; |
88 | 84 | |
89 | 85 | struct MenuOption { |
90 | string text; | |
86 | std::string text; | |
91 | 87 | MenuAction action; |
92 | 88 | }; |
93 | 89 | |
... | ... | |
95 | 91 | |
96 | 92 | class GMenu2X { |
97 | 93 | private: |
98 | string path; //!< Contains the working directory of GMenu2X | |
94 | std::string path; //!< Contains the working directory of GMenu2X | |
99 | 95 | /*! |
100 | 96 | Retrieves the free disk space on the sd |
101 | 97 | @return String containing a human readable representation of the free disk space |
102 | 98 | */ |
103 | string getDiskFree(const char *path); | |
99 | std::string getDiskFree(const char *path); | |
104 | 100 | unsigned short cpuX; //!< Offset for displaying cpu clock information |
105 | 101 | unsigned short volumeX; //!< Offset for displaying volume level |
106 | 102 | unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar |
... | ... | |
116 | 112 | */ |
117 | 113 | unsigned short getBatteryLevel(); |
118 | 114 | FILE* batteryHandle, *backlightHandle, *usbHandle, *acHandle; |
119 | void browsePath(const string &path, vector<string>* directories, vector<string>* files); | |
115 | void browsePath(const std::string &path, std::vector<std::string>* directories, std::vector<std::string>* files); | |
120 | 116 | /*! |
121 | 117 | Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections. |
122 | 118 | */ |
... | ... | |
125 | 121 | Performs the actual scan in the given path and populates the files vector with the results. The creation of the links is not performed here. |
126 | 122 | @see scanner |
127 | 123 | */ |
128 | void scanPath(string path, vector<string> *files); | |
124 | void scanPath(std::string path, std::vector<std::string> *files); | |
129 | 125 | |
130 | 126 | /*! |
131 | 127 | Displays a selector and launches the specified executable file |
... | ... | |
137 | 133 | samba, |
138 | 134 | web; |
139 | 135 | |
140 | string ip, defaultgw, lastSelectorDir; | |
136 | std::string ip, defaultgw, lastSelectorDir; | |
141 | 137 | int lastSelectorElement; |
142 | 138 | void readConfig(); |
143 | void readConfig(string path); | |
139 | void readConfig(std::string path); | |
144 | 140 | void readTmp(); |
145 | 141 | |
146 | 142 | void initServices(); |
... | ... | |
174 | 170 | |
175 | 171 | /* Returns the home directory of gmenu2x, usually |
176 | 172 | * ~/.gmenu2x */ |
177 | static const string getHome(void); | |
173 | static const std::string getHome(void); | |
178 | 174 | |
179 | 175 | /* |
180 | 176 | * Variables needed for elements disposition |
... | ... | |
188 | 184 | @see path |
189 | 185 | @return String containing the parent directory |
190 | 186 | */ |
191 | const string &getExePath(); | |
187 | const std::string &getExePath(); | |
192 | 188 | |
193 | 189 | InputManager input; |
194 | 190 | Touchscreen ts; |
... | ... | |
200 | 196 | |
201 | 197 | //Configuration settings |
202 | 198 | bool useSelectionPng; |
203 | void setSkin(const string &skin, bool setWallpaper = true); | |
199 | void setSkin(const std::string &skin, bool setWallpaper = true); | |
204 | 200 | |
205 | 201 | #ifdef PLATFORM_GP2X |
206 | 202 | //firmware type and version |
207 | string fwType, fwVersion; | |
203 | std::string fwType, fwVersion; | |
208 | 204 | |
209 | 205 | bool isF200() { return ts.initialized(); } |
210 | 206 | |
211 | 207 | // Open2x settings --------------------------------------------------------- |
212 | 208 | bool o2x_usb_net_on_boot, o2x_ftp_on_boot, o2x_telnet_on_boot, o2x_gp2xjoy_on_boot, o2x_usb_host_on_boot, o2x_usb_hid_on_boot, o2x_usb_storage_on_boot; |
213 | string o2x_usb_net_ip; | |
209 | std::string o2x_usb_net_ip; | |
214 | 210 | int volumeMode, savedVolumeMode; // just use the const int scale values at top of source |
215 | 211 | #endif |
216 | 212 | |
... | ... | |
262 | 258 | void writeConfigOpen2x(); |
263 | 259 | #endif |
264 | 260 | void writeSkinConfig(); |
265 | void writeTmp(int selelem=-1, const string &selectordir=""); | |
261 | void writeTmp(int selelem=-1, const std::string &selectordir=""); | |
266 | 262 | |
267 | 263 | void ledOn(); |
268 | 264 | void ledOff(); |
... | ... | |
276 | 272 | |
277 | 273 | void initBG(); |
278 | 274 | int drawButton(Button *btn, int x=5, int y=-10); |
279 | int drawButton(Surface *s, const string &btn, const string &text, int x=5, int y=-10); | |
280 | int drawButtonRight(Surface *s, const string &btn, const string &text, int x=5, int y=-10); | |
275 | int drawButton(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10); | |
276 | int drawButtonRight(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10); | |
281 | 277 | void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height); |
282 | 278 | |
283 | 279 | void drawTopBar(Surface *s=NULL); |
284 | 280 | void drawBottomBar(Surface *s=NULL); |
285 | 281 | |
286 | Menu* menu; | |
282 | Menu *menu; | |
287 | 283 | }; |
288 | 284 | |
289 | #endif | |
285 | #endif // GMENU2X_H |
src/imagedialog.h | ||
---|---|---|
31 | 31 | SurfaceCollection previews; |
32 | 32 | public: |
33 | 33 | ImageDialog(GMenu2X *gmenu2x, const std::string &text, |
34 | const std::string &filter="", const string &file=""); | |
34 | const std::string &filter="", const std::string &file=""); | |
35 | 35 | virtual ~ImageDialog(); |
36 | 36 | |
37 | 37 | virtual void beforeFileList(); |
src/link.h | ||
---|---|---|
24 | 24 | #include "button.h" |
25 | 25 | |
26 | 26 | #include <string> |
27 | #include <iostream> | |
28 | 27 | |
29 | 28 | class Surface; |
30 | 29 | |
31 | using std::string; | |
32 | ||
33 | 30 | class GMenu2X; |
34 | 31 | |
35 | 32 | /** |
... | ... | |
44 | 41 | protected: |
45 | 42 | GMenu2X *gmenu2x; |
46 | 43 | bool edited; |
47 | string title, description, icon, iconPath; | |
44 | std::string title, description, icon, iconPath; | |
48 | 45 | |
49 | 46 | Surface *iconSurface; |
50 | 47 | Surface *icon_hover; |
... | ... | |
62 | 59 | void setSize(int w, int h); |
63 | 60 | void setPosition(int x, int y); |
64 | 61 | |
65 | const string &getTitle(); | |
66 | void setTitle(const string &title); | |
67 | const string &getDescription(); | |
68 | void setDescription(const string &description); | |
69 | const string &getIcon(); | |
70 | void setIcon(const string &icon); | |
71 | virtual const string &searchIcon(); | |
72 | const string &getIconPath(); | |
73 | void setIconPath(const string &icon); | |
62 | const std::string &getTitle(); | |
63 | void setTitle(const std::string &title); | |
64 | const std::string &getDescription(); | |
65 | void setDescription(const std::string &description); | |
66 | const std::string &getIcon(); | |
67 | void setIcon(const std::string &icon); | |
68 | virtual const std::string &searchIcon(); | |
69 | const std::string &getIconPath(); | |
70 | void setIconPath(const std::string &icon); | |
74 | 71 | |
75 | 72 | virtual void run(); |
76 | 73 | }; |
src/linkaction.cpp | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
17 | 17 | * Free Software Foundation, Inc., * |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | #include <fstream> | |
21 | #include <sstream> | |
22 | #include "linkaction.h" | |
23 | 20 | |
24 | using namespace std; | |
21 | #include "linkaction.h" | |
25 | 22 | |
26 | 23 | LinkAction::LinkAction(GMenu2X *gmenu2x, LinkRunAction act) |
27 | 24 | : Link(gmenu2x) { |
src/linkaction.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
17 | 17 | * Free Software Foundation, Inc., * |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | ||
20 | 21 | #ifndef LINKACTION_H |
21 | 22 | #define LINKACTION_H |
22 | 23 | |
23 | #include <string> | |
24 | #include <iostream> | |
25 | ||
26 | 24 | #include "FastDelegate.h" |
27 | 25 | #include "link.h" |
28 | 26 | |
29 | using std::string; | |
30 | using fastdelegate::FastDelegate0; | |
31 | ||
32 | typedef FastDelegate0<> LinkRunAction; | |
27 | typedef fastdelegate::FastDelegate0<> LinkRunAction; | |
33 | 28 | |
34 | 29 | class GMenu2X; |
35 | 30 | |
... | ... | |
47 | 42 | virtual void run(); |
48 | 43 | }; |
49 | 44 | |
50 | #endif | |
45 | #endif // LINKACTION_H |
src/linkapp.h | ||
---|---|---|
24 | 24 | #include "link.h" |
25 | 25 | |
26 | 26 | #include <string> |
27 | #include <iostream> | |
28 | ||
29 | using std::string; | |
30 | 27 | |
31 | 28 | class GMenu2X; |
32 | 29 | class InputManager; |
... | ... | |
39 | 36 | class LinkApp : public Link { |
40 | 37 | private: |
41 | 38 | InputManager &inputMgr; |
42 | string sclock, svolume; | |
39 | std::string sclock, svolume; | |
43 | 40 | int iclock, ivolume; |
44 | 41 | //G |
45 | string sgamma; | |
42 | std::string sgamma; | |
46 | 43 | //G |
47 | 44 | int igamma; |
48 | string exec, params, workdir, manual, selectordir, selectorfilter, selectorscreens; | |
45 | std::string exec, params, workdir, manual, selectordir, selectorfilter, selectorscreens; | |
49 | 46 | bool selectorbrowser, useRamTimings; |
50 | 47 | void drawRun(); |
51 | 48 | |
52 | string aliasfile; | |
53 | string file; | |
49 | std::string aliasfile; | |
50 | std::string file; | |
54 | 51 | |
55 | 52 | bool wrapper; |
56 | 53 | bool dontleave; |
57 | 54 | |
58 | 55 | public: |
59 | 56 | LinkApp(GMenu2X *gmenu2x, InputManager &inputMgr, const char* linkfile); |
60 | virtual const string &searchIcon(); | |
61 | ||
62 | const string &getExec(); | |
63 | void setExec(const string &exec); | |
64 | const string &getParams(); | |
65 | void setParams(const string ¶ms); | |
66 | const string &getWorkdir(); | |
67 | void setWorkdir(const string &workdir); | |
68 | const string &getManual(); | |
69 | void setManual(const string &manual); | |
70 | const string &getSelectorDir(); | |
71 | void setSelectorDir(const string &selectordir); | |
57 | virtual const std::string &searchIcon(); | |
58 | ||
59 | const std::string &getExec(); | |
60 | void setExec(const std::string &exec); | |
61 | const std::string &getParams(); | |
62 | void setParams(const std::string ¶ms); | |
63 | const std::string &getWorkdir(); | |
64 | void setWorkdir(const std::string &workdir); | |
65 | const std::string &getManual(); | |
66 | void setManual(const std::string &manual); | |
67 | const std::string &getSelectorDir(); | |
68 | void setSelectorDir(const std::string &selectordir); | |
72 | 69 | bool getSelectorBrowser(); |
73 | 70 | void setSelectorBrowser(bool value); |
74 | 71 | bool getUseRamTimings(); |
75 | 72 | void setUseRamTimings(bool value); |
76 | const string &getSelectorScreens(); | |
77 | void setSelectorScreens(const string &selectorscreens); | |
78 | const string &getSelectorFilter(); | |
79 | void setSelectorFilter(const string &selectorfilter); | |
80 | const string &getAliasFile(); | |
81 | void setAliasFile(const string &aliasfile); | |
73 | const std::string &getSelectorScreens(); | |
74 | void setSelectorScreens(const std::string &selectorscreens); | |
75 | const std::string &getSelectorFilter(); | |
76 | void setSelectorFilter(const std::string &selectorfilter); | |
77 | const std::string &getAliasFile(); | |
78 | void setAliasFile(const std::string &aliasfile); | |
82 | 79 | |
83 | 80 | int clock(); |
84 | const string &clockStr(int maxClock); | |
81 | const std::string &clockStr(int maxClock); | |
85 | 82 | void setClock(int mhz); |
86 | 83 | |
87 | 84 | int volume(); |
88 | const string &volumeStr(); | |
85 | const std::string &volumeStr(); | |
89 | 86 | void setVolume(int vol); |
90 | 87 | |
91 | 88 | //G |
92 | 89 | int gamma(); |
93 | const string &gammaStr(); | |
90 | const std::string &gammaStr(); | |
94 | 91 | void setGamma(int gamma); |
95 | 92 | |
96 | 93 | bool save(); |
97 | 94 | void run(); |
98 | 95 | void showManual(); |
99 | void selector(int startSelection=0, const string &selectorDir=""); | |
100 | void launch(const string &selectedFile="", const string &selectedDir=""); | |
96 | void selector(int startSelection=0, const std::string &selectorDir=""); | |
97 | void launch(const std::string &selectedFile="", | |
98 | const std::string &selectedDir=""); | |
101 | 99 | bool targetExists(); |
102 | 100 | |
103 | const string &getFile() { return file; } | |
104 | void renameFile(const string &name); | |
101 | const std::string &getFile() { return file; } | |
102 | void renameFile(const std::string &name); | |
105 | 103 | bool &needsWrapperRef() { return wrapper; } |
106 | 104 | bool &runsInBackgroundRef() { return dontleave; } |
107 | 105 | }; |
src/menu.cpp | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
74 | 74 | if (statret != -1) { |
75 | 75 | if (find(sections.begin(), sections.end(), (string)dptr->d_name) == sections.end()) { |
76 | 76 | sections.push_back((string)dptr->d_name); |
77 | linklist ll; | |
77 | vector<Link*> ll; | |
78 | 78 | links.push_back(ll); |
79 | 79 | } |
80 | 80 | } |
... | ... | |
114 | 114 | SECTION MANAGEMENT |
115 | 115 | ====================================*/ |
116 | 116 | void Menu::freeLinks() { |
117 | for (vector<linklist>::iterator section = links.begin(); section<links.end(); section++) | |
118 | for (linklist::iterator link = section->begin(); link<section->end(); link++) | |
117 | for (vector< vector<Link*> >::iterator section = links.begin(); section<links.end(); section++) | |
118 | for (vector<Link*>::iterator link = section->begin(); link<section->end(); link++) | |
119 | 119 | delete *link; |
120 | 120 | } |
121 | 121 | |
122 | linklist *Menu::sectionLinks(int i) { | |
122 | vector<Link*> *Menu::sectionLinks(int i) { | |
123 | 123 | if (i<0 || i>(int)links.size()) |
124 | 124 | i = selSectionIndex(); |
125 | 125 | |
... | ... | |
305 | 305 | sectiondir = sectiondir + "/" + sectionName; |
306 | 306 | if (mkdir(sectiondir.c_str(), 0755) == 0) { |
307 | 307 | sections.push_back(sectionName); |
308 | linklist ll; | |
308 | vector<Link*> ll; | |
309 | 309 | links.push_back(ll); |
310 | 310 | return true; |
311 | 311 | } |
... | ... | |
324 | 324 | sectionLinks()->erase( sectionLinks()->begin() + selLinkIndex() ); |
325 | 325 | setLinkIndex(selLinkIndex()); |
326 | 326 | |
327 | for (vector<linklist>::iterator section = links.begin(); | |
327 | for (vector< vector<Link*> >::iterator section = links.begin(); | |
328 | 328 | !icon_used && section<links.end(); section++) |
329 | for (linklist::iterator link = section->begin(); | |
329 | for (vector<Link*>::iterator link = section->begin(); | |
330 | 330 | !icon_used && link<section->end(); link++) |
331 | 331 | icon_used = !iconpath.compare((*link)->getIconPath()); |
332 | 332 |
src/menu.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
17 | 17 | * Free Software Foundation, Inc., * |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | ||
20 | 21 | #ifndef MENU_H |
21 | 22 | #define MENU_H |
22 | 23 | |
23 | #include <string> | |
24 | #include <vector> | |
25 | 24 | #include "linkaction.h" |
26 | 25 | |
27 | using std::string; | |
28 | using std::vector; | |
26 | #include <string> | |
27 | #include <vector> | |
29 | 28 | |
30 | 29 | class LinkApp; |
31 | 30 | class GMenu2X; |
32 | 31 | |
33 | typedef vector<Link*> linklist; | |
34 | ||
35 | 32 | /** |
36 | 33 | Handles the menu structure |
37 | 34 | |
... | ... | |
42 | 39 | GMenu2X *gmenu2x; |
43 | 40 | int iSection, iLink; |
44 | 41 | uint iFirstDispSection, iFirstDispRow; |
45 | vector<string> sections; | |
46 | vector<linklist> links; | |
42 | std::vector<std::string> sections; | |
43 | std::vector< std::vector<Link*> > links; | |
47 | 44 | |
48 | 45 | void readLinks(); |
49 | 46 | void freeLinks(); |
... | ... | |
58 | 55 | Menu(GMenu2X *gmenu2x); |
59 | 56 | ~Menu(); |
60 | 57 | |
61 | linklist *sectionLinks(int i = -1); | |
58 | std::vector<Link*> *sectionLinks(int i = -1); | |
62 | 59 | |
63 | 60 | int selSectionIndex(); |
64 | const string &selSection(); | |
61 | const std::string &selSection(); | |
65 | 62 | void decSectionIndex(); |
66 | 63 | void incSectionIndex(); |
67 | 64 | void setSectionIndex(int i); |
68 | 65 | uint firstDispSection(); |
69 | 66 | uint firstDispRow(); |
70 | 67 | |
71 | bool addActionLink(uint section, const string &title, LinkRunAction action, const string &description="", const string &icon=""); | |
72 | bool addLink(string path, string file, string section=""); | |
73 | bool addSection(const string §ionName); | |
68 | bool addActionLink(uint section, const std::string &title, | |
69 | LinkRunAction action, const std::string &description="", | |
70 | const std::string &icon=""); | |
71 | bool addLink(std::string path, std::string file, std::string section=""); | |
72 | bool addSection(const std::string §ionName); | |
74 | 73 | void deleteSelectedLink(); |
75 | 74 | void deleteSelectedSection(); |
76 | 75 | |
... | ... | |
86 | 85 | void linkDown(); |
87 | 86 | void setLinkIndex(int i); |
88 | 87 | |
89 | const vector<string> &getSections() { return sections; } | |
90 | void renameSection(int index, const string &name); | |
88 | const std::vector<std::string> &getSections() { return sections; } | |
89 | void renameSection(int index, const std::string &name); | |
91 | 90 | }; |
92 | 91 | |
93 | #endif | |
92 | #endif // MENU_H |
src/menusetting.cpp | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
17 | 17 | * Free Software Foundation, Inc., * |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | ||
20 | 21 | #include "menusetting.h" |
22 | ||
21 | 23 | #include "asfont.h" |
22 | 24 | #include "gmenu2x.h" |
23 | 25 | |
26 | using std::string; | |
27 | ||
24 | 28 | MenuSetting::MenuSetting(GMenu2X *gmenu2x, const string &name, |
25 | 29 | const string &description) |
26 | 30 | : gmenu2x(gmenu2x) |
src/selector.cpp | ||
---|---|---|
35 | 35 | #include "debug.h" |
36 | 36 | |
37 | 37 | using namespace std; |
38 | using std::tr1::unordered_map; | |
38 | 39 | |
39 | 40 | #define SELECTOR_ELEMENTS 11 |
40 | 41 |
src/selector.h | ||
---|---|---|
29 | 29 | class LinkApp; |
30 | 30 | class FileLister; |
31 | 31 | |
32 | using std::string; | |
33 | using std::vector; | |
34 | ||
35 | 32 | class Selector : protected Dialog { |
36 | 33 | private: |
37 | 34 | int selRow; |
... | ... | |
40 | 37 | std::tr1::unordered_map<std::string, std::string> aliases; |
41 | 38 | |
42 | 39 | void loadAliases(); |
43 | string getAlias(const std::string &key); | |
40 | std::string getAlias(const std::string &key); | |
44 | 41 | void prepare(FileLister *fl, std::vector<std::string> *screens, |
45 | 42 | std::vector<std::string> *titles); |
46 | 43 | void freeScreenshots(std::vector<std::string> *screens); |
src/surface.cpp | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
19 | 19 | ***************************************************************************/ |
20 | 20 | |
21 | 21 | #include "surface.h" |
22 | #include "imageio.h" | |
23 | #include "utilities.h" | |
22 | ||
24 | 23 | #include "debug.h" |
24 | #include "imageio.h" | |
25 | 25 | #include "surfacecollection.h" |
26 | #include "utilities.h" | |
26 | 27 | |
27 | 28 | #include <SDL_gfxPrimitives.h> |
28 | 29 | |
29 | 30 | #include <iostream> |
31 | ||
30 | 32 | using namespace std; |
31 | 33 | |
32 | 34 | RGBAColor strtorgba(const string &strColor) { |
src/surface.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
17 | 17 | * Free Software Foundation, Inc., * |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | ||
20 | 21 | #ifndef SURFACE_H |
21 | 22 | #define SURFACE_H |
22 | 23 | |
23 | #include <SDL.h> | |
24 | #include <string> | |
25 | ||
26 | 24 | #include "asfont.h" |
27 | 25 | |
28 | using std::string; | |
26 | #include <SDL.h> | |
27 | #include <string> | |
29 | 28 | |
30 | 29 | struct RGBAColor { |
31 | 30 | unsigned short r,g,b,a; |
32 | 31 | }; |
33 | 32 | |
34 | RGBAColor strtorgba(const string &strColor); | |
33 | RGBAColor strtorgba(const std::string &strColor); | |
35 | 34 | |
36 | 35 | /** |
37 | 36 | Wrapper around SDL_Surface |
... | ... | |
41 | 40 | public: |
42 | 41 | static Surface *openOutputSurface(int width, int height, int bitsperpixel); |
43 | 42 | static Surface *emptySurface(int width, int height); |
44 | static Surface *loadImage(const string &img, const string &skin=""); | |
43 | static Surface *loadImage(const std::string &img, | |
44 | const std::string &skin=""); | |
45 | 45 | |
46 | 46 | Surface(Surface *s); |
47 | 47 | ~Surface(); |
... | ... | |
66 | 66 | bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); |
67 | 67 | bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); |
68 | 68 | |
69 | void write(ASFont *font, const string &text, int x, int y, ASFont::HAlign halign = ASFont::HAlignLeft, ASFont::VAlign valign = ASFont::VAlignTop) { | |
69 | void write(ASFont *font, const std::string &text, int x, int y, | |
70 | ASFont::HAlign halign = ASFont::HAlignLeft, | |
71 | ASFont::VAlign valign = ASFont::VAlignTop) { | |
70 | 72 | font->write(this, text, x, y, halign, valign); |
71 | 73 | } |
72 | 74 |
src/translator.cpp | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | 20 | |
21 | #include "translator.h" | |
22 | ||
23 | #include "debug.h" | |
24 | #include "gmenu2x.h" | |
25 | ||
21 | 26 | #include <fstream> |
22 | 27 | #include <iostream> |
23 | 28 | #include <sstream> |
24 | 29 | #include <stdarg.h> |
25 | 30 | |
26 | #include "translator.h" | |
27 | #include "debug.h" | |
28 | #include "gmenu2x.h" | |
29 | ||
30 | 31 | using namespace std; |
32 | using std::tr1::unordered_map; | |
31 | 33 | |
32 | 34 | Translator::Translator(const string &lang) { |
33 | 35 | _lang = ""; |
src/translator.h | ||
---|---|---|
1 | 1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * | |
3 | * massimiliano.torromeo@gmail.com * | |
4 | 4 | * * |
5 | 5 | * This program is free software; you can redistribute it and/or modify * |
6 | 6 | * it under the terms of the GNU General Public License as published by * |
... | ... | |
17 | 17 | * Free Software Foundation, Inc., * |
18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | 19 | ***************************************************************************/ |
20 | ||
20 | 21 | #ifndef TRANSLATOR_H |
21 | 22 | #define TRANSLATOR_H |
22 | 23 | |
23 | #include "utilities.h" | |
24 | #include <string> | |
25 | #include <tr1/unordered_map> | |
24 | 26 | |
25 | 27 | /** |
26 | 28 | Hash Map of translation strings. |
... | ... | |
29 | 31 | */ |
30 | 32 | class Translator { |
31 | 33 | private: |
32 | string _lang; | |
33 | unordered_map<string, string> translations; | |
34 | std::string _lang; | |
35 | std::tr1::unordered_map<std::string, std::string> translations; | |
34 | 36 | |
35 | 37 | public: |
36 | Translator(const string &lang=""); | |
38 | Translator(const std::string &lang=""); | |
37 | 39 | ~Translator(); |
38 | 40 | |
39 | string lang(); | |
40 | void setLang(const string &lang); | |
41 | bool exists(const string &term); | |
42 | string translate(const string &term,const char *replacestr=NULL,...); | |
43 | string operator[](const string &term); | |
41 | std::string lang(); | |
42 | void setLang(const std::string &lang); | |
43 | bool exists(const std::string &term); | |
44 | std::string translate(const std::string &term, | |
45 | const char *replacestr = NULL, ...); | |
46 | std::string operator[](const std::string &term); | |
44 | 47 | }; |
45 | 48 | |
46 | #endif | |
49 | #endif // TRANSLATOR_H |
src/utilities.h | ||
---|---|---|
23 | 23 | |
24 | 24 | #include <string> |
25 | 25 | #include <vector> |
26 | #include <tr1/unordered_map> | |
27 | ||
28 | using std::tr1::unordered_map; | |
29 | using std::tr1::hash; | |
30 | using std::string; | |
31 | using std::vector; | |
32 | 26 | |
33 | 27 | class case_less { |
34 | 28 | public: |
35 | bool operator()(const string &left, const string &right) const; | |
29 | bool operator()(const std::string &left, const std::string &right) const; | |
36 | 30 | }; |
37 | 31 | |
38 | string trim(const string& s); | |
39 | string strreplace (string orig, const string &search, const string &replace); | |
40 | string cmdclean (string cmdline); | |
32 | std::string trim(const std::string& s); | |
33 | std::string strreplace (std::string orig, const std::string &search, const std::string &replace); | |
34 | std::string cmdclean (std::string cmdline); | |
41 | 35 | |
42 | char *string_copy(const string &); | |
43 | void string_copy(const string &, char **); | |
36 | char *string_copy(const std::string &); | |
37 | void string_copy(const std::string &, char **); | |
44 | 38 | |
45 | bool fileExists(const string &file); | |
46 | bool rmtree(string path); | |
39 | bool fileExists(const std::string &file); | |
40 | bool rmtree(std::string path); | |
47 | 41 | |
48 | int max (int a, int b); | |
49 | int min (int a, int b); | |
50 | int constrain (int x, int imin, int imax); | |
42 | int max(int a, int b); | |
43 | int min(int a, int b); | |
44 | int constrain(int x, int imin, int imax); | |
51 | 45 | |
52 | int evalIntConf (int val, int def, int imin, int imax); | |
53 | int evalIntConf (int *val, int def, int imin, int imax); | |
54 | const string &evalStrConf (const string &val, const string &def); | |
55 | const string &evalStrConf (string *val, const string &def); | |
46 | int evalIntConf(int val, int def, int imin, int imax); | |
47 | int evalIntConf(int *val, int def, int imin, int imax); | |
48 | const std::string &evalStrConf(const std::string &val, const std::string &def); | |
49 | const std::string &evalStrConf(std::string *val, const std::string &def); | |
56 | 50 | |
57 | bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true); | |
51 | bool split(std::vector<std::string> &vec, const std::string &str, | |
52 | const std::string &delim, bool destructive=true); | |
58 | 53 | |
59 | int intTransition(int from, int to, long int tickStart, long duration=500, long tickNow=-1); | |
54 | int intTransition(int from, int to, long int tickStart, long duration=500, | |
55 | long tickNow=-1); | |
60 | 56 | |
61 | #endif | |
57 | #endif // UTILITIES_H |
Branches:
install_locations
master
opkrun
packages