1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#include <tqfile.h>
#include <tqdir.h>
#include <kapplication.h>
#include <ksimpleconfig.h>
#include <kglobal.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kcmdlineargs.h>
#include <klocale.h>
static const char description[] =
I18N_NOOP("Installs a KWM theme");
static KCmdLineOptions options[] =
{
{ "+[file]", I18N_NOOP("Path to a theme config file"), 0 },
KCmdLineLastOption
};
void copy(const TQString &src, const TQString &dest)
{
TQFile copyInput(src);
TQFile copyOutput(dest);
if(!copyInput.open(IO_ReadOnly)){
kdWarning() << "Couldn't open " << src << endl;
return;
}
if(!copyOutput.open(IO_WriteOnly)){
kdWarning() << "Couldn't open " << dest << endl;
copyInput.close();
return;
}
while(!copyInput.atEnd()){
copyOutput.putch(copyInput.getch());
}
copyInput.close();
copyOutput.close();
}
int main(int argc, char **argv)
{
TDECmdLineArgs::init(argc, argv, "kwmtheme", description, "0.1");
TDECmdLineArgs::addCmdLineOptions( options );
TDEApplication app(argc, argv);
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
if(!args->count()){
kdWarning() << "You need to specify the path to a theme config file!" << endl;
return(1);
}
TQString srcStr = TQString(TQFile::decodeName(args->arg(0)));
TQFile f(srcStr);
TQString tmpStr;
if(!f.exists()){
kdWarning() << "Specified theme config file doesn't exist!" << endl;
return(2);
}
TQStringList appDirs = TDEGlobal::dirs()->findDirs("data", "twin");
TQString localDirStr = *(appDirs.end());
if(localDirStr.isEmpty()){
localDirStr = TDEGlobal::dirs()->saveLocation("data", "twin");
}
localDirStr += "/pics/";
if(!TQFile::exists(localDirStr))
TQDir().mkdir(localDirStr);
TQFileInfo fi(f);
KSimpleConfig input(fi.absFilePath());
srcStr = fi.dirPath(true) + "/";
TDEConfig *output = TDEGlobal::config();
input.setGroup("Window Border");
output->setGroup("General");
tmpStr = input.readEntry("shapePixmapTop");
if(!tmpStr.isEmpty()){
copy(srcStr+tmpStr, localDirStr+tmpStr);
}
output->writeEntry("wm_top", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapBottom");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottom", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_left", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_right", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapTopLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_topleft", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapTopRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_topright", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapBottomLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottomleft", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapBottomRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottomright", tmpStr, true, true);
input.setGroup("Window Titlebar");
output->writeEntry("TitleAlignment", input.readEntry("TitleAlignment"), true, true);
output->writeEntry("PixmapUnderTitleText", input.readEntry("PixmapUnderTitleText"), true, true);
output->writeEntry("TitleFrameShaded", input.readEntry("TitleFrameShaded"), true, true);
tmpStr = input.readEntry("MenuButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("menu", tmpStr, true, true);
tmpStr = input.readEntry("PinUpButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("pinup", tmpStr, true, true);
tmpStr = input.readEntry("PinDownButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("pindown", tmpStr, true, true);
tmpStr = input.readEntry("CloseButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("close", tmpStr, true, true);
tmpStr = input.readEntry("MaximizeButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("maximize", tmpStr, true, true);
tmpStr = input.readEntry("MaximizeDownButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("maximizedown", tmpStr, true, true);
tmpStr = input.readEntry("MinimizeButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("iconify", tmpStr, true, true);
tmpStr = input.readEntry("TitlebarPixmapActive");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("TitlebarPixmapActive", tmpStr, true, true);
tmpStr = input.readEntry("TitlebarPixmapInactive");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("TitlebarPixmapInactive", tmpStr, true, true);
input.setGroup("Window Button Layout");
output->setGroup("Buttons");
output->writeEntry("ButtonA", input.readEntry("ButtonA"), true, true);
output->writeEntry("ButtonB", input.readEntry("ButtonB"), true, true);
output->writeEntry("ButtonC", input.readEntry("ButtonC"), true, true);
output->writeEntry("ButtonD", input.readEntry("ButtonD"), true, true);
output->writeEntry("ButtonE", input.readEntry("ButtonE"), true, true);
output->writeEntry("ButtonF", input.readEntry("ButtonF"), true, true);
output->sync();
return(0);
}
|