Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / system / Wanderer / iconwindow_volumelist.c
blob50d706b6b0f34c52c7c9a259cf065e0fd8c4ea34
1 /*
2 Copyright 2004-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define ZCC_QUIET
8 #include "portable_macros.h"
10 #ifdef __AROS__
11 #define MUIMASTER_YES_INLINE_STDARG
12 #endif
14 //#define DEBUG_NETWORKBROWSER
15 //#define DEBUG_SHOWUSERFILES
16 #define TXTBUFF_LEN 1024
18 #ifdef __AROS__
19 #define DEBUG 0
20 #include <aros/debug.h>
21 #endif
23 #include <exec/types.h>
24 #include <libraries/mui.h>
26 #ifdef __AROS__
27 #include <zune/customclasses.h>
28 #else
29 #include <zune_AROS/customclasses.h>
30 #endif
33 #include <proto/utility.h>
35 #include <proto/graphics.h>
36 #include <proto/exec.h>
37 #include <proto/datatypes.h>
38 #include <proto/icon.h>
40 #include <dos/dos.h>
41 #include <proto/dos.h>
43 #include <stdio.h>
44 #include <string.h>
46 #include <intuition/screens.h>
47 #include <datatypes/pictureclass.h>
48 #include <clib/macros.h>
50 #if defined(__AMIGA__) && !defined(__PPC__)
51 #define NO_INLINE_STDARG
52 #endif
53 #ifndef _PROTO_INTUITION_H
54 #include <proto/intuition.h>
55 #endif
56 #include <proto/muimaster.h>
58 #include "Classes/iconlist.h"
59 #include "Classes/iconlist_attributes.h"
60 #include "Classes/icon_attributes.h"
62 #include "wanderer.h"
63 #include "wandererprefs.h"
64 #include "iconwindow.h"
65 #include "iconwindow_iconlist.h"
66 #include "appobjects.h"
68 #ifndef __AROS__
69 #define DEBUG 1
71 #ifdef DEBUG
72 #define D(x) if (DEBUG) x
73 #ifdef __amigaos4__
74 #define bug DebugPrintF
75 #else
76 #define bug kprintf
77 #endif
78 #else
79 #define D(...)
80 #endif
81 #endif
83 extern struct IconWindow_BackFill_Descriptor *iconwindow_BackFill_Active;
85 #define WIWVLVERS 1
86 #define WIWVLREV 2
88 #define BG_DRAWFLAG 0xf00dd00f
90 /*** Instance Data **********************************************************/
92 struct IconWindowVolumeList_DATA
94 Object *iwcd_IconWindow;
95 struct RastPort *iwcd_RastPort;
96 struct MUI_EventHandlerNode iwcd_EventHandlerNode;
97 #ifdef __AROS__
98 struct Hook iwcd_ProcessIconListPrefs_hook;
99 #else
100 struct Hook *iwcd_ProcessIconListPrefs_hook;
101 #endif
103 IPTR iwcd_ViewPrefs_ID;
104 Object *iwcd_ViewPrefs_NotificationObject;
105 #ifdef __AROS__
106 struct Hook iwvcd_UpdateNetworkPrefs_hook;
107 #else
108 struct Hook *iwvcd_UpdateNetworkPrefs_hook;
109 #endif
111 IPTR iwvcd_ShowNetworkBrowser;
112 IPTR iwvcd_ShowUserFolder;
114 /* File System update handling */
115 struct MsgPort *iwvcd_FSNotifyPort;
118 static char __icwc_intern_TxtBuff[TXTBUFF_LEN];
120 /*** Macros *****************************************************************/
121 #define SETUP_INST_DATA struct IconWindowVolumeList_DATA *data = INST_DATA(CLASS, self)
123 /*** Hook functions *********************************************************/
124 ///IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc()
125 #ifdef __AROS__
126 AROS_UFH3(
127 void, IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc,
128 AROS_UFHA(struct Hook *, hook, A0),
129 AROS_UFHA(APTR *, obj, A2),
130 AROS_UFHA(IPTR *, param, A1)
133 #else
134 HOOKPROTO(IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc, void, APTR *obj, IPTR *param)
136 #endif
137 AROS_USERFUNC_INIT
139 /* Get our private data */
140 Object *self = ( Object *)obj;
141 IPTR CHANGED_ATTRIB = *param;
142 Class *CLASS = OCLASS(self);
144 SETUP_INST_DATA;
146 Object *prefs = NULL;
148 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
150 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
152 if (prefs)
154 IPTR attrib_Current = 0, attrib_Prefs, prefs_Processing = 0;
155 BOOL options_changed = FALSE;
157 D(bug("[Wanderer:VolumeList] %s: Setting IconList options ..\n", __PRETTY_FUNCTION__));
159 GET(prefs, MUIA_WandererPrefs_Processing, &prefs_Processing);
161 switch (CHANGED_ATTRIB)
163 case MUIA_IconList_IconListMode:
164 case MUIA_IconList_LabelText_Mode:
165 case MUIA_IconList_LabelText_MaxLineLen:
166 case MUIA_IconList_LabelText_MultiLine:
167 case MUIA_IconList_LabelText_MultiLineOnFocus:
168 case MUIA_IconList_Icon_HorizontalSpacing:
169 case MUIA_IconList_Icon_VerticalSpacing:
170 case MUIA_IconList_Icon_ImageSpacing:
171 case MUIA_IconList_LabelText_HorizontalPadding:
172 case MUIA_IconList_LabelText_VerticalPadding:
173 case MUIA_IconList_LabelText_BorderWidth:
174 case MUIA_IconList_LabelText_BorderHeight:
175 case MUIA_IconList_DragImageTransparent:
176 case MUIA_IconList_SortFlags:
177 /* Generic code */
178 GET(self, (ULONG)CHANGED_ATTRIB, &attrib_Current);
180 if (((attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, (ULONG)CHANGED_ATTRIB)) != -1) &&
181 (attrib_Current != attrib_Prefs))
183 options_changed = TRUE;
184 if (prefs_Processing)
186 NNSET(self, (ULONG)CHANGED_ATTRIB, attrib_Prefs);
188 else
190 SET(self, (ULONG)CHANGED_ATTRIB, attrib_Prefs);
193 break;
195 default:
196 D(bug("[Wanderer:VolumeList] %s: Unhandled change\n", __PRETTY_FUNCTION__));
197 break;
200 if (options_changed)
202 if (!(prefs_Processing))
204 D(bug("[Wanderer:VolumeList] %s: IconList Options have changed, causing an update ..\n", __PRETTY_FUNCTION__));
205 DoMethod(self, MUIM_IconList_Update);
206 DoMethod(self, MUIM_IconList_Sort);
208 else if (data->iwcd_IconWindow)
210 SET(data->iwcd_IconWindow, MUIA_IconWindow_Changed, TRUE);
214 AROS_USERFUNC_EXIT
216 #ifndef __AROS__
217 MakeStaticHook(Hook_ProcessIconListPrefsFunc,IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc);
218 #endif
221 ///IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc()
222 #ifdef __AROS__
223 AROS_UFH3(
224 void, IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc,
225 AROS_UFHA(struct Hook *, hook, A0),
226 AROS_UFHA(APTR *, obj, A2),
227 AROS_UFHA(APTR, param, A1)
230 #else
231 HOOKPROTO(IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc, void, APTR *obj, APTR param)
233 #endif
234 AROS_USERFUNC_INIT
236 /* Get our private data */
237 Object *self = ( Object *)obj;
238 Object *prefs = NULL;
239 Class *CLASS = *( Class **)param;
241 SETUP_INST_DATA;
243 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
245 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
247 if (prefs)
249 BOOL options_changed = FALSE;
250 IPTR prefs_Processing = 0;
252 GET(prefs, MUIA_WandererPrefs_Processing, &prefs_Processing);
254 IPTR current_ShowNetwork = 0;
255 IPTR prefs_ShowNetwork = 0;
257 D(bug("[Wanderer:VolumeList] %s: Setting ROOT view Network options ..\n", __PRETTY_FUNCTION__));
259 GET(self, MUIA_IconWindowExt_NetworkBrowser_Show, &current_ShowNetwork);
261 D(bug("[Wanderer:VolumeList] %s: Current = %d\n", __PRETTY_FUNCTION__, current_ShowNetwork));
263 GET(prefs, MUIA_IconWindowExt_NetworkBrowser_Show, &prefs_ShowNetwork);
265 D(bug("[Wanderer:VolumeList] %s: Prefs = %d\n", __PRETTY_FUNCTION__, prefs_ShowNetwork));
267 if ((BOOL)current_ShowNetwork != (BOOL)prefs_ShowNetwork)
269 D(bug("[Wanderer:VolumeList] %s: ROOT view Network prefs changed - updating ..\n", __PRETTY_FUNCTION__));
270 options_changed = TRUE;
271 ((struct IconWindowVolumeList_DATA *)data)->iwvcd_ShowNetworkBrowser = prefs_ShowNetwork;
273 if ((options_changed) && !(prefs_Processing))
275 D(bug("[Wanderer:VolumeList] %s: Network prefs changed, causing an update ..\n", __PRETTY_FUNCTION__));
276 DoMethod(self, MUIM_IconList_Update);
277 DoMethod(self, MUIM_IconList_Sort);
279 else if (data->iwcd_IconWindow)
281 SET(data->iwcd_IconWindow, MUIA_IconWindow_Changed, TRUE);
284 AROS_USERFUNC_EXIT
286 #ifndef __AROS__
287 MakeStaticHook(Hook_UpdateNetworkPrefsFunc,IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc);
288 #endif
290 #define BDRPLINELEN_MAX 1024
291 BOOL IconWindowVolumeList__Func_ParseBackdrop(Object *self, struct IconEntry *bdrp_direntry, struct List* entryList)
293 BPTR bdrp_lock = (BPTR)NULL;
294 char *bdrp_file = NULL, *linebuf = NULL, *bdrp_fullfile = NULL, *bdrp_namepart = NULL;
295 struct DiskObject *bdrp_currfile_dob = NULL;
296 BOOL retVal = FALSE;
297 char *bdrp_dir = bdrp_direntry->ie_IconNode.ln_Name;
299 if ((bdrp_dir == NULL) || (bdrp_dir[strlen(bdrp_dir) - 1] != ':'))
300 return retVal;
302 D(bug("[Wanderer:VolumeList] %s('%s')\n", __PRETTY_FUNCTION__, bdrp_dir));
304 if ((bdrp_file = AllocVec(strlen(bdrp_dir) + 9 + 1, MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
306 sprintf(bdrp_file, "%s.backdrop", bdrp_dir);
307 if ((bdrp_lock = Open(bdrp_file, MODE_OLDFILE)))
309 D(bug("[Wanderer:VolumeList] %s: Loading backdrop file: '%s'\n", __PRETTY_FUNCTION__, bdrp_file));
311 if ((linebuf = AllocMem(BDRPLINELEN_MAX, MEMF_PUBLIC)) != NULL)
313 while (FGets(bdrp_lock, linebuf, BDRPLINELEN_MAX))
315 int linelen = 0;
316 if (*linebuf != ':')
317 continue;
319 linelen = strlen(linebuf) - 1; /* drop the newline char */
320 linebuf[linelen] = '\0';
322 if ((bdrp_fullfile = AllocVec(linelen + strlen(bdrp_dir), MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
324 ULONG lofTYPE = 0;
326 sprintf(bdrp_fullfile, "%s%s", bdrp_dir, &linebuf[1]);
328 struct FileInfoBlock *lofFIB = AllocDosObject(DOS_FIB, NULL);
329 if (lofFIB)
331 BPTR lofLock = BNULL;
332 if ((lofLock = Lock(bdrp_fullfile, SHARED_LOCK)) != BNULL)
334 char *tmpbdrp_file = NULL;
335 int tmpbdrp_len = strlen(bdrp_fullfile) + 128;
336 if ((tmpbdrp_file = AllocVec(tmpbdrp_len, MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
338 if (NameFromLock(lofLock, tmpbdrp_file, tmpbdrp_len) != 0)
340 FreeVec(bdrp_fullfile);
341 bdrp_fullfile = tmpbdrp_file;
343 else
344 FreeVec(tmpbdrp_file);
346 if (Examine(lofLock, lofFIB))
348 if (lofFIB->fib_DirEntryType == ST_FILE)
350 lofTYPE = ST_LINKFILE;
352 else if (lofFIB->fib_DirEntryType == ST_USERDIR)
354 lofTYPE = ST_LINKDIR;
357 UnLock(lofLock);
359 FreeDosObject(DOS_FIB, lofFIB);
362 bdrp_namepart = FilePart(bdrp_fullfile);
364 struct IconEntry *this_entry = NULL, *iconNode = NULL, *tmpentry = NULL;
366 if (entryList != NULL)
368 D(bug("[Wanderer:VolumeList] %s: Checking for existing entry in list @ 0x%p\n", __PRETTY_FUNCTION__, entryList));
369 ForeachNodeSafe(entryList, iconNode, tmpentry)
371 if (strcmp(iconNode->ie_IconNode.ln_Name, bdrp_fullfile) == 0)
373 this_entry = iconNode;
374 Remove((struct Node*)&iconNode->ie_IconNode);
375 iconNode->ie_IconListEntry.udata = bdrp_direntry;
376 D(bug("[Wanderer:VolumeList] %s: Reinserting '%s'\n", __PRETTY_FUNCTION__, iconNode->ie_IconNode.ln_Name));
377 DoMethod(self, MUIM_Family_AddTail, (struct Node*)&iconNode->ie_IconNode);
378 /* retVal - this case is not considered a change */
379 break;
384 if (this_entry == NULL)
386 //bug("[Wanderer:VolumeList] %s: Checking for existing entry in iconlist\n", __PRETTY_FUNCTION__);
388 bdrp_currfile_dob = GetIconTags
390 bdrp_fullfile,
391 ICONGETA_Screen, _screen(self),
392 ICONGETA_FailIfUnavailable, FALSE,
393 ICONGETA_Label, bdrp_namepart,
394 TAG_DONE
397 D(bug("[Wanderer:VolumeList] %s: LEAVEOUT Icon '%s' ('%s') DOB @ 0x%p\n", __PRETTY_FUNCTION__, bdrp_fullfile, bdrp_namepart, bdrp_currfile_dob));
399 if (bdrp_currfile_dob)
401 if ((this_entry = (struct IconEntry *)DoMethod(self, MUIM_IconList_CreateEntry, (IPTR)bdrp_fullfile, (IPTR)bdrp_namepart, (IPTR)NULL, (IPTR)bdrp_currfile_dob, 0, (IPTR)NULL)))
403 this_entry->ie_IconNode.ln_Pri = 1;
404 this_entry->ie_IconListEntry.type = lofTYPE;
405 this_entry->ie_IconListEntry.udata = bdrp_direntry;
406 DoMethod(self, MUIM_Family_AddTail, (struct Node*)&this_entry->ie_IconNode);
408 retVal = TRUE;
412 FreeVec(bdrp_fullfile);
415 FreeMem(linebuf, BDRPLINELEN_MAX);
417 Close(bdrp_lock);
419 FreeVec(bdrp_file);
421 return retVal;
425 /*** Methods ****************************************************************/
426 ///OM_NEW()
427 Object *IconWindowVolumeList__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
429 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
431 self = (Object *) DoSuperNewTags
433 CLASS, self, NULL,
434 MUIA_CycleChain, 1,
435 TAG_MORE, (IPTR) message->ops_AttrList
438 if (self != NULL)
440 SETUP_INST_DATA;
441 D(bug("[Wanderer:VolumeList] %s: SELF = 0x%p\n", __PRETTY_FUNCTION__, self));
443 data->iwvcd_FSNotifyPort = (struct MsgPort *)GetTagData(MUIA_Wanderer_FileSysNotifyPort, (IPTR) NULL, message->ops_AttrList);
445 #ifdef __AROS__
446 data->iwcd_ProcessIconListPrefs_hook.h_Entry = ( HOOKFUNC )IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc;
447 #else
448 data->iwcd_ProcessIconListPrefs_hook = &Hook_ProcessIconListPrefsFunc;
449 #endif
452 return self;
456 ///OM_SET()
457 IPTR IconWindowVolumeList__OM_SET(Class *CLASS, Object *self, struct opSet *message)
459 SETUP_INST_DATA;
461 struct TagItem *tstate = message->ops_AttrList, *tag;
463 while ((tag = NextTagItem(&tstate)) != NULL)
465 switch (tag->ti_Tag)
467 case MUIA_Background:
469 D(bug("[Wanderer:VolumeList] %s: MUIA_Background\n", __PRETTY_FUNCTION__));
470 break;
472 case MUIA_IconWindow_Window:
474 D(bug("[Wanderer:VolumeList] %s: MUIA_IconWindow_Window @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
475 data->iwcd_IconWindow = (Object *)tag->ti_Data;
476 break;
478 case MUIA_IconList_BufferRastport:
480 D(bug("[Wanderer:VolumeList] %s: MUIA_IconList_BufferRastport @ %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
481 data->iwcd_RastPort = (struct RastPort *)tag->ti_Data;
482 break;
486 return DoSuperMethodA(CLASS, self, (Msg) message);
490 ///OM_GET()
491 IPTR IconWindowVolumeList__OM_GET(Class *CLASS, Object *self, struct opGet *message)
493 //SETUP_INST_DATA;
494 IPTR *store = message->opg_Storage;
495 IPTR rv = TRUE;
497 switch (message->opg_AttrID)
499 case MUIA_Version:
500 *store = (IPTR)WIWVLVERS;
501 break;
503 case MUIA_Revision:
504 *store = (IPTR)WIWVLREV;
505 break;
507 default:
508 rv = DoSuperMethodA(CLASS, self, (Msg) message);
511 return rv;
515 #define SETFROMPREFS(tag) \
516 attrib_Prefs = DoMethod(prefs, MUIM_WandererPrefs_ViewSettings_GetAttribute, data->iwcd_ViewPrefs_ID, tag); \
517 if ((attrib_Prefs != (IPTR)-1) && (attrib_Prefs != XGET(self, tag))) SET(self, tag, attrib_Prefs);
519 #define ADDPREFSNTF(tag) \
520 DoMethod(data->iwcd_ViewPrefs_NotificationObject, MUIM_Notify, tag, MUIV_EveryTime, (IPTR) self, 3, \
521 MUIM_CallHook, &data->iwcd_ProcessIconListPrefs_hook, (IPTR)tag);
523 #define REMPREFSNTF(tag) \
524 DoMethod(data->iwcd_ViewPrefs_NotificationObject, MUIM_KillNotifyObj, tag, (IPTR)self);
526 ///IconWindowVolumeList__MUIM_Setup()
527 IPTR IconWindowVolumeList__MUIM_Setup
529 Class *CLASS, Object *self, Msg message
532 SETUP_INST_DATA;
534 Object *prefs = NULL;
536 if (!DoSuperMethodA(CLASS, self, message)) return FALSE;
538 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
540 if (prefs)
542 /* Set our initial options */
543 IPTR attrib_Prefs;
545 GET(_win(self), MUIA_IconWindow_BackgroundAttrib, &data->iwcd_ViewPrefs_ID);
546 D(bug("[Wanderer:VolumeList] %s: Window Background = '%s'\n", __PRETTY_FUNCTION__, data->iwcd_ViewPrefs_ID));
547 data->iwcd_ViewPrefs_NotificationObject = (Object *)DoMethod(prefs,
548 MUIM_WandererPrefs_ViewSettings_GetNotifyObject,
549 data->iwcd_ViewPrefs_ID);
551 D(bug("[Wanderer:VolumeList] %s: Background Notification Obj @ 0x%p\n", __PRETTY_FUNCTION__, data->iwcd_ViewPrefs_NotificationObject));
553 SETFROMPREFS(MUIA_IconList_IconListMode);
554 SETFROMPREFS(MUIA_IconList_LabelText_Mode);
555 SETFROMPREFS(MUIA_IconList_SortFlags);
556 SETFROMPREFS(MUIA_IconList_DragImageTransparent);
557 SETFROMPREFS(MUIA_IconList_LabelText_MaxLineLen);
558 SETFROMPREFS(MUIA_IconList_LabelText_MultiLine);
559 SETFROMPREFS(MUIA_IconList_LabelText_MultiLineOnFocus);
560 SETFROMPREFS(MUIA_IconList_Icon_HorizontalSpacing);
561 SETFROMPREFS(MUIA_IconList_Icon_VerticalSpacing);
562 SETFROMPREFS(MUIA_IconList_Icon_ImageSpacing);
563 SETFROMPREFS(MUIA_IconList_LabelText_HorizontalPadding);
564 SETFROMPREFS(MUIA_IconList_LabelText_VerticalPadding);
565 SETFROMPREFS(MUIA_IconList_LabelText_BorderWidth);
566 SETFROMPREFS(MUIA_IconList_LabelText_BorderHeight);
568 /* Configure notifications incase they get updated =) */
569 ADDPREFSNTF(MUIA_IconList_IconListMode);
570 ADDPREFSNTF(MUIA_IconList_LabelText_Mode);
571 ADDPREFSNTF(MUIA_IconList_SortFlags);
572 ADDPREFSNTF(MUIA_IconList_DragImageTransparent);
573 ADDPREFSNTF(MUIA_IconList_LabelText_MaxLineLen);
574 ADDPREFSNTF(MUIA_IconList_LabelText_MultiLine);
575 ADDPREFSNTF(MUIA_IconList_LabelText_MultiLineOnFocus);
576 ADDPREFSNTF(MUIA_IconList_Icon_HorizontalSpacing);
577 ADDPREFSNTF(MUIA_IconList_Icon_VerticalSpacing);
578 ADDPREFSNTF(MUIA_IconList_Icon_ImageSpacing);
579 ADDPREFSNTF(MUIA_IconList_LabelText_HorizontalPadding);
580 ADDPREFSNTF(MUIA_IconList_LabelText_VerticalPadding);
581 ADDPREFSNTF(MUIA_IconList_LabelText_BorderWidth);
582 ADDPREFSNTF(MUIA_IconList_LabelText_BorderHeight);
585 if (prefs)
587 #ifdef __AROS__
588 ((struct IconWindowVolumeList_DATA *)data)->iwvcd_UpdateNetworkPrefs_hook.h_Entry = ( HOOKFUNC )IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc;
589 #else
590 ((struct IconWindowVolumeList_DATA *)data)->iwvcd_UpdateNetworkPrefs_hook = &Hook_UpdateNetworkPrefsFunc;
591 #endif
593 DoMethod
595 prefs, MUIM_Notify, MUIA_IconWindowExt_NetworkBrowser_Show, MUIV_EveryTime,
596 (IPTR) self, 3,
597 MUIM_CallHook, &((struct IconWindowVolumeList_DATA *)data)->iwvcd_UpdateNetworkPrefs_hook, (IPTR)CLASS
601 if (muiRenderInfo(self))
603 D(bug("[Wanderer:VolumeList] %s: Setting up EventHandler for (IDCMP_DISKINSERTED | IDCMP_DISKREMOVED)\n", __PRETTY_FUNCTION__));
605 data->iwcd_EventHandlerNode.ehn_Priority = 1;
606 data->iwcd_EventHandlerNode.ehn_Flags = MUI_EHF_GUIMODE;
607 data->iwcd_EventHandlerNode.ehn_Object = self;
608 data->iwcd_EventHandlerNode.ehn_Class = CLASS;
609 data->iwcd_EventHandlerNode.ehn_Events = IDCMP_DISKINSERTED | IDCMP_DISKREMOVED;
611 DoMethod(_win(self), MUIM_Window_AddEventHandler, &data->iwcd_EventHandlerNode);
613 else
615 D(bug("[Wanderer:VolumeList] %s: Couldnt add IDCMP EventHandler!\n", __PRETTY_FUNCTION__));
618 D(bug("[Wanderer:VolumeList] %s: Setup complete!\n", __PRETTY_FUNCTION__));
620 return TRUE;
624 ///IconWindowVolumeList__MUIM_Cleanup()
625 IPTR IconWindowVolumeList__MUIM_Cleanup
627 Class *CLASS, Object *self, Msg message
630 SETUP_INST_DATA;
632 Object *prefs = NULL;
634 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
635 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
637 if (prefs)
639 REMPREFSNTF(MUIA_IconList_IconListMode);
640 REMPREFSNTF(MUIA_IconList_LabelText_Mode);
641 REMPREFSNTF(MUIA_IconList_SortFlags);
642 REMPREFSNTF(MUIA_IconList_DragImageTransparent);
643 REMPREFSNTF(MUIA_IconList_LabelText_MaxLineLen);
644 REMPREFSNTF(MUIA_IconList_LabelText_MultiLine);
645 REMPREFSNTF(MUIA_IconList_LabelText_MultiLineOnFocus);
646 REMPREFSNTF(MUIA_IconList_Icon_HorizontalSpacing);
647 REMPREFSNTF(MUIA_IconList_Icon_VerticalSpacing);
648 REMPREFSNTF(MUIA_IconList_Icon_ImageSpacing);
649 REMPREFSNTF(MUIA_IconList_LabelText_HorizontalPadding);
650 REMPREFSNTF(MUIA_IconList_LabelText_VerticalPadding);
651 REMPREFSNTF(MUIA_IconList_LabelText_BorderWidth);
652 REMPREFSNTF(MUIA_IconList_LabelText_BorderHeight);
655 if (prefs)
657 DoMethod
659 prefs,
660 MUIM_KillNotifyObj, MUIA_IconWindowExt_NetworkBrowser_Show, (IPTR) self
663 D(bug("[Wanderer:VolumeList] %s: Removing Disk Event Handler\n", __PRETTY_FUNCTION__));
664 DoMethod(_win(self), MUIM_Window_RemEventHandler, &data->iwcd_EventHandlerNode);
666 return DoSuperMethodA(CLASS, self, message);
670 ///IconWindowVolumeList__MUIM_HandleEvent()
671 IPTR IconWindowVolumeList__MUIM_HandleEvent
673 Class *CLASS, Object *self, struct MUIP_HandleEvent *message
676 //SETUP_INST_DATA;
678 struct IntuiMessage *imsg = message->imsg;
680 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
682 if(imsg->Class == IDCMP_DISKINSERTED)
684 D(bug("[Wanderer:VolumeList] %s: IDCMP_DISKINSERTED\n", __PRETTY_FUNCTION__));
685 DoMethod(self, MUIM_IconList_Update);
686 DoMethod(self, MUIM_IconList_Sort);
687 return(MUI_EventHandlerRC_Eat);
689 else if (imsg->Class == IDCMP_DISKREMOVED)
691 D(bug("[Wanderer:VolumeList] %s: IDCMP_DISKREMOVED\n", __PRETTY_FUNCTION__));
692 DoMethod(self, MUIM_IconList_Update);
693 DoMethod(self, MUIM_IconList_Sort);
694 return(MUI_EventHandlerRC_Eat);
696 return 0;
700 ///IconWindowVolumeList__MUIM_DrawBackground()
701 IPTR IconWindowVolumeList__MUIM_DrawBackground
703 Class *CLASS, Object *self, struct MUIP_DrawBackground *message
706 SETUP_INST_DATA;
708 IPTR retVal = (IPTR)TRUE;
709 IPTR clip = 0;
710 struct RastPort *DrawBackGround_RastPort;
711 struct IconWindowBackFillMsg DrawBackGround_BackFillMsg;
713 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
715 if ((iconwindow_BackFill_Active == NULL) ||
716 (data->iwcd_IconWindow == NULL))
718 D(bug("[Wanderer:VolumeList] %s: No Backfill support/Window not set .. causing parent class to render\n", __PRETTY_FUNCTION__));
719 goto iwc_ParentBackground;
722 DrawBackGround_RastPort = _rp(self);
724 if ((data->iwcd_RastPort != NULL) && (DrawBackGround_RastPort != data->iwcd_RastPort))
726 DrawBackGround_RastPort = data->iwcd_RastPort;
728 DrawBackGround_BackFillMsg.AreaBounds.MinX = 0;
729 DrawBackGround_BackFillMsg.AreaBounds.MinY = 0;
730 DrawBackGround_BackFillMsg.AreaBounds.MaxX = _mwidth(self);
731 DrawBackGround_BackFillMsg.AreaBounds.MaxY = _mheight(self);
733 DrawBackGround_BackFillMsg.DrawBounds.MinX = message->left - _mleft(self);
734 DrawBackGround_BackFillMsg.DrawBounds.MinY = message->top - _mtop(self);
735 DrawBackGround_BackFillMsg.DrawBounds.MaxX = message->width;
736 DrawBackGround_BackFillMsg.DrawBounds.MaxY = message->height;
738 else
740 DrawBackGround_BackFillMsg.AreaBounds.MinX = _mleft(self);
741 DrawBackGround_BackFillMsg.AreaBounds.MinY = _mtop(self);
742 DrawBackGround_BackFillMsg.AreaBounds.MaxX = (_mleft(self) + _mwidth(self));
743 DrawBackGround_BackFillMsg.AreaBounds.MaxY = (_mtop(self) + _mheight(self));
745 DrawBackGround_BackFillMsg.DrawBounds.MinX = message->left;
746 DrawBackGround_BackFillMsg.DrawBounds.MinY = message->top;
747 DrawBackGround_BackFillMsg.DrawBounds.MaxX = (message->left + message->width);
748 DrawBackGround_BackFillMsg.DrawBounds.MaxY = (message->top + message->height);
751 DrawBackGround_BackFillMsg.Layer = DrawBackGround_RastPort->Layer;
753 /* Offset into source image (ala scroll bar position) */
754 DrawBackGround_BackFillMsg.OffsetX = message->xoffset;
755 DrawBackGround_BackFillMsg.OffsetY = message->yoffset;
757 D(bug("[Wanderer:VolumeList] %s: RastPort @ 0x%p\n", __PRETTY_FUNCTION__, DrawBackGround_RastPort));
759 if ((retVal = DoMethod(data->iwcd_IconWindow, MUIM_IconWindow_BackFill_DrawBackground, XGET(data->iwcd_IconWindow, MUIA_IconWindow_BackFillData), &DrawBackGround_BackFillMsg, DrawBackGround_RastPort)) == (IPTR)TRUE)
761 D(bug("[Wanderer:VolumeList] %s: Backfill module rendered background ..\n", __PRETTY_FUNCTION__));
762 return retVal;
764 D(bug("[Wanderer:VolumeList] %s: Backfill module failed to render background ..\n", __PRETTY_FUNCTION__));
766 iwc_ParentBackground:
768 clip = (IPTR)MUI_AddClipping(muiRenderInfo(self), message->left, message->top, message->width, message->height);
770 message->width = _mwidth(self);
771 message->height = _mheight(self);
772 message->left = _mleft(self);
773 message->top = _mtop(self);
775 retVal = DoSuperMethodA(CLASS, self, (Msg) message);
777 MUI_RemoveClipping(muiRenderInfo(self), (APTR)clip);
779 return retVal;
783 ///IconWindowVolumeList__MUIM_IconList_Update()
784 IPTR IconWindowVolumeList__MUIM_IconList_Update
786 Class *CLASS, Object *self, struct MUIP_IconList_Update *message
789 SETUP_INST_DATA;
791 IPTR retVal = (IPTR)TRUE;
793 if ((BOOL)XGET(_win(self), MUIA_IconWindow_IsRoot))
795 // struct IconList_Entry *icon_entry = (IPTR)MUIV_IconList_NextIcon_Start;
796 Object *prefs = NULL;
797 struct Node *Obj_NetworkIcon = NULL;
798 struct Node *Obj_UserFilesIcon = NULL;
800 struct List leftoutList, iconifiedList, *iconList = NULL;
801 struct IconEntry *volentry = NULL, *entry = NULL, *tmpentry = NULL;
803 NEWLIST(&leftoutList);
804 NEWLIST(&iconifiedList);
806 D(bug("[Wanderer:VolumeList] %s: left-out List @ %p\n", __PRETTY_FUNCTION__, &leftoutList));
808 GET(self, MUIA_Family_List, &iconList);
810 ForeachNodeSafe(iconList, entry, tmpentry)
812 if (entry->ie_IconListEntry.type == ST_ROOT)
814 D(bug("[Wanderer:VolumeList] %s: Marking volume entry '%s' (pri = %d)\n",
815 __PRETTY_FUNCTION__, entry->ie_IconNode.ln_Name, entry->ie_IconNode.ln_Pri));
816 if (entry->ie_IconNode.ln_Pri == 5) entry->ie_IconNode.ln_Pri = -5;
817 else entry->ie_IconNode.ln_Pri = -2;
819 if ((entry->ie_IconListEntry.type == ST_LINKFILE) || (entry->ie_IconListEntry.type == ST_LINKDIR))
821 D(bug("[Wanderer:VolumeList] %s: Removing left out entry '%s'\n",
822 __PRETTY_FUNCTION__, entry->ie_IconNode.ln_Name));
823 Remove(&entry->ie_IconNode);
824 AddTail(&leftoutList, &entry->ie_IconNode);
826 else if (entry->ie_IconListEntry.type == ILE_TYPE_APPICON)
828 D(bug("[Wanderer:VolumeList] %s: Removing iconified entry '%s'\n",
829 __PRETTY_FUNCTION__, entry->ie_IconNode.ln_Name));
830 Remove(&entry->ie_IconNode);
831 AddTail(&iconifiedList, &entry->ie_IconNode);
833 else if (strcmp(entry->ie_IconNode.ln_Name, "?wanderer.networkbrowse?") == 0)
835 D(bug("[Wanderer:VolumeList] %s: Removing NetworkBrowser entry\n", __PRETTY_FUNCTION__));
836 Remove(&entry->ie_IconNode);
837 Obj_NetworkIcon = (struct Node *)entry;
839 /*else if (strcmp(, "User Files..") == 0)
841 Remove(&entry->ie_IconNode);
842 Obj_UserFilesIcon = entry;
846 D(bug("[Wanderer:VolumeList] %s: Causing parent to update\n", __PRETTY_FUNCTION__));
847 retVal = DoSuperMethodA(CLASS, self, (Msg) message);
849 GET(self, MUIA_Family_List, &iconList);
851 /* Re-parsing .backdrop files and re-adding entries */
852 ForeachNode(iconList, volentry)
854 if ((volentry->ie_IconListEntry.type == ST_ROOT)
855 && ((volentry->ie_IconNode.ln_Pri == -2) || (volentry->ie_IconNode.ln_Pri == -5))
856 && !(_volpriv(volentry)->vip_FLags & ICONENTRY_VOL_OFFLINE))
858 if (volentry->ie_IconNode.ln_Pri == -5) volentry->ie_IconNode.ln_Pri = 5;
859 else volentry->ie_IconNode.ln_Pri = 2;
861 D(bug("[Wanderer:VolumeList] %s: Re-Parsing backdrop file for '%s'\n", __PRETTY_FUNCTION__, volentry->ie_IconNode.ln_Name));
863 /* Re-add entries which did not change and create entries for new left-out entries */
864 /* This function removes objects from leftoutlist */
865 IconWindowVolumeList__Func_ParseBackdrop(self, volentry, &leftoutList);
869 /* Destroy entries which where not re-added */
870 ForeachNodeSafe(&leftoutList, entry, tmpentry)
872 if ((entry->ie_IconListEntry.type == ST_LINKFILE) || (entry->ie_IconListEntry.type == ST_LINKDIR))
874 D(bug("[Wanderer:VolumeList] %s: Destroying orphaned left-out entry '%s'\n", __PRETTY_FUNCTION__, entry->ie_IconNode.ln_Name));
875 Remove(&entry->ie_IconNode);
876 DoMethod(self, MUIM_IconList_DestroyEntry, entry);
882 /* Refresh entries for AppIcons */
885 struct AppIcon * appicon = NULL;
887 APTR lock = AppObjectsLock();
889 /* Reinsert existing, add new */
890 while ((appicon = GetNextAppIconLocked(appicon, lock)))
892 struct IconEntry * appentry = NULL;
894 ForeachNodeSafe(&iconifiedList, entry, tmpentry)
896 if (entry->ie_User1 == (APTR)appicon)
898 appentry = entry;
899 Remove((struct Node*)&entry->ie_IconNode);
900 D(bug("[Wanderer:VolumeList] %s: Reinserting '%s'\n", __PRETTY_FUNCTION__,
901 entry->ie_IconNode.ln_Name));
902 DoMethod(self, MUIM_Family_AddTail, (struct Node*)&entry->ie_IconNode);
903 break;
907 if (appentry == NULL)
909 struct DiskObject * appdo = AppIcon_GetDiskObject(appicon);
910 struct DiskObject * dupdo = DupDiskObject(appdo, TAG_DONE);
911 LayoutIconA(dupdo, _screen(self), NULL);
912 CONST_STRPTR label = AppIcon_GetLabel(appicon);
913 appentry = (struct IconEntry *)DoMethod(self,
914 MUIM_IconList_CreateEntry, (IPTR)"?APPICON?", (IPTR)label, (IPTR)NULL, (IPTR)dupdo, 0, (IPTR)NULL);
915 if (appentry)
917 appentry->ie_User1 = (APTR)appicon;
918 appentry->ie_IconNode.ln_Pri = 0;
919 appentry->ie_IconListEntry.type = ILE_TYPE_APPICON;
920 DoMethod(self, MUIM_Family_AddTail, (struct Node*)&appentry->ie_IconNode);
925 AppObjectsUnlock(lock);
927 /* Destroy entries which where not re-added */
928 ForeachNodeSafe(&iconifiedList, entry, tmpentry)
930 D(bug("[Wanderer:VolumeList] %s: Destroying old iconified entry '%s'\n",
931 __PRETTY_FUNCTION__, entry->ie_IconNode.ln_Name));
932 Remove(&entry->ie_IconNode);
933 DoMethod(self, MUIM_IconList_DestroyEntry, entry);
939 /* Network browser / User Files */
940 D(bug("[Wanderer:VolumeList] %s: Check if we should show NetworkBrowser Icon ..\n", __PRETTY_FUNCTION__));
942 GET(_app(self), MUIA_Wanderer_Prefs, &prefs);
944 if (prefs)
946 struct IconWindowVolumeList_DATA *volumel_data = (struct IconWindowVolumeList_DATA *)data;
948 GET(prefs, MUIA_IconWindowExt_NetworkBrowser_Show, &volumel_data->iwvcd_ShowNetworkBrowser);
950 #if defined(DEBUG_NETWORKBROWSER)
951 volumel_data->iwvcd_ShowNetworkBrowser = TRUE;
952 #endif
954 if (volumel_data->iwvcd_ShowNetworkBrowser)
956 if (Obj_NetworkIcon == NULL)
958 struct DiskObject *_nb_dob = NULL;
959 _nb_dob = GetIconTags
961 "ENV:SYS/def_NetworkHost",
962 ICONGETA_FailIfUnavailable, FALSE,
963 ICONGETA_Label, (IPTR)"Network Access..",
964 TAG_DONE
967 D(bug("[Wanderer:VolumeList] %s: NetworkBrowser Icon DOB @ 0x%p\n", __PRETTY_FUNCTION__, _nb_dob));
969 if (_nb_dob)
971 if ((Obj_NetworkIcon = (struct Node *)DoMethod(self, MUIM_IconList_CreateEntry, (IPTR)"?wanderer.networkbrowse?", (IPTR)"Network Access..", (IPTR)NULL, (IPTR)_nb_dob, 0, (IPTR)NULL)))
973 Obj_NetworkIcon->ln_Pri = 4; /// Network Access gets Priority 4 so its displayed after special dirs
974 // D(bug("[Wanderer:VolumeList] %s: NetworkBrowser Icon Entry @ 0x%p\n", __PRETTY_FUNCTION__, this_entry));
979 else
981 if (Obj_NetworkIcon != NULL)
983 DoMethod(self, MUIM_IconList_DestroyEntry, Obj_NetworkIcon);
987 GET(prefs, MUIA_IconWindowExt_UserFiles_ShowFilesFolder, &volumel_data->iwvcd_ShowUserFolder);
989 #if defined(DEBUG_SHOWUSERFILES)
990 volumel_data->iwvcd_ShowUserFolder = TRUE;
991 #endif
992 if (volumel_data->iwvcd_ShowUserFolder)
994 if (Obj_UserFilesIcon == NULL)
996 if (GetVar("SYS/Wanderer/userfiles.prefs", __icwc_intern_TxtBuff, TXTBUFF_LEN, GVF_GLOBAL_ONLY) != -1)
998 char * userfiles_path = NULL;
1000 D(bug("[Wanderer:VolumeList] %s: SYS/UserFilesLocation = '%s'\n", __PRETTY_FUNCTION__, __icwc_intern_TxtBuff));
1002 if ((userfiles_path = AllocVec(strlen(__icwc_intern_TxtBuff) + 1, MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
1004 struct DiskObject *_nb_dob = NULL;
1006 D(bug("[Wanderer:VolumeList] %s: UserFilesLocation Path storage @ 0x%p\n", __PRETTY_FUNCTION__, userfiles_path));
1008 strcpy(userfiles_path, __icwc_intern_TxtBuff);
1010 D(bug("[Wanderer:VolumeList] %s: UserFilesLocation Path storage contains '%s'\n", __PRETTY_FUNCTION__, userfiles_path));
1012 _nb_dob = GetIconTags
1014 "ENV:SYS/def_UserHome",
1015 ICONGETA_FailIfUnavailable, FALSE,
1016 ICONGETA_Label, (IPTR)"User Files..",
1017 TAG_DONE
1020 D(bug("[Wanderer:VolumeList] %s: UserFiles Icon DOB @ 0x%p\n", __PRETTY_FUNCTION__, _nb_dob));
1022 if (_nb_dob)
1024 if ((Obj_UserFilesIcon = (struct Node *)DoMethod(self, MUIM_IconList_CreateEntry, userfiles_path, (IPTR)"User Files..", (IPTR)NULL, (IPTR)_nb_dob, 0, (IPTR)NULL)))
1026 Obj_UserFilesIcon->ln_Pri = 5; /// Special dirs get Priority 5
1029 FreeVec(userfiles_path);
1034 else
1036 if (Obj_UserFilesIcon != NULL)
1038 DoMethod(self, MUIM_IconList_DestroyEntry, Obj_UserFilesIcon);
1043 else
1045 retVal = TRUE;
1046 DoMethod(self, MUIM_IconList_Clear);
1049 return retVal;
1052 /* Notes:
1053 * This handle only changes to .backdrop file. In theory we could just add notification on this file instead of whole root directory
1054 * but this file is not guaranteed to exist - meaning that leavout dune during "first" session would not be visible until reboot
1056 IPTR IconWindowVolumeList__HandleFSUpdate(Object *target, struct NotifyMessage *msg)
1058 struct List *iconList = NULL, fsLeftOutList;
1059 struct IconEntry *entry = NULL, *tmpEntry = NULL, *fsEntry = NULL;
1060 BOOL changed = FALSE;
1062 D(bug("[Wanderer:VolumeList]: %s(NotifyMessage @ %p -> '%s')\n", __PRETTY_FUNCTION__, msg, msg->nm_NReq->nr_Name));
1064 NEWLIST(&fsLeftOutList);
1066 D(bug("[Wanderer:VolumeList] %s: IconWindowVolumeList, IconList @ %p\n", __PRETTY_FUNCTION__, target));
1068 GET(target, MUIA_Family_List, &iconList);
1069 /* Find out which icon matches the volument that notified us */
1070 ForeachNode(iconList, entry)
1072 if ((entry->ie_IconListEntry.type == ST_ROOT)
1073 && (strncmp(entry->ie_IconNode.ln_Name, msg->nm_NReq->nr_Name, strlen(entry->ie_IconNode.ln_Name)) == 0))
1075 fsEntry = entry;
1076 break;
1080 if (fsEntry != NULL)
1082 D(bug("[Wanderer:VolumeList] %s: Processing .backdrop for entry @ %p '%s'\n", __PRETTY_FUNCTION__, fsEntry, fsEntry->ie_IconNode.ln_Name));
1084 /* Find other icons that are linked the the root icon */
1085 ForeachNodeSafe(iconList, entry,tmpEntry)
1087 if (((entry->ie_IconListEntry.type == ST_LINKFILE) || (entry->ie_IconListEntry.type == ST_LINKDIR)) && (entry->ie_IconListEntry.udata == fsEntry))
1089 D(bug("[Wanderer:VolumeList] %s: existing left-out entry @ %p '%s' for this volume\n", __PRETTY_FUNCTION__, entry, entry->ie_IconNode.ln_Name));
1090 Remove(&entry->ie_IconNode);
1091 AddTail(&fsLeftOutList, &entry->ie_IconNode);
1095 /* Parse .backdrop and add any of the existing icons back to family list */
1096 changed = IconWindowVolumeList__Func_ParseBackdrop(target, fsEntry, &fsLeftOutList);
1098 /* Destroy left-out entries which are no longer valid */
1099 ForeachNodeSafe(&fsLeftOutList, entry, tmpEntry)
1101 D(bug("[Wanderer:VolumeList] %s: Destroying orphaned entry @ %p '%s'\n", __PRETTY_FUNCTION__, entry, entry->ie_IconNode.ln_Name));
1102 Remove(&entry->ie_IconNode);
1103 DoMethod(target, MUIM_IconList_DestroyEntry, entry);
1104 changed = TRUE;
1107 /* Re-sort the list */
1108 if (changed)
1109 DoMethod(target, MUIM_IconList_Sort);
1112 return 0;
1115 IPTR IconWindowVolumeList__MUIM_IconList_CreateEntry(struct IClass *CLASS, Object *self, struct MUIP_IconList_CreateEntry *message)
1117 struct IconEntry *this_Icon = NULL;
1118 struct VolumeIcon_Private *volPrivate = NULL;
1119 struct Wanderer_FSHandler *_volumeIcon__FSNotifyHandler = NULL;
1121 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
1123 this_Icon = (struct IconEntry *)DoSuperMethodA(CLASS, self, (Msg) message);
1125 if (this_Icon)
1127 volPrivate = this_Icon->ie_IconListEntry.udata;
1129 D(bug("[Wanderer:VolumeList] %s: IconEntry '%s' Allocated @ %p, volPrivate @ %p\n", __PRETTY_FUNCTION__, this_Icon->ie_IconNode.ln_Name, this_Icon, volPrivate));
1131 if ((this_Icon->ie_IconListEntry.type == ST_ROOT) && (volPrivate && ((volPrivate->vip_FLags & (ICONENTRY_VOL_OFFLINE|ICONENTRY_VOL_DISABLED)) == 0)))
1133 if (((_volumeIcon__FSNotifyHandler = AllocMem(sizeof(struct Wanderer_FSHandler), MEMF_CLEAR)) != NULL))
1135 SETUP_INST_DATA;
1137 _volumeIcon__FSNotifyHandler->target = self;
1138 _volumeIcon__FSNotifyHandler->HandleFSUpdate = IconWindowVolumeList__HandleFSUpdate;
1139 volPrivate->vip_FSNotifyRequest.nr_Name = this_Icon->ie_IconNode.ln_Name;
1140 volPrivate->vip_FSNotifyRequest.nr_Flags = NRF_SEND_MESSAGE;
1141 volPrivate->vip_FSNotifyRequest.nr_stuff.nr_Msg.nr_Port = data->iwvcd_FSNotifyPort;
1142 volPrivate->vip_FSNotifyRequest.nr_UserData = (IPTR)_volumeIcon__FSNotifyHandler;
1143 _volumeIcon__FSNotifyHandler->fshn_Node.ln_Name = volPrivate->vip_FSNotifyRequest.nr_Name;
1145 if (StartNotify(&volPrivate->vip_FSNotifyRequest))
1147 D(bug("[Wanderer:VolumeList] %s: FSNotification setup", __PRETTY_FUNCTION__));
1149 else
1151 D(bug("[Wanderer:VolumeList] %s: FAILED to setup FSNotification", __PRETTY_FUNCTION__));
1152 FreeMem(_volumeIcon__FSNotifyHandler, sizeof(struct Wanderer_FSHandler));
1153 volPrivate->vip_FSNotifyRequest.nr_Name = NULL;
1154 volPrivate->vip_FSNotifyRequest.nr_UserData = (IPTR)NULL;
1156 D(bug(" for Volume '%s'\n", this_Icon->ie_IconNode.ln_Name));
1158 IconWindowVolumeList__Func_ParseBackdrop(self, this_Icon, NULL);
1161 return (IPTR)this_Icon;
1164 IPTR IconWindowVolumeList__MUIM_IconList_UpdateEntry(struct IClass *CLASS, Object *obj, struct MUIP_IconList_UpdateEntry *message)
1166 struct VolumeIcon_Private *volPrivate = NULL;
1167 struct IconEntry *this_Icon = NULL;
1169 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
1171 volPrivate = message->entry->ie_IconListEntry.udata;
1173 if (message->entry->ie_IconListEntry.type == ST_ROOT
1174 && (_volpriv(message->entry)->vip_FLags &
1175 (ICONENTRY_VOL_OFFLINE|ICONENTRY_VOL_DISABLED)) != 0)
1177 if (volPrivate->vip_FSNotifyRequest.nr_Name != NULL)
1179 EndNotify(&volPrivate->vip_FSNotifyRequest);
1181 FreeMem((struct Wanderer_FSHandler *)volPrivate->vip_FSNotifyRequest.nr_UserData, sizeof(struct Wanderer_FSHandler));
1182 volPrivate->vip_FSNotifyRequest.nr_Name = NULL;
1183 volPrivate->vip_FSNotifyRequest.nr_UserData = (IPTR)NULL;
1187 this_Icon = (struct IconEntry *)DoSuperMethodA(CLASS, obj, (Msg) message);
1189 return (IPTR)this_Icon;
1192 IPTR IconWindowVolumeList__MUIM_IconList_DestroyEntry(struct IClass *CLASS, Object *obj, struct MUIP_IconList_DestroyEntry *message)
1194 struct VolumeIcon_Private *volPrivate = NULL;
1195 IPTR rv = 0;
1197 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__));
1199 volPrivate = message->entry->ie_IconListEntry.udata;
1201 if ((message->entry->ie_IconListEntry.type == ST_ROOT))
1203 if (volPrivate->vip_FSNotifyRequest.nr_Name != NULL)
1205 EndNotify(&volPrivate->vip_FSNotifyRequest);
1206 FreeMem((struct Wanderer_FSHandler *)volPrivate->vip_FSNotifyRequest.nr_UserData, sizeof(struct Wanderer_FSHandler));
1207 volPrivate->vip_FSNotifyRequest.nr_Name = NULL;
1208 volPrivate->vip_FSNotifyRequest.nr_UserData = (IPTR)NULL;
1211 else if ((message->entry->ie_IconListEntry.type == ST_LINKFILE) || (message->entry->ie_IconListEntry.type == ST_LINKDIR))
1212 message->entry->ie_IconListEntry.udata = NULL;
1214 D(bug("[Wanderer:VolumeList] %s: causing parent class to dispose of '%s'\n", __PRETTY_FUNCTION__, message->entry->ie_IconNode.ln_Name));
1216 rv = DoSuperMethodA(CLASS, obj, (Msg) message);
1218 return rv;
1221 IPTR IconWindowVolumeList__MUIM_IconList_DrawEntry(struct IClass *CLASS, Object *self, struct MUIP_IconList_DrawEntry *message)
1223 D(bug("[Wanderer:Volumelist]: %s()\n", __PRETTY_FUNCTION__));
1225 /* If the Entry is an AppIcon, and it has a renderhook - use the hook to perform the rendering, otherwise fall back to our parent's handling */
1226 if (message->entry->ie_IconListEntry.type == ILE_TYPE_APPICON)
1228 if (AppIcon_Supports((struct AppIcon *)message->entry->ie_User1, WBAPPICONA_RenderHook))
1230 struct AppIconRenderMsg renderMsg;
1231 struct TagItem renderTags[] = {
1232 { ICONDRAWA_Frameless, TRUE },
1233 { ICONDRAWA_Borderless, TRUE },
1234 { ICONDRAWA_EraseBackground, FALSE },
1235 { TAG_DONE, }
1238 GET(self, MUIA_IconList_BufferRastport, &renderMsg.arm_RastPort);
1239 renderMsg.arm_Icon = message->entry->ie_DiskObj;
1240 renderMsg.arm_Label = message->entry->ie_TxtBuf_DisplayedLabel;
1242 renderMsg.arm_Left = message->entry->ie_IconX;
1243 renderMsg.arm_Top = message->entry->ie_IconY;
1244 renderMsg.arm_Width = message->entry->ie_IconWidth;
1245 renderMsg.arm_Height = message->entry->ie_IconHeight;
1247 renderMsg.arm_State = (message->entry->ie_Flags & ICONENTRY_FLAG_SELECTED) ? IDS_SELECTED : IDS_NORMAL;
1248 renderMsg.arm_Tags = renderTags;
1250 D(bug("[Wanderer:Volumelist] %s: Using AppIcon RenderHook for AppIcon 0x%p with DiskObj 0x%p and RastPort 0x%p\n",
1251 __PRETTY_FUNCTION__, message->entry->ie_User1, renderMsg.arm_Icon, renderMsg.arm_RastPort));
1252 D(bug("[Wanderer:Volumelist] %s: Render @ %d, %d (%d x %d pixels)\n", __PRETTY_FUNCTION__,
1253 renderMsg.arm_Left, renderMsg.arm_Top, renderMsg.arm_Width, renderMsg.arm_Height));
1255 AppIcon_CallRenderHook((struct AppIcon*)message->entry->ie_User1, &renderMsg);
1257 return TRUE;
1261 return DoSuperMethodA(CLASS, self, (Msg) message);
1264 IPTR IconWindowVolumeList__MUIM_IconList_PropagateEntryPos(struct IClass *CLASS, Object *obj,
1265 struct MUIP_IconList_PropagateEntryPos *message)
1268 if (message->entry->ie_IconListEntry.type == ILE_TYPE_APPICON)
1270 struct AppIcon * ai = (struct AppIcon *)message->entry->ie_User1;
1272 if (AppIcon_Supports(ai, WBAPPICONA_PropagatePosition))
1274 struct DiskObject * diskobj = AppIcon_GetDiskObject(ai);
1275 diskobj->do_CurrentX = message->entry->ie_IconX;
1276 diskobj->do_CurrentY = message->entry->ie_IconY;
1280 return DoSuperMethodA(CLASS, obj, (Msg) message);
1283 IPTR IconWindowVolumeList__MUIM_IconList_DrawEntryLabel(struct IClass *CLASS, Object *self, struct MUIP_IconList_DrawEntryLabel *message)
1285 D(bug("[Wanderer:Volumelist]: %s()\n", __PRETTY_FUNCTION__));
1287 if (message->entry->ie_IconListEntry.type == ILE_TYPE_APPICON)
1289 if (AppIcon_Supports((struct AppIcon *)message->entry->ie_User1, WBAPPICONA_RenderHook))
1290 return TRUE;
1293 return DoSuperMethodA(CLASS, self, (Msg) message);
1297 /*** Setup ******************************************************************/
1298 #ifdef __AROS__
1299 ICONWINDOWICONVOLUMELIST_CUSTOMCLASS
1301 IconWindowVolumeList, NULL, MUIC_IconVolumeList, NULL,
1302 OM_NEW, struct opSet *,
1303 OM_SET, struct opSet *,
1304 OM_GET, struct opGet *,
1305 MUIM_Setup, Msg,
1306 MUIM_Cleanup, Msg,
1307 MUIM_DrawBackground, struct MUIP_DrawBackground *,
1308 MUIM_HandleEvent, struct MUIP_HandleEvent *,
1309 MUIM_IconList_Update, struct MUIP_IconList_Update *,
1310 MUIM_IconList_CreateEntry, struct MUIP_IconList_CreateEntry *,
1311 MUIM_IconList_UpdateEntry, struct MUIP_IconList_UpdateEntry *,
1312 MUIM_IconList_DestroyEntry, struct MUIP_IconList_DestroyEntry *,
1313 MUIM_IconList_PropagateEntryPos, struct MUIP_IconList_PropagateEntryPos *,
1314 MUIM_IconList_DrawEntry, struct MUIP_IconList_DrawEntry *,
1315 MUIM_IconList_DrawEntryLabel, struct MUIP_IconList_DrawEntryLabel *
1317 #else
1318 ICONWINDOWICONVOLUMELIST_CUSTOMCLASS
1320 IconWindowVolumeList, NULL, NULL, IconVolumeList_Class,
1321 OM_NEW, struct opSet *,
1322 OM_SET, struct opSet *,
1323 OM_GET, struct opGet *,
1324 MUIM_Setup, Msg,
1325 MUIM_Cleanup, Msg,
1326 MUIM_DrawBackground, Msg,
1327 MUIM_HandleEvent, Msg,
1328 MUIM_IconList_Update, struct MUIP_IconList_Update *,
1329 MUIM_IconList_CreateEntry, struct MUIP_IconList_CreateEntry *,
1330 MUIM_IconList_UpdateEntry, struct MUIP_IconList_UpdateEntry *,
1331 MUIM_IconList_DestroyEntry, struct MUIP_IconList_DestroyEntry *,
1332 MUIM_IconList_PropagateEntryPos, struct MUIP_IconList_PropagateEntryPos *,
1333 MUIM_IconList_DrawEntry, struct MUIP_IconList_DrawEntry *,
1334 MUIM_IconList_DrawEntryLabel, struct MUIP_IconList_DrawEntryLabel *
1336 #endif