2 #include <X11/keysym.h>
3 #include <WINGs/WINGsP.h>
11 #define WIN_HEIGHT 322
14 #define TABVIEW_HEIGHT WIN_HEIGHT-50
15 #define TABVIEW_WIDTH WIN_WIDTH-PADX*2
25 /* Nickname for mount point */
42 typedef struct _DISK Disc
;
44 static FSPreferencesPanel
*FSCreatePreferencesPanel(FSViewer
*, char*);
45 static void FSClosePreferencesPanel(WMWidget
*, void*);
46 static void FSDestroyPreferencesPanel(FSPreferencesPanel
*);
47 static void createVarsTab(FSPreferencesPanel
*prefs
);
48 static void createDiskTab(FSPreferencesPanel
*prefs
);
49 static void createTypesTab(FSPreferencesPanel
*prefs
);
50 static void genericListClick(WMWidget
*self
, void *data
);
51 static void genericButtonActionHandler(WMWidget
*self
, void *clientData
);
52 static void setVarsImage(WMWidget
*self
, void *data
);
53 static void populateVarsTab(FSPreferencesPanel
*prefs
);
54 static void populateTypesTab(FSPreferencesPanel
*prefs
);
55 static void populateDisksTab(FSPreferencesPanel
*prefs
);
56 static void populateDisksFields(FSPreferencesPanel
*prefs
);
57 static void populateAppsFields(FSPreferencesPanel
*prefs
);
58 static void populateTypesFields(FSPreferencesPanel
*prefs
);
59 static void applyBtnCB(WMWidget
*self
, void *client
);
60 static void tfDidChange(struct WMTextFieldDelegate
*self
,
61 WMNotification
*notif
);
62 static void setTFDelegate(FSPreferencesPanel
*prefs
, WMTextField
*tf
);
63 static void setTVIDelegate(FSPreferencesPanel
*prefs
, WMTabView
*tv
);
64 static void tvDidSelectItem(struct WMTabViewDelegate
*self
,
65 WMTabView
*tabView
, WMTabViewItem
*item
);
66 static void saveTab(FSPreferencesPanel
*prefs
, int tabID
);
67 static void saveVarsTab(FSPreferencesPanel
*prefs
);
68 static void saveAppsTab(FSPreferencesPanel
*prefs
);
69 static void saveDiscsTab(FSPreferencesPanel
*prefs
);
70 static void saveAllTabsAndClose(WMWidget
*self
, void *client
);
71 static void genericListDrawProc(WMList
*lPtr
, int index
, Drawable d
,
72 char *text
, int state
, WMRect
*rect
);
76 static FSPreferencesPanel
*preferences
= NULL
;
78 void FSRunPreferencesPanel(FSViewer
*app
, char *title
)
83 if (!(preferences
= FSCreatePreferencesPanel(app
, title
))) { return; }
85 WMMapWidget(preferences
->win
);
87 while (!(preferences
->flags
.done
))
91 WMNextEvent(preferences
->dpy
, &event
);
92 WMHandleEvent(&event
);
94 FSDestroyPreferencesPanel(preferences
);
98 static FSPreferencesPanel
*FSCreatePreferencesPanel(FSViewer
*app
, char *title
)
100 FSPreferencesPanel
*prefs
;
101 int height
, width
, offset
;
107 /* allocate memory for the prefernces panel */
108 if (!( prefs
= (FSPreferencesPanel
*)malloc(sizeof(FSPreferencesPanel
))))
112 memset((void *) prefs
, 0, sizeof(FSPreferencesPanel
));
114 /* Take in some settings */
116 prefs
->scr
= FSGetFSViewerScreen(app
);
117 prefs
->dpy
= WMScreenDisplay(prefs
->scr
);
123 prefs
->win
= WMCreateWindow(prefs
->scr
, "prefs");
124 WMResizeWidget(prefs
->win
, width
, height
);
125 WMSetWindowTitle(prefs
->win
, title
);
126 WMSetWindowCloseAction(prefs
->win
, FSClosePreferencesPanel
,
129 prefs
->frame
= WMCreateFrame(prefs
->win
);
130 WMResizeWidget(prefs
->frame
, width
, height
);
131 WMMoveWidget(prefs
->frame
, 0, 0);
132 WMSetFrameRelief(prefs
->frame
, WRFlat
);
134 prefs
->tabV
= WMCreateTabView(prefs
->frame
);
135 WMMoveWidget(prefs
->tabV
, 5, 5);
136 WMResizeWidget(prefs
->tabV
, TABVIEW_WIDTH
, TABVIEW_HEIGHT
);
137 setTVIDelegate(prefs
, prefs
->tabV
);
140 createVarsTab(prefs
);
141 populateVarsTab(prefs
);
143 /* App/File Types Tab*/
144 createTypesTab(prefs
);
145 populateTypesTab(prefs
);
148 createDiskTab(prefs
);
149 populateDisksTab(prefs
);
151 /* Ok/Apply/Cancel Buttons */
152 prefs
->cancelBtn
= WMCreateCommandButton(prefs
->frame
);
153 WMSetButtonText(prefs
->cancelBtn
, _("Cancel"));
154 WMResizeWidget(prefs
->cancelBtn
, 100, 24);
155 WMMoveWidget(prefs
->cancelBtn
,
156 WIN_WIDTH
-330, (WIN_HEIGHT
+PADY
+TABVIEW_HEIGHT
-24)/2);
157 WMSetButtonAction(prefs
->cancelBtn
, FSClosePreferencesPanel
, prefs
);
158 WMMapWidget(prefs
->cancelBtn
);
160 prefs
->applyBtn
= WMCreateCommandButton(prefs
->frame
);
161 WMSetButtonText(prefs
->applyBtn
, _("Apply"));
162 WMResizeWidget(prefs
->applyBtn
, 100, 24);
163 WMMoveWidget(prefs
->applyBtn
,
164 WIN_WIDTH
-215, (WIN_HEIGHT
+PADY
+TABVIEW_HEIGHT
-24)/2);
165 WMSetButtonAction(prefs
->applyBtn
, applyBtnCB
, prefs
);
166 WMSetButtonEnabled(prefs
->applyBtn
, False
);
167 WMMapWidget(prefs
->applyBtn
);
169 prefs
->okBtn
= WMCreateCommandButton(prefs
->frame
);
170 WMSetButtonText(prefs
->okBtn
, _("OK"));
171 WMResizeWidget(prefs
->okBtn
, 100, 24);
172 WMMoveWidget(prefs
->okBtn
,
173 WIN_WIDTH
-105, (WIN_HEIGHT
+PADY
+TABVIEW_HEIGHT
-24)/2);
174 WMSetButtonAction(prefs
->okBtn
, saveAllTabsAndClose
, prefs
);
175 WMSetButtonEnabled(prefs
->okBtn
, False
);
176 WMMapWidget(prefs
->okBtn
);
178 prefs
->flags
.done
= 0;
179 prefs
->flags
.evars
= False
;
180 prefs
->flags
.eapps
= False
;
181 prefs
->flags
.ediscs
= False
;
183 WMRealizeWidget(prefs
->win
);
185 FSAddWindow(prefs
->app
, WMWidgetXID(prefs
->win
));
186 WMMapSubwidgets(prefs
->frame
);
187 WMMapSubwidgets(prefs
->win
);
193 createDiskTab(FSPreferencesPanel
*prefs
)
202 int frame_width
= 255;
203 int frame_height
= 220;
204 int padx
= (TABVIEW_WIDTH
-PADX
*8-frame_width
*2);
205 WMTextFieldDelegate
*delegate
= NULL
;
206 f
= WMCreateFrame(prefs
->frame
);
207 WMSetFrameRelief(f
, WRFlat
);
210 f2
= WMCreateFrame(f
);
211 WMSetFrameRelief(f2
, WRGroove
);
212 WMSetFrameTitle(f2
, _(" Disks "));
213 WMMoveWidget(f2
, PADX
*2, 10);
214 WMResizeWidget(f2
, TABVIEW_WIDTH
-23, frame_height
);
217 list
= WMCreateList(f2
);
218 WMMoveWidget(list
, 10, 30);
219 WMResizeWidget(list
, frame_width
-20, 100);
220 WMSetListAction(list
, genericListClick
, prefs
);
222 prefs
->disksList
= list
;
224 l
= WMCreateLabel(f2
);
225 WMResizeWidget(l
, 45, 18);
226 WMMoveWidget(l
, 10, 140);
227 WMSetLabelText(l
, _("Name:"));
228 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
231 tf
= WMCreateTextField(f2
);
232 WMResizeWidget(tf
, 110, 18);
233 WMMoveWidget(tf
, 50, 140);
234 WMSetTextFieldText(tf
, _("Menu Name"));
235 setTFDelegate(prefs
, tf
);
237 prefs
->disksNameTF
= tf
;
240 l
= WMCreateLabel(f2
);
241 WMResizeWidget(l
, 45, 18);
242 WMMoveWidget(l
, 10, 166);
243 WMSetLabelText(l
, _("Mnt:"));
244 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
247 tf
= WMCreateTextField(f2
);
248 WMResizeWidget(tf
, 110, 18);
249 WMMoveWidget(tf
, 50, 166);
250 WMSetTextFieldText(tf
, _("Mount Point"));
251 /* WMSetTextFieldDelegate(tPtr, delegate); */
252 setTFDelegate(prefs
, tf
);
254 prefs
->disksMntTF
= tf
;
257 l
= WMCreateLabel(f2
);
258 WMResizeWidget(l
, 45, 18);
259 WMMoveWidget(l
, 10, 192);
260 WMSetLabelText(l
, _("Dev:"));
261 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
264 tf
= WMCreateTextField(f2
);
265 WMResizeWidget(tf
, 110, 18);
266 WMMoveWidget(tf
, 50, 192);
267 WMSetTextFieldText(tf
, _("Device"));
268 setTFDelegate(prefs
, tf
);
269 /* WMSetTextFieldDelegate(tPtr, delegate); */
271 prefs
->disksDevTF
= tf
;
274 b
= WMCreateCommandButton(f2
);
275 WMResizeWidget(b
, 68, 18);
276 WMMoveWidget(b
, 175, 140);
277 WMSetButtonText(b
, _("New"));
278 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
280 prefs
->disksNewBtn
= b
;
283 b
= WMCreateCommandButton(f2
);
284 WMResizeWidget(b
, 68, 18);
285 WMMoveWidget(b
, 175, 166);
286 WMSetButtonText(b
, _("Update"));
287 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
289 prefs
->disksUpdateBtn
= b
;
292 b
= WMCreateCommandButton(f2
);
293 WMResizeWidget(b
, 68, 18);
294 WMMoveWidget(b
, 175, 192);
295 WMSetButtonText(b
, _("Remove"));
296 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
298 prefs
->disksRemoveBtn
= b
;
303 /* f2 = WMCreateFrame(f); */
304 /* WMSetFrameRelief(f2, WRGroove); */
305 /* WMSetFrameTitle(f2, " Commands "); */
306 /* WMMoveWidget(f2, frame_width+PADX*2+padx, 10); */
307 /* WMResizeWidget(f2, frame_width, frame_height); */
308 /* WMMapWidget(f2); */
310 l
= WMCreateLabel(f2
);
311 WMResizeWidget(l
, frame_width
-20, 18);
312 WMMoveWidget(l
, frame_width
+PADX
*2+padx
+10, 30);
313 WMSetLabelText(l
, _("Mount:"));
314 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
317 tf
= WMCreateTextField(f2
);
318 WMResizeWidget(tf
, frame_width
-20, 18);
319 WMMoveWidget(tf
, frame_width
+PADX
*2+padx
+10, 48);
320 WMSetTextFieldText(tf
, _("App"));
321 /* WMSetTextFieldDelegate(tPtr, delegate); */
322 setTFDelegate(prefs
, tf
);
324 prefs
->cmdMntTF
= tf
;
327 l
= WMCreateLabel(f2
);
328 WMResizeWidget(l
, frame_width
-20, 18);
329 WMMoveWidget(l
, frame_width
+PADX
*2+padx
+10, 76);
330 WMSetLabelText(l
, _("Unmount:"));
331 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
334 tf
= WMCreateTextField(f2
);
335 WMResizeWidget(tf
, frame_width
-20, 18);
336 WMMoveWidget(tf
, frame_width
+PADX
*2+padx
+10, 94);
337 WMSetTextFieldText(tf
, _("App"));
338 /* WMSetTextFieldDelegate(tPtr, delegate); */
339 setTFDelegate(prefs
, tf
);
341 prefs
->cmdUMntTF
= tf
;
344 l
= WMCreateLabel(f2
);
345 WMResizeWidget(l
, frame_width
-20, 18);
346 WMMoveWidget(l
, frame_width
+PADX
*2+padx
+10, 122);
347 WMSetLabelText(l
, _("Eject:"));
348 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
351 tf
= WMCreateTextField(f2
);
352 WMResizeWidget(tf
, frame_width
-20, 18);
353 WMMoveWidget(tf
, frame_width
+PADX
*2+padx
+10, 140);
354 WMSetTextFieldText(tf
, _("App"));
355 /* WMSetTextFieldDelegate(tPtr, delegate); */
356 setTFDelegate(prefs
, tf
);
358 prefs
->cmdEjectTF
= tf
;
361 l
= WMCreateLabel(f2
);
362 WMResizeWidget(l
, frame_width
-20, 18);
363 WMMoveWidget(l
, frame_width
+PADX
*2+padx
+10, 168);
364 WMSetLabelText(l
, _("Close:"));
365 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
368 tf
= WMCreateTextField(f2
);
369 WMResizeWidget(tf
, frame_width
-20, 18);
370 WMMoveWidget(tf
, frame_width
+PADX
*2+padx
+10, 186);
371 WMSetTextFieldText(tf
, _("close tray"));
372 /* WMSetTextFieldDelegate(tPtr, delegate); */
373 setTFDelegate(prefs
, tf
);
375 prefs
->cmdCloseTF
= tf
;
378 tab
= WMCreateTabViewItemWithIdentifier(DISCS_TAB
);
379 WMSetTabViewItemView(tab
, WMWidgetView(f
));
380 WMAddItemInTabView(prefs
->tabV
, tab
);
381 WMSetTabViewItemLabel(tab
, _("Disks"));
385 createTypesTab(FSPreferencesPanel
*prefs
)
394 int frame_width
= 255;
395 int frame_height
= 220;
396 int padx
= (TABVIEW_WIDTH
-PADX
*4-frame_width
*2);
398 f
= WMCreateFrame(prefs
->frame
);
399 WMSetFrameRelief(f
, WRFlat
);
402 f2
= WMCreateFrame(f
);
403 WMSetFrameRelief(f2
, WRGroove
);
404 WMSetFrameTitle(f2
, _(" Applications "));
405 WMMoveWidget(f2
, PADX
*2, 10);
406 WMResizeWidget(f2
, frame_width
, frame_height
);
409 list
= WMCreateList(f2
);
410 WMMoveWidget(list
, 10, 30);
411 WMResizeWidget(list
, frame_width
-100, 100);
412 WMSetListAction(list
, genericListClick
, prefs
);
413 WMSetListUserDrawProc(list
, genericListDrawProc
);
415 prefs
->appsList
= list
;
417 b
= WMCreateCommandButton(f2
);
418 WMMoveWidget(b
, 175, 46);
419 WMResizeWidget(b
, 68, 68);
420 WMSetButtonEnabled(b
, True
);
421 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
422 WMSetButtonImagePosition(b
, WIPImageOnly
);
424 prefs
->appsIconBtn
= b
;
427 l
= WMCreateLabel(f2
);
428 WMResizeWidget(l
, 40, 18);
429 WMMoveWidget(l
, 10, 140);
430 WMSetLabelText(l
, _("Exec:"));
431 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
434 tf
= WMCreateTextField(f2
);
435 WMResizeWidget(tf
, 115, 18);
436 WMMoveWidget(tf
, 50, 140);
437 WMSetTextFieldText(tf
, _("App"));
438 /* WMSetTextFieldDelegate(tPtr, delegate); */
439 setTFDelegate(prefs
, tf
);
441 prefs
->appsExecTF
= tf
;
444 b
= WMCreateCommandButton(f2
);
445 WMResizeWidget(b
, 68, 18);
446 WMMoveWidget(b
, 175, 140);
447 WMSetButtonText(b
, _("Browse..."));
448 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
450 prefs
->appsBrowseBtn
= b
;
453 b
= WMCreateCommandButton(f2
);
454 WMResizeWidget(b
, 73, 18);
455 WMMoveWidget(b
, 10, 166);
456 WMSetButtonText(b
, _("Set"));
457 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
459 prefs
->appsSetBtn
= b
;
461 b
= WMCreateCommandButton(f2
);
462 WMResizeWidget(b
, 73, 18);
463 WMMoveWidget(b
, 93, 166);
464 WMSetButtonText(b
, _("Delete"));
465 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
467 prefs
->appsRemoveBtn
= b
;
470 /* Start File Types */
471 f2
= WMCreateFrame(f
);
472 WMSetFrameRelief(f2
, WRGroove
);
473 WMSetFrameTitle(f2
, _(" File Types "));
474 WMMoveWidget(f2
, frame_width
+PADX
*2+padx
, 10);
475 WMResizeWidget(f2
, frame_width
, frame_height
);
478 list
= WMCreateList(f2
);
479 WMMoveWidget(list
, 10, 30);
480 WMResizeWidget(list
, frame_width
-100, 100);
481 WMSetListAction(list
, genericListClick
, prefs
);
482 WMSetListUserDrawProc(list
, genericListDrawProc
);
484 prefs
->typesList
= list
;
487 b
= WMCreateCommandButton(f2
);
488 WMMoveWidget(b
, 175, 46);
489 WMResizeWidget(b
, 68, 68);
490 WMSetButtonEnabled(b
, True
);
491 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
492 WMSetButtonImagePosition(b
, WIPImageOnly
);
494 prefs
->typesIconBtn
= b
;
497 l
= WMCreateLabel(f2
);
498 WMResizeWidget(l
, 40, 18);
499 WMMoveWidget(l
, 10, 140);
500 WMSetLabelText(l
, _("View:"));
501 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
504 tf
= WMCreateTextField(f2
);
505 WMResizeWidget(tf
, 115, 18);
506 WMMoveWidget(tf
, 50, 140);
507 WMSetTextFieldText(tf
, _("App"));
508 /* WMSetTextFieldDelegate(tPtr, delegate); */
509 setTFDelegate(prefs
, tf
);
511 prefs
->typesViewTF
= tf
;
514 b
= WMCreateCommandButton(f2
);
515 WMResizeWidget(b
, 68, 18);
516 WMMoveWidget(b
, 175, 140);
517 WMSetButtonText(b
, _("Browse..."));
518 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
520 /* Could use WMHangData instead!!! */
521 prefs
->typesViewBrowseBtn
= b
;
523 l
= WMCreateLabel(f2
);
524 WMResizeWidget(l
, 40, 18);
525 WMMoveWidget(l
, 10, 166);
526 WMSetLabelText(l
, _("Edit:"));
527 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
530 tf
= WMCreateTextField(f2
);
531 WMResizeWidget(tf
, 115, 18);
532 WMMoveWidget(tf
, 50, 166);
533 WMSetTextFieldText(tf
, _("App"));
534 /* WMSetTextFieldDelegate(tPtr, delegate); */
535 setTFDelegate(prefs
, tf
);
537 prefs
->typesEditTF
= tf
;
540 b
= WMCreateCommandButton(f2
);
541 WMResizeWidget(b
, 68, 18);
542 WMMoveWidget(b
, 175, 166);
543 WMSetButtonText(b
, _("Browse..."));
544 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
546 prefs
->typesEditBrowseBtn
= b
;
549 b
= WMCreateCommandButton(f2
);
550 WMResizeWidget(b
, 73, 18);
551 WMMoveWidget(b
, 10, 192);
552 WMSetButtonText(b
, _("Set"));
553 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
555 prefs
->typesSetBtn
= b
;
557 b
= WMCreateCommandButton(f2
);
558 WMResizeWidget(b
, 73, 18);
559 WMMoveWidget(b
, 93, 192);
560 WMSetButtonText(b
, _("Delete"));
561 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
563 prefs
->typesRemoveBtn
= b
;
564 /* End Executables */
567 tab
= WMCreateTabViewItemWithIdentifier(APPS_TAB
);
568 WMSetTabViewItemView(tab
, WMWidgetView(f
));
569 WMAddItemInTabView(prefs
->tabV
, tab
);
570 WMSetTabViewItemLabel(tab
, _("App/File Types"));
575 createVarsTab(FSPreferencesPanel
*prefs
)
584 int frame_width
= 155;
585 int frame_height
= 220;
586 int padx
= (TABVIEW_WIDTH
-PADX
*4-frame_width
*3)/2;
588 f
= WMCreateFrame(prefs
->frame
);
589 WMSetFrameRelief(f
, WRFlat
);
592 f2
= WMCreateFrame(f
);
593 WMSetFrameRelief(f2
, WRGroove
);
594 WMSetFrameTitle(f2
, _(" Images "));
595 WMMoveWidget(f2
, PADX
*2, 10);
596 WMResizeWidget(f2
, frame_width
, frame_height
);
599 list
= WMCreateList(f2
);
600 WMMoveWidget(list
, 10, 30);
601 WMResizeWidget(list
, frame_width
-20, 100);
602 WMSetListAction(list
, genericListClick
, prefs
);
604 prefs
->imgList
= list
;
607 b
= WMCreateCommandButton(f2
);
608 WMMoveWidget(b
, (frame_width
-68)/2, 140);
609 WMResizeWidget(b
, 68, 68);
610 WMSetButtonEnabled(b
, True
);
611 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
612 WMSetButtonImagePosition(b
, WIPImageOnly
);
614 prefs
->imgIconBtn
= b
;
617 /* Start Executables */
618 f2
= WMCreateFrame(f
);
619 WMSetFrameRelief(f2
, WRGroove
);
620 WMSetFrameTitle(f2
, _(" Executables "));
621 WMMoveWidget(f2
, frame_width
+PADX
*2+padx
, 10);
622 WMResizeWidget(f2
, frame_width
, frame_height
);
625 list
= WMCreateList(f2
);
626 WMMoveWidget(list
, 10, 30);
627 WMResizeWidget(list
, frame_width
-20, 100);
628 WMSetListAction(list
, genericListClick
, prefs
);
630 prefs
->execList
= list
;
633 l
= WMCreateLabel(f2
);
634 WMMoveWidget(l
, 10, 140);
635 WMResizeWidget(l
, frame_width
-20, 18);
636 WMSetLabelText(l
, _("Exec Str:"));
637 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
640 tf
= WMCreateTextField(f2
);
641 WMMoveWidget(tf
, 10, 160);
642 WMResizeWidget(tf
, frame_width
-20, 18);
643 WMSetTextFieldText(tf
, _("Exes:"));
644 /* WMSetTextFieldDelegate(tPtr, delegate); */
645 setTFDelegate(prefs
, tf
);
650 b
= WMCreateCommandButton(f2
);
651 WMResizeWidget(b
, 80, 18);
652 WMMoveWidget(b
, (frame_width
-80)/2, 188);
653 WMSetButtonText(b
, _("Set"));
654 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
656 prefs
->execSetBtn
= b
;
657 /* End Executables */
660 f2
= WMCreateFrame(f
);
661 WMSetFrameRelief(f2
, WRGroove
);
662 WMSetFrameTitle(f2
, _(" Display "));
663 WMMoveWidget(f2
, PADX
*2+frame_width
*2+padx
*2, 10);
664 WMResizeWidget(f2
, frame_width
, frame_height
);
667 list
= WMCreateList(f2
);
668 WMMoveWidget(list
, 10, 30);
669 WMResizeWidget(list
, frame_width
-20, 100);
670 WMSetListAction(list
, genericListClick
, prefs
);
672 prefs
->dpyList
= list
;
675 l
= WMCreateLabel(f2
);
676 WMMoveWidget(l
, 10, 140);
677 WMResizeWidget(l
, frame_width
-20, 18);
678 WMSetLabelText(l
, _("Display:"));
679 WMSetLabelTextColor(l
, WMDarkGrayColor(prefs
->scr
));
682 tf
= WMCreateTextField(f2
);
683 WMMoveWidget(tf
, 10, 160);
684 WMResizeWidget(tf
, frame_width
-20, 18);
685 WMSetTextFieldText(tf
, _("Display"));
686 /* WMSetTextFieldDelegate(tPtr, delegate); */
687 setTFDelegate(prefs
, tf
);
692 b
= WMCreateCommandButton(f2
);
693 WMResizeWidget(b
, 80, 18);
694 WMMoveWidget(b
, (frame_width
-80)/2, 188);
695 WMSetButtonText(b
, _("Set"));
696 WMSetButtonAction(b
, genericButtonActionHandler
, prefs
);
698 prefs
->dpySetBtn
= b
;
701 tab
= WMCreateTabViewItemWithIdentifier(VARS_TAB
);
702 WMSetTabViewItemView(tab
, WMWidgetView(f
));
703 WMAddItemInTabView(prefs
->tabV
, tab
);
704 WMSetTabViewItemLabel(tab
, _("Variables"));
709 populateVarsTab(FSPreferencesPanel
*prefs
)
713 item
= WMAddListItem(prefs
->imgList
, "ROOT");
715 item
->clientData
= FSGetStringForNameKey("ROOT", "icon");
717 item
= WMAddListItem(prefs
->imgList
, "DIRECTORY");
719 item
->clientData
= FSGetStringForName("DIRECTORY");
721 item
= WMAddListItem(prefs
->imgList
, "DEFAULT_IMG");
723 item
->clientData
= FSGetStringForName("DEFAULT_IMG");
725 item
= WMAddListItem(prefs
->imgList
, "HOME");
727 item
->clientData
= FSGetStringForName("HOME");
729 item
= WMAddListItem(prefs
->execList
, "CONSOLE");
731 item
->clientData
= FSGetStringForNameKey("CONSOLE", "exec");
733 item
= WMAddListItem(prefs
->execList
, "PROCESS");
735 item
->clientData
= FSGetStringForNameKey("PROCESS", "exec");
737 item
= WMAddListItem(prefs
->execList
, "MAGICASCII");
739 item
->clientData
= FSGetStringForNameKey("MAGICASCII", "exec");
741 item
= WMAddListItem(prefs
->execList
, "MAGICIMAGE");
743 item
->clientData
= FSGetStringForNameKey("MAGICIMAGE", "exec");
745 item
= WMAddListItem(prefs
->execList
, "MAGICPS");
747 item
->clientData
= FSGetStringForNameKey("MAGICPS", "exec");
749 item
= WMAddListItem(prefs
->dpyList
, "ColumnWidth");
754 sprintf(buf
, "%d", FSGetIntegerForName("ColumnWidth"));
755 item
->clientData
= wstrdup(buf
);
758 /* item = WMAddListItem(prefs->dpyList, "IconWidth"); */
763 /* sprintf(buf, "%d", WMGetIntegerForKey(defaultsDB, "IconWidth")); */
764 /* item->clientData = wstrdup(buf); */
767 item
= WMAddListItem(prefs
->dpyList
, "ICONDIR");
769 item
->clientData
= FSGetStringForName("ICONDIR");
771 item
= WMAddListItem(prefs
->dpyList
, "SortDisplay");
776 sprintf(buf
, "%d", FSGetIntegerForName("SortDisplay"));
777 item
->clientData
= wstrdup(buf
);
780 item
= WMAddListItem(prefs
->dpyList
, "SortOrder");
785 sprintf(buf
, "%d", FSGetIntegerForName("SortOrder"));
786 item
->clientData
= wstrdup(buf
);
789 item
= WMAddListItem(prefs
->dpyList
, "DisplaySVBG");
794 sprintf(buf
, "%d", FSGetIntegerForName("DisplaySVBG"));
795 item
->clientData
= wstrdup(buf
);
798 item
= WMAddListItem(prefs
->dpyList
, "DisplayMCListPixmap");
803 sprintf(buf
, "%d", FSGetIntegerForName("DisplayMCListPixmap"));
804 item
->clientData
= wstrdup(buf
);
806 WMSortListItems(prefs
->imgList
);
807 WMSortListItems(prefs
->execList
);
808 WMSortListItems(prefs
->dpyList
);
813 populateTypesTab(FSPreferencesPanel
*prefs
)
816 WMListItem
*item
= NULL
;
817 WMPropList
* array
= NULL
;
818 WMPropList
* element
= NULL
;
820 WMClearList(prefs
->typesList
);
821 WMSetTextFieldText(prefs
->appsExecTF
, "");
822 WMSetButtonImage(prefs
->appsIconBtn
, NULL
);
824 WMClearList(prefs
->appsList
);
825 WMSetTextFieldText(prefs
->typesViewTF
, "");
826 WMSetTextFieldText(prefs
->typesEditTF
, "");
827 WMSetButtonImage(prefs
->typesIconBtn
, NULL
);
829 array
= FSGetUDObjectForKey(defaultsDB
, "EXTN");
830 if (array
&& WMIsPLArray(array
))
833 numElem
= WMGetPropListItemCount(array
);
834 for(i
= 0; i
< numElem
; i
++)
836 element
= WMGetFromPLArray(array
, i
);
840 char *str
= WMGetPropListDescription(element
, False
);
843 item
= WMAddListItem(prefs
->typesList
, str
);
849 WMPropList
* tmp
= NULL
;
851 tmp
= FSGetUDObjectForKey(defaultsDB
, str
);
853 item
->clientData
= WMDeepCopyPropList(tmp
);
861 array
= FSGetUDObjectForKey(defaultsDB
, "EXE");
862 if (array
&& WMIsPLArray(array
))
864 numElem
= WMGetPropListItemCount(array
);
865 for(i
= 0; i
< numElem
; i
++)
867 element
= WMGetFromPLArray(array
, i
);
871 char *str
= WMGetPropListDescription(element
, False
);
874 item
= WMAddListItem(prefs
->appsList
, str
);
880 WMPropList
* tmp
= NULL
;
882 tmp
= FSGetUDObjectForKey(defaultsDB
, str
);
884 item
->clientData
= WMDeepCopyPropList(tmp
);
892 WMSortListItems(prefs
->appsList
);
893 WMSortListItems(prefs
->typesList
);
897 populateDisksTab(FSPreferencesPanel
*prefs
)
899 WMPropList
* devArray
= NULL
;
900 WMPropList
* array
= NULL
;
902 devArray
= FSGetUDObjectForKey(defaultsDB
, "DISCS");
904 if (devArray
&& WMIsPLArray(devArray
))
909 numElem
= WMGetPropListItemCount(devArray
);
910 for(i
= 0; i
< numElem
; i
++)
912 array
= WMGetFromPLArray(devArray
, i
);
913 if (array
&& WMIsPLArray(array
))
916 WMListItem
*item
= NULL
;
918 disk
= (Disc
*) wmalloc(sizeof(Disc
));
919 memset(disk
, 0, sizeof(Disc
));
921 tmp
= WMGetFromPLArray(array
, 0);
922 if (WMIsPLString(tmp
))
924 disk
->name
= wstrdup(WMGetFromPLString(tmp
));
925 item
= WMAddListItem(prefs
->disksList
, disk
->name
);
932 tmp
= WMGetFromPLArray(array
, 1);
933 if (WMIsPLString(tmp
))
934 disk
->point
= wstrdup(WMGetFromPLString(tmp
));
936 tmp
= WMGetFromPLArray(array
, 2);
937 if (WMIsPLString(tmp
))
938 disk
->device
= wstrdup(WMGetFromPLString(tmp
));
940 tmp
= WMGetFromPLArray(array
, 3);
941 if (WMIsPLString(tmp
))
942 disk
->mnt
= wstrdup(WMGetFromPLString(tmp
));
944 tmp
= WMGetFromPLArray(array
, 4);
945 if (WMIsPLString(tmp
))
946 disk
->umnt
= wstrdup(WMGetFromPLString(tmp
));
948 tmp
= WMGetFromPLArray(array
, 5);
949 if (WMIsPLString(tmp
))
950 disk
->eject
= wstrdup(WMGetFromPLString(tmp
));
952 tmp
= WMGetFromPLArray(array
, 6);
953 if (WMIsPLString(tmp
))
954 disk
->close
= wstrdup(WMGetFromPLString(tmp
));
957 item
->clientData
= disk
;
961 WMSortListItems(prefs
->disksList
);
965 populateDisksFields(FSPreferencesPanel
*prefs
)
967 WMListItem
*item
= WMGetListSelectedItem(prefs
->disksList
);
968 Disc
*disk
= (Disc
*)item
->clientData
;
971 WMSetTextFieldText(prefs
->disksNameTF
, disk
->name
);
973 WMSetTextFieldText(prefs
->disksNameTF
, "");
976 WMSetTextFieldText(prefs
->disksMntTF
, disk
->point
);
978 WMSetTextFieldText(prefs
->disksMntTF
, "");
981 WMSetTextFieldText(prefs
->disksDevTF
, disk
->device
);
983 WMSetTextFieldText(prefs
->disksDevTF
, "");
986 WMSetTextFieldText(prefs
->cmdMntTF
, disk
->mnt
);
988 WMSetTextFieldText(prefs
->cmdMntTF
, "");
991 WMSetTextFieldText(prefs
->cmdUMntTF
, disk
->umnt
);
993 WMSetTextFieldText(prefs
->cmdUMntTF
, "");
996 WMSetTextFieldText(prefs
->cmdEjectTF
, disk
->eject
);
998 WMSetTextFieldText(prefs
->cmdEjectTF
, "");
1001 WMSetTextFieldText(prefs
->cmdCloseTF
, disk
->close
);
1003 WMSetTextFieldText(prefs
->cmdCloseTF
, "");
1008 populateAppsFields(FSPreferencesPanel
*prefs
)
1011 WMPropList
* val
= NULL
;
1012 WMListItem
*item
= WMGetListSelectedItem(prefs
->appsList
);
1017 val
= FSGetDBObjectForKey(item
->clientData
, "exec");
1018 if (val
&& WMIsPLString(val
))
1019 WMSetTextFieldText(prefs
->appsExecTF
, WMGetFromPLString(val
));
1021 val
= FSGetDBObjectForKey(item
->clientData
, "icon");
1022 if (val
&& WMIsPLString(val
))
1024 char *img
= LocateImage(WMGetFromPLString(val
));
1028 FSSetButtonImageFromFile(prefs
->appsIconBtn
, img
);
1029 WMHangData(prefs
->appsIconBtn
, WMGetFromPLString(val
));
1034 WMSetButtonImage(prefs
->appsIconBtn
, NULL
);
1037 * uflags indicates whether or not the list item should be
1041 WMSetButtonText(prefs
->appsRemoveBtn
, _("Undelete"));
1043 WMSetButtonText(prefs
->appsRemoveBtn
, _("Delete"));
1047 populateTypesFields(FSPreferencesPanel
*prefs
)
1050 WMPropList
* val
= NULL
;
1051 WMListItem
*item
= WMGetListSelectedItem(prefs
->typesList
);
1056 val
= FSGetDBObjectForKey(item
->clientData
, "editor");
1057 if (val
&& WMIsPLString(val
))
1058 WMSetTextFieldText(prefs
->typesEditTF
, WMGetFromPLString(val
));
1060 WMSetTextFieldText(prefs
->typesEditTF
, "");
1062 val
= FSGetDBObjectForKey(item
->clientData
, "viewer");
1063 if (val
&& WMIsPLString(val
))
1064 WMSetTextFieldText(prefs
->typesViewTF
, WMGetFromPLString(val
));
1066 WMSetTextFieldText(prefs
->typesViewTF
, "");
1068 val
= FSGetDBObjectForKey(item
->clientData
, "icon");
1069 if (val
&& WMIsPLString(val
))
1071 char *img
= LocateImage(WMGetFromPLString(val
));
1075 FSSetButtonImageFromFile(prefs
->typesIconBtn
, img
);
1076 WMHangData(prefs
->typesIconBtn
, WMGetFromPLString(val
));
1081 WMSetButtonImage(prefs
->typesIconBtn
, NULL
);
1085 WMSetButtonText(prefs
->typesRemoveBtn
, _("Undelete"));
1089 WMSetButtonText(prefs
->typesRemoveBtn
, _("Delete"));
1094 static clearDisksFields(FSPreferencesPanel
*prefs
)
1096 WMSetTextFieldText(prefs
->disksNameTF
, "");
1097 WMSetTextFieldText(prefs
->disksMntTF
, "");
1098 WMSetTextFieldText(prefs
->disksDevTF
, "");
1099 WMSetTextFieldText(prefs
->cmdMntTF
, "");
1100 WMSetTextFieldText(prefs
->cmdUMntTF
, "");
1101 WMSetTextFieldText(prefs
->cmdEjectTF
, "");
1102 WMSetTextFieldText(prefs
->cmdCloseTF
, "");
1106 updateDisksList(FSPreferencesPanel
*prefs
)
1108 WMListItem
*item
= WMGetListSelectedItem(prefs
->disksList
);
1110 char *name
= WMGetTextFieldText(prefs
->disksNameTF
);
1114 /* If an item is selected, update it's settings */
1115 disk
= (Disc
*) item
->clientData
;
1120 /* If no item has been selected, its a new entry */
1121 disk
= (Disc
*) wmalloc(sizeof(Disc
));
1122 memset(disk
, 0, sizeof(Disc
));
1124 item
= WMAddListItem(prefs
->disksList
, name
);
1125 item
->clientData
= disk
;
1129 * This could be a problem if an empty entry is
1130 * created. I wonder what will happen!!
1134 disk
->name
= WMGetTextFieldText(prefs
->disksNameTF
);
1135 disk
->point
= WMGetTextFieldText(prefs
->disksMntTF
);
1136 disk
->device
= WMGetTextFieldText(prefs
->disksDevTF
);
1137 disk
->mnt
= WMGetTextFieldText(prefs
->cmdMntTF
);
1138 disk
->umnt
= WMGetTextFieldText(prefs
->cmdUMntTF
);
1139 disk
->eject
= WMGetTextFieldText(prefs
->cmdEjectTF
);
1140 disk
->close
= WMGetTextFieldText(prefs
->cmdCloseTF
);
1145 genericListClick(WMWidget
*self
, void *data
)
1147 WMList
*list
= (WMList
*) self
;
1148 WMListItem
*item
= WMGetListSelectedItem(list
);
1149 FSPreferencesPanel
*prefs
= (FSPreferencesPanel
*) data
;
1151 if (list
== prefs
->imgList
)
1155 img
= LocateImage(item
->clientData
);
1159 FSSetButtonImageFromFile(prefs
->imgIconBtn
, img
);
1163 else if (list
== prefs
->execList
)
1165 WMSetTextFieldText(prefs
->execTF
, item
->clientData
);
1167 else if (list
== prefs
->dpyList
)
1169 WMSetTextFieldText(prefs
->dpyTF
, item
->clientData
);
1171 else if (list
== prefs
->disksList
)
1173 populateDisksFields(prefs
);
1175 else if (list
== prefs
->typesList
)
1177 populateTypesFields(prefs
);
1179 else if (list
== prefs
->appsList
)
1181 populateAppsFields(prefs
);
1186 genericButtonActionHandler(WMWidget
*self
, void *clientData
)
1188 Bool edited
= False
;
1189 WMOpenPanel
*oPanel
= NULL
;
1190 WMButton
*btn
= (WMButton
*) self
;
1191 FSPreferencesPanel
*prefs
= (FSPreferencesPanel
*) clientData
;
1193 if (btn
== prefs
->imgIconBtn
)
1197 WMListItem
*item
= WMGetListSelectedItem(prefs
->imgList
);
1199 if (!item
|| !item
->clientData
)
1202 tmp
= FSRunSelectIconPanel(prefs
->win
, _("Icon Select"),item
->clientData
);
1206 img
= LocateImage(tmp
);
1209 FSSetButtonImageFromFile(prefs
->imgIconBtn
, img
);
1212 free(item
->clientData
);
1213 item
->clientData
= tmp
;
1216 else if (btn
== prefs
->execSetBtn
)
1218 WMListItem
*item
= WMGetListSelectedItem(prefs
->execList
);
1223 item
->clientData
= WMGetTextFieldText(prefs
->execTF
);
1225 /* WMSetTextFieldText(prefs->execTF, ""); */
1226 /* WMSelectListItem(prefs->execList, -1); */
1228 else if (btn
== prefs
->dpySetBtn
)
1230 WMListItem
*item
= WMGetListSelectedItem(prefs
->dpyList
);
1235 item
->clientData
= WMGetTextFieldText(prefs
->dpyTF
);
1236 /* WMSetTextFieldText(prefs->dpyTF, ""); */
1237 /* WMSelectListItem(prefs->dpyList, -1); */
1240 else if (btn
== prefs
->disksNewBtn
)
1242 clearDisksFields(prefs
);
1243 WMSelectListItem(prefs
->disksList
, -1);
1245 else if (btn
== prefs
->disksRemoveBtn
)
1248 WMListItem
*item
= NULL
;
1250 clearDisksFields(prefs
);
1251 item
= WMGetListSelectedItem(prefs
->disksList
);
1254 free(item
->clientData
);
1255 item
->clientData
= NULL
;
1257 row
= WMGetListSelectedItemRow(prefs
->disksList
);
1258 WMRemoveListItem(prefs
->disksList
, row
);
1261 else if (btn
== prefs
->disksUpdateBtn
)
1263 updateDisksList(prefs
);
1265 /* clearDisksFields(prefs); */
1266 /* WMSelectListItem(prefs->disksList, -1); */
1269 else if (btn
== prefs
->appsSetBtn
)
1271 char *appStr
= WMGetTextFieldText(prefs
->appsExecTF
);
1272 char *imgStr
= WMGetHangedData(prefs
->appsIconBtn
);
1273 WMListItem
*item
= WMGetListSelectedItem(prefs
->appsList
);
1274 WMPropList
* array
= FSGetUDObjectForKey(defaultsDB
, "EXE");
1280 if (appStr
) /* crash in 0.2.3e*/
1282 if (item
->clientData
) {
1283 WMPutInPLDictionary(item
->clientData
,
1284 WMCreatePLString("exec"), WMCreatePLString(appStr
));
1286 /* new in V 0.2.3f */
1288 item
->clientData
= WMCreatePLDictionary(
1289 WMCreatePLString("exec"), WMCreatePLString(appStr
), NULL
);
1294 if (item
->clientData
) {
1295 WMPutInPLDictionary(item
->clientData
,
1296 WMCreatePLString("icon"), WMCreatePLString(imgStr
));
1298 /* new in V 0.2.3f */
1300 item
->clientData
= WMCreatePLDictionary(
1301 WMCreatePLString("icon"), WMCreatePLString(imgStr
), NULL
);
1305 if (array
&& WMIsPLArray(array
))
1307 InsertArrayElement(array
, WMCreatePLString(item
->text
));
1312 else if (btn
== prefs
->appsRemoveBtn
)
1314 WMListItem
*item
= WMGetListSelectedItem(prefs
->appsList
);
1322 WMSetButtonText(btn
, _("Undelete"));
1327 WMSetButtonText(btn
, _("Delete"));
1329 /* Update of ListView? */
1330 WMSelectListItem(prefs
->appsList
,
1331 WMGetListSelectedItemRow(prefs
->appsList
));
1335 else if (btn
== prefs
->typesSetBtn
)
1337 char *viewStr
= WMGetTextFieldText(prefs
->typesViewTF
);
1338 char *editStr
= WMGetTextFieldText(prefs
->typesEditTF
);
1339 char *imgStr
= WMGetHangedData(prefs
->typesIconBtn
);
1340 WMListItem
*item
= WMGetListSelectedItem(prefs
->typesList
);
1341 WMPropList
* array
= FSGetUDObjectForKey(defaultsDB
, "EXTN");
1348 if (item
->clientData
) {
1349 WMPutInPLDictionary(item
->clientData
,
1350 WMCreatePLString("viewer"), WMCreatePLString(viewStr
));
1352 /* new in V 0.2.3f */
1354 item
->clientData
= WMCreatePLDictionary(
1355 WMCreatePLString("viewer"), WMCreatePLString(viewStr
), NULL
);
1361 if (item
->clientData
) {
1362 WMPutInPLDictionary(item
->clientData
,
1363 WMCreatePLString("editor"), WMCreatePLString(editStr
));
1365 /* new in V 0.2.3f */
1367 item
->clientData
= WMCreatePLDictionary(
1368 WMCreatePLString("editor"), WMCreatePLString(editStr
), NULL
);
1373 if (item
->clientData
) {
1374 WMPutInPLDictionary(item
->clientData
,
1375 WMCreatePLString("icon"), WMCreatePLString(imgStr
));
1377 /* new in V 0.2.3f */
1379 item
->clientData
= WMCreatePLDictionary(
1380 WMCreatePLString("icon"), WMCreatePLString(imgStr
), NULL
);
1384 if (array
&& WMIsPLArray(array
))
1386 InsertArrayElement(array
, WMCreatePLString(item
->text
));
1391 else if (btn
== prefs
->typesRemoveBtn
)
1393 WMListItem
*item
= WMGetListSelectedItem(prefs
->typesList
);
1401 WMSetButtonText(btn
, _("Undelete"));
1406 WMSetButtonText(btn
, _("Delete"));
1408 WMSelectListItem(prefs
->typesList
,
1409 WMGetListSelectedItemRow(prefs
->typesList
));
1413 else if (btn
== prefs
->appsIconBtn
)
1418 WMListItem
*item
= WMGetListSelectedItem(prefs
->appsList
);
1420 if (!item
|| !item
->clientData
)
1423 val
= FSGetDBObjectForKey(item
->clientData
, "icon");
1424 if (val
&& WMIsPLString(val
))
1426 tmp
= FSRunSelectIconPanel(prefs
->win
, _("Icon Select"),
1427 WMGetFromPLString(val
));
1431 img
= LocateImage(tmp
);
1434 FSSetButtonImageFromFile(prefs
->appsIconBtn
, img
);
1435 WMHangData(prefs
->appsIconBtn
, tmp
);
1439 WMSetButtonImage(prefs
->appsIconBtn
, NULL
);
1440 /* edited = True; */
1442 else if (btn
== prefs
->typesIconBtn
)
1447 WMListItem
*item
= WMGetListSelectedItem(prefs
->typesList
);
1449 if (!item
|| !item
->clientData
)
1452 val
= FSGetDBObjectForKey(item
->clientData
, "icon");
1453 if (val
&& WMIsPLString(val
))
1455 tmp
= FSRunSelectIconPanel(prefs
->win
, _("Icon Select"),
1456 WMGetFromPLString(val
));
1460 img
= LocateImage(tmp
);
1463 FSSetButtonImageFromFile(prefs
->typesIconBtn
, img
);
1464 WMHangData(prefs
->typesIconBtn
, tmp
);
1468 WMSetButtonImage(prefs
->typesIconBtn
, NULL
);
1469 /* edited = True; */
1471 else if (btn
== prefs
->appsBrowseBtn
)
1473 WMOpenPanel
*oPanel
= NULL
;
1475 oPanel
= WMGetOpenPanel(prefs
->scr
);
1476 if (WMRunModalFilePanelForDirectory(oPanel
, prefs
->win
,
1477 "/", _("Browse -> App"), NULL
))
1479 char *str
= WMGetFilePanelFileName(oPanel
);
1481 WMSetTextFieldText(prefs
->appsExecTF
, str
);
1482 WMInsertTextFieldText(prefs
->appsExecTF
, " %s", strlen(str
));
1485 else if (btn
== prefs
->typesViewBrowseBtn
)
1487 oPanel
= WMGetOpenPanel(prefs
->scr
);
1488 if (WMRunModalFilePanelForDirectory(oPanel
, prefs
->win
,
1489 "/", _("Browse -> Viewer"), NULL
))
1491 char *str
= WMGetFilePanelFileName(oPanel
);
1493 WMSetTextFieldText(prefs
->typesViewTF
, str
);
1494 WMInsertTextFieldText(prefs
->typesViewTF
, " %s", strlen(str
));
1497 else if (btn
== prefs
->typesEditBrowseBtn
)
1499 oPanel
= WMGetOpenPanel(prefs
->scr
);
1500 if (WMRunModalFilePanelForDirectory(oPanel
, prefs
->win
,
1501 "/", _("Browse -> Editor"), NULL
))
1503 char *str
= WMGetFilePanelFileName(oPanel
);
1505 WMSetTextFieldText(prefs
->typesEditTF
, str
);
1506 WMInsertTextFieldText(prefs
->typesEditTF
, " %s", strlen(str
));
1513 WMTabViewItem
*item
= NULL
;
1515 item
= WMGetSelectedTabViewItem(prefs
->tabV
);
1519 id
= WMGetTabViewItemIdentifier(item
);
1524 prefs
->flags
.evars
= True
;
1527 prefs
->flags
.eapps
= True
;
1530 prefs
->flags
.ediscs
= True
;
1535 WMSetButtonEnabled(prefs
->applyBtn
, True
);
1536 WMSetButtonEnabled(prefs
->okBtn
, True
);
1541 setVarsImage(WMWidget
*self
, void *data
)
1545 static void FSClosePreferencesPanel(WMWidget
*self
, void *client
)
1547 FSPreferencesPanel
*prefs
= (FSPreferencesPanel
*) client
;
1549 prefs
->flags
.done
= 1;
1553 saveAllTabsAndClose(WMWidget
*self
, void *client
)
1556 FSPreferencesPanel
*prefs
= (FSPreferencesPanel
*) client
;
1558 for (i
= 0; i
< NUM_TABS
; i
++)
1561 FSClosePreferencesPanel(self
, client
);
1565 applyBtnCB(WMWidget
*self
, void *client
)
1568 WMTabViewItem
*item
= NULL
;
1569 FSPreferencesPanel
*prefs
= (FSPreferencesPanel
*) client
;
1571 item
= WMGetSelectedTabViewItem(prefs
->tabV
);
1574 id
= WMGetTabViewItemIdentifier(item
);
1579 prefs
->flags
.evars
= False
;
1582 prefs
->flags
.eapps
= False
;
1585 prefs
->flags
.ediscs
= False
;
1590 WMSetButtonEnabled(prefs
->applyBtn
, False
);
1595 saveTab(FSPreferencesPanel
*prefs
, int tabID
)
1599 case VARS_TAB
: saveVarsTab(prefs
);
1601 case APPS_TAB
: saveAppsTab(prefs
);
1603 case DISCS_TAB
: saveDiscsTab(prefs
);
1608 WMSynchronizeUserDefaults(defaultsDB
);
1612 FSDestroyPreferencesPanel(FSPreferencesPanel
*preferences
)
1614 WMUnmapWidget(preferences
->win
);
1615 WMDestroyWidget(preferences
->win
);
1616 free((void *) preferences
);
1621 tfDidChange(struct WMTextFieldDelegate
*self
, WMNotification
*notif
)
1627 setTFDelegate(FSPreferencesPanel
*prefs
, WMTextField
*tf
)
1629 WMTextFieldDelegate
*delegate
= NULL
;
1631 delegate
= (WMTextFieldDelegate
*) wmalloc(sizeof(WMTextFieldDelegate
));
1632 memset(delegate
, 0, sizeof(WMTextFieldDelegate
));
1636 delegate
->data
= prefs
;
1637 delegate
->didChange
= tfDidChange
;
1638 WMSetTextFieldDelegate(tf
, delegate
);
1643 setTVIDelegate(FSPreferencesPanel
*prefs
, WMTabView
*tv
)
1645 WMTabViewDelegate
*delegate
= NULL
;
1647 delegate
= (WMTabViewDelegate
*) wmalloc(sizeof(WMTabViewDelegate
));
1648 memset(delegate
, 0, sizeof(WMTabViewDelegate
));
1652 delegate
->data
= prefs
;
1653 delegate
->didSelectItem
= tvDidSelectItem
;
1654 WMSetTabViewDelegate(tv
, delegate
);
1659 tvDidSelectItem(struct WMTabViewDelegate
*self
, WMTabView
*tabView
,
1660 WMTabViewItem
*item
)
1663 Bool edited
= False
;
1664 WMTabViewDelegate
*delegate
= (WMTabViewDelegate
*)self
;
1665 FSPreferencesPanel
*prefs
= (FSPreferencesPanel
*) delegate
->data
;
1667 id
= WMGetTabViewItemIdentifier(item
);
1672 if (prefs
->flags
.evars
)
1676 if (prefs
->flags
.eapps
)
1680 if (prefs
->flags
.ediscs
)
1683 default: edited
= False
;
1687 WMSetButtonEnabled(prefs
->applyBtn
, edited
);
1691 saveVarsTab(FSPreferencesPanel
*prefs
)
1694 WMListItem
*item
= NULL
;
1696 row
= WMFindRowOfListItemWithTitle(prefs
->imgList
, "ROOT");
1699 item
= WMGetListItem(prefs
->imgList
, row
);
1701 FSSetStringForNameKey("ROOT", "icon", item
->clientData
);
1704 row
= WMFindRowOfListItemWithTitle(prefs
->imgList
, "DIRECTORY");
1707 item
= WMGetListItem(prefs
->imgList
, row
);
1709 FSSetStringForName("DIRECTORY", item
->clientData
);
1712 row
= WMFindRowOfListItemWithTitle(prefs
->imgList
, "DEFAULT_IMG");
1715 item
= WMGetListItem(prefs
->imgList
, row
);
1717 FSSetStringForName("DEFAULT_IMG", item
->clientData
);
1720 row
= WMFindRowOfListItemWithTitle(prefs
->imgList
, "HOME");
1723 item
= WMGetListItem(prefs
->imgList
, row
);
1725 FSSetStringForName("HOME", item
->clientData
);
1728 row
= WMFindRowOfListItemWithTitle(prefs
->execList
, "CONSOLE");
1731 item
= WMGetListItem(prefs
->execList
, row
);
1733 FSSetStringForNameKey("CONSOLE", "exec", item
->clientData
);
1736 row
= WMFindRowOfListItemWithTitle(prefs
->execList
, "PROCESS");
1739 item
= WMGetListItem(prefs
->execList
, row
);
1741 FSSetStringForNameKey("PROCESS", "exec", item
->clientData
);
1744 row
= WMFindRowOfListItemWithTitle(prefs
->execList
, "MAGICASCII");
1747 item
= WMGetListItem(prefs
->execList
, row
);
1749 FSSetStringForNameKey("MAGICASCII", "exec", item
->clientData
);
1752 row
= WMFindRowOfListItemWithTitle(prefs
->execList
, "MAGICIMAGE");
1755 item
= WMGetListItem(prefs
->execList
, row
);
1757 FSSetStringForNameKey("MAGICIMAGE", "exec", item
->clientData
);
1760 row
= WMFindRowOfListItemWithTitle(prefs
->execList
, "MAGICPS");
1763 item
= WMGetListItem(prefs
->execList
, row
);
1765 FSSetStringForNameKey("MAGICPS", "exec", item
->clientData
);
1768 row
= WMFindRowOfListItemWithTitle(prefs
->dpyList
, "ColumnWidth");
1771 item
= WMGetListItem(prefs
->dpyList
, row
);
1773 int value
= atoi(item
->clientData
);
1774 if (FSGetIntegerForName("ColumnWidth") != value
) {
1775 if (value
< 169) /*MAGIC*/
1777 FSSetIntegerForName("ColumnWidth", value
);
1778 /* TODO: update viewer width */
1783 /* row = WMFindRowOfListItemWithTitle(prefs->imgList, "IconWidth"); */
1786 /* item = WMGetListItem(prefs->dpyList, row); */
1788 /* FSSetIntegerForName("IconWidth", atoi(item->clientData)); */
1792 row
= WMFindRowOfListItemWithTitle(prefs
->dpyList
, "ICONDIR");
1795 item
= WMGetListItem(prefs
->dpyList
, row
);
1797 FSSetStringForName("ICONDIR", item
->clientData
);
1800 row
= WMFindRowOfListItemWithTitle(prefs
->dpyList
, "SortDisplay");
1803 item
= WMGetListItem(prefs
->dpyList
, row
);
1805 int value
= atoi(item
->clientData
);
1806 if (FSGetIntegerForName("SortDisplay") != value
) {
1807 FSSetIntegerForName("SortDisplay", value
);
1808 FSUpdateFileViewPath(
1809 FSGetFSViewerCurrentView(prefs
->app
),
1810 FileSync
, NULL
, NULL
);
1815 row
= WMFindRowOfListItemWithTitle(prefs
->dpyList
, "SortOrder");
1818 item
= WMGetListItem(prefs
->dpyList
, row
);
1820 int value
= atoi(item
->clientData
);
1821 if (FSGetIntegerForName("SortOrder") != value
) {
1822 FSSetIntegerForName("SortOrder", value
);
1823 FSUpdateFileViewPath(
1824 FSGetFSViewerCurrentView(prefs
->app
),
1825 FileSync
, NULL
, NULL
);
1830 row
= WMFindRowOfListItemWithTitle(prefs
->dpyList
, "DisplaySVBG");
1833 item
= WMGetListItem(prefs
->dpyList
, row
);
1835 int value
= atoi(item
->clientData
);
1836 if (FSGetIntegerForName("DisplaySVBG") != value
) {
1837 FSSetIntegerForName("DisplaySVBG", value
);
1838 /* TODO: update view*/
1843 row
= WMFindRowOfListItemWithTitle(prefs
->dpyList
, "DisplayMCListPixmap");
1846 item
= WMGetListItem(prefs
->dpyList
, row
);
1848 int value
= atoi(item
->clientData
);
1849 if (FSGetIntegerForName("DisplayMCListPixmap") != value
) {
1850 FSSetIntegerForName("DisplayMCListPixmap", value
);
1851 /* TODO: update view*/
1858 saveAppsTab(FSPreferencesPanel
*prefs
)
1862 WMListItem
*item
= NULL
;
1863 WMPropList
* exeArray
= FSGetUDObjectForKey(defaultsDB
, "EXE");
1864 WMPropList
* extnArray
= FSGetUDObjectForKey(defaultsDB
, "EXTN");
1867 numRows
= WMGetListNumberOfRows(prefs
->appsList
);
1869 for (row
= 0; row
< numRows
; row
++)
1871 item
= WMGetListItem(prefs
->appsList
, row
);
1872 if (item
&& !item
->uflags
)
1873 WMSetUDObjectForKey(defaultsDB
, item
->clientData
, item
->text
);
1876 if (exeArray
&& WMIsPLArray(exeArray
))
1878 FSRemoveArrayElement(exeArray
, WMCreatePLString(item
->text
));
1879 WMRemoveUDObjectForKey(defaultsDB
, item
->text
);
1884 numRows
= WMGetListNumberOfRows(prefs
->typesList
);
1885 for (row
= 0; row
< numRows
; row
++)
1887 item
= WMGetListItem(prefs
->typesList
, row
);
1888 if (item
&& !item
->uflags
)
1890 WMSetUDObjectForKey(defaultsDB
, item
->clientData
, item
->text
);
1894 if (extnArray
&& WMIsPLArray(extnArray
))
1896 FSRemoveArrayElement(extnArray
, WMCreatePLString(item
->text
));
1897 WMRemoveUDObjectForKey(defaultsDB
, item
->text
);
1901 populateTypesTab(prefs
);
1905 saveDiscsTab(FSPreferencesPanel
*prefs
)
1909 WMListItem
*item
= NULL
;
1910 WMPropList
* array
= NULL
;
1911 WMPropList
* diskArray
= NULL
;
1914 diskArray
= WMCreatePLArray(NULL
, NULL
);
1916 numRows
= WMGetListNumberOfRows(prefs
->disksList
);
1917 for (row
= 0; row
< numRows
; row
++)
1919 item
= WMGetListItem(prefs
->disksList
, row
);
1920 disk
= (Disc
*)item
->clientData
;
1924 array
= WMCreatePLArray(WMCreatePLString(disk
->name
),
1925 WMCreatePLString(disk
->point
),
1926 WMCreatePLString(disk
->device
),
1927 WMCreatePLString(disk
->mnt
),
1928 WMCreatePLString(disk
->umnt
),
1929 WMCreatePLString(disk
->eject
),
1930 WMCreatePLString(disk
->close
),
1932 WMAddToPLArray(diskArray
, array
);
1935 WMSetUDObjectForKey(defaultsDB
, diskArray
, "DISCS");
1939 genericListDrawProc(WMList
*lPtr
, int index
, Drawable d
,
1940 char *text
, int state
, WMRect
*rect
)
1942 WMView
*view
= W_VIEW(lPtr
);
1943 W_Screen
*scr
= view
->screen
;
1944 WMListItem
*item
= WMGetListItem(lPtr
, index
);
1947 WMPaintColorSwatch(WMWhiteColor(scr
), d
,
1948 rect
->pos
.x
, rect
->pos
.y
,
1949 rect
->size
.width
, rect
->size
.height
);
1951 WMPaintColorSwatch(WMGetWidgetBackgroundColor(lPtr
), d
,
1952 rect
->pos
.x
, rect
->pos
.y
,
1953 rect
->size
.width
, rect
->size
.height
);
1957 W_PaintText(view
, d
, scr
->boldFont
,
1958 rect
->pos
.x
+4, rect
->pos
.y
, rect
->size
.width
,
1959 WALeft
, WMBlackColor(scr
), False
,
1960 item
->text
, strlen(item
->text
));
1964 W_PaintText(view
, d
, scr
->normalFont
,
1965 rect
->pos
.x
+4, rect
->pos
.y
, rect
->size
.width
,
1966 WALeft
, WMBlackColor(scr
), False
,
1967 item
->text
, strlen(item
->text
));