Skip to content

Commit f2f3698

Browse files
committed
Update to use new prefsclass functions
1 parent d628a93 commit f2f3698

File tree

10 files changed

+175
-321
lines changed

10 files changed

+175
-321
lines changed

LFSApplications/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.2.0
2+
Update to use new prefsclass functions.
23
Added killall docks to lfsappearance 'Apply'.
34
Added prelight colour to lfsdockprefs.
45
File dialog now goes to last valid folder selected.

LFSApplications/LFSApplications/src/lfsbackdropprefs.cpp

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
* along with LFSApplications. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
#include <getopt.h>
22-
2321
#include "config.h"
2422
#include <lfstk/LFSTKGlobals.h>
2523

@@ -252,43 +250,24 @@ void loadMonitorInfo(void)
252250

253251
int main(int argc, char **argv)
254252
{
255-
XEvent event;
256-
int sy=0;
257-
int c=0;
258-
int option_index=0;
259-
const char *shortOpts="h?w:";
260-
std::string bffr;
261-
262-
option longOptions[]=
263-
{
264-
{"window",1,0,'w'},
265-
{"help",0,0,'h'},
266-
{0, 0, 0, 0}
267-
};
268-
269-
while(1)
270-
{
271-
option_index=0;
272-
c=getopt_long_only(argc,argv,shortOpts,longOptions,&option_index);
273-
if (c==-1)
274-
break;
275-
switch (c)
276-
{
277-
case 'h':
278-
case '?':
279-
printf("-?,-h,--help\t\tPrint this help\n");
280-
printf("-w,--window\t\tSet transient for window\n");
281-
exit(0);
282-
case 'w':
283-
parentWindow=atoi(optarg);
284-
break;
285-
}
286-
}
253+
XEvent event;
254+
int sy=0;
255+
std::string bffr;
256+
LFSTK_prefsClass cliprefs("lfsbackdropprefs",VERSION);
257+
option longOptions[]={{"window",1,0,'w'},{0, 0, 0, 0}};
287258

288259
apc=new LFSTK_applicationClass();
289260
apc->LFSTK_addWindow(NULL,BOXLABEL,"LFSTKPrefs");
290261
wc=apc->mainWindow;
291262

263+
cliprefs.prefsMap=
264+
{
265+
{LFSTK_UtilityClass::LFSTK_hashFromKey("window"),{TYPEINT,"window","Set transient for window ARG","",false,0}}
266+
};
267+
if(cliprefs.LFSTK_argsToPrefs(argc,argv,longOptions,true)==false)
268+
return(1);
269+
parentWindow=cliprefs.LFSTK_getInt("window");
270+
292271
asprintf(&wd,"%s",apc->userHome);
293272
asprintf(&mainPrefs,"%s/lfssetwallpaper.rc",apc->configDir.c_str());
294273
asprintf(&monitorPrefs,"%s/lfsmonitors.rc",apc->configDir.c_str());

LFSApplications/LFSApplications/src/lfscolourchooser.cpp

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
*/
2020

2121
#include "config.h"
22-
#include <getopt.h>
2322
#include <sstream>
2423
#include <string>
2524
#include <iomanip>
@@ -137,42 +136,22 @@ bool doAlpha(void *p,void *ud)
137136

138137
int main(int argc, char **argv)
139138
{
140-
XEvent event;
141-
int sy=BORDER;
142-
143-
int c=0;
144-
int option_index=0;
145-
const char *shortOpts="h?w:";
146-
option longOptions[]=
147-
{
148-
{"window",1,0,'w'},
149-
{"help",0,0,'h'},
150-
{0, 0, 0, 0}
151-
};
152-
153-
while(1)
154-
{
155-
option_index=0;
156-
c=getopt_long_only(argc,argv,shortOpts,longOptions,&option_index);
157-
if (c==-1)
158-
break;
159-
switch (c)
160-
{
161-
case 'h':
162-
case '?':
163-
printf("Usage:\nlfscolourchooser [ARG] - Where ARG is a colour definition either e.g. \"#ff0080\" or \"darkgreen\"\n");
164-
printf("-?,-h,--help\t\tPrint this help\n");
165-
printf("-w,--window\t\tSet transient for window\n");
166-
exit(0);
167-
case 'w':
168-
parentWindow=atoi(optarg);
169-
break;
170-
}
171-
}
139+
XEvent event;
140+
int sy=BORDER;
141+
LFSTK_prefsClass cliprefs("lfspanelprefs",VERSION);
142+
option longOptions[]={{"window",1,0,'w'},{0, 0, 0, 0}};
172143

173144
apc=new LFSTK_applicationClass();
174145
apc->LFSTK_addWindow(NULL,BOXLABEL);
175146
wc=apc->mainWindow;
147+
148+
cliprefs.prefsMap=
149+
{
150+
{LFSTK_UtilityClass::LFSTK_hashFromKey("window"),{TYPEINT,"window","Set transient for window ARG","",false,0}}
151+
};
152+
if(cliprefs.LFSTK_argsToPrefs(argc,argv,longOptions,true)==false)
153+
return(1);
154+
parentWindow=cliprefs.LFSTK_getInt("window");
176155

177156
label=new LFSTK_labelClass(wc,BOXLABEL,BORDER,sy,DIALOGWIDTH-BORDER-BORDER,GADGETHITE);
178157
label->LFSTK_setCairoFontDataParts("sB",20);

LFSApplications/LFSApplications/src/lfsdesktopprefs.cpp

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
* along with LFSApplications. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
#include <getopt.h>
22-
2321
#include "config.h"
24-
#include "lfstk/LFSTKGlobals.h"
22+
#include <lfstk/LFSTKGlobals.h>
2523

2624
#include <libgen.h>
2725

@@ -197,39 +195,21 @@ int main(int argc, char **argv)
197195
XEvent event;
198196
int sy=0;
199197
std::string bffr;
200-
int c=0;
201-
int option_index=0;
202-
const char *shortOpts="h?w:";
203-
option longOptions[]=
204-
{
205-
{"window",1,0,'w'},
206-
{"help",0,0,'h'},
207-
{0, 0, 0, 0}
208-
};
209-
while(1)
210-
{
211-
option_index=0;
212-
c=getopt_long_only(argc,argv,shortOpts,longOptions,&option_index);
213-
if (c==-1)
214-
break;
215-
switch (c)
216-
{
217-
case 'h':
218-
case '?':
219-
printf("-?,-h,--help\t\tPrint this help\n");
220-
printf("-w,--window\t\tSet transient for window\n");
221-
printf("Right click in a colour edit box for a colour chooser.\n");
222-
exit(0);
223-
case 'w':
224-
parentWindow=atoi(optarg);
225-
break;
226-
}
227-
}
198+
LFSTK_prefsClass cliprefs("lfsdesktopprefs",VERSION);
199+
option longOptions[]={{"window",1,0,'w'},{0, 0, 0, 0}};
228200

229201
apc=new LFSTK_applicationClass();
230202
apc->LFSTK_addWindow(NULL,BOXLABEL,"LFSTKPrefs");
231203
wc=apc->mainWindow;
232204

205+
cliprefs.prefsMap=
206+
{
207+
{LFSTK_UtilityClass::LFSTK_hashFromKey("window"),{TYPEINT,"window","Set transient for window ARG","",false,0}}
208+
};
209+
if(cliprefs.LFSTK_argsToPrefs(argc,argv,longOptions,true)==false)
210+
return(1);
211+
parentWindow=cliprefs.LFSTK_getInt("window");
212+
233213
prefs.prefsMap=
234214
{
235215
{LFSTK_UtilityClass::LFSTK_hashFromKey("icontheme"),{TYPESTRING,"icontheme","","gnome",false,0}},

LFSApplications/LFSApplications/src/lfsdockprefs.cpp

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
*/
2020

2121
#include <string>
22-
#include <getopt.h>
2322

24-
#include "lfstk/LFSTKGlobals.h"
23+
#include "config.h"
24+
#include <lfstk/LFSTKGlobals.h>
2525

2626
#undef GADGETWIDTH
2727
#define GADGETWIDTH 128
@@ -289,43 +289,29 @@ int main(int argc, char **argv)
289289
{
290290
int sy=0;
291291
int parentWindow=-1;
292-
int c=0;
293-
int option_index=0;
294-
const char *shortOpts="h?w:";
292+
LFSTK_prefsClass cliprefs("lfsdockprefs",VERSION);
293+
295294
option longOptions[]=
296295
{
297296
{"window",1,0,'w'},
298-
{"dock",1,0,'d'},
299-
{"help",0,0,'h'},
297+
{"dockname",1,0,'d'},
300298
{0, 0, 0, 0}
301299
};
302300

303-
while(1)
304-
{
305-
option_index=0;
306-
c=getopt_long_only(argc,argv,shortOpts,longOptions,&option_index);
307-
if (c==-1)
308-
break;
309-
switch (c)
310-
{
311-
case 'h':
312-
case '?':
313-
printf("-?,-h,--help\t\tPrint this help\n");
314-
printf("-w,--window\t\tSet transient for window\n");
315-
exit(0);
316-
case 'w':
317-
parentWindow=atoi(optarg);
318-
break;
319-
case 'd':
320-
dockName=optarg;
321-
break;
322-
}
323-
}
324-
325301
apc=new LFSTK_applicationClass();
326302
apc->LFSTK_addWindow(NULL,BOXLABEL,"LFSTKPrefs");
327303
wc=apc->mainWindow;
328304

305+
cliprefs.prefsMap=
306+
{
307+
{LFSTK_UtilityClass::LFSTK_hashFromKey("window"),{TYPEINT,"window","Set transient for window ARG","",false,0}},
308+
{LFSTK_UtilityClass::LFSTK_hashFromKey("dockname"),{TYPESTRING,"dockname","Load prefs for dock ARG","",false,0}}
309+
};
310+
if(cliprefs.LFSTK_argsToPrefs(argc,argv,longOptions,true)==false)
311+
return(1);
312+
parentWindow=cliprefs.LFSTK_getInt("window");
313+
dockName=cliprefs.LFSTK_getString("dockname");
314+
329315
copyrite=new LFSTK_labelClass(wc,COPYRITE,BORDER,sy,DIALOGWIDTH-BORDER-BORDER,GADGETHITE);
330316
sy+=HALFYSPACING;
331317
personal=new LFSTK_labelClass(wc,PERSONAL,BORDER,sy,DIALOGWIDTH-BORDER-BORDER,GADGETHITE);

LFSApplications/LFSApplications/src/lfsfilechooser.cpp

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,62 +18,46 @@
1818
* along with LFSApplications. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
#include <getopt.h>
22-
2321
#include "config.h"
2422
#include <lfstk/LFSTKGlobals.h>
2523

2624
LFSTK_applicationClass *apc=NULL;
2725
LFSTK_windowClass *wc=NULL;
2826
LFSTK_fileDialogClass *filedialogfile;
2927
LFSTK_fileDialogClass *filedialogdir;
28+
LFSTK_prefsClass prefs("lfsfilechooser",VERSION);
3029

3130
bool showFolder=false;
3231
Window parentWindow=None;
3332
char *wd;
3433

35-
int main(int argc, char **argv)
34+
void setPrefs(void)
3635
{
37-
int c=0;
38-
int option_index=0;
39-
const char *shortOpts="fh?w:";
40-
int retval=1;
41-
42-
option longOptions[]=
36+
prefs.prefsMap=
4337
{
44-
{"window",1,0,'w'},
45-
{"folder",0,0,'f'},
46-
{"help",0,0,'h'},
47-
{0, 0, 0, 0}
38+
{LFSTK_UtilityClass::LFSTK_hashFromKey("window"),{TYPEINT,"window","Parent Window ARG","",false,0}},
39+
{LFSTK_UtilityClass::LFSTK_hashFromKey("folder"),{TYPEBOOL,"folder","Select folder","",false,0}},
4840
};
41+
}
4942

50-
while(1)
43+
int main(int argc, char **argv)
44+
{
45+
int retval=1;
46+
option longOptions[]=
5147
{
52-
option_index=0;
53-
c=getopt_long_only(argc,argv,shortOpts,longOptions,&option_index);
54-
if (c==-1)
55-
break;
56-
switch (c)
57-
{
58-
case 'f':
59-
showFolder=true;
60-
break;
61-
case 'h':
62-
case '?':
63-
printf("-?,-h,--help\t\tPrint this help\n");
64-
printf("-f,--folder\t\tSelect folder instead of file\n");
65-
printf("-w,--window\t\tSet transient for window\n");
66-
exit(0);
67-
case 'w':
68-
parentWindow=atoi(optarg);
69-
break;
70-
}
71-
}
48+
{"window",required_argument,0,'w'},
49+
{"folder",no_argument,0,'f'},
50+
{0, 0, 0, 0}
51+
};
7252

53+
setPrefs();
54+
if(prefs.LFSTK_argsToPrefs(argc,argv,longOptions,true)==false)
55+
return(1);
56+
parentWindow=prefs.LFSTK_getInt("window");
57+
showFolder=prefs.LFSTK_getBool("folder");
7358
apc=new LFSTK_applicationClass();
7459
apc->LFSTK_addWindow(NULL,"");
7560
wc=apc->mainWindow;
76-
wc->LFSTK_showWindow();
7761

7862
asprintf(&wd,"%s",apc->userHome.c_str());
7963
if(parentWindow!=None)

0 commit comments

Comments
 (0)