Root/
Source at commit 2a2634b3640286bf05fa5158e5f71ba1d2490aea created 9 years 5 months ago. By Nebuleon Fumika, Remove all touch-screen-related code | |
---|---|
1 | /*************************************************************************** |
2 | * Copyright (C) 2006 by Massimiliano Torromeo * |
3 | * massimiliano.torromeo@gmail.com * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | ***************************************************************************/ |
20 | |
21 | #ifndef GMENU2X_H |
22 | #define GMENU2X_H |
23 | |
24 | #include "contextmenu.h" |
25 | #include "surfacecollection.h" |
26 | #include "translator.h" |
27 | #include "inputmanager.h" |
28 | #include "powersaver.h" |
29 | #include "surface.h" |
30 | #include "utilities.h" |
31 | |
32 | #include <iostream> |
33 | #include <memory> |
34 | #include <string> |
35 | #include <vector> |
36 | |
37 | class Button; |
38 | class Font; |
39 | class HelpPopup; |
40 | class IconButton; |
41 | class Launcher; |
42 | class Layer; |
43 | class MediaMonitor; |
44 | class Menu; |
45 | |
46 | #ifndef GMENU2X_SYSTEM_DIR |
47 | #define GMENU2X_SYSTEM_DIR "/usr/share/gmenu2x" |
48 | #endif |
49 | |
50 | #ifndef LOG_FILE |
51 | #define LOG_FILE "/var/log/gmenu2x.log" |
52 | #endif |
53 | |
54 | const int LOOP_DELAY = 30000; |
55 | |
56 | extern const char *CARD_ROOT; |
57 | |
58 | // Note: Keep this in sync with colorNames! |
59 | enum color { |
60 | COLOR_TOP_BAR_BG, |
61 | COLOR_BOTTOM_BAR_BG, |
62 | COLOR_SELECTION_BG, |
63 | COLOR_MESSAGE_BOX_BG, |
64 | COLOR_MESSAGE_BOX_BORDER, |
65 | COLOR_MESSAGE_BOX_SELECTION, |
66 | |
67 | NUM_COLORS, |
68 | }; |
69 | |
70 | class GMenu2X { |
71 | private: |
72 | std::shared_ptr<Menu> menu; |
73 | #ifdef ENABLE_INOTIFY |
74 | MediaMonitor *monitor; |
75 | #endif |
76 | |
77 | std::unique_ptr<Launcher> toLaunch; |
78 | |
79 | std::vector<std::shared_ptr<Layer>> layers; |
80 | |
81 | /*! |
82 | Retrieves the free disk space on the sd |
83 | @return String containing a human readable representation of the free disk space |
84 | */ |
85 | std::string getDiskFree(const char *path); |
86 | #ifdef ENABLE_CPUFREQ |
87 | unsigned cpuFreqMin; //!< Minimum CPU frequency |
88 | unsigned cpuFreqMax; //!< Maximum theoretical CPU frequency |
89 | unsigned cpuFreqSafeMax; //!< Maximum safe CPU frequency |
90 | unsigned cpuFreqMenuDefault; //!< Default CPU frequency for gmenu2x |
91 | unsigned cpuFreqAppDefault; //!< Default CPU frequency for launched apps |
92 | unsigned cpuFreqMultiple; //!< All valid CPU frequencies are a multiple of this |
93 | |
94 | void initCPULimits(); |
95 | #endif |
96 | |
97 | /*! |
98 | Displays a selector and launches the specified executable file |
99 | */ |
100 | void explorer(); |
101 | |
102 | bool inet, //!< Represents the configuration of the basic network services. @see readCommonIni @see usbnet @see samba @see web |
103 | usbnet, |
104 | samba, |
105 | web; |
106 | |
107 | std::string ip, defaultgw, lastSelectorDir; |
108 | int lastSelectorElement; |
109 | void readConfig(); |
110 | void readConfig(std::string path); |
111 | void readTmp(); |
112 | |
113 | void initServices(); |
114 | void initFont(); |
115 | void initMenu(); |
116 | void initBG(); |
117 | |
118 | public: |
119 | static void run(); |
120 | |
121 | GMenu2X(); |
122 | ~GMenu2X(); |
123 | |
124 | /* Returns the home directory of gmenu2x, usually |
125 | * ~/.gmenu2x */ |
126 | static const std::string getHome(); |
127 | |
128 | /* |
129 | * Variables needed for elements disposition |
130 | */ |
131 | uint resX, resY, halfX, halfY; |
132 | uint bottomBarIconY, bottomBarTextY; |
133 | unsigned short cpuX; //!< Offset for displaying cpu clock information |
134 | unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar |
135 | |
136 | /** |
137 | * Gets the position and height of the area between the top and bottom bars. |
138 | */ |
139 | std::pair<unsigned int, unsigned int> getContentArea() { |
140 | const unsigned int top = skinConfInt["topBarHeight"]; |
141 | const unsigned int bottom = skinConfInt["bottomBarHeight"]; |
142 | return std::make_pair(top, resY - top - bottom); |
143 | } |
144 | |
145 | PowerSaver powerSaver; |
146 | InputManager input; |
147 | |
148 | //Configuration hashes |
149 | ConfStrHash confStr, skinConfStr; |
150 | ConfIntHash confInt, skinConfInt; |
151 | RGBAColor skinConfColors[NUM_COLORS]; |
152 | |
153 | //Configuration settings |
154 | bool useSelectionPng; |
155 | void setSkin(const std::string &skin, bool setWallpaper = true); |
156 | bool readSkinConfig(const std::string& conffile); |
157 | |
158 | SurfaceCollection sc; |
159 | Translator tr; |
160 | std::unique_ptr<OutputSurface> s; |
161 | /** Background with empty top and bottom bar. */ |
162 | std::unique_ptr<OffscreenSurface> bg; |
163 | /** Background with empty top bar and a partially filled bottom bar. */ |
164 | std::unique_ptr<OffscreenSurface> bgmain; |
165 | std::unique_ptr<Font> font; |
166 | |
167 | //Status functions |
168 | void mainLoop(); |
169 | void showContextMenu(); |
170 | void showHelpPopup(); |
171 | void showManual(); |
172 | void showSettings(); |
173 | void skinMenu(); |
174 | void about(); |
175 | void viewLog(); |
176 | void changeWallpaper(); |
177 | |
178 | #ifdef ENABLE_CPUFREQ |
179 | void setClock(unsigned mhz); |
180 | void setMenuClock() { setClock(cpuFreqMenuDefault); } |
181 | void setSafeMaxClock() { setClock(cpuFreqSafeMax); } |
182 | unsigned getDefaultAppClock() { return cpuFreqAppDefault; } |
183 | #endif |
184 | |
185 | /** |
186 | * Requests that the given application be launched. |
187 | * The launch won't happen immediately; it will happen after control |
188 | * returns to the main loop. |
189 | */ |
190 | void queueLaunch(std::unique_ptr<Launcher>&& launcher, |
191 | std::shared_ptr<Layer> launchLayer); |
192 | |
193 | void saveSelection(); |
194 | void writeConfig(); |
195 | void writeSkinConfig(); |
196 | void writeTmp(int selelem=-1, const std::string &selectordir=""); |
197 | |
198 | void addLink(); |
199 | void editLink(); |
200 | void deleteLink(); |
201 | void addSection(); |
202 | void renameSection(); |
203 | void deleteSection(); |
204 | |
205 | int drawButton(Surface& s, const std::string &btn, const std::string &text, int x=5, int y=-10); |
206 | int drawButtonRight(Surface& s, const std::string &btn, const std::string &text, int x=5, int y=-10); |
207 | void drawScrollBar(uint pageSize, uint totalSize, uint pagePos); |
208 | |
209 | void drawTopBar(Surface& s); |
210 | void drawBottomBar(Surface& s); |
211 | }; |
212 | |
213 | #endif // GMENU2X_H |
214 |
Branches:
install_locations
master
opkrun
packages