2 Copyright 2004-2010, The AROS Development Team. All rights reserved.
8 #include "portable_macros.h"
11 #define MUIMASTER_YES_INLINE_STDARG
14 //#define DEBUG_NETWORKBROWSER
15 //#define DEBUG_SHOWUSERFILES
16 #define TXTBUFF_LEN 1024
20 #include <aros/debug.h>
23 #include <exec/types.h>
24 #include <libraries/mui.h>
27 #include <zune/customclasses.h>
29 #include <zune_AROS/customclasses.h>
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>
41 #include <proto/dos.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
53 #ifndef _PROTO_INTUITION_H
54 #include <proto/intuition.h>
56 #include <proto/muimaster.h>
58 #include "Classes/iconlist.h"
59 #include "Classes/iconlist_attributes.h"
60 #include "Classes/icon_attributes.h"
63 #include "wandererprefs.h"
64 #include "iconwindow.h"
65 #include "iconwindow_iconlist.h"
72 #define D(x) if (DEBUG) x
74 #define bug DebugPrintF
83 extern struct IconWindow_BackFill_Descriptor
*iconwindow_BackFill_Active
;
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
;
98 struct Hook iwcd_ProcessIconListPrefs_hook
;
100 struct Hook
*iwcd_ProcessIconListPrefs_hook
;
103 IPTR iwcd_ViewPrefs_ID
;
104 Object
*iwcd_ViewPrefs_NotificationObject
;
106 struct Hook iwvcd_UpdateNetworkPrefs_hook
;
108 struct Hook
*iwvcd_UpdateNetworkPrefs_hook
;
111 IPTR iwvcd_ShowNetworkBrowser
;
112 IPTR iwvcd_ShowUserFolder
;
113 char *iwvcd_UserFolderPath
;
116 static char __icwc_intern_TxtBuff
[TXTBUFF_LEN
];
118 /*** Macros *****************************************************************/
119 #define SETUP_INST_DATA struct IconWindowVolumeList_DATA *data = INST_DATA(CLASS, self)
121 /*** Hook functions *********************************************************/
122 ///IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc()
125 void, IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc
,
126 AROS_UFHA(struct Hook
*, hook
, A0
),
127 AROS_UFHA(APTR
*, obj
, A2
),
128 AROS_UFHA(IPTR
*, param
, A1
)
132 HOOKPROTO(IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc
, void, APTR
*obj
, IPTR
*param
)
137 /* Get our private data */
138 Object
*self
= ( Object
*)obj
;
139 IPTR CHANGED_ATTRIB
= *param
;
140 Class
*CLASS
= OCLASS(self
);
144 Object
*prefs
= NULL
;
146 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
148 GET(_app(self
), MUIA_Wanderer_Prefs
, &prefs
);
152 IPTR attrib_Current
, attrib_Prefs
, prefs_Processing
= 0;
153 BOOL options_changed
= FALSE
;
155 D(bug("[Wanderer:VolumeList] %s: Setting IconList options ..\n", __PRETTY_FUNCTION__
));
157 GET(prefs
, MUIA_WandererPrefs_Processing
, &prefs_Processing
);
159 switch (CHANGED_ATTRIB
)
161 case MUIA_IconList_IconListMode
:
162 GET(self
, MUIA_IconList_IconListMode
, &attrib_Current
);
164 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_IconListMode
)) != -1) &&
165 (attrib_Current
!= attrib_Prefs
))
167 D(bug("[Wanderer:VolumeList] %s: IconList ListMode changed - updating ..\n", __PRETTY_FUNCTION__
));
168 options_changed
= TRUE
;
169 if (prefs_Processing
)
171 NNSET(self
, MUIA_IconList_IconListMode
, attrib_Prefs
);
175 SET(self
, MUIA_IconList_IconListMode
, attrib_Prefs
);
180 case MUIA_IconList_LabelText_Mode
:
181 GET(self
, MUIA_IconList_LabelText_Mode
, &attrib_Current
);
183 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_Mode
)) != -1) &&
184 (attrib_Current
!= attrib_Prefs
))
186 D(bug("[Wanderer:VolumeList] %s: IconList TextRenderMode changed - updating ..\n", __PRETTY_FUNCTION__
));
187 options_changed
= TRUE
;
188 if (prefs_Processing
)
190 NNSET(self
, MUIA_IconList_LabelText_Mode
, attrib_Prefs
);
194 SET(self
, MUIA_IconList_LabelText_Mode
, attrib_Prefs
);
199 case MUIA_IconList_LabelText_MaxLineLen
:
200 GET(self
, MUIA_IconList_LabelText_MaxLineLen
, &attrib_Current
);
202 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_MaxLineLen
)) != -1) &&
203 (attrib_Current
!= attrib_Prefs
))
205 D(bug("[Wanderer:VolumeList] %s: IconList Max Text Length changed - updating ..\n", __PRETTY_FUNCTION__
));
206 options_changed
= TRUE
;
207 if (prefs_Processing
)
209 NNSET(self
, MUIA_IconList_LabelText_MaxLineLen
, attrib_Prefs
);
213 SET(self
, MUIA_IconList_LabelText_MaxLineLen
, attrib_Prefs
);
218 case MUIA_IconList_LabelText_MultiLine
:
219 GET(self
, MUIA_IconList_LabelText_MultiLine
, &attrib_Current
);
221 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_MultiLine
)) != -1) &&
222 (attrib_Current
!= attrib_Prefs
))
224 D(bug("[Wanderer:VolumeList] %s: IconList Multi-Line changed - updating ..\n", __PRETTY_FUNCTION__
));
225 options_changed
= TRUE
;
226 if (prefs_Processing
)
228 NNSET(self
, MUIA_IconList_LabelText_MultiLine
, attrib_Prefs
);
232 SET(self
, MUIA_IconList_LabelText_MultiLine
, attrib_Prefs
);
237 case MUIA_IconList_LabelText_MultiLineOnFocus
:
238 GET(self
, MUIA_IconList_LabelText_MultiLineOnFocus
, &attrib_Current
);
240 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_MultiLineOnFocus
)) != -1) &&
241 (attrib_Current
!= attrib_Prefs
))
243 D(bug("[Wanderer:VolumeList] %s: Multi-Line on Focus changed - updating ..\n", __PRETTY_FUNCTION__
));
244 options_changed
= TRUE
;
245 if (prefs_Processing
)
247 NNSET(self
, MUIA_IconList_LabelText_MultiLineOnFocus
, attrib_Prefs
);
251 SET(self
, MUIA_IconList_LabelText_MultiLineOnFocus
, attrib_Prefs
);
256 case MUIA_IconList_Icon_HorizontalSpacing
:
257 GET(self
, MUIA_IconList_Icon_HorizontalSpacing
, &attrib_Current
);
259 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_Icon_HorizontalSpacing
)) != -1) &&
260 (attrib_Current
!= attrib_Prefs
))
262 D(bug("[Wanderer:VolumeList] %s: Icon Horizontal Spacing changed - updating ..\n", __PRETTY_FUNCTION__
));
263 options_changed
= TRUE
;
264 if (prefs_Processing
)
266 NNSET(self
, MUIA_IconList_Icon_HorizontalSpacing
, attrib_Prefs
);
270 SET(self
, MUIA_IconList_Icon_HorizontalSpacing
, attrib_Prefs
);
275 case MUIA_IconList_Icon_VerticalSpacing
:
276 GET(self
, MUIA_IconList_Icon_VerticalSpacing
, &attrib_Current
);
278 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_Icon_VerticalSpacing
)) != -1) &&
279 (attrib_Current
!= attrib_Prefs
))
281 D(bug("[Wanderer:VolumeList] %s: Icon Vertical Spacing changed - updating ..\n", __PRETTY_FUNCTION__
));
282 options_changed
= TRUE
;
283 if (prefs_Processing
)
285 NNSET(self
, MUIA_IconList_Icon_VerticalSpacing
, attrib_Prefs
);
289 SET(self
, MUIA_IconList_Icon_VerticalSpacing
, attrib_Prefs
);
294 case MUIA_IconList_Icon_ImageSpacing
:
295 GET(self
, MUIA_IconList_Icon_ImageSpacing
, &attrib_Current
);
297 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_Icon_ImageSpacing
)) != -1) &&
298 (attrib_Current
!= attrib_Prefs
))
300 D(bug("[Wanderer:VolumeList] %s: Icon Label Image Spacing changed - updating ..\n", __PRETTY_FUNCTION__
));
301 options_changed
= TRUE
;
302 if (prefs_Processing
)
304 NNSET(self
, MUIA_IconList_Icon_ImageSpacing
, attrib_Prefs
);
308 SET(self
, MUIA_IconList_Icon_ImageSpacing
, attrib_Prefs
);
313 case MUIA_IconList_LabelText_HorizontalPadding
:
314 GET(self
, MUIA_IconList_LabelText_HorizontalPadding
, &attrib_Current
);
316 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_HorizontalPadding
)) != -1) &&
317 (attrib_Current
!= attrib_Prefs
))
319 D(bug("[Wanderer:VolumeList] %s: Icon Label Horizontal Padding changed - updating ..\n", __PRETTY_FUNCTION__
));
320 options_changed
= TRUE
;
321 if (prefs_Processing
)
323 NNSET(self
, MUIA_IconList_LabelText_HorizontalPadding
, attrib_Prefs
);
327 SET(self
, MUIA_IconList_LabelText_HorizontalPadding
, attrib_Prefs
);
332 case MUIA_IconList_LabelText_VerticalPadding
:
333 GET(self
, MUIA_IconList_LabelText_VerticalPadding
, &attrib_Current
);
335 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_VerticalPadding
)) != -1) &&
336 (attrib_Current
!= attrib_Prefs
))
338 D(bug("[Wanderer:VolumeList] %s: Icon Label Vertical Padding changed - updating ..\n", __PRETTY_FUNCTION__
));
339 options_changed
= TRUE
;
340 if (prefs_Processing
)
342 NNSET(self
, MUIA_IconList_LabelText_VerticalPadding
, attrib_Prefs
);
346 SET(self
, MUIA_IconList_LabelText_VerticalPadding
, attrib_Prefs
);
351 case MUIA_IconList_LabelText_BorderWidth
:
352 GET(self
, MUIA_IconList_LabelText_BorderWidth
, &attrib_Current
);
354 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_BorderWidth
)) != -1) &&
355 (attrib_Current
!= attrib_Prefs
))
357 D(bug("[Wanderer:VolumeList] %s: Icon Label Border Width changed - updating ..\n", __PRETTY_FUNCTION__
));
358 options_changed
= TRUE
;
359 if (prefs_Processing
)
361 NNSET(self
, MUIA_IconList_LabelText_BorderWidth
, attrib_Prefs
);
365 SET(self
, MUIA_IconList_LabelText_BorderWidth
, attrib_Prefs
);
370 case MUIA_IconList_LabelText_BorderHeight
:
371 GET(self
, MUIA_IconList_LabelText_BorderHeight
, &attrib_Current
);
373 if (((attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_BorderHeight
)) != -1) &&
374 (attrib_Current
!= attrib_Prefs
))
376 D(bug("[Wanderer:VolumeList] %s: Icon Label Border Height changed - updating ..\n", __PRETTY_FUNCTION__
));
377 options_changed
= TRUE
;
378 if (prefs_Processing
)
380 NNSET(self
, MUIA_IconList_LabelText_BorderHeight
, attrib_Prefs
);
384 SET(self
, MUIA_IconList_LabelText_BorderHeight
, attrib_Prefs
);
390 D(bug("[Wanderer:VolumeList] %s: Unhandled change\n", __PRETTY_FUNCTION__
));
396 if (!(prefs_Processing
))
398 D(bug("[Wanderer:VolumeList] %s: IconList Options have changed, causing an update ..\n", __PRETTY_FUNCTION__
));
399 DoMethod(self
, MUIM_IconList_Update
);
400 DoMethod(self
, MUIM_IconList_Sort
);
402 else if (data
->iwcd_IconWindow
)
404 SET(data
->iwcd_IconWindow
, MUIA_IconWindow_Changed
, TRUE
);
411 MakeStaticHook(Hook_ProcessIconListPrefsFunc
,IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc
);
415 ///IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc()
418 void, IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc
,
419 AROS_UFHA(struct Hook
*, hook
, A0
),
420 AROS_UFHA(APTR
*, obj
, A2
),
421 AROS_UFHA(APTR
, param
, A1
)
425 HOOKPROTO(IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc
, void, APTR
*obj
, APTR param
)
430 /* Get our private data */
431 Object
*self
= ( Object
*)obj
;
432 Object
*prefs
= NULL
;
433 Class
*CLASS
= *( Class
**)param
;
437 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
439 GET(_app(self
), MUIA_Wanderer_Prefs
, &prefs
);
443 BOOL options_changed
= FALSE
;
444 IPTR prefs_Processing
= 0;
446 GET(prefs
, MUIA_WandererPrefs_Processing
, &prefs_Processing
);
448 IPTR current_ShowNetwork
= 0;
449 IPTR prefs_ShowNetwork
= 0;
451 D(bug("[Wanderer:VolumeList] %s: Setting ROOT view Network options ..\n", __PRETTY_FUNCTION__
));
453 GET(self
, MUIA_IconWindowExt_NetworkBrowser_Show
, ¤t_ShowNetwork
);
455 D(bug("[Wanderer:VolumeList] %s: Current = %d\n", __PRETTY_FUNCTION__
, current_ShowNetwork
));
457 GET(prefs
, MUIA_IconWindowExt_NetworkBrowser_Show
, &prefs_ShowNetwork
);
459 D(bug("[Wanderer:VolumeList] %s: Prefs = %d\n", __PRETTY_FUNCTION__
, prefs_ShowNetwork
));
461 if ((BOOL
)current_ShowNetwork
!= (BOOL
)prefs_ShowNetwork
)
463 D(bug("[Wanderer:VolumeList] %s: ROOT view Network prefs changed - updating ..\n", __PRETTY_FUNCTION__
));
464 options_changed
= TRUE
;
465 ((struct IconWindowVolumeList_DATA
*)data
)->iwvcd_ShowNetworkBrowser
= prefs_ShowNetwork
;
467 if ((options_changed
) && !(prefs_Processing
))
469 D(bug("[Wanderer:VolumeList] %s: Network prefs changed, causing an update ..\n", __PRETTY_FUNCTION__
));
470 DoMethod(self
, MUIM_IconList_Update
);
471 DoMethod(self
, MUIM_IconList_Sort
);
473 else if (data
->iwcd_IconWindow
)
475 SET(data
->iwcd_IconWindow
, MUIA_IconWindow_Changed
, TRUE
);
481 MakeStaticHook(Hook_UpdateNetworkPrefsFunc
,IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc
);
484 #define BDRPLINELEN_MAX 1024
485 BOOL
IconWindowVolumeList__Func_ParseBackdrop(Object
*self
, struct IconEntry
*bdrp_direntry
, struct List
* entryList
)
487 BPTR bdrp_lock
= (BPTR
)NULL
;
488 char *bdrp_file
= NULL
, *linebuf
= NULL
, *bdrp_fullfile
= NULL
, *bdrp_namepart
= NULL
;
489 struct DiskObject
*bdrp_currfile_dob
= NULL
;
492 char *bdrp_dir
= bdrp_direntry
->ie_IconListEntry
.label
;
494 if ((bdrp_dir
== NULL
) || (bdrp_dir
[strlen(bdrp_dir
) - 1] != ':'))
497 D(bug("[Wanderer:VolumeList] %s('%s')\n", __PRETTY_FUNCTION__
, bdrp_dir
));
499 if ((bdrp_file
= AllocVec(strlen(bdrp_dir
) + 9 + 1, MEMF_CLEAR
|MEMF_PUBLIC
)) != NULL
)
501 sprintf(bdrp_file
, "%s.backdrop", bdrp_dir
);
502 if ((bdrp_lock
= Open(bdrp_file
, MODE_OLDFILE
)))
504 D(bug("[Wanderer:VolumeList] %s: Loading backdrop file: '%s'\n", __PRETTY_FUNCTION__
, bdrp_file
));
506 if ((linebuf
= AllocMem(BDRPLINELEN_MAX
, MEMF_PUBLIC
)) != NULL
)
508 while (FGets(bdrp_lock
, linebuf
, BDRPLINELEN_MAX
))
514 linelen
= strlen(linebuf
) - 1; /* drop the newline char */
515 linebuf
[linelen
] = '\0';
517 if ((bdrp_fullfile
= AllocVec(linelen
+ strlen(bdrp_dir
), MEMF_CLEAR
|MEMF_PUBLIC
)) != NULL
)
521 sprintf(bdrp_fullfile
, "%s%s", bdrp_dir
, &linebuf
[1]);
523 struct FileInfoBlock
*lofFIB
= AllocDosObject(DOS_FIB
, NULL
);
526 BPTR lofLock
= (BPTR
)NULL
;
527 if ((lofLock
= Lock(bdrp_fullfile
, SHARED_LOCK
)) != NULL
)
529 char *tmpbdrp_file
= NULL
;
530 int tmpbdrp_len
= strlen(bdrp_fullfile
) + 128;
531 if ((tmpbdrp_file
= AllocVec(tmpbdrp_len
, MEMF_CLEAR
|MEMF_PUBLIC
)) != NULL
)
533 if (NameFromLock(lofLock
, tmpbdrp_file
, tmpbdrp_len
) != 0)
535 FreeVec(bdrp_fullfile
);
536 bdrp_fullfile
= tmpbdrp_file
;
539 FreeVec(tmpbdrp_file
);
541 if (Examine(lofLock
, lofFIB
))
543 if (lofFIB
->fib_DirEntryType
== ST_FILE
)
545 lofTYPE
= ST_LINKFILE
;
547 else if (lofFIB
->fib_DirEntryType
== ST_USERDIR
)
549 lofTYPE
= ST_LINKDIR
;
554 FreeDosObject(DOS_FIB
, lofFIB
);
557 bdrp_namepart
= FilePart(bdrp_fullfile
);
559 struct IconEntry
*this_entry
= NULL
, *iconNode
= NULL
, *tmpentry
= NULL
;
561 if (entryList
!= NULL
)
563 D(bug("[Wanderer:VolumeList] %s: Checking for existing entry in list @ 0x%p\n", __PRETTY_FUNCTION__
, entryList
));
564 ForeachNodeSafe(entryList
, iconNode
, tmpentry
)
566 if (strcmp(iconNode
->ie_IconNode
.ln_Name
, bdrp_fullfile
) == 0)
568 this_entry
= iconNode
;
569 Remove((struct Node
*)&iconNode
->ie_IconNode
);
570 iconNode
->ie_IconListEntry
.udata
= bdrp_direntry
;
571 D(bug("[Wanderer:VolumeList] %s: Reinserting '%s'\n", __PRETTY_FUNCTION__
, iconNode
->ie_IconNode
.ln_Name
));
572 DoMethod(self
, MUIM_Family_AddTail
, (struct Node
*)&iconNode
->ie_IconNode
);
578 if (this_entry
== NULL
)
580 //bug("[Wanderer:VolumeList] %s: Checking for existing entry in iconlist\n", __PRETTY_FUNCTION__);
582 bdrp_currfile_dob
= GetIconTags
585 ICONGETA_FailIfUnavailable
, FALSE
,
586 ICONGETA_Label
, bdrp_namepart
,
590 D(bug("[Wanderer:VolumeList] %s: LEAVEOUT Icon '%s' ('%s') DOB @ 0x%p\n", __PRETTY_FUNCTION__
, bdrp_fullfile
, bdrp_namepart
, bdrp_currfile_dob
));
592 if (bdrp_currfile_dob
)
594 if ((this_entry
= (struct IconEntry
*)DoMethod(self
, MUIM_IconList_CreateEntry
, (IPTR
)bdrp_fullfile
, (IPTR
)bdrp_namepart
, (IPTR
)NULL
, (IPTR
)bdrp_currfile_dob
, 0)))
596 this_entry
->ie_IconNode
.ln_Pri
= 1;
597 this_entry
->ie_IconListEntry
.type
= lofTYPE
;
598 this_entry
->ie_IconListEntry
.udata
= bdrp_direntry
;
599 DoMethod(self
, MUIM_Family_AddTail
, (struct Node
*)&this_entry
->ie_IconNode
);
607 FreeMem(linebuf
, BDRPLINELEN_MAX
);
617 /*** Methods ****************************************************************/
619 Object
*IconWindowVolumeList__OM_NEW(Class
*CLASS
, Object
*self
, struct opSet
*message
)
621 IPTR _newIconList__FSNotifyPort
= 0;
623 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
625 _newIconList__FSNotifyPort
= GetTagData(MUIA_Wanderer_FileSysNotifyPort
, (IPTR
) NULL
, message
->ops_AttrList
);
627 self
= (Object
*) DoSuperNewTags
631 TAG_MORE
, (IPTR
) message
->ops_AttrList
637 D(bug("[Wanderer:VolumeList] %s: SELF = 0x%p\n", __PRETTY_FUNCTION__
, self
));
640 data
->iwcd_ProcessIconListPrefs_hook
.h_Entry
= ( HOOKFUNC
)IconWindowVolumeList__HookFunc_ProcessIconListPrefsFunc
;
642 data
->iwcd_ProcessIconListPrefs_hook
= &Hook_ProcessIconListPrefsFunc
;
651 IPTR
IconWindowVolumeList__OM_SET(Class
*CLASS
, Object
*self
, struct opSet
*message
)
655 struct TagItem
*tstate
= message
->ops_AttrList
, *tag
;
657 while ((tag
= NextTagItem((const struct TagItem
**)&tstate
)) != NULL
)
661 case MUIA_Background
:
663 D(bug("[Wanderer:VolumeList] %s: MUIA_Background\n", __PRETTY_FUNCTION__
));
666 case MUIA_IconWindow_Window
:
668 D(bug("[Wanderer:VolumeList] %s: MUIA_IconWindow_Window @ %p\n", __PRETTY_FUNCTION__
, tag
->ti_Data
));
669 data
->iwcd_IconWindow
= (Object
*)tag
->ti_Data
;
672 case MUIA_IconList_BufferRastport
:
674 D(bug("[Wanderer:VolumeList] %s: MUIA_IconList_BufferRastport @ %p\n", __PRETTY_FUNCTION__
, tag
->ti_Data
));
675 data
->iwcd_RastPort
= (struct RastPort
*)tag
->ti_Data
;
680 return DoSuperMethodA(CLASS
, self
, (Msg
) message
);
685 IPTR
IconWindowVolumeList__OM_GET(Class
*CLASS
, Object
*self
, struct opGet
*message
)
688 IPTR
*store
= message
->opg_Storage
;
691 switch (message
->opg_AttrID
)
694 *store
= (IPTR
)WIWVLVERS
;
698 *store
= (IPTR
)WIWVLREV
;
702 rv
= DoSuperMethodA(CLASS
, self
, (Msg
) message
);
709 ///IconWindowVolumeList__MUIM_Setup()
710 IPTR IconWindowVolumeList__MUIM_Setup
712 Class
*CLASS
, Object
*self
, Msg message
717 Object
*prefs
= NULL
;
719 if (!DoSuperMethodA(CLASS
, self
, message
)) return FALSE
;
721 GET(_app(self
), MUIA_Wanderer_Prefs
, &prefs
);
725 /* Set our initial options */
728 GET(_win(self
), MUIA_IconWindow_BackgroundAttrib
, &data
->iwcd_ViewPrefs_ID
);
729 D(bug("[Wanderer:VolumeList] %s: Window Background = '%s'\n", __PRETTY_FUNCTION__
, data
->iwcd_ViewPrefs_ID
));
730 data
->iwcd_ViewPrefs_NotificationObject
= (Object
*)DoMethod(prefs
,
731 MUIM_WandererPrefs_ViewSettings_GetNotifyObject
,
732 data
->iwcd_ViewPrefs_ID
);
734 D(bug("[Wanderer:VolumeList] %s: Background Notification Obj @ 0x%p\n", __PRETTY_FUNCTION__
, data
->iwcd_ViewPrefs_NotificationObject
));
736 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_IconListMode
);
737 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_IconListMode
))) SET(self
, MUIA_IconList_IconListMode
, attrib_Prefs
);
739 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_Mode
);
740 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_Mode
))) SET(self
, MUIA_IconList_LabelText_Mode
, attrib_Prefs
);
742 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_MaxLineLen
);
743 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_MaxLineLen
))) SET(self
, MUIA_IconList_LabelText_MaxLineLen
, attrib_Prefs
);
745 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_MultiLine
);
746 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_MultiLine
))) SET(self
, MUIA_IconList_LabelText_MultiLine
, attrib_Prefs
);
748 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_MultiLineOnFocus
);
749 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_MultiLineOnFocus
))) SET(self
, MUIA_IconList_LabelText_MultiLineOnFocus
, attrib_Prefs
);
751 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_Icon_HorizontalSpacing
);
752 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_Icon_HorizontalSpacing
))) SET(self
, MUIA_IconList_Icon_HorizontalSpacing
, attrib_Prefs
);
754 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_Icon_VerticalSpacing
);
755 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_Icon_VerticalSpacing
))) SET(self
, MUIA_IconList_Icon_VerticalSpacing
, attrib_Prefs
);
757 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_Icon_ImageSpacing
);
758 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_Icon_ImageSpacing
))) SET(self
, MUIA_IconList_Icon_ImageSpacing
, attrib_Prefs
);
760 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_HorizontalPadding
);
761 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_HorizontalPadding
))) SET(self
, MUIA_IconList_LabelText_HorizontalPadding
, attrib_Prefs
);
763 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_VerticalPadding
);
764 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_VerticalPadding
))) SET(self
, MUIA_IconList_LabelText_VerticalPadding
, attrib_Prefs
);
766 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_BorderWidth
);
767 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_BorderWidth
))) SET(self
, MUIA_IconList_LabelText_BorderWidth
, attrib_Prefs
);
769 attrib_Prefs
= DoMethod(prefs
, MUIM_WandererPrefs_ViewSettings_GetAttribute
, data
->iwcd_ViewPrefs_ID
, MUIA_IconList_LabelText_BorderHeight
);
770 if ((attrib_Prefs
!= (IPTR
)-1) && (attrib_Prefs
!= XGET(self
, MUIA_IconList_LabelText_BorderHeight
))) SET(self
, MUIA_IconList_LabelText_BorderHeight
, attrib_Prefs
);
772 /* Configure notifications incase they get updated =) */
775 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_IconListMode
, MUIV_EveryTime
,
777 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_IconListMode
782 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_Mode
, MUIV_EveryTime
,
784 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_Mode
789 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_MaxLineLen
, MUIV_EveryTime
,
791 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_MaxLineLen
796 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_MultiLine
, MUIV_EveryTime
,
798 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_MultiLine
803 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_MultiLineOnFocus
, MUIV_EveryTime
,
805 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_MultiLineOnFocus
810 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_Icon_HorizontalSpacing
, MUIV_EveryTime
,
812 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_Icon_HorizontalSpacing
817 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_Icon_VerticalSpacing
, MUIV_EveryTime
,
819 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_Icon_VerticalSpacing
824 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_Icon_ImageSpacing
, MUIV_EveryTime
,
826 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_Icon_ImageSpacing
831 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_HorizontalPadding
, MUIV_EveryTime
,
833 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_HorizontalPadding
838 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_VerticalPadding
, MUIV_EveryTime
,
840 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_VerticalPadding
845 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_BorderWidth
, MUIV_EveryTime
,
847 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_BorderWidth
852 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_Notify
, MUIA_IconList_LabelText_BorderHeight
, MUIV_EveryTime
,
854 MUIM_CallHook
, &data
->iwcd_ProcessIconListPrefs_hook
, (IPTR
)MUIA_IconList_LabelText_BorderHeight
861 ((struct IconWindowVolumeList_DATA
*)data
)->iwvcd_UpdateNetworkPrefs_hook
.h_Entry
= ( HOOKFUNC
)IconWindowVolumeList__HookFunc_UpdateNetworkPrefsFunc
;
863 ((struct IconWindowVolumeList_DATA
*)data
)->iwvcd_UpdateNetworkPrefs_hook
= &Hook_UpdateNetworkPrefsFunc
;
868 prefs
, MUIM_Notify
, MUIA_IconWindowExt_NetworkBrowser_Show
, MUIV_EveryTime
,
870 MUIM_CallHook
, &((struct IconWindowVolumeList_DATA
*)data
)->iwvcd_UpdateNetworkPrefs_hook
, (IPTR
)CLASS
874 if (muiRenderInfo(self
))
876 D(bug("[Wanderer:VolumeList] %s: Setting up EventHandler for (IDCMP_DISKINSERTED | IDCMP_DISKREMOVED)\n", __PRETTY_FUNCTION__
));
878 data
->iwcd_EventHandlerNode
.ehn_Priority
= 1;
879 data
->iwcd_EventHandlerNode
.ehn_Flags
= MUI_EHF_GUIMODE
;
880 data
->iwcd_EventHandlerNode
.ehn_Object
= self
;
881 data
->iwcd_EventHandlerNode
.ehn_Class
= CLASS
;
882 data
->iwcd_EventHandlerNode
.ehn_Events
= IDCMP_DISKINSERTED
| IDCMP_DISKREMOVED
;
884 DoMethod(_win(self
), MUIM_Window_AddEventHandler
, &data
->iwcd_EventHandlerNode
);
888 D(bug("[Wanderer:VolumeList] %s: Couldnt add IDCMP EventHandler!\n", __PRETTY_FUNCTION__
));
891 D(bug("[Wanderer:VolumeList] %s: Setup complete!\n", __PRETTY_FUNCTION__
));
897 ///IconWindowVolumeList__MUIM_Cleanup()
898 IPTR IconWindowVolumeList__MUIM_Cleanup
900 Class
*CLASS
, Object
*self
, Msg message
905 Object
*prefs
= NULL
;
907 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
908 GET(_app(self
), MUIA_Wanderer_Prefs
, &prefs
);
914 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_IconListMode
, (IPTR
)self
919 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_Mode
, (IPTR
)self
924 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_MaxLineLen
, (IPTR
)self
929 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_MultiLine
, (IPTR
)self
934 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_MultiLineOnFocus
, (IPTR
)self
939 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_Icon_HorizontalSpacing
, (IPTR
)self
944 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_Icon_VerticalSpacing
, (IPTR
)self
949 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_Icon_ImageSpacing
, (IPTR
)self
954 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_HorizontalPadding
, (IPTR
)self
959 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_VerticalPadding
, (IPTR
)self
964 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_BorderWidth
, (IPTR
)self
969 data
->iwcd_ViewPrefs_NotificationObject
, MUIM_KillNotifyObj
, MUIA_IconList_LabelText_BorderHeight
, (IPTR
)self
978 MUIM_KillNotifyObj
, MUIA_IconWindowExt_NetworkBrowser_Show
, (IPTR
) self
981 D(bug("[Wanderer:VolumeList] %s: Removing Disk Event Handler\n", __PRETTY_FUNCTION__
));
982 DoMethod(_win(self
), MUIM_Window_RemEventHandler
, &data
->iwcd_EventHandlerNode
);
984 return DoSuperMethodA(CLASS
, self
, message
);
988 ///IconWindowVolumeList__MUIM_HandleEvent()
989 IPTR IconWindowVolumeList__MUIM_HandleEvent
991 Class
*CLASS
, Object
*self
, struct MUIP_HandleEvent
*message
996 struct IntuiMessage
*imsg
= message
->imsg
;
998 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
1000 if(imsg
->Class
== IDCMP_DISKINSERTED
)
1002 D(bug("[Wanderer:VolumeList] %s: IDCMP_DISKINSERTED\n", __PRETTY_FUNCTION__
));
1003 DoMethod(self
, MUIM_IconList_Update
);
1004 DoMethod(self
, MUIM_IconList_Sort
);
1005 return(MUI_EventHandlerRC_Eat
);
1007 else if (imsg
->Class
== IDCMP_DISKREMOVED
)
1009 D(bug("[Wanderer:VolumeList] %s: IDCMP_DISKREMOVED\n", __PRETTY_FUNCTION__
));
1010 DoMethod(self
, MUIM_IconList_Update
);
1011 DoMethod(self
, MUIM_IconList_Sort
);
1012 return(MUI_EventHandlerRC_Eat
);
1018 ///IconWindowVolumeList__MUIM_DrawBackground()
1019 IPTR IconWindowVolumeList__MUIM_DrawBackground
1021 Class
*CLASS
, Object
*self
, struct MUIP_DrawBackground
*message
1026 IPTR retVal
= (IPTR
)TRUE
;
1028 struct RastPort
*DrawBackGround_RastPort
;
1029 struct IconWindowBackFillMsg DrawBackGround_BackFillMsg
;
1031 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
1033 if ((iconwindow_BackFill_Active
== NULL
) ||
1034 (data
->iwcd_IconWindow
== NULL
))
1036 D(bug("[Wanderer:VolumeList] %s: No Backfill support/Window not set .. causing parent class to render\n", __PRETTY_FUNCTION__
));
1037 goto iwc_ParentBackground
;
1040 DrawBackGround_RastPort
= _rp(self
);
1042 if ((data
->iwcd_RastPort
!= NULL
) && (DrawBackGround_RastPort
!= data
->iwcd_RastPort
))
1044 DrawBackGround_RastPort
= data
->iwcd_RastPort
;
1046 DrawBackGround_BackFillMsg
.AreaBounds
.MinX
= 0;
1047 DrawBackGround_BackFillMsg
.AreaBounds
.MinY
= 0;
1048 DrawBackGround_BackFillMsg
.AreaBounds
.MaxX
= _mwidth(self
);
1049 DrawBackGround_BackFillMsg
.AreaBounds
.MaxY
= _mheight(self
);
1051 DrawBackGround_BackFillMsg
.DrawBounds
.MinX
= message
->left
- _mleft(self
);
1052 DrawBackGround_BackFillMsg
.DrawBounds
.MinY
= message
->top
- _mtop(self
);
1053 DrawBackGround_BackFillMsg
.DrawBounds
.MaxX
= message
->width
;
1054 DrawBackGround_BackFillMsg
.DrawBounds
.MaxY
= message
->height
;
1058 DrawBackGround_BackFillMsg
.AreaBounds
.MinX
= _mleft(self
);
1059 DrawBackGround_BackFillMsg
.AreaBounds
.MinY
= _mtop(self
);
1060 DrawBackGround_BackFillMsg
.AreaBounds
.MaxX
= (_mleft(self
) + _mwidth(self
));
1061 DrawBackGround_BackFillMsg
.AreaBounds
.MaxY
= (_mtop(self
) + _mheight(self
));
1063 DrawBackGround_BackFillMsg
.DrawBounds
.MinX
= message
->left
;
1064 DrawBackGround_BackFillMsg
.DrawBounds
.MinY
= message
->top
;
1065 DrawBackGround_BackFillMsg
.DrawBounds
.MaxX
= (message
->left
+ message
->width
);
1066 DrawBackGround_BackFillMsg
.DrawBounds
.MaxY
= (message
->top
+ message
->height
);
1069 DrawBackGround_BackFillMsg
.Layer
= DrawBackGround_RastPort
->Layer
;
1071 /* Offset into source image (ala scroll bar position) */
1072 DrawBackGround_BackFillMsg
.OffsetX
= message
->xoffset
;
1073 DrawBackGround_BackFillMsg
.OffsetY
= message
->yoffset
;
1075 D(bug("[Wanderer:VolumeList] %s: RastPort @ 0x%p\n", __PRETTY_FUNCTION__
, DrawBackGround_RastPort
));
1077 if ((retVal
= DoMethod(data
->iwcd_IconWindow
, MUIM_IconWindow_BackFill_DrawBackground
, XGET(data
->iwcd_IconWindow
, MUIA_IconWindow_BackFillData
), &DrawBackGround_BackFillMsg
, DrawBackGround_RastPort
)) == (IPTR
)TRUE
)
1079 D(bug("[Wanderer:VolumeList] %s: Backfill module rendered background ..\n", __PRETTY_FUNCTION__
));
1082 D(bug("[Wanderer:VolumeList] %s: Backfill module failed to render background ..\n", __PRETTY_FUNCTION__
));
1084 iwc_ParentBackground
:
1086 clip
= (IPTR
)MUI_AddClipping(muiRenderInfo(self
), message
->left
, message
->top
, message
->width
, message
->height
);
1088 message
->width
= _mwidth(self
);
1089 message
->height
= _mheight(self
);
1090 message
->left
= _mleft(self
);
1091 message
->top
= _mtop(self
);
1093 retVal
= DoSuperMethodA(CLASS
, self
, (Msg
) message
);
1095 MUI_RemoveClipping(muiRenderInfo(self
), (APTR
)clip
);
1101 ///IconWindowVolumeList__MUIM_IconList_Update()
1102 IPTR IconWindowVolumeList__MUIM_IconList_Update
1104 Class
*CLASS
, Object
*self
, struct MUIP_IconList_Update
*message
1109 IPTR retVal
= (IPTR
)TRUE
;
1111 if ((BOOL
)XGET(_win(self
), MUIA_IconWindow_IsRoot
))
1113 struct IconList_Entry
*icon_entry
= (IPTR
)MUIV_IconList_NextIcon_Start
;
1114 Object
*prefs
= NULL
;
1115 struct Node
*Obj_NetworkIcon
= NULL
;
1116 struct Node
*Obj_UserFilesIcon
= NULL
;
1118 struct List leftoutList
, *iconList
= NULL
;
1119 struct IconEntry
*volentry
= NULL
, *entry
= NULL
, *tmpentry
= NULL
;
1121 NEWLIST(&leftoutList
);
1123 D(bug("[Wanderer:VolumeList] %s: left-out List @ %p\n", __PRETTY_FUNCTION__
, &leftoutList
));
1125 GET(self
, MUIA_Family_List
, &iconList
);
1127 ForeachNodeSafe(iconList
, entry
, tmpentry
)
1129 if (entry
->ie_IconListEntry
.type
== ST_ROOT
)
1131 D(bug("[Wanderer:VolumeList] %s: Marking volume entry '%s' (pri = %d)\n", __PRETTY_FUNCTION__
, entry
->ie_IconNode
.ln_Name
, entry
->ie_IconNode
.ln_Pri
));
1132 if (entry
->ie_IconNode
.ln_Pri
== 5) entry
->ie_IconNode
.ln_Pri
= -5;
1133 else entry
->ie_IconNode
.ln_Pri
= -2;
1135 if ((entry
->ie_IconListEntry
.type
== ST_LINKFILE
) || (entry
->ie_IconListEntry
.type
== ST_LINKDIR
))
1137 D(bug("[Wanderer:VolumeList] %s: Removing left out entry '%s'\n", __PRETTY_FUNCTION__
, entry
->ie_IconNode
.ln_Name
));
1138 Remove(&entry
->ie_IconNode
);
1139 AddTail(&leftoutList
, &entry
->ie_IconNode
);
1141 else if (strcmp(entry
->ie_IconNode
.ln_Name
, "?wanderer.networkbrowse?") == 0)
1143 D(bug("[Wanderer:VolumeList] %s: Removing NetworkBrowser entry\n", __PRETTY_FUNCTION__
));
1144 Remove(&entry
->ie_IconNode
);
1145 Obj_NetworkIcon
= entry
;
1147 /*else if (strcmp(, "User Files..") == 0)
1149 Remove(&entry->ie_IconNode);
1150 Obj_UserFilesIcon = entry;
1154 D(bug("[Wanderer:VolumeList] %s: Causing parent to update\n", __PRETTY_FUNCTION__
));
1155 retVal
= DoSuperMethodA(CLASS
, self
, (Msg
) message
);
1157 GET(self
, MUIA_Family_List
, &iconList
);
1159 ForeachNode(iconList
, volentry
)
1161 if ((volentry
->ie_IconListEntry
.type
== ST_ROOT
) && ((volentry
->ie_IconNode
.ln_Pri
== -2) || (volentry
->ie_IconNode
.ln_Pri
== -5)))
1163 if (volentry
->ie_IconNode
.ln_Pri
== -5) volentry
->ie_IconNode
.ln_Pri
= 5;
1164 else volentry
->ie_IconNode
.ln_Pri
= 2;
1166 D(bug("[Wanderer:VolumeList] %s: Re-Parsing backdrop file for '%s'\n", __PRETTY_FUNCTION__
, volentry
->ie_IconNode
.ln_Name
));
1168 IconWindowVolumeList__Func_ParseBackdrop(self
, volentry
, &leftoutList
);
1170 ForeachNodeSafe(&leftoutList
, entry
, tmpentry
)
1172 if (((entry
->ie_IconListEntry
.type
== ST_LINKFILE
) || (entry
->ie_IconListEntry
.type
== ST_LINKDIR
))
1173 && (entry
->ie_IconListEntry
.udata
== volentry
))
1175 D(bug("[Wanderer:VolumeList] %s: Destroying orphaned left-out entry '%s'\n", __PRETTY_FUNCTION__
, entry
->ie_IconNode
.ln_Name
));
1176 Remove(&entry
->ie_IconNode
);
1177 DoMethod(self
, MUIM_IconList_DestroyEntry
, entry
);
1183 D(bug("[Wanderer:VolumeList] %s: Check if we should show NetworkBrowser Icon ..\n", __PRETTY_FUNCTION__
));
1185 GET(_app(self
), MUIA_Wanderer_Prefs
, &prefs
);
1189 struct IconWindowVolumeList_DATA
*volumel_data
= (struct IconWindowVolumeList_DATA
*)data
;
1191 GET(prefs
, MUIA_IconWindowExt_NetworkBrowser_Show
, &volumel_data
->iwvcd_ShowNetworkBrowser
);
1193 #if defined(DEBUG_NETWORKBROWSER)
1194 volumel_data
->iwvcd_ShowNetworkBrowser
= TRUE
;
1197 if (volumel_data
->iwvcd_ShowNetworkBrowser
)
1199 if (Obj_NetworkIcon
== NULL
)
1201 struct DiskObject
*_nb_dob
= NULL
;
1202 _nb_dob
= GetIconTags
1204 "ENV:SYS/def_NetworkHost",
1205 ICONGETA_FailIfUnavailable
, FALSE
,
1206 ICONGETA_Label
, (IPTR
)"Network Access..",
1210 D(bug("[Wanderer:VolumeList] %s: NetworkBrowser Icon DOB @ 0x%p\n", __PRETTY_FUNCTION__
, _nb_dob
));
1214 if ((Obj_NetworkIcon
= (struct Node
*)DoMethod(self
, MUIM_IconList_CreateEntry
, (IPTR
)"?wanderer.networkbrowse?", (IPTR
)"Network Access..", (IPTR
)NULL
, (IPTR
)_nb_dob
, 0)))
1216 Obj_NetworkIcon
->ln_Pri
= 4; /// Network Access gets Priority 4 so its displayed after special dirs
1217 D(bug("[Wanderer:VolumeList] %s: NetworkBrowser Icon Entry @ 0x%p\n", __PRETTY_FUNCTION__
, this_entry
));
1224 if (Obj_NetworkIcon
!= NULL
)
1226 DoMethod(self
, MUIM_IconList_DestroyEntry
, Obj_NetworkIcon
);
1230 GET(prefs
, MUIA_IconWindowExt_UserFiles_ShowFilesFolder
, &volumel_data
->iwvcd_ShowUserFolder
);
1232 #if defined(DEBUG_SHOWUSERFILES)
1233 volumel_data
->iwvcd_ShowUserFolder
= TRUE
;
1235 if (volumel_data
->iwvcd_ShowUserFolder
)
1237 if (Obj_UserFilesIcon
== NULL
)
1239 if (GetVar("SYS/Wanderer/userfiles.prefs", __icwc_intern_TxtBuff
, TXTBUFF_LEN
, GVF_GLOBAL_ONLY
) != -1)
1241 char * userfiles_path
= NULL
;
1243 D(bug("[Wanderer:VolumeList] %s: SYS/UserFilesLocation = '%s'\n", __PRETTY_FUNCTION__
, __icwc_intern_TxtBuff
));
1245 if ((userfiles_path
= AllocVec(strlen(__icwc_intern_TxtBuff
) + 1, MEMF_CLEAR
|MEMF_PUBLIC
)) != NULL
)
1247 struct DiskObject
*_nb_dob
= NULL
;
1249 volumel_data
->iwvcd_UserFolderPath
= userfiles_path
;
1251 D(bug("[Wanderer:VolumeList] %s: UserFilesLocation Path storage @ 0x%p\n", __PRETTY_FUNCTION__
, userfiles_path
));
1253 strcpy(userfiles_path
, __icwc_intern_TxtBuff
);
1255 D(bug("[Wanderer:VolumeList] %s: UserFilesLocation Path storage contains '%s'\n", __PRETTY_FUNCTION__
, userfiles_path
));
1257 _nb_dob
= GetIconTags
1259 "ENV:SYS/def_UserHome",
1260 ICONGETA_FailIfUnavailable
, FALSE
,
1261 ICONGETA_Label
, (IPTR
)"User Files..",
1265 D(bug("[Wanderer:VolumeList] %s: UserFiles Icon DOB @ 0x%p\n", __PRETTY_FUNCTION__
, _nb_dob
));
1269 if ((Obj_UserFilesIcon
= (struct Node
*)DoMethod(self
, MUIM_IconList_CreateEntry
, userfiles_path
, (IPTR
)"User Files..", (IPTR
)NULL
, (IPTR
)_nb_dob
, 0)))
1271 Obj_UserFilesIcon
->ln_Pri
= 5; /// Special dirs get Priority 5
1280 if (Obj_UserFilesIcon
!= NULL
)
1282 DoMethod(self
, MUIM_IconList_DestroyEntry
, Obj_UserFilesIcon
);
1290 DoMethod(self
, MUIM_IconList_Clear
);
1297 IPTR
IconWindowVolumeList__HandleFSUpdate(Object
*WandererObj
, struct NotifyMessage
*msg
)
1299 Object
*rootwindow
= (Object
*) XGET(WandererObj
, MUIA_Wanderer_WorkbenchWindow
);
1300 Object
*rooticonList
= (Object
*) XGET(rootwindow
, MUIA_IconWindow_IconList
);
1301 struct List
*iconList
= NULL
, fsLeftOutList
;
1302 struct IconEntry
*entry
= NULL
, *tmpEntry
= NULL
, *fsEntry
= NULL
;
1304 D(bug("[Wanderer:VolumeList]: %s(NotifyMessage @ %p -> '%s')\n", __PRETTY_FUNCTION__
, msg
, msg
->nm_NReq
->nr_Name
));
1306 NEWLIST(&fsLeftOutList
);
1308 D(bug("[Wanderer:VolumeList] %s: Desktop Window @ %p, IconList @ %p\n", __PRETTY_FUNCTION__
, rootwindow
, rooticonList
));
1310 GET(rooticonList
, MUIA_Family_List
, &iconList
);
1311 ForeachNode(iconList
, entry
)
1313 if ((entry
->ie_IconListEntry
.type
== ST_ROOT
)
1314 && (strncmp(entry
->ie_IconNode
.ln_Name
, msg
->nm_NReq
->nr_Name
, strlen(entry
->ie_IconNode
.ln_Name
)) == 0))
1321 if (fsEntry
!= NULL
)
1323 D(bug("[Wanderer:VolumeList] %s: Processing .backdrop for icon @ %p '%s'\n", __PRETTY_FUNCTION__
, fsEntry
, fsEntry
->ie_IconNode
.ln_Name
));
1325 ForeachNodeSafe(iconList
, entry
,tmpEntry
)
1327 if (((entry
->ie_IconListEntry
.type
== ST_LINKFILE
) || (entry
->ie_IconListEntry
.type
== ST_LINKDIR
)) && (entry
->ie_IconListEntry
.udata
== fsEntry
))
1329 D(bug("[Wanderer:VolumeList] %s: existing left-out icon @ %p '%s' for this volume\n", __PRETTY_FUNCTION__
, entry
, entry
->ie_IconNode
.ln_Name
));
1330 Remove(&entry
->ie_IconNode
);
1331 AddTail(&fsLeftOutList
, &entry
->ie_IconNode
);
1335 IconWindowVolumeList__Func_ParseBackdrop(rooticonList
, fsEntry
, &fsLeftOutList
);
1337 ForeachNodeSafe(&fsLeftOutList
, entry
, tmpEntry
)
1339 D(bug("[Wanderer:VolumeList] %s: Destroying orphaned icon @ %p '%s'\n", __PRETTY_FUNCTION__
, entry
, entry
->ie_IconNode
.ln_Name
));
1340 Remove(&entry
->ie_IconNode
);
1341 DoMethod(rooticonList
, MUIM_IconList_DestroyEntry
, entry
);
1344 DoMethod(rooticonList
, MUIM_IconList_Sort
);
1351 IPTR
IconWindowVolumeList__MUIM_IconList_CreateEntry(struct IClass
*CLASS
, Object
*obj
, struct MUIP_IconList_CreateEntry
*message
)
1353 struct IconEntry
*this_Icon
= NULL
;
1354 struct VolumeIcon_Private
*volPrivate
= NULL
;
1355 IPTR _volumeIcon__FSNotifyPort
= 0;
1356 struct List
*_volumeIcon__FSNotifyList
= NULL
;
1357 struct Wanderer_FSHandler
*_volumeIcon__FSNotifyHandler
= NULL
1359 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
1361 this_Icon
= DoSuperMethodA(CLASS
, obj
, (Msg
) message
);
1365 volPrivate
= this_Icon
->ie_IconListEntry
.udata
;
1367 D(bug("[Wanderer:VolumeList] %s: IconEntry '%s' Allocated @ %p, volPrivate @ %p\n", __PRETTY_FUNCTION__
, this_Icon
->ie_IconNode
.ln_Name
, this_Icon
, volPrivate
));
1369 if ((this_Icon
->ie_IconListEntry
.type
== ST_ROOT
) && (volPrivate
&& ((volPrivate
->vip_FLags
& (ICONENTRY_VOL_OFFLINE
|ICONENTRY_VOL_DISABLED
)) == 0)))
1371 GET(_app(obj
), MUIA_Wanderer_FileSysNotifyPort
, &_volumeIcon__FSNotifyPort
);
1372 GET(_app(obj
), MUIA_Wanderer_FileSysNotifyList
, &_volumeIcon__FSNotifyList
);
1374 if (_volumeIcon__FSNotifyList
&& ((_volumeIcon__FSNotifyHandler
= AllocMem(sizeof(struct Wanderer_FSHandler
), MEMF_CLEAR
)) != NULL
))
1376 _volumeIcon__FSNotifyHandler
->fshn_Node
.ln_Name
= this_Icon
->ie_IconNode
.ln_Name
;
1377 volPrivate
->vip_FSNotifyRequest
.nr_Name
= _volumeIcon__FSNotifyHandler
->fshn_Node
.ln_Name
;
1378 volPrivate
->vip_FSNotifyRequest
.nr_Flags
= NRF_SEND_MESSAGE
;
1379 volPrivate
->vip_FSNotifyRequest
.nr_stuff
.nr_Msg
.nr_Port
= _volumeIcon__FSNotifyPort
;
1380 _volumeIcon__FSNotifyHandler
->HandleFSUpdate
= IconWindowVolumeList__HandleFSUpdate
;
1382 if (StartNotify(&volPrivate
->vip_FSNotifyRequest
))
1384 D(bug("[Wanderer:VolumeList] %s: FSNotification setup", __PRETTY_FUNCTION__
));
1388 D(bug("[Wanderer:VolumeList] %s: FAILED to setup FSNotification", __PRETTY_FUNCTION__
));
1389 volPrivate
->vip_FSNotifyRequest
.nr_Name
= NULL
;
1391 D(bug(" for Volume '%s'\n", this_Icon
->ie_IconNode
.ln_Name
));
1392 AddTail(_volumeIcon__FSNotifyList
, &_volumeIcon__FSNotifyHandler
->fshn_Node
);
1394 IconWindowVolumeList__Func_ParseBackdrop(obj
, this_Icon
, NULL
);
1400 IPTR
IconWindowVolumeList__MUIM_IconList_UpdateEntry(struct IClass
*CLASS
, Object
*obj
, struct MUIP_IconList_UpdateEntry
*message
)
1402 struct IconEntry
*this_Icon
= NULL
;
1403 struct VolumeIcon_Private
*volPrivate
= NULL
;
1405 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
1407 volPrivate
= message
->icon
->ie_IconListEntry
.udata
;
1409 this_Icon
= DoSuperMethodA(CLASS
, obj
, (Msg
) message
);
1414 IPTR
IconWindowVolumeList__MUIM_IconList_DestroyEntry(struct IClass
*CLASS
, Object
*obj
, struct MUIP_IconList_DestroyEntry
*message
)
1416 struct VolumeIcon_Private
*volPrivate
= NULL
;
1419 D(bug("[Wanderer:VolumeList]: %s()\n", __PRETTY_FUNCTION__
));
1421 volPrivate
= message
->icon
->ie_IconListEntry
.udata
;
1423 if ((message
->icon
->ie_IconListEntry
.type
== ST_ROOT
) && (volPrivate
&& ((volPrivate
->vip_FLags
& (ICONENTRY_VOL_OFFLINE
|ICONENTRY_VOL_DISABLED
)) == 0)))
1425 if (volPrivate
->vip_FSNotifyRequest
.nr_Name
!= NULL
)
1427 EndNotify(&volPrivate
->vip_FSNotifyRequest
);
1428 //Remove(&_volumeIcon__FSNotifyHandler->fshn_Node);
1431 // Remove all the icons left out for this volume ..
1432 struct List
*iconList
= NULL
;
1433 struct IconEntry
*entry
= NULL
;
1435 GET(obj
, MUIA_Family_List
, &iconList
);
1436 ForeachNode(iconList
, entry
)
1438 if (((entry
->ie_IconListEntry
.type
== ST_LINKFILE
) || (entry
->ie_IconListEntry
.type
== ST_LINKDIR
)) && (entry
->ie_IconListEntry
.udata
== message
->icon
))
1440 D(bug("[Wanderer:VolumeList] %s: Removing child entry '%s'\n", __PRETTY_FUNCTION__
, entry
->ie_IconNode
.ln_Name
));
1441 DoMethod(obj
, MUIM_IconList_DestroyEntry
, entry
);
1445 else if ((message
->icon
->ie_IconListEntry
.type
== ST_LINKFILE
) || (message
->icon
->ie_IconListEntry
.type
== ST_LINKDIR
))
1446 message
->icon
->ie_IconListEntry
.udata
= NULL
;
1448 D(bug("[Wanderer:VolumeList] %s: causing parent class to dispose of '%s'\n", __PRETTY_FUNCTION__
, message
->icon
->ie_IconNode
.ln_Name
));
1450 rv
= DoSuperMethodA(CLASS
, obj
, (Msg
) message
);
1456 /*** Setup ******************************************************************/
1458 ICONWINDOWICONVOLUMELIST_CUSTOMCLASS
1460 IconWindowVolumeList
, NULL
, MUIC_IconVolumeList
, NULL
,
1461 OM_NEW
, struct opSet
*,
1462 OM_SET
, struct opSet
*,
1463 OM_GET
, struct opGet
*,
1466 MUIM_DrawBackground
, Msg
,
1467 MUIM_HandleEvent
, Msg
,
1468 MUIM_IconList_Update
, struct MUIP_IconList_Update
*,
1469 MUIM_IconList_CreateEntry
, struct MUIP_IconList_CreateEntry
*,
1470 MUIM_IconList_UpdateEntry
, struct MUIP_IconList_UpdateEntry
*,
1471 MUIM_IconList_DestroyEntry
, struct MUIP_IconList_DestroyEntry
*
1474 ICONWINDOWICONVOLUMELIST_CUSTOMCLASS
1476 IconWindowVolumeList
, NULL
, NULL
, IconVolumeList_Class
,
1477 OM_NEW
, struct opSet
*,
1478 OM_SET
, struct opSet
*,
1479 OM_GET
, struct opGet
*,
1482 MUIM_DrawBackground
, Msg
,
1483 MUIM_HandleEvent
, Msg
,
1484 MUIM_IconList_Update
, struct MUIP_IconList_Update
*,
1485 MUIM_IconList_CreateEntry
, struct MUIP_IconList_CreateEntry
*,
1486 MUIM_IconList_UpdateEntry
, struct MUIP_IconList_UpdateEntry
*,
1487 MUIM_IconList_DestroyEntry
, struct MUIP_IconList_DestroyEntry
*