~israeldahl/jwm-settings-manager/trunk

« back to all changes in this revision

Viewing changes to src/flIcons.cpp

  • 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 tinyxml2 and FLTK
 
4
 *
 
5
 *         Copyright (C) 2014  Israel <israel@torios.org>
 
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
 * This has been developed by Israel<israel@torios.org>
 
20
 *
 
21
 *
 
22
 * You may redistribute this, but you must keep this comment in place
 
23
 * Jesus is my Lord, and if you don't like it feel free to ignore it.
 
24
 */
 
25
#include "flIcons.h"
 
26
 
 
27
flIcons::flIcons()
 
28
{
 
29
    std::string icons = "icons";
 
30
    std::string configPath = ".jwm/";
 
31
    setFileName(icons);
 
32
    tinyxml2::XMLDocument doc;
 
33
    homePath(file);
 
34
    homePathTemp(file);
 
35
    ///what will be the default Icon set here??
 
36
    std::string recoveryFileText ="<?xml version=\"1.0\"?>\n\
 
37
      <JWM>\n\
 
38
      <IconPath>"+ homePathNoFile() + configPath + "Moka/32x32/apps</IconPath>\n\
 
39
          <IconPath>" + homePathNoFile() + configPath + "Moka/32x32/actions</IconPath>\n\
 
40
          <IconPath>"+ homePathNoFile() + configPath +"</IconPath>\n\
 
41
          <IconPath>/usr/share/pixmaps</IconPath>\n\
 
42
      </JWM>";
 
43
    setRecoveryText(recoveryFileText);
 
44
}
 
45
 
 
46
flIcons::~flIcons()
 
47
{
 
48
    //dtor
 
49
}
 
50
 
 
51
void flIcons::addIcons(const char* path){
 
52
    tinyxml2::XMLNode *iconNode = doc.FirstChildElement( "JWM" );
 
53
    tinyxml2::XMLNode *node = doc.NewElement("IconPath");
 
54
    iconNode->InsertEndChild(node);
 
55
    tinyxml2::XMLText *icons = doc.NewText(path);
 
56
    node->LinkEndChild(icons);
 
57
    saveChangesTemp();
 
58
}
 
59
 
 
60
void flIcons::getIcons(Fl_Browser *o){
 
61
 for(const tinyxml2::XMLElement* node=doc.FirstChildElement("JWM")->FirstChildElement("IconPath");node;node=node->NextSiblingElement()){
 
62
        std::string value  = node->GetText();
 
63
        if(value.c_str() !=NULL){
 
64
            const char * v = value.c_str();
 
65
            o->add(v);
 
66
        }
 
67
        //std::cout<<value<<std::endl;
 
68
    }
 
69
}
 
70
 
 
71
void flIcons::removeIcons(const char * icons){
 
72
for(tinyxml2::XMLElement* node=doc.FirstChildElement("JWM")->FirstChildElement("IconPath");node;node=node->NextSiblingElement()){
 
73
        std::string fromDoc = node->GetText();
 
74
        unsigned found = fromDoc.find_last_of(" ");
 
75
        fromDoc = fromDoc.erase(0,found+1);
 
76
        const char* value  = fromDoc.c_str();
 
77
        std::string fromProgram = icons;
 
78
        //std::cout<<"Value: "<<value<<" Icons: "<<icons<<std::endl;
 
79
        if(fromProgram.compare(value) ==0){
 
80
            node->DeleteChild(node);
 
81
            //std::cout<<"deleted "<<icons<<std::endl;
 
82
        }
 
83
 
 
84
    }
 
85
    saveChangesTemp();
 
86
}