Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / desktop / iconobserver.c
blob87935230b61e969667d9222f9738a318f726b8e6
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 <intuition/classes.h>
13 #include <intuition/classusr.h>
14 #include <libraries/mui.h>
16 #include "support.h"
17 #include "worker.h"
18 #include "desktop_intern.h"
20 #include <proto/dos.h>
21 #include <proto/intuition.h>
22 #include <proto/icon.h>
23 #include <proto/utility.h>
25 #include "presentation.h"
26 #include "observer.h"
27 #include "iconclass.h"
28 #include "iconobserver.h"
29 #include "abstracticon.h"
31 #include "desktop_intern_protos.h"
33 #include <string.h>
35 IPTR iconObserverNew(Class * cl, Object * obj, struct opSet * msg)
37 IPTR retval = 0;
38 struct IconObserverClassData *data;
39 struct TagItem *tag,
40 *tstate = msg->ops_AttrList;
41 UBYTE *name = NULL,
42 *directory = NULL;
43 BOOL selected = FALSE;
44 UBYTE *comment = NULL;
45 BOOL script = FALSE,
46 pure = FALSE,
47 archived = FALSE,
48 readable = TRUE,
49 writeable = TRUE,
50 executable = FALSE,
51 deleteable = TRUE;
53 while ((tag = NextTagItem(&tstate)) != NULL)
55 switch (tag->ti_Tag)
57 case IOA_Selected:
58 selected = (BOOL) tag->ti_Data;
59 break;
61 case IOA_Name:
62 name = (UBYTE *) tag->ti_Data;
63 break;
65 case IOA_Directory:
66 directory = (UBYTE *) tag->ti_Data;
67 break;
69 case IOA_Comment:
70 comment = (UBYTE *) tag->ti_Data;
71 break;
73 case IOA_Script:
74 script = (BOOL) tag->ti_Data;
75 break;
77 case IOA_Pure:
78 pure = (BOOL) tag->ti_Data;
79 break;
81 case IOA_Archived:
82 archived = (BOOL) tag->ti_Data;
83 break;
85 case IOA_Readable:
86 readable = (BOOL) tag->ti_Data;
87 break;
89 case IOA_Writeable:
90 writeable = (BOOL) tag->ti_Data;
91 break;
93 case IOA_Executable:
94 executable = (BOOL) tag->ti_Data;
95 break;
97 case IOA_Deleteable:
98 deleteable = (BOOL) tag->ti_Data;
99 break;
101 default:
102 continue; /* Don't supress non-processed tags */
105 tag->ti_Tag = TAG_IGNORE;
108 retval = DoSuperMethodA(cl, obj, (Msg) msg);
109 if (retval)
111 obj = (Object *) retval;
112 data = INST_DATA(cl, obj);
113 data->selected = selected;
114 data->name = name;
115 data->directory = directory;
116 data->comment = comment;
117 data->script = script;
118 data->pure = pure;
119 data->archived = archived;
120 data->readable = readable;
121 data->writeable = writeable;
122 data->executable = executable;
123 data->deleteable = deleteable;
125 DoMethod(_presentation(obj), MUIM_Notify, IA_Executed, TRUE, (IPTR) obj, 1,
126 IOM_Execute);
127 DoMethod(_presentation(obj), MUIM_Notify, IA_Selected, MUIV_EveryTime,
128 (IPTR) obj, 3, MUIM_Set, IOA_Selected, MUIV_TriggerValue);
129 DoMethod(_presentation(obj), MUIM_Notify, IA_Directory,
130 MUIV_EveryTime, (IPTR) obj, 3, MUIM_Set, IOA_Directory,
131 MUIV_TriggerValue);
132 DoMethod(_presentation(obj), MUIM_Notify, AIA_Comment, MUIV_EveryTime,
133 (IPTR) obj, 3, MUIM_Set, IOA_Comment, MUIV_TriggerValue);
135 DoMethod(_presentation(obj), MUIM_Notify, AIA_Script, MUIV_EveryTime,
136 (IPTR) obj, 3, MUIM_Set, IOA_Script, MUIV_TriggerValue);
137 DoMethod(_presentation(obj), MUIM_Notify, AIA_Pure, MUIV_EveryTime,
138 (IPTR) obj, 3, MUIM_Set, IOA_Pure, MUIV_TriggerValue);
139 DoMethod(_presentation(obj), MUIM_Notify, AIA_Archived, MUIV_EveryTime,
140 (IPTR) obj, 3, MUIM_Set, IOA_Archived, MUIV_TriggerValue);
141 DoMethod(_presentation(obj), MUIM_Notify, AIA_Readable, MUIV_EveryTime,
142 (IPTR) obj, 3, MUIM_Set, IOA_Readable, MUIV_TriggerValue);
143 DoMethod(_presentation(obj), MUIM_Notify, AIA_Writeable,
144 MUIV_EveryTime, (IPTR) obj, 3, MUIM_Set, IOA_Writeable,
145 MUIV_TriggerValue);
146 DoMethod(_presentation(obj), MUIM_Notify, AIA_Executable,
147 MUIV_EveryTime, (IPTR) obj, 3, MUIM_Set, IOA_Executable,
148 MUIV_TriggerValue);
149 DoMethod(_presentation(obj), MUIM_Notify, AIA_Deleteable,
150 MUIV_EveryTime, (IPTR) obj, 3, MUIM_Set, IOA_Deleteable,
151 MUIV_TriggerValue);
154 return retval;
157 IPTR iconObserverSet(Class * cl, Object * obj, struct opSet * msg)
159 struct IconObserverClassData *data;
160 IPTR retval = 1;
161 struct TagItem *tag,
162 *tstate = msg->ops_AttrList;
164 data = (struct IconObserverClassData *) INST_DATA(cl, obj);
166 while ((tag = NextTagItem(&tstate)))
168 switch (tag->ti_Tag)
170 case IOA_Comment:
171 data->comment = (UBYTE *) tag->ti_Data;
173 was this OM_SET triggered by a notify?
175 if (strcmp(_comment(_presentation(obj)), data->comment))
176 DoMethod(_presentation(obj), MUIM_NoNotifySet, AIA_Comment,
177 (IPTR) data->comment);
178 break;
179 // TODO: When one of these bits is set, send a request to the
180 // handler to do the change
181 case IOA_Script:
182 data->script = tag->ti_Data;
184 was this OM_SET triggered by a notify?
186 if (_script(_presentation(obj)) != data->script)
187 DoMethod(_presentation(obj), MUIM_NoNotifySet, AIA_Script,
188 data->script);
189 break;
190 case IOA_Pure:
191 data->pure = tag->ti_Data;
193 was this OM_SET triggered by a notify?
195 if (_pure(_presentation(obj)) != data->pure)
196 DoMethod(_presentation(obj), MUIM_NoNotifySet, AIA_Pure,
197 data->pure);
198 break;
199 case IOA_Archived:
200 data->archived = tag->ti_Data;
202 was this OM_SET triggered by a notify?
204 if (_archived(_presentation(obj)) != data->archived)
205 DoMethod(_presentation(obj), MUIM_NoNotifySet,
206 AIA_Archived, data->archived);
207 break;
208 case IOA_Readable:
209 data->readable = tag->ti_Data;
211 was this OM_SET triggered by a notify?
213 if (_readable(_presentation(obj)) != data->readable)
214 DoMethod(_presentation(obj), MUIM_NoNotifySet,
215 AIA_Readable, data->readable);
216 break;
217 case IOA_Writeable:
218 data->writeable = tag->ti_Data;
220 was this OM_SET triggered by a notify?
222 if (_writeable(_presentation(obj)) != data->writeable)
223 DoMethod(_presentation(obj), MUIM_NoNotifySet,
224 AIA_Writeable, data->writeable);
225 break;
226 case IOA_Executable:
227 data->comment = (UBYTE *) tag->ti_Data;
229 was this OM_SET triggered by a notify?
231 if (_executable(_presentation(obj)) != data->executable)
232 DoMethod(_presentation(obj), MUIM_NoNotifySet,
233 AIA_Executable, data->executable);
234 break;
235 case IOA_Deleteable:
236 data->comment = (UBYTE *) tag->ti_Data;
238 was this OM_SET triggered by a notify?
240 if (_deleteable(_presentation(obj)) != data->deleteable)
241 DoMethod(_presentation(obj), MUIM_NoNotifySet,
242 AIA_Deleteable, data->deleteable);
243 break;
244 default:
245 break;
249 retval = DoSuperMethodA(cl, obj, (Msg) msg);
251 return retval;
254 IPTR iconObserverGet(Class * cl, Object * obj, struct opGet * msg)
256 IPTR retval = 1;
257 struct IconObserverClassData *data;
259 data = (struct IconObserverClassData *) INST_DATA(cl, obj);
261 switch (msg->opg_AttrID)
263 case IOA_Name:
264 *msg->opg_Storage = (IPTR) data->name;
265 break;
266 case IOA_Script:
267 *msg->opg_Storage = data->script;
268 break;
269 case IOA_Pure:
270 *msg->opg_Storage = data->pure;
271 break;
272 case IOA_Archived:
273 *msg->opg_Storage = data->archived;
274 break;
275 case IOA_Readable:
276 *msg->opg_Storage = data->readable;
277 break;
278 case IOA_Writeable:
279 *msg->opg_Storage = data->writeable;
280 break;
281 case IOA_Executable:
282 *msg->opg_Storage = data->executable;
283 break;
284 case IOA_Deleteable:
285 *msg->opg_Storage = data->deleteable;
286 break;
287 default:
288 retval = DoSuperMethodA(cl, obj, (Msg) msg);
289 break;
292 return retval;
295 IPTR iconObserverDispose(Class * cl, Object * obj, Msg msg)
297 IPTR retval;
298 struct IconObserverClassData *data;
300 data = (struct IconObserverClassData *) INST_DATA(cl, obj);
302 FreeDiskObject(_diskobject(_presentation(obj)));
303 // note:
304 // IconObserverClassData.name is part of the ExAllBuffer and is freed
305 // by this object's parent
306 // IconObserverClassData.directory belongs to this object's parent, and
307 // is freed by it
309 retval = DoSuperMethodA(cl, obj, msg);
311 return retval;
314 IPTR iconObserverExecute(Class * cl, Object * obj, Msg msg)
316 return 0;
319 BOOPSI_DISPATCHER(IPTR, iconObserverDispatcher, cl, obj, msg)
321 ULONG retval = 0;
323 switch (msg->MethodID)
325 case OM_NEW:
326 retval = iconObserverNew(cl, obj, (struct opSet *) msg);
327 break;
328 case OM_SET:
329 retval = iconObserverSet(cl, obj, (struct opSet *) msg);
330 break;
331 case OM_GET:
332 retval = iconObserverGet(cl, obj, (struct opGet *) msg);
333 break;
334 case OM_DISPOSE:
335 retval = iconObserverDispose(cl, obj, msg);
336 break;
337 case IOM_Execute:
338 retval = iconObserverExecute(cl, obj, msg);
339 break;
340 default:
341 retval = DoSuperMethodA(cl, obj, msg);
342 break;
345 return retval;
347 BOOPSI_DISPATCHER_END