6 #include <exec/types.h>
7 #include <graphics/gels.h>
8 #include <graphics/rastport.h>
9 #include <intuition/classes.h>
10 #include <intuition/classusr.h>
11 #include <utility/hooks.h>
12 #include <intuition/gadgetclass.h>
13 #include <intuition/newmouse.h>
14 #include <workbench/workbench.h>
15 #include <workbench/startup.h>
16 #include <cybergraphx/cybergraphics.h>
17 #include <dos/dostags.h>
18 #include <dos/datetime.h>
22 #include <proto/dos.h>
23 #include <proto/exec.h>
24 #include <proto/layers.h>
25 #include <proto/intuition.h>
26 #include <proto/graphics.h>
27 #include <proto/utility.h>
28 #include <proto/locale.h>
29 #include <proto/iconobject.h>
30 #include <proto/cybergraphics.h>
32 #include <proto/scalos.h>
34 #include <clib/alib_protos.h>
37 #include <datatypes/iconobject.h>
38 #include <scalos/scalos.h>
46 #include "scalos_structures.h"
47 #include "FsAbstraction.h"
48 #include "functions.h"
50 #include "Variables.h"
52 //----------------------------------------------------------------------------
54 // local data definitions
56 struct DeviceWindowClassInstance
61 //----------------------------------------------------------------------------
65 static SAVEDS(ULONG
) INTERRUPT
DeviceWindowClass_Dispatcher(Class
*cl
, Object
*o
, Msg msg
);
66 static ULONG
DeviceWindowClass_ReadIconList(Class
*cl
, Object
*o
, Msg msg
);
67 static ULONG
DeviceWindowClass_ReadIcon(Class
*cl
, Object
*o
, Msg msg
);
68 static ULONG
DeviceWindowClass_RemIcon(Class
*cl
, Object
*o
, Msg msg
);
69 static ULONG
DeviceWindowClass_RemIcon2(Class
*cl
, Object
*o
, Msg msg
);
70 static ULONG
DeviceWindowClass_Ping(Class
*cl
, Object
*o
, Msg msg
);
71 static ULONG
DeviceWindowClass_Message(Class
*cl
, Object
*o
, Msg msg
);
72 static ULONG
DeviceWindowClass_New(Class
*cl
, Object
*o
, Msg msg
);
73 static ULONG
DeviceWindowClass_Dispose(Class
*cl
, Object
*o
, Msg msg
);
74 static ULONG
DeviceWindowClass_CheckUpdate(Class
*cl
, Object
*o
, Msg msg
);
75 static ULONG
DeviceWindowClass_Update(Class
*cl
, Object
*o
, Msg msg
);
76 static struct ScaIconNode
*ReadDevIcon_Device(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
);
77 static struct ScaIconNode
*ReadDevIcon_Volume(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
);
78 static struct ScaIconNode
*DevIconOk2(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, Object
*iconObj
);
79 static LONG
ReadDevBackdrop(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*DevIn
);
80 static struct ScaIconNode
*CreateBackdropIcon(struct internalScaWindowTask
*iwt
,
81 struct BackDropList
*bdl
, struct ScaIconNode
*DevIn
,
82 CONST_STRPTR BackdropIconName
, STRPTR fName
);
83 static Object
*ReadDefaultVolumeIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
);
84 static Object
*ReadDefaultDeviceIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
);
85 static Object
*ReadDiskIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
);
86 static Object
*ReadDefaultIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
);
87 static void FreeBackdropIcon(struct ScaBackdropIcon
*bdi
);
88 static BOOL
CreateSbi(struct ScaIconNode
*DevIn
, struct ScaIconNode
*in
);
89 static struct ScaIconNode
*IconAlreadyExists(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
);
90 static BOOL
FindIconInDrawerWindows(BPTR dirLock
, CONST_STRPTR IconName
);
91 static Object
*ReadDefaultIconByName(struct internalScaWindowTask
*iwt
, CONST_STRPTR iconName
, STRPTR DevName
);
92 static BOOL
StartDeviceIconNotify(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
);
93 static void SetDeviceIconSupportsFlags(struct ScaIconNode
*in
);
94 static void SetBackdropIconSupportsFlags(struct internalScaWindowTask
*iwt
,
95 struct BackDropList
*bdl
, struct ScaIconNode
*in
);
97 //----------------------------------------------------------------------------
99 // public data items :
101 //----------------------------------------------------------------------------
104 struct ScalosClass
*initDeviceWindowClass(const struct PluginClass
*plug
)
106 struct ScalosClass
*DeviceWindowClass
;
108 DeviceWindowClass
= SCA_MakeScalosClass(plug
->plug_classname
,
109 plug
->plug_superclassname
,
110 sizeof(struct DeviceWindowClassInstance
),
113 if (DeviceWindowClass
)
115 // initialize the cl_Dispatcher Hook
116 SETHOOKFUNC(DeviceWindowClass
->sccl_class
->cl_Dispatcher
, DeviceWindowClass_Dispatcher
);
119 return DeviceWindowClass
;
123 static SAVEDS(ULONG
) INTERRUPT
DeviceWindowClass_Dispatcher(Class
*cl
, Object
*o
, Msg msg
)
127 switch (msg
->MethodID
)
130 Result
= DeviceWindowClass_New(cl
, o
, msg
);
134 Result
= DeviceWindowClass_Dispose(cl
, o
, msg
);
137 case SCCM_IconWin_ReadIconList
:
138 Result
= DeviceWindowClass_ReadIconList(cl
, o
, msg
);
141 case SCCM_DeviceWin_ReadIcon
:
142 Result
= DeviceWindowClass_ReadIcon(cl
, o
, msg
);
146 Result
= DeviceWindowClass_Ping(cl
, o
, msg
);
150 Result
= DeviceWindowClass_Message(cl
, o
, msg
);
153 case SCCM_IconWin_NewViewMode
:
157 case SCCM_IconWin_Update
:
158 Result
= DeviceWindowClass_Update(cl
, o
, msg
);
161 case SCCM_IconWin_ImmediateCheckUpdate
:
162 Result
= DeviceWindowClass_CheckUpdate(cl
, o
, msg
);
165 case SCCM_DeviceWin_RemIcon
:
166 Result
= DeviceWindowClass_RemIcon(cl
, o
, msg
);
169 case SCCM_IconWin_RemIcon
:
170 // Only supports left-out icons
171 Result
= DeviceWindowClass_RemIcon2(cl
, o
, msg
);
175 Result
= DoSuperMethodA(cl
, o
, msg
);
183 static ULONG
DeviceWindowClass_ReadIconList(Class
*cl
, Object
*o
, Msg msg
)
185 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
186 struct ScaDeviceIcon
*sdi
, *diNext
;
187 struct ScaIconNode
*NotShownIconList
= NULL
;
189 d1(kprintf("%s/%s/%ld: Start iwt=%08lx ws=%08lx <%s>\n", \
190 __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WindowTask
.mt_WindowStruct
, iwt
->iwt_WinTitle
));
194 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
196 SplashDisplayProgress(GetLocString(MSGID_PROGRESS_READDEVICEICONS
), 0);
198 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
200 DoMethod(iwt
->iwt_DevListObject
, SCCM_DeviceList_Generate
, &iwt
->iwt_DevIconList
);
202 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
204 for (sdi
= iwt
->iwt_DevIconList
; sdi
; sdi
= diNext
)
206 diNext
= (struct ScaDeviceIcon
*) sdi
->di_Node
.mln_Succ
;
208 d1(kprintf("%s/%s/%ld: di=%08lx <%s> Flags=%04lx\n", __FILE__
, __FUNC__
, __LINE__
, \
209 sdi
, sdi
->di_Volume
, sdi
->di_Flags
));
211 if (DIBF_DontDisplay
& sdi
->di_Flags
)
213 // remove icon from iwt_DevIconList
214 d1(kprintf("%s/%s/%ld: Remove di=%08lx <%s> di_Flags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, sdi
, sdi
->di_Device
, sdi
->di_Flags
));
215 RemoveDeviceIcon(iwt
, sdi
, &NotShownIconList
);
219 d1(kprintf("%s/%s/%ld: Add di=%08lx <%s> di_Flags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, sdi
, sdi
->di_Device
, sdi
->di_Flags
));
220 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_DeviceWin_ReadIcon
, sdi
);
223 FreeIconList(iwt
, &NotShownIconList
);
225 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
227 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUp
);
229 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
231 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
, SETVIRTF_AdjustBottomSlider
| SETVIRTF_AdjustRightSlider
);
233 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
235 SplashDisplayProgress(GetLocString(MSGID_PROGRESS_ENDREADDEVICEICONS
), 0);
237 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
241 d1(kprintf("%s/%s/%ld: Finished iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
247 static ULONG
DeviceWindowClass_ReadIcon(Class
*cl
, Object
*o
, Msg msg
)
249 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
250 struct msg_DevWinReadIcon
*dri
= (struct msg_DevWinReadIcon
*) msg
;
251 struct ScaIconNode
*in
;
253 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
254 d1(KPrintF("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, dri
->dri_DeviceNode
, dri
->dri_DeviceNode
->di_Device
));
255 d1(KPrintF("%s/%s/%ld: deviceNode=%08lx <%s> diskType=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, \
256 dri
->dri_DeviceNode
, dri
->dri_DeviceNode
->di_Device
, dri
->dri_DeviceNode
->di_Info
->id_DiskType
));
258 in
= IconAlreadyExists(iwt
, dri
->dri_DeviceNode
);
261 ScalosUnLockIconList(iwt
);
266 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s> di_Volume=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
, dri
->dri_DeviceNode
->di_Volume
));
268 if (dri
->dri_DeviceNode
->di_Volume
)
269 ReadDevIcon_Volume(iwt
, dri
->dri_DeviceNode
);
271 ReadDevIcon_Device(iwt
, dri
->dri_DeviceNode
);
273 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
279 static ULONG
DeviceWindowClass_RemIcon(Class
*cl
, Object
*o
, Msg msg
)
281 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
282 struct msg_DevWinRemIcon
*dri
= (struct msg_DevWinRemIcon
*) msg
;
283 struct ScaIconNode
*dummyIconList
= NULL
;
285 d1(kprintf("%s/%s/%ld: iwt=%08lx lock=%08lx IconName=<%s>\n", \
286 __FILE__
, __FUNC__
, __LINE__
, iwt
, dri
->dri_IconNode
, GetIconName(dri
->dri_IconNode
)));
288 ScalosLockIconListExclusive(iwt
);
290 SCA_MoveIconNode(&iwt
->iwt_WindowTask
.wt_IconList
, &dummyIconList
, dri
->dri_IconNode
);
292 RemoveIcons(iwt
, &dummyIconList
); // visually erase icons
294 debugLock_d1(dri
->dri_IconNode
->in_Lock
);
296 FreeIconNode(iwt
, &dummyIconList
, dri
->dri_IconNode
);
298 ScalosUnLockIconList(iwt
);
300 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
,
301 SETVIRTF_AdjustRightSlider
| SETVIRTF_AdjustBottomSlider
);
307 static ULONG
DeviceWindowClass_RemIcon2(Class
*cl
, Object
*o
, Msg msg
)
309 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
310 struct msg_RemIcon
*mri
= (struct msg_RemIcon
*) msg
;
311 struct ScaIconNode
*in
, *inNext
;
314 d1(KPrintF("%s/%s/%ld: iwt=%08lx lock=%08lx IconName=<%s>\n", \
315 __FILE__
, __FUNC__
, __LINE__
, iwt
, mri
->mri_Lock
, mri
->mri_Name
));
317 ScalosLockIconListExclusive(iwt
);
319 for (in
= iwt
->iwt_WindowTask
.wt_IconList
; in
; in
=inNext
)
321 d1(kprintf("%s/%s/%ld: in_Name=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, in
->in_Name
));
323 inNext
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
;
325 if (in
->in_Lock
&& (LOCK_SAME
== SameLock(in
->in_Lock
, mri
->mri_Lock
))
326 && in
->in_Name
&& 0 == Stricmp((STRPTR
) mri
->mri_Name
, in
->in_Name
))
328 struct ScaIconNode
*dummyIconList
= NULL
;
330 d1(KPrintF("%s/%s/%ld: FOUND in=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, in
));
334 SCA_MoveIconNode(&iwt
->iwt_WindowTask
.wt_IconList
, &dummyIconList
, in
);
336 RemoveIcons(iwt
, &dummyIconList
); // visually erase icons
338 debugLock_d1(in
->in_Lock
);
341 FreeIconNode(iwt
, &dummyIconList
, in
);
345 ScalosUnLockIconList(iwt
);
349 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
,
350 SETVIRTF_AdjustRightSlider
| SETVIRTF_AdjustBottomSlider
);
357 static ULONG
DeviceWindowClass_Ping(Class
*cl
, Object
*o
, Msg msg
)
359 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
361 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
363 if (++iwt
->iwt_dRefreshCount
>= CurrentPrefs
.pref_DiskRefresh
)
365 iwt
->iwt_dRefreshCount
= 0;
367 IDCMPDiskInserted(iwt
, NULL
);
370 return DoSuperMethodA(cl
, o
, msg
);
374 static ULONG
DeviceWindowClass_Message(Class
*cl
, Object
*o
, Msg msg
)
376 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
377 struct msg_Message
*msm
= (struct msg_Message
*) msg
;
379 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
381 switch (msm
->msm_iMsg
->Class
)
383 case IDCMP_DISKINSERTED
:
384 case IDCMP_DISKREMOVED
:
385 IDCMPDiskInserted(iwt
, NULL
);
389 return DoSuperMethodA(cl
, o
, msg
);
393 static ULONG
DeviceWindowClass_New(Class
*cl
, Object
*o
, Msg msg
)
395 d1(kprintf("%s/%s/%ld: START o=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, o
));
397 o
= (Object
*) DoSuperMethodA(cl
, o
, msg
);
401 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
402 struct ScaWindowStruct
*ws
= iwt
->iwt_WindowTask
.mt_WindowStruct
;
403 struct opSet
*ops
= (struct opSet
*) msg
;
406 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s> o=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
, o
));
408 SplashDisplayProgress(GetLocString(MSGID_PROGRESS_INITDEVICEWINDOW
), 0);
410 // desktop window is ALWAYS displayed as icons
411 ws
->ws_Viewmodes
= IDTV_ViewModes_Icon
;
413 iwt
->iwt_DevListObject
= (Object
*) SCA_NewScalosObject("DeviceList.sca", ops
->ops_AttrList
);
415 iwt
->iwt_IDCMPFlags
|= IDCMP_DISKINSERTED
| IDCMP_DISKREMOVED
;
416 iwt
->iwt_NeedsTimerFlag
= TRUE
;
417 ws
->ws_Flags
|= WSV_FlagF_NeedsTimerMsg
;
419 iwt
->iwt_IconFont
= IconWindowFont
;
420 iwt
->iwt_IconTTFont
= IconWindowTTFont
;
422 // initialize iwt_IconLayoutInfo
423 memset(&iwt
->iwt_IconLayoutInfo
.ili_LayoutArea
, 0, sizeof(iwt
->iwt_IconLayoutInfo
.ili_LayoutArea
));
424 memset(&iwt
->iwt_IconLayoutInfo
.ili_Restricted
, 0, sizeof(iwt
->iwt_IconLayoutInfo
.ili_Restricted
));
426 for (n
= 0; n
< Sizeof(iwt
->iwt_IconLayoutInfo
.ili_IconTypeLayoutModes
); n
++)
428 if (n
< Sizeof(CurrentPrefs
.pref_DeviceWindowLayoutModes
))
429 iwt
->iwt_IconLayoutInfo
.ili_IconTypeLayoutModes
[n
] = CurrentPrefs
.pref_DeviceWindowLayoutModes
[n
];
431 iwt
->iwt_IconLayoutInfo
.ili_IconTypeLayoutModes
[n
] = ICONLAYOUT_Columns
; //default
434 d1(kprintf("%s/%s/%ld: DevListObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_DevListObject
));
436 if (NULL
== iwt
->iwt_DevListObject
)
438 DoMethod(o
, OM_DISPOSE
);
443 d1(kprintf("%s/%s/%ld: END o=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, o
));
449 static ULONG
DeviceWindowClass_Dispose(Class
*cl
, Object
*o
, Msg msg
)
451 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
453 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
455 SCA_DisposeScalosObject(iwt
->iwt_DevListObject
);
456 iwt
->iwt_DevListObject
= NULL
;
458 return DoSuperMethodA(cl
, o
, msg
);
462 static ULONG
DeviceWindowClass_CheckUpdate(Class
*cl
, Object
*o
, Msg msg
)
464 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
466 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
468 return DeviceWindowCheckUpdate(iwt
);
472 static ULONG
DeviceWindowClass_Update(Class
*cl
, Object
*o
, Msg msg
)
474 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ((struct ScaRootList
*) o
)->rl_WindowTask
;
475 ULONG Result
, ReadResult
;
476 struct ScaIconNode
*in
, *inNext
;
479 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
481 UpdateIconOverlays(iwt
);
483 if (NULL
== iwt
->iwt_WindowTask
.wt_Window
)
486 ScalosLockIconListExclusive(iwt
);
488 d1(Forbid(); KPrintF("%s/%s/%ld: iwt=%08lx MsgList Head=%08lx TailPred=%08lx\n", \
489 __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WindowTask
.wt_IconPort
->mp_MsgList
.lh_Head
, \
490 iwt
->iwt_WindowTask
.wt_IconPort
->mp_MsgList
.lh_TailPred
); Permit());
492 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= inNext
)
494 inNext
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
;
496 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
498 if (WBAPPICON
!= IconType
)
499 FreeIconNode(iwt
, &iwt
->iwt_WindowTask
.wt_IconList
, in
);
502 d1(Forbid(); KPrintF("%s/%s/%ld: iwt=%08lx MsgList Head=%08lx TailPred=%08lx\n", \
503 __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WindowTask
.wt_IconPort
->mp_MsgList
.lh_Head
, \
504 iwt
->iwt_WindowTask
.wt_IconPort
->mp_MsgList
.lh_TailPred
); Permit());
506 for (in
=iwt
->iwt_WindowTask
.wt_LateIconList
; in
; in
= inNext
)
508 inNext
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
;
510 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
512 if (WBAPPICON
!= IconType
)
513 FreeIconNode(iwt
, &iwt
->iwt_WindowTask
.wt_LateIconList
, in
);
516 d1(Forbid(); KPrintF("%s/%s/%ld: iwt=%08lx MsgList Head=%08lx TailPred=%08lx\n", \
517 __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WindowTask
.wt_IconPort
->mp_MsgList
.lh_Head
, \
518 iwt
->iwt_WindowTask
.wt_IconPort
->mp_MsgList
.lh_TailPred
); Permit());
520 ScalosUnLockIconList(iwt
);
524 SetAttrs(iwt
->iwt_WindowTask
.mt_MainObject
,
525 SCCA_IconWin_Reading
, TRUE
,
530 if (iwt
->iwt_WindowTask
.wt_Window
)
532 EraseRect(iwt
->iwt_WindowTask
.wt_Window
->RPort
,
534 iwt
->iwt_WindowTask
.wt_Window
->Width
- 1,
535 iwt
->iwt_WindowTask
.wt_Window
->Height
- 1);
538 RefreshIcons(iwt
, NULL
);
540 ReadResult
= DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_ReadIconList
, 0L);
542 SetAttrs(iwt
->iwt_WindowTask
.mt_MainObject
,
543 SCCA_IconWin_Reading
, FALSE
,
548 if (ScanDirIsError(ReadResult
))
551 iwt
->iwt_CloseWindow
= TRUE
;
556 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
, SETVIRTF_AdjustBottomSlider
| SETVIRTF_AdjustRightSlider
);
559 d1(KPrintF("%s/%s/%ld: END iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
565 static struct ScaIconNode
*ReadDevIcon_Device(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
)
567 struct ScaIconNode
*in
= NULL
;
571 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, di
, di
->di_Device
));
574 DevName
= AllocPathBuffer();
578 stccpy(DevName
, di
->di_Device
, Max_PathLen
- 4);
580 d1(kprintf("%s/%s/%ld: DevName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, DevName
));
582 if (MAKE_ID('B','A','D',0) == di
->di_Info
->id_DiskType
)
583 SafeStrCat(DevName
, GetLocString(MSGID_DISK_UNREADABLE
), Max_PathLen
);
584 else if (MAKE_ID('B','U','S','Y') == di
->di_Info
->id_DiskType
)
585 SafeStrCat(DevName
, GetLocString(MSGID_DISK_BUSY
), Max_PathLen
);
586 else if (MAKE_ID('N','D','O','S') == di
->di_Info
->id_DiskType
) // +jmc+
587 SafeStrCat(DevName
, GetLocString(MSGID_DISK_NDOS
), Max_PathLen
);
589 strncat(DevName
, (STRPTR
) &di
->di_Info
->id_DiskType
, 4);
591 // GetDefIconObject()
592 iconObj
= GetDefIconObjectTags(WBKICK
,
593 IDTA_InnerBottom
, CurrentPrefs
.pref_ImageBorders
.Bottom
,
594 IDTA_InnerRight
, CurrentPrefs
.pref_ImageBorders
.Right
,
595 IDTA_InnerTop
, CurrentPrefs
.pref_ImageBorders
.Top
,
596 IDTA_InnerLeft
, CurrentPrefs
.pref_ImageBorders
.Left
,
597 IDTA_HalfShinePen
, PalettePrefs
.pal_PensList
[PENIDX_HSHINEPEN
],
598 IDTA_HalfShadowPen
, PalettePrefs
.pal_PensList
[PENIDX_HSHADOWPEN
],
599 IDTA_FrameTypeSel
, CurrentPrefs
.pref_FrameTypeSel
,
600 IDTA_FrameType
, CurrentPrefs
.pref_FrameType
,
601 IDTA_TextSkip
, CurrentPrefs
.pref_TextSkip
,
602 IDTA_MultiLineText
, (ULONG
) CurrentPrefs
.pref_IconTextMuliLine
,
603 IDTA_TextPen
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPEN
],
604 IDTA_TextPenSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENSEL
],
605 IDTA_TextPenShadow
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTSHADOWPEN
],
606 IDTA_TextPenOutline
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTOUTLINEPEN
],
607 IDTA_TextPenBgSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENBGSEL
],
608 IDTA_SelectedTextRectangle
, CurrentPrefs
.pref_SelectedTextRectangle
,
609 IDTA_SelTextRectBorderX
, CurrentPrefs
.pref_SelTextRectBorderX
,
610 IDTA_SelTextRectBorderY
, CurrentPrefs
.pref_SelTextRectBorderY
,
611 IDTA_SelTextRectRadius
, CurrentPrefs
.pref_SelTextRectRadius
,
612 IDTA_TextMode
, CurrentPrefs
.pref_TextMode
,
613 IDTA_TextDrawMode
, FontPrefs
.fprf_TextDrawMode
,
614 IDTA_TextBackPen
, FontPrefs
.fprf_FontBackPen
,
615 DTA_Name
, (ULONG
) di
->di_Device
,
616 IDTA_Text
, (ULONG
) DevName
,
617 IDTA_Font
, (ULONG
) iwt
->iwt_IconFont
,
618 IDTA_Fonthandle
, (ULONG
) &iwt
->iwt_IconTTFont
,
619 IDTA_FontHook
, (ULONG
) (TTEngineBase
? &ScalosFontHook
: NULL
),
620 IDTA_SizeConstraints
, (ULONG
) &iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconSizeConstraints
,
621 IDTA_ScalePercentage
, iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconScaleFactor
,
626 in
= DevIconOk2(iwt
, di
, iconObj
);
630 FreePathBuffer(DevName
);
636 static struct ScaIconNode
*ReadDevIcon_Volume(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
)
639 BPTR oldDir
= NOT_A_LOCK
;
640 STRPTR DevName
= NULL
;
641 struct ScaIconNode
*in
= NULL
;
642 Object
*iconObj
= NULL
;
644 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, di
, di
->di_Volume
));
647 dLock
= Lock(di
->di_Device
, ACCESS_READ
);
648 if ((BPTR
)NULL
== dLock
)
653 oldDir
= CurrentDir(dLock
);
655 DevName
= AllocPathBuffer();
659 stccpy(DevName
, di
->di_Volume
, Max_PathLen
- 1);
660 StripTrailingColon(DevName
);
662 d1(KPrintF("%s/%s/%ld: DevName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, DevName
));
663 d1(KPrintF("%s/%s/%ld: pref_DefIconsFirst=%ld\n", __FILE__
, __FUNC__
, __LINE__
, CurrentPrefs
.pref_DefIconsFirst
));
665 if (CurrentPrefs
.pref_DefIconsFirst
)
667 iconObj
= ReadDefaultVolumeIcon(iwt
, di
, DevName
);
668 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
671 iconObj
= ReadDefaultDeviceIcon(iwt
, di
, DevName
);
673 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
675 iconObj
= ReadDiskIcon(iwt
, di
, DevName
);
679 iconObj
= ReadDiskIcon(iwt
, di
, DevName
);
681 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
683 iconObj
= ReadDefaultVolumeIcon(iwt
, di
, DevName
);
685 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
687 iconObj
= ReadDefaultDeviceIcon(iwt
, di
, DevName
);
690 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
693 iconObj
= ReturnDefIconObjTags(dLock
, "",
694 IDTA_InnerBottom
, CurrentPrefs
.pref_ImageBorders
.Bottom
,
695 IDTA_InnerRight
, CurrentPrefs
.pref_ImageBorders
.Right
,
696 IDTA_InnerTop
, CurrentPrefs
.pref_ImageBorders
.Top
,
697 IDTA_InnerLeft
, CurrentPrefs
.pref_ImageBorders
.Left
,
698 IDTA_HalfShinePen
, PalettePrefs
.pal_PensList
[PENIDX_HSHINEPEN
],
699 IDTA_HalfShadowPen
, PalettePrefs
.pal_PensList
[PENIDX_HSHADOWPEN
],
700 IDTA_FrameTypeSel
, CurrentPrefs
.pref_FrameTypeSel
,
701 IDTA_FrameType
, CurrentPrefs
.pref_FrameType
,
702 IDTA_TextSkip
, CurrentPrefs
.pref_TextSkip
,
703 IDTA_MultiLineText
, (ULONG
) CurrentPrefs
.pref_IconTextMuliLine
,
704 IDTA_TextPen
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPEN
],
705 IDTA_TextPenSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENSEL
],
706 IDTA_TextPenShadow
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTSHADOWPEN
],
707 IDTA_TextPenOutline
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTOUTLINEPEN
],
708 IDTA_TextPenBgSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENBGSEL
],
709 IDTA_SelectedTextRectangle
, CurrentPrefs
.pref_SelectedTextRectangle
,
710 IDTA_SelTextRectBorderX
, CurrentPrefs
.pref_SelTextRectBorderX
,
711 IDTA_SelTextRectBorderY
, CurrentPrefs
.pref_SelTextRectBorderY
,
712 IDTA_SelTextRectRadius
, CurrentPrefs
.pref_SelTextRectRadius
,
713 IDTA_TextMode
, CurrentPrefs
.pref_TextMode
,
714 IDTA_TextDrawMode
, FontPrefs
.fprf_TextDrawMode
,
715 IDTA_TextBackPen
, FontPrefs
.fprf_FontBackPen
,
716 DTA_Name
, (ULONG
) di
->di_Device
,
717 IDTA_Text
, (ULONG
) DevName
,
718 IDTA_Font
, (ULONG
) iwt
->iwt_IconFont
,
719 IDTA_Fonthandle
, (ULONG
) &iwt
->iwt_IconTTFont
,
720 IDTA_FontHook
, (ULONG
) (TTEngineBase
? &ScalosFontHook
: NULL
),
721 IDTA_SizeConstraints
, (ULONG
) &iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconSizeConstraints
,
722 IDTA_ScalePercentage
, iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconScaleFactor
,
726 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
728 iconObj
= ReadDefaultIcon(iwt
, di
, DevName
);
732 in
= DevIconOk2(iwt
, di
, iconObj
);
734 if (IS_VALID_LOCK(oldDir
))
739 FreePathBuffer(DevName
);
745 // try to read <pref_DefIconPath>/<VolumeName>.info
746 static Object
*ReadDefaultVolumeIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
)
749 STRPTR iconName
= DevName
+ strlen(DevName
) + 1;
750 size_t iconNameLen
= Max_PathLen
- strlen(DevName
) - 2;
752 stccpy(iconName
, CurrentPrefs
.pref_DefIconPath
, iconNameLen
);
753 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iconName
, iconNameLen
));
754 AddPart(iconName
, "", iconNameLen
);
755 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iconName
, iconNameLen
));
756 SafeStrCat(iconName
, "def_", iconNameLen
);
757 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iconName
, iconNameLen
));
758 SafeStrCat(iconName
, di
->di_Volume
, iconNameLen
);
759 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iconName
, iconNameLen
));
760 StripTrailingColon(iconName
);
762 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, iconName
));
764 iconObj
= ReadDefaultIconByName(iwt
, iconName
, DevName
);
768 // Try again, but remove spaces from di->di_Volume
773 stccpy(iconName
, CurrentPrefs
.pref_DefIconPath
, iconNameLen
);
774 AddPart(iconName
, "", iconNameLen
);
775 SafeStrCat(iconName
, "def_", iconNameLen
);
777 Len
= iconNameLen
- 1 - strlen(iconName
);
779 dlp
= iconName
+ strlen(iconName
);
790 StripTrailingColon(iconName
);
792 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, iconName
));
794 iconObj
= ReadDefaultIconByName(iwt
, iconName
, DevName
);
797 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
803 // try to read <pref_DefIconPath>/<DeviceName>.info
804 static Object
*ReadDefaultDeviceIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
)
807 STRPTR iconName
= DevName
+ strlen(DevName
) + 1;
808 size_t iconNameLen
= Max_PathLen
- strlen(DevName
) - 2;
810 stccpy(iconName
, CurrentPrefs
.pref_DefIconPath
, iconNameLen
);
811 AddPart(iconName
, "", iconNameLen
);
812 SafeStrCat(iconName
, "def_", iconNameLen
);
813 SafeStrCat(iconName
, di
->di_Device
, iconNameLen
);
814 StripTrailingColon(iconName
);
816 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, iconName
));
818 iconObj
= ReadDefaultIconByName(iwt
, iconName
, DevName
);
820 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
826 // try to read "disk.info" icon from volume
827 static Object
*ReadDiskIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
)
831 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, di
, di
->di_Volume
));
834 iconObj
= NewIconObjectTags("disk",
835 IDTA_InnerBottom
, CurrentPrefs
.pref_ImageBorders
.Bottom
,
836 IDTA_InnerRight
, CurrentPrefs
.pref_ImageBorders
.Right
,
837 IDTA_InnerTop
, CurrentPrefs
.pref_ImageBorders
.Top
,
838 IDTA_InnerLeft
, CurrentPrefs
.pref_ImageBorders
.Left
,
839 IDTA_HalfShinePen
, PalettePrefs
.pal_PensList
[PENIDX_HSHINEPEN
],
840 IDTA_HalfShadowPen
, PalettePrefs
.pal_PensList
[PENIDX_HSHADOWPEN
],
841 IDTA_FrameTypeSel
, CurrentPrefs
.pref_FrameTypeSel
,
842 IDTA_FrameType
, CurrentPrefs
.pref_FrameType
,
843 IDTA_TextSkip
, CurrentPrefs
.pref_TextSkip
,
844 IDTA_MultiLineText
, (ULONG
) CurrentPrefs
.pref_IconTextMuliLine
,
845 IDTA_TextPen
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPEN
],
846 IDTA_TextPenSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENSEL
],
847 IDTA_TextPenShadow
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTSHADOWPEN
],
848 IDTA_TextPenOutline
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTOUTLINEPEN
],
849 IDTA_TextPenBgSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENBGSEL
],
850 IDTA_SelectedTextRectangle
, CurrentPrefs
.pref_SelectedTextRectangle
,
851 IDTA_SelTextRectBorderX
, CurrentPrefs
.pref_SelTextRectBorderX
,
852 IDTA_SelTextRectBorderY
, CurrentPrefs
.pref_SelTextRectBorderY
,
853 IDTA_SelTextRectRadius
, CurrentPrefs
.pref_SelTextRectRadius
,
854 IDTA_TextMode
, CurrentPrefs
.pref_TextMode
,
855 IDTA_TextDrawMode
, FontPrefs
.fprf_TextDrawMode
,
856 IDTA_TextBackPen
, FontPrefs
.fprf_FontBackPen
,
857 IDTA_Font
, (ULONG
) iwt
->iwt_IconFont
,
858 IDTA_Fonthandle
, (ULONG
) &iwt
->iwt_IconTTFont
,
859 IDTA_FontHook
, (ULONG
) (TTEngineBase
? &ScalosFontHook
: NULL
),
860 IDTA_SupportedIconTypes
, CurrentPrefs
.pref_SupportedIconTypes
,
861 IDTA_SizeConstraints
, (ULONG
) &iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconSizeConstraints
,
862 IDTA_ScalePercentage
, iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconScaleFactor
,
865 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
871 GetAttr(IDTA_Type
, iconObj
, &IconType
);
873 d1(kprintf("%s/%s/%ld: iconObj=%08lx IconType=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
, IconType
));
875 if (WBDISK
== IconType
)
878 IDTA_Text
, (ULONG
) DevName
,
883 DisposeIconObject(iconObj
);
888 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
894 // try to get default WBDISK icon
895 static Object
*ReadDefaultIcon(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, STRPTR DevName
)
898 ULONG IconType
= WBDISK
;
900 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, di
, di
->di_Volume
));
902 switch (di
->di_Info
->id_DiskType
)
904 case ID_NOT_REALLY_DOS
:
905 case ID_KICKSTART_DISK
:
910 // GetDefIconObject()
911 iconObj
= GetDefIconObjectTags(IconType
,
912 IDTA_InnerBottom
, CurrentPrefs
.pref_ImageBorders
.Bottom
,
913 IDTA_InnerRight
, CurrentPrefs
.pref_ImageBorders
.Right
,
914 IDTA_InnerTop
, CurrentPrefs
.pref_ImageBorders
.Top
,
915 IDTA_InnerLeft
, CurrentPrefs
.pref_ImageBorders
.Left
,
916 IDTA_HalfShinePen
, PalettePrefs
.pal_PensList
[PENIDX_HSHINEPEN
],
917 IDTA_HalfShadowPen
, PalettePrefs
.pal_PensList
[PENIDX_HSHADOWPEN
],
918 IDTA_FrameTypeSel
, CurrentPrefs
.pref_FrameTypeSel
,
919 IDTA_FrameType
, CurrentPrefs
.pref_FrameType
,
920 IDTA_TextSkip
, CurrentPrefs
.pref_TextSkip
,
921 IDTA_MultiLineText
, (ULONG
) CurrentPrefs
.pref_IconTextMuliLine
,
922 IDTA_TextPen
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPEN
],
923 IDTA_TextPenSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENSEL
],
924 IDTA_TextPenShadow
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTSHADOWPEN
],
925 IDTA_TextPenOutline
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTOUTLINEPEN
],
926 IDTA_TextPenBgSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENBGSEL
],
927 IDTA_SelectedTextRectangle
, CurrentPrefs
.pref_SelectedTextRectangle
,
928 IDTA_SelTextRectBorderX
, CurrentPrefs
.pref_SelTextRectBorderX
,
929 IDTA_SelTextRectBorderY
, CurrentPrefs
.pref_SelTextRectBorderY
,
930 IDTA_SelTextRectRadius
, CurrentPrefs
.pref_SelTextRectRadius
,
931 IDTA_TextMode
, CurrentPrefs
.pref_TextMode
,
932 IDTA_TextDrawMode
, FontPrefs
.fprf_TextDrawMode
,
933 IDTA_TextBackPen
, FontPrefs
.fprf_FontBackPen
,
934 DTA_Name
, (ULONG
) di
->di_Device
,
935 IDTA_Text
, (ULONG
) DevName
,
936 IDTA_Font
, (ULONG
) iwt
->iwt_IconFont
,
937 IDTA_Fonthandle
, (ULONG
) &iwt
->iwt_IconTTFont
,
938 IDTA_FontHook
, (ULONG
) (TTEngineBase
? &ScalosFontHook
: NULL
),
948 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
954 static struct ScaIconNode
*DevIconOk2(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
, Object
*iconObj
)
956 struct ScaIconNode
*in
;
959 struct ExtGadget
*gg
= (struct ExtGadget
*) iconObj
;
961 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, di
, iconObj
));
964 if (DoMethod(iconObj
, IDTM_FindToolType
, "SCALOS_NOTEXT", &tt
))
966 d1(kprintf("%s/%s/%ld: SCALOS_NOTEXT\n", __FILE__
, __FUNC__
, __LINE__
));
973 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, di
, iconObj
));
975 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_LayoutIcon
, iconObj
, IOLAYOUTF_NormalImage
);
977 ScalosLockIconListExclusive(iwt
);
979 d1(KPrintF("%s/%s/%ld: iwt=%08lx di=%08lx iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, di
, iconObj
));
981 if (IsNoIconPosition(gg
))
982 in
= SCA_AllocIconNode(&iwt
->iwt_WindowTask
.wt_LateIconList
);
984 in
= SCA_AllocIconNode(&iwt
->iwt_WindowTask
.wt_IconList
);
987 ScalosUnLockIconList(iwt
);
995 StartDeviceIconNotify(iwt
, di
);
997 SetIconName(iconObj
, in
);
999 in
->in_Icon
= di
->di_Icon
= iconObj
;
1000 in
->in_DeviceIcon
= di
;
1001 // in->in_FileType = (struct TypeNode *) WBDISK;
1002 in
->in_FileType
= DefIconsIdentify(BNULL
, di
->di_Volume
, WBDISK
);
1003 in
->in_Flags
|= INF_Identified
;
1005 d1(KPrintF("%s/%s/%ld: <%s> in_FileType=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, GetIconName(in
), in
->in_FileType
));
1006 DateStamp(&in
->in_DateStamp
);
1008 if (!ClassCheckInfoData(di
->di_Info
))
1010 in
->in_Flags
|= INF_VolumeWriteProtected
;
1011 AddIconOverlay(in
->in_Icon
, ICONOVERLAYF_ReadOnly
);
1014 SetDeviceIconSupportsFlags(in
);
1016 if (!(in
->in_SupportFlags
& INF_SupportsOpen
))
1018 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
1020 gg
->Flags
|= GFLG_DISABLED
;
1023 d1(kprintf("%s/%s/%ld: <%s> SupportFlags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, \
1024 GetIconName(in
), in
->in_SupportFlags
));
1027 if (DoMethod(iconObj
, IDTM_FindToolType
, "SCALOS_NODRAG", &tt
))
1029 in
->in_Flags
|= INF_Sticky
;
1032 ScalosUnLockIconList(iwt
);
1034 if (!IsNoIconPosition(gg
))
1036 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1038 if ((!iwt
->iwt_BackDrop
|| !CheckPosition(iwt
, in
)) && !CheckOverlap(iwt
, in
))
1039 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_DrawIcon
, iconObj
);
1042 GetAttr(IDTA_Type
, iconObj
, &IconType
);
1044 if (WBDISK
== IconType
)
1046 // Read and display backdrop icons
1047 ReadDevBackdrop(iwt
, in
);
1054 static LONG
ReadDevBackdrop(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*DevIn
)
1056 STRPTR fName
= NULL
;
1057 struct BackDropList bdl
;
1059 BPTR oldDir
= NOT_A_LOCK
;
1062 d1(kprintf("%s/%s/%ld: START iwt=%08lx DevIn=%08lx <%s> in_DeviceIcon=%08lx\n", \
1063 __FILE__
, __FUNC__
, __LINE__
, iwt
, DevIn
, DevIn
->in_Name
, DevIn
->in_DeviceIcon
));
1065 BackDropInitList(&bdl
);
1068 struct ChainedLine
*cnl
;
1070 d1(kprintf("%s/%s/%ld: di_Device=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, DevIn
->in_DeviceIcon
->di_Device
));
1072 vLock
= Lock(DevIn
->in_DeviceIcon
->di_Device
, ACCESS_READ
);
1073 d1(kprintf("%s/%s/%ld: vLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, vLock
));
1074 debugLock_d1(vLock
);
1078 d1(kprintf("%s/%s/%ld: vLock=NULL, Result=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Result
));
1082 oldDir
= CurrentDir(vLock
);
1084 Result
= BackdropLoadList(&bdl
);
1085 if (RETURN_OK
!= Result
)
1087 d1(kprintf("%s/%s/%ld: BackdropLoadList() failed, Result=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Result
));
1091 fName
= AllocPathBuffer();
1094 Result
= ERROR_NO_FREE_STORE
;
1095 d1(kprintf("%s/%s/%ld: AllocPathBuffer() failed, Result=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Result
));
1099 for (cnl
= (struct ChainedLine
*) bdl
.bdl_LinesList
.lh_Head
;
1100 RETURN_OK
== Result
&& cnl
!= (struct ChainedLine
*) &bdl
.bdl_LinesList
.lh_Tail
;
1101 cnl
= (struct ChainedLine
*) cnl
->cnl_Node
.ln_Succ
)
1103 d1(kprintf("%s/%s/%ld: Line=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, cnl
->cnl_Line
));
1104 CreateBackdropIcon(iwt
, &bdl
, DevIn
, cnl
->cnl_Line
, fName
);
1108 if (DevIn
&& DevIn
->in_DeviceIcon
)
1110 d1(kprintf("%s/%s/%ld: setting DIBF_BackdropReadComplete flag\n", __FILE__
, __FUNC__
, __LINE__
));
1111 DevIn
->in_DeviceIcon
->di_Flags
|= DIBF_BackdropReadComplete
;
1114 BackdropFreeList(&bdl
);
1116 d1(kprintf("%s/%s/%ld: vLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, vLock
));
1118 if (IS_VALID_LOCK(oldDir
))
1123 FreePathBuffer(fName
);
1125 d1(kprintf("%s/%s/%ld: END Result=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Result
));
1131 static struct ScaIconNode
*CreateBackdropIcon(struct internalScaWindowTask
*iwt
,
1132 struct BackDropList
*bdl
, struct ScaIconNode
*DevIn
,
1133 CONST_STRPTR BackdropIconName
, STRPTR fName
)
1139 Object
*iconObj
= NULL
;
1140 struct ScaIconNode
*in
= NULL
;
1141 struct ExtGadget
*gg
;
1142 BPTR dirLock
= (BPTR
)NULL
;
1143 BPTR oldDir
= NOT_A_LOCK
;
1144 BPTR iLock
; // +++ JMC 28.11.2004
1145 T_ExamineData
*fib
= NULL
; // +++ JMC 28.11.2004
1148 d1(kprintf("%s/%s/%ld: START BackdropIconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, BackdropIconName
));
1152 if (strlen(BackdropIconName
) < 1)
1155 stccpy(fName
, BackdropIconName
, Max_PathLen
- 1);
1157 lp
= PathPart(fName
);
1161 d1(kprintf("%s/%s/%ld: PathPart=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, fName
));
1163 dirLock
= Lock(fName
, ACCESS_READ
);
1167 debugLock_d1(dirLock
);
1168 if ((BPTR
)NULL
== dirLock
)
1171 oldDir
= CurrentDir(dirLock
);
1173 lp
= FilePart(fName
);
1174 d1(kprintf("%s/%s/%ld: FilePart=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, lp
));
1176 //-----------------------------------------------------------------------------
1177 // +++ JMC 28.11.2004
1178 // Check if the object got
1179 // a Hidden protection bit activated before to display it on desktop.
1181 if (CurrentPrefs
.pref_HideProtectHiddenFlag
)
1183 if (!ScalosExamineBegin(&fib
))
1186 d1(kprintf("%s/%s/%ld: AllocDosObject failed\n", __FILE__
, __FUNC__
, __LINE__
));
1189 iLock
= Lock(PathPart(fName
), SHARED_LOCK
);
1192 ScalosExamineLock(iLock
, &fib
);
1193 if (ScalosExamineGetProtection(fib
) & FIBF_HIDDEN
)
1195 d1(kprintf("%s/%s/%ld: <%s> FIBF_HIDDEN found!\n", __FILE__
, __FUNC__
, __LINE__
, PathPart(fName
)));
1203 //-----------------------------------------------------------------------------
1205 if (FindIconInDrawerWindows(dirLock
, lp
))
1207 d1(kprintf("%s/%s/%ld: <%s> Icon found in drawer window!\n", __FILE__
, __FUNC__
, __LINE__
, PathPart(fName
)));
1211 iconObj
= NewIconObjectTags(lp
,
1212 IDTA_Text
, (ULONG
) lp
,
1213 IDTA_InnerBottom
, CurrentPrefs
.pref_ImageBorders
.Bottom
,
1214 IDTA_InnerRight
, CurrentPrefs
.pref_ImageBorders
.Right
,
1215 IDTA_InnerTop
, CurrentPrefs
.pref_ImageBorders
.Top
,
1216 IDTA_InnerLeft
, CurrentPrefs
.pref_ImageBorders
.Left
,
1217 IDTA_HalfShinePen
, PalettePrefs
.pal_PensList
[PENIDX_HSHINEPEN
],
1218 IDTA_HalfShadowPen
, PalettePrefs
.pal_PensList
[PENIDX_HSHADOWPEN
],
1219 IDTA_FrameTypeSel
, CurrentPrefs
.pref_FrameTypeSel
,
1220 IDTA_FrameType
, CurrentPrefs
.pref_FrameType
,
1221 IDTA_TextSkip
, CurrentPrefs
.pref_TextSkip
,
1222 IDTA_MultiLineText
, (ULONG
) CurrentPrefs
.pref_IconTextMuliLine
,
1223 IDTA_TextPen
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPEN
],
1224 IDTA_TextPenSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENSEL
],
1225 IDTA_TextPenShadow
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTSHADOWPEN
],
1226 IDTA_TextPenOutline
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTOUTLINEPEN
],
1227 IDTA_TextPenBgSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENBGSEL
],
1228 IDTA_SelectedTextRectangle
, CurrentPrefs
.pref_SelectedTextRectangle
,
1229 IDTA_SelTextRectBorderX
, CurrentPrefs
.pref_SelTextRectBorderX
,
1230 IDTA_SelTextRectBorderY
, CurrentPrefs
.pref_SelTextRectBorderY
,
1231 IDTA_SelTextRectRadius
, CurrentPrefs
.pref_SelTextRectRadius
,
1232 IDTA_TextMode
, CurrentPrefs
.pref_TextMode
,
1233 IDTA_TextDrawMode
, FontPrefs
.fprf_TextDrawMode
,
1234 IDTA_TextBackPen
, FontPrefs
.fprf_FontBackPen
,
1235 IDTA_Font
, (ULONG
) iwt
->iwt_IconFont
,
1236 IDTA_Fonthandle
, (ULONG
) &iwt
->iwt_IconTTFont
,
1237 IDTA_FontHook
, (ULONG
) (TTEngineBase
? &ScalosFontHook
: NULL
),
1238 IDTA_SupportedIconTypes
, CurrentPrefs
.pref_SupportedIconTypes
,
1239 IDTA_SizeConstraints
, (ULONG
) &iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconSizeConstraints
,
1240 IDTA_ScalePercentage
, iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconScaleFactor
,
1241 IDTA_OverlayType
, ICONOVERLAYF_LeftOut
,
1244 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
1245 if (NULL
== iconObj
)
1248 gg
= (struct ExtGadget
*) iconObj
;
1250 GetAttr(IDTA_Type
, iconObj
, &IconType
);
1252 d1(kprintf("%s/%s/%ld: IconType=%ld\n", __FILE__
, __FUNC__
, __LINE__
, IconType
));
1253 if (WBDISK
== IconType
)
1257 if (DoMethod(iconObj
, IDTM_FindToolType
, "SCALOS_NOTEXT", &tt
))
1259 d1(kprintf("%s/%s/%ld: SCALOS_NOTEXT\n", __FILE__
, __FUNC__
, __LINE__
));
1265 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_LayoutIcon
, iconObj
, IOLAYOUTF_NormalImage
);
1267 ScalosLockIconListExclusive(iwt
);
1269 if (IsNoIconPosition(gg
))
1270 in
= SCA_AllocIconNode(&iwt
->iwt_WindowTask
.wt_LateIconList
);
1272 in
= SCA_AllocIconNode(&iwt
->iwt_WindowTask
.wt_IconList
);
1276 SetIconName(iconObj
, in
);
1278 DateStamp(&in
->in_DateStamp
);
1280 in
->in_Icon
= iconObj
;
1281 in
->in_Lock
= CurrentDir(oldDir
);
1282 oldDir
= NOT_A_LOCK
;
1283 dirLock
= (BPTR
)NULL
; // do not UnLock() !!!s
1285 if (WBTOOL
== IconType
|| WBPROJECT
== IconType
)
1287 in
->in_Flags
|= INF_File
;
1290 SetBackdropIconSupportsFlags(iwt
, bdl
, in
);
1293 if (DoMethod(iconObj
, IDTM_FindToolType
, "SCALOS_NODRAG", &tt
))
1295 in
->in_Flags
|= INF_Sticky
;
1298 if (!ClassCheckInfoData(DevIn
->in_DeviceIcon
->di_Info
))
1300 in
->in_Flags
|= INF_VolumeWriteProtected
;
1301 AddIconOverlay(in
->in_Icon
, ICONOVERLAYF_ReadOnly
);
1304 ScalosUnLockIconList(iwt
);
1306 if (!IsNoIconPosition(gg
))
1308 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1310 if ((!iwt
->iwt_BackDrop
|| !CheckPosition(iwt
, in
)) && !CheckOverlap(iwt
, in
))
1311 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_DrawIcon
, iconObj
);
1314 CreateSbi(DevIn
, in
);
1319 if (IS_VALID_LOCK(oldDir
))
1324 DisposeIconObject(iconObj
);
1325 ScalosExamineEnd(&fib
);
1327 d1(kprintf("%s/%s/%ld: END in=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, in
));
1333 // Frees everything inside the ScaBackdropIcon, but does not free the node itself !!
1334 static void FreeBackdropIcon(struct ScaBackdropIcon
*bdi
)
1336 d1(kprintf("%s/%s/%ld: bdi=%08lx sbi_NotifyReq=%08lx sbi_DrawerName=%08lx <%s>\n", \
1337 __FILE__
, __FUNC__
, __LINE__
, bdi
, bdi
->sbi_NotifyReq
, bdi
->sbi_DrawerName
, bdi
->sbi_DrawerName
));
1342 if (bdi
->sbi_NotifyReq
)
1344 ScalosEndNotify(bdi
->sbi_NotifyReq
);
1346 ScalosFree(bdi
->sbi_NotifyReq
);
1347 bdi
->sbi_NotifyReq
= NULL
;
1349 if (bdi
->sbi_DrawerName
)
1351 FreePathBuffer(bdi
->sbi_DrawerName
);
1352 bdi
->sbi_DrawerName
= NULL
;
1357 void FreeBackdropIconList(struct ScaBackdropIcon
**bdiList
)
1359 struct ScaBackdropIcon
*bdi
, *bdiNext
;
1361 d1(kprintf("%s/%s/%ld: START *bdiList=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, *bdiList
));
1363 for (bdi
=*bdiList
; bdi
; bdi
= bdiNext
)
1365 bdiNext
= (struct ScaBackdropIcon
*) bdi
->sbi_Node
.mln_Succ
;
1367 d1(kprintf("%s/%s/%ld: bdi=%08lx bdiNext=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, bdi
, bdiNext
));
1369 FreeBackdropIcon(bdi
);
1370 SCA_FreeNode((struct ScalosNodeList
*) bdiList
, &bdi
->sbi_Node
);
1373 d1(kprintf("%s/%s/%ld: END *bdiList=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, *bdiList
));
1377 // remove ScalosBackdropIcon from in_IconList of the parent device icon
1378 void RemoveScalosBackdropIcon(struct ScaIconNode
*in
)
1380 struct internalScaWindowTask
*iwtMain
;
1381 struct ScaBackdropIcon
*bdiList
= NULL
;
1382 struct ScaIconNode
*inDev
;
1384 d1(kprintf("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
1386 if (NULL
== iInfos
.xii_iinfos
.ii_MainWindowStruct
)
1389 iwtMain
= (struct internalScaWindowTask
*) iInfos
.xii_iinfos
.ii_MainWindowStruct
->ws_WindowTask
;
1391 ScalosLockIconListExclusive(iwtMain
);
1393 for (inDev
=iwtMain
->iwt_WindowTask
.wt_IconList
; inDev
; inDev
= (struct ScaIconNode
*) inDev
->in_Node
.mln_Succ
)
1395 if (inDev
->in_IconList
)
1397 struct ScaBackdropIcon
*sbi
, *sbiNext
;
1399 for (sbi
=inDev
->in_IconList
; sbi
; sbi
= sbiNext
)
1401 sbiNext
= (struct ScaBackdropIcon
*) sbi
->sbi_Node
.mln_Succ
;
1403 if (sbi
->sbi_Icon
== in
->in_Icon
)
1405 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_NotifyReq=%08lx sbi_DrawerName=%08lx <%s>\n",\
1406 __FILE__
, __FUNC__
, __LINE__
, sbi
, sbi
->sbi_NotifyReq
, sbi
->sbi_DrawerName
, sbi
->sbi_DrawerName
));
1408 SCA_MoveNode((struct ScalosNodeList
*)(APTR
) &inDev
->in_IconList
,
1409 (struct ScalosNodeList
*)(APTR
) &bdiList
,
1412 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_NotifyReq=%08lx sbi_DrawerName=%08lx <%s>\n",\
1413 __FILE__
, __FUNC__
, __LINE__
, sbi
, sbi
->sbi_NotifyReq
, sbi
->sbi_DrawerName
, sbi
->sbi_DrawerName
));
1419 d1(kprintf("%s/%s/%ld: bdiList=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, bdiList
));
1421 FreeBackdropIconList(&bdiList
);
1423 ScalosUnLockIconList(iwtMain
);
1427 // Create <ScaBackdropIcon> entry for <in> in <DevIn->in_IconList>
1428 static BOOL
CreateSbi(struct ScaIconNode
*DevIn
, struct ScaIconNode
*in
)
1430 struct internalScaWindowTask
*iwtMain
= (struct internalScaWindowTask
*) iInfos
.xii_iinfos
.ii_MainWindowStruct
->ws_WindowTask
;
1431 struct ScaBackdropIcon
*bdi
;
1432 BOOL NotifySuccess
= FALSE
;
1433 BOOL Success
= FALSE
;
1435 d1(kprintf("%s/%s/%ld: DevIn=%08lx <%s> in=%08lx <%s>\n", \
1436 __FILE__
, __FUNC__
, __LINE__
, DevIn
, GetIconName(DevIn
), in
, GetIconName(in
)));
1439 bdi
= (struct ScaBackdropIcon
*) SCA_AllocNode((struct ScalosNodeList
*) &DevIn
->in_IconList
,
1440 sizeof(struct ScaBackdropIcon
) - sizeof(struct MinNode
));
1444 bdi
->sbi_Icon
= in
->in_Icon
;
1446 bdi
->sbi_NotifyReq
= ScalosAlloc(sizeof(struct NotifyRequest
));
1447 if (NULL
== bdi
->sbi_NotifyReq
)
1450 memset(bdi
->sbi_NotifyReq
, 0, sizeof(struct NotifyRequest
));
1452 d1(kprintf("%s/%s/%ld: bdi=%08lx NotifyReq=%08lx\n", \
1453 __FILE__
, __FUNC__
, __LINE__
, bdi
, bdi
->sbi_NotifyReq
));
1455 bdi
->sbi_DrawerName
= AllocPathBuffer();
1456 if (NULL
== bdi
->sbi_DrawerName
)
1459 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_DrawerName=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, bdi
, bdi
->sbi_DrawerName
));
1461 if (!NameFromLock(in
->in_Lock
, bdi
->sbi_DrawerName
, MAX_FileName
-1))
1464 bdi
->sbi_NotifyReq
->nr_Name
= bdi
->sbi_DrawerName
;
1465 bdi
->sbi_NotifyReq
->nr_stuff
.nr_Msg
.nr_Port
= iwtMain
->iwt_WindowTask
.wt_IconPort
;
1466 bdi
->sbi_NotifyReq
->nr_Flags
= NRF_SEND_MESSAGE
;
1467 bdi
->sbi_NotifyReq
->nr_UserData
= (ULONG
)NULL
;
1469 d1(kprintf("%s/%s/%ld: starting notification on <%s>\n", \
1470 __FILE__
, __FUNC__
, __LINE__
, bdi
->sbi_NotifyReq
->nr_Name
));
1474 if (!StartNotify(bdi
->sbi_NotifyReq
))
1477 d1(kprintf("%s/%s/%ld: started notification on <%s>\n", \
1478 __FILE__
, __FUNC__
, __LINE__
, bdi
->sbi_NotifyReq
->nr_Name
));
1480 NotifySuccess
= TRUE
;
1487 if (bdi
->sbi_NotifyReq
)
1489 ScalosFree(bdi
->sbi_NotifyReq
);
1490 bdi
->sbi_NotifyReq
= NULL
;
1494 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_DrawerName=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, bdi
, bdi
->sbi_DrawerName
));
1500 if (bdi
->sbi_DrawerName
)
1502 FreePathBuffer(bdi
->sbi_DrawerName
);
1503 bdi
->sbi_DrawerName
= NULL
;
1505 if (bdi
->sbi_NotifyReq
)
1507 ScalosFree(bdi
->sbi_NotifyReq
);
1508 bdi
->sbi_NotifyReq
= NULL
;
1511 SCA_FreeNode((struct ScalosNodeList
*) &DevIn
->in_IconList
, &bdi
->sbi_Node
);
1515 d1(kprintf("%s/%s/%ld: Success=%ld NotifySuccess=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
, NotifySuccess
));
1517 return NotifySuccess
;
1521 // Look for Device icon for <in>,
1522 // and create <ScaBackdropIcon> entry for <in>
1523 void CreateSbiForIcon(struct ScaIconNode
*in
)
1525 struct internalScaWindowTask
*iwtMain
= (struct internalScaWindowTask
*) iInfos
.xii_iinfos
.ii_MainWindowStruct
->ws_WindowTask
;
1526 struct ScaIconNode
*inDev
;
1527 BOOL Finished
= FALSE
;
1529 d1(kprintf("%s/%s/%ld: START in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
1530 debugLock_d1(in
->in_Lock
);
1532 if ((BPTR
)NULL
== in
->in_Lock
)
1533 return; // only useful for left-out icons
1535 ScalosLockIconListExclusive(iwtMain
);
1537 for (inDev
=iwtMain
->iwt_WindowTask
.wt_IconList
; !Finished
&& inDev
; inDev
= (struct ScaIconNode
*) inDev
->in_Node
.mln_Succ
)
1539 if (inDev
->in_DeviceIcon
)
1541 BPTR DeviceIconLock
= DiskInfoLock(inDev
);
1547 d1(kprintf("%s/%s/%ld: inDev=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, inDev
, GetIconName(inDev
)));
1549 IsSameLock
= ScaSameLock(DeviceIconLock
, in
->in_Lock
);
1550 d1(kprintf("%s/%s/%ld: SameLock()=%ld\n", __FILE__
, __FUNC__
, __LINE__
, IsSameLock
));
1554 case LOCK_SAME_VOLUME
:
1556 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1557 CreateSbi(inDev
, in
);
1564 UnLock(DeviceIconLock
);
1569 ScalosUnLockIconList(iwtMain
);
1571 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
1576 static struct ScaIconNode
*IconAlreadyExists(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
)
1578 struct ScaIconNode
*in
;
1579 struct ScaIconNode
*inFound
= NULL
;
1581 ScalosLockIconListShared(iwt
);
1583 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
1585 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; NULL
== inFound
&& in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
1587 if (in
->in_DeviceIcon
&& in
->in_DeviceIcon
->di_Handler
== di
->di_Handler
)
1589 d1(kprintf("%s/%s/%ld: Found in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
1594 if (NULL
== inFound
)
1595 ScalosUnLockIconList(iwt
);
1601 static BOOL
FindIconInDrawerWindows(BPTR dirLock
, CONST_STRPTR IconName
)
1603 struct ScaWindowStruct
*ws
;
1606 SCA_LockWindowList(SCA_LockWindowList_Shared
);
1608 for (ws
=winlist
.wl_WindowStruct
; !Found
&& ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
1610 struct internalScaWindowTask
*iwtx
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
1612 if (ws
->ws_Lock
&& LOCK_SAME
== SameLock(dirLock
, ws
->ws_Lock
))
1614 struct ScaIconNode
*in
;
1616 ScalosLockIconListShared(iwtx
);
1618 for (in
=iwtx
->iwt_WindowTask
.wt_IconList
; !Found
&& in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
1620 if (0 == Stricmp((STRPTR
) IconName
, (STRPTR
) GetIconName(in
)))
1624 ScalosUnLockIconList(iwtx
);
1630 // Search in desktop window if backdrop icon is already present
1631 struct internalScaWindowTask
*iwtx
;
1632 struct ScaIconNode
*in
;
1634 ws
= iInfos
.xii_iinfos
.ii_MainWindowStruct
;
1635 iwtx
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
1637 ScalosLockIconListShared(iwtx
);
1639 for (in
=iwtx
->iwt_WindowTask
.wt_IconList
; !Found
&& in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
1641 if (in
->in_Lock
&& LOCK_SAME
== SameLock(dirLock
, in
->in_Lock
)
1642 && (0 == Stricmp((STRPTR
) IconName
, (STRPTR
) GetIconName(in
))))
1646 ScalosUnLockIconList(iwtx
);
1648 SCA_UnLockWindowList();
1654 static Object
*ReadDefaultIconByName(struct internalScaWindowTask
*iwt
, CONST_STRPTR iconName
, STRPTR DevName
)
1658 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, iconName
));
1660 iconObj
= NewIconObjectTags(iconName
,
1661 IDTA_InnerBottom
, CurrentPrefs
.pref_ImageBorders
.Bottom
,
1662 IDTA_InnerRight
, CurrentPrefs
.pref_ImageBorders
.Right
,
1663 IDTA_InnerTop
, CurrentPrefs
.pref_ImageBorders
.Top
,
1664 IDTA_InnerLeft
, CurrentPrefs
.pref_ImageBorders
.Left
,
1665 IDTA_HalfShinePen
, PalettePrefs
.pal_PensList
[PENIDX_HSHINEPEN
],
1666 IDTA_HalfShadowPen
, PalettePrefs
.pal_PensList
[PENIDX_HSHADOWPEN
],
1667 IDTA_FrameTypeSel
, CurrentPrefs
.pref_FrameTypeSel
,
1668 IDTA_FrameType
, CurrentPrefs
.pref_FrameType
,
1669 IDTA_TextSkip
, CurrentPrefs
.pref_TextSkip
,
1670 IDTA_MultiLineText
, (ULONG
) CurrentPrefs
.pref_IconTextMuliLine
,
1671 IDTA_TextPen
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPEN
],
1672 IDTA_TextPenSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENSEL
],
1673 IDTA_TextPenShadow
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTSHADOWPEN
],
1674 IDTA_TextPenOutline
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTOUTLINEPEN
],
1675 IDTA_TextPenBgSel
, PalettePrefs
.pal_PensList
[PENIDX_ICONTEXTPENBGSEL
],
1676 IDTA_SelectedTextRectangle
, CurrentPrefs
.pref_SelectedTextRectangle
,
1677 IDTA_SelTextRectBorderX
, CurrentPrefs
.pref_SelTextRectBorderX
,
1678 IDTA_SelTextRectBorderY
, CurrentPrefs
.pref_SelTextRectBorderY
,
1679 IDTA_SelTextRectRadius
, CurrentPrefs
.pref_SelTextRectRadius
,
1680 IDTA_TextMode
, CurrentPrefs
.pref_TextMode
,
1681 IDTA_TextDrawMode
, FontPrefs
.fprf_TextDrawMode
,
1682 IDTA_TextBackPen
, FontPrefs
.fprf_FontBackPen
,
1683 IDTA_Font
, (ULONG
) iwt
->iwt_IconFont
,
1684 IDTA_Fonthandle
, (ULONG
) &iwt
->iwt_IconTTFont
,
1685 IDTA_FontHook
, (ULONG
) (TTEngineBase
? &ScalosFontHook
: NULL
),
1686 IDTA_SupportedIconTypes
, CurrentPrefs
.pref_SupportedIconTypes
,
1687 IDTA_SizeConstraints
, (ULONG
) &iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconSizeConstraints
,
1688 IDTA_ScalePercentage
, iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_IconScaleFactor
,
1695 GetAttr(IDTA_Type
, iconObj
, &IconType
);
1697 d1(kprintf("%s/%s/%ld: iconObj=%08lx IconType=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
, IconType
));
1701 IDTA_Text
, (ULONG
) DevName
,
1705 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
1711 static BOOL
StartDeviceIconNotify(struct internalScaWindowTask
*iwt
, struct ScaDeviceIcon
*di
)
1713 BOOL Success
= FALSE
;
1715 if (di
->di_NotifyReq
.nr_Name
)
1717 ScalosEndNotify(&di
->di_NotifyReq
);
1718 memset(&di
->di_NotifyReq
, 0, sizeof(di
->di_NotifyReq
));
1720 if (di
->di_DiskIconName
)
1722 FreePathBuffer(di
->di_DiskIconName
);
1723 di
->di_DiskIconName
= NULL
;
1728 CONST_STRPTR NotifyReqName
= "disk.info";
1730 di
->di_DiskIconName
= AllocPathBuffer();
1731 if (NULL
== di
->di_DiskIconName
)
1734 fLock
= Lock(NotifyReqName
, ACCESS_READ
);
1737 if (!NameFromLock(fLock
, di
->di_DiskIconName
, Max_PathLen
))
1739 FreePathBuffer(di
->di_DiskIconName
);
1740 di
->di_DiskIconName
= NULL
;
1747 stccpy(di
->di_DiskIconName
, di
->di_Device
, Max_PathLen
);
1748 AddPart(di
->di_DiskIconName
, NotifyReqName
, Max_PathLen
);
1751 d1(kprintf("%s/%s/%ld: start notify for <%s>\n", __FILE__
, __FUNC__
, __LINE__
, di
->di_Device
));
1753 di
->di_NotifyReq
.nr_Name
= di
->di_Device
;
1754 di
->di_NotifyReq
.nr_stuff
.nr_Msg
.nr_Port
= iwt
->iwt_WindowTask
.wt_IconPort
;
1755 di
->di_NotifyReq
.nr_Flags
= NRF_SEND_MESSAGE
;
1757 Success
= StartNotify(&di
->di_NotifyReq
);
1764 static void SetDeviceIconSupportsFlags(struct ScaIconNode
*in
)
1769 in
->in_SupportFlags
|= INF_SupportsOpen
| INF_SupportsCopy
| INF_SupportsInformation
1770 | INF_SupportsSnapshot
| INF_SupportsUnSnapshot
| INF_SupportsRename
;
1772 if (in
->in_DeviceIcon
)
1774 if (ID_WRITE_PROTECTED
!= in
->in_DeviceIcon
->di_Info
->id_DiskState
)
1775 in
->in_SupportFlags
|= INF_SupportsFormatDisk
;
1777 d1(kprintf("%s/%s/%ld: <%s> DiskType=%08lx DiskState=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, \
1778 GetIconName(in
), in
->in_DeviceIcon
->di_Info
->id_DiskType
, in
->in_DeviceIcon
->di_Info
->id_DiskState
));
1780 SetIconSupportsFlags(in
, ClassCheckInfoData(in
->in_DeviceIcon
->di_Info
));
1782 if (NULL
== in
->in_DeviceIcon
->di_Volume
)
1784 in
->in_SupportFlags
|= INF_SupportsFormatDisk
;
1785 in
->in_SupportFlags
&= ~(INF_SupportsOpen
| INF_SupportsCopy
| INF_SupportsInformation
1786 | INF_SupportsSnapshot
| INF_SupportsUnSnapshot
| INF_SupportsRename
);
1792 static void SetBackdropIconSupportsFlags(struct internalScaWindowTask
*iwt
,
1793 struct BackDropList
*bdl
, struct ScaIconNode
*in
)
1800 isWriteable
= ClassIsDiskWritable(in
->in_Lock
);
1802 in
->in_SupportFlags
|= INF_SupportsOpen
| INF_SupportsCopy
| INF_SupportsInformation
;
1804 d1(kprintf("%s/%s/%ld: <%s> isWriteable=%ld\n", __FILE__
, __FUNC__
, __LINE__
, GetIconName(in
), isWriteable
));
1807 in
->in_SupportFlags
|= INF_SupportsSnapshot
| INF_SupportsUnSnapshot
1808 | INF_SupportsDelete
| INF_SupportsRename
;
1810 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1812 if (IsPermanentBackDropIcon(iwt
, bdl
, in
->in_Lock
, GetIconName(in
)))
1814 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1815 in
->in_SupportFlags
|= INF_SupportsPutAway
;
1816 in
->in_SupportFlags
&= ~INF_SupportsLeaveOut
;
1820 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1821 in
->in_SupportFlags
&= ~INF_SupportsPutAway
;
1822 in
->in_SupportFlags
|= INF_SupportsLeaveOut
;
1826 SetIconSupportsFlags(in
, isWriteable
);