~israeldahl/jwm-settings-manager/trunk

« back to all changes in this revision

Viewing changes to include/jwmrc.hpp

  • Committer: Israel Dahl
  • Date: 2014-07-06 02:48:28 UTC
  • Revision ID: israeldahl@gmail.com-20140706024828-1bt17riyy2ep06bt
actually added the themes, buttons, etc...
* Alpha Version update
 * Desktop
 - Added Rox checkers, and getters and setters, but haven't finished/enabled it
 - Finished gradient support
 - finished Single color support
 - moved the image setting code to flDesktop(h/cpp)
 * Window
 - fixed Window icon code to reliably open the directory containing icons
 - added 'BoxShaped' window buttons

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*                 Joe's Window Manager Configuration
2
 
 *
3
 
 * This program configures JWM using pugixml and FLTK
4
 
 *
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.
10
 
 * 
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.
15
 
 *
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
19
 
 *
20
 
 *
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.
23
 
 */
24
 
#ifndef JWMRC_H
25
 
#define JWMRC_H
26
 
#include <X11/Xlib.h>
27
 
//icon includes
28
 
#include <X11/xpm.h>
29
 
#include <FL/x.H>
30
 
//FLTK includes
31
 
#include <FL/fl_ask.H> //errorJWM
32
 
#include <FL/Fl_Widget.H>
33
 
#include <FL/Fl_Menu_Button.H>
34
 
#include <FL/Fl_Menu_Bar.H>
35
 
#include <FL/Fl_Output.H>
36
 
#include <FL/Fl_Double_Window.H>
37
 
#include <FL/Fl_File_Chooser.H>
38
 
#include <FL/Fl_PNG_Image.H>
39
 
//Used for getting the user's Home directory
40
 
#include <stdlib.h>
41
 
//strtoul  for background string to unsigned int
42
 
#include <cstdlib>
43
 
//write recovery file directly from program
44
 
#include <fstream>
45
 
//MultiDesktop int from string
46
 
#include <cstdio>
47
 
//double to string
48
 
#include <sstream>
49
 
//Used by some sub-classes to check for files and folders
50
 
#include <sys/types.h>
51
 
#include <sys/stat.h>
52
 
//Hopefully you already know what these are for
53
 
#include <iostream>
54
 
#include <string>
55
 
#include <stdio.h>
56
 
#include <vector>
57
 
#include <algorithm>
58
 
#include <list>
59
 
//getExtention for icons
60
 
#include <dirent.h>
61
 
//gettext
62
 
#include <libintl.h>
63
 
#include "common.hpp"
64
 
#include "pugixml.hpp"
65
 
class JWMRC
66
 
{
67
 
        public:
68
 
 
69
 
///Variables//////////////////////////////////////////////////////////////
70
 
                pugi::xml_document doc;
71
 
 
72
 
///Boolean//////////////////////////////////////////////////////////////
73
 
        //A
74
 
                bool addButtonToLastTray(std::string attribute, std::string value, std::string text);
75
 
                bool addElement(std::string element);
76
 
                bool addElementAndSub(std::string element, std::string subelelemnt);
77
 
                bool addElementWithText(std::string element, std::string text);
78
 
                bool addElementWithTextAfter(std::string element, std::string text);
79
 
                bool addElementWithAttribute(std::string element, std::string attribute, std::string value);
80
 
                bool addElementWithTextAndAttribute(std::string element, std::string attribute, std::string value,std::string text);
81
 
                bool addElementWithTextAndAttribute(std::string element, std::string attribute, std::string value, std::string attribute2, std::string value2,std::string text);
82
 
                bool addElementWithTextAndAttributes(std::string element, std::string text, std::string attribute1, std::string value1, std::string attribute2="", std::string value2="", std::string attribute3="", std::string value3="");
83
 
                bool addElementWithSubAndText(std::string element, std::string subelement, std::string text);
84
 
                bool addMenuElement(unsigned int whichMenu,std::string element);
85
 
                bool addMenuElement(pugi::xml_node node,std::string element);
86
 
                bool addSubElement(unsigned int whichElement,std::string element, std::string subelelemnt);
87
 
                bool addSubElementWithText(unsigned int whichElement,std::string element, std::string subelelemnt, std::string text);
88
 
                bool addSubElementWithTextandAttribute(unsigned int whichElement,std::string element, std::string subelelemnt, std::string text,std::string attribute, std::string value);
89
 
                bool addSubElementWithAttribute(unsigned int whichElement,std::string element, std::string subelelemnt, std::string attribute, std::string value);
90
 
                bool addSubNodewithText(pugi::xml_node node,std::string element,std::string text);
91
 
                bool addSubNodewithAttributeAndText(pugi::xml_node node,std::string element,std::string attribute, std::string value, std::string text);
92
 
        //C
93
 
                bool changeCursorTheme(Fl_Browser *o);
94
 
                bool checkDE(std::string file);
95
 
                bool checkExec(std::string exec);
96
 
                bool checkFlBrowserItem(Fl_Browser* o);
97
 
                bool checkVector(std::vector<std::string> myVec,std::string item);
98
 
        //D
99
 
                bool deleteElements(std::string element);
100
 
                bool deleteNode(pugi::xml_node node);
101
 
                bool deleteSubElement(std::string element, int whichElement);
102
 
        //E
103
 
                bool elementTextExists(std::string element, std::string text);
104
 
                bool editMenuItem(int menu, int item, std::string text);
105
 
                bool editMenuItem(int menu, int item, std::string attribute,std::string value);
106
 
        //G
107
 
                bool getIcons(Fl_Browser *o);
108
 
                bool getMenuItems(Fl_Browser* menuElement,std::string menu,Fl_Browser* menuElementText);
109
 
                bool getMenus(Fl_Browser* rootnode);
110
 
                bool getSubMenu(Fl_Browser* name, Fl_Browser* text, unsigned int whichMenu, unsigned int whichItem);
111
 
        //I
112
 
                bool isColor(std::string text);
113
 
                bool isElement(std::string element);
114
 
                bool isElement(std::string element, std::string subelement);
115
 
                bool isElement(std::string element, std::string subelement, std::string SUBsubelement);
116
 
                //bool isElement(std::string element, std::string subelement, std::string SUBsubsubelement);
117
 
                bool isExec(std::string exec);
118
 
                bool isImage(std::string filename);
119
 
                bool isMenu(std::string rootNumber);
120
 
                bool isRootMenu(std::string rootmenu);
121
 
                bool isSVG(std::string filename);
122
 
                bool isTrayElement(std::string element);
123
 
        //L
124
 
                bool load();
125
 
                bool load(std::string filename);
126
 
                bool load(std::string filename, bool saveTemp);
127
 
                bool loadTemp();
128
 
        //M
129
 
                bool modifyElement(std::string element,std::string old_text,std::string text, std::string attribute1, std::string attribute_value1, std::string attribute_value1_new, std::string attribute2, std::string attribute_value2, std::string attribute_value2_new, std::string attribute3, std::string attribute_value3_new, std::string attribute3_value);
130
 
        //N
131
 
                bool newVersionJWM();
132
 
        //P
133
 
                bool populateActions(Fl_Menu_Bar *o, Fl_Callback *Menu_CB);
134
 
                bool populateFLBrowser(Fl_Browser *o, pugi::xml_node noder);
135
 
                bool populateFLBrowser(Fl_Browser *o, std::string element);
136
 
                bool populateFLBrowser(Fl_Browser *o, std::string element, std::string attribute, std::string attribute_value, std::string attribute2, std::string optional_attribute);
137
 
                bool populateFLBrowser(Fl_Browser *o, std::string element, std::string subelement, unsigned int whichMainElement);
138
 
                bool populateFLBrowserElements(Fl_Browser *o, pugi::xml_node noder);
139
 
                bool populateFLBrowser2Attr(Fl_Browser *o, std::string element, std::string attribute1, std::string attribute2,char delim='\t');
140
 
        //R
141
 
                bool removeMenu(std::string value);
142
 
        //S
143
 
                bool saveChanges();
144
 
                bool saveChanges(std::string filename,bool restart, bool reload);
145
 
                bool saveChangesMenu();
146
 
                bool saveChangesTemp();
147
 
                bool saveChangesTempOverwrite();
148
 
                bool saveChangesTempOverwrite(std::string myhomie);
149
 
                bool saveNoRestart();
150
 
                bool setAttribute(pugi::xml_node node,std::string attribute,std::string value);
151
 
                bool setLastTrayButtonAttribute(std::string attribute,std::string value);
152
 
                bool setElementText(std::string element, std::string text);
153
 
                bool setElementText(unsigned int whichElement, std::string element, std::string subelement, std::string text);
154
 
                bool setElementText(std::string element, std::string subelement, std::string text);
155
 
                bool setElementText(std::string element, std::string subelement, std::string SUBsubsubelement, std::string text);
156
 
                bool setElementInt(std::string element, unsigned int text);
157
 
                bool setElementInt(std::string element, std::string subelement, unsigned int text);
158
 
                bool setElementInt(std::string element, std::string subelement, std::string SUBsubsubelement, unsigned int text);
159
 
                bool setElementFloat(std::string element, double* text);
160
 
                bool setElementFloat(std::string element, std::string subelement, double* text);
161
 
                bool setElementFloat(std::string element, std::string subelement, std::string SUBsubsubelement, double* text);
162
 
                bool setElementAttribute(unsigned int whichElement, std::string element, std::string attribute, std::string value);
163
 
                bool setElementAttribute(unsigned int whichElement, std::string element, std::string subelement, std::string attribute, std::string value);
164
 
                bool setElementAttribute(std::string element, std::string attribute, std::string value);
165
 
                bool setElementAttribute(std::string element, std::string subelement, std::string attribute, std::string value);
166
 
                bool setElementAttribute(std::string element, std::string subelement, std::string SUBsubsubelement, std::string attribute, std::string value);
167
 
                bool setElementAttributeANDtext(std::string element, std::string attribute, std::string value,std::string text);
168
 
                bool setElementAttributeANDtext(std::string element, std::string subelement, std::string attribute, std::string value,std::string text);
169
 
                bool setElementAttributeANDtext(unsigned int whichElement,std::string element, std::string subelement, std::string attribute, std::string value,std::string text);
170
 
                bool setElementAttributeANDtext(std::string element, std::string subelement, std::string SUBsubsubelement, std::string attribute, std::string value,std::string text);
171
 
                bool setElementColor(std::string element, const double* rgb);
172
 
                bool setElementColor(std::string element, std::string subelement, const double* rgb);
173
 
                bool setElementColor(std::string element, std::string subelement, std::string SUBsubsubelement, const double* rgb);
174
 
                bool setJSMItem(std::string item, std::string value);
175
 
                bool setNodeText(pugi::xml_node node,std::string text);
176
 
                bool setNodeButtonTextByMask(pugi::xml_node node,std::string text,std::string attribute);
177
 
                bool setRootMenuAttribute(int MENU, std::string attribute,std::string value);
178
 
                bool setRootMenuHeight(std::string val, int height);
179
 
                bool set_user_tz(std::string timeZone);
180
 
        //T
181
 
                bool testExec(std::string command); //linuxcommon wrapper
182
 
 
183
 
 
184
 
//String////////////////////////////////////////////////////////////////
185
 
        //a
186
 
                std::string addExecToLine(std::string line);
187
 
        //b
188
 
                std::string buttonExec(std::string line);
189
 
                std::string buttonFixer(std::string line, std::string thing);
190
 
                std::string buttonRoot(std::string line);
191
 
        //c
192
 
                std::string checkListofExec(std::vector<std::string> list);
193
 
                std::string colorToString(const double *rgb);
194
 
        //f
195
 
                std::string fixHomieInclude(std::string includeLine);
196
 
        //g
197
 
                std::string getAttribute(pugi::xml_node node,std::string attribute);
198
 
                std::string getElementText(std::string element);
199
 
                std::string getElementText(std::string element, std::string subelement);
200
 
                std::string getElementText(unsigned int whichOne, std::string element, std::string subelement);
201
 
                std::string getElementText(std::string element, unsigned int whichElement, std::string subelement,std::string subsub);
202
 
                std::string getElementText(std::string element, std::string subelement, std::string SUBsubsubelement);
203
 
                std::string getElementText2Attributes(std::string element, std::string attr1, std::string attr1v, std::string attr2, std::string attr2v);
204
 
                std::string getElementAttribute(std::string element, std::string attribute);
205
 
                std::string getElementAttribute(std::string element, std::string subelement, std::string attribute);
206
 
                std::string getElementAttribute(std::string element, std::string subelement, std::string SUBsubsubelement, std::string attribute);
207
 
                std::string getElementAttributeFromElementWithAttributeAndValue(std::string element, std::string attribOfEle, std::string value, std::string subelement, std::string attribute);
208
 
                std::string getElementAttributeFromElementWithAttributeAndValueAndText(std::string element, std::string attribOfEle, std::string value, std::string subelement, std::string attribute,std::string text);
209
 
                std::string getElementAttribute(unsigned int whichElement,std::string element, std::string subelement, std::string attribute);
210
 
                std::string getElementAttribute(unsigned int whichElement,std::string element, std::string attribute);
211
 
                std::string getElementAttribute(unsigned int whichElement,std::string element,unsigned int whichItem, std::string subelement, std::string attribute);
212
 
                std::string getEQUALvalue(std::string INTERNAL_LINE);
213
 
                std::string getFirstColor(std::string element, std::string subelement);
214
 
                std::string getItemText(pugi::xml_node node);
215
 
                std::string getJSMItem(std::string item);
216
 
                std::string getMenuAttribute(std::string MENU, std::string attribute);
217
 
                std::string getMenuAttribute(int MENU, int subitem, std::string element, std::string attribute);
218
 
                std::string getLayoutThing(std::string attribute,std::string vaule1,std::string value2,std::string value3,std::string layout);
219
 
                std::string getPanelButtonIcon();
220
 
                std::string getRootMenuAttribute(int MENU, std::string attribute);
221
 
                std::string getSecondColor(std::string element, std::string subelement);
222
 
                std::string getSmartHoriz(std::string layout);
223
 
                std::string getSmartVert(std::string layout);
224
 
                std::string getSmartLayout();
225
 
                std::string getTabItem(unsigned int whichOne, std::string browser_line);
226
 
        //h
227
 
                std::string homePath();
228
 
                std::string horizontalORvertical(int horizontalValue, int verticalValue);
229
 
        //j
230
 
                std::string joinColors(const double* rgb, const double* rgb2);
231
 
        //m
232
 
                std::string makeTempName(std::string filename);
233
 
                std::string makeNOTtemp(std::string filename);
234
 
                std::string menuButtonText(pugi::xml_node node);
235
 
        //s
236
 
                std::string splitColor(unsigned int first_or_second, std::string HTMLcolor);
237
 
        //t
238
 
                std::string terminal(std::string terminal);//linuxcommon wrapper
239
 
 
240
 
//const char*///////////////////////////////////////////////////////////
241
 
                const char* convert(double num);
242
 
 
243
 
//unsigned int//////////////////////////////////////////////////////////
244
 
        //c
245
 
                unsigned int convert(const char* num);
246
 
                unsigned int currentPanel();
247
 
        //e
248
 
                unsigned int elementCounter(std::string element);
249
 
        //f
250
 
                unsigned int flCOLOR(std::string color, unsigned int &c);//linuxcommon wrapper
251
 
                unsigned int flCOLOR(std::string color);//linuxcommon wrapper
252
 
        //g
253
 
                unsigned int getActiveBackground(unsigned int c,std::string element);
254
 
                unsigned int getActiveForeground(unsigned int c,std::string element);
255
 
                unsigned int getBackground(unsigned int c,std::string element);
256
 
                unsigned int getFontColor(unsigned int c,std::string element);
257
 
                unsigned int getFontColor(std::string whichElement);
258
 
                unsigned int getElementInt(std::string element);
259
 
                unsigned int getElementInt(std::string element, std::string subelement);
260
 
                unsigned int getElementInt(std::string element, std::string subelement, std::string SUBsubsubelement);
261
 
        //n
262
 
                unsigned int numPanels();
263
 
        //s
264
 
                unsigned int splitColor(std::string color, int one_or_two);
265
 
                unsigned int switch_panel(Fl_Menu_Item *o);
266
 
 
267
 
//int///////////////////////////////////////////////////////////////////
268
 
                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);
269
 
                int addMenuItem(int menu, int item, Fl_Input* add_label, Fl_Input* add_icon, Fl_Input* add_input, Fl_Input* add_tooltip, Fl_Check_Button* add_button, std::string result);
270
 
                int addMenuAttrib(int whichMenu,std::string element,std::string attribute,const char *value);
271
 
                int addMenuAttrib(pugi::xml_node node,std::string element,std::string attribute,std::string value);
272
 
                int getIntAttribute(std::string element, std::string attribute);
273
 
                int getIntAttribute(std::string element, std::string subelement, std::string attribute);
274
 
                int JWMversion();
275
 
                int newStyle();
276
 
                int removeMenuItem(int menu, int item, int sub);
277
 
                int whichAlign(std::string align);
278
 
 
279
 
//float/////////////////////////////////////////////////////////////////
280
 
                float getElementFloat(std::string element);
281
 
                float getElementFloat(std::string element, std::string subelement);
282
 
                float getElementFloat(std::string element, std::string subelement, std::string SUBsubsubelement);
283
 
                float getOpacity(std::string element);
284
 
 
285
 
                //const double* getBoxColor(Fl_Box*o);
286
 
 
287
 
//Vector////////////////////////////////////////////////////////////////
288
 
                std::vector<std::string> AnythingVector(std::string element);
289
 
                std::vector<std::string> getActions();
290
 
                std::vector<std::string> getActionsDescriptions();
291
 
                std::vector<std::string> IconPaths();
292
 
                std::vector<std::string> Includes();
293
 
                std::vector<std::string> XDGautostart();
294
 
                std::vector<std::string> zoneSubdir(std::string thisDIR);
295
 
                std::vector<std::string> zoneVector();
296
 
 
297
 
 
298
 
//void//////////////////////////////////////////////////////////////////
299
 
        //A
300
 
                void addCursorsToBrowser(Fl_Browser *o);
301
 
        //C
302
 
                void cancel(bool Quit = true);
303
 
                void createElement(std::string element,std::string text);
304
 
                void changeElementText(std::string element,std::string text,std::string NEWTEXT);
305
 
        //D
306
 
                void debug_out(std::string msg);
307
 
                void deletePanelItem(int whichElement);
308
 
                void deleteShortcut(std::string program);
309
 
        //E
310
 
                void errorOUT(std::string msg);
311
 
        //G
312
 
                void getShortcuts(Fl_Browser *o);
313
 
        //H
314
 
                void hideWidgetForVersion(Fl_Widget *o, int version);
315
 
        //L
316
 
                void listAutostartXDG(Fl_Browser *o);
317
 
        //M
318
 
                void moveUp(int whichone);
319
 
                void moveDown(int whichone);
320
 
        //P
321
 
                void populateDesc(Fl_Browser *o);
322
 
                void populateOptions(Fl_Browser *o);
323
 
                void populateApps(Fl_Browser *o);
324
 
        //Q
325
 
                void quit();
326
 
        //R
327
 
                void removeElement(unsigned int whichMainElement, std::string element,std::string subelement,std::string text);
328
 
                void removeElement(unsigned int whichMainElement, std::string element,std::string subelement);
329
 
                void removeElement(unsigned int whichMainElement, std::string element);
330
 
                void removeElement(std::string element,std::string text);
331
 
                void removeElementHazy(std::string element,std::string text);
332
 
                void removeElementCompare2Attr(std::string element, std::string attribute, std::string value, std::string attribute2, std::string value2,std::string text);
333
 
                void removeXDGautostart(bool NOT, bool ONLY, bool DE, std::string filename, std::string env);
334
 
        //S
335
 
                void setRootMenuAttribute(std::string menustring ,std::string attribute,std::string value);
336
 
        //U
337
 
                void under_mouse(Fl_Window *o);
338
 
 
339
 
//pugixml/////////////////////////////////////////////////////////////
340
 
        //a
341
 
                pugi::xml_node addNextSubelement(std::string element);
342
 
                pugi::xml_node addNode(unsigned int whichElement,std::string element, std::string subelement);
343
 
                pugi::xml_node addNode(std::string element);
344
 
        //c
345
 
                pugi::xml_node checkIncludes(unsigned int whichOne,std::string element);
346
 
                pugi::xml_node checkIncludes(std::string element);
347
 
                pugi::xml_node checkIncludes(std::string element,std::string subelement);
348
 
                pugi::xml_node checkIncludes(std::string element,std::string subelement,std::string SUBsubelement);
349
 
                pugi::xml_node compareNode(std::string element, std::string attribute, std::string value, std::string attribute2, std::string value2,std::string text);
350
 
                pugi::xml_node compareNode(std::string element, std::string text, std::string attribute, std::string value, std::string attribute2, std::string value2, std::string attribute3, std::string value3);
351
 
        //g
352
 
                pugi::xml_node getCurrentTrayNode();
353
 
                pugi::xml_node getLastSubNode(unsigned int whichElement,std::string element, std::string subelement);
354
 
                pugi::xml_node getMenu(std::string text);
355
 
                pugi::xml_node getMenu(int whichMenu);
356
 
                pugi::xml_node getMenuButtonByMask(std::string text,int item);
357
 
                pugi::xml_node getNode(unsigned int whichElement,std::string element,unsigned int whichNODE);
358
 
                pugi::xml_node getNode(unsigned int whichElement,std::string element,unsigned int whichNODE, std::string subelement);
359
 
                pugi::xml_node getRootMenu(std::string text);
360
 
                pugi::xml_node getSubNode(unsigned int whichElement, pugi::xml_node inputnode);
361
 
                pugi::xml_node getSubNode(unsigned int whichElement,std::string element,unsigned int whichSubElement, std::string subelement);
362
 
                pugi::xml_node getTraySubElement(unsigned int whichElement);
363
 
        //p
364
 
                pugi::xml_node parseNodes(unsigned int whichElement,std::string element);
365
 
//variables/////////////////////////////////////////////////////////////
366
 
};
367
 
#endif