Root/
| 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 | #ifndef MENU_H |
| 21 | #define MENU_H |
| 22 | |
| 23 | #include <string> |
| 24 | #include <vector> |
| 25 | #include "linkaction.h" |
| 26 | |
| 27 | using std::string; |
| 28 | using std::vector; |
| 29 | |
| 30 | class LinkApp; |
| 31 | class GMenu2X; |
| 32 | |
| 33 | typedef vector<Link*> linklist; |
| 34 | |
| 35 | /** |
| 36 | Handles the menu structure |
| 37 | |
| 38 | @author Massimiliano Torromeo <massimiliano.torromeo@gmail.com> |
| 39 | */ |
| 40 | class Menu { |
| 41 | private: |
| 42 | GMenu2X *gmenu2x; |
| 43 | int iSection, iLink; |
| 44 | uint iFirstDispSection, iFirstDispRow; |
| 45 | vector<string> sections; |
| 46 | vector<linklist> links; |
| 47 | |
| 48 | void readLinks(); |
| 49 | void freeLinks(); |
| 50 | |
| 51 | // Load all the sections of the given "sections" directory. |
| 52 | void readSections(std::string parentDir); |
| 53 | |
| 54 | // Load all the links on the given section directory. |
| 55 | void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles); |
| 56 | |
| 57 | public: |
| 58 | Menu(GMenu2X *gmenu2x); |
| 59 | ~Menu(); |
| 60 | |
| 61 | linklist *sectionLinks(int i = -1); |
| 62 | |
| 63 | int selSectionIndex(); |
| 64 | const string &selSection(); |
| 65 | void decSectionIndex(); |
| 66 | void incSectionIndex(); |
| 67 | void setSectionIndex(int i); |
| 68 | uint firstDispSection(); |
| 69 | uint firstDispRow(); |
| 70 | |
| 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); |
| 74 | void deleteSelectedLink(); |
| 75 | void deleteSelectedSection(); |
| 76 | |
| 77 | void loadIcons(); |
| 78 | bool linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex); |
| 79 | |
| 80 | int selLinkIndex(); |
| 81 | Link *selLink(); |
| 82 | LinkApp *selLinkApp(); |
| 83 | void linkLeft(); |
| 84 | void linkRight(); |
| 85 | void linkUp(); |
| 86 | void linkDown(); |
| 87 | void setLinkIndex(int i); |
| 88 | |
| 89 | const vector<string> &getSections() { return sections; } |
| 90 | void renameSection(int index, const string &name); |
| 91 | }; |
| 92 | |
| 93 | #endif |
| 94 |
Branches:
install_locations
master
opkrun
packages
