1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
3 * This program is free software. It comes without any warranty, to
4 * the extent permitted by applicable law. You can redistribute it
5 * and/or modify it under the terms of the Do What The Fuck You Want
6 * To Public License, Version 2, as published by Sam Hocevar. See
7 * http://sam.zoy.org/wtfpl/COPYING for more details.
14 #include <QApplication>
15 #include <QStringList>
17 #include <QTextStream>
25 #include "xcrthemefx.h"
26 #include "xcrthemexp.h"
29 ///////////////////////////////////////////////////////////////////////////////
30 static XCursorTheme
*loadTheme (const QString
&fname
) {
33 if (fname
.endsWith(".CursorFX", Qt::CaseInsensitive
)) {
34 ct
= new XCursorThemeFX(fname
);
35 } else if (fname
.endsWith(".CurXPTheme", Qt::CaseInsensitive
)) {
36 ct
= new XCursorThemeXP(fname
);
39 if (ct
&& !ct
->count()) { delete ct
; ct
= 0; }
44 static void fixTextCodec () {
46 const char *ll
= getenv("LANG");
48 if (!ll
|| !ll
[0]) ll
= getenv("LC_CTYPE");
49 if (ll
&& ll
[0] && (strcasestr(ll
, "utf-8") || strcasestr(ll
, "utf8"))) return;
50 kc
= QTextCodec::codecForName("koi8-r");
52 QTextCodec::setCodecForCStrings(kc
);
53 QTextCodec::setCodecForLocale(kc
);
57 ///////////////////////////////////////////////////////////////////////////////
58 int main (int argc
, char *argv
[]) {
61 QApplication
app(argc
, argv
);
63 bool doPack
= false, doRemove
= false;
66 while (argNo
< argc
) {
67 if (!strcmp(argv
[argNo
], "-p")) doPack
= true;
68 else if (!strcmp(argv
[argNo
], "-P")) doPack
= doRemove
= true;
75 "usage: %s [-p] [-P] file [file...]\n"
76 " -p: pack converted theme\n"
77 " -P: pack converted theme and remove source\n"
85 while (argNo
< argc
) {
86 QString
fn(argv
[argNo
++]);
88 if (fi
.exists() && fi
.isReadable()) flist
<< fn
;
90 flist
.removeDuplicates();
92 foreach (const QString
&fn
, flist
) {
93 XCursorTheme
*ct
= loadTheme(fn
);
98 outFName
.truncate(outFName
.lastIndexOf('.'));
103 if (dd
.cd(outFName
)) {
108 if (!packXCursorTheme(outFName
+".tgz", dd
, outFName
, doRemove
)) {
109 fprintf(stderr
, "ERROR: can't pack theme %s!\n", outFName
.toLocal8Bit().constData());
111 printf("theme %s.tgz sucessfully created.\n", outFName
.toLocal8Bit().constData());