more rendering corrections
[AROS.git] / workbench / libs / desktop / iconcontainerobserver.c
blob27c33bc89d50094cb57ba8afab1be321d6ebad82
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define MUIMASTER_YES_INLINE_STDARG
8 #define DEBUG 1
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>
23 #include "support.h"
24 #include "worker.h"
25 #include "desktop_intern.h"
26 #include "iconcontainerobserver.h"
27 #include "presentation.h"
28 #include "iconcontainerclass.h"
29 #include "iconobserver.h"
30 #include "observer.h"
31 #include "iconclass.h"
33 #include "desktop_intern_protos.h"
35 IPTR iconConObsNew(Class * cl, Object * obj, struct opSet * msg)
37 IPTR retval = 0;
38 struct IconContainerObserverClassData *data;
39 struct TagItem *tag,
40 *tstate = msg->ops_AttrList;
41 UBYTE *directory = NULL;
43 while ((tag = NextTagItem(&tstate)) != NULL)
45 switch (tag->ti_Tag)
47 case ICOA_Directory:
48 directory = (UBYTE *) tag->ti_Data;
49 break;
51 default:
52 continue; /* Don't supress non-processed tags */
55 tag->ti_Tag = TAG_IGNORE;
58 retval = DoSuperMethodA(cl, obj, (Msg) msg);
59 if (retval)
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);
68 return retval;
71 IPTR iconConObsSet(Class * cl, Object * obj, struct opSet * msg)
73 struct IconContainerObserverClassData *data;
74 IPTR retval = 1;
75 struct TagItem *tag,
76 *tstate = msg->ops_AttrList;
78 data = (struct IconContainerObserverClassData *) INST_DATA(cl, obj);
80 while ((tag = NextTagItem(&tstate)))
82 switch (tag->ti_Tag)
84 case ICOA_Directory:
85 data->directory = (UBYTE *) tag->ti_Data;
86 break;
87 case OA_InTree:
89 struct HandlerScanRequest *hsr;
91 hsr =
92 createScanMessage(DIMC_SCANDIRECTORY, NULL,
93 data->dirLock, obj,
94 _app(_presentation(obj)));
95 PutMsg(DesktopBase->db_HandlerPort,
96 (struct Message *) hsr);
98 DoMethod(_presentation(obj), MUIM_KillNotify, PA_InTree);
100 break;
102 default:
103 break;
107 retval = DoSuperMethodA(cl, obj, (Msg) msg);
109 return retval;
112 IPTR iconConObsGet(Class * cl, Object * obj, struct opGet * msg)
114 IPTR retval = 1;
115 struct IconContainerObserverClassData *data;
117 data = (struct IconContainerObserverClassData *) INST_DATA(cl, obj);
119 switch (msg->opg_AttrID)
121 case ICOA_Directory:
122 *msg->opg_Storage = (ULONG) data->directory;
123 break;
124 default:
125 retval = DoSuperMethodA(cl, obj, (Msg) msg);
126 break;
129 return retval;
132 IPTR iconConObsDispose(Class * cl, Object * obj, Msg msg)
134 IPTR retval;
135 struct IconContainerObserverClassData *data;
137 data = (struct IconContainerObserverClassData *) INST_DATA(cl, obj);
138 UnLock(data->dirLock);
139 retval = DoSuperMethodA(cl, obj, msg);
141 return retval;
144 IPTR iconConObsAddIcons(Class * cl, Object * obj, struct icoAddIcon * msg)
146 IPTR retval = 0;
147 ULONG i;
148 Object *newIcon;
149 ULONG kind;
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)
161 case WBDISK:
162 kind = CDO_DiskIcon;
163 break;
165 case WBDRAWER:
166 kind = CDO_DrawerIcon;
167 break;
169 case WBTOOL:
170 kind = CDO_ToolIcon;
171 break;
173 case WBPROJECT:
174 kind = CDO_ProjectIcon;
175 break;
177 case WBGARBAGE:
178 kind = CDO_TrashcanIcon;
179 break;
181 case WBDEVICE:
182 case WBKICK:
183 case WBAPPICON:
184 default:
185 continue; /* skip unknown disk object types */
188 newIcon = CreateDesktopObject
190 kind,
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,
210 TAG_DONE
213 DoMethod(_presentation(obj), OM_ADDMEMBER, (IPTR) newIcon);
216 FreeVec(msg->wsr_ResultsArray);
219 return retval;
222 BOOPSI_DISPATCHER(IPTR, iconContainerObserverDispatcher, cl, obj, msg)
224 ULONG retval = 0;
226 switch (msg->MethodID)
228 case OM_NEW:
229 retval = iconConObsNew(cl, obj, (struct opSet *) msg);
230 break;
231 case OM_SET:
232 retval = iconConObsSet(cl, obj, (struct opSet *) msg);
233 break;
234 case OM_GET:
235 retval = iconConObsGet(cl, obj, (struct opGet *) msg);
236 break;
237 case OM_DISPOSE:
238 retval = iconConObsDispose(cl, obj, msg);
239 break;
240 case ICOM_AddIcons:
241 retval = iconConObsAddIcons(cl, obj, (struct icoAddIcon *) msg);
242 break;
243 default:
244 retval = DoSuperMethodA(cl, obj, msg);
245 break;
248 return retval;
250 BOOPSI_DISPATCHER_END