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 <workbench/workbench.h>
14 #include <workbench/startup.h>
15 #include <libraries/asl.h>
16 #include <cybergraphx/cybergraphics.h>
17 #include <datatypes/pictureclass.h>
19 #include <dos/dostags.h>
20 #include <dos/exall.h>
24 #include <proto/asl.h>
25 #include <proto/dos.h>
26 #include <proto/exec.h>
27 #include <proto/layers.h>
28 #include <proto/graphics.h>
29 #include <proto/intuition.h>
30 #include <proto/iconobject.h>
31 #include <proto/utility.h>
32 #include <proto/icon.h>
33 #include <proto/gadtools.h>
34 #include <proto/datatypes.h>
35 #include <proto/cybergraphics.h>
38 #include <proto/scalos.h>
40 #include <clib/alib_protos.h>
43 #include <datatypes/iconobject.h>
44 #include <scalos/scalos.h>
54 #include "scalos_structures.h"
55 #include "FsAbstraction.h"
57 #include "functions.h"
58 #include "Variables.h"
60 //----------------------------------------------------------------------------
62 // local data structures
65 // extended SM_AsyncRoutine to run xxxProg() asynchronously
68 struct SM_AsyncRoutine sma_Async
;
69 struct MenuCmdArg sma_CmdArg
;
72 // xxxProg() Function called by ProgTask()
73 typedef void (*PROGFUNC
)(struct internalScaWindowTask
*, const struct MenuCmdArg
*);
77 PROGFUNC spr_ProgFunc
;
79 struct internalScaWindowTask
*spr_WindowTask
;
81 struct MenuCmdArg spr_Arg
;
86 struct WBArg
*cla_wbArg
;
87 ULONG cla_NumArgs
; // number of entries in cla_wbArg
90 //----------------------------------------------------------------------------
94 static void SizeToFitProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
95 static void WindowPropertiesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
96 static void SelectContentsProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
97 static void NewDrawerProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
98 static void RenameProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
99 static void MenuInfoProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
100 static void IconPropertiesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
101 static void BackDropProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
102 static void RedrawAllProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
103 static void ViewByIconProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
104 static void ViewByTextProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
105 static void ViewByDateProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
106 static void ViewBySizeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
107 static void ViewByTypeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
108 static void ViewByDefaultProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
109 static void CloneProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
110 static void ThumbnailCacheCleanupProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
111 static void UpdateProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
112 static void CloseProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
113 static void FindProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
114 static void FormatDiskProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
115 static void ShutdownProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
116 static void ShowOnlyIconsProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
117 static void ShowAllFilesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
118 static void ShowDefaultProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
119 static void CleanupProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
120 static void CleanupByNameProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
121 static void CleanupByDateProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
122 static void CleanupBySizeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
123 static void CleanupByTypeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
124 static void MenuOpenProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
125 static void MenuOpenNewProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
126 static void MenuOpenBrowserWindowProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
127 static void OpenParentProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
128 static void ExecuteCmdProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
129 static void LastMessageProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
130 static void IconifyProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
131 static void RedrawProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
132 static void ResetScalosProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
133 static void AsyncResetScalosProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*dummy
);
134 static void MenuSnapshotProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
135 static void MenuUnsnapshotProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
136 static void MenuUndoProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
137 static void MenuRedoProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
138 static void SnapshotAllProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
139 static void SnapshotWindowProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
140 static void LeaveOutProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
141 static void PutAwayProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
142 static void EmptyTrashProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
143 static void MenuCopyProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
144 static void MenuCutProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
145 static void MenuPasteProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
146 static void MenuCreateThumbnailProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
148 static void AsyncPasteProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
149 static void SnapshotWindow(struct internalScaWindowTask
*iwt
);
150 static BOOL
StartProgTask(struct internalScaWindowTask
*iwt
,
151 const struct MenuCmdArg
*mcArg
, PROGFUNC ProgProc
, struct MsgPort
*ReplyPort
);
152 static SAVEDS(ULONG
) ProgTask(struct SM_StartProg
*sMsg
, struct SM_RunProcess
*msg
);
153 static void AsyncNewDrawerProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
154 static void WBIconPropertiesStart(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
155 static SAVEDS(ULONG
) IconPropertiesStart(APTR aptr
, struct SM_RunProcess
*msg
);
156 static void AsyncWindowPropertiesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
157 void AsyncRenameProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
158 void AsyncDeleteProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
159 static void LeaveOutIcon(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
160 static void PutAwayIconNode(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
161 static void DoForAllWindowsShared(struct internalScaWindowTask
*iwt
,
162 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
),
163 void (*WindowProc
)(struct internalScaWindowTask
*iwt
));
164 static void DoForAllIconsShared(struct internalScaWindowTask
*iwt
,
165 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
),
167 static void DoForAllWindows(struct internalScaWindowTask
*iwt
,
168 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
));
169 static void DoForAllIconsExclusive(struct internalScaWindowTask
*iwt
,
170 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
),
172 static SAVEDS(ULONG
) InfoStart(APTR aptr
, struct SM_RunProcess
*msg
);
173 //static struct ScaIconNode *FindIconGlobal(BPTR dirLock, CONST_STRPTR Name);
174 static void ClearSelectionInWindow(struct internalScaWindowTask
*iwt
);
175 static void MakeCloneArgs(struct internalScaWindowTask
*iwt
,
176 struct WBArg
**wbArg
, ULONG
*ArgCount
);
177 static void CloneInfoStart(struct internalScaWindowTask
*iwt
,
178 struct WBArg
**wbArg
, ULONG
*ArgCount
);
179 static BOOL
CloneWBArg(struct internalScaWindowTask
*iwt
, struct WBArg
**wbArg
,
180 struct ScaIconNode
*in
, ULONG
*ArgCount
);
181 static SAVEDS(ULONG
) CloneFilesStart(APTR aptr
, struct SM_RunProcess
*msg
);
182 static SAVEDS(LONG
) IconCompareFunc(struct Hook
*hook
, struct ScaIconNode
*in2
, struct ScaIconNode
*in1
);
183 static void SnapshotIcon(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
184 static void UnsnapshotIconAndSave(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
185 static void UnsnapshotIcon(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, BOOL SaveIcon
, APTR undoStep
);
186 static void AfterUnsnapshotIcon(struct internalScaWindowTask
*iwt
);
187 static void SetRect(struct ScaIconNode
*in
);
188 static void SetRect2(struct ScaIconNode
*in
, BPTR iconLock
);
189 static void CloseWindowProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
190 static ULONG
FindIconType(struct WBArg
*Arg
);
191 static BOOL
CallGlobalDeleteHook(struct WBArg
*wbArg
, ULONG nArgs
, ULONG Action
);
192 static void DeleteModuleKludge(struct WBArg
*wbArg
, ULONG nArgs
);
193 static void RememberFilesToCopy(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
194 static void RememberFilesToCut(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
195 static ULONG
CallTextInputHook(ULONG Action
, STRPTR Prompt
);
196 static STRPTR
FindUniqueName(STRPTR Name
, size_t MaxLength
);
197 static BOOL
CanBeSizedMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
198 static BOOL
IsMainWindowMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
199 static BOOL
NotMainWindowMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
200 static BOOL
NotRootWindowMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
201 static BOOL
MustHaveLockMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
202 static BOOL
IconsSelectedAndWriteableMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
203 static BOOL
IconsSelectedMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
204 static BOOL
IconsSelectedBrowserModeMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
205 static BOOL
IconsSelectedNotBrowserModeMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
206 static BOOL
EmptyTrashMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
207 static BOOL
FormatDiskMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
208 static BOOL
LeaveOutMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
209 static BOOL
PutAwayMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
210 static BOOL
PasteMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
211 static BOOL
UndoMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
212 static BOOL
RedoMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
213 static BOOL
NotMainWindowAndNotReadingMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
214 static BOOL
SnapshotMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
215 static BOOL
NotReadingMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
216 static BOOL
IsWriteableMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
);
217 static BOOL
IconsSelectedNoDiskMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
); // +jmc+ - Diable menu item if in->in_Device.
218 static SAVEDS(ULONG
) AsyncStartModule(APTR aptr
, struct SM_RunProcess
*msg
, CONST_STRPTR ModuleName
);
219 static void CreateThumbnailStart(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
);
220 static void DoForAppIcons(ULONG AppMsgClass
);
222 //--- +jmc+ --- CopyTo/MoveTo ------------------------------------------------
224 static void CopyToProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
225 static SAVEDS(ULONG
) CopyToStart(APTR aptr
, struct SM_RunProcess
*msg
);
227 static void MoveToProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
);
228 static SAVEDS(ULONG
) MoveToStart(APTR aptr
, struct SM_RunProcess
*msg
);
230 static void CopyToMakeCloneArgs(struct internalScaWindowTask
*iwt
,
231 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
);
232 static void CopyToCloneInfoStart(struct internalScaWindowTask
*iwt
,
233 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
);
234 static BOOL
CopyToCloneWBArg(struct internalScaWindowTask
*iwt
, struct WBArg
**wbArg
,
235 struct ScaIconNode
*in
, ULONG
*ArgCount
, ULONG MaxArgs
);
237 static void MoveToMakeCloneArgs(struct internalScaWindowTask
*iwt
,
238 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
);
239 static void MoveToCloneInfoStart(struct internalScaWindowTask
*iwt
,
240 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
);
242 //----------------------------------------------------------------------------
245 //----------------------------------------------------------------------------
249 //----------------------------------------------------------------------------
253 struct ScalosMenuCommand MenuCommandTable
[] =
255 { "about", SMCOMFLAGF_RunFromRootWindow
, MITYPE_NOTHING
, AboutProg
, NULL
},
256 { "backdrop", SMCOMFLAGF_RunFromRootWindow
, MITYPEF_Backdrop
, BackDropProg
, IsMainWindowMenuEnable
},
257 { "cleanup", 0, MITYPE_NOTHING
, CleanupProg
, NULL
},
258 { "cleanupbyname", 0, MITYPE_NOTHING
, CleanupByNameProg
, NULL
},
259 { "cleanupbydate", 0, MITYPE_NOTHING
, CleanupByDateProg
, NULL
},
260 { "cleanupbysize", 0, MITYPE_NOTHING
, CleanupBySizeProg
, NULL
},
261 { "cleanupbytype", 0, MITYPE_NOTHING
, CleanupByTypeProg
, NULL
},
262 { "clearselection", 0, MITYPE_NOTHING
, ClearSelectionProg
, NULL
},
263 { "createthumbnail", 0, MITYPE_NOTHING
, MenuCreateThumbnailProg
, IconsSelectedAndWriteableMenuEnable
},
264 { "clone", 0, MITYPE_NOTHING
, CloneProg
, IconsSelectedAndWriteableMenuEnable
},
265 { "close", 0, MITYPE_NOTHING
, CloseProg
, NotMainWindowMenuEnable
},
266 { "copy", 0, MITYPE_NOTHING
, MenuCopyProg
, IconsSelectedMenuEnable
},
267 { "copyto", 0, MITYPE_NOTHING
, CopyToProg
, IconsSelectedMenuEnable
},
268 { "cut", 0, MITYPE_NOTHING
, MenuCutProg
, IconsSelectedNoDiskMenuEnable
}, // IconsSelectedAndWriteableMenuEnable
269 { "delete", 0, MITYPE_NOTHING
, DeleteProg
, IconsSelectedAndWriteableMenuEnable
},
270 { "emptytrashcan", 0, MITYPE_NOTHING
, EmptyTrashProg
, EmptyTrashMenuEnable
},
271 { "executecommand", 0, MITYPE_NOTHING
, ExecuteCmdProg
, NULL
},
272 { "find", 0, MITYPE_NOTHING
, FindProg
, NULL
},
273 { "formatdisk", 0, MITYPE_NOTHING
, FormatDiskProg
, FormatDiskMenuEnable
},
274 { "iconify", 0, MITYPE_NOTHING
, IconifyProg
, CanBeSizedMenuEnable
},
275 { "iconinfo", 0, MITYPE_NOTHING
, MenuInfoProg
, IconsSelectedMenuEnable
},
276 { "iconproperties", 0, MITYPE_NOTHING
, IconPropertiesProg
, IconsSelectedMenuEnable
},
277 { "lastmsg", 0, MITYPE_NOTHING
, LastMessageProg
, NULL
},
278 { "leaveout", 0, MITYPE_NOTHING
, LeaveOutProg
, LeaveOutMenuEnable
},
279 { "makedir", 0, MITYPE_NOTHING
, NewDrawerProg
, MustHaveLockMenuEnable
},
280 { "moveto", 0, MITYPE_NOTHING
, MoveToProg
, IconsSelectedNoDiskMenuEnable
}, // IconsSelectedAndWriteableMenuEnable
281 { "open", 0, MITYPE_NOTHING
, MenuOpenProg
, IconsSelectedMenuEnable
},
282 { "openinbrowserwindow",0, MITYPE_NOTHING
, MenuOpenBrowserWindowProg
, IconsSelectedNotBrowserModeMenuEnable
},
283 { "openinnewwindow", 0, MITYPE_NOTHING
, MenuOpenNewProg
, IconsSelectedBrowserModeMenuEnable
},
284 { "parent", 0, MITYPE_NOTHING
, OpenParentProg
, NotRootWindowMenuEnable
},
285 { "paste", 0, MITYPE_NOTHING
, MenuPasteProg
, PasteMenuEnable
},
286 { "putaway", 0, MITYPE_NOTHING
, PutAwayProg
, PutAwayMenuEnable
},
287 { "quit", SMCOMFLAGF_RunFromRootWindow
, MITYPE_NOTHING
, CloseWindowProg
, NULL
},
288 { "redo", 0, MITYPE_NOTHING
, MenuRedoProg
, RedoMenuEnable
},
289 { "redraw", 0, MITYPE_NOTHING
, RedrawProg
, NULL
},
290 { "redrawall", SMCOMFLAGF_RunFromRootWindow
, MITYPE_NOTHING
, RedrawAllProg
, NULL
},
291 { "rename", 0, MITYPE_NOTHING
, RenameProg
, IconsSelectedAndWriteableMenuEnable
},
292 { "reset", SMCOMFLAGF_RunFromRootWindow
, MITYPE_NOTHING
, ResetScalosProg
, NULL
},
293 { "selectall", 0, MITYPE_NOTHING
, SelectContentsProg
, NULL
},
294 { "showallfiles", 0, MITYPEF_ShowAllFiles
, ShowAllFilesProg
, NotMainWindowAndNotReadingMenuEnable
},
295 { "showonlyicons", 0, MITYPEF_ShowOnlyIcons
, ShowOnlyIconsProg
, NotMainWindowAndNotReadingMenuEnable
},
296 { "showdefault", 0, MITYPEF_ShowDefault
, ShowDefaultProg
, NotMainWindowAndNotReadingMenuEnable
},
297 { "shutdown", SMCOMFLAGF_RunFromRootWindow
, MITYPE_NOTHING
, ShutdownProg
, NULL
},
298 { "sizetofit", 0, MITYPE_NOTHING
, SizeToFitProg
, CanBeSizedMenuEnable
},
299 { "snapshot", 0, MITYPE_NOTHING
, MenuSnapshotProg
, SnapshotMenuEnable
},
300 { "snapshotall", 0, MITYPE_NOTHING
, SnapshotAllProg
, IsWriteableMenuEnable
},
301 { "snapshotwindow", 0, MITYPE_NOTHING
, SnapshotWindowProg
, IsWriteableMenuEnable
},
302 { "thumbnailcachecleanup", 0, MITYPE_NOTHING
, ThumbnailCacheCleanupProg
, NULL
},
303 { "undo", 0, MITYPE_NOTHING
, MenuUndoProg
, UndoMenuEnable
},
304 { "unsnapshot", 0, MITYPE_NOTHING
, MenuUnsnapshotProg
, SnapshotMenuEnable
},
305 { "update", 0, MITYPE_NOTHING
, UpdateProg
, NotReadingMenuEnable
},
306 { "updateall", SMCOMFLAGF_RunFromRootWindow
, MITYPE_NOTHING
, UpdateAllProg
, NULL
},
307 { "viewbydate", 0, MITYPEF_ViewByDate
, ViewByDateProg
, NotMainWindowAndNotReadingMenuEnable
},
308 { "viewbyicon", 0, MITYPEF_ViewByIcon
, ViewByIconProg
, NotMainWindowAndNotReadingMenuEnable
},
309 { "viewbysize", 0, MITYPEF_ViewBySize
, ViewBySizeProg
, NotMainWindowAndNotReadingMenuEnable
},
310 { "viewbytype", 0, MITYPEF_ViewByType
, ViewByTypeProg
, NotMainWindowAndNotReadingMenuEnable
},
311 { "viewbytext", 0, MITYPEF_ViewByText
, ViewByTextProg
, NotMainWindowAndNotReadingMenuEnable
},
312 { "viewbydefault", 0, MITYPEF_ViewByDefault
, ViewByDefaultProg
, NotMainWindowAndNotReadingMenuEnable
},
313 { "windowproperties", 0, MITYPE_NOTHING
, WindowPropertiesProg
, NotReadingMenuEnable
},
314 { NULL
, 0, 0, NULL
, NULL
},
317 struct List globalCopyClipBoard
; // Clipboard for files/directories via copy/cut/paste
318 SCALOSSEMAPHORE ClipboardSemaphore
; // Semaphore to protect globalCopyClipBoard
320 //----------------------------------------------------------------------------
322 static void MenuInfoProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
324 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
325 d1(KPrintF("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
327 if (mcArg
->mca_IconNode
)
329 SCA_LockWindowList(SCA_LockWindowList_Shared
);
330 WBInfoStart(iwt
, mcArg
->mca_IconNode
, NULL
);
331 SCA_UnLockWindowList();
335 DoForAllWindowsShared(iwt
, WBInfoStart
, NULL
);
339 //----------------------------------------------------------------------------
341 static void IconPropertiesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
343 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
344 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
346 if (mcArg
->mca_IconNode
)
348 SCA_LockWindowList(SCA_LockWindowList_Shared
);
349 WBIconPropertiesStart(iwt
, mcArg
->mca_IconNode
, NULL
);
350 SCA_UnLockWindowList();
354 DoForAllWindowsShared(iwt
, WBIconPropertiesStart
, NULL
);
358 //----------------------------------------------------------------------------
360 static void DoForAllWindowsShared(struct internalScaWindowTask
*iwt
,
361 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
),
362 void (*WindowProc
)(struct internalScaWindowTask
*iwt
))
364 struct ScaWindowStruct
*ws
;
367 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
369 undoStep
= UndoBeginStep();
371 SCA_LockWindowList(SCA_LockWindowList_Shared
);
373 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
375 DoForAllIconsShared(iwt
, IconProc
, undoStep
);
379 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
381 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
383 if (ws
!= iwt
->iwt_WindowTask
.mt_WindowStruct
)
385 DoForAllIconsShared((struct internalScaWindowTask
*) ws
->ws_WindowTask
, IconProc
, undoStep
);
387 (*WindowProc
)((struct internalScaWindowTask
*) ws
->ws_WindowTask
);
391 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
393 SCA_UnLockWindowList();
395 UndoEndStep(iwt
, undoStep
);
397 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
401 static void DoForAllIconsShared(struct internalScaWindowTask
*iwt
,
402 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
),
405 struct ScaIconNode
*in
;
407 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
409 ScalosLockIconListShared(iwt
);
411 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
413 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
415 if (gg
->Flags
& GFLG_SELECTED
)
417 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
418 (*IconProc
)(iwt
, in
, undoStep
);
422 ScalosUnLockIconList(iwt
);
426 static void DoForAllWindows(struct internalScaWindowTask
*iwt
,
427 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
))
429 struct ScaWindowStruct
*ws
;
432 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
434 undoStep
= UndoBeginStep();
436 SCA_LockWindowList(SCA_LockWindowList_Shared
);
438 DoForAllIconsExclusive(iwt
, IconProc
, undoStep
);
440 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
442 if (ws
!= iwt
->iwt_WindowTask
.mt_WindowStruct
)
443 DoForAllIconsExclusive((struct internalScaWindowTask
*) ws
->ws_WindowTask
, IconProc
, undoStep
);
446 SCA_UnLockWindowList();
448 UndoEndStep(iwt
, undoStep
);
452 // IconProc might modify wt_IconList !!
453 static void DoForAllIconsExclusive(struct internalScaWindowTask
*iwt
,
454 void (*IconProc
)(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
),
458 struct ScaIconNode
*in
;
460 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
462 ScalosLockIconListExclusive(iwt
);
464 // Count icons in window
465 for (IconCount
= 0, in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
470 struct ScaIconNode
**IconArray
;
472 IconArray
= ScalosAlloc(IconCount
* sizeof(struct ScaIconNode
*));
477 // Collect addresses of all icons in IconArray
478 for (n
= 0, in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
481 // Now iterate through the collected icons
482 for (n
= 0; n
< IconCount
; n
++)
484 // verify that IconArray[n] is still present
485 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
487 if (in
== IconArray
[n
])
489 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
491 if (gg
->Flags
& GFLG_SELECTED
)
492 (*IconProc
)(iwt
, in
, undoStep
);
498 ScalosFree(IconArray
);
502 ScalosUnLockIconList(iwt
);
505 //----------------------------------------------------------------------------
507 void WBInfoStart(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
511 d1(KPrintF("%s/%s/%ld: iwt=%08lx in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, in
, GetIconName(in
)));
515 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
517 if (WBAPPICON
== IconType
)
519 WindowSendAppIconMsg(iwt
, AMCLASSICON_Information
, in
);
523 struct WBArg InfoArgs
;
525 if (in
->in_DeviceIcon
)
527 InfoArgs
.wa_Lock
= DiskInfoLock(in
);
528 InfoArgs
.wa_Name
= AllocCopyString("Disk"); // look for "Disk.info"
532 InfoArgs
.wa_Name
= AllocCopyString(GetIconName(in
));
535 InfoArgs
.wa_Lock
= DupLock(in
->in_Lock
);
537 InfoArgs
.wa_Lock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
540 d1(KPrintF("%s/%s/%ld: InfoArgs.wa_Name=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, \
541 InfoArgs
.wa_Name
, InfoArgs
.wa_Name
? InfoArgs
.wa_Name
: (BYTE
*) ""));
542 debugLock_d1(InfoArgs
.wa_Lock
);
544 RunProcess(&iwt
->iwt_WindowTask
, InfoStart
, sizeof(InfoArgs
)/sizeof(ULONG
), &InfoArgs
, iInfos
.xii_iinfos
.ii_MainMsgPort
);
549 static SAVEDS(ULONG
) InfoStart(APTR aptr
, struct SM_RunProcess
*msg
)
551 return AsyncStartModule(aptr
, msg
, "Information.module");
554 //----------------------------------------------------------------------------
556 static void SizeToFitProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
558 struct Rectangle VirtRect
;
559 WORD NewInnerWidth
, NewInnerHeight
;
560 WORD NewLeft
, NewTop
, NewWidth
, NewHeight
;
562 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
563 d1(kprintf("%s/%s/%ld: vWidth=%ld vHeight=%ld iWidth=%ld iHeight=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
564 iwt
->iwt_InvisibleWidth
, iwt
->iwt_InvisibleHeight
, iwt
->iwt_InnerWidth
, iwt
->iwt_InnerHeight
));
566 if (iwt
->iwt_BackDrop
)
569 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
571 GetIconsBoundingBox(iwt
, &VirtRect
);
573 d1(kprintf("%s/%s/%ld: MinX=%ld MinY=%ld MaxX=%ld MaxY=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
574 VirtRect
.MinX
, VirtRect
.MinY
, VirtRect
.MaxX
, VirtRect
.MaxY
));
576 if (NULL
== iwt
->iwt_WindowTask
.wt_Window
)
578 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
582 NewInnerWidth
= VirtRect
.MaxX
- VirtRect
.MinX
+ 1;
583 NewInnerHeight
= VirtRect
.MaxY
- VirtRect
.MinY
+ 1;
585 NewLeft
= iwt
->iwt_WindowTask
.wt_Window
->LeftEdge
;
586 NewTop
= iwt
->iwt_WindowTask
.wt_Window
->TopEdge
;
587 NewWidth
= iwt
->iwt_WindowTask
.wt_Window
->Width
;
588 NewHeight
= iwt
->iwt_WindowTask
.wt_Window
->Height
;
590 if (iwt
->iwt_InnerWidth
!= NewInnerWidth
)
592 NewWidth
= NewInnerWidth
+ iwt
->iwt_InnerLeft
+ iwt
->iwt_InnerRight
;
594 if (NewWidth
> iwt
->iwt_WinScreen
->Width
)
595 NewWidth
= iwt
->iwt_WinScreen
->Width
;
596 if (NewLeft
+ NewWidth
> iwt
->iwt_WinScreen
->Width
)
597 NewLeft
= iwt
->iwt_WinScreen
->Width
- NewWidth
;
599 if (iwt
->iwt_InnerHeight
!= NewInnerHeight
)
601 NewHeight
= NewInnerHeight
+ iwt
->iwt_InnerTop
+ iwt
->iwt_InnerBottom
;
603 if (NewHeight
> iwt
->iwt_WinScreen
->Height
)
604 NewHeight
= iwt
->iwt_WinScreen
->Height
;
605 if (NewLeft
+ NewHeight
> iwt
->iwt_WinScreen
->Height
)
606 NewLeft
= iwt
->iwt_WinScreen
->Height
- NewHeight
;
609 UndoAddEvent(iwt
, UNDO_SizeWindow
,
610 UNDOTAG_WindowTask
, iwt
,
611 UNDOTAG_OldWindowLeft
, iwt
->iwt_WindowTask
.wt_Window
->LeftEdge
,
612 UNDOTAG_OldWindowTop
, iwt
->iwt_WindowTask
.wt_Window
->TopEdge
,
613 UNDOTAG_OldWindowWidth
, iwt
->iwt_WindowTask
.wt_Window
->Width
,
614 UNDOTAG_OldWindowHeight
, iwt
->iwt_WindowTask
.wt_Window
->Height
,
615 UNDOTAG_NewWindowLeft
, NewLeft
,
616 UNDOTAG_NewWindowTop
, NewTop
,
617 UNDOTAG_NewWindowWidth
, NewWidth
,
618 UNDOTAG_NewWindowHeight
, NewHeight
,
619 UNDOTAG_OldWindowVirtX
, iwt
->iwt_WindowTask
.wt_XOffset
,
620 UNDOTAG_OldWindowVirtY
, iwt
->iwt_WindowTask
.wt_YOffset
,
621 UNDOTAG_NewWindowVirtX
, VirtRect
.MinX
,
622 UNDOTAG_NewWindowVirtY
, VirtRect
.MinY
,
625 d1(kprintf("%s/%s/%ld: XOffset=%ld YOffset=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
626 iwt
->iwt_WindowTask
.wt_XOffset
, iwt
->iwt_WindowTask
.wt_YOffset
));
628 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_DeltaMove
,
629 VirtRect
.MinX
- iwt
->iwt_WindowTask
.wt_XOffset
,
630 VirtRect
.MinY
- iwt
->iwt_WindowTask
.wt_YOffset
);
632 d1(KPrintF("%s/%s/%ld: Left=%ld Top=%ld Width=%ld Height=%ld\n", __FILE__
, __FUNC__
, __LINE__
, \
633 NewLeft
, NewTop
, NewWidth
, NewHeight
));
635 ChangeWindowBox(iwt
->iwt_WindowTask
.wt_Window
, NewLeft
, NewTop
, NewWidth
, NewHeight
);
637 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
640 //----------------------------------------------------------------------------
642 static void WindowPropertiesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
644 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
646 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
); // prevent window from closing
648 StartProgTask(iwt
, mcArg
, AsyncWindowPropertiesProg
, (struct MsgPort
*) SCCV_RunProcess_WaitReply
);
650 d1(kprintf("%s/%s/%ld: Release WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
652 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
655 //----------------------------------------------------------------------------
657 void ClearSelectionProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
659 struct ScaWindowStruct
*ws
;
661 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
663 SCA_LockWindowList(SCA_LockWindowList_Shared
);
665 // Deselect all icons in all windows
666 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
668 ClearSelectionInWindow((struct internalScaWindowTask
*) ws
->ws_WindowTask
);
671 SCA_UnLockWindowList();
673 AdjustIconActive(iwt
);
679 static void SelectContentsProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
681 struct ScaIconNode
*in
;
682 struct ScaWindowStruct
*ws
;
684 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
686 SCA_LockWindowList(SCA_LockWindowList_Shared
);
688 // Deselect all icons in other windows
689 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
691 if (ws
!= iwt
->iwt_WindowTask
.mt_WindowStruct
)
692 ClearSelectionInWindow((struct internalScaWindowTask
*) ws
->ws_WindowTask
);
695 ScalosLockIconListExclusive(iwt
);
697 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
699 ClassSelectIcon(iwt
->iwt_WindowTask
.mt_WindowStruct
, in
, TRUE
);
702 ScalosUnLockIconList(iwt
);
704 SCA_UnLockWindowList();
706 AdjustIconActive(iwt
);
712 static void NewDrawerProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
715 char NewDrawerName
[108];
717 d1(kprintf("%s/%s/%ld: Obtain WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
719 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
); // prevent window from closing
721 stccpy(NewDrawerName
, GetLocString(MSGID_NEW_DRAWER_NAME
), sizeof(NewDrawerName
));
723 Result
= CallTextInputHook(TIACTION_NewDrawer
, FindUniqueName(NewDrawerName
, sizeof(NewDrawerName
)));
726 StartProgTask(iwt
, mcArg
, AsyncNewDrawerProg
, (struct MsgPort
*) SCCV_RunProcess_WaitReply
);
728 d1(kprintf("%s/%s/%ld: Release WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
730 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
734 static void RenameProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
736 d1(kprintf("%s/%s/%ld: Obtain WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
738 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
); // prevent window from closing
740 StartProgTask(iwt
, mcArg
, AsyncRenameProg
, (struct MsgPort
*) SCCV_RunProcess_WaitReply
);
742 d1(kprintf("%s/%s/%ld: Release WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
744 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
748 void DeleteProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
750 d1(kprintf("%s/%s/%ld: Obtain WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
752 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
); // prevent window from closing
754 StartProgTask(iwt
, mcArg
, AsyncDeleteProg
, (struct MsgPort
*) SCCV_RunProcess_WaitReply
);
756 d1(kprintf("%s/%s/%ld: Release WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
758 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
762 static BOOL
StartProgTask(struct internalScaWindowTask
*iwt
,
763 const struct MenuCmdArg
*mcArg
, PROGFUNC ProgProc
, struct MsgPort
*ReplyPort
)
765 struct SM_StartProg sMsg
;
768 sMsg
.spr_ProgFunc
= ProgProc
;
769 sMsg
.spr_WindowTask
= iwt
;
770 sMsg
.spr_Arg
= *mcArg
;
772 Success
= DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_RunProcess
, ProgTask
,
773 &sMsg
, sizeof(sMsg
), ReplyPort
);
779 static SAVEDS(ULONG
) ProgTask(struct SM_StartProg
*sMsg
, struct SM_RunProcess
*msg
)
781 static CONST_STRPTR ProgTaskName
= "Scalos_RunProg";
782 struct internalScaWindowTask
*iwt
;
785 struct MenuCmdArg Arg
;
786 struct Process
*myProc
= (struct Process
*) FindTask(NULL
);
788 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
790 prWindowPtr
= myProc
->pr_WindowPtr
;
791 myProc
->pr_WindowPtr
= (APTR
) ~0; // suppress error requesters
793 myProc
->pr_Task
.tc_Node
.ln_Name
= (STRPTR
) ProgTaskName
;
794 SetProgramName(ProgTaskName
);
796 iwt
= sMsg
->spr_WindowTask
;
797 ProgFunc
= sMsg
->spr_ProgFunc
;
800 d1(kprintf("%s/%s/%ld: Obtain WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
802 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
804 (*ProgFunc
)(iwt
, &Arg
);
806 d1(kprintf("%s/%s/%ld: Release WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
808 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
810 // restore pr_WindowPtr
811 myProc
->pr_WindowPtr
= prWindowPtr
;
816 //----------------------------------------------------------------------------
818 static void AsyncNewDrawerProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
821 struct WBArg wbArg
[2];
823 wbArg
[1].wa_Name
= NULL
;
824 wbArg
[1].wa_Lock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
825 if ((BPTR
)NULL
== wbArg
[1].wa_Lock
)
828 wbArg
[0].wa_Name
= (STRPTR
) "newdrawer.module";
829 wbArg
[0].wa_Lock
= LockScaModsDir();
830 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
832 UnLock(wbArg
[1].wa_Lock
);
837 Success
= SCA_WBStartTags(wbArg
, 2,
838 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
839 SCA_Flags
, SCAF_WBStart_Wait
,
845 UnLock(wbArg
[0].wa_Lock
);
846 UnLock(wbArg
[1].wa_Lock
);
849 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_ImmediateCheckUpdate
);
852 //----------------------------------------------------------------------------
854 static void WBIconPropertiesStart(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
856 struct WBArg InfoArgs
;
858 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
859 d1(kprintf("%s/%s/%ld: iwt=%08lx in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, in
, GetIconName(in
)));
861 if (in
->in_DeviceIcon
)
863 InfoArgs
.wa_Lock
= DiskInfoLock(in
);
864 InfoArgs
.wa_Name
= AllocCopyString("Disk"); // look for "Disk.info"
868 InfoArgs
.wa_Name
= AllocCopyString(GetIconName(in
));
871 InfoArgs
.wa_Lock
= DupLock(in
->in_Lock
);
873 InfoArgs
.wa_Lock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
876 d1(kprintf("%s/%s/%ld: InfoArgs.wa_Name=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, \
877 InfoArgs
.wa_Name
, InfoArgs
.wa_Name
? InfoArgs
.wa_Name
: ""));
878 debugLock_d1(InfoArgs
.wa_Lock
);
880 RunProcess(&iwt
->iwt_WindowTask
, IconPropertiesStart
, sizeof(InfoArgs
)/sizeof(ULONG
), &InfoArgs
, iInfos
.xii_iinfos
.ii_MainMsgPort
);
884 static SAVEDS(ULONG
) IconPropertiesStart(APTR aptr
, struct SM_RunProcess
*msg
)
888 d1(KPrintF("%s/%s/%ld: START aptr=%08lx msg=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, aptr
, msg
));
889 Result
= AsyncStartModule(aptr
, msg
, "iconproperties.module");
890 d1(KPrintF("%s/%s/%ld: END Result=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Result
));
895 //----------------------------------------------------------------------------
897 static void AsyncWindowPropertiesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
900 struct WBArg wbArg
[2];
902 wbArg
[1].wa_Name
= NULL
;
903 wbArg
[1].wa_Lock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
904 if ((BPTR
)NULL
== wbArg
[1].wa_Lock
)
907 wbArg
[0].wa_Name
= (STRPTR
) "windowproperties.module";
908 wbArg
[0].wa_Lock
= LockScaModsDir();
909 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
911 UnLock(wbArg
[1].wa_Lock
);
916 Success
= SCA_WBStartTags(wbArg
, 2,
917 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
918 SCA_Flags
, SCAF_WBStart_Wait
,
924 UnLock(wbArg
[0].wa_Lock
);
925 UnLock(wbArg
[1].wa_Lock
);
928 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_ImmediateCheckUpdate
);
931 //----------------------------------------------------------------------------
933 void AsyncRenameProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
939 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
944 ULONG NumberOfWbArgs
= 1;
946 d1(KPrintF("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
948 if (mcArg
->mca_IconNode
)
951 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
953 d1(KPrintF("%s/%s/%ld: NumberOfWbArgs=%lu\n", __FILE__
, __FUNC__
, __LINE__
, NumberOfWbArgs
));
955 wbArg
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
956 d1(KPrintF("%s/%s/%ld: wbArg=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, wbArg
));
960 wbArg
[0].wa_Name
= (STRPTR
) "rename.module";
961 wbArg
[0].wa_Lock
= LockScaModsDir();
962 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
965 nArgs
= 1; // first argument is program itself
967 if (NumberOfWbArgs
> 1)
969 if (mcArg
->mca_IconNode
)
971 nArgs
+= DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_MakeWBArg
,
972 mcArg
->mca_IconNode
, &wbArg
[1]);
976 nArgs
+= SCA_MakeWBArgs(&wbArg
[1], NULL
, NumberOfWbArgs
- 1);
980 d1(KPrintF("%s/%s/%ld: nArgs=%lu\n", __FILE__
, __FUNC__
, __LINE__
, nArgs
));
982 DoForAppIcons(AMCLASSICON_Rename
);
987 for (n
=1, tiResult
=0; !tiResult
&& n
<nArgs
; n
++)
989 BPTR oldDir
= CurrentDir(wbArg
[n
].wa_Lock
);
991 if (strlen(wbArg
[n
].wa_Name
) > 0)
993 tiResult
= CallTextInputHook(TIACTION_Rename
, wbArg
[n
].wa_Name
);
997 STRPTR VolumeName
= AllocPathBuffer();
1001 NameFromLock(wbArg
[n
].wa_Lock
, VolumeName
, Max_PathLen
);
1002 StripTrailingColon(VolumeName
);
1004 tiResult
= CallTextInputHook(TIACTION_RelabelVolume
, VolumeName
);
1005 FreePathBuffer(VolumeName
);
1014 d1(KPrintF("%s/%s/%ld: tiResult=%lu\n", __FILE__
, __FUNC__
, __LINE__
, tiResult
));
1019 Success
= SCA_WBStartTags(wbArg
, nArgs
,
1020 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
1021 SCA_Flags
, SCAF_WBStart_Wait
,
1025 d1(KPrintF("%s/%s/%ld: Success=%lu\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
1027 if (NumberOfWbArgs
> 1)
1029 SCA_FreeWBArgs(&wbArg
[1], nArgs
- 1,
1030 Success
? SCAF_FreeNames
: SCAF_FreeNames
| SCAF_FreeLocks
);
1033 wbArg
[0].wa_Lock
= (BPTR
)NULL
;
1035 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_ImmediateCheckUpdate
);
1039 // Rename done by TextInputHook
1040 if (NumberOfWbArgs
> 1)
1042 SCA_FreeWBArgs(&wbArg
[1], nArgs
- 1, SCAF_FreeNames
| SCAF_FreeLocks
);
1048 d1(KPrintF("%s/%s/%ld: wbArg=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, wbArg
));
1052 if (wbArg
[0].wa_Lock
)
1053 UnLock(wbArg
[0].wa_Lock
);
1058 d1(KPrintF("%s/%s/%ld: END", __FILE__
, __FUNC__
, __LINE__
));
1061 //----------------------------------------------------------------------------
1063 void AsyncDeleteProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1065 BOOL Success
= FALSE
;
1066 struct WBArg
*wbArg
;
1070 ULONG NumberOfWbArgs
= 1;
1072 if (mcArg
->mca_IconNode
)
1073 NumberOfWbArgs
+= 1;
1075 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
1077 wbArg
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
1081 if (NumberOfWbArgs
> 1)
1083 if (mcArg
->mca_IconNode
)
1085 nArgs
+= DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_MakeWBArg
,
1086 mcArg
->mca_IconNode
, &wbArg
[1]
1091 nArgs
+= SCA_MakeWBArgs(&wbArg
[1], NULL
, NumberOfWbArgs
- 1);
1095 DoForAppIcons(AMCLASSICON_Delete
);
1100 ScalosObtainSemaphoreShared(&DeleteHookSemaphore
);
1102 if (globalDeleteHook
)
1104 Success
= CallGlobalDeleteHook(&wbArg
[1], nArgs
- 1, DLACTION_BeginDiscard
);
1108 wbArg
[0].wa_Name
= (STRPTR
) "delete.module";
1109 wbArg
[0].wa_Lock
= LockScaModsDir();
1110 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
1113 DeleteModuleKludge(wbArg
, nArgs
);
1116 ScalosReleaseSemaphore(&DeleteHookSemaphore
);
1121 Success
= SCA_WBStartTags(wbArg
, nArgs
,
1122 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
1123 SCA_Flags
, SCAF_WBStart_Wait
,
1127 if (NumberOfWbArgs
> 1)
1129 SCA_FreeWBArgs(&wbArg
[1], nArgs
- 1,
1130 Success
? SCAF_FreeNames
: SCAF_FreeNames
| SCAF_FreeLocks
);
1133 wbArg
[0].wa_Lock
= (BPTR
)NULL
;
1136 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_ImmediateCheckUpdate
);
1141 if (wbArg
[0].wa_Lock
)
1142 UnLock(wbArg
[0].wa_Lock
);
1148 //----------------------------------------------------------------------------
1150 static void LeaveOutIcon(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
1154 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1155 d1(KPrintF("%s/%s/%ld: Icon=<%s> Lock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, IconName
, in
->in_Lock
));
1157 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
1162 if (WBAPPICON
== IconType
)
1164 WindowSendAppIconMsg(iwt
, AMCLASSICON_LeaveOut
, in
);
1172 DirLock
= in
->in_Lock
;
1174 DirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
1176 UndoAddEvent(iwt
, UNDO_Leaveout
,
1177 UNDOTAG_UndoMultiStep
, undoStep
,
1178 UNDOTAG_IconName
, GetIconName(in
),
1179 UNDOTAG_IconDirLock
, DirLock
,
1180 UNDOTAG_IconPosX
, NO_ICON_POSITION_SHORT
,
1181 UNDOTAG_IconPosY
, NO_ICON_POSITION_SHORT
,
1184 DoLeaveOutIcon(iwt
, DirLock
, GetIconName(in
),
1185 NO_ICON_POSITION_SHORT
, NO_ICON_POSITION_SHORT
);
1187 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1190 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1194 static void PutAwayIconNode(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
1198 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1199 d1(KPrintF("%s/%s/%ld: Icon=<%s> Lock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, GetIconName(in
), in
->in_Lock
));
1201 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
1206 if (WBAPPICON
== IconType
)
1208 WindowSendAppIconMsg(iwt
, AMCLASSICON_PutAway
, in
);
1215 BPTR iconDirLockClone
= (BPTR
)NULL
;
1219 struct ScaWindowStruct
*wsDest
;
1222 iconDirLock
= in
->in_Lock
;
1224 iconDirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
1226 IconName
= AllocCopyString(GetIconName(in
));
1227 if (NULL
== IconName
)
1230 debugLock_d1(iconDirLock
);
1232 iconDirLockClone
= DupLock(iconDirLock
);
1233 if ((BPTR
)NULL
== iconDirLockClone
)
1236 UndoAddEvent(iwt
, UNDO_PutAway
,
1237 UNDOTAG_UndoMultiStep
, undoStep
,
1238 UNDOTAG_IconName
, IconName
,
1239 UNDOTAG_IconDirLock
, iconDirLock
,
1242 // !!! side effects: UnLocks(iconDirLock) and frees <in> !!!
1243 PutAwayIcon(iwt
, iconDirLock
, IconName
, TRUE
);
1245 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1247 // add icon to owning drawer window
1248 SCA_LockWindowList(SCA_LockWindowList_Shared
);
1250 for (wsDest
= winlist
.wl_WindowStruct
; wsDest
; wsDest
= (struct ScaWindowStruct
*) wsDest
->ws_Node
.mln_Succ
)
1252 debugLock_d1(iconDirLockClone
);
1253 d1(if (wsDest
->ws_Lock
) debugLock_d1(wsDest
->ws_Lock
));
1255 if (wsDest
->ws_Lock
&& LOCK_SAME
== ScaSameLock(iconDirLockClone
, wsDest
->ws_Lock
))
1257 struct internalScaWindowTask
*iwtDest
= (struct internalScaWindowTask
*) wsDest
->ws_WindowTask
;
1259 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1261 DoMethod(iwtDest
->iwt_WindowTask
.mt_MainObject
,
1262 SCCM_IconWin_ReadIcon
,
1266 // Special handling for "view all" textwindows.
1267 // here both object and icon are separate entries, which must be removed both!
1268 if (!IsIwtViewByIcon(iwtDest
) &&
1269 IsShowAll(iwtDest
->iwt_WindowTask
.mt_WindowStruct
))
1271 Path
= AllocPathBuffer();
1275 stccpy(Path
, IconName
, Max_PathLen
);
1276 SafeStrCat(Path
, ".info", Max_PathLen
);
1278 DoMethod(iwtDest
->iwt_WindowTask
.mt_MainObject
,
1279 SCCM_IconWin_ReadIcon
,
1286 SCA_UnLockWindowList();
1288 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
1292 FreeCopyString(IconName
);
1293 if (iconDirLockClone
)
1294 UnLock(iconDirLockClone
);
1296 FreePathBuffer(Path
);
1299 d1(KPrintF("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
1303 static void SnapshotWindow(struct internalScaWindowTask
*iwt
)
1305 struct ScaWindowStruct
*ws
= iwt
->iwt_WindowTask
.mt_WindowStruct
;
1306 CONST_STRPTR iconName
;
1307 Object
*IconObj
, *allocIconObj
= NULL
;
1308 BPTR parentLock
= (BPTR
)NULL
;
1310 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1313 struct IBox WinRect
;
1317 WinRect
.Left
= ws
->ws_Left
;
1318 WinRect
.Top
= ws
->ws_Top
;
1319 WinRect
.Width
= ws
->ws_Width
;
1320 WinRect
.Height
= ws
->ws_Height
;
1322 IconObj
= ClassGetWindowIconObject(iwt
, &allocIconObj
);
1324 d1(KPrintF("%s/%s/%ld: iconName=<%s> IconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconName
, IconObj
));
1325 if (NULL
== IconObj
)
1328 IconViewMode
= TranslateViewModesToIcon(ws
->ws_Viewmodes
);
1329 ddFlags
= ws
->ws_ViewAll
;
1330 if (SortOrder_Ascending
== ws
->ws_SortOrder
)
1331 ddFlags
|= DDFLAGS_SORTASC
;
1332 else if (SortOrder_Descending
== ws
->ws_SortOrder
)
1333 ddFlags
|= DDFLAGS_SORTDESC
;
1335 d1(KPrintF("%s/%s/%ld: ws_ViewAll=%04lx ddFlags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ws
->ws_ViewAll
, ddFlags
));
1338 IDTA_ViewModes
, IconViewMode
,
1339 IDTA_Flags
, ddFlags
,
1340 IDTA_WindowRect
, (IPTR
) &WinRect
,
1341 IDTA_WinCurrentY
, ws
->ws_yoffset
,
1342 IDTA_WinCurrentX
, ws
->ws_xoffset
,
1345 GetAttr(DTA_Name
, IconObj
, (APTR
) &iconName
);
1347 d1(kprintf("%s/%s/%ld: iconName=<%s> IconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconName
, IconObj
));
1349 if (ws
->ws_Flags
& WSV_FlagF_RootWindow
)
1350 parentLock
= DupLock(ws
->ws_Lock
);
1352 parentLock
= ParentDir(ws
->ws_Lock
);
1353 if ((BPTR
)NULL
== parentLock
)
1356 SaveIconObject(IconObj
, parentLock
, iconName
, FALSE
, NULL
);
1360 DisposeIconObject(allocIconObj
);
1366 static struct ScaIconNode
*FindIconGlobal(BPTR dirLock
, CONST_STRPTR Name
)
1368 struct ScaWindowStruct
*ws
;
1369 struct ScaIconNode
*in
= NULL
;
1370 STRPTR allocName
= NULL
;
1371 BPTR parentLock
= NULL
;
1373 d1(kprintf("%s/%s/%ld: dirLock=%08lx Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, dirLock
, Name
));
1374 debugLock_d1(dirLock
);
1376 if (strlen(Name
) < 1)
1378 // dirLock is really ObjectLock
1379 parentLock
= ParentDir(dirLock
);
1380 if (NULL
== parentLock
)
1383 allocName
= AllocPathBuffer();
1384 if (NULL
== allocName
)
1390 NameFromLock(dirLock
, allocName
, Max_PathLen
- 1);
1391 Name
= FilePart(allocName
);
1392 dirLock
= parentLock
;
1394 d1(kprintf("%s/%s/%ld: allocName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, allocName
));
1396 d1(kprintf("%s/%s/%ld: dirLock=%08lx Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, dirLock
, Name
));
1397 debugLock_d1(dirLock
);
1400 SCA_LockWindowList(SCA_LockWindowList_Shared
);
1402 for (ws
=winlist
.wl_WindowStruct
; NULL
== in
&& ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
1404 if (LOCK_SAME
== ScaSameLock(ws
->ws_Lock
, dirLock
))
1406 struct ScaIconNode
*inx
;
1407 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
1409 d1(kprintf("%s/%s/%ld: Window FOUND iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1411 ScalosLockIconListShared(iwt
);
1413 for (inx
=iwt
->iwt_WindowTask
.wt_IconList
; NULL
== in
&& inx
; inx
= (struct ScaIconNode
*) inx
->in_Node
.mln_Succ
)
1415 if (0 == Stricmp(inx
->in_Name
, Name
))
1419 ScalosUnLockIconList(iwt
);
1426 // now look in main window for left-out (=backdrop) icons.
1428 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) iInfos
.xii_iinfos
.ii_MainWindowStruct
->ws_WindowTask
;
1429 struct ScaIconNode
*inx
;
1431 ScalosLockIconListShared(iwt
);
1433 for (inx
=iwt
->iwt_WindowTask
.wt_IconList
; NULL
== in
&& inx
; inx
= (struct ScaIconNode
*) inx
->in_Node
.mln_Succ
)
1436 LOCK_SAME
== ScaSameLock(inx
->in_Lock
, dirLock
) &&
1437 0 == Stricmp(inx
->in_Name
, Name
))
1443 ScalosUnLockIconList(iwt
);
1446 SCA_UnLockWindowList();
1448 d1(kprintf("%s/%s/%ld: in=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, in
));
1451 FreePathBuffer(allocName
);
1459 static void BackDropProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1463 newState
= mcArg
->mca_State
!= 0;
1465 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1466 d1(kprintf("%s/%s/%ld: State=%ld\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_State
));
1467 d1(kprintf("%s/%s/%ld: CommandName=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_CommandName
));
1469 d1(kprintf("%s/%s/%ld: iwt_BackDrop=%ld newState=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_BackDrop
, newState
));
1471 if (newState
!= iwt
->iwt_BackDrop
)
1473 struct ScaWindowStruct
*ws
= iwt
->iwt_WindowTask
.mt_WindowStruct
;
1474 struct PatternNode
*ptNode
;
1476 SCA_LockWindowList(SCA_LockWindowList_Shared
);
1478 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_Sleep
);
1480 iwt
->iwt_BackDrop
= newState
;
1482 if (iwt
->iwt_BackDrop
)
1484 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Flags
|= WSV_FlagF_Backdrop
;
1485 iwt
->iwt_WindowTask
.wt_XOffset
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_xoffset
= 0;
1486 iwt
->iwt_WindowTask
.wt_YOffset
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_yoffset
= 0;
1489 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Flags
&= ~WSV_FlagF_Backdrop
;
1491 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_WakeUp
, 1);
1493 ptNode
= ws
->ws_PatternNode
;
1495 d1(kprintf("%s/%s/%ld: type=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ptNode
->ptn_type
));
1497 if (PatternPrefs
.patt_NewRenderFlag
&& ptNode
&&
1498 ((SCP_RenderType_FitSize
== ptNode
->ptn_type
)
1499 || (SCP_RenderType_ScaledMin
== ptNode
->ptn_type
)
1500 || (SCP_RenderType_Centered
== ptNode
->ptn_type
))
1501 && GuiGFXBase
&& iwt
->iwt_WindowTask
.wt_PatternInfo
.ptinf_bitmap
)
1503 d1(KPrintF("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
1505 NewWindowPatternMsg(iwt
, NULL
, &ptNode
);
1508 SCA_UnLockWindowList();
1513 void UpdateAllProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1515 struct ScaWindowStruct
*ws
;
1517 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1521 SCA_LockWindowList(SCA_LockWindowList_Shared
);
1523 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
1525 d1(KPrintF("%s/%s/%ld: Name=<%s> Flags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ws
->ws_Name
, ws
->ws_Flags
));
1527 if (!(ws
->ws_Flags
& WSV_FlagF_TaskSleeps
))
1529 struct ScalosMessage
*msg
;
1531 msg
= SCA_AllocMessage(MTYP_Update
, 0);
1534 PutMsg(ws
->ws_MessagePort
, &msg
->sm_Message
);
1538 SCA_UnLockWindowList();
1540 d1(KPrintF("%s/%s/%ld: END iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1545 static void RedrawAllProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1547 struct ScaWindowStruct
*ws
;
1549 SCA_LockWindowList(SCA_LockWindowList_Shared
);
1551 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
1553 if (!(ws
->ws_Flags
& WSV_FlagF_TaskSleeps
))
1555 struct ScalosMessage
*msg
;
1557 msg
= SCA_AllocMessage(MTYP_Redraw
, 0);
1560 PutMsg(ws
->ws_MessagePort
, &msg
->sm_Message
);
1564 SCA_UnLockWindowList();
1568 void GetIconsBoundingBox(struct internalScaWindowTask
*iwt
, struct Rectangle
*BBox
)
1570 struct ScaIconNode
*in
;
1572 BBox
->MinX
= BBox
->MinY
= SHRT_MAX
;
1573 BBox
->MaxX
= BBox
->MaxY
= SHRT_MIN
;
1575 ScalosLockIconListShared(iwt
);
1577 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
1579 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
1581 if (BBox
->MinX
> gg
->BoundsLeftEdge
)
1582 BBox
->MinX
= gg
->BoundsLeftEdge
;
1583 if (BBox
->MinY
> gg
->BoundsTopEdge
)
1584 BBox
->MinY
= gg
->BoundsTopEdge
;
1586 if (BBox
->MaxX
< gg
->BoundsLeftEdge
+ gg
->BoundsWidth
- 1)
1587 BBox
->MaxX
= gg
->BoundsLeftEdge
+ gg
->BoundsWidth
- 1;
1588 if (BBox
->MaxY
< gg
->BoundsTopEdge
+ gg
->BoundsHeight
- 1)
1589 BBox
->MaxY
= gg
->BoundsTopEdge
+ gg
->BoundsHeight
- 1;
1592 BBox
->MinX
-= CurrentPrefs
.pref_CleanupSpace
.Left
;
1593 BBox
->MaxX
+= CurrentPrefs
.pref_CleanupSpace
.Left
;
1594 BBox
->MinY
-= CurrentPrefs
.pref_CleanupSpace
.Top
;
1595 BBox
->MaxY
+= CurrentPrefs
.pref_CleanupSpace
.Top
;
1597 ScalosUnLockIconList(iwt
);
1601 static void ClearSelectionInWindow(struct internalScaWindowTask
*iwt
)
1603 struct ScaIconNode
*in
;
1605 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1607 ScalosLockIconListShared(iwt
);
1609 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
1611 ClassSelectIcon(iwt
->iwt_WindowTask
.mt_WindowStruct
, in
, FALSE
);
1614 ScalosUnLockIconList(iwt
);
1618 static void ViewByIconProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1620 ViewWindowBy(iwt
, IDTV_ViewModes_Icon
);
1624 static void ViewByTextProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1626 ViewWindowBy(iwt
, IDTV_ViewModes_Name
);
1630 static void ViewByDateProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1632 ViewWindowBy(iwt
, IDTV_ViewModes_Date
);
1636 static void ViewBySizeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1638 ViewWindowBy(iwt
, IDTV_ViewModes_Size
);
1642 static void ViewByTypeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1644 ViewWindowBy(iwt
, IDTV_ViewModes_Type
);
1647 static void ViewByDefaultProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1649 ViewWindowBy(iwt
, IDTV_ViewModes_Default
);
1652 BOOL
ViewWindowBy(struct internalScaWindowTask
*iwt
, UBYTE NewViewByType
)
1654 struct ScaWindowStruct
*ws
= iwt
->iwt_WindowTask
.mt_WindowStruct
;
1656 UBYTE OldViewByType
;
1657 BOOL Updated
= FALSE
;
1659 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1660 d1(KPrintF("%s/%s/%ld: ws_Viewmodes=%ld NewViewByType=%ld\n", \
1661 __FILE__
, __FUNC__
, __LINE__
, ws
->ws_Viewmodes
, NewViewByType
));
1663 if (ws
->ws_Viewmodes
== NewViewByType
)
1666 FlushThumbnailEntries(iwt
);
1668 OldViewByType
= ws
->ws_Viewmodes
;
1670 newObject
= (Object
*) DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_NewViewMode
, NewViewByType
);
1671 d1(KPrintF("%s/%s/%ld: newObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, newObject
));
1675 ws
->ws_Viewmodes
= OldViewByType
;
1677 if (iwt
->iwt_WindowTask
.wt_Window
)
1679 struct Region
*origClipRegion
= iwt
->iwt_RemRegion
;
1681 d1(kprintf("%s/%s/%ld: iwt_RemRegion=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_RemRegion
));
1682 iwt
->iwt_RemRegion
= NULL
;
1684 DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_RemClipRegion
, origClipRegion
);
1687 oldObject
= iwt
->iwt_WindowTask
.mt_MainObject
;
1688 iwt
->iwt_WindowTask
.mt_MainObject
= newObject
;
1690 ws
->ws_Viewmodes
= NewViewByType
;
1692 DisposeObject(oldObject
);
1695 DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_SetInnerSize
);
1697 iwt
->iwt_WindowTask
.wt_XOffset
= 0;
1698 iwt
->iwt_WindowTask
.wt_YOffset
= 0;
1700 ws
->ws_xoffset
= iwt
->iwt_WindowTask
.wt_XOffset
;
1701 ws
->ws_yoffset
= iwt
->iwt_WindowTask
.wt_YOffset
;
1703 d1(KPrintF("%s/%s/%ld: newObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, newObject
));
1706 // switch between icon/text window
1707 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_Update
);
1712 // all text window, different sorting
1713 if (!IsIwtViewByIcon(iwt
))
1714 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_TextWin_DrawColumnHeaders
);
1716 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUp
);
1718 d1(KPrintF("%s/%s/%ld: END Updated=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Updated
));
1724 static void CloneProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1726 struct WBArg
*wbArg
, *wbArgAlloc
;
1729 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1732 struct CloneArg processArgs
;
1733 ULONG NumberOfWbArgs
= 1;
1735 if (mcArg
->mca_IconNode
)
1736 NumberOfWbArgs
+= 1;
1738 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
1740 wbArg
= wbArgAlloc
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
1741 if (NULL
== wbArgAlloc
)
1744 if (mcArg
->mca_IconNode
)
1748 GetAttr(IDTA_Type
, mcArg
->mca_IconNode
->in_Icon
, &IconType
);
1750 if (WB_TEXTICON_TOOL
!= IconType
&&
1751 WB_TEXTICON_DRAWER
!= IconType
&&
1752 WBDRAWER
!= IconType
&&
1753 WBTOOL
!= IconType
&&
1754 WBPROJECT
!= IconType
)
1759 if (!CloneWBArg(iwt
, &wbArg
, mcArg
->mca_IconNode
, &ArgCount
))
1764 d1(kprintf("%s/%s/%ld: NumArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ArgCount
));
1768 MakeCloneArgs(iwt
, &wbArg
, &ArgCount
);
1771 d1(KPrintF("%s/%s/%ld: NumArgs=%ld iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ArgCount
, iwt
));
1773 DoForAppIcons(AMCLASSICON_Copy
);
1778 processArgs
.cla_wbArg
= wbArgAlloc
;
1779 processArgs
.cla_NumArgs
= ArgCount
;
1781 RunProcess(&iwt
->iwt_WindowTask
, CloneFilesStart
,
1782 sizeof(processArgs
)/sizeof(ULONG
), (struct WBArg
*)(APTR
) &processArgs
, NULL
);
1784 // wbArgAlloc will be freed inside <CloneFilesStart>
1792 SCA_FreeWBArgs(wbArgAlloc
, ArgCount
, SCAF_FreeNames
| SCAF_FreeLocks
);
1794 ScalosFree(wbArgAlloc
);
1799 static void MakeCloneArgs(struct internalScaWindowTask
*iwt
,
1800 struct WBArg
**wbArg
, ULONG
*ArgCount
)
1802 struct ScaWindowStruct
*ws
;
1804 SCA_LockWindowList(SCA_LockWindowList_Shared
);
1806 CloneInfoStart(iwt
, wbArg
, ArgCount
);
1808 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
1810 if (ws
!= iwt
->iwt_WindowTask
.mt_WindowStruct
)
1811 CloneInfoStart((struct internalScaWindowTask
*) ws
->ws_WindowTask
, wbArg
, ArgCount
);
1814 SCA_UnLockWindowList();
1818 static void CloneInfoStart(struct internalScaWindowTask
*iwt
,
1819 struct WBArg
**wbArg
, ULONG
*ArgCount
)
1821 struct ScaIconNode
*in
;
1823 ScalosLockIconListShared(iwt
);
1825 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
1827 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
1829 if (gg
->Flags
& GFLG_SELECTED
)
1833 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
1837 case WB_TEXTICON_TOOL
:
1838 case WB_TEXTICON_DRAWER
:
1842 d1(kprintf("%s/%s/%ld: icon=<%s> NumArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, GetIconName(in
), *ArgCount
));
1843 CloneWBArg(iwt
, wbArg
, in
, ArgCount
);
1851 ScalosUnLockIconList(iwt
);
1855 static BOOL
CloneWBArg(struct internalScaWindowTask
*iwt
, struct WBArg
**wbArg
,
1856 struct ScaIconNode
*in
, ULONG
*ArgCount
)
1858 if (NULL
== in
->in_Name
)
1863 (*wbArg
)->wa_Lock
= DupLock(in
->in_Lock
);
1867 if (iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
)
1868 (*wbArg
)->wa_Lock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
1870 (*wbArg
)->wa_Lock
= (BPTR
)NULL
;
1874 (*wbArg
)->wa_Name
= AllocCopyString(GetIconName(in
));
1876 if (NULL
== (*wbArg
)->wa_Name
)
1878 if ((*wbArg
)->wa_Lock
)
1879 UnLock((*wbArg
)->wa_Lock
);
1890 //---------------------------------------------------------------------------------------
1892 static SAVEDS(ULONG
) CloneFilesStart(APTR aptr
, struct SM_RunProcess
*msg
)
1894 struct CloneArg
*arg
= aptr
;
1896 STRPTR OldIconName
= NULL
;
1898 Object
*fileTransObj
= NULL
;
1902 undoStep
= UndoBeginStep();
1904 NewName
= AllocPathBuffer();
1905 if (NULL
== NewName
)
1908 OldIconName
= AllocPathBuffer();
1909 if (NULL
== OldIconName
)
1912 fileTransObj
= SCA_NewScalosObjectTags((STRPTR
) "FileTransfer.sca",
1913 SCCA_FileTrans_Screen
, (IPTR
) iInfos
.xii_iinfos
.ii_Screen
,
1914 SCCA_FileTrans_Number
, arg
->cla_NumArgs
,
1915 SCCA_FileTrans_ReplaceMode
, SCCV_ReplaceMode_Ask
,
1917 if (NULL
== fileTransObj
)
1920 d1(kprintf("%s/%s/%ld: NumArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, arg
->cla_NumArgs
));
1922 for (n
=0; n
< arg
->cla_NumArgs
; n
++)
1924 BumpRevision(NewName
, arg
->cla_wbArg
[n
].wa_Name
);
1926 debugLock_d1(arg
->cla_wbArg
[n
].wa_Lock
);
1927 d1(kprintf("%s/%s/%ld: wa_Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, arg
->cla_wbArg
[n
].wa_Name
));
1929 d1(kprintf("%s/%s/%ld: OldName=<%s> NewName=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, arg
->cla_wbArg
[n
].wa_Name
, NewName
));
1931 UndoAddEvent((struct internalScaWindowTask
*) msg
->WindowTask
, UNDO_Copy
,
1932 UNDOTAG_UndoMultiStep
, undoStep
,
1933 UNDOTAG_CopySrcDirLock
, arg
->cla_wbArg
[n
].wa_Lock
,
1934 UNDOTAG_CopyDestDirLock
, arg
->cla_wbArg
[n
].wa_Lock
,
1935 UNDOTAG_CopySrcName
, arg
->cla_wbArg
[n
].wa_Name
,
1936 UNDOTAG_CopyDestName
, NewName
,
1939 // clone file/drawer
1940 DoMethod(fileTransObj
, SCCM_FileTrans_Copy
,
1941 arg
->cla_wbArg
[n
].wa_Lock
, arg
->cla_wbArg
[n
].wa_Lock
,
1942 arg
->cla_wbArg
[n
].wa_Name
, NewName
);
1946 SCA_FreeWBArgs(arg
->cla_wbArg
, arg
->cla_NumArgs
, SCAF_FreeNames
| SCAF_FreeLocks
);
1947 ScalosFree(arg
->cla_wbArg
);
1950 UndoEndStep((struct internalScaWindowTask
*) msg
->WindowTask
, undoStep
);
1952 SCA_DisposeScalosObject(fileTransObj
);
1954 FreePathBuffer(OldIconName
);
1956 FreePathBuffer(NewName
);
1961 //---------------------------------------------------------------------------------------
1963 static void ThumbnailCacheCleanupProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1965 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1967 ThumbnailsStartCleanup(TRUE
);
1970 //---------------------------------------------------------------------------------------
1972 static void UpdateProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1974 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1976 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_Update
);
1979 //---------------------------------------------------------------------------------------
1981 static void CloseProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1983 iwt
->iwt_CloseWindow
= TRUE
;
1987 //---------------------------------------------------------------------------------------
1989 static void FindProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
1991 struct WBArg
*wbArg
;
1993 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
1996 ULONG NumberOfWbArgs
= 1;
2000 if (mcArg
->mca_IconNode
)
2001 NumberOfWbArgs
+= 1;
2003 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
2005 wbArg
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
2009 wbArg
[0].wa_Name
= (STRPTR
) "Find.module";
2010 wbArg
[0].wa_Lock
= LockScaModsDir();
2011 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
2015 d1(KPrintF("%s/%s/%ld: nArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, nArgs
));
2017 if (NumberOfWbArgs
> 1)
2019 if (mcArg
->mca_IconNode
)
2021 d1(KPrintF("%s/%s/%ld: NumberOfWbArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, NumberOfWbArgs
));
2022 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_MakeWBArg
,
2023 mcArg
->mca_IconNode
, &wbArg
[1]);
2028 d1(KPrintF("%s/%s/%ld: NumberOfWbArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, NumberOfWbArgs
));
2029 nArgs
+= SCA_MakeWBArgs(&wbArg
[1], NULL
, NumberOfWbArgs
- 1);
2033 d1(KPrintF("%s/%s/%ld: nArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, nArgs
));
2036 Success
= SCA_WBStartTags(wbArg
, nArgs
,
2037 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
2038 // SCA_Flags, SCAF_WBStart_Wait,
2039 // SCA_WaitTimeout, 0,
2042 d1(KPrintF("%s/%s/%ld: Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
2044 if (NumberOfWbArgs
> 1)
2046 SCA_FreeWBArgs(&wbArg
[1], nArgs
- 1,
2047 Success
? SCAF_FreeNames
: SCAF_FreeNames
| SCAF_FreeLocks
);
2050 wbArg
[0].wa_Lock
= (BPTR
)NULL
;
2053 d1(KPrintF("%s/%s/%ld: wbArg=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, wbArg
));
2057 if (wbArg
[0].wa_Lock
)
2058 UnLock(wbArg
[0].wa_Lock
);
2063 d1(KPrintF("%s/%s/%ld: END iwt=%08lx iwt_WinTitle=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2066 //---------------------------------------------------------------------------------------
2068 static void FormatDiskProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2070 struct WBArg
*wbArg
;
2072 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2075 ULONG NumberOfWbArgs
= 1;
2079 if (mcArg
->mca_IconNode
)
2080 NumberOfWbArgs
+= 1;
2082 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
2084 wbArg
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
2088 wbArg
[0].wa_Name
= (STRPTR
) "Format_Disk.module";
2089 wbArg
[0].wa_Lock
= LockScaModsDir();
2090 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
2095 if (NumberOfWbArgs
> 1)
2097 if (mcArg
->mca_IconNode
)
2099 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_MakeWBArg
,
2100 mcArg
->mca_IconNode
, &wbArg
[1]
2106 nArgs
+= SCA_MakeWBArgs(&wbArg
[1], NULL
, NumberOfWbArgs
- 1);
2110 DoForAppIcons(AMCLASSICON_FormatDisk
);
2116 Success
= SCA_WBStartTags(wbArg
, nArgs
,
2117 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
2118 SCA_Flags
, SCAF_WBStart_Wait
,
2122 if (NumberOfWbArgs
> 1)
2124 SCA_FreeWBArgs(&wbArg
[1], nArgs
- 1,
2125 Success
? SCAF_FreeNames
: SCAF_FreeNames
| SCAF_FreeLocks
);
2128 wbArg
[0].wa_Lock
= (BPTR
)NULL
;
2131 d1(KPrintF("%s/%s/%ld: START wbArg=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, wbArg
));
2135 if (wbArg
[0].wa_Lock
)
2136 UnLock(wbArg
[0].wa_Lock
);
2141 d1(KPrintF("%s/%s/%ld: END iwt=%08lx iwt_WinTitle=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2145 static void ShutdownProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2148 struct WBArg wbArg
[2];
2151 wbArg
[0].wa_Name
= (STRPTR
) "Shutdown.module";
2152 wbArg
[0].wa_Lock
= LockScaModsDir();
2153 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
2157 Success
= SCA_WBStartTags(wbArg
, 1,
2158 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
2159 SCA_Flags
, SCAF_WBStart_Wait
,
2164 UnLock(wbArg
[0].wa_Lock
);
2168 //---------------------------------------------------------------------------------------
2170 static void ShowOnlyIconsProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2172 SetAttrs(iwt
->iwt_WindowTask
.mt_MainObject
,
2173 SCCA_IconWin_ShowType
, DDFLAGS_SHOWICONS
,
2177 //---------------------------------------------------------------------------------------
2179 static void ShowAllFilesProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2181 SetAttrs(iwt
->iwt_WindowTask
.mt_MainObject
,
2182 SCCA_IconWin_ShowType
, DDFLAGS_SHOWALL
,
2186 //---------------------------------------------------------------------------------------
2188 static void ShowDefaultProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2190 SetAttrs(iwt
->iwt_WindowTask
.mt_MainObject
,
2191 SCCA_IconWin_ShowType
, DDFLAGS_SHOWDEFAULT
,
2195 //---------------------------------------------------------------------------------------
2197 static void CleanupProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2199 struct Hook SortHook
;
2200 struct ScaIconNode
*in
, *inNext
;
2202 if (!IsIwtViewByIcon(iwt
))
2205 ScalosLockIconListExclusive(iwt
);
2207 UndoAddEvent(iwt
, UNDO_Cleanup
,
2208 UNDOTAG_IconList
, iwt
->iwt_WindowTask
.wt_IconList
,
2209 UNDOTAG_WindowTask
, iwt
,
2210 UNDOTAG_CleanupMode
, CLEANUP_Default
,
2213 for (in
=iwt
->iwt_WindowTask
.wt_LateIconList
; in
; in
=inNext
)
2215 inNext
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
;
2217 SCA_MoveIconNode(&iwt
->iwt_WindowTask
.wt_LateIconList
, &iwt
->iwt_WindowTask
.wt_IconList
, in
);
2220 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
2222 in
->in_Flags
&= ~INF_IconVisible
;
2224 in
->in_OldLeftEdge
= NO_ICON_POSITION_SHORT
;
2225 in
->in_OldTopEdge
= NO_ICON_POSITION_SHORT
;
2228 iwt
->iwt_WindowTask
.wt_LateIconList
= iwt
->iwt_WindowTask
.wt_IconList
;
2229 iwt
->iwt_WindowTask
.wt_IconList
= NULL
;
2231 SETHOOKFUNC(SortHook
, IconCompareFunc
);
2232 SortHook
.h_Data
= NULL
;
2234 SCA_SortNodes((struct ScalosNodeList
*) &iwt
->iwt_WindowTask
.wt_LateIconList
, &SortHook
, SCA_SortType_Best
);
2236 ScalosUnLockIconList(iwt
);
2238 iwt
->iwt_WindowTask
.wt_XOffset
= iwt
->iwt_WindowTask
.wt_YOffset
= 0;
2239 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_xoffset
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_yoffset
= 0;
2241 if (iwt
->iwt_WindowTask
.wt_Window
)
2243 EraseRect(iwt
->iwt_WindowTask
.wt_Window
->RPort
, 0, 0,
2244 iwt
->iwt_WindowTask
.wt_Window
->Width
- 1,
2245 iwt
->iwt_WindowTask
.wt_Window
->Height
-1);
2247 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUp
);
2249 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
,
2250 SETVIRTF_AdjustBottomSlider
| SETVIRTF_AdjustRightSlider
);
2254 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUp
);
2258 //---------------------------------------------------------------------------------------
2260 static void CleanupByNameProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2262 UndoAddEvent(iwt
, UNDO_Cleanup
,
2263 UNDOTAG_IconList
, iwt
->iwt_WindowTask
.wt_IconList
,
2264 UNDOTAG_WindowTask
, iwt
,
2265 UNDOTAG_CleanupMode
, CLEANUP_ByName
,
2268 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpByName
);
2271 //---------------------------------------------------------------------------------------
2273 static void CleanupByDateProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2275 UndoAddEvent(iwt
, UNDO_Cleanup
,
2276 UNDOTAG_IconList
, iwt
->iwt_WindowTask
.wt_IconList
,
2277 UNDOTAG_WindowTask
, iwt
,
2278 UNDOTAG_CleanupMode
, CLEANUP_ByDate
,
2281 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpByDate
);
2284 //---------------------------------------------------------------------------------------
2286 static void CleanupBySizeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2288 UndoAddEvent(iwt
, UNDO_Cleanup
,
2289 UNDOTAG_IconList
, iwt
->iwt_WindowTask
.wt_IconList
,
2290 UNDOTAG_WindowTask
, iwt
,
2291 UNDOTAG_CleanupMode
, CLEANUP_BySize
,
2294 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpBySize
);
2297 //---------------------------------------------------------------------------------------
2299 static void CleanupByTypeProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2301 UndoAddEvent(iwt
, UNDO_Cleanup
,
2302 UNDOTAG_IconList
, iwt
->iwt_WindowTask
.wt_IconList
,
2303 UNDOTAG_WindowTask
, iwt
,
2304 UNDOTAG_CleanupMode
, CLEANUP_ByType
,
2307 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUpByType
);
2310 //---------------------------------------------------------------------------------------
2312 static SAVEDS(LONG
) IconCompareFunc(struct Hook
*hook
, struct ScaIconNode
*in2
, struct ScaIconNode
*in1
)
2314 struct ExtGadget
*gg1
= (struct ExtGadget
*) in1
->in_Icon
;
2315 struct ExtGadget
*gg2
= (struct ExtGadget
*) in2
->in_Icon
;
2320 d1(kprintf("%s/%s/%ld: in1=%08lx in2=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, in1
, in2
));
2322 xDiff
= gg1
->LeftEdge
- gg2
->LeftEdge
;
2326 else if (xDiff
< -16)
2329 yDiff
= gg1
->TopEdge
- gg2
->TopEdge
;
2338 //---------------------------------------------------------------------------------------
2340 static void MenuOpenProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2344 if (mcArg
->mca_IconNode
)
2345 GetAttr(IDTA_Type
, mcArg
->mca_IconNode
->in_Icon
, &IconType
);
2347 if (WBAPPICON
== IconType
)
2349 WindowSendAppIconMsg(iwt
, AMCLASSICON_LeaveOut
, mcArg
->mca_IconNode
);
2354 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2356 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
,
2358 mcArg
->mca_IconNode
,
2359 ICONWINOPENF_IgnoreFileTypes
);
2363 //---------------------------------------------------------------------------------------
2365 static void MenuOpenNewProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2367 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2369 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
,
2371 mcArg
->mca_IconNode
,
2372 ICONWINOPENF_IgnoreFileTypes
| ICONWINOPENF_NewWindow
);
2375 //---------------------------------------------------------------------------------------
2377 static void MenuOpenBrowserWindowProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2379 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2381 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
,
2383 mcArg
->mca_IconNode
,
2384 ICONWINOPENF_IgnoreFileTypes
| ICONWINOPENF_BrowserWindow
);
2387 //---------------------------------------------------------------------------------------
2389 static void OpenParentProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2391 struct ScaWindowStruct
*ws
= iwt
->iwt_WindowTask
.mt_WindowStruct
;
2392 BPTR parentLock
= (BPTR
)NULL
;
2393 STRPTR ParentName
= NULL
;
2395 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2398 if ((BPTR
)NULL
== ws
->ws_Lock
)
2401 parentLock
= ParentDir(ws
->ws_Lock
);
2402 if ((BPTR
)NULL
== parentLock
)
2405 ParentName
= AllocPathBuffer();
2406 if (NULL
== ParentName
)
2409 if (!NameFromLock(parentLock
, ParentName
, Max_PathLen
))
2412 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
2414 if (ws
->ws_Flags
& WSV_FlagF_BrowserMode
)
2416 WindowNewPath(iwt
, ParentName
);
2420 SCA_OpenIconWindowTags(SCA_Flags
, SCAF_OpenWindow_ScalosPort
,
2421 SCA_Path
, (IPTR
) ParentName
,
2422 SCA_CheckOverlappingIcons
, CurrentPrefs
.pref_CheckOverlappingIcons
,
2426 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
2430 FreePathBuffer(ParentName
);
2435 //---------------------------------------------------------------------------------------
2437 static void ExecuteCmdProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2439 CONST_STRPTR ProgramName
;
2442 if (mcArg
->mca_IconNode
)
2443 ProgramName
= GetIconName(mcArg
->mca_IconNode
);
2447 Result
= CallTextInputHook(TIACTION_Execute
, (STRPTR
) ProgramName
);
2451 struct WBArg Args
[2];
2453 Args
[0].wa_Lock
= LockScaModsDir();
2455 if (Args
[0].wa_Lock
)
2457 Args
[0].wa_Name
= (STRPTR
) "Execute_Command.module";
2458 Args
[1].wa_Lock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
2459 Args
[1].wa_Name
= (STRPTR
) ProgramName
;
2462 SCA_WBStartTags(Args
, 2,
2463 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
2469 //---------------------------------------------------------------------------------------
2471 static void LastMessageProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2473 SCA_ScreenTitleMsg((CONST_STRPTR
) ~0, NULL
);
2476 //---------------------------------------------------------------------------------------
2478 static void IconifyProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2480 DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_Iconify
);
2483 //---------------------------------------------------------------------------------------
2485 static void RedrawProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2487 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_Redraw
, REDRAWF_DontRefreshWindowFrame
);
2490 //---------------------------------------------------------------------------------------
2492 static void ResetScalosProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2494 struct MenuCmdArg DummyArg
;
2496 StartProgTask(iwt
, &DummyArg
, AsyncResetScalosProg
, (struct MsgPort
*) SCCV_RunProcess_NoReply
);
2499 //---------------------------------------------------------------------------------------
2501 static void AsyncResetScalosProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*dummy
)
2503 struct ScaWindowStruct
*WinList
= NULL
;
2504 struct ScaWindowStruct
*ws
, *wsNext
;
2505 struct MsgPort
*ReplyPort
;
2508 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2512 ReplyPort
= CreateMsgPort();
2514 d1(kprintf("%s/%s/%ld: ReplyPort=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ReplyPort
));
2517 struct SM_AppSleep
*smas
= (struct SM_AppSleep
*) SCA_AllocMessage(MTYP_AppSleep
, 0);
2520 smas
->ScalosMessage
.sm_Message
.mn_ReplyPort
= ReplyPort
;
2522 d1(kprintf("%s/%s/%ld: Before PutMsg\n", __FILE__
, __FUNC__
, __LINE__
));
2523 PutMsg(iInfos
.xii_iinfos
.ii_MainMsgPort
, &smas
->ScalosMessage
.sm_Message
);
2524 d1(kprintf("%s/%s/%ld: After PutMsg\n", __FILE__
, __FUNC__
, __LINE__
));
2526 WaitReply(ReplyPort
, iwt
, MTYP_AppSleep
);
2527 d1(kprintf("%s/%s/%ld: After WaitReply\n", __FILE__
, __FUNC__
, __LINE__
));
2531 SCA_LockWindowList(SCA_LockWindowList_Exclusiv
);
2532 d1(kprintf("%s/%s/%ld: Window List Loecked\n", __FILE__
, __FUNC__
, __LINE__
));
2534 iLock
= ScaLockIBase(0);
2535 d1(kprintf("%s/%s/%ld: iLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iLock
));
2537 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
=wsNext
)
2539 wsNext
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
;
2546 for (win
=iwt
->iwt_WinScreen
->FirstWindow
; win
; win
=win
->NextWindow
)
2548 if (win
== ws
->ws_Window
)
2557 SCA_MoveWSNode(&winlist
.wl_WindowStruct
, &WinList
, ws
);
2562 ScaUnlockIBase(iLock
);
2563 d1(kprintf("%s/%s/%ld: After UnlockIBase\n", __FILE__
, __FUNC__
, __LINE__
));
2565 for (ws
=WinList
; ws
; ws
=wsNext
)
2567 wsNext
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
;
2569 d1(kprintf("%s/%s/%ld: ws=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ws
));
2571 FreeBackFill(&((struct internalScaWindowTask
*) ws
->ws_WindowTask
)->iwt_WindowTask
.wt_PatternInfo
);
2572 ScalosFree(ws
->ws_WindowTask
);
2574 SCA_FreeNode((struct ScalosNodeList
*)(APTR
) &WinList
, &ws
->ws_Node
);
2577 SCA_UnLockWindowList();
2578 d1(kprintf("%s/%s/%ld: Window List Unlocked\n", __FILE__
, __FUNC__
, __LINE__
));
2582 struct SM_AppWakeup
*smaw
= (struct SM_AppWakeup
*) SCA_AllocMessage(MTYP_AppWakeup
, 0);
2585 smaw
->ScalosMessage
.sm_Message
.mn_ReplyPort
= ReplyPort
;
2586 smaw
->smaw_ReLayout
= FALSE
;
2588 d1(kprintf("%s/%s/%ld: Before PutMsg\n", __FILE__
, __FUNC__
, __LINE__
));
2589 PutMsg(iInfos
.xii_iinfos
.ii_MainMsgPort
, &smaw
->ScalosMessage
.sm_Message
);
2590 d1(kprintf("%s/%s/%ld: After PutMsg\n", __FILE__
, __FUNC__
, __LINE__
));
2592 WaitReply(ReplyPort
, iwt
, MTYP_AppWakeup
);
2593 d1(kprintf("%s/%s/%ld: After WaitReply\n", __FILE__
, __FUNC__
, __LINE__
));
2596 DeleteMsgPort(ReplyPort
);
2599 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
2602 //---------------------------------------------------------------------------------------
2604 static void MenuSnapshotProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2606 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2607 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
2609 if (mcArg
->mca_IconNode
)
2611 UndoAddEvent(iwt
, UNDO_Snapshot
,
2612 UNDOTAG_IconNode
, mcArg
->mca_IconNode
,
2613 UNDOTAG_IconDirLock
, mcArg
->mca_IconNode
->in_Lock
?
2614 mcArg
->mca_IconNode
->in_Lock
:
2615 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
,
2616 UNDOTAG_SaveIcon
, TRUE
,
2619 SCA_LockWindowList(SCA_LockWindowList_Shared
);
2620 SnapshotIcon(iwt
, mcArg
->mca_IconNode
, NULL
);
2621 SCA_UnLockWindowList();
2625 DoForAllWindowsShared(iwt
, SnapshotIcon
, NULL
);
2629 //---------------------------------------------------------------------------------------
2631 static void MenuUnsnapshotProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2633 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2634 d1(KPrintF("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
2636 if (mcArg
->mca_IconNode
)
2638 UndoAddEvent(iwt
, UNDO_Unsnapshot
,
2639 UNDOTAG_IconNode
, mcArg
->mca_IconNode
,
2640 UNDOTAG_IconDirLock
, mcArg
->mca_IconNode
->in_Lock
?
2641 mcArg
->mca_IconNode
->in_Lock
:
2642 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
,
2643 UNDOTAG_SaveIcon
, TRUE
,
2646 SCA_LockWindowList(SCA_LockWindowList_Shared
);
2647 UnsnapshotIcon(iwt
, mcArg
->mca_IconNode
, TRUE
, NULL
);
2648 AfterUnsnapshotIcon(iwt
);
2649 SCA_UnLockWindowList();
2653 DoForAllWindowsShared(iwt
, UnsnapshotIconAndSave
, AfterUnsnapshotIcon
);
2657 //---------------------------------------------------------------------------------------
2659 static void MenuUndoProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2661 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2662 d1(KPrintF("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
2667 //---------------------------------------------------------------------------------------
2669 static void MenuRedoProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2671 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
2672 d1(KPrintF("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
2677 //---------------------------------------------------------------------------------------
2679 static void SnapshotIcon(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
2683 d1(KPrintF("%s/%s/%ld: START iwt=%08lx in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, in
, GetIconName(in
)));
2685 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
2690 if (WBAPPICON
== IconType
)
2692 WindowSendAppIconMsg(iwt
, AMCLASSICON_Snapshot
, in
);
2699 SetIconWindowRect(in
);
2701 if (in
->in_DeviceIcon
)
2703 destDirLock
= DiskInfoLock(in
);
2707 UndoAddEvent(iwt
, UNDO_Snapshot
,
2708 UNDOTAG_UndoMultiStep
, undoStep
,
2709 UNDOTAG_IconNode
, in
,
2710 UNDOTAG_IconDirLock
, destDirLock
,
2711 UNDOTAG_SaveIcon
, TRUE
,
2714 ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
2716 UnLock(destDirLock
);
2722 destDirLock
= in
->in_Lock
;
2724 destDirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
2726 UndoAddEvent(iwt
, UNDO_Snapshot
,
2727 UNDOTAG_UndoMultiStep
, undoStep
,
2728 UNDOTAG_IconNode
, in
,
2729 UNDOTAG_IconDirLock
, destDirLock
,
2730 UNDOTAG_SaveIcon
, TRUE
,
2733 ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
2736 in
->in_Flags
&= ~INF_FreeIconPosition
;
2737 in
->in_SupportFlags
|= INF_SupportsUnSnapshot
;
2740 d1(KPrintF("%s/%s/%ld: END in=%08lx <%s> inFlags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
), in
->in_Flags
));
2743 //---------------------------------------------------------------------------------------
2745 static void UnsnapshotIconAndSave(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
2747 UnsnapshotIcon(iwt
, in
, TRUE
, undoStep
);
2750 //---------------------------------------------------------------------------------------
2752 static void UnsnapshotIcon(struct internalScaWindowTask
*iwt
,
2753 struct ScaIconNode
*in
, BOOL SaveIcon
, APTR undoStep
)
2757 d1(KPrintF("%s/%s/%ld: iwt=%08lx in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, in
, GetIconName(in
)));
2759 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
2764 if (WBAPPICON
== IconType
)
2766 WindowSendAppIconMsg(iwt
, AMCLASSICON_UnSnapshot
, in
);
2771 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
2773 WORD LeftEdge
, TopEdge
;
2775 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2777 SetIconWindowRect(in
);
2779 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2781 LeftEdge
= gg
->LeftEdge
;
2782 TopEdge
= gg
->TopEdge
;
2784 if (in
->in_DeviceIcon
)
2786 destDirLock
= DiskInfoLock(in
);
2788 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2792 UndoAddEvent(iwt
, UNDO_Unsnapshot
,
2793 UNDOTAG_UndoMultiStep
, undoStep
,
2794 UNDOTAG_IconNode
, in
,
2795 UNDOTAG_IconDirLock
, destDirLock
,
2796 UNDOTAG_SaveIcon
, SaveIcon
,
2799 gg
->LeftEdge
= gg
->TopEdge
= NO_ICON_POSITION_SHORT
;
2802 ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
2804 UnLock(destDirLock
);
2809 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2812 destDirLock
= in
->in_Lock
;
2814 destDirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
2816 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2818 UndoAddEvent(iwt
, UNDO_Unsnapshot
,
2819 UNDOTAG_UndoMultiStep
, undoStep
,
2820 UNDOTAG_IconNode
, in
,
2821 UNDOTAG_IconDirLock
, destDirLock
,
2822 UNDOTAG_SaveIcon
, SaveIcon
,
2825 gg
->LeftEdge
= gg
->TopEdge
= NO_ICON_POSITION_SHORT
;
2828 ScalosPutIcon(in
, destDirLock
, in
->in_Flags
& INF_DefaultIcon
);
2830 d1(kprintf("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2833 gg
->LeftEdge
= LeftEdge
;
2834 gg
->TopEdge
= TopEdge
;
2836 in
->in_Flags
|= INF_FreeIconPosition
;
2837 in
->in_SupportFlags
|= INF_SupportsSnapshot
;
2838 in
->in_SupportFlags
&= ~INF_SupportsUnSnapshot
;
2841 d1(KPrintF("%s/%s/%ld: in=%08lx <%s> inFlags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
), in
->in_Flags
));
2844 //---------------------------------------------------------------------------------------
2846 static void AfterUnsnapshotIcon(struct internalScaWindowTask
*iwt
)
2848 d1(KPrintF("%s/%s/%ld:START\n", __FILE__
, __FUNC__
, __LINE__
));
2850 if (IsIwtViewByIcon(iwt
))
2852 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_UnCleanUp
);
2853 d1(KPrintF("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2854 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_CleanUp
);
2855 d1(KPrintF("%s/%s/%ld:\n", __FILE__
, __FUNC__
, __LINE__
));
2856 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_SetVirtSize
,
2857 SETVIRTF_AdjustBottomSlider
| SETVIRTF_AdjustRightSlider
);
2860 d1(KPrintF("%s/%s/%ld:END\n", __FILE__
, __FUNC__
, __LINE__
));
2863 //---------------------------------------------------------------------------------------
2865 void SetIconWindowRect(struct ScaIconNode
*in
)
2869 BPTR oldDir
= CurrentDir(in
->in_Lock
);
2879 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
2881 if (WBDISK
== IconType
)
2883 SetRect2(in
, DiskInfoLock(in
));
2890 //---------------------------------------------------------------------------------------
2892 static void SetRect(struct ScaIconNode
*in
)
2896 BPTR iconLock
= Lock((STRPTR
) GetIconName(in
), ACCESS_READ
);
2900 SetRect2(in
, iconLock
);
2906 //---------------------------------------------------------------------------------------
2908 static void SetRect2(struct ScaIconNode
*in
, BPTR iconLock
)
2912 struct ScaWindowStruct
*ws
;
2914 SCA_LockWindowList(SCA_LockWindowList_Shared
);
2916 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
2918 if (LOCK_SAME
== ScaSameLock(iconLock
, ws
->ws_Lock
))
2921 struct IBox WinRect
;
2922 ULONG IconViewMode
= TranslateViewModesToIcon(ws
->ws_Viewmodes
);
2924 WinRect
.Left
= ws
->ws_Left
;
2925 WinRect
.Top
= ws
->ws_Top
;
2926 WinRect
.Width
= ws
->ws_Width
;
2927 WinRect
.Height
= ws
->ws_Height
;
2929 ddFlags
= ws
->ws_ViewAll
;
2930 if (SortOrder_Ascending
== ws
->ws_SortOrder
)
2931 ddFlags
|= DDFLAGS_SORTASC
;
2932 else if (SortOrder_Descending
== ws
->ws_SortOrder
)
2933 ddFlags
|= DDFLAGS_SORTDESC
;
2935 d1(KPrintF("%s/%s/%ld: ws_ViewAll=%04lx ddFlags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ws
->ws_ViewAll
, ddFlags
));
2937 SetAttrs(in
->in_Icon
,
2938 IDTA_ViewModes
, IconViewMode
,
2939 IDTA_Flags
, ddFlags
,
2940 IDTA_WindowRect
, (IPTR
) &WinRect
,
2941 IDTA_WinCurrentY
, ws
->ws_yoffset
,
2942 IDTA_WinCurrentX
, ws
->ws_xoffset
,
2947 SCA_UnLockWindowList();
2952 static void SnapshotAllProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2954 struct ScaIconNode
*in
;
2956 ScalosLockIconListShared(iwt
);
2958 if (IsIwtViewByIcon(iwt
))
2960 APTR undoStep
= UndoBeginStep();
2962 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
2964 SnapshotIcon(iwt
, in
, undoStep
);
2966 UndoEndStep(iwt
, undoStep
);
2969 ScalosUnLockIconList(iwt
);
2971 SnapshotWindowProg(iwt
, mcArg
);
2974 //---------------------------------------------------------------------------------------
2976 static void SnapshotWindowProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2978 if (iInfos
.xii_iinfos
.ii_MainWindowStruct
== iwt
->iwt_WindowTask
.mt_WindowStruct
)
2981 SnapshotWindow(iwt
);
2984 //---------------------------------------------------------------------------------------
2986 static void LeaveOutProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
2988 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
2990 if (mcArg
->mca_IconNode
)
2992 SCA_LockWindowList(SCA_LockWindowList_Shared
);
2993 LeaveOutIcon(iwt
, mcArg
->mca_IconNode
, NULL
);
2994 SCA_UnLockWindowList();
2998 DoForAllWindows(iwt
, LeaveOutIcon
);
3002 //---------------------------------------------------------------------------------------
3004 static void PutAwayProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3006 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
3008 if (mcArg
->mca_IconNode
)
3010 SCA_LockWindowList(SCA_LockWindowList_Shared
);
3011 PutAwayIconNode(iwt
, mcArg
->mca_IconNode
, NULL
);
3012 SCA_UnLockWindowList();
3016 DoForAllWindows(iwt
, PutAwayIconNode
);
3020 //---------------------------------------------------------------------------------------
3022 static void EmptyTrashProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3024 BOOL Success
= FALSE
;
3025 struct WBArg
*wbArg
;
3029 ULONG NumberOfWbArgs
= 1;
3031 if (mcArg
->mca_IconNode
)
3032 NumberOfWbArgs
+= 1;
3034 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
3036 wbArg
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
3040 wbArg
[0].wa_Name
= (STRPTR
) "Empty_Trashcan.module";
3041 wbArg
[0].wa_Lock
= LockScaModsDir();
3042 if ((BPTR
)NULL
== wbArg
[0].wa_Lock
)
3047 if (NumberOfWbArgs
> 1)
3049 if (mcArg
->mca_IconNode
)
3053 GetAttr(IDTA_Type
, mcArg
->mca_IconNode
->in_Icon
, &IconType
);
3055 if (WBGARBAGE
!= IconType
)
3058 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_MakeWBArg
,
3059 mcArg
->mca_IconNode
, &wbArg
[1]
3065 struct ScaWindowStruct
*ws
;
3066 struct WBArg
*WBArgPtr
= &wbArg
[1];
3068 SCA_LockWindowList(SCA_LockWindowList_Shared
);
3070 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
3072 struct internalScaWindowTask
*iwtx
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
3073 struct ScaIconNode
*in
;
3075 ScalosLockIconListShared(iwtx
);
3077 for (in
=iwtx
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
3079 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
3081 if (gg
->Flags
& GFLG_SELECTED
)
3085 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
3087 if (WBGARBAGE
== IconType
)
3089 if (DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_MakeWBArg
,
3099 ScalosUnLockIconList(iwtx
);
3102 SCA_UnLockWindowList();
3106 DoForAppIcons(AMCLASSICON_EmptyTrash
);
3111 ScalosObtainSemaphoreShared(&DeleteHookSemaphore
);
3113 if (globalDeleteHook
)
3115 Success
= CallGlobalDeleteHook(&wbArg
[1], nArgs
- 1, DLACTION_BeginEmptyTrash
);
3118 ScalosReleaseSemaphore(&DeleteHookSemaphore
);
3123 Success
= SCA_WBStartTags(wbArg
, nArgs
,
3124 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
3125 SCA_Flags
, SCAF_WBStart_Wait
,
3129 if (NumberOfWbArgs
> 1)
3131 SCA_FreeWBArgs(&wbArg
[1], nArgs
- 1,
3132 Success
? SCAF_FreeNames
: SCAF_FreeNames
| SCAF_FreeLocks
);
3135 wbArg
[0].wa_Lock
= (BPTR
)NULL
;
3139 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_ImmediateCheckUpdate
);
3144 if (wbArg
[0].wa_Lock
)
3145 UnLock(wbArg
[0].wa_Lock
);
3151 //---------------------------------------------------------------------------------------
3153 static void CloseWindowProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3155 iwt
->iwt_CloseWindow
= TRUE
;
3158 //---------------------------------------------------------------------------------------
3160 static ULONG
FindIconType(struct WBArg
*Arg
)
3162 struct ScaWindowStruct
*ws
;
3166 SCA_LockWindowList(SCA_LockWindowList_Shared
);
3168 for (ws
=winlist
.wl_WindowStruct
; !Found
&& ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
3170 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
3174 if (LOCK_SAME
== ScaSameLock(Arg
->wa_Lock
, ws
->ws_Lock
))
3176 struct ScaIconNode
*in
;
3178 ScalosLockIconListShared(iwt
);
3180 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; !Found
&& in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
3182 if (0 == strcmp(Arg
->wa_Name
, GetIconName(in
)))
3184 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
3189 ScalosUnLockIconList(iwt
);
3194 struct ScaIconNode
*in
;
3196 ScalosLockIconListShared(iwt
);
3198 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; !Found
&& in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
3200 if (in
->in_DeviceIcon
)
3202 if ((BPTR
)NULL
== Arg
->wa_Lock
3203 && (0 == strcmp(Arg
->wa_Name
, GetIconName(in
))))
3205 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
3211 if (LOCK_SAME
== ScaSameLock(in
->in_Lock
, Arg
->wa_Lock
)
3212 && (0 == strcmp(Arg
->wa_Name
, GetIconName(in
))))
3214 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
3221 ScalosUnLockIconList(iwt
);
3225 SCA_UnLockWindowList();
3230 //---------------------------------------------------------------------------------------
3232 static BOOL
CallGlobalDeleteHook(struct WBArg
*wbArg
, ULONG nArgs
, ULONG Action
)
3234 BOOL Success
= FALSE
;
3239 struct DeleteBeginMsg dbm
;
3240 struct DeleteEndMsg dem
;
3242 dbm
.dbm_Length
= sizeof(dbm
);
3243 dbm
.dbm_Action
= Action
;
3245 Result
= CallHookPkt(globalDeleteHook
, NULL
, &dbm
);
3246 if (RETURN_OK
!= Result
)
3249 for (n
=0; n
<nArgs
; n
++)
3251 struct DeleteDataMsg ddm
;
3253 BOOL isTrashcan
= FALSE
;
3255 switch (FindIconType(&wbArg
[n
]))
3264 case WB_TEXTICON_DRAWER
:
3272 ddm
.ddm_Length
= sizeof(ddm
);
3273 ddm
.ddm_Action
= isDrawer
? DLACTION_DeleteContents
: DLACTION_DeleteObject
;
3274 ddm
.ddm_Lock
= wbArg
[n
].wa_Lock
;
3275 ddm
.ddm_Name
= wbArg
[n
].wa_Name
;
3277 d1(kprintf("%s/%s/%ld: ddm.ddm_Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ddm
.ddm_Name
));
3278 debugLock_d1(ddm
.ddm_Lock
);
3280 Result
= CallHookPkt(globalDeleteHook
, NULL
, &ddm
);
3281 if (RETURN_OK
!= Result
)
3284 if (isDrawer
&& !isTrashcan
)
3286 ddm
.ddm_Length
= sizeof(ddm
);
3287 ddm
.ddm_Action
= DLACTION_DeleteObject
;
3288 ddm
.ddm_Lock
= wbArg
[n
].wa_Lock
;
3289 ddm
.ddm_Name
= wbArg
[n
].wa_Name
;
3291 d1(kprintf("%s/%s/%ld: ddm.ddm_Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, ddm
.ddm_Name
));
3292 debugLock_d1(ddm
.ddm_Lock
);
3294 Result
= CallHookPkt(globalDeleteHook
, NULL
, &ddm
);
3298 if (RETURN_OK
!= Result
)
3301 dem
.dem_Length
= sizeof(dem
);
3302 dem
.dem_Action
= DLACTION_End
;
3304 Result
= CallHookPkt(globalDeleteHook
, NULL
, &dem
);
3306 if (RETURN_OK
!= Result
)
3310 SCA_FreeWBArgs(wbArg
, nArgs
, SCAF_FreeNames
| SCAF_FreeLocks
);
3316 //---------------------------------------------------------------------------------------
3318 // Workaround for broken "delete.module" implementations.
3319 // every directory WBArg gets changed
3320 // from <Lock to Parent-Dir> <Directory-Name>
3321 // to <Lock to Directory> <empty-Name>
3322 static void DeleteModuleKludge(struct WBArg
*wbArg
, ULONG nArgs
)
3326 d1(kprintf("%s/%s/%ld: START fib=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, fib
));
3328 if (ScalosExamineBegin(&fib
))
3332 // do not change wbArg[0] here!
3333 for (n
=1; n
<nArgs
; n
++)
3336 BPTR oldLock
= (BPTR
)NULL
;
3339 oldDir
= CurrentDir(wbArg
[n
].wa_Lock
);
3341 dirLock
= Lock(wbArg
[n
].wa_Name
, ACCESS_READ
);
3344 if (ScalosExamineLock(dirLock
, &fib
) && ScalosExamineIsDrawer(fib
))
3346 FreeCopyString(wbArg
[n
].wa_Name
);
3347 oldLock
= wbArg
[n
].wa_Lock
;
3349 wbArg
[n
].wa_Lock
= DupLock(dirLock
);
3350 wbArg
[n
].wa_Name
= AllocCopyString("");
3361 d1(kprintf("%s/%s/%ld: wa_Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, wbArg
[n
].wa_Name
));
3362 debugLock_d1(wbArg
[n
].wa_Lock
);
3365 ScalosExamineEnd(&fib
);
3369 //---------------------------------------------------------------------------------------
3371 static void MenuCopyProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3373 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
3375 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_ClearClipboard
);
3377 if (mcArg
->mca_IconNode
)
3379 SCA_LockWindowList(SCA_LockWindowList_Shared
);
3380 RememberFilesToCopy(iwt
, mcArg
->mca_IconNode
, NULL
);
3381 SCA_UnLockWindowList();
3385 DoForAllWindowsShared(iwt
, RememberFilesToCopy
, NULL
);
3389 //---------------------------------------------------------------------------------------
3391 static void MenuCutProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3393 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
3395 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_ClearClipboard
);
3397 if (mcArg
->mca_IconNode
)
3399 SCA_LockWindowList(SCA_LockWindowList_Shared
);
3400 RememberFilesToCut(iwt
, mcArg
->mca_IconNode
, NULL
);
3401 SCA_UnLockWindowList();
3405 DoForAllWindowsShared(iwt
, RememberFilesToCut
, NULL
);
3409 //---------------------------------------------------------------------------------------
3411 static void MenuPasteProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3413 d1(kprintf("%s/%s/%ld: Obtain WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
3415 ScalosObtainSemaphoreShared(iwt
->iwt_WindowTask
.wt_WindowSemaphore
); // prevent window from closing
3417 StartProgTask(iwt
, mcArg
, AsyncPasteProg
, SCCV_RunProcess_NoReply
);
3419 d1(kprintf("%s/%s/%ld: Release WindowSemaphore iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
3421 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
3424 //---------------------------------------------------------------------------------------
3426 static void AsyncPasteProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3428 Object
*fileTransObj
;
3429 BPTR DestLock
= (BPTR
)NULL
;
3430 APTR undoStep
= NULL
;
3432 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
3434 if (mcArg
->mca_IconNode
)
3437 BPTR newLock
= (BPTR
)NULL
;
3440 d1(kprintf("%s/%s/%ld: mca_IconNode=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
, GetIconName(mcArg
->mca_IconNode
)));
3442 GetAttr(IDTA_Type
, mcArg
->mca_IconNode
->in_Icon
, &IconType
);
3449 case WBGARBAGE
: // +++ JMC 26.11.2004
3450 case WB_TEXTICON_DRAWER
:
3451 if (mcArg
->mca_IconNode
->in_DeviceIcon
)
3453 parentDirLock
= newLock
= DiskInfoLock(mcArg
->mca_IconNode
);
3457 if (mcArg
->mca_IconNode
->in_Lock
)
3458 parentDirLock
= mcArg
->mca_IconNode
->in_Lock
;
3460 parentDirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
3463 debugLock_d1(parentDirLock
);
3467 BPTR oldDir
= CurrentDir(parentDirLock
);
3469 DestLock
= Lock((STRPTR
) GetIconName(mcArg
->mca_IconNode
), ACCESS_READ
);
3470 debugLock_d1(DestLock
);
3481 if ((BPTR
)NULL
== DestLock
)
3482 DestLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
3484 debugLock_d1(DestLock
);
3486 fileTransObj
= SCA_NewScalosObjectTags((STRPTR
) "FileTransfer.sca",
3487 SCCA_FileTrans_Screen
, (IPTR
) iInfos
.xii_iinfos
.ii_Screen
,
3488 // SCCA_FileTrans_Number, ArgCount,
3489 SCCA_FileTrans_ReplaceMode
, SCCV_ReplaceMode_Ask
,
3494 struct FileTransArg
*fta
;
3495 ULONG Result
= RETURN_OK
;
3497 undoStep
= UndoBeginStep();
3499 while (RETURN_OK
== Result
)
3501 CONST_STRPTR destName
;
3502 STRPTR destNameCopy
= NULL
;
3505 ScalosObtainSemaphore(&ClipboardSemaphore
);
3506 fta
= (struct FileTransArg
*) RemHead(&globalCopyClipBoard
);
3507 ScalosReleaseSemaphore(&ClipboardSemaphore
);
3512 debugLock_d1(fta
->ftarg_Arg
.wa_Lock
);
3513 d1(kprintf("%s/%s/%ld: ftarg_Arg.wa_Name=<%s> OpCode=%ld\n", \
3514 __FILE__
, __FUNC__
, __LINE__
, fta
->ftarg_Arg
.wa_Name
, fta
->ftarg_Opcode
));
3516 switch (fta
->ftarg_Opcode
)
3519 len
= strlen(fta
->ftarg_Arg
.wa_Name
);
3520 destName
= fta
->ftarg_Arg
.wa_Name
;
3521 if (':' == destName
[len
- 1])
3523 // Replace trailing ":" by "/" for copying volumes/disks to directories
3525 destNameCopy
= AllocCopyString(destName
);
3528 fta
->ftarg_Arg
.wa_Name
[0] = '\0';
3530 destName
= destNameCopy
;
3531 StripTrailingColon(destNameCopy
);
3535 UndoAddEvent(iwt
, UNDO_Copy
,
3536 UNDOTAG_UndoMultiStep
, undoStep
,
3537 UNDOTAG_CopySrcDirLock
, fta
->ftarg_Arg
.wa_Lock
,
3538 UNDOTAG_CopyDestDirLock
, DestLock
,
3539 UNDOTAG_CopySrcName
, fta
->ftarg_Arg
.wa_Name
,
3540 UNDOTAG_CopyDestName
, destName
,
3543 Result
= DoMethod(fileTransObj
, SCCM_FileTrans_Copy
,
3544 fta
->ftarg_Arg
.wa_Lock
, DestLock
,
3545 fta
->ftarg_Arg
.wa_Name
, // srcName
3546 destName
, // destName
3547 NO_ICON_POSITION_SHORT
, NO_ICON_POSITION_SHORT
);
3551 UndoAddEvent(iwt
, UNDO_Move
,
3552 UNDOTAG_UndoMultiStep
, undoStep
,
3553 UNDOTAG_CopySrcDirLock
, fta
->ftarg_Arg
.wa_Lock
,
3554 UNDOTAG_CopyDestDirLock
, DestLock
,
3555 UNDOTAG_CopySrcName
, fta
->ftarg_Arg
.wa_Name
,
3558 Result
= DoMethod(fileTransObj
, SCCM_FileTrans_Move
,
3559 fta
->ftarg_Arg
.wa_Lock
, DestLock
,
3560 fta
->ftarg_Arg
.wa_Name
,
3561 NO_ICON_POSITION_SHORT
, NO_ICON_POSITION_SHORT
);
3566 FreeCopyString(destNameCopy
);
3567 if (fta
->ftarg_Arg
.wa_Name
)
3569 FreeCopyString(fta
->ftarg_Arg
.wa_Name
);
3570 fta
->ftarg_Arg
.wa_Name
= NULL
;
3572 if (fta
->ftarg_Arg
.wa_Lock
)
3574 UnLock(fta
->ftarg_Arg
.wa_Lock
);
3575 fta
->ftarg_Arg
.wa_Lock
= (BPTR
)NULL
;
3580 d1(kprintf("%s/%s/%ld: Result=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Result
));
3583 SCA_DisposeScalosObject(fileTransObj
);
3586 UndoEndStep(iwt
, undoStep
);
3588 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_ClearClipboard
);
3591 //---------------------------------------------------------------------------------------
3593 static void MenuCreateThumbnailProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
3595 d1(KPrintF("%s/%s/%ld: START mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
3597 if (mcArg
->mca_IconNode
)
3599 CreateThumbnailStart(iwt
, mcArg
->mca_IconNode
, NULL
);
3603 DoForAllWindows(iwt
, CreateThumbnailStart
);
3605 d1(KPrintF("%s/%s/%ld: END mca_IconNode=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, mcArg
->mca_IconNode
));
3608 //---------------------------------------------------------------------------------------
3610 static void RememberFilesToCopy(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
3614 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_AddToClipboard
, iwt
, in
, FTOPCODE_Copy
);
3617 //---------------------------------------------------------------------------------------
3619 static void RememberFilesToCut(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
3621 struct ScaIconNode inCopy
;
3622 struct ScaIconNode
*IconList
= &inCopy
;
3627 GetAttr(IDTA_UserFlags
, in
->in_Icon
, &UserFlags
);
3628 UserFlags
|= ICONOBJ_USERFLAGF_DrawShadowed
;
3629 SetAttrs(in
->in_Icon
, IDTA_UserFlags
, UserFlags
, TAG_END
);
3632 inCopy
.in_Node
.mln_Succ
= NULL
;
3634 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_AddToClipboard
, iwt
, in
, FTOPCODE_Move
);
3636 RemoveIcons(iwt
, &IconList
);
3637 RefreshIconList(iwt
, IconList
, NULL
);
3640 //---------------------------------------------------------------------------------------
3642 static ULONG
CallTextInputHook(ULONG Action
, STRPTR Prompt
)
3644 struct TextInputMsg tim
;
3646 if (NULL
== globalTextInputHook
)
3649 tim
.tim_Length
= sizeof(tim
);
3650 tim
.tim_Action
= Action
;
3651 tim
.tim_Prompt
= Prompt
;
3653 return CallHookPkt(globalTextInputHook
, NULL
, &tim
);
3656 //---------------------------------------------------------------------------------------
3658 static STRPTR
FindUniqueName(STRPTR Name
, size_t MaxLength
)
3660 STRPTR lp
= Name
+ strlen(Name
);
3671 ScaFormatStringMaxLength(NrString
, sizeof(NrString
), "_%lu", Nr
);
3672 SafeStrCat(Name
, NrString
, MaxLength
);
3675 fLock
= Lock(Name
, ACCESS_READ
);
3686 //---------------------------------------------------------------------------------------
3688 static BOOL
CanBeSizedMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3692 if (iwt
->iwt_BackDrop
)
3698 //---------------------------------------------------------------------------------------
3700 static BOOL
IsMainWindowMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3704 return (BOOL
) (WSV_Type_DeviceWindow
== iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_WindowType
);
3707 //---------------------------------------------------------------------------------------
3709 static BOOL
NotMainWindowMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3713 return (BOOL
) !(WSV_Type_DeviceWindow
== iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_WindowType
);
3716 //---------------------------------------------------------------------------------------
3718 static BOOL
NotRootWindowMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3722 return (BOOL
) !(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Flags
& WSV_FlagF_RootWindow
);
3725 //---------------------------------------------------------------------------------------
3727 static BOOL
MustHaveLockMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3729 if (iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
)
3732 if (in
&& in
->in_Lock
)
3738 //---------------------------------------------------------------------------------------
3740 static BOOL
IconsSelectedAndWriteableMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3742 d1(KPrintF("%s/%s/%ld: in=%08lx IconActive=%ld\n", __FILE__
, __FUNC__
, __LINE__
, in
, IconActive
));
3744 if (NULL
== in
&& 0 == IconActive
)
3746 if (iwt
->iwt_ReadOnly
)
3749 if (in
&& (in
->in_Flags
& INF_VolumeWriteProtected
))
3755 //---------------------------------------------------------------------------------------
3757 static BOOL
IconsSelectedNoDiskMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3759 if (NULL
== in
&& 0 == IconActive
)
3762 if (in
&& in
->in_DeviceIcon
)
3765 if (iwt
->iwt_ReadOnly
)
3768 if (in
&& (in
->in_Flags
& INF_VolumeWriteProtected
))
3774 //---------------------------------------------------------------------------------------
3776 static BOOL
IconsSelectedMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3778 if (NULL
== in
&& 0 == IconActive
)
3784 //---------------------------------------------------------------------------------------
3786 static BOOL
IconsSelectedBrowserModeMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3788 if (!(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Flags
& WSV_FlagF_BrowserMode
))
3789 return FALSE
; // only enabled if browser mode
3791 return IconsSelectedMenuEnable(iwt
, in
);
3794 //---------------------------------------------------------------------------------------
3796 static BOOL
IconsSelectedNotBrowserModeMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3798 if (iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Flags
& WSV_FlagF_BrowserMode
)
3799 return FALSE
; // only enabled if not browser mode
3801 return IconsSelectedMenuEnable(iwt
, in
);
3804 //---------------------------------------------------------------------------------------
3806 static BOOL
EmptyTrashMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3808 if (NULL
== in
&& 0 == IconActive
)
3816 //---------------------------------------------------------------------------------------
3818 static BOOL
FormatDiskMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3820 if (NULL
== in
&& 0 == IconActive
)
3828 //---------------------------------------------------------------------------------------
3830 static BOOL
LeaveOutMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3832 if (NULL
== in
&& 0 == IconActive
)
3834 if (iwt
->iwt_ReadOnly
)
3836 if (WSV_Type_DeviceWindow
== iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_WindowType
)
3837 return FALSE
; // "leave out" not allowed from desktop window
3844 //---------------------------------------------------------------------------------------
3846 static BOOL
PutAwayMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3848 if (NULL
== in
&& 0 == IconActive
)
3850 if (iwt
->iwt_ReadOnly
)
3852 if (WSV_Type_DeviceWindow
!= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_WindowType
)
3853 return FALSE
; // "put away" only allowed from desktop window
3860 //---------------------------------------------------------------------------------------
3862 static BOOL
PasteMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3864 BOOL ClipboardEmpty
;
3866 d1(KPrintF("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
3868 if (iwt
->iwt_ReadOnly
)
3871 d1(KPrintF("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
3873 ScalosObtainSemaphoreShared(&ClipboardSemaphore
);
3874 ClipboardEmpty
= IsListEmpty(&globalCopyClipBoard
);
3875 ScalosReleaseSemaphore(&ClipboardSemaphore
);
3879 d1(KPrintF("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
3881 if (iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
)
3884 d1(KPrintF("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
3886 // Desktop window, left-out icon
3887 if (in
&& in
->in_Lock
)
3890 // Desktop window, device icon
3891 if (in
&& in
->in_DeviceIcon
)
3894 d1(KPrintF("%s/%s/%ld: in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
3899 //---------------------------------------------------------------------------------------
3901 static BOOL
UndoMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3905 ScalosObtainSemaphoreShared(&UndoListListSemaphore
);
3906 UndoListEmpty
= IsListEmpty(&globalUndoList
);
3907 ScalosReleaseSemaphore(&UndoListListSemaphore
);
3914 //---------------------------------------------------------------------------------------
3916 static BOOL
RedoMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3920 ScalosObtainSemaphoreShared(&RedoListListSemaphore
);
3921 RedoListEmpty
= IsListEmpty(&globalRedoList
);
3922 ScalosReleaseSemaphore(&RedoListListSemaphore
);
3929 //---------------------------------------------------------------------------------------
3931 static BOOL
NotMainWindowAndNotReadingMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3933 if (WSV_Type_DeviceWindow
== iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_WindowType
)
3935 if (iwt
->iwt_Reading
)
3941 //---------------------------------------------------------------------------------------
3943 static BOOL
SnapshotMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3945 if (!IsIwtViewByIcon(iwt
))
3947 if (NULL
== in
&& 0 == IconActive
)
3949 if (iwt
->iwt_ReadOnly
)
3955 //---------------------------------------------------------------------------------------
3957 static BOOL
NotReadingMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3961 if (iwt
->iwt_Reading
)
3967 //---------------------------------------------------------------------------------------
3969 static BOOL
IsWriteableMenuEnable(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
)
3971 if (iwt
->iwt_ReadOnly
)
3973 if (in
&& (in
->in_Flags
& INF_VolumeWriteProtected
))
3979 //----------------------------------------------------------------------------
3981 static SAVEDS(ULONG
) AsyncStartModule(APTR aptr
, struct SM_RunProcess
*msg
, CONST_STRPTR ModuleName
)
3983 struct WBArg
*arg
= aptr
;
3985 BPTR oldDir
= NOT_A_LOCK
;
3986 BPTR infoModLock
= (BPTR
)NULL
;
3989 debugLock_d1(arg
->wa_Lock
);
3990 d1(kprintf("%s/%s/%ld: START arg->wa_Name=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, arg
->wa_Name
, arg
->wa_Name
? arg
->wa_Name
: ""));
3993 ModsDirLock
= LockScaModsDir();
3995 d1(kprintf("%s/%s/%ld: arg->wa_Name=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, arg
->wa_Name
, arg
->wa_Name
? arg
->wa_Name
: ""));
3996 debugLock_d1(ModsDirLock
);
3997 if ((BPTR
)NULL
== ModsDirLock
)
4000 oldDir
= CurrentDir(ModsDirLock
);
4001 infoModLock
= Lock((STRPTR
) ModuleName
, ACCESS_READ
);
4003 d1(kprintf("%s/%s/%ld: arg->wa_Name=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, arg
->wa_Name
, arg
->wa_Name
? arg
->wa_Name
: ""));
4004 debugLock_d1(infoModLock
);
4007 struct WBArg argArray
[2];
4009 argArray
[0].wa_Name
= (STRPTR
) ModuleName
;
4010 argArray
[0].wa_Lock
= ModsDirLock
;
4013 if (SCA_WBStartTags(argArray
, 2,
4014 SCA_Stacksize
, CurrentPrefs
.pref_DefaultStackSize
,
4017 d1(kprintf("%s/%s/%ld: SCA_WBStartTags Ok\n", __FILE__
, __FUNC__
, __LINE__
));
4019 arg
->wa_Lock
= (BPTR
)NULL
;
4020 ModsDirLock
= (BPTR
)NULL
; // will be UnLock()ed
4027 d1(kprintf("%s/%s/%ld: arg->wa_Name=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, arg
->wa_Name
, arg
->wa_Name
? arg
->wa_Name
: ""));
4030 WBInfo(arg
->wa_Lock
, arg
->wa_Name
, iInfos
.xii_iinfos
.ii_Screen
);
4032 if (IS_VALID_LOCK(oldDir
))
4035 UnLock(ModsDirLock
);
4037 UnLock(infoModLock
);
4039 UnLock(arg
->wa_Lock
);
4041 FreeCopyString(arg
->wa_Name
);
4043 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
4048 //---------------------------------------------------------------------------------------
4049 //------- CopyTo: MakeCloneArgs/CopyToCloneInfoStart/CopyToCloneWBArg -------------------
4051 static void CopyToMakeCloneArgs(struct internalScaWindowTask
*iwt
,
4052 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
)
4054 struct ScaWindowStruct
*ws
;
4056 SCA_LockWindowList(SCA_LockWindowList_Shared
);
4058 CopyToCloneInfoStart(iwt
, wbArg
, ArgCount
, MaxArgs
);
4060 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
4062 if (ws
!= iwt
->iwt_WindowTask
.mt_WindowStruct
)
4063 CopyToCloneInfoStart((struct internalScaWindowTask
*) ws
->ws_WindowTask
, wbArg
, ArgCount
, MaxArgs
);
4066 SCA_UnLockWindowList();
4069 //---------------------------------------------------------------------------------------
4071 static void CopyToCloneInfoStart(struct internalScaWindowTask
*iwt
,
4072 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
)
4074 struct ScaIconNode
*in
;
4076 if ((*ArgCount
) < MaxArgs
)
4078 ScalosLockIconListShared(iwt
);
4080 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
4082 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
4084 if (gg
->Flags
& GFLG_SELECTED
)
4088 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
4092 case WB_TEXTICON_TOOL
:
4093 case WB_TEXTICON_DRAWER
:
4099 d1(kprintf("%s/%s/%ld: icon=<%s> NumArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, GetIconName(in
), *ArgCount
));
4100 CopyToCloneWBArg(iwt
, wbArg
, in
, ArgCount
, MaxArgs
);
4108 ScalosUnLockIconList(iwt
);
4112 //---------------------------------------------------------------------------------------
4114 static BOOL
CopyToCloneWBArg(struct internalScaWindowTask
*iwt
, struct WBArg
**wbArg
,
4115 struct ScaIconNode
*in
, ULONG
*ArgCount
, ULONG MaxArgs
)
4117 CONST_STRPTR newName
;
4119 BPTR NLock
= (BPTR
)NULL
;
4121 if ((*ArgCount
) < MaxArgs
)
4123 if (NULL
== in
->in_Name
)
4126 (*wbArg
)->wa_Name
= AllocCopyString(GetIconName(in
));
4127 len
= strlen((*wbArg
)->wa_Name
);
4128 newName
= (*wbArg
)->wa_Name
;
4130 if (':' == newName
[len
- 1])
4132 NLock
= Lock((*wbArg
)->wa_Name
, SHARED_LOCK
);
4133 (*wbArg
)->wa_Lock
= DupLock(NLock
);
4139 (*wbArg
)->wa_Lock
= DupLock(in
->in_Lock
);
4140 d1(kprintf("%s/%s/%ld: (*wbArg)->wa_Lock = <%s>\n", __FILE__
, __FUNC__
, __LINE__
, TestLock
));
4144 if (iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
)
4145 (*wbArg
)->wa_Lock
= DupLock(iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
);
4147 (*wbArg
)->wa_Lock
= (BPTR
)NULL
;
4151 // (*wbArg)->wa_Name = AllocCopyString(GetIconName(in));
4153 d1(kprintf("%s/%s/%ld: (*wbArg)->wa_Name = <%s>\n", __FILE__
, __FUNC__
, __LINE__
, (*wbArg
)->wa_Name
));
4155 if (NULL
== (*wbArg
)->wa_Name
)
4157 if ((*wbArg
)->wa_Lock
)
4158 UnLock((*wbArg
)->wa_Lock
);
4175 //---------------------------------------------------------------------------------------
4177 static void CopyToProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
4179 struct WBArg
*wbArg
, *wbArgAlloc
;
4183 struct CloneArg processArgs
;
4184 ULONG NumberOfWbArgs
= 1;
4186 if (mcArg
->mca_IconNode
)
4187 NumberOfWbArgs
+= 1;
4189 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
4191 wbArg
= wbArgAlloc
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
4192 if (NULL
== wbArgAlloc
)
4195 if (mcArg
->mca_IconNode
)
4199 GetAttr(IDTA_Type
, mcArg
->mca_IconNode
->in_Icon
, &IconType
);
4201 d1(kprintf("%s/%s/%ld: IconType = [%08lx] Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, IconType
, mcArg
->mca_IconNode
->in_Name
));
4203 if (WBKICK
== IconType
)
4205 d1(kprintf("%s/%s/%ld: IconType WBKICK = %08lx\n", __FILE__
, __FUNC__
, __LINE__
, IconType
));
4209 if (!CopyToCloneWBArg(iwt
, &wbArg
, mcArg
->mca_IconNode
, &ArgCount
, NumberOfWbArgs
))
4214 d1(kprintf("%s/%s/%ld: CopyToCloneWBArg() ArgCount=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ArgCount
));
4218 CopyToMakeCloneArgs(iwt
, &wbArg
, &ArgCount
, NumberOfWbArgs
);
4220 d1(kprintf("%s/%s/%ld: CopyToMakeCloneArgs() iwt=[%08lx] &ArgCount=[%ld])\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, ArgCount
));
4223 processArgs
.cla_wbArg
= wbArgAlloc
;
4224 processArgs
.cla_NumArgs
= ArgCount
;
4226 RunProcess(&iwt
->iwt_WindowTask
, CopyToStart
,
4227 sizeof(processArgs
)/sizeof(ULONG
), (struct WBArg
*)(APTR
) &processArgs
, NULL
);
4229 // wbArgAlloc will be freed inside <CopyToStart>
4237 SCA_FreeWBArgs(wbArgAlloc
, ArgCount
, SCAF_FreeNames
| SCAF_FreeLocks
);
4239 ScalosFree(wbArgAlloc
);
4243 //---------------------------------------------------------------------------------------
4245 static SAVEDS(ULONG
) CopyToStart(APTR aptr
, struct SM_RunProcess
*msg
)
4247 struct CloneArg
*arg
= aptr
;
4248 Object
*fileTransObj
= NULL
;
4250 BPTR dirLock
= (BPTR
)NULL
;
4251 APTR undoStep
= NULL
;
4252 struct FileRequester
*dirReq
;
4259 NameFromLock(arg
->cla_wbArg
[0].wa_Lock
, Path
, sizeof(Path
));
4261 d1(kprintf("%s/%s/%ld: arg->cla_wbArg[0].wa_Lock=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, Path
));
4263 // AllocAslRequest()
4264 dirReq
= AllocAslRequestTags(ASL_FileRequest
,
4265 ASLFR_PrivateIDCMP
, TRUE
,
4266 ASLFR_Screen
, (IPTR
) iInfos
.xii_iinfos
.ii_Screen
,
4267 ASLFR_TitleText
, (IPTR
) GetLocString(MSGID_COPYTO_ASLTITLE
),
4268 ASLFR_DoSaveMode
, TRUE
,
4269 ASLFR_DrawersOnly
, TRUE
,
4276 Success
= AslRequestTags(dirReq
,
4277 ASLFR_InitialDrawer
, (IPTR
) Path
,
4282 CONST_STRPTR destName
;
4283 STRPTR destNameCopy
= NULL
;
4285 char NLockName
[512];
4286 char LockdirName
[256];
4287 char TestRootName
[256];
4290 undoStep
= UndoBeginStep();
4292 dirLock
= Lock(dirReq
->fr_Drawer
, ACCESS_READ
);
4293 if ((BPTR
)NULL
== dirLock
)
4296 stccpy(LockdirName
, dirReq
->fr_Drawer
, sizeof(LockdirName
));
4298 fileTransObj
= SCA_NewScalosObjectTags((STRPTR
) "FileTransfer.sca",
4299 SCCA_FileTrans_Screen
, (IPTR
) iInfos
.xii_iinfos
.ii_Screen
,
4300 SCCA_FileTrans_Number
, arg
->cla_NumArgs
,
4301 SCCA_FileTrans_ReplaceMode
, SCCV_ReplaceMode_Ask
,
4304 if (NULL
== fileTransObj
)
4307 d1(kprintf("%s/%s/%ld: NumArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, arg
->cla_NumArgs
));
4309 for (n
=0; n
< arg
->cla_NumArgs
; n
++)
4313 debugLock_d1(arg
->cla_wbArg
[n
].wa_Lock
);
4315 NameFromLock(arg
->cla_wbArg
[n
].wa_Lock
, NLockName
, sizeof(NLockName
));
4317 if (arg
->cla_wbArg
[n
].wa_Name
&& strlen(arg
->cla_wbArg
[n
].wa_Name
) > 0)
4318 AddPart(NLockName
, arg
->cla_wbArg
[n
].wa_Name
, sizeof(NLockName
));
4320 if (LOCK_SAME
== ScaSameLock(dirLock
, arg
->cla_wbArg
[n
].wa_Lock
)) // Can't copy a object to itself!
4324 d1(kprintf("%s/%s/%ld: ERROR SAME LOCK!: ErrorFound=[%ld] Source Lock=<%s> Destination Lock=<%s>\n", \
4325 __FILE__
, __FUNC__
, __LINE__
, ErrorFound
, NLockName
, dirReq
->fr_Drawer
));
4330 stccpy(TestRootName
, LockdirName
, strlen(NLockName
) + 1); // Check if destination with a max string lenght
4331 if (0 == Stricmp(TestRootName
, NLockName
)) // from source's string lenght = source.
4335 d1(kprintf("%s/%s/%ld: SAME! : ErrorFound=[%ld] NLockName=<%s> TestRootname=<%s>\n", \
4336 __FILE__
, __FUNC__
, __LINE__
, ErrorFound
, NLockName
, TestRootName
));
4342 len
= strlen(arg
->cla_wbArg
[n
].wa_Name
);
4343 destName
= arg
->cla_wbArg
[n
].wa_Name
;
4346 d1(kprintf("%s/%s/%ld: Copy NLockName=<%s> to Destination=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, NLockName
, LockdirName
));
4348 if (':' == destName
[len
- 1])
4350 // Replace trailing ":" by "/" for copying volumes/disks to directories
4351 destNameCopy
= AllocCopyString(destName
);
4354 arg
->cla_wbArg
[n
].wa_Name
[0] = '\0';
4355 destName
= destNameCopy
;
4356 StripTrailingColon(destNameCopy
);
4357 d1(kprintf("%s/%s/%ld: destName=<%s> destNameCopy=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, destName
, destNameCopy
));
4361 UndoAddEvent((struct internalScaWindowTask
*) msg
->WindowTask
, UNDO_Copy
,
4362 UNDOTAG_UndoMultiStep
, undoStep
,
4363 UNDOTAG_CopySrcDirLock
, arg
->cla_wbArg
[n
].wa_Lock
,
4364 UNDOTAG_CopyDestDirLock
, dirLock
,
4365 UNDOTAG_CopySrcName
, arg
->cla_wbArg
[n
].wa_Name
,
4366 UNDOTAG_CopyDestName
, destName
,
4369 DoMethod(fileTransObj
, SCCM_FileTrans_Copy
,
4370 arg
->cla_wbArg
[n
].wa_Lock
, dirLock
,
4371 arg
->cla_wbArg
[n
].wa_Name
,
4373 NO_ICON_POSITION_SHORT
, NO_ICON_POSITION_SHORT
);
4378 FreeCopyString(destNameCopy
);
4382 UndoEndStep((struct internalScaWindowTask
*) msg
->WindowTask
, undoStep
);
4384 SCA_FreeWBArgs(arg
->cla_wbArg
, arg
->cla_NumArgs
, SCAF_FreeNames
| SCAF_FreeLocks
);
4385 ScalosFree(arg
->cla_wbArg
);
4388 SCA_DisposeScalosObject(fileTransObj
);
4394 FreeAslRequest(dirReq
);
4399 //---------------------------------------------------------------------------------------
4400 //------- MoveTo: MoveToMakeCloneArgs/MoveToCloneInfoStart ------------------------------
4401 //---------------------------------------------------------------------------------------
4403 static void MoveToMakeCloneArgs(struct internalScaWindowTask
*iwt
,
4404 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
)
4406 struct ScaWindowStruct
*ws
;
4408 SCA_LockWindowList(SCA_LockWindowList_Shared
);
4410 MoveToCloneInfoStart(iwt
, wbArg
, ArgCount
, MaxArgs
);
4412 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
4414 if (ws
!= iwt
->iwt_WindowTask
.mt_WindowStruct
)
4415 MoveToCloneInfoStart((struct internalScaWindowTask
*) ws
->ws_WindowTask
, wbArg
, ArgCount
, MaxArgs
);
4417 SCA_UnLockWindowList();
4420 //---------------------------------------------------------------------------------------
4422 static void MoveToCloneInfoStart(struct internalScaWindowTask
*iwt
,
4423 struct WBArg
**wbArg
, ULONG
*ArgCount
, ULONG MaxArgs
)
4425 struct ScaIconNode
*in
;
4427 if ((*ArgCount
) <= MaxArgs
)
4429 ScalosLockIconListShared(iwt
);
4431 d1(KPrintF("%s/%s/%ld: ScalosLockIconListShared(iwt)\n", __FILE__
, __FUNC__
, __LINE__
));
4433 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
4435 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
4437 if (gg
->Flags
& GFLG_SELECTED
)
4441 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
4448 d1(kprintf("%s/%s/%ld: icon=<%s> NumArgs=[%ld] IconType=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, GetIconName(in
), *ArgCount
, IconType
));
4452 UseRequestArgs(NULL
, MSGID_MOVETO_DEVICE
, MSGID_OKNAME
, 1, GetIconName(in
));
4454 ClassSelectIcon(iwt
->iwt_WindowTask
.mt_WindowStruct
, in
, FALSE
); // UnSelect drive icon.
4456 CopyToCloneWBArg(iwt
, wbArg
, in
, ArgCount
, MaxArgs
);
4457 //CloneWBArg(iwt, wbArg, in, ArgCount);
4459 case WB_TEXTICON_TOOL
:
4460 case WB_TEXTICON_DRAWER
:
4465 d1(kprintf("%s/%s/%ld: icon=<%s> NumArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, GetIconName(in
), *ArgCount
));
4466 //CloneWBArg(iwt, wbArg, in, ArgCount);
4467 CopyToCloneWBArg(iwt
, wbArg
, in
, ArgCount
, MaxArgs
);
4476 ScalosUnLockIconList(iwt
);
4480 //---------------------------------------------------------------------------------------
4482 static void MoveToProg(struct internalScaWindowTask
*iwt
, const struct MenuCmdArg
*mcArg
)
4484 struct WBArg
*wbArg
, *wbArgAlloc
;
4488 struct CloneArg processArgs
;
4489 ULONG NumberOfWbArgs
= 1;
4491 if (mcArg
->mca_IconNode
)
4492 NumberOfWbArgs
+= 1;
4494 NumberOfWbArgs
+= SCA_CountWBArgs(mcArg
->mca_IconNode
);
4496 wbArg
= wbArgAlloc
= ScalosAlloc(NumberOfWbArgs
* sizeof(struct WBArg
));
4497 if (NULL
== wbArgAlloc
)
4500 if (mcArg
->mca_IconNode
)
4504 GetAttr(IDTA_Type
, mcArg
->mca_IconNode
->in_Icon
, &IconType
);
4506 if (WBDISK
== IconType
||
4507 WBDEVICE
== IconType
||
4514 if (!CopyToCloneWBArg(iwt
, &wbArg
, mcArg
->mca_IconNode
, &ArgCount
, NumberOfWbArgs
))
4519 d1(kprintf("%s/%s/%ld: [a] ArgCount=[%ld]\n", __FILE__
, __FUNC__
, __LINE__
, ArgCount
));
4523 MoveToMakeCloneArgs(iwt
, &wbArg
, &ArgCount
, NumberOfWbArgs
);
4526 d1(KPrintF("%s/%s/%ld: [b] ArgCount=[%ld] iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ArgCount
, iwt
));
4528 processArgs
.cla_wbArg
= wbArgAlloc
;
4529 processArgs
.cla_NumArgs
= ArgCount
;
4531 RunProcess(&iwt
->iwt_WindowTask
, MoveToStart
,
4532 sizeof(processArgs
)/sizeof(ULONG
), (struct WBArg
*)(APTR
) &processArgs
, NULL
);
4534 // wbArgAlloc will be freed inside <MoveToStart>
4542 SCA_FreeWBArgs(wbArgAlloc
, ArgCount
, SCAF_FreeNames
| SCAF_FreeLocks
);
4544 ScalosFree(wbArgAlloc
);
4548 //---------------------------------------------------------------------------------------
4550 static SAVEDS(ULONG
) MoveToStart(APTR aptr
, struct SM_RunProcess
*msg
)
4552 struct CloneArg
*arg
= aptr
;
4553 Object
*fileTransObj
= NULL
;
4555 BPTR dirLock
= (BPTR
)NULL
;
4556 APTR undoStep
= NULL
;
4557 struct FileRequester
*dirReq
;
4560 d1(kprintf("%s/%s/%ld: START NumArgs=[%ld]\n", __FILE__
, __FUNC__
, __LINE__
, arg
->cla_NumArgs
));
4567 // AllocAslRequest()
4568 dirReq
= AllocAslRequestTags(ASL_FileRequest
,
4569 ASLFR_PrivateIDCMP
, TRUE
,
4570 ASLFR_Screen
, (IPTR
) iInfos
.xii_iinfos
.ii_Screen
,
4571 ASLFR_TitleText
, (IPTR
) GetLocString(MSGID_MOVETO_ASLTITLE
),
4572 ASLFR_DoSaveMode
, TRUE
,
4573 ASLFR_DrawersOnly
, TRUE
,
4579 for (n
=0; n
< arg
->cla_NumArgs
; n
++)
4582 if (':' == arg
->cla_wbArg
[n
].wa_Name
[strlen(arg
->cla_wbArg
[n
].wa_Name
) - 1]) // Check number of drives if selected from workbench
4583 np
--; // Decrease "np" variable if a drive is found.
4586 if ((BPTR
)NULL
!= arg
->cla_wbArg
[n
].wa_Lock
) // If object isn't a drive, select last valid path found
4587 NameFromLock(arg
->cla_wbArg
[n
].wa_Lock
, Path
, sizeof(Path
)); // for "ASLFR_InitialDrawer" field.
4590 d1(kprintf("%s/%s/%ld: CHECKING ARGS: n=[%ld] np=[%ld] NumArgs=[%ld] Path=<%s> arg->cla_wbArg[%ld]=<%s>\n", \
4591 __FILE__
, __FUNC__
, __LINE__
, n
, np
, arg
->cla_NumArgs
, Path
, n
, arg
->cla_wbArg
[n
].wa_Name
));
4594 d1(kprintf("%s/%s/%ld: END np=[%ld] NumArgs=[%ld]\n", __FILE__
, __FUNC__
, __LINE__
, np
, arg
->cla_NumArgs
));
4596 if (0 == np
) // if "np= 0" all objects found are drives,
4597 { // so abort MoveTo function.
4598 d1(kprintf("%s/%s/%ld: np=[%ld] NumArgs=[%ld]\n", \
4599 __FILE__
, __FUNC__
, __LINE__
, np
, arg
->cla_NumArgs
));
4604 Success
= AslRequestTags(dirReq
,
4605 ASLFR_InitialDrawer
, (IPTR
) Path
,
4610 char NLockName
[512];
4611 char ProgramIcon
[512];
4612 char LockdirName
[256];
4613 char TestRootName
[256];
4614 CONST_STRPTR SrcName
;
4618 undoStep
= UndoBeginStep();
4620 dirLock
= Lock(dirReq
->fr_Drawer
, ACCESS_READ
);
4621 if ((BPTR
)NULL
== dirLock
)
4624 stccpy(LockdirName
, dirReq
->fr_Drawer
, sizeof(LockdirName
));
4626 fileTransObj
= SCA_NewScalosObjectTags((STRPTR
) "FileTransfer.sca",
4627 SCCA_FileTrans_Screen
, (IPTR
) iInfos
.xii_iinfos
.ii_Screen
,
4628 SCCA_FileTrans_Number
, arg
->cla_NumArgs
,
4629 SCCA_FileTrans_ReplaceMode
, SCCV_ReplaceMode_Ask
,
4632 if (NULL
== fileTransObj
)
4635 d1(kprintf("%s/%s/%ld: NumArgs=%ld\n", __FILE__
, __FUNC__
, __LINE__
, arg
->cla_NumArgs
));
4637 for (n
=0; n
<arg
->cla_NumArgs
; n
++)
4641 debugLock_d1(arg
->cla_wbArg
[n
].wa_Lock
);
4643 len
= strlen(arg
->cla_wbArg
[n
].wa_Name
);
4644 SrcName
= arg
->cla_wbArg
[n
].wa_Name
;
4646 NameFromLock(arg
->cla_wbArg
[n
].wa_Lock
, NLockName
, sizeof(NLockName
));
4648 if (SrcName
&& len
> 0)
4649 AddPart(NLockName
, SrcName
, sizeof(NLockName
));
4651 if (LOCK_SAME
== ScaSameLock(dirLock
, arg
->cla_wbArg
[n
].wa_Lock
)) // Can't copy a object to itself!
4655 d1(kprintf("%s/%s/%ld: ERROR SAME LOCK!: ErrorFound=[%ld] Source Lock=<%s> Destination Lock=<%s>\n", \
4656 __FILE__
, __FUNC__
, __LINE__
, ErrorFound
, NLockName
, dirReq
->fr_Drawer
));
4661 stccpy(TestRootName
, LockdirName
, strlen(NLockName
) + 1); // Check if destination with a max string lenght
4662 if (0 == Stricmp(TestRootName
, NLockName
)) // from source's string lenght = source.
4666 d1(kprintf("%s/%s/%ld: SAME! : ErrorFound=[%ld] NLockName=<%s> TestRootname=<%s>\n", \
4667 __FILE__
, __FUNC__
, __LINE__
, ErrorFound
, NLockName
, TestRootName
));
4673 if (':' == SrcName
[len
- 1]) // Skip all drives found, from wb arg.
4681 d1(kprintf("%s/%s/%ld: NUMBER=[%ld] ErrorFound=[%ld] [Move <%s> - Full path = <%s>] To =<%s>\n", \
4682 __FILE__
, __FUNC__
, __LINE__
, n
, ErrorFound
, SrcName
, NLockName
, LockdirName
));
4684 UndoAddEvent((struct internalScaWindowTask
*) msg
->WindowTask
, UNDO_Move
,
4685 UNDOTAG_UndoMultiStep
, undoStep
,
4686 UNDOTAG_CopySrcDirLock
, arg
->cla_wbArg
[n
].wa_Lock
,
4687 UNDOTAG_CopyDestDirLock
, dirLock
,
4688 UNDOTAG_CopySrcName
, SrcName
,
4691 DoMethod(fileTransObj
, SCCM_FileTrans_Move
,
4692 arg
->cla_wbArg
[n
].wa_Lock
, dirLock
,
4694 NO_ICON_POSITION_SHORT
, NO_ICON_POSITION_SHORT
);
4696 snprintf(ProgramIcon
, sizeof(ProgramIcon
), "%s.info", SrcName
);
4698 if ((IconLock
= Lock(ProgramIcon
, SHARED_LOCK
)))
4702 d1(kprintf("%s/%s/%ld: FOUND ICON HERE!!!: [Move Icon <%s>] To =<%s>\n", \
4703 __FILE__
, __FUNC__
, __LINE__
, ProgramIcon
, LockdirName
));
4705 UndoAddEvent((struct internalScaWindowTask
*) msg
->WindowTask
, UNDO_Move
,
4706 UNDOTAG_UndoMultiStep
, undoStep
,
4707 UNDOTAG_CopySrcDirLock
, arg
->cla_wbArg
[n
].wa_Lock
,
4708 UNDOTAG_CopyDestDirLock
, dirLock
,
4709 UNDOTAG_CopySrcName
, ProgramIcon
,
4712 DoMethod(fileTransObj
, SCCM_FileTrans_Move
,
4713 arg
->cla_wbArg
[n
].wa_Lock
, dirLock
,
4715 NO_ICON_POSITION_SHORT
, NO_ICON_POSITION_SHORT
);
4723 UndoEndStep((struct internalScaWindowTask
*) msg
->WindowTask
, undoStep
);
4725 SCA_FreeWBArgs(arg
->cla_wbArg
, arg
->cla_NumArgs
, SCAF_FreeNames
| SCAF_FreeLocks
);
4726 ScalosFree(arg
->cla_wbArg
);
4729 SCA_DisposeScalosObject(fileTransObj
);
4735 FreeAslRequest(dirReq
);
4740 //----------------------------------------------------------------------------
4742 static void CreateThumbnailStart(struct internalScaWindowTask
*iwt
, struct ScaIconNode
*in
, APTR undoStep
)
4745 Object
*OrigIconObj
;
4747 d1(KPrintF("%s/%s/%ld: START iwt=%08lx in=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, in
, GetIconName(in
)));
4750 IconDirLock
= in
->in_Lock
;
4752 IconDirLock
= iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_Lock
;
4754 OrigIconObj
= CloneIconObject(in
->in_Icon
);
4756 if (AddThumbnailIcon(iwt
, in
->in_Icon
,
4759 THUMBNAILICONF_SAVEICON
| THUMBNAILICONF_NOICONPOSITION
,
4762 d1(KPrintF("%s/%s/%ld: AddThumbnailIcon succeeded\n", __FILE__
, __FUNC__
, __LINE__
));
4764 UnsnapshotIcon(iwt
, in
, FALSE
, undoStep
);
4766 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
4768 DoMethod(in
->in_Icon
, IDTM_FreeLayout
, IOFREELAYOUTF_ScreenAvailable
);
4769 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_LayoutIcon
,
4770 in
->in_Icon
, IOLAYOUTF_NormalImage
);
4772 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
4774 AfterUnsnapshotIcon(iwt
);
4776 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
4778 // Start thumbnail generation process
4779 GenerateThumbnails(iwt
);
4783 DisposeIconObject(OrigIconObj
);
4785 d1(KPrintF("%s/%s/%ld: END iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
));
4788 //---------------------------------------------------------------------------------------
4790 static void DoForAppIcons(ULONG AppMsgClass
)
4792 struct ScaWindowStruct
*ws
;
4794 SCA_LockWindowList(SCA_LockWindowList_Shared
);
4796 for (ws
=winlist
.wl_WindowStruct
; ws
; ws
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
)
4798 if (!(ws
->ws_Flags
& WSV_FlagF_TaskSleeps
)
4800 && (0 == ws
->ws_Lock
) )
4802 struct internalScaWindowTask
*iwt
= (struct internalScaWindowTask
*) ws
->ws_WindowTask
;
4803 struct ScaIconNode
*in
;
4805 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WinTitle
));
4807 ScalosLockIconListShared(iwt
);
4809 for (in
=iwt
->iwt_WindowTask
.wt_IconList
; in
; in
= (struct ScaIconNode
*) in
->in_Node
.mln_Succ
)
4811 struct ExtGadget
*gg
= (struct ExtGadget
*) in
->in_Icon
;
4813 if (gg
->Flags
& GFLG_SELECTED
)
4817 GetAttr(IDTA_Type
, in
->in_Icon
, &IconType
);
4819 if (WBAPPICON
== IconType
)
4821 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, in
, GetIconName(in
)));
4822 WindowSendAppIconMsg(iwt
, AppMsgClass
, in
);
4827 ScalosUnLockIconList(iwt
);
4833 SCA_UnLockWindowList();
4836 //---------------------------------------------------------------------------------------