more rendering corrections
[AROS.git] / workbench / libs / desktop / desktopobserver.c
blobb5122cc902e2fac715616242c3fbf9f34d1f5051
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 "desktopobserver.h"
28 #include "presentation.h"
29 #include "iconcontainerclass.h"
30 #include "observer.h"
31 #include "iconclass.h"
33 #include "desktop_intern_protos.h"
35 IPTR desktopObsNew(Class * cl, Object * obj, struct opSet *msg)
37 IPTR retval = 0;
38 struct DesktopObserverClassData *data;
39 struct TagItem *tag;
40 Class *defaultWindowClass = NULL;
41 struct TagItem *defaultWindowArgs = NULL;
43 tag = FindTagItem(DOA_DefaultWindowClass, msg->ops_AttrList);
44 if (tag)
46 defaultWindowClass = (Class *) tag->ti_Data;
47 // this will change, save the variable in a new
48 // desktopcontext area
49 DesktopBase->db_DefaultWindow = defaultWindowClass;
50 tag->ti_Tag = TAG_IGNORE;
53 tag = FindTagItem(DOA_DefaultWindowArguments, msg->ops_AttrList);
54 if (tag)
56 defaultWindowArgs = (struct TagItem *) tag->ti_Data;
57 // this will change, save the variable in a new
58 // desktopcontext area
59 DesktopBase->db_DefaultWindowArguments = defaultWindowArgs;
60 tag->ti_Tag = TAG_IGNORE;
63 retval = DoSuperMethodA(cl, obj, (Msg) msg);
64 if (retval)
66 obj = (Object *) retval;
67 data = INST_DATA(cl, obj);
68 data->defaultWindow = defaultWindowClass;
69 data->defaultWindowArgs = defaultWindowArgs;
72 return retval;
75 IPTR desktopObsSet(Class * cl, Object * obj, struct opSet * msg)
77 struct DesktopObserverClassData *data;
78 IPTR retval = 1;
79 struct TagItem *tag,
80 *tstate = msg->ops_AttrList;
82 data = (struct DesktopObserverClassData *) INST_DATA(cl, obj);
84 while ((tag = NextTagItem(&tstate)))
86 switch (tag->ti_Tag)
88 case OA_InTree:
90 struct HandlerTopLevelRequest *htl;
92 htl =
93 createTLScanMessage(DIMC_TOPLEVEL, NULL, LDF_VOLUMES,
94 obj, _app(_presentation(obj)));
95 PutMsg(DesktopBase->db_HandlerPort,
96 (struct Message *) htl);
98 break;
100 default:
101 break;
105 retval = DoSuperMethodA(cl, obj, (Msg) msg);
107 return retval;
110 IPTR desktopObsGet(Class * cl, Object * obj, struct opGet * msg)
112 IPTR retval = 1;
113 struct DesktopObserverClassData *data;
115 data = (struct DesktopObserverClassData *) INST_DATA(cl, obj);
117 switch (msg->opg_AttrID)
119 default:
120 retval = DoSuperMethodA(cl, obj, (Msg) msg);
121 break;
124 return retval;
127 IPTR desktopObsDispose(Class * cl, Object * obj, Msg msg)
129 IPTR retval;
130 struct DesktopObserverClassData *data;
132 data = (struct DesktopObserverClassData *) INST_DATA(cl, obj);
133 retval = DoSuperMethodA(cl, obj, msg);
135 return retval;
138 IPTR desktopObsAddIcons(Class * cl, Object * obj, struct icoAddIcon * msg)
140 IPTR retval = 0;
141 ULONG i;
142 Object *newIcon;
143 ULONG kind;
145 // struct DesktopObserverClassData *data;
147 for (i = 0; i < msg->wsr_Results; i++)
149 switch (msg->wsr_ResultsArray[i].sr_DiskObject->do_Type)
151 case WBDISK:
152 kind = CDO_DiskIcon;
153 break;
155 case WBDRAWER:
156 kind = CDO_DrawerIcon;
157 break;
159 case WBTOOL:
160 kind = CDO_ToolIcon;
161 break;
163 case WBPROJECT:
164 kind = CDO_ProjectIcon;
165 break;
167 case WBGARBAGE:
168 kind = CDO_TrashcanIcon;
169 break;
171 case WBDEVICE:
172 case WBKICK:
173 case WBAPPICON:
174 default:
175 continue; /* skip unknown diskobject types */
178 newIcon = CreateDesktopObject
180 kind,
182 IA_DiskObject, (IPTR) msg->wsr_ResultsArray[i].sr_DiskObject,
183 IA_Label, (IPTR) msg->wsr_ResultsArray[i].sr_Name,
184 IA_Desktop, (IPTR) _presentation(obj),
185 // IA_Directory, data->directory,
186 MUIA_Draggable, TRUE,
188 TAG_DONE
191 DoMethod(_presentation(obj), OM_ADDMEMBER, (IPTR) newIcon);
194 FreeVec(msg->wsr_ResultsArray);
196 return retval;
199 BOOPSI_DISPATCHER(IPTR, desktopObserverDispatcher, cl, obj, msg)
201 ULONG retval = 0;
203 switch (msg->MethodID)
205 case OM_NEW:
206 retval = desktopObsNew(cl, obj, (struct opSet *) msg);
207 break;
208 case OM_SET:
209 retval = desktopObsSet(cl, obj, (struct opSet *) msg);
210 break;
211 case OM_GET:
212 retval = desktopObsGet(cl, obj, (struct opGet *) msg);
213 break;
214 case OM_DISPOSE:
215 retval = desktopObsDispose(cl, obj, msg);
216 break;
217 case ICOM_AddIcons:
218 retval = desktopObsAddIcons(cl, obj, (struct icoAddIcon *) msg);
219 break;
220 default:
221 retval = DoSuperMethodA(cl, obj, msg);
222 break;
225 return retval;
227 BOOPSI_DISPATCHER_END