2010-02-04 13:33:47 +02:00
|
|
|
/***************************************************************************
|
2011-10-23 17:43:56 +03:00
|
|
|
* Copyright (C) 2006 by Massimiliano Torromeo *
|
|
|
|
* massimiliano.torromeo@gmail.com *
|
2010-02-04 13:33:47 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef GMENU2X_H
|
|
|
|
#define GMENU2X_H
|
|
|
|
|
|
|
|
#include "surfacecollection.h"
|
|
|
|
#include "translator.h"
|
|
|
|
#include "FastDelegate.h"
|
|
|
|
#include "touchscreen.h"
|
|
|
|
#include "inputmanager.h"
|
2010-07-28 04:08:26 +03:00
|
|
|
#include "surface.h"
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2010-07-28 04:31:41 +03:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <tr1/unordered_map>
|
|
|
|
|
2011-10-23 18:27:29 +03:00
|
|
|
class ASFont;
|
|
|
|
class Button;
|
|
|
|
class Menu;
|
|
|
|
class Surface;
|
|
|
|
|
2011-03-29 13:11:59 +03:00
|
|
|
#ifndef GMENU2X_SYSTEM_DIR
|
|
|
|
#define GMENU2X_SYSTEM_DIR "/usr/share/gmenu2x"
|
|
|
|
#endif
|
|
|
|
|
2011-10-23 18:27:29 +03:00
|
|
|
const int LOOP_DELAY = 30000;
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2010-07-04 04:19:52 +03:00
|
|
|
extern const char *CARD_ROOT;
|
2010-08-03 18:32:54 +03:00
|
|
|
extern const int CARD_ROOT_LEN;
|
2010-07-04 04:19:52 +03:00
|
|
|
|
2010-07-28 17:15:52 +03:00
|
|
|
// Note: Keep this in sync with colorNames!
|
2010-05-02 20:53:06 +03:00
|
|
|
enum color {
|
|
|
|
COLOR_TOP_BAR_BG,
|
|
|
|
COLOR_BOTTOM_BAR_BG,
|
|
|
|
COLOR_SELECTION_BG,
|
|
|
|
COLOR_MESSAGE_BOX_BG,
|
|
|
|
COLOR_MESSAGE_BOX_BORDER,
|
|
|
|
COLOR_MESSAGE_BOX_SELECTION,
|
|
|
|
|
|
|
|
NUM_COLORS,
|
|
|
|
};
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
typedef std::tr1::unordered_map<std::string, std::string, std::tr1::hash<std::string> > ConfStrHash;
|
|
|
|
typedef std::tr1::unordered_map<std::string, int, std::tr1::hash<std::string> > ConfIntHash;
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
class GMenu2X {
|
|
|
|
private:
|
2011-12-23 15:03:05 +02:00
|
|
|
Touchscreen ts;
|
2012-12-20 23:01:30 +02:00
|
|
|
Menu *menu;
|
2011-12-23 15:03:05 +02:00
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
/*!
|
|
|
|
Retrieves the free disk space on the sd
|
|
|
|
@return String containing a human readable representation of the free disk space
|
|
|
|
*/
|
2011-10-23 17:43:56 +03:00
|
|
|
std::string getDiskFree(const char *path);
|
2010-02-04 13:33:47 +02:00
|
|
|
unsigned short cpuX; //!< Offset for displaying cpu clock information
|
|
|
|
unsigned short manualX; //!< Offset for displaying the manual indicator in the taskbar
|
2012-12-08 06:03:33 +02:00
|
|
|
#ifdef ENABLE_CPUFREQ
|
2011-09-18 19:27:03 +03:00
|
|
|
unsigned cpuFreqMin; //!< Minimum CPU frequency
|
|
|
|
unsigned cpuFreqMax; //!< Maximum theoretical CPU frequency
|
|
|
|
unsigned cpuFreqSafeMax; //!< Maximum safe CPU frequency
|
|
|
|
unsigned cpuFreqMenuDefault; //!< Default CPU frequency for gmenu2x
|
|
|
|
unsigned cpuFreqAppDefault; //!< Default CPU frequency for launched apps
|
|
|
|
unsigned cpuFreqMultiple; //!< All valid CPU frequencies are a multiple of this
|
2012-12-08 06:03:33 +02:00
|
|
|
|
|
|
|
void initCPULimits();
|
|
|
|
#endif
|
2010-02-04 13:33:47 +02:00
|
|
|
/*!
|
|
|
|
Reads the current battery state and returns a number representing it's level of charge
|
|
|
|
@return A number representing battery charge. 0 means fully discharged. 5 means fully charged. 6 represents a gp2x using AC power.
|
|
|
|
*/
|
|
|
|
unsigned short getBatteryLevel();
|
2011-10-23 17:43:56 +03:00
|
|
|
void browsePath(const std::string &path, std::vector<std::string>* directories, std::vector<std::string>* files);
|
2010-02-04 13:33:47 +02:00
|
|
|
/*!
|
|
|
|
Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections.
|
|
|
|
*/
|
|
|
|
void scanner();
|
|
|
|
/*!
|
|
|
|
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.
|
|
|
|
@see scanner
|
|
|
|
*/
|
2011-10-23 17:43:56 +03:00
|
|
|
void scanPath(std::string path, std::vector<std::string> *files);
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Displays a selector and launches the specified executable file
|
|
|
|
*/
|
|
|
|
void explorer();
|
|
|
|
|
|
|
|
bool inet, //!< Represents the configuration of the basic network services. @see readCommonIni @see usbnet @see samba @see web
|
|
|
|
usbnet,
|
|
|
|
samba,
|
|
|
|
web;
|
2011-06-02 06:04:35 +03:00
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
std::string ip, defaultgw, lastSelectorDir;
|
2010-02-04 13:33:47 +02:00
|
|
|
int lastSelectorElement;
|
|
|
|
void readConfig();
|
2011-10-23 17:43:56 +03:00
|
|
|
void readConfig(std::string path);
|
2010-02-04 13:33:47 +02:00
|
|
|
void readTmp();
|
|
|
|
|
|
|
|
void initServices();
|
|
|
|
void initFont();
|
|
|
|
void initMenu();
|
|
|
|
|
2011-09-15 12:18:07 +03:00
|
|
|
void showManual();
|
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
public:
|
2010-06-19 04:15:20 +03:00
|
|
|
GMenu2X();
|
2010-02-04 13:33:47 +02:00
|
|
|
~GMenu2X();
|
|
|
|
void quit();
|
|
|
|
|
2011-03-29 13:15:16 +03:00
|
|
|
/* Returns the home directory of gmenu2x, usually
|
|
|
|
* ~/.gmenu2x */
|
2011-10-23 17:43:56 +03:00
|
|
|
static const std::string getHome(void);
|
2011-03-29 13:15:16 +03:00
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
/*
|
|
|
|
* Variables needed for elements disposition
|
|
|
|
*/
|
|
|
|
uint resX, resY, halfX, halfY;
|
|
|
|
uint bottomBarIconY, bottomBarTextY, linkColumns, linkRows;
|
|
|
|
|
|
|
|
InputManager input;
|
|
|
|
|
|
|
|
//Configuration hashes
|
|
|
|
ConfStrHash confStr, skinConfStr;
|
|
|
|
ConfIntHash confInt, skinConfInt;
|
2010-05-02 20:53:06 +03:00
|
|
|
RGBAColor skinConfColors[NUM_COLORS];
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
//Configuration settings
|
|
|
|
bool useSelectionPng;
|
2011-10-23 17:43:56 +03:00
|
|
|
void setSkin(const std::string &skin, bool setWallpaper = true);
|
2011-07-29 02:13:35 +03:00
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
SurfaceCollection sc;
|
|
|
|
Translator tr;
|
|
|
|
Surface *s, *bg;
|
|
|
|
ASFont *font;
|
|
|
|
|
|
|
|
//Status functions
|
2010-06-19 04:50:23 +03:00
|
|
|
void main();
|
2010-02-04 13:33:47 +02:00
|
|
|
void options();
|
|
|
|
void skinMenu();
|
|
|
|
void about();
|
|
|
|
void viewLog();
|
|
|
|
void contextMenu();
|
|
|
|
void changeWallpaper();
|
|
|
|
|
2012-12-08 06:03:33 +02:00
|
|
|
#ifdef ENABLE_CPUFREQ
|
2010-02-04 13:33:47 +02:00
|
|
|
void setClock(unsigned mhz);
|
2012-12-07 01:53:39 +02:00
|
|
|
void setMenuClock() { setClock(cpuFreqMenuDefault); }
|
|
|
|
void setSafeMaxClock() { setClock(cpuFreqSafeMax); }
|
2012-12-08 06:03:33 +02:00
|
|
|
unsigned getDefaultAppClock() { return cpuFreqAppDefault; }
|
|
|
|
#endif
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
void setInputSpeed();
|
|
|
|
|
2012-12-20 23:01:30 +02:00
|
|
|
void saveSelection();
|
2010-02-04 13:33:47 +02:00
|
|
|
void writeConfig();
|
|
|
|
void writeSkinConfig();
|
2011-10-23 17:43:56 +03:00
|
|
|
void writeTmp(int selelem=-1, const std::string &selectordir="");
|
2010-02-04 13:33:47 +02:00
|
|
|
|
|
|
|
void addLink();
|
|
|
|
void editLink();
|
|
|
|
void deleteLink();
|
|
|
|
void addSection();
|
|
|
|
void renameSection();
|
|
|
|
void deleteSection();
|
|
|
|
|
|
|
|
void initBG();
|
2010-05-03 23:21:36 +03:00
|
|
|
int drawButton(Button *btn, int x=5, int y=-10);
|
2011-10-23 17:43:56 +03:00
|
|
|
int drawButton(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
|
|
|
|
int drawButtonRight(Surface *s, const std::string &btn, const std::string &text, int x=5, int y=-10);
|
2010-02-04 13:33:47 +02:00
|
|
|
void drawScrollBar(uint pagesize, uint totalsize, uint pagepos, uint top, uint height);
|
|
|
|
|
|
|
|
void drawTopBar(Surface *s=NULL);
|
|
|
|
void drawBottomBar(Surface *s=NULL);
|
|
|
|
};
|
|
|
|
|
2011-10-23 17:43:56 +03:00
|
|
|
#endif // GMENU2X_H
|