1
/* Joe's Window Manager Configuration
3
* This program configures JWM using pugixml and FLTK
5
* Copyright (C) 2016 Israel <israeldahl@gmail.com>
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
* This has been developed as a part of the ToriOS Project
21
* You may redistribute this, but you must keep this comment in place
22
* Jesus is my Lord, and if you don't like it feel free to ignore it.
31
#include <FL/fl_ask.H> //errorJWM
32
#include <FL/Fl_Menu_Button.H>
33
#include <FL/Fl_Output.H>
34
#include <FL/Fl_Double_Window.H>
35
#include <FL/Fl_File_Chooser.H>
36
#include <FL/Fl_PNG_Image.H>
37
//Used for getting the user's Home directory
39
//strtoul for background string to unsigned int
41
//write recovery file directly from program
43
//MultiDesktop int from string
47
//Used by some sub-classes to check for files and folders
48
#include <sys/types.h>
50
//Hopefully you already know what these are for
57
//getExtention for icons
62
#include "pugixml.hpp"
64
///Boolean//////////////////////////////////////////////////////////////
66
bool addButtonToLastTray(std::string attribute, std::string value, std::string text);
67
bool addElement(std::string element);
68
bool addElementAndSub(std::string element, std::string subelelemnt);
69
bool addElementWithText(std::string element, std::string text);
70
bool addElementWithTextAfter(std::string element, std::string text);
71
bool addElementWithAttribute(std::string element, std::string attribute, std::string value);
72
bool addElementWithTextAndAttribute(std::string element, std::string attribute, std::string value,std::string text);
73
bool addElementWithTextAndAttribute(std::string element, std::string attribute, std::string value, std::string attribute2, std::string value2,std::string text);
74
bool addElementWithSubAndText(std::string element, std::string subelement, std::string text);
75
bool addMenuElement(unsigned int whichMenu,std::string element);
76
bool addSubElement(unsigned int whichElement,std::string element, std::string subelelemnt);
77
bool addSubElementWithText(unsigned int whichElement,std::string element, std::string subelelemnt, std::string text);
78
bool addSubElementWithTextandAttribute(unsigned int whichElement,std::string element, std::string subelelemnt, std::string text,std::string attribute, std::string value);
79
bool addSubElementWithAttribute(unsigned int whichElement,std::string element, std::string subelelemnt, std::string attribute, std::string value);
80
bool addSubNodewithText(pugi::xml_node node,std::string element,std::string text);
81
bool addSubNodewithAttributeAndText(pugi::xml_node node,std::string element,std::string attribute, std::string value, std::string text);
83
bool changeCursorTheme(Fl_Browser *o);
84
bool checkDE(std::string file);
85
bool checkExec(std::string exec);
86
bool checkFlBrowserItem(Fl_Browser* o);
87
bool checkVector(std::vector<std::string> myVec,std::string item);
89
bool deleteElements(std::string element);
90
bool deleteSubElement(std::string element, int whichElement);
92
bool editMenuItem(int menu, int item, std::string text);
93
bool editMenuItem(int menu, int item, std::string attribute,std::string value);
95
bool getIcons(Fl_Browser *o);
96
bool getMenuItems(Fl_Browser* menuElement,std::string menu,Fl_Browser* menuElementText);
97
bool getMenus(Fl_Browser* rootnode);
99
bool isColor(std::string text);
100
bool isElement(std::string element);
101
bool isElement(std::string element, std::string subelement);
102
bool isElement(std::string element, std::string subelement, std::string SUBsubelement);
103
//bool isElement(std::string element, std::string subelement, std::string SUBsubsubelement);
104
bool isExec(std::string exec);
105
bool isImage(std::string filename);
106
bool isMenu(std::string rootNumber);
107
bool isRootMenu(std::string rootmenu);
108
bool isSVG(std::string filename);
109
bool isTrayElement(std::string element);
112
bool load(std::string filename);
113
bool load(std::string filename, bool saveTemp);
116
bool newVersionJWM();
118
bool populateFLBrowser(Fl_Browser *o,std::string element);
119
bool populateFLBrowser(Fl_Browser *o,std::string element,std::string subelement, unsigned int whichMainElement);
120
bool populateFLBrowser2Attr(Fl_Browser *o,std::string element,std::string attribute1, std::string attribute2);
122
bool removeMenu(std::string value);
125
bool saveChanges(std::string filename,bool restart, bool reload);
126
bool saveChangesTemp();
127
bool saveChangesTempOverwrite();
128
bool saveChangesTempOverwrite(std::string myhomie);
129
bool saveNoRestart();
130
bool setAttribute(pugi::xml_node node,std::string attribute,std::string value);
131
bool setLastTrayButtonAttribute(std::string attribute,std::string value);
132
bool setElementText(std::string element, std::string text);
133
bool setElementText(unsigned int whichElement, std::string element, std::string subelement, std::string text);
134
bool setElementText(std::string element, std::string subelement, std::string text);
135
bool setElementText(std::string element, std::string subelement, std::string SUBsubsubelement, std::string text);
136
bool setElementInt(std::string element, unsigned int text);
137
bool setElementInt(std::string element, std::string subelement, unsigned int text);
138
bool setElementInt(std::string element, std::string subelement, std::string SUBsubsubelement, unsigned int text);
139
bool setElementFloat(std::string element, double* text);
140
bool setElementFloat(std::string element, std::string subelement, double* text);
141
bool setElementFloat(std::string element, std::string subelement, std::string SUBsubsubelement, double* text);
142
bool setElementAttribute(unsigned int whichElement, std::string element, std::string attribute, std::string value);
143
bool setElementAttribute(unsigned int whichElement, std::string element, std::string subelement, std::string attribute, std::string value);
144
bool setElementAttribute(std::string element, std::string attribute, std::string value);
145
bool setElementAttribute(std::string element, std::string subelement, std::string attribute, std::string value);
146
bool setElementAttribute(std::string element, std::string subelement, std::string SUBsubsubelement, std::string attribute, std::string value);
147
bool setElementAttributeANDtext(std::string element, std::string attribute, std::string value,std::string text);
148
bool setElementAttributeANDtext(std::string element, std::string subelement, std::string attribute, std::string value,std::string text);
149
bool setElementAttributeANDtext(std::string element, std::string subelement, std::string SUBsubsubelement, std::string attribute, std::string value,std::string text);
150
bool setElementColor(std::string element, const double* rgb);
151
bool setElementColor(std::string element, std::string subelement, const double* rgb);
152
bool setElementColor(std::string element, std::string subelement, std::string SUBsubsubelement, const double* rgb);
153
bool setJSMItem(std::string item, std::string value);
154
bool setNodeText(pugi::xml_node node,std::string text);
155
bool setNodeButtonTextByMask(pugi::xml_node node,std::string text,std::string attribute);
156
bool setRootMenuAttribute(int MENU, std::string attribute,std::string value);
157
bool setRootMenuHeight(std::string val, int height);
159
bool testExec(std::string command); //linuxcommon wrapper
160
//String////////////////////////////////////////////////////////////////
162
std::string checkListofExec(std::vector<std::string> list);
163
std::string colorToString(const double *rgb);
165
std::string fixHomieInclude(std::string includeLine);
167
std::string getAttribute(pugi::xml_node node,std::string attribute);
168
std::string getElementText(std::string element);
169
std::string getElementText(std::string element, std::string subelement);
170
std::string getElementText(unsigned int whichOne, std::string element, std::string subelement);
171
std::string getElementText(std::string element, std::string subelement, std::string SUBsubsubelement);
172
std::string getElementAttribute(std::string element, std::string attribute);
173
std::string getElementAttribute(std::string element, std::string subelement, std::string attribute);
174
std::string getElementAttribute(std::string element, std::string subelement, std::string SUBsubsubelement, std::string attribute);
175
std::string getElementAttributeFromElementWithAttributeAndValue(std::string element, std::string attribOfEle, std::string value, std::string subelement, std::string attribute);
176
std::string getElementAttributeFromElementWithAttributeAndValueAndText(std::string element, std::string attribOfEle, std::string value, std::string subelement, std::string attribute,std::string text);
177
std::string getElementAttribute(unsigned int whichElement,std::string element, std::string subelement, std::string attribute);
178
std::string getElementAttribute(unsigned int whichElement,std::string element, std::string attribute);
179
std::string getElementAttribute(unsigned int whichElement,std::string element,unsigned int whichItem, std::string subelement, std::string attribute);
180
std::string getEQUALvalue(std::string INTERNAL_LINE);
181
std::string getFirstColor(std::string element, std::string subelement);
182
std::string getItemText(pugi::xml_node node);
183
std::string getJSMItem(std::string item);
184
std::string getMenuAttribute(std::string MENU, std::string attribute);
185
std::string getMenuAttribute(int MENU, int subitem, std::string element, std::string attribute);
186
std::string getLayoutThing(std::string attribute,std::string vaule1,std::string value2,std::string value3,std::string layout);
187
std::string getPanelButtonIcon();
188
std::string getRootMenuAttribute(int MENU, std::string attribute);
189
std::string getSecondColor(std::string element, std::string subelement);
190
std::string getSmartHoriz(std::string layout);
191
std::string getSmartVert(std::string layout);
192
std::string getSmartLayout();
194
std::string homePath();
195
std::string horizontalORvertical(int horizontalValue, int verticalValue);
197
std::string joinColors(const double* rgb, const double* rgb2);
199
std::string makeTempName(std::string filename);
200
std::string makeNOTtemp(std::string filename);
201
std::string menuButtonText(pugi::xml_node node);
203
std::string splitColor(unsigned int first_or_second, std::string HTMLcolor);
205
std::string terminal(std::string terminal);//linuxcommon wrapper
206
//const char*///////////////////////////////////////////////////////////
207
const char* convert(double num);
208
//unsigned int//////////////////////////////////////////////////////////
210
unsigned int convert(const char* num);
211
unsigned int currentPanel();
213
unsigned int elementCounter(std::string element);
215
unsigned int flCOLOR(std::string color, unsigned int &c);//linuxcommon wrapper
216
unsigned int flCOLOR(std::string color);//linuxcommon wrapper
218
unsigned int getActiveBackground(unsigned int c,std::string element);
219
unsigned int getActiveForeground(unsigned int c,std::string element);
220
unsigned int getBackground(unsigned int c,std::string element);
221
unsigned int getFontColor(unsigned int c,std::string element);
222
unsigned int getFontColor(unsigned int c,std::string element);
223
unsigned int getElementInt(std::string element);
224
unsigned int getElementInt(std::string element, std::string subelement);
225
unsigned int getElementInt(std::string element, std::string subelement, std::string SUBsubsubelement);
227
unsigned int numPanels();
229
unsigned int splitColor(std::string color, int one_or_two);
230
unsigned int switch_panel(Fl_Menu_Item *o);
231
//int///////////////////////////////////////////////////////////////////
232
int addMenuItem(Fl_Browser* root_menu, Fl_Input* add_label, Fl_Input* add_icon, Fl_Input* add_input, Fl_Input* add_tooltip, Fl_Check_Button* add_button, std::string result);
233
int addMenuAttrib(int whichMenu,std::string element,std::string attribute,const char *value);
234
int getIntAttribute(std::string element, std::string attribute);
235
int getIntAttribute(std::string element, std::string subelement, std::string attribute);
238
int whichAlign(std::string align);
239
//float/////////////////////////////////////////////////////////////////
240
float getElementFloat(std::string element);
241
float getElementFloat(std::string element, std::string subelement);
242
float getElementFloat(std::string element, std::string subelement, std::string SUBsubsubelement);
243
float getOpacity(std::string element);
244
//const double* getBoxColor(Fl_Box*o);
245
//Vector////////////////////////////////////////////////////////////////
246
std::vector<std::string> AnythingVector(std::string element);
247
std::vector<std::string> IconPaths();
248
std::vector<std::string> Includes();
249
std::vector<std::string> XDGautostart();
250
std::vector<std::string> zoneSubdir(std::string thisDIR);
251
std::vector<std::string> zoneVector();
252
//void//////////////////////////////////////////////////////////////////
254
void addCursorsToBrowser(Fl_Browser *o);
257
void createElement(std::string element,std::string text);
258
void changeElementText(std::string element,std::string text,std::string NEWTEXT);
260
void debug_out(std::string msg);
261
void deletePanelItem(int whichElement);
262
void deleteShortcut(std::string program);
264
void errorOUT(std::string msg);
266
void getShortcuts(Fl_Browser *o);
268
void listAutostartXDG(Fl_Browser *o);
270
void moveUp(int whichone);
271
void moveDown(int whichone);
273
void populateDesc(Fl_Browser *o);
274
void populateOptions(Fl_Browser *o);
275
void populateApps(Fl_Browser *o);
279
void removeElement(unsigned int whichMainElement, std::string element,std::string subelement,std::string text);
280
void removeElement(unsigned int whichMainElement, std::string element,std::string subelement);
281
void removeElement(unsigned int whichMainElement, std::string element);
282
void removeElement(std::string element,std::string text);
283
void removeElementCompare2Attr(std::string element, std::string attribute, std::string value, std::string attribute2, std::string value2,std::string text);
284
void removeXDGautostart(bool NOT, bool ONLY, bool DE, std::string filename, std::string env);
286
void setRootMenuAttribute(std::string menustring ,std::string attribute,std::string value);
288
void under_mouse(Fl_Window *o);
289
//pugixml/////////////////////////////////////////////////////////////
291
pugi::xml_node addNextSubelement(std::string element);
292
pugi::xml_node addNode(unsigned int whichElement,std::string element, std::string subelement);
294
pugi::xml_node checkIncludes(unsigned int whichOne,std::string element);
295
pugi::xml_node checkIncludes(std::string element);
296
pugi::xml_node checkIncludes(std::string element,std::string subelement);
297
pugi::xml_node checkIncludes(std::string element,std::string subelement,std::string SUBsubelement);
298
pugi::xml_node compareNode(std::string element, std::string attribute, std::string value, std::string attribute2, std::string value2,std::string text);
300
pugi::xml_node getCurrentTrayNode();
301
pugi::xml_node getLastSubNode(unsigned int whichElement,std::string element, std::string subelement);
302
pugi::xml_node getMenu(std::string text);
303
pugi::xml_node getMenu(int whichMenu);
304
pugi::xml_node getMenuButtonByMask(std::string text,int item);
305
pugi::xml_node getNode(unsigned int whichElement,std::string element,unsigned int whichNODE);
306
pugi::xml_node getNode(unsigned int whichElement,std::string element,unsigned int whichNODE, std::string subelement);
307
pugi::xml_node getRootMenu(std::string text);
308
pugi::xml_node getSubNode(unsigned int whichElement,std::string element,unsigned int whichSubElement, std::string subelement);
309
pugi::xml_node getTraySubElement(unsigned int whichElement);
311
pugi::xml_node parseNodes(unsigned int whichElement,std::string element);
312
//variables/////////////////////////////////////////////////////////////