2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
9 #include <aros/debug.h>
11 #include <exec/types.h>
12 #include <exec/memory.h>
13 #include <intuition/classes.h>
14 #include <intuition/classusr.h>
15 #include <libraries/mui.h>
16 #include <workbench/workbench.h>
18 #include <proto/dos.h>
19 #include <proto/desktop.h>
20 #include <proto/intuition.h>
21 #include <proto/utility.h>
25 #include "desktop_intern.h"
26 #include "iconcontainerobserver.h"
27 #include "presentation.h"
28 #include "iconcontainerclass.h"
29 #include "iconobserver.h"
31 #include "iconclass.h"
33 #include "desktop_intern_protos.h"
35 IPTR
iconConObsNew(Class
* cl
, Object
* obj
, struct opSet
* msg
)
38 struct IconContainerObserverClassData
*data
;
40 *tstate
= msg
->ops_AttrList
;
41 UBYTE
*directory
= NULL
;
43 while ((tag
= NextTagItem(&tstate
)) != NULL
)
48 directory
= (UBYTE
*) tag
->ti_Data
;
52 continue; /* Don't supress non-processed tags */
55 tag
->ti_Tag
= TAG_IGNORE
;
58 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
61 obj
= (Object
*) retval
;
62 data
= INST_DATA(cl
, obj
);
63 data
->directory
= directory
;
64 // this is unlocked by the scanner worker
65 data
->dirLock
= Lock(directory
, ACCESS_READ
);
71 IPTR
iconConObsSet(Class
* cl
, Object
* obj
, struct opSet
* msg
)
73 struct IconContainerObserverClassData
*data
;
76 *tstate
= msg
->ops_AttrList
;
78 data
= (struct IconContainerObserverClassData
*) INST_DATA(cl
, obj
);
80 while ((tag
= NextTagItem(&tstate
)))
85 data
->directory
= (UBYTE
*) tag
->ti_Data
;
89 struct HandlerScanRequest
*hsr
;
92 createScanMessage(DIMC_SCANDIRECTORY
, NULL
,
94 _app(_presentation(obj
)));
95 PutMsg(DesktopBase
->db_HandlerPort
,
96 (struct Message
*) hsr
);
98 DoMethod(_presentation(obj
), MUIM_KillNotify
, PA_InTree
);
107 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
112 IPTR
iconConObsGet(Class
* cl
, Object
* obj
, struct opGet
* msg
)
115 struct IconContainerObserverClassData
*data
;
117 data
= (struct IconContainerObserverClassData
*) INST_DATA(cl
, obj
);
119 switch (msg
->opg_AttrID
)
122 *msg
->opg_Storage
= (ULONG
) data
->directory
;
125 retval
= DoSuperMethodA(cl
, obj
, (Msg
) msg
);
132 IPTR
iconConObsDispose(Class
* cl
, Object
* obj
, Msg msg
)
135 struct IconContainerObserverClassData
*data
;
137 data
= (struct IconContainerObserverClassData
*) INST_DATA(cl
, obj
);
138 UnLock(data
->dirLock
);
139 retval
= DoSuperMethodA(cl
, obj
, msg
);
144 IPTR
iconConObsAddIcons(Class
* cl
, Object
* obj
, struct icoAddIcon
* msg
)
150 struct IconContainerObserverClassData
*data
;
151 Object
*desktop
= NULL
;
153 data
= (struct IconContainerObserverClassData
*) INST_DATA(cl
, obj
);
155 GetAttr(AICA_Desktop
, _presentation(obj
), (IPTR
*) &desktop
);
157 for (i
= 0; i
< msg
->wsr_Results
; i
++)
159 switch (msg
->wsr_ResultsArray
[i
].sr_DiskObject
->do_Type
)
166 kind
= CDO_DrawerIcon
;
174 kind
= CDO_ProjectIcon
;
178 kind
= CDO_TrashcanIcon
;
185 continue; /* skip unknown disk object types */
188 newIcon
= CreateDesktopObject
192 IOA_Name
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Name
,
193 IOA_Directory
, (IPTR
) data
->directory
,
194 IOA_Comment
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Comment
,
195 IOA_Script
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Script
,
196 IOA_Pure
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Pure
,
197 IOA_Readable
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Read
,
198 IOA_Writeable
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Write
,
199 IOA_Archived
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Archive
,
200 IOA_Executable
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Execute
,
201 IOA_Deleteable
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Delete
,
202 IA_DiskObject
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_DiskObject
,
203 IA_Label
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Name
,
204 IA_Size
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Size
,
205 IA_LastModified
, (IPTR
) &msg
->wsr_ResultsArray
[i
].sr_LastModified
,
206 IA_Type
, (IPTR
) msg
->wsr_ResultsArray
[i
].sr_Type
,
207 IA_Desktop
, (IPTR
) desktop
,
208 MUIA_Draggable
, TRUE
,
213 DoMethod(_presentation(obj
), OM_ADDMEMBER
, (IPTR
) newIcon
);
216 FreeVec(msg
->wsr_ResultsArray
);
222 BOOPSI_DISPATCHER(IPTR
, iconContainerObserverDispatcher
, cl
, obj
, msg
)
226 switch (msg
->MethodID
)
229 retval
= iconConObsNew(cl
, obj
, (struct opSet
*) msg
);
232 retval
= iconConObsSet(cl
, obj
, (struct opSet
*) msg
);
235 retval
= iconConObsGet(cl
, obj
, (struct opGet
*) msg
);
238 retval
= iconConObsDispose(cl
, obj
, msg
);
241 retval
= iconConObsAddIcons(cl
, obj
, (struct icoAddIcon
*) msg
);
244 retval
= DoSuperMethodA(cl
, obj
, msg
);
250 BOOPSI_DISPATCHER_END