grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / system / Wanderer / wanderer.c
blob863bbd514729700b1bee2627faeb51307aaaf858
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
13 #define DEBUG 0
14 #include <aros/debug.h>
15 #endif
17 #define WANDERER_DEFAULT_BACKDROP
19 #include <exec/types.h>
20 #include <libraries/gadtools.h>
21 #include <libraries/mui.h>
23 #ifdef __AROS__
24 #include <zune/customclasses.h>
25 #else
26 #include <zune_AROS/customclasses.h>
27 #endif
29 #include <dos/notify.h>
31 #ifdef __AROS__
32 #include <workbench/handler.h>
33 #else
34 #include <workbench_AROS/handler.h>
35 #endif
37 #include <proto/graphics.h>
38 #include <proto/utility.h>
40 #include <proto/dos.h>
42 #include <proto/icon.h>
44 #ifdef __AROS__
45 #include <proto/workbench.h>
46 #endif
48 #include <proto/layers.h>
50 #ifdef __AROS__
51 #include <proto/alib.h>
52 #endif
54 #include <string.h>
55 #include <stdio.h>
56 #include <time.h>
59 #ifdef __AROS__
60 #include <aros/detach.h>
61 #include <prefs/wanderer.h>
62 #else
63 #include <prefs_AROS/wanderer.h>
64 #endif
66 #if defined(__AMIGA__) && !defined(__PPC__)
67 #define NO_INLINE_STDARG
68 #endif
69 #include <proto/intuition.h>
70 #include <proto/muimaster.h>
72 #include <zune/iconimage.h>
74 #include "iconwindow.h"
75 #include "iconwindow_attributes.h"
76 #include "iconwindow_iconlist.h"
77 #include "wandererprefs.h"
78 #include "filesystems.h"
79 #include "wanderer.h"
80 #include "Classes/iconlist.h"
81 #include "Classes/iconlist_attributes.h"
82 #include "Classes/icon_attributes.h"
83 #include "locale.h"
84 #include "appobjects.h"
86 #include "version.h"
88 #ifndef __AROS__
89 #define DEBUG 1
91 #ifdef DEBUG
92 #define D(x) if (DEBUG) x
93 #ifdef __amigaos4__
94 #define bug DebugPrintF
95 #else
96 #define bug kprintf
97 #endif
98 #else
99 #define D(...)
100 #endif
101 #endif
103 #ifndef NO_ICON_POSITION
104 #define NO_ICON_POSITION (0x8000000) /* belongs to workbench/workbench.h */
105 #endif
107 #define KeyButton(name,key) TextObject, ButtonFrame, MUIA_Font, MUIV_Font_Button, MUIA_Text_Contents, (IPTR)(name), MUIA_Text_PreParse, "\33c", MUIA_Text_HiChar, (IPTR)(key), MUIA_ControlChar, key, MUIA_InputMode, MUIV_InputMode_RelVerify, MUIA_Background, MUII_ButtonBack, TAG_DONE)
109 Object *FindMenuitem(Object* strip, int id);
110 Object *Wanderer__Func_CreateWandererIntuitionMenu(BOOL isRoot, BOOL useBackdrop);
111 void wanderer_menufunc_window_update(void);
112 void wanderer_menufunc_window_cleanup(void);
113 void wanderer_menufunc_window_find(void);
114 void execute_open_with_command(BPTR cd, STRPTR contents);
115 void DisposeCopyDisplay(struct MUIDisplayObjects *d);
116 BOOL CreateCopyDisplay(UWORD flags, struct MUIDisplayObjects *d);
118 static struct List _WandererIntern_FSHandlerList;
120 /* Stored in the main wanderer executable */
121 extern Object *_WandererIntern_AppObj;
122 extern Class *_WandererIntern_CLASS;
123 /* Internal Hooks */
124 #ifdef __AROS__
125 struct Hook _WandererIntern_hook_standard;
126 struct Hook _WandererIntern_hook_action;
127 struct Hook _WandererIntern_hook_backdrop;
128 #else
129 struct Hook *_WandererIntern_hook_standard;
130 struct Hook *_WandererIntern_hook_action;
131 struct Hook *_WandererIntern_hook_backdrop;
132 #endif
134 /*** Instance Data **********************************************************/
135 struct Wanderer_DATA
137 struct Screen *wd_Screen;
139 Object *wd_Prefs,
140 *wd_ActiveWindow,
141 *wd_WorkbenchWindow,
142 *wd_AboutWindow;
144 struct MUI_InputHandlerNode wd_TimerIHN;
145 struct MsgPort *wd_CommandPort;
146 struct MUI_InputHandlerNode wd_CommandIHN;
147 struct MsgPort *wd_NotifyPort;
148 struct MUI_InputHandlerNode wd_NotifyIHN;
150 BOOL wd_Option_BackDropMode;
153 const UBYTE wand_titlestr[] = WANDERERSTR;
154 const UBYTE wand_versionstr[] = VERSION;
155 const UBYTE wand_copyrightstr[] = WANDERERCOPY;
156 const UBYTE wand_authorstr[] = WANDERERAUTH;
157 const UBYTE wand_namestr[] = WANDERERNAME;
159 const UBYTE wand_copyprocnamestr[] = WANDERERNAME" FileCopy Operation";
161 const UBYTE wand_backdropprefs[] = "SYS/Wanderer/backdrop.prefs";
163 /*** Macros *****************************************************************/
164 #define SETUP_WANDERER_INST_DATA struct Wanderer_DATA *data = INST_DATA(CLASS, self)
166 /**************************************************************************
167 * HOOK FUNCS *
168 **************************************************************************/
169 ///Wanderer__HookFunc_DisplayCopyFunc()
170 #ifdef __AROS__
171 AROS_UFH3
173 BOOL, Wanderer__HookFunc_DisplayCopyFunc,
174 AROS_UFHA(struct Hook *, hook, A0),
175 AROS_UFHA(struct dCopyStruct *, obj, A2),
176 AROS_UFHA(APTR, unused_param, A1)
179 #else
180 HOOKPROTO(Wanderer__HookFunc_DisplayCopyFunc, BOOL, struct dCopyStruct *obj, APTR unused_param)
182 #endif
183 AROS_USERFUNC_INIT
185 struct MUIDisplayObjects *d = (struct MUIDisplayObjects *) obj->userdata;
187 if ((obj->flags & ACTION_UPDATE) == 0)
189 d->updateme = TRUE;
191 if ((obj->filelen < 8192) && (d->numfiles > 0))
193 d->smallobjects++;
194 if (d->smallobjects >= 20) d->smallobjects = 0;
196 else
198 d->smallobjects = 0;
201 if (d->smallobjects > 0)
202 d->updateme = FALSE;
204 if (d->updateme)
206 SET(d->fileObject, MUIA_Text_Contents, obj->file);
207 SET(d->sourceObject, MUIA_Text_Contents, obj->spath);
210 if (d->action != ACTION_DELETE)
212 d->bytes += obj->actlen;
214 if ((obj->flags & ACTION_UPDATE) == 0)
216 if (d->updateme)
218 SET(d->gauge, MUIA_Gauge_Current, 0);
219 SET(d->destObject, MUIA_Text_Contents, obj->dpath);
221 d->numfiles++;
223 else
225 if (d->updateme &&(obj->totallen <= obj->filelen))
227 double rate = (double) (((double) obj->totallen) / (((double) obj->difftime) / ((double) CLOCKS_PER_SEC))) / 1024.0;
228 if (rate < 1024.0) sprintf(d->SpeedBuffer, "%.2f kBytes/s", rate); else sprintf(d->SpeedBuffer, "%.2f MBytes/s", rate / 1024.0);
229 SetAttrs(d->gauge, MUIA_Gauge_Current, (ULONG) (32768.0 * (double) obj->totallen / (double) obj->filelen), MUIA_Gauge_InfoText, d->SpeedBuffer, TAG_DONE);
233 if (d->updateme)
235 if (d->bytes < 1048576)
237 if (obj->filelen < 1048576)
239 sprintf(
240 d->Buffer, "%s %ld %s %.2f kBytes %s %.2f kBytes",
241 _(MSG_WANDERER_FILEACCESS_NOOFFILES), (long)d->numfiles, _(MSG_WANDERER_FILEACCESS_ACTUAL), (double) obj->filelen / 1024.0, _(MSG_WANDERER_FILEACCESS_TOTAL), (double) d->bytes / 1024.0
244 else
246 sprintf(
247 d->Buffer, "%s %ld %s %.2f MBytes %s %.2f kBytes",
248 _(MSG_WANDERER_FILEACCESS_NOOFFILES), (long)d->numfiles, _(MSG_WANDERER_FILEACCESS_ACTUAL), (double) obj->filelen / 1048576.0, _(MSG_WANDERER_FILEACCESS_TOTAL), (double) d->bytes / 1024.0
252 else
254 if (obj->filelen < 1048576)
256 sprintf(
257 d->Buffer, "%s %ld %s %.2f kBytes %s %.2f MBytes",
258 _(MSG_WANDERER_FILEACCESS_NOOFFILES), (long)d->numfiles, _(MSG_WANDERER_FILEACCESS_ACTUAL), (double) obj->filelen / 1024.0, _(MSG_WANDERER_FILEACCESS_TOTAL), (double) d->bytes / 1048576.0
261 else
263 sprintf(
264 d->Buffer, "%s %ld %s %.2f MBytes %s %.2f MBytes",
265 _(MSG_WANDERER_FILEACCESS_NOOFFILES), (long)d->numfiles, _(MSG_WANDERER_FILEACCESS_ACTUAL), (double) obj->filelen / 1048576.0, _(MSG_WANDERER_FILEACCESS_TOTAL), (double) d->bytes / 1048576.0
269 SET(d->performanceObject, MUIA_Text_Contents, d->Buffer);
273 DoMethod(d->copyApp, MUIM_Application_InputBuffered);
275 /* read the stopflag and return TRUE if the user wanted to stop actionDir() */
276 if (d->stopflag == 1)
277 return TRUE;
278 else
279 return FALSE;
281 AROS_USERFUNC_EXIT
283 #ifndef __AROS__
284 MakeStaticHook(Hook_DisplayCopyFunc,Wanderer__HookFunc_DisplayCopyFunc);
285 #endif
288 ///Wanderer__HookFunc_AskModeFunc()
289 #ifdef __AROS__
290 AROS_UFH3
292 ULONG, Wanderer__HookFunc_AskModeFunc,
293 AROS_UFHA(struct Hook *, hook, A0),
294 AROS_UFHA(struct dCopyStruct *, obj, A2),
295 AROS_UFHA(APTR, unused_param, A1)
298 #else
299 HOOKPROTO(Wanderer__HookFunc_AskModeFunc, ULONG, struct dCopyStruct *obj, APTR unused_param)
301 #endif
302 AROS_USERFUNC_INIT
304 ULONG back = OPMODE_NONE;
306 UWORD ret = 0;
307 char *string = NULL;
309 if (obj->file)
311 if (obj->type == 0)
313 string = CombineString("%s\n\033b%s\033n\n%s\n\033b%s\033n %s",
314 _(MSG_REQU_DELETE_FILE_S), obj->file, _(MSG_REQU_DELETE_FILE_M), obj->spath, _(MSG_REQU_DELETE_FILE_E) );
316 else if (obj->type == 1)
318 string = CombineString("%s\n\033b%s\033n\n%s\n\033b%s\033n %s",
319 _(MSG_REQU_FILEUNPROTECT_S), obj->file, _(MSG_REQU_FILEUNPROTECT_M), obj->spath, _(MSG_REQU_FILEUNPROTECT_E) );
321 else if (obj->type == 2)
323 string = CombineString("%s\n\033b%s\033n\n%s\n\033b%s\033n %s",
324 _(MSG_REQU_OVERWRITE_S), obj->file, _(MSG_REQU_OVERWRITE_M), obj->spath, _(MSG_REQU_OVERWRITE_E) );
326 else
328 string = CombineString("%s\n\033b%s\033n\n%s\n\033b%s\033n%s",
329 _(MSG_NOFILEACCESS_S), obj->file, _(MSG_NOFILEACCESS_M), obj->spath, _(MSG_NOFILEACCESS_E) );
332 else
334 if (obj->type == 0) string = CombineString("%s \033b%s\033n %s", _(MSG_REQU_DELETE_DRAWER_S), obj->spath, _(MSG_REQU_DELETE_DRAWER_E) );
335 else if (obj->type == 1) string = CombineString("%s\n\033b%s\033n %s", _(MSG_REQU_PROTECTION_UNPROTECTDRAWER_S), obj->spath, _(MSG_REQU_PROTECTION_UNPROTECTDRAWER_E) );
336 else if (obj->type == 3) string = CombineString("%s\n\033b%s %s", _(MSG_NODRAWERACCESS_S), obj->spath, _(MSG_NODRAWERACCESS_E) );
339 if (string)
341 if (obj->type == 0) ret = AskChoiceCentered( _(MSG_REQU_DELETE), string, _(MSG_REQU_DELETE_YESNO), 0);
342 else if (obj->type == 1) ret = AskChoiceCentered( _(MSG_REQU_PROTECTION), string, _(MSG_REQU_PROTECTION_UNPROTECT), 0);
343 else if (obj->type == 2) ret = AskChoiceCentered( _(MSG_REQU_OVERWRITE), string, _(MSG_REQU_OVERWRITE_YESNO), 0);
344 else ret = AskChoiceCentered( _(MSG_REQU_OVERWRITE), string, _(MSG_REQU_OVERWRITE_SKIPABORT), 0);
345 freeString(NULL, string);
348 if (ret == 0) back = OPMODE_NONE;
349 else if (ret == 1) back = OPMODE_YES;
350 else if (ret == 2) back = OPMODE_ALL;
351 else if (ret == 3) back = OPMODE_NO;
353 return back;
355 AROS_USERFUNC_EXIT
357 #ifndef __AROS__
358 MakeStaticHook(Hook_AskModeFunc,Wanderer__HookFunc_AskModeFunc);
359 #endif
362 ///Wanderer__Func_CopyDropEntries()
363 AROS_UFH3(void, Wanderer__Func_CopyDropEntries,
364 AROS_UFHA(STRPTR, argPtr, A0),
365 AROS_UFHA(ULONG, argSize, D0),
366 AROS_UFHA(struct ExecBase *, SysBase, A6))
368 AROS_USERFUNC_INIT
370 struct IconList_Drop_Event *copyFunc_DropEvent = FindTask(NULL)->tc_UserData;
372 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
374 if (copyFunc_DropEvent)
376 struct MUIDisplayObjects dobjects;
377 struct IconList_Drop_SourceEntry *currententry;
378 struct OpModes opModes;
379 ULONG updatedIcons = 0;
381 opModes.deletemode = OPMODE_ASK;
382 opModes.protectmode = OPMODE_ASK;
383 opModes.overwritemode = OPMODE_ASK;
384 #ifdef __AROS__
385 struct Hook displayCopyHook;
386 struct Hook displayAskHook;
387 displayCopyHook.h_Entry = (HOOKFUNC) Wanderer__HookFunc_DisplayCopyFunc;
388 displayAskHook.h_Entry = (HOOKFUNC) Wanderer__HookFunc_AskModeFunc;
389 opModes.askhook = &displayAskHook;
390 #else
391 struct Hook *displayCopyHook;
392 struct Hook *displayAskHook;
393 displayCopyHook = &Hook_DisplayCopyFunc;
394 displayAskHook = &Hook_AskModeFunc;
395 opModes.askhook = displayAskHook;
396 #endif
398 if (CreateCopyDisplay(ACTION_COPY, &dobjects))
400 while ((currententry = (struct IconList_Drop_SourceEntry *)RemTail(&copyFunc_DropEvent->drop_SourceList)) != NULL)
402 D(bug("[Wanderer] %s: Copying '%s' to '%s'\n", __PRETTY_FUNCTION__,
403 currententry->dropse_Node.ln_Name, copyFunc_DropEvent->drop_TargetPath));
405 CopyContent(NULL,
406 currententry->dropse_Node.ln_Name, copyFunc_DropEvent->drop_TargetPath,
407 TRUE, ACTION_COPY, &displayCopyHook, &opModes, (APTR) &dobjects);
408 updatedIcons++;
410 FreeVec(currententry->dropse_Node.ln_Name);
411 FreeMem(currententry, sizeof(struct IconList_Drop_SourceEntry));
413 /* delete copy window */
414 DisposeCopyDisplay(&dobjects);
417 if (updatedIcons > 0)
419 /* Update state of target object after copying */
420 DoMethod(_app(copyFunc_DropEvent->drop_TargetObj), MUIM_Application_PushMethod,
421 copyFunc_DropEvent->drop_TargetObj, 1, MUIM_IconList_Update);
422 DoMethod(_app(copyFunc_DropEvent->drop_TargetObj), MUIM_Application_PushMethod,
423 copyFunc_DropEvent->drop_TargetObj, 1, MUIM_IconList_Sort);
426 FreeVec(copyFunc_DropEvent->drop_TargetPath);
427 FreeMem(copyFunc_DropEvent, sizeof(struct IconList_Drop_Event));
429 return;
431 AROS_USERFUNC_EXIT
435 ///Wanderer__HookFunc_ActionFunc()
436 #ifdef __AROS__
437 AROS_UFH3
439 void, Wanderer__HookFunc_ActionFunc,
440 AROS_UFHA(struct Hook *, hook, A0),
441 AROS_UFHA(Object *, obj, A2),
442 AROS_UFHA(struct IconWindow_ActionMsg *, msg, A1)
445 #else
446 HOOKPROTO(Wanderer__HookFunc_ActionFunc, void, Object *obj, struct IconWindow_ActionMsg *msg)
448 #endif
449 AROS_USERFUNC_INIT
451 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
453 if (msg->type == ICONWINDOW_ACTION_OPEN)
455 static unsigned char buf[1024];
456 D(IPTR offset);
457 struct IconList_Entry *ent = (void*)MUIV_IconList_NextIcon_Start;
459 DoMethod(msg->iconlist, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&ent);
460 if ((IPTR)ent == (IPTR)MUIV_IconList_NextIcon_End)
462 D(bug("[Wanderer] %s: ICONWINDOW_ACTION_OPEN: NextIcon returned MUIV_IconList_NextIcon_TAG_DONE)\n", __PRETTY_FUNCTION__));
463 return;
466 D(offset = strlen(ent->ile_IconEntry->ie_IconNode.ln_Name) - 5);
468 if ((msg->isroot) && (ent->type == ST_ROOT))
470 strcpy((STRPTR)buf, ent->label);
472 else
474 strcpy((STRPTR)buf, ent->ile_IconEntry->ie_IconNode.ln_Name);
477 D(bug("[Wanderer] %s: ICONWINDOW_ACTION_OPEN: offset = %d, buf = %s\n", __PRETTY_FUNCTION__, offset, buf));
479 if ((ent->type == ST_ROOT) || (ent->type == ST_USERDIR) || (ent->type == ST_LINKDIR))
481 Object *cstate = (Object*)(((struct List*)XGET(_app(obj), MUIA_Application_WindowList))->lh_Head);
482 Object *prefs = (Object*) XGET(_app(obj), MUIA_Wanderer_Prefs);
483 Object *child;
485 /* open new window if root or classic navigation set */
486 if ( (msg->isroot) || (XGET(prefs, MUIA_IconWindow_WindowNavigationMethod) == WPD_NAVIGATION_CLASSIC) )
488 /* Check if the window for this drawer is already opened */
489 while ((child = NextObject(&cstate)))
491 if (XGET(child, MUIA_UserData))
493 STRPTR child_drawer = (STRPTR)XGET(child, MUIA_IconWindow_Location);
494 if (child_drawer && !Stricmp(buf,(CONST_STRPTR)child_drawer))
496 BOOL is_open = ( BOOL )XGET(child, MUIA_Window_Open);
498 if (!is_open)
500 DoMethod(child, MUIM_IconWindow_Open);
502 else
504 DoMethod(child, MUIM_Window_ToFront);
505 SET(child, MUIA_Window_Activate, TRUE);
508 return;
512 DoMethod(_app(obj), MUIM_Wanderer_CreateDrawerWindow, (IPTR) buf);
513 // FIXME: error handling
515 else
517 /* Open drawer in same window */
518 SET(obj, MUIA_IconWindow_Location, (IPTR) buf);
521 else if ((ent->type == ST_FILE) || (ent->type == ST_LINKFILE))
523 BPTR newwd, oldwd;
524 STRPTR path;
526 path = StrDup(ent->ile_IconEntry->ie_IconNode.ln_Name);
528 if (path) {
529 /* Set the CurrentDir to the path of the executable to be started */
530 *PathPart(path) = 0;
532 newwd = Lock(path, SHARED_LOCK);
533 if(newwd)
535 struct IconList_Entry *ent2 = (void*)MUIV_IconList_NextIcon_Start;
536 int argsCounted = 0,
537 i = 0;
538 struct TagItem *argsTagList = NULL;
539 Object *firstWindow = (Object *) (((struct List*)XGET(_app(obj), MUIA_Application_WindowList))->lh_Head);
540 Object *windowItem,
541 *iconList;
543 oldwd = CurrentDir(newwd);
545 ** If we have more than one icon selected, the first one
546 ** is our command, and the next ones are the arguments.
547 ** We take care of icons selected on other windows.
550 /* Count the selected icons */
551 while ( (windowItem = NextObject(&firstWindow)) )
553 iconList = (Object *) XGET(windowItem, MUIA_IconWindow_IconList);
554 if (iconList != NULL) /* Wanderer has non-iconlist windows as well */
556 ent2 = (void*) MUIV_IconList_NextIcon_Start;
557 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&ent2);
560 if ((IPTR)ent2 != MUIV_IconList_NextIcon_End )
561 argsCounted++;
562 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&ent2);
564 while ((IPTR)ent2 != MUIV_IconList_NextIcon_End );
566 } /* while ( (windowItem = NextObject(&firstWindow)) ) */
567 D(bug("[Wanderer] argsCounted = %d\n", argsCounted));
569 /* If we have arguments, populate argsTagList with them */
570 if ( argsCounted > 1 ) /* "ent" is selected and has been counted */
572 BPTR argLock;
573 argsTagList = AllocateTagItems((argsCounted * 2) - 1); /* first time for wa_Name, second wa_Lock */
574 firstWindow = (Object *) (((struct List*)XGET(_app(obj), MUIA_Application_WindowList))->lh_Head);
575 while ( (windowItem = NextObject(&firstWindow)) )
577 iconList = (Object *) XGET(windowItem, MUIA_IconWindow_IconList);
578 if (iconList != NULL) /* Wanderer has non-iconlist windows as well */
580 ent2 = (void*) MUIV_IconList_NextIcon_Start;
581 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&ent2);
583 while ((IPTR)ent2 != MUIV_IconList_NextIcon_End)
585 if (ent2->ile_IconEntry->ie_IconNode.ln_Name != ent->ile_IconEntry->ie_IconNode.ln_Name)
587 argLock = Lock(ent2->ile_IconEntry->ie_IconNode.ln_Name, ACCESS_READ);
588 argsTagList[i].ti_Tag = WBOPENA_ArgLock;
589 argsTagList[i].ti_Data = (IPTR) ParentDir(argLock);
590 D(bug("[Wanderer] argsTagList[%d]: Lock = %lx\n", i, argsTagList[i].ti_Data));
591 UnLock(argLock);
592 argsTagList[++i].ti_Tag = WBOPENA_ArgName;
593 argsTagList[i].ti_Data = (IPTR) FilePart(ent2->ile_IconEntry->ie_IconNode.ln_Name);
594 D(bug("[Wanderer] argsTagList[%d]: Name = %s\n", i, argsTagList[i].ti_Data));
595 i++;
597 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&ent2);
600 } /* while ( (windowItem = NextObject(&cstate)) ) */
601 argsTagList[i].ti_Tag = TAG_DONE;
603 ** TODO: the user should be able to select the tool in one window, and some arguments
604 ** in other windows, in that very order. For now Wanderer only handles selected icons
605 ** per window, and so doesn't provide an easy way to know about _all_ selected icons.
606 ** At least we can browse all windows and keep track of all selected icons on each of
607 ** them. But then we don't have a way to know which icon was selected first (which is
608 ** the tool one). The trick for the user is to select first all arguments that aren't
609 ** in the tool's window, and only then select the tool on its window and the last
610 ** arguments in the tool's window, and of course double-click the very last icon.
612 } /* if (argsCounted > 1) */
614 if ( !OpenWorkbenchObjectA(ent->ile_IconEntry->ie_IconNode.ln_Name, argsTagList) )
616 execute_open_with_command(newwd, FilePart(ent->ile_IconEntry->ie_IconNode.ln_Name));
618 struct TagItem * tag = argsTagList;
619 while ((tag = FindTagItem(WBOPENA_ArgLock, tag)))
621 D(bug("[Wanderer] UnLocking %lx\n", tag->ti_Data));
622 UnLock((BPTR)tag->ti_Data);
623 tag++;
625 FreeTagItems(argsTagList); /* FreeTagItems() only frees memory if non NULL */
626 CurrentDir(oldwd);
627 UnLock(newwd);
629 FreeVec(path);
632 else if (ent->type == ILE_TYPE_APPICON)
634 SendAppIconMessage((struct AppIcon *)ent->ile_IconEntry->ie_User1, 0, NULL);
637 else if (msg->type == ICONWINDOW_ACTION_DIRUP)
639 STRPTR actual_drawer = (STRPTR)XGET(obj, MUIA_IconWindow_Location);
640 STRPTR parent_drawer = strrchr(actual_drawer,'/');
641 STRPTR root_drawer = strrchr(actual_drawer,':');
643 /* check if dir is not drive root dir */
644 if ( strlen(root_drawer) > 1 )
646 /* check if second or third level directory*/
647 if (!parent_drawer)
649 (*(root_drawer+1)) = 0;
650 SET(obj, MUIA_IconWindow_Location, actual_drawer);
653 else
655 (*parent_drawer) = 0;
656 SET(obj, MUIA_IconWindow_Location, actual_drawer);
661 else if (msg->type == ICONWINDOW_ACTION_CLICK)
663 if (!msg->click->shift)
665 Object *cstate = (Object*)(((struct List*)XGET(_app(obj), MUIA_Application_WindowList))->lh_Head);
666 Object *child;
668 while ((child = NextObject(&cstate)))
670 if (XGET(child, MUIA_UserData))
672 if (child != obj) DoMethod(child, MUIM_IconWindow_UnselectAll);
677 else if (msg->type == ICONWINDOW_ACTION_ICONDROP)
679 struct Process *wandererCopyProcess;
680 struct IconList_Drop_Event *dropevent = (struct IconList_Drop_Event *)msg->drop;
683 wandererCopyProcess = CreateNewProcTags(
684 NP_Entry, (IPTR)Wanderer__Func_CopyDropEntries,
685 NP_Name, (IPTR)wand_copyprocnamestr,
686 NP_Synchronous, FALSE,
687 NP_UserData, (IPTR)dropevent,
688 NP_StackSize, 40000,
689 TAG_DONE);
690 if (wandererCopyProcess == NULL) {
691 /* TODO: Handle failure to create the copy process */
695 else if (msg->type == ICONWINDOW_ACTION_APPWINDOWDROP)
697 struct Screen *wscreen = NULL;
698 struct Layer *layer;
700 /* get wanderers screen struct and the layer located at cursor position afterwards */
701 get( obj, MUIA_Window_Screen, &wscreen);
702 LockLayerInfo(&wscreen->LayerInfo);
703 layer = WhichLayer(&wscreen->LayerInfo,wscreen->MouseX,wscreen->MouseY);
704 UnlockLayerInfo(&wscreen->LayerInfo);
706 if (layer)
708 struct Window *win = (struct Window *) layer->Window;
709 if (win)
711 struct List AppList;
712 ULONG files = 0;
713 BOOL fail = FALSE;
714 struct IconList_Entry *ent;
716 NewList(&AppList);
718 ent = (void*)MUIV_IconList_NextIcon_Start;
719 /* process all selected entries */
722 DoMethod(msg->iconlist, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR) &ent);
723 /* if not end of selection, process */
724 if ((IPTR)ent != MUIV_IconList_NextIcon_End )
726 struct AppW *a = AllocVec(sizeof(struct AppW), MEMF_CLEAR);
727 if (a)
729 a->name = AllocVec(strlen(ent->ile_IconEntry->ie_IconNode.ln_Name)+2, MEMF_CLEAR);
730 if (a->name)
732 files++;
733 strcpy(a->name, ent->ile_IconEntry->ie_IconNode.ln_Name);
734 if((ent->type == ST_LINKDIR) || (ent->type == ST_USERDIR))
736 D(bug("[Wanderer] %s: ent->type=%d\n", __PRETTY_FUNCTION__, ent->type));
737 strcat (a->name, "/");
739 AddTail(&AppList, (struct Node *) a);
741 else
743 FreeVec(a);
744 fail = TRUE;
747 else fail = TRUE;
750 while (((IPTR)ent != MUIV_IconList_NextIcon_End) && !fail);
752 if (!fail && (files > 0))
754 STRPTR *filelist = AllocVec(sizeof(STRPTR) * files, MEMF_CLEAR);
755 if (filelist != NULL)
757 STRPTR *flist = filelist;
758 if (!IsListEmpty(&AppList))
760 struct Node *succ;
761 struct Node *s = AppList.lh_Head;
762 while (((succ = ((struct Node*) s)->ln_Succ) != NULL) && !fail)
764 *flist ++ = ((struct AppW *) s)->name;
765 s = succ;
768 D(bug("[Wanderer] %s: win:<%s> first file:<%s> mx=%d my=%d\n", __PRETTY_FUNCTION__,
769 win->Title, *filelist,
770 wscreen->MouseX - win->LeftEdge, wscreen->MouseY - win->TopEdge);)
772 /* send appwindow msg struct containing selected files to destination */
773 SendAppWindowMessage(win, files, (char **)filelist, 0, wscreen->MouseX - win->LeftEdge, wscreen->MouseY - win->TopEdge, 0, 0);
776 FreeVec(filelist);
779 if (!IsListEmpty(&AppList))
781 struct Node *succ;
782 struct Node *s = AppList.lh_Head;
783 while (((succ = ((struct Node*) s)->ln_Succ) != NULL))
785 FreeVec(((struct AppW *) s)->name);
786 FreeVec(s);
787 s = succ;
794 AROS_USERFUNC_EXIT
796 #ifndef __AROS__
797 MakeStaticHook(Hook_ActionFunc,Wanderer__HookFunc_ActionFunc);
798 #endif
801 ///Wanderer__HookFunc_StandardFunc()
802 #ifdef __AROS__
803 AROS_UFH3
805 void, Wanderer__HookFunc_StandardFunc,
806 AROS_UFHA(struct Hook *, hook, A0),
807 AROS_UFHA(void *, dummy, A2),
808 AROS_UFHA(void **, funcptr, A1)
811 #else
812 HOOKPROTO(Wanderer__HookFunc_StandardFunc, void, void *dummy, void **funcptr)
814 #endif
815 AROS_USERFUNC_INIT
817 void (*func) (ULONG *) = (void (*)(ULONG *)) (*funcptr);
818 if (func) func((ULONG *)(funcptr + 1));
820 AROS_USERFUNC_EXIT
822 #ifndef __AROS__
823 MakeStaticHook(Hook_StandardFunc,Wanderer__HookFunc_StandardFunc);
824 #endif
827 ///Wanderer__HookFunc_BackdropFunc()
828 #ifdef __AROS__
829 AROS_UFH3
831 void, Wanderer__HookFunc_BackdropFunc,
832 AROS_UFHA(struct Hook *, hook, A0),
833 AROS_UFHA(void *, dummy, A2),
834 AROS_UFHA(void **, funcptr, A1)
837 #else
838 HOOKPROTO(Wanderer__HookFunc_BackdropFunc, void, void *dummy, void **funcptr)
840 #endif
841 AROS_USERFUNC_INIT
843 struct Wanderer_DATA *data = INST_DATA(_WandererIntern_CLASS, _WandererIntern_AppObj);
844 BOOL wb_iscurrentlybd;
846 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
848 D(bug("[Wanderer] %s: Private data @ %x\n", __PRETTY_FUNCTION__, data));
850 if (!data->wd_WorkbenchWindow)
852 D(bug("[Wanderer] %s: No Workbench Window\n", __PRETTY_FUNCTION__));
853 return;
856 wb_iscurrentlybd = (BOOL)XGET(data->wd_WorkbenchWindow, MUIA_IconWindow_IsBackdrop);
858 if (wb_iscurrentlybd != data->wd_Option_BackDropMode)
860 BOOL isOpen = (BOOL)XGET(data->wd_WorkbenchWindow, MUIA_Window_Open);
861 Object *win_Active = NULL;
863 D(bug("[Wanderer] %s: Backdrop mode change requested!\n", __PRETTY_FUNCTION__));
864 D(bug("[Wanderer] %s: Disposing of existing Workbench window Obj ..\n", __PRETTY_FUNCTION__));
865 if (isOpen)
866 SET(data->wd_WorkbenchWindow, MUIA_Window_Open, FALSE);
868 if (data->wd_WorkbenchWindow == data->wd_ActiveWindow)
870 data->wd_ActiveWindow = NULL;
872 else
874 win_Active = data->wd_ActiveWindow;
877 /* Kill our close request notification .. */
878 DoMethod
880 data->wd_WorkbenchWindow, MUIM_KillNotify, MUIA_Window_CloseRequest
883 /* .. And dispose of the window */
884 DoMethod(_WandererIntern_AppObj, OM_REMMEMBER, data->wd_WorkbenchWindow);
885 MUI_DisposeObject(data->wd_WorkbenchWindow);
886 data->wd_WorkbenchWindow = NULL;
888 #if defined(DEBUG)
889 if (data->wd_Option_BackDropMode)
891 D(bug("[Wanderer] %s: Creating new Workbench window Obj (BACKDROP MODE)..\n", __PRETTY_FUNCTION__));
893 else
895 D(bug("[Wanderer] %s: Creating new Workbench window Obj (NORMAL MODE)..\n", __PRETTY_FUNCTION__));
897 #endif
898 SetVar(wand_backdropprefs, data->wd_Option_BackDropMode ? "True" : "False", -1, GVF_GLOBAL_ONLY | GVF_SAVE_VAR);
900 data->wd_WorkbenchWindow = (Object *) DoMethod
902 _WandererIntern_AppObj, MUIM_Wanderer_CreateDrawerWindow, (IPTR) NULL
905 if ((data->wd_WorkbenchWindow) && (isOpen))
907 D(bug("[Wanderer] %s: Making Workbench window visable..\n", __PRETTY_FUNCTION__));
908 DoMethod(data->wd_WorkbenchWindow, MUIM_IconWindow_Open);
909 DoMethod(data->wd_WorkbenchWindow, MUIM_Window_ToBack);
912 if (win_Active)
914 SET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow, win_Active);
916 else if (data->wd_WorkbenchWindow)
918 SET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow, data->wd_WorkbenchWindow);
921 AROS_USERFUNC_EXIT
923 #ifndef __AROS__
924 MakeStaticHook(Hook_BackdropFunc,Wanderer__HookFunc_BackdropFunc);
925 #endif
927 /******** code from workbench/c/Info.c *******************/
928 ///fmtlarge()
929 static void fmtlarge(UBYTE *buf, IPTR num)
931 UQUAD d;
932 const UBYTE *ch;
933 struct
935 ULONG val;
936 ULONG dec;
937 } array =
939 num,
943 if (num >= 0x40000000)
945 array.val = num >> 30;
946 d = ((UQUAD)num * 100 + 0x20000000) / 0x40000000;
947 array.dec = d % 100;
948 //ch = 'G';
949 ch = _(MSG_MEM_G);
951 else if (num >= 0x100000)
953 array.val = num >> 20;
954 d = ((UQUAD)num * 100 + 0x80000) / 0x100000;
955 array.dec = d % 100;
956 //ch = 'M';
957 ch = _(MSG_MEM_M);
959 else if (num >= 0x400)
961 array.val = num >> 10;
962 d = (num * 100 + 0x200) / 0x400;
963 array.dec = d % 100;
964 //ch = 'K';
965 ch = _(MSG_MEM_K);
967 else
969 array.val = num;
970 array.dec = 0;
971 d = 0;
972 //ch = 'B';
973 ch = _(MSG_MEM_B);
976 if (!array.dec && (d > array.val * 100))
978 array.val++;
981 RawDoFmt(array.dec ? "%lu.%02lu" : "%lu", (RAWARG)&array, NULL, buf);
982 while (*buf) { buf++; }
983 *buf++ = *ch;
984 *buf = '\0';
988 ///GetScreenTitle()
989 STRPTR GetScreenTitle(VOID)
991 static TEXT title[256];
992 UBYTE chip[14], fast[14];
993 IPTR __availMem;
995 __availMem = AvailMem(MEMF_CHIP);
996 fmtlarge(chip, __availMem);
997 __availMem = AvailMem(MEMF_FAST);
998 fmtlarge(fast, __availMem);
1000 sprintf(title, _(MSG_SCREENTITLE), chip, fast);
1002 return title;
1006 ///GetUserScreenTitle()
1007 STRPTR GetUserScreenTitle(Object *self)
1009 /*Work in progress :-)
1011 char *screentitlestr = NULL;
1012 int screentitleleng;
1014 GET(self, MUIA_IconWindowExt_ScreenTitle_String, &screentitlestr);
1016 if (screentitlestr == NULL)
1017 screentitlestr = "";
1019 screentitleleng = strlen(screentitlestr);
1021 if (screentitleleng<1)
1023 return GetScreenTitle();
1025 return screentitlestr;
1030 enum
1032 MEN_WANDERER = 1,
1033 MEN_WANDERER_BACKDROP,
1034 MEN_WANDERER_EXECUTE,
1035 MEN_WANDERER_SHELL,
1036 MEN_WANDERER_AROS_GUISETTINGS,
1037 MEN_WANDERER_AROS_ABOUT,
1038 MEN_WANDERER_ABOUT,
1039 MEN_WANDERER_QUIT,
1040 MEN_WANDERER_SHUTDOWN,
1042 MEN_WINDOW_NEW_DRAWER,
1043 MEN_WINDOW_OPEN_PARENT,
1044 MEN_WINDOW_CLOSE,
1045 MEN_WINDOW_UPDATE,
1047 MEN_WINDOW_SELECT,
1048 MEN_WINDOW_CLEAR,
1050 MEN_WINDOW_SNAP_WIN,
1051 MEN_WINDOW_SNAP_ALL,
1053 MEN_WINDOW_VIEW_ICON,
1054 MEN_WINDOW_VIEW_DETAIL,
1055 MEN_WINDOW_VIEW_ALL,
1056 MEN_WINDOW_VIEW_HIDDEN,
1058 MEN_WINDOW_SORT_ENABLE,
1059 MEN_WINDOW_SORT_NOW,
1060 MEN_WINDOW_SORT_NAME,
1061 MEN_WINDOW_SORT_TYPE,
1062 MEN_WINDOW_SORT_DATE,
1063 MEN_WINDOW_SORT_SIZE,
1064 MEN_WINDOW_SORT_REVERSE,
1065 MEN_WINDOW_SORT_TOPDRAWERS,
1066 MEN_WINDOW_SORT_GROUP,
1068 MEN_WINDOW_FIND,
1070 MEN_ICON_OPEN,
1071 MEN_ICON_RENAME,
1072 MEN_ICON_INFORMATION,
1073 MEN_ICON_SNAPSHOT,
1074 MEN_ICON_UNSNAPSHOT,
1075 MEN_ICON_LEAVEOUT,
1076 MEN_ICON_PUTAWAY,
1077 MEN_ICON_DELETE,
1078 MEN_ICON_FORMAT,
1079 MEN_ICON_EMPTYTRASH
1083 ///execute_open_with_command()
1084 /**************************************************************************
1085 Open the execute window. Similar to below but you can also set the
1086 command. Called when item is openend
1087 **************************************************************************/
1088 void execute_open_with_command(BPTR cd, STRPTR contents)
1090 BPTR lock;
1092 if (cd !=(BPTR) NULL) lock = cd;
1093 else lock = Lock("RAM:", ACCESS_READ);
1095 OpenWorkbenchObject
1097 "WANDERER:Tools/ExecuteCommand",
1098 WBOPENA_ArgLock, (IPTR) lock,
1099 WBOPENA_ArgName, (IPTR) contents,
1100 TAG_DONE
1103 if (cd ==(BPTR) NULL) UnLock(lock);
1107 ///wanderer_menufunc_wanderer_execute()
1108 /**************************************************************************
1109 Open the execute window
1111 This function will always get the current drawer as argument
1112 **************************************************************************/
1113 VOID wanderer_menufunc_wanderer_execute(STRPTR *cdptr)
1115 //TODO: remove the STRPTR *cdptr from top
1116 //TODO:remove this commented out stuff
1117 //BPTR lock = NULL;
1118 //if (cdptr != NULL) lock = Lock(*cdptr, SHARED_LOCK);
1119 Object *win = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1120 STRPTR dr = ( STRPTR )XGET( win, MUIA_IconWindow_Location );
1121 BPTR cd = Lock(dr,SHARED_LOCK);
1122 execute_open_with_command(cd, NULL);
1123 if (cd) UnLock(cd);
1125 /*******************************/
1128 ///wanderer_menufunc_wanderer_shell()
1129 void wanderer_menufunc_wanderer_shell(STRPTR *cd_ptr)
1131 Object *win = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1132 STRPTR dr = ( STRPTR )XGET( win, MUIA_IconWindow_Location );
1133 BPTR cd, olddir;
1135 if (!dr)
1137 dr = "";
1140 cd = Lock(dr, ACCESS_READ);
1141 olddir = CurrentDir(cd);
1142 Execute("", BNULL, BNULL);
1143 CurrentDir(olddir);
1144 UnLock(cd);
1148 ///wanderer_menufunc_wanderer_backdrop()
1149 void wanderer_menufunc_wanderer_backdrop(Object **pstrip)
1151 struct Wanderer_DATA *data = INST_DATA(_WandererIntern_CLASS, _WandererIntern_AppObj);
1152 Object *strip = *pstrip;
1153 Object *item = FindMenuitem(strip, MEN_WANDERER_BACKDROP);
1155 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1157 if (item != NULL)
1159 data->wd_Option_BackDropMode = (BOOL)XGET(item, MUIA_Menuitem_Checked);
1160 SET(data->wd_WorkbenchWindow, MUIA_IconWindow_IsBackdrop, data->wd_Option_BackDropMode);
1165 ///wanderer_menufunc_window_find()
1166 void wanderer_menufunc_window_find(void)
1168 #if 0
1169 Object *win = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1170 STRPTR dr = ( STRPTR )XGET( win, MUIA_IconWindow_Location );
1171 Object *actwindow = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1172 Object *wbwindow = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_WorkbenchWindow);
1173 BPTR lock;
1175 D(bug("[Wanderer]: %s('%s')\n", __PRETTY_FUNCTION__, dr));
1177 if (actwindow == wbwindow)
1179 /* This check is necessary because WorkbenchWindow has path RAM: */
1180 D(bug("[Wanderer] %s: Can't call WBNewDrawer for WorkbenchWindow\n", __PRETTY_FUNCTION__));
1181 return;
1183 if ( XGET(actwindow, MUIA_Window_Open) == FALSE )
1185 D(bug("[Wanderer] %s: Can't call WBNewDrawer: the active window isn't open\n", __PRETTY_FUNCTION__));
1186 return;
1189 lock = Lock(dr, ACCESS_READ);
1190 #endif
1192 OpenWorkbenchObject
1194 "SYS:System/Find",
1195 // WBOPENA_ArgLock, (IPTR) lock,
1196 // WBOPENA_ArgName, 0,
1197 TAG_DONE
1199 //UnLock(lock);
1204 ///wanderer_menufunc_window_newdrawer()
1205 void wanderer_menufunc_window_newdrawer(STRPTR *cdptr)
1207 //TODO: remove the STRPTR *cdptr from top
1209 Object *win = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1210 STRPTR dr = ( STRPTR )XGET( win, MUIA_IconWindow_Location );
1211 Object *actwindow = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1212 Object *wbwindow = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_WorkbenchWindow);
1213 BPTR lock;
1215 D(bug("[Wanderer]: %s('%s')\n", __PRETTY_FUNCTION__, dr));
1217 if (actwindow == wbwindow)
1219 /* This check is necessary because WorkbenchWindow has path RAM: */
1220 D(bug("[Wanderer] %s: Can't call WBNewDrawer for WorkbenchWindow\n", __PRETTY_FUNCTION__));
1221 return;
1223 if ( XGET(actwindow, MUIA_Window_Open) == FALSE )
1225 D(bug("[Wanderer] %s: Can't call WBNewDrawer: the active window isn't open\n", __PRETTY_FUNCTION__));
1226 return;
1229 lock = Lock(dr, ACCESS_READ);
1230 OpenWorkbenchObject
1232 "WANDERER:Tools/WBNewDrawer",
1233 WBOPENA_ArgLock, (IPTR) lock,
1234 WBOPENA_ArgName, 0,
1235 TAG_DONE
1237 UnLock(lock);
1241 ///wanderer_menufunc_window_openparent()
1242 void wanderer_menufunc_window_openparent(STRPTR *cdptr)
1244 //TODO: Remove the **cdptr stuff from top
1245 Object *win = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1246 STRPTR dr = ( STRPTR )XGET( win, MUIA_IconWindow_Location );
1248 IPTR path_len=0;
1249 STRPTR last_letter=NULL;
1250 STRPTR thispath;
1251 STRPTR buf;
1252 Object *cstate;
1253 Object *child;
1254 BOOL foundSlash, foundColon;
1255 int i = 0;
1257 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1259 last_letter = &dr[ strlen(dr) - 1 ];
1261 thispath = FilePart(dr);
1263 if (*last_letter==0x3a) return; /* Top Drawer has no parent to open */
1265 last_letter = &thispath[strlen(thispath)-1];
1267 if (*last_letter==0x3a)
1268 path_len = (IPTR)(thispath-(IPTR)(dr));
1269 else
1270 path_len = (IPTR)((thispath-(IPTR)(dr))-1);
1272 buf = AllocVec((path_len+1),MEMF_PUBLIC|MEMF_CLEAR);
1273 if (buf == NULL)
1274 return;
1275 CopyMem(dr, buf, path_len);
1277 // Make sure we have a correct path
1278 foundSlash = FALSE, foundColon = FALSE;
1279 i = 0; for ( ; i < path_len; i++ )
1281 if ( buf[ i ] == '/' ) foundSlash = TRUE;
1282 if ( buf[ i ] == ':' ) foundColon = TRUE;
1284 if ( !foundColon && !foundSlash )
1286 STRPTR newbuf = AllocVec ((path_len + 2), MEMF_PUBLIC|MEMF_CLEAR);
1287 if (newbuf == NULL)
1288 return;
1289 sprintf(newbuf,"%s:",buf);
1290 FreeVec(buf);
1291 buf = newbuf;
1293 // Done with path correction check
1295 /* Check if window already exists. If so, ensure it's open and brought to the front */
1296 cstate = (Object*)(((struct List*)XGET(_WandererIntern_AppObj, MUIA_Application_WindowList))->lh_Head);
1297 while ((child = NextObject(&cstate)))
1299 if (XGET(child, MUIA_UserData))
1301 STRPTR child_drawer = (STRPTR)XGET(child, MUIA_IconWindow_Location);
1302 if (child_drawer && !Stricmp(buf,child_drawer))
1304 int is_open = XGET(child, MUIA_Window_Open);
1305 if (!is_open)
1306 DoMethod(child, MUIM_IconWindow_Open);
1307 else
1309 DoMethod(child, MUIM_Window_ToFront);
1310 SET(child, MUIA_Window_Activate, TRUE);
1312 FreeVec(buf);
1313 return;
1318 /* Open a new window */
1319 DoMethod(_WandererIntern_AppObj, MUIM_Wanderer_CreateDrawerWindow, (IPTR) buf);
1320 FreeVec(buf);
1324 ///wanderer_menufunc_window_close()
1325 void wanderer_menufunc_window_close()
1327 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1329 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1331 SET(window, MUIA_Window_CloseRequest, TRUE);
1335 ///wanderer_menufunc_window_update()
1336 void wanderer_menufunc_window_update()
1338 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1339 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1340 struct IconList_Entry *entry = (APTR) MUIV_IconList_NextIcon_Start;
1342 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1344 if (iconList != NULL)
1347 * Reset the ie_Provided[X|Y] to DiskObject values. This will cause all icons to return to their
1348 * snapshoted position or get layouted. This is bahavior only present in this menu action. This is Wanderer
1349 * function, not IconList function, thus the implementation is here.
1353 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Visible, (IPTR) &entry);
1355 if ((IPTR)entry != MUIV_IconList_NextIcon_End)
1358 LONG x = NO_ICON_POSITION, y = NO_ICON_POSITION;
1360 if (entry->ile_IconEntry->ie_DiskObj)
1362 x = entry->ile_IconEntry->ie_DiskObj->do_CurrentX;
1363 y = entry->ile_IconEntry->ie_DiskObj->do_CurrentY;
1366 entry->ile_IconEntry->ie_IconX = x;
1367 entry->ile_IconEntry->ie_IconY = y;
1369 DoMethod(iconList, MUIM_IconList_PropagateEntryPos, entry->ile_IconEntry);
1371 else break;
1372 } while (TRUE);
1374 DoMethod(iconList, MUIM_IconList_Update);
1375 DoMethod(iconList, MUIM_IconList_Sort);
1380 ///wanderer_menufunc_window_cleanup()
1381 void wanderer_menufunc_window_cleanup()
1383 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1384 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1386 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1388 if (iconList != NULL)
1391 * Cleanup ignores all snapshoted / provided positions and re-layouts all icons. To enable this,
1392 * temporarilly set the AutoSort flag. This is Wanderer function, not IconList function, thus the
1393 * implementation is here.
1395 IPTR sortFlags = 0;
1397 get(iconList, MUIA_IconList_SortFlags, &sortFlags);
1399 if ((sortFlags & MUIV_IconList_Sort_AutoSort) == 0)
1401 sortFlags |= MUIV_IconList_Sort_AutoSort;
1402 set(iconList, MUIA_IconList_SortFlags, sortFlags);
1404 DoMethod(iconList, MUIM_IconList_Sort);
1406 get(iconList, MUIA_IconList_SortFlags, &sortFlags);
1407 sortFlags &= ~MUIV_IconList_Sort_AutoSort;
1408 set(iconList, MUIA_IconList_SortFlags, sortFlags);
1410 else
1412 DoMethod(iconList, MUIM_IconList_Sort);
1420 ///wanderer_menufunc_window_clear()
1421 void wanderer_menufunc_window_clear()
1423 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1424 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1426 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1428 if (iconList != NULL)
1430 DoMethod(iconList, MUIM_IconList_UnselectAll);
1435 ///wanderer_menufunc_window_select()
1436 void wanderer_menufunc_window_select()
1438 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1439 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1441 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1443 if (iconList != NULL)
1445 DoMethod(iconList, MUIM_IconList_SelectAll);
1450 ///wanderer_menufunc_window_snapshot()
1451 void wanderer_menufunc_window_snapshot(IPTR *flags)
1453 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1454 BOOL snapshot_all = *flags;
1456 DoMethod(window, MUIM_IconWindow_Snapshot, snapshot_all);
1460 ///wanderer_menufunc_window_view_iconsonly(Object **pstrip)
1461 void wanderer_menufunc_window_view_iconsonly(Object **pstrip)
1463 Object *strip = *pstrip;
1464 Object *item = FindMenuitem(strip, MEN_WINDOW_VIEW_ALL);
1465 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1466 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1468 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1470 if ((item != NULL) && (iconList != NULL))
1472 IPTR display_bits = 0, menu_view_state = 0;
1473 GET(iconList, MUIA_IconList_DisplayFlags, &display_bits);
1475 GET(item, MUIA_Menuitem_Checked, &menu_view_state);
1477 if (menu_view_state)
1479 display_bits &= ~ICONLIST_DISP_SHOWINFO;
1481 else
1483 display_bits |= ICONLIST_DISP_SHOWINFO;
1486 SET(iconList, MUIA_IconList_DisplayFlags, display_bits);
1487 DoMethod(iconList, MUIM_IconList_Sort);
1492 void wanderer_menufunc_window_view_modeicon(Object **pstrip)
1494 Object *strip = *pstrip;
1495 Object *item = FindMenuitem(strip, MEN_WINDOW_VIEW_ICON);
1496 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1497 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1499 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1501 if ((item != NULL) && (iconList != NULL))
1503 IPTR display_bits = 0, menu_view_state = 0;
1504 GET(iconList, MUIA_IconList_DisplayFlags, &display_bits);
1506 display_bits &= ~(ICONLIST_DISP_MODEDEFAULT | ICONLIST_DISP_MODELABELRIGHT | ICONLIST_DISP_MODELIST);
1508 GET(item, MUIA_Menuitem_Checked, &menu_view_state);
1510 if (menu_view_state == TRUE)
1512 // if ( != LABELRIGHT)
1513 display_bits |= ICONLIST_DISP_MODEDEFAULT;
1514 // else
1515 // display_bits |= ICONLIST_DISP_MODELABELRIGHT;
1518 SET(iconList, MUIA_IconList_DisplayFlags, display_bits);
1519 DoMethod(iconList, MUIM_IconList_Sort);
1523 void wanderer_menufunc_window_view_modelist(Object **pstrip)
1525 Object *strip = *pstrip;
1526 Object *item = FindMenuitem(strip, MEN_WINDOW_VIEW_DETAIL);
1527 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1528 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1530 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1532 if ((item != NULL) && (iconList != NULL))
1534 IPTR display_bits = 0, menu_view_state = 0;
1535 GET(iconList, MUIA_IconList_DisplayFlags, &display_bits);
1537 display_bits &= ~(ICONLIST_DISP_MODEDEFAULT | ICONLIST_DISP_MODELABELRIGHT | ICONLIST_DISP_MODELIST);
1539 GET(item, MUIA_Menuitem_Checked, &menu_view_state);
1541 if (menu_view_state == TRUE)
1543 display_bits |= ICONLIST_DISP_MODELIST;
1546 SET(iconList, MUIA_IconList_DisplayFlags, display_bits);
1547 DoMethod(iconList, MUIM_IconList_Sort);
1551 ///wanderer_menufunc_window_view_hidden(Object **pstrip)
1552 void wanderer_menufunc_window_view_hidden(Object **pstrip)
1554 Object *strip = *pstrip;
1555 Object *item = FindMenuitem(strip, MEN_WINDOW_VIEW_HIDDEN);
1556 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1557 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1559 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1561 if ((item != NULL) && (iconList != NULL))
1563 IPTR display_bits = 0, menu_view_state = 0;
1564 GET(iconList, MUIA_IconList_DisplayFlags, &display_bits);
1566 GET(item, MUIA_Menuitem_Checked, &menu_view_state);
1568 if (menu_view_state)
1570 display_bits |= ICONLIST_DISP_SHOWHIDDEN;
1572 else
1574 display_bits &= ~ICONLIST_DISP_SHOWHIDDEN;
1577 SET(iconList, MUIA_IconList_DisplayFlags, display_bits);
1578 DoMethod(iconList, MUIM_IconList_Sort);
1582 ///wanderer_menufunc_window_sort_enable()
1583 void wanderer_menufunc_window_sort_enable(Object **pstrip)
1585 Object *strip = *pstrip;
1586 Object *item = FindMenuitem(strip, MEN_WINDOW_SORT_ENABLE);
1587 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1588 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1590 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1592 if (item != NULL)
1594 if (!XGET(item, MUIA_Disabled) && (iconList != NULL))
1596 IPTR sort_bits = 0;
1598 GET(iconList, MUIA_IconList_SortFlags, &sort_bits);
1600 if( XGET(item, MUIA_Menuitem_Checked) )
1602 sort_bits &= ~(MUIV_IconList_Sort_Orders|MUIV_IconList_Sort_Reverse);
1603 sort_bits |= MUIV_IconList_Sort_DrawersMixed;
1604 sort_bits |= MUIV_IconList_Sort_AutoSort;
1606 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_DATE)) != NULL)
1608 NNSET(item, MUIA_Disabled, FALSE);
1609 if( XGET(item, MUIA_Menuitem_Checked) )
1611 sort_bits |= MUIV_IconList_Sort_ByDate;
1614 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_SIZE)) != NULL)
1616 NNSET(item, MUIA_Disabled, FALSE);
1617 if( XGET(item, MUIA_Menuitem_Checked) )
1619 sort_bits |= MUIV_IconList_Sort_BySize;
1622 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_TYPE)) != NULL)
1624 NNSET(item, MUIA_Disabled, FALSE);
1625 if( XGET(item, MUIA_Menuitem_Checked) )
1627 sort_bits |= MUIV_IconList_Sort_ByType;
1630 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_NAME)) != NULL)
1632 NNSET(item, MUIA_Disabled, FALSE);
1633 if( XGET(item, MUIA_Menuitem_Checked) )
1635 sort_bits |= MUIV_IconList_Sort_ByName;
1638 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_REVERSE)) != NULL)
1640 NNSET(item, MUIA_Disabled, FALSE);
1641 if( XGET(item, MUIA_Menuitem_Checked) )
1643 sort_bits |= MUIV_IconList_Sort_Reverse;
1646 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_TOPDRAWERS)) != NULL)
1648 NNSET(item, MUIA_Disabled, FALSE);
1649 if( XGET(item, MUIA_Menuitem_Checked) )
1651 sort_bits &= ~MUIV_IconList_Sort_DrawersMixed;
1654 D(bug("[Wanderer] %s: (enable) Setting sort flags %08x\n", __PRETTY_FUNCTION__, sort_bits));
1656 else
1658 sort_bits &= ~MUIV_IconList_Sort_AutoSort;
1660 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_DATE)) != NULL)
1662 NNSET(item, MUIA_Disabled, TRUE);
1664 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_SIZE)) != NULL)
1666 NNSET(item, MUIA_Disabled, TRUE);
1668 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_TYPE)) != NULL)
1670 NNSET(item, MUIA_Disabled, TRUE);
1672 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_NAME)) != NULL)
1674 NNSET(item, MUIA_Disabled, TRUE);
1676 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_REVERSE)) != NULL)
1678 NNSET(item, MUIA_Disabled, TRUE);
1680 if ((item = FindMenuitem(strip, MEN_WINDOW_SORT_TOPDRAWERS)) != NULL)
1682 NNSET(item, MUIA_Disabled, TRUE);
1684 D(bug("[Wanderer] %s: (disable) Setting sort flags %08x\n", __PRETTY_FUNCTION__, sort_bits));
1687 SET(iconList, MUIA_IconList_SortFlags, sort_bits);
1688 DoMethod(iconList, MUIM_IconList_Sort);
1694 ///wanderer_menufunc_window_sort_name()
1695 void wanderer_menufunc_window_sort_name(Object **pstrip)
1697 Object *strip = *pstrip;
1698 Object *item = FindMenuitem(strip, MEN_WINDOW_SORT_NAME);
1699 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1700 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1702 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1704 if (item != NULL && iconList != NULL)
1706 IPTR sort_bits = 0, checked = FALSE;
1707 GET(iconList, MUIA_IconList_SortFlags, &sort_bits);
1708 GET(item, MUIA_Menuitem_Checked, &checked);
1710 sort_bits &= ~MUIV_IconList_Sort_Orders;
1711 if (checked == TRUE)
1713 sort_bits |= MUIV_IconList_Sort_ByName;
1715 SET(iconList, MUIA_IconList_SortFlags, sort_bits);
1716 DoMethod(iconList, MUIM_IconList_Sort);
1721 ///wanderer_menufunc_window_sort_date()
1722 void wanderer_menufunc_window_sort_date(Object **pstrip)
1724 Object *strip = *pstrip;
1725 Object *item = FindMenuitem(strip, MEN_WINDOW_SORT_DATE);
1726 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1727 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1729 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1731 if (item != NULL && iconList != NULL)
1733 IPTR sort_bits = 0, checked = FALSE;
1734 GET(iconList, MUIA_IconList_SortFlags, &sort_bits);
1735 GET(item, MUIA_Menuitem_Checked, &checked);
1737 sort_bits &= ~MUIV_IconList_Sort_Orders;
1738 if (checked == TRUE)
1740 sort_bits |= MUIV_IconList_Sort_ByDate;
1742 SET(iconList, MUIA_IconList_SortFlags, sort_bits);
1743 DoMethod(iconList, MUIM_IconList_Sort);
1748 ///wanderer_menufunc_window_sort_size()
1749 void wanderer_menufunc_window_sort_size(Object **pstrip)
1751 Object *strip = *pstrip;
1752 Object *item = FindMenuitem(strip, MEN_WINDOW_SORT_SIZE);
1753 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1754 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1756 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1758 if (item != NULL && iconList != NULL)
1760 IPTR sort_bits = 0, checked = FALSE;
1761 GET(iconList, MUIA_IconList_SortFlags, &sort_bits);
1762 GET(item, MUIA_Menuitem_Checked, &checked);
1764 D(bug("[Wanderer]: %s: (start) sort flags %08x\n", __PRETTY_FUNCTION__, sort_bits));
1765 sort_bits &= ~MUIV_IconList_Sort_Orders;
1766 if (checked == TRUE)
1768 sort_bits |= MUIV_IconList_Sort_BySize;
1770 D(bug("[Wanderer]: %s: (end) sort flags %08x\n", __PRETTY_FUNCTION__, sort_bits));
1771 SET(iconList, MUIA_IconList_SortFlags, sort_bits);
1772 DoMethod(iconList, MUIM_IconList_Sort);
1777 ///wanderer_menufunc_window_sort_type()
1778 void wanderer_menufunc_window_sort_type(Object **pstrip)
1780 Object *strip = *pstrip;
1781 Object *item = FindMenuitem(strip, MEN_WINDOW_SORT_TYPE);
1782 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1783 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1785 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1787 if (item != NULL && iconList != NULL)
1789 IPTR sort_bits = 0, checked = FALSE;
1790 GET(iconList, MUIA_IconList_SortFlags, &sort_bits);
1791 GET(item, MUIA_Menuitem_Checked, &checked);
1793 sort_bits &= ~MUIV_IconList_Sort_Orders;
1794 if (checked == TRUE)
1796 sort_bits |= MUIV_IconList_Sort_ByType;
1798 SET(iconList, MUIA_IconList_SortFlags, sort_bits);
1799 DoMethod(iconList, MUIM_IconList_Sort);
1804 ///wanderer_menufunc_window_sort_reverse()
1805 void wanderer_menufunc_window_sort_reverse(Object **pstrip)
1807 Object *strip = *pstrip;
1808 Object *item = FindMenuitem(strip, MEN_WINDOW_SORT_REVERSE);
1809 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1810 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1812 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1814 if (item != NULL && iconList != NULL)
1816 IPTR sort_bits = 0, checked = FALSE;
1817 GET(iconList, MUIA_IconList_SortFlags, &sort_bits);
1818 GET(item, MUIA_Menuitem_Checked, &checked);
1820 if (checked == TRUE)
1822 sort_bits |= MUIV_IconList_Sort_Reverse;
1824 else
1826 sort_bits &= ~MUIV_IconList_Sort_Reverse;
1829 SET(iconList, MUIA_IconList_SortFlags, sort_bits);
1830 DoMethod(iconList, MUIM_IconList_Sort);
1835 ///wanderer_menufunc_window_sort_topdrawers()
1836 void wanderer_menufunc_window_sort_topdrawers(Object **pstrip)
1838 Object *strip = *pstrip;
1839 Object *item = FindMenuitem(strip, MEN_WINDOW_SORT_TOPDRAWERS);
1840 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1841 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1843 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
1845 if (item != NULL && iconList != NULL)
1847 IPTR sort_bits = 0, checked = FALSE;
1848 GET(iconList, MUIA_IconList_SortFlags, &sort_bits);
1849 GET(item, MUIA_Menuitem_Checked, &checked);
1851 if (checked == TRUE)
1853 sort_bits &= ~MUIV_IconList_Sort_DrawersMixed;
1855 else
1857 sort_bits |= MUIV_IconList_Sort_DrawersMixed;
1860 SET(iconList, MUIA_IconList_SortFlags, sort_bits);
1861 DoMethod(iconList, MUIM_IconList_Sort);
1866 ///wanderer_menufunc_icon_open()
1867 void wanderer_menufunc_icon_open()
1869 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1870 DoMethod(window, MUIM_IconWindow_DoubleClicked);
1874 ///wanderer_menufunc_icon_rename()
1875 void wanderer_menufunc_icon_rename(void)
1877 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1878 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1879 struct IconList_Entry *entry = (APTR) MUIV_IconList_NextIcon_Start;
1883 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR) &entry);
1885 if ((IPTR)entry != MUIV_IconList_NextIcon_End)
1887 if (entry->type == ILE_TYPE_APPICON)
1888 continue; /* TODO: Implement */
1891 BPTR lock = Lock(entry->ile_IconEntry->ie_IconNode.ln_Name, ACCESS_READ);
1892 BPTR parent = ParentDir(lock);
1893 UnLock(lock);
1895 D(bug("[Wanderer] %s: selected = '%s'\n", __PRETTY_FUNCTION__,
1896 entry->ile_IconEntry->ie_IconNode.ln_Name));
1898 OpenWorkbenchObject
1900 "WANDERER:Tools/WBRename",
1901 WBOPENA_ArgLock, (IPTR) parent,
1902 WBOPENA_ArgName, (IPTR) FilePart(entry->ile_IconEntry->ie_IconNode.ln_Name),
1903 TAG_DONE
1906 D(bug("[Wanderer] %s: selected = '%s'\n", __PRETTY_FUNCTION__,
1907 entry->ile_IconEntry->ie_IconNode.ln_Name));
1909 UnLock(parent);
1912 else
1914 break;
1916 } while (TRUE);
1920 ///wanderer_menufunc_icon_information()
1921 void wanderer_menufunc_icon_information()
1923 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
1924 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
1925 struct IconList_Entry *entry = (IPTR)MUIV_IconList_NextIcon_Start;
1927 D(bug("[Wanderer] %s: Window @ %p, IconList @ %p\n", __PRETTY_FUNCTION__, window, iconList));
1931 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&entry);
1933 if ((IPTR)entry != MUIV_IconList_NextIcon_End)
1935 if (entry->type == ILE_TYPE_APPICON)
1936 continue; /* TODO: Implement */
1939 BPTR lock, parent;
1940 STRPTR name, file;
1942 file = entry->ile_IconEntry->ie_IconNode.ln_Name;
1943 D(bug("[Wanderer] %s: selected = '%s'\n", __PRETTY_FUNCTION__, file));
1945 attemptlock:
1947 D(bug("[Wanderer] %s: Trying with '%s'\n", __PRETTY_FUNCTION__, file));
1949 if ((lock = Lock(file, ACCESS_READ)) == BNULL)
1951 D(bug("[Wanderer] %s: couldnt lock '%s'\n", __PRETTY_FUNCTION__, file));
1952 if ((strlen(file) > 5)
1953 && (strcmp(file + strlen(file) - 5, ".info") != 0)
1954 && (file[strlen(file) -1] != ':'))
1956 D(bug("[Wanderer] %s: not a '.info' file or device - check if there is a '.info'..\n",
1957 __PRETTY_FUNCTION__));
1958 file = AllocVec(strlen(entry->ile_IconEntry->ie_IconNode.ln_Name) + 6, MEMF_CLEAR);
1959 if (file == NULL)
1961 UnLock(lock);
1962 return;
1964 sprintf(file, "%s.info", entry->ile_IconEntry->ie_IconNode.ln_Name);
1965 goto attemptlock;
1968 else
1970 name = FilePart(file);
1971 if (name[0])
1973 parent = ParentDir(lock);
1974 UnLock(lock);
1976 else
1978 parent = lock;
1981 D(bug("[Wanderer] %s: Calling WBInfo(name = '%s' parent lock = 0x%p)\n",
1982 __PRETTY_FUNCTION__, name, lock));
1983 WBInfo(parent, name, NULL);
1985 UnLock(parent);
1987 if (file != (STRPTR)entry->ile_IconEntry->ie_IconNode.ln_Name)
1989 FreeVec(file);
1993 else
1995 break;
1997 } while (TRUE);
2001 ///wanderer_menufunc_icon_snapshot()
2002 void wanderer_menufunc_icon_snapshot(IPTR *flags)
2004 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
2005 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
2006 struct IconList_Entry *entry = (IPTR)MUIV_IconList_NextIcon_Start;
2007 struct IconEntry *node = NULL;
2008 BOOL snapshot = *flags;
2009 struct TagItem icontags[] =
2011 { ICONPUTA_OnlyUpdatePosition, TRUE },
2012 { TAG_DONE, 0 }
2015 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
2019 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&entry);
2021 if ((IPTR)entry != MUIV_IconList_NextIcon_End)
2023 if (entry->type == ILE_TYPE_APPICON)
2025 struct AppIcon * ai = (struct AppIcon *)entry->ile_IconEntry->ie_User1;
2027 if (snapshot)
2028 SendAppIconMenuMessage(ai, AMCLASSICON_Snapshot);
2029 else
2030 SendAppIconMenuMessage(ai, AMCLASSICON_UnSnapshot);
2032 continue;
2036 /* On 3.1 Workbench it is not possible to snapshot an object that does not have icon file. Wanderer in such
2037 * case automatically creates and icon because user explicitly request icon snapshot operation
2038 * (see window snapshoting comment) */
2040 node = (struct IconEntry *)((IPTR)entry - ((IPTR)&node->ie_IconListEntry - (IPTR)node));
2041 D(bug("[Wanderer] %s: %s entry = '%s' @ %p, (%p)\n", __PRETTY_FUNCTION__,
2042 (snapshot) ? "SNAPSHOT" : "UNSNAPSHOT", entry->ile_IconEntry->ie_IconNode.ln_Name, entry, node));
2043 if (node->ie_DiskObj)
2045 if (snapshot)
2047 node->ie_DiskObj->do_CurrentX = node->ie_IconX;
2048 node->ie_DiskObj->do_CurrentY = node->ie_IconY;
2050 else
2052 node->ie_DiskObj->do_CurrentX = NO_ICON_POSITION;
2053 node->ie_DiskObj->do_CurrentY = NO_ICON_POSITION;
2055 if (node->ie_Flags & ICONENTRY_FLAG_HASICON)
2056 PutIconTagList(entry->ile_IconEntry->ie_IconNode.ln_Name, node->ie_DiskObj, icontags);
2057 else
2058 PutIconTagList(entry->ile_IconEntry->ie_IconNode.ln_Name, node->ie_DiskObj, TAG_DONE);
2059 D(bug("[Wanderer] %s: saved ..\n", __PRETTY_FUNCTION__));
2061 else
2063 D(bug("[Wanderer] %s: icon has no diskobj!\n", __PRETTY_FUNCTION__));
2066 else
2068 break;
2070 } while (TRUE);
2071 D(bug("[Wanderer] %s: finished ..\n", __PRETTY_FUNCTION__));
2074 static char * get_volume(char * path)
2076 char * _return = NULL;
2077 char * sep = strchr(path, ':');
2079 if (sep)
2081 int i = (int)(sep - path);
2082 _return = AllocVec(i + 2, MEMF_CLEAR);
2083 if (_return != NULL)
2084 CopyMem(path, _return, i + 1);
2087 return _return;
2090 #define BDRPLINELEN_MAX 1024
2092 struct DesktopLinkIcon_Entry
2094 struct Node dlie_Node;
2097 ///wanderer_menufunc_icon_leaveout()
2098 void wanderer_menufunc_icon_leaveout(void)
2100 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
2101 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
2102 Object *rootwindow = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_WorkbenchWindow);
2103 Object *rooticonList = (Object *) XGET(rootwindow, MUIA_IconWindow_IconList);
2104 struct IconList_Entry *entry = (IPTR)MUIV_IconList_NextIcon_Start;
2105 // struct IconEntry *node = NULL;
2106 char *leavout_dir = NULL;
2107 struct DesktopLinkIcon_Entry *bdrpeNode = NULL, *bdrpeNext, *loiEntry = NULL;
2109 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
2111 GET(window, MUIA_IconWindow_Location, &leavout_dir);
2113 if (leavout_dir != NULL)
2115 D(bug("[Wanderer] %s: dir '%s'\n", __PRETTY_FUNCTION__, leavout_dir));
2117 char *entryVolume = get_volume(leavout_dir);
2119 if (entryVolume != NULL)
2121 D(bug("[Wanderer] %s: Updating .backdrop file for volume '%s'.. \n", __PRETTY_FUNCTION__, entryVolume));
2122 char * bdrp_file = NULL;
2124 if ((bdrp_file = AllocVec(strlen(entryVolume) + 9 + 1, MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
2126 struct List bdrp_Entries;
2127 BPTR bdrp_lock = BNULL;
2128 BOOL bdrp_changed = FALSE;
2129 char *linebuf = NULL;
2131 sprintf(bdrp_file, "%s.backdrop", entryVolume);
2133 NEWLIST(&bdrp_Entries);
2135 if ((bdrp_lock = Open(bdrp_file, MODE_OLDFILE)))
2137 D(bug("[Wanderer] %s: Parsing backdrop file: '%s'\n", __PRETTY_FUNCTION__, bdrp_file));
2139 if ((linebuf = AllocMem(BDRPLINELEN_MAX, MEMF_PUBLIC)) != NULL)
2141 while (FGets(bdrp_lock, linebuf, BDRPLINELEN_MAX))
2143 bdrpeNode = AllocMem(sizeof(struct DesktopLinkIcon_Entry), MEMF_CLEAR);
2144 if (bdrpeNode != NULL)
2146 bdrpeNode->dlie_Node.ln_Name = AllocVec(strlen(linebuf) + 1, MEMF_CLEAR);
2147 if (bdrpeNode->dlie_Node.ln_Name != NULL)
2149 CopyMem(linebuf, bdrpeNode->dlie_Node.ln_Name, strlen(linebuf) - 1);
2151 D(bug("[Wanderer] %s: Existing entry '%s'\n", __PRETTY_FUNCTION__,
2152 bdrpeNode->dlie_Node.ln_Name));
2154 AddTail(&bdrp_Entries, &bdrpeNode->dlie_Node);
2156 else
2157 FreeMem(bdrpeNode, sizeof(struct DesktopLinkIcon_Entry));
2160 FreeMem(linebuf, BDRPLINELEN_MAX);
2162 Close(bdrp_lock);
2167 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&entry);
2169 if (((IPTR)entry != MUIV_IconList_NextIcon_End) && ((entry->type == ST_FILE) || (entry->type == ST_USERDIR)))
2171 char *entryDIEString = (entry->ile_IconEntry->ie_IconNode.ln_Name + strlen(entryVolume) - 1);
2172 D(bug("[Wanderer] %s: Leave-Out Entry = '%s' @ %p ('%s')\n", __PRETTY_FUNCTION__,
2173 entry->ile_IconEntry->ie_IconNode.ln_Name, entry, entryDIEString));
2174 loiEntry = NULL;
2176 ForeachNode(&bdrp_Entries, bdrpeNode)
2179 if (strcmp(bdrpeNode->dlie_Node.ln_Name, entryDIEString) == 0)
2181 loiEntry = bdrpeNode;
2182 break;
2186 if (loiEntry == NULL)
2188 bdrpeNode = AllocMem(sizeof(struct DesktopLinkIcon_Entry), MEMF_CLEAR);
2189 if (bdrpeNode != NULL)
2191 bdrpeNode->dlie_Node.ln_Name = AllocVec(strlen(entryDIEString) + 2, MEMF_CLEAR);
2192 if (bdrpeNode->dlie_Node.ln_Name != NULL)
2194 CopyMem(entryDIEString, bdrpeNode->dlie_Node.ln_Name, strlen(entryDIEString));
2196 D(bug("[Wanderer] %s: Created new .backdrop entry for '%s'\n",
2197 __PRETTY_FUNCTION__, bdrpeNode->dlie_Node.ln_Name));
2199 AddTail(&bdrp_Entries, &bdrpeNode->dlie_Node);
2200 bdrp_changed = TRUE;
2202 else
2203 FreeMem(bdrpeNode, sizeof(struct DesktopLinkIcon_Entry));
2207 else
2209 break;
2211 } while (TRUE);
2213 if (bdrp_changed)
2215 D(bug("[Wanderer] %s: Updating backdrop file for '%s' ..\n", __PRETTY_FUNCTION__, entryVolume));
2216 // Write out the new backdrop file :
2217 // this will cause a filesystem notification in the iconwindow_volumeiconlist
2218 // class that will cause the changes to be noticed if the underlying
2219 // filesystem supports it....
2221 if ((bdrp_lock = Open(bdrp_file, MODE_NEWFILE)))
2223 ForeachNode(&bdrp_Entries, bdrpeNode)
2225 D(bug("[Wanderer] %s: Writing entry '%s'\n", __PRETTY_FUNCTION__,
2226 bdrpeNode->dlie_Node.ln_Name));
2227 bdrpeNode->dlie_Node.ln_Name[strlen(bdrpeNode->dlie_Node.ln_Name)] = '\n';
2228 FPuts(bdrp_lock, bdrpeNode->dlie_Node.ln_Name);
2230 Close(bdrp_lock);
2232 struct List *iconList = NULL;
2233 struct IconEntry *entry = NULL;
2235 GET(rooticonList, MUIA_Family_List, &iconList);
2236 ForeachNode(iconList, entry)
2238 if ((entry->ie_IconListEntry.type == ST_ROOT)
2239 && (strncmp(entry->ie_IconListEntry.label, entryVolume, strlen(entry->ie_IconListEntry.label)) == 0))
2241 struct VolumeIcon_Private *volPrivate = entry->ie_IconListEntry.udata;;
2242 if (volPrivate && (volPrivate->vip_FSNotifyRequest.nr_Name == NULL))
2244 // Volume's filesystem couldn't handle fs notifications so we will have to force the update...
2245 D(bug("[Wanderer] %s: Forcing desktop redraw for volume '%s'\n",
2246 __PRETTY_FUNCTION__, entryVolume));
2247 DoMethod(rooticonList, MUIM_IconList_Update);
2248 DoMethod(rooticonList, MUIM_IconList_Sort);
2249 break;
2254 ForeachNodeSafe(&bdrp_Entries, bdrpeNode, bdrpeNext)
2256 Remove(&bdrpeNode->dlie_Node);
2257 FreeVec(bdrpeNode->dlie_Node.ln_Name);
2258 FreeMem(bdrpeNode, sizeof(struct DesktopLinkIcon_Entry));
2260 FreeVec(bdrp_file);
2262 FreeVec(entryVolume);
2266 D(bug("[Wanderer] %s: finished ..\n", __PRETTY_FUNCTION__));
2269 struct PutAwayIcon_Volume
2271 struct Node paiv_Node;
2272 struct List paiv_Entries;
2275 ///wanderer_menufunc_icon_putaway()
2276 void wanderer_menufunc_icon_putaway(void)
2278 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
2279 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
2280 Object *rootwindow = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_WorkbenchWindow);
2281 Object *rooticonList = (Object *) XGET(rootwindow, MUIA_IconWindow_IconList);
2282 struct IconList_Entry *entry = (IPTR)MUIV_IconList_NextIcon_Start;
2283 struct IconEntry *node = NULL;
2284 struct PutAwayIcon_Volume *paivNode = NULL, *paivNext, *paiVolume = NULL;
2285 struct DesktopLinkIcon_Entry *bdrpeNode = NULL, *paieNode = NULL, *paieNext, *paiEntry = NULL;
2286 struct List putawayiconlists;
2288 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
2290 NEWLIST(&putawayiconlists);
2294 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&entry);
2296 if (((IPTR)entry != MUIV_IconList_NextIcon_End) && ((entry->type == ST_LINKFILE) || (entry->type == ST_LINKDIR)))
2298 node = (struct IconEntry *)((IPTR)entry - ((IPTR)&node->ie_IconListEntry - (IPTR)node));
2299 D(bug("[Wanderer] %s: entry = '%s' @ %p, (%p)\n", __PRETTY_FUNCTION__,
2300 entry->ile_IconEntry->ie_IconNode.ln_Name, entry, node));
2302 char *entryVolume = get_volume(entry->ile_IconEntry->ie_IconNode.ln_Name);
2304 if (entryVolume == NULL)
2306 D(bug("[Wanderer] %s: couldnt figure out the volume name.. ?????\n", __PRETTY_FUNCTION__));
2307 continue;
2310 ForeachNode(&putawayiconlists, paivNode)
2312 if (strcmp(paivNode->paiv_Node.ln_Name, entryVolume) == 0)
2314 paiVolume = paivNode;
2318 if (paiVolume == NULL)
2320 paiVolume = AllocMem(sizeof(struct PutAwayIcon_Volume), MEMF_CLEAR);
2321 if (paiVolume != NULL)
2323 paiVolume->paiv_Node.ln_Name = entryVolume;
2324 NEWLIST(&paiVolume->paiv_Entries);
2325 AddTail(&putawayiconlists, &paiVolume->paiv_Node);
2327 else
2329 FreeVec(entryVolume);
2332 else
2334 FreeVec(entryVolume);
2337 if (paiVolume != NULL)
2339 paiEntry = AllocMem(sizeof(struct DesktopLinkIcon_Entry), MEMF_CLEAR);
2340 if (paiEntry != NULL)
2342 paiEntry->dlie_Node.ln_Name = entry->ile_IconEntry->ie_IconNode.ln_Name + strlen(paiVolume->paiv_Node.ln_Name) - 1;
2343 AddTail(&paiVolume->paiv_Entries, &paiEntry->dlie_Node);
2347 else if ((IPTR)entry == MUIV_IconList_NextIcon_End)
2349 break;
2351 } while (TRUE);
2353 ForeachNodeSafe(&putawayiconlists, paivNode, paivNext)
2355 // Open the Backdrop file and read in the existing contents...
2356 char *bdrp_file = NULL;
2358 D(bug("[Wanderer] %s: Processing entries in .backdrop file for '%s' ..\n", __PRETTY_FUNCTION__, paivNode->paiv_Node.ln_Name));
2359 if ((bdrp_file = AllocVec(strlen(paivNode->paiv_Node.ln_Name) + 9 + 1, MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
2361 struct List bdrp_Entries;
2362 BPTR bdrp_lock = BNULL;
2363 BOOL bdrp_changed = FALSE;
2364 char *linebuf = NULL;
2366 sprintf(bdrp_file, "%s.backdrop", paivNode->paiv_Node.ln_Name);
2368 NEWLIST(&bdrp_Entries);
2370 if ((bdrp_lock = Open(bdrp_file, MODE_OLDFILE)))
2372 D(bug("[Wanderer] %s: Parsing backdrop file: '%s'\n", __PRETTY_FUNCTION__, bdrp_file));
2374 if ((linebuf = AllocMem(BDRPLINELEN_MAX, MEMF_PUBLIC)) != NULL)
2376 while (FGets(bdrp_lock, linebuf, BDRPLINELEN_MAX))
2378 bdrpeNode = AllocMem(sizeof(struct DesktopLinkIcon_Entry), MEMF_CLEAR);
2379 if (bdrpeNode != NULL)
2381 bdrpeNode->dlie_Node.ln_Name = AllocVec(strlen(linebuf) + 1, MEMF_CLEAR);
2382 if(bdrpeNode->dlie_Node.ln_Name != NULL)
2384 CopyMem(linebuf, bdrpeNode->dlie_Node.ln_Name, strlen(linebuf) - 1);
2386 D(bug("[Wanderer] %s: Existing entry '%s'\n", __PRETTY_FUNCTION__,
2387 bdrpeNode->dlie_Node.ln_Name));
2389 AddTail(&bdrp_Entries, &bdrpeNode->dlie_Node);
2391 else
2392 FreeVec(bdrpeNode);
2395 FreeMem(linebuf, BDRPLINELEN_MAX);
2397 Close(bdrp_lock);
2400 ForeachNodeSafe(&paivNode->paiv_Entries, paieNode, paieNext)
2402 paiEntry = NULL;
2403 bdrpeNode = NULL;
2404 D(bug("[Wanderer] %s: Checking for '%s' ..\n", __PRETTY_FUNCTION__, paieNode->dlie_Node.ln_Name));
2406 // Find and remove the entry...
2407 ForeachNode(&bdrp_Entries, bdrpeNode)
2410 if (strcmp(paieNode->dlie_Node.ln_Name, bdrpeNode->dlie_Node.ln_Name) == 0)
2412 paiEntry = bdrpeNode;
2413 break;
2417 if (paiEntry != NULL)
2419 D(bug("[Wanderer] %s: Removing entry '%s'\n", __PRETTY_FUNCTION__, paiEntry->dlie_Node.ln_Name));
2420 Remove(&paiEntry->dlie_Node);
2421 FreeVec(paiEntry->dlie_Node.ln_Name);
2422 FreeMem(paiEntry, sizeof(struct DesktopLinkIcon_Entry));
2423 bdrp_changed = TRUE;
2425 Remove(&paieNode->dlie_Node);
2426 FreeMem(paieNode, sizeof(struct DesktopLinkIcon_Entry));
2428 if (bdrp_changed)
2430 D(bug("[Wanderer] %s: Updating backdrop file for '%s' ..\n", __PRETTY_FUNCTION__,
2431 paivNode->paiv_Node.ln_Name));
2432 // Write out the new backdrop file :
2433 // this will cause a filesystem notification in the iconwindow_volumeiconlist
2434 // class that will cause the changes to be noticed ....
2435 if ((bdrp_lock = Open(bdrp_file, MODE_NEWFILE)))
2437 ForeachNode(&bdrp_Entries, bdrpeNode)
2439 D(bug("[Wanderer] %s: Writing entry '%s'\n", __PRETTY_FUNCTION__,
2440 bdrpeNode->dlie_Node.ln_Name));
2441 bdrpeNode->dlie_Node.ln_Name[strlen(bdrpeNode->dlie_Node.ln_Name)] = '\n';
2442 FPuts(bdrp_lock, bdrpeNode->dlie_Node.ln_Name);
2444 Close(bdrp_lock);
2446 struct List *iconList = NULL;
2447 struct IconEntry *entry = NULL;
2449 GET(rooticonList, MUIA_Family_List, &iconList);
2450 ForeachNode(iconList, entry)
2452 if ((entry->ie_IconListEntry.type == ST_ROOT)
2453 && (strncmp(entry->ie_IconListEntry.label, paivNode->paiv_Node.ln_Name, strlen(entry->ie_IconListEntry.label)) == 0))
2455 struct VolumeIcon_Private *volPrivate = entry->ie_IconListEntry.udata;;
2456 if (volPrivate && (volPrivate->vip_FSNotifyRequest.nr_Name == NULL))
2458 // Volume's filesystem couldn't handle fs notifications so we will have to force the update...
2459 D(bug("[Wanderer] %s: Forcing desktop redraw for volume '%s'\n", __PRETTY_FUNCTION__,
2460 paivNode->paiv_Node.ln_Name));
2461 DoMethod(rooticonList, MUIM_IconList_Update);
2462 DoMethod(rooticonList, MUIM_IconList_Sort);
2463 break;
2468 ForeachNodeSafe(&bdrp_Entries, bdrpeNode, paieNext)
2470 Remove(&bdrpeNode->dlie_Node);
2471 FreeVec(bdrpeNode->dlie_Node.ln_Name);
2472 FreeMem(bdrpeNode, sizeof(struct DesktopLinkIcon_Entry));
2474 FreeVec(bdrp_file);
2476 Remove(&paivNode->paiv_Node);
2477 FreeVec(paivNode->paiv_Node.ln_Name);
2478 FreeMem(paivNode, sizeof(struct PutAwayIcon_Volume));
2480 D(bug("[Wanderer] %s: Finished\n", __PRETTY_FUNCTION__));
2483 ///DisposeCopyDisplay()
2484 /* dispose the file copy display */
2485 void DisposeCopyDisplay(struct MUIDisplayObjects *d)
2487 if (d->copyApp)
2489 //SET(d->win,MUIA_Window_Open,FALSE);
2490 MUI_DisposeObject(d->copyApp);
2495 ///CreateCopyDisplay()
2496 /* create the file copy window */
2497 BOOL CreateCopyDisplay(UWORD flags, struct MUIDisplayObjects *d)
2499 BOOL back = FALSE;
2501 Object *group, *fromObject, *toObject, *fileTextObject, *fileLengthObject, *gaugeGroup;
2503 d->stopflag = 0; // will be set to 1 when clicking on stop, than the displayhook can tell actionDir() to stop copy
2504 d->bytes = 0;
2505 d->numfiles = 0;
2506 d->action = flags;
2507 d->smallobjects = 0;
2508 d->copyApp = MUI_NewObject(MUIC_Application,
2509 MUIA_Application_Title, (IPTR)wand_copyprocnamestr,
2510 MUIA_Application_Base, (IPTR)"WANDERER_COPY",
2511 MUIA_Application_Copyright, (IPTR) wand_copyrightstr,
2512 MUIA_Application_Author, (IPTR) wand_authorstr,
2513 MUIA_Application_SingleTask, (IPTR)FALSE,
2514 MUIA_Application_Window, (IPTR)(d->win = MUI_NewObject(MUIC_Window,
2515 MUIA_Window_Title, (IPTR)_(MSG_WANDERER_FILEACCESS),
2516 MUIA_Window_ID, (IPTR)MAKE_ID('W','F','C','R'),
2517 MUIA_Window_Activate, TRUE,
2518 MUIA_Window_DepthGadget, TRUE,
2519 MUIA_Window_DragBar, TRUE,
2520 MUIA_Window_SizeGadget, TRUE,
2521 MUIA_Window_AppWindow, FALSE,
2522 MUIA_Window_CloseGadget, FALSE,
2523 MUIA_Window_Borderless, FALSE,
2524 MUIA_Window_TopEdge, MUIV_Window_TopEdge_Centered,
2525 MUIA_Window_LeftEdge, MUIV_Window_LeftEdge_Centered,
2526 MUIA_Window_Width, MUIV_Window_Width_Visible(60),
2527 WindowContents, (group = MUI_NewObject(MUIC_Group,
2528 Child, (IPTR)(fromObject = MUI_NewObject(MUIC_Text,
2529 MUIA_InnerLeft,(8),
2530 MUIA_InnerRight,(8),
2531 MUIA_InnerTop,(2),
2532 MUIA_InnerBottom,(2),
2533 MUIA_Text_PreParse, (IPTR)"\33c",
2534 TAG_DONE)),
2535 Child, (IPTR)(d->sourceObject = MUI_NewObject(MUIC_Text,
2536 TextFrame,
2537 MUIA_InnerLeft,(8),
2538 MUIA_InnerRight,(8),
2539 MUIA_InnerTop,(2),
2540 MUIA_InnerBottom,(2),
2541 MUIA_Background, MUII_TextBack,
2542 MUIA_Text_PreParse, (IPTR)"\33c",
2543 MUIA_Text_Contents, (IPTR)"---",
2544 TAG_DONE)),
2545 Child, (IPTR)(toObject = MUI_NewObject(MUIC_Text,
2546 MUIA_InnerLeft,(8),
2547 MUIA_InnerRight,(8),
2548 MUIA_InnerTop,(2),
2549 MUIA_InnerBottom,(2),
2550 MUIA_Text_PreParse, (IPTR)"\33c",
2551 TAG_DONE)),
2552 Child, (IPTR)(d->destObject = MUI_NewObject(MUIC_Text,
2553 TextFrame,
2554 MUIA_InnerLeft,(8),
2555 MUIA_InnerRight,(8),
2556 MUIA_InnerTop,(2),
2557 MUIA_InnerBottom,(2),
2558 MUIA_Background, MUII_TextBack,
2559 MUIA_Text_PreParse, (IPTR)"\33c",
2560 MUIA_Text_Contents, (IPTR)"---",
2561 TAG_DONE)),
2562 Child, (IPTR)(fileTextObject = MUI_NewObject(MUIC_Text,
2563 MUIA_InnerLeft,(8),
2564 MUIA_InnerRight,(8),
2565 MUIA_InnerTop,(2),
2566 MUIA_InnerBottom,(2),
2567 MUIA_Text_PreParse, (IPTR)"\33c",
2568 TAG_DONE)),
2569 Child, (IPTR)(d->fileObject = MUI_NewObject(MUIC_Text,
2570 TextFrame,
2571 MUIA_InnerLeft,(8),
2572 MUIA_InnerRight,(8),
2573 MUIA_InnerTop,(2),
2574 MUIA_InnerBottom,(2),
2575 MUIA_Background, MUII_TextBack,
2576 MUIA_Text_PreParse, (IPTR)"\33c",
2577 MUIA_Text_Contents, (IPTR)"---",
2578 TAG_DONE)),
2579 Child, (IPTR)(fileLengthObject = MUI_NewObject(MUIC_Text,
2580 MUIA_InnerLeft,(8),
2581 MUIA_InnerRight,(8),
2582 MUIA_InnerTop,(2),
2583 MUIA_InnerBottom,(2),
2584 MUIA_Text_PreParse, (IPTR)"\33c",
2585 TAG_DONE)),
2586 Child, (IPTR)(gaugeGroup = MUI_NewObject(MUIC_Group,
2587 TextFrame,
2588 Child, d->gauge = MUI_NewObject(MUIC_Gauge,
2589 MUIA_Gauge_Horiz, TRUE,
2590 MUIA_Gauge_Max, 32768,
2591 MUIA_Gauge_InfoText, _(MSG_WANDERER_FILEACCESS_PROCESSING),
2592 TAG_DONE),
2593 Child, MUI_NewObject(MUIC_Scale,
2594 MUIA_Scale_Horiz, TRUE,
2595 TAG_DONE),
2596 TAG_DONE)),
2597 Child, (IPTR)( d->performanceObject = MUI_NewObject(MUIC_Text,
2598 TextFrame,
2599 MUIA_InnerLeft,(8),
2600 MUIA_InnerRight,(8),
2601 MUIA_InnerTop,(2),
2602 MUIA_InnerBottom,(2),
2603 MUIA_Background, MUII_TextBack,
2604 MUIA_Text_PreParse, (IPTR)"\33c",
2605 MUIA_Text_Contents, (IPTR)"...........0 Bytes...........",
2606 TAG_DONE)),
2608 Child, (IPTR)( d->stopObject = SimpleButton( _(MSG_WANDERER_FILEACCESS_STOP) ) ),
2609 TAG_DONE)),
2610 TAG_DONE)),
2611 TAG_DONE);
2613 if (d->copyApp)
2615 if ((flags & (ACTION_COPY|ACTION_DELETE)) == (ACTION_COPY|ACTION_DELETE))
2617 SET(fromObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_MOVEFROM) );
2618 SET(toObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_MOVETO) );
2619 SET(fileTextObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_FILE) );
2620 SET(fileLengthObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_TRAFFIC) );
2622 else if ((flags & ACTION_COPY) == ACTION_COPY)
2624 SET(fromObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_COPYFROM) );
2625 SET(toObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_COPYTO) );
2626 SET(fileTextObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_FILE) );
2627 SET(fileLengthObject, MUIA_Text_Contents, (IPTR) _(MSG_WANDERER_FILEACCESS_TRAFFIC) );
2630 else if ((flags & ACTION_DELETE) == ACTION_DELETE)
2632 SET(fromObject, MUIA_Text_Contents, _(MSG_WANDERER_FILEACCESS_DELETEFROM) );
2633 DoMethod(group, MUIM_Group_InitChange);
2634 DoMethod(group, OM_REMMEMBER, toObject);
2635 DoMethod(group, OM_REMMEMBER, fileLengthObject);
2636 DoMethod(group, OM_REMMEMBER, d->performanceObject);
2637 DoMethod(group, OM_REMMEMBER, d->destObject);
2638 DoMethod(group, OM_REMMEMBER, gaugeGroup);
2639 DoMethod(group, MUIM_Group_ExitChange);
2640 SET(fileTextObject, MUIA_Text_Contents, _(MSG_WANDERER_FILEACCESS_FILETODELETE) );
2643 SET(d->win,MUIA_Window_Open,TRUE);
2644 DoMethod(d->stopObject,MUIM_Notify, MUIA_Pressed, FALSE, d->stopObject, 3, MUIM_WriteLong, 1 ,&d->stopflag);
2645 back = TRUE;
2647 return back;
2651 ///wanderer_menufunc_icon_delete()
2652 void wanderer_menufunc_icon_delete(void)
2654 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
2655 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
2656 struct IconList_Entry *entry = ( void*) MUIV_IconList_NextIcon_Start;
2657 struct MUIDisplayObjects dobjects;
2658 struct Hook displayCopyHook;
2659 struct Hook displayAskHook;
2660 struct OpModes opModes;
2661 ULONG updatedIcons;
2663 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR) &entry);
2664 displayCopyHook.h_Entry = (HOOKFUNC) Wanderer__HookFunc_DisplayCopyFunc;
2665 displayAskHook.h_Entry = (HOOKFUNC) Wanderer__HookFunc_AskModeFunc;
2666 opModes.askhook = &displayAskHook;
2667 opModes.deletemode = OPMODE_ASK;
2668 opModes.protectmode = OPMODE_ASK;
2669 opModes.overwritemode = OPMODE_ASK;
2671 updatedIcons = 0;
2673 /* Process all selected entries */
2674 if (CreateCopyDisplay(ACTION_DELETE, &dobjects))
2678 if ((IPTR)entry != MUIV_IconList_NextIcon_End)
2680 if (entry->type != ILE_TYPE_APPICON)
2682 /* copy via filesystems.c */
2683 D(bug("[Wanderer] Delete \"%s\"\n", entry->ile_IconEntry->ie_IconNode.ln_Name);)
2684 CopyContent( NULL, entry->ile_IconEntry->ie_IconNode.ln_Name, NULL, TRUE,
2685 ACTION_DELETE, &displayCopyHook, &opModes, (APTR) &dobjects);
2686 updatedIcons++;
2688 else
2690 SendAppIconMenuMessage((struct AppIcon *)entry->ile_IconEntry->ie_User1, AMCLASSICON_Delete);
2693 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR) &entry);
2695 while ((IPTR)entry != MUIV_IconList_NextIcon_End );
2696 DisposeCopyDisplay(&dobjects);
2698 // Only update list if anything happened to the icons!
2699 if ( updatedIcons > 0 )
2701 DoMethod(window, MUIM_IconWindow_UnselectAll);
2702 DoMethod(iconList, MUIM_IconList_Update);
2703 DoMethod(iconList, MUIM_IconList_Sort);
2708 ///wanderer_menufunc_icon_format()
2709 void wanderer_menufunc_icon_format(void)
2711 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
2712 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
2713 struct IconList_Entry *entry = ( void*) MUIV_IconList_NextIcon_Start;
2715 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR) &entry);
2717 /* Process only first selected entry */
2718 if ((IPTR)entry != MUIV_IconList_NextIcon_End)
2720 if (entry->type != ILE_TYPE_APPICON) /* TODO: Implement */
2722 BPTR lock = Lock(entry->ile_IconEntry->ie_IconNode.ln_Name, ACCESS_READ);
2723 D(bug("[Wanderer]: %s('%s')\n", __PRETTY_FUNCTION__, entry->ile_IconEntry->ie_IconNode.ln_Name));
2724 /* Usually we pass object name and parent lock. Here we do the same thing.
2725 Just object name is empty string and its parent is device's root. */
2726 OpenWorkbenchObject
2728 "SYS:System/Format",
2729 WBOPENA_ArgLock, (IPTR) lock,
2730 WBOPENA_ArgName, lock ? (IPTR)"" : (IPTR)entry->ile_IconEntry->ie_IconNode.ln_Name,
2731 TAG_DONE
2733 if (lock)
2734 UnLock(lock);
2740 ///wanderer_menufunc_icon_emptytrash
2741 void wanderer_menufunc_icon_emptytrash(void)
2743 Object *window = (Object *) XGET(_WandererIntern_AppObj, MUIA_Wanderer_ActiveWindow);
2744 Object *iconList = (Object *) XGET(window, MUIA_IconWindow_IconList);
2745 struct IconList_Entry *entry = ( void*) MUIV_IconList_NextIcon_Start;
2747 D(bug("[Wanderer]: %s\n", __PRETTY_FUNCTION__));
2749 DoMethod(iconList, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR) &entry);
2751 /* Process only first selected entry */
2752 if ((IPTR)entry != MUIV_IconList_NextIcon_End)
2754 if (entry->type == ILE_TYPE_APPICON)
2756 struct AppIcon *ai = (struct AppIcon *)entry->ile_IconEntry->ie_User1;
2757 SendAppIconMenuMessage(ai, AMCLASSICON_EmptyTrash);
2760 else {
2761 // TODO: Implement for icons(!=ILE_TYPE_APPICON) of disks having a trashcan
2768 ///wanderer_menufunc_wanderer_AROS_guisettings()
2769 void wanderer_menufunc_wanderer_AROS_guisettings(void)
2771 //DoMethod(_WandererIntern_AppObj, MUIM_Application_OpenConfigWindow);
2772 OpenWorkbenchObject("SYS:Prefs/Zune",
2773 WBOPENA_ArgName, (IPTR) "WANDERER",
2774 TAG_DONE);
2778 ///wanderer_menufunc_wanderer_AROS_about()
2779 void wanderer_menufunc_wanderer_AROS_about(void)
2781 OpenWorkbenchObject("SYS:System/About",
2782 TAG_DONE);
2786 ///wanderer_menufunc_wanderer_about()
2787 void wanderer_menufunc_wanderer_about(Object **pwand)
2789 Object *self = *pwand;
2790 Class *CLASS = _WandererIntern_CLASS;
2791 SETUP_WANDERER_INST_DATA;
2793 /* Display Information about this version of wanderer */
2794 if (data->wd_AboutWindow == NULL)
2796 data->wd_AboutWindow = WindowObject,
2797 MUIA_Window_Title, (IPTR)"About Wanderer...",
2798 MUIA_Window_ID, (IPTR)MAKE_ID('W','A','B','T'),
2799 WindowContents, (IPTR)VGroup,
2800 Child, (IPTR)HGroup,
2801 Child, (IPTR) IconImageObject,
2802 MUIA_InputMode, MUIV_InputMode_Toggle,
2803 MUIA_IconImage_File, (IPTR)"PROGDIR:Wanderer",
2804 End,
2805 Child, (IPTR)VGroup,
2806 Child, (IPTR)TextObject,
2807 MUIA_Text_PreParse, (IPTR)"\33c\33b",
2808 MUIA_Text_Contents, (IPTR)wand_titlestr,
2809 End,
2810 Child, (IPTR)TextObject,
2811 MUIA_Text_PreParse, (IPTR)"\33c",
2812 MUIA_Text_Contents, (IPTR)wand_copyrightstr,
2813 End,
2814 End,
2815 End,
2817 Child, (IPTR)VGroup,
2818 MUIA_Frame, MUIV_Frame_Group,
2819 Child, (IPTR)TextObject,
2820 MUIA_Text_PreParse, (IPTR)"\33b",
2821 MUIA_Text_Contents, (IPTR)"Internal Classes:",
2822 End,
2823 Child, (IPTR)HVSpace,
2824 Child, (IPTR)ColGroup(2),
2825 Child, (IPTR)TextObject,
2826 MUIA_Text_Contents, (IPTR)"IconWindow",
2827 End,
2828 Child, (IPTR)TextObject,
2829 MUIA_Text_Contents, (IPTR)"",
2830 End,
2831 Child, (IPTR)TextObject,
2832 MUIA_Text_Contents, (IPTR)"IconWindowVolumeList",
2833 End,
2834 Child, (IPTR)TextObject,
2835 MUIA_Text_Contents, (IPTR)"",
2836 End,
2837 Child, (IPTR)TextObject,
2838 MUIA_Text_Contents, (IPTR)"IconWindowDrawerList",
2839 End,
2840 Child, (IPTR)TextObject,
2841 MUIA_Text_Contents, (IPTR)"",
2842 End,
2843 End,
2844 Child, (IPTR)HVSpace,
2845 Child, (IPTR)TextObject,
2846 MUIA_Text_PreParse, (IPTR)"\33b",
2847 MUIA_Text_Contents, (IPTR)"External Classes:",
2848 End,
2849 Child, (IPTR)HVSpace,
2850 Child, (IPTR)ColGroup(2),
2851 Child, (IPTR)TextObject,
2852 MUIA_Text_Contents, (IPTR)"IconList.mui",
2853 End,
2854 Child, (IPTR)TextObject,
2855 MUIA_Text_Contents, (IPTR)"",
2856 End,
2857 Child, (IPTR)TextObject,
2858 MUIA_Text_Contents, (IPTR)"IconListView.mui",
2859 End,
2860 Child, (IPTR)TextObject,
2861 MUIA_Text_Contents, (IPTR)"",
2862 End,
2863 Child, (IPTR)TextObject,
2864 MUIA_Text_Contents, (IPTR)"IconVolumeList.mui",
2865 End,
2866 Child, (IPTR)TextObject,
2867 MUIA_Text_Contents, (IPTR)"",
2868 End,
2869 Child, (IPTR)TextObject,
2870 MUIA_Text_Contents, (IPTR)"IconDrawerList.mui",
2871 End,
2872 Child, (IPTR)TextObject,
2873 MUIA_Text_Contents, (IPTR)"",
2874 End,
2875 End,
2876 Child, (IPTR)HVSpace,
2877 End,
2878 End,
2879 End;
2881 #ifdef __AROS__
2882 DoMethod(_app(self), OM_ADDMEMBER, (IPTR) data->wd_AboutWindow);
2883 #else
2884 DoMethod(self, OM_ADDMEMBER, (IPTR) data->wd_AboutWindow);
2885 #endif
2886 DoMethod
2888 data->wd_AboutWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
2889 (IPTR)data->wd_AboutWindow, 3, MUIM_Set, MUIA_Window_Open, FALSE
2893 if (data->wd_AboutWindow)
2895 IPTR isOpen = (IPTR)FALSE;
2896 GET(data->wd_AboutWindow, MUIA_Window_Open, &isOpen);
2897 if (isOpen)
2899 isOpen = FALSE;
2901 else
2903 isOpen = TRUE;
2905 SET(data->wd_AboutWindow, MUIA_Window_Open, isOpen);
2910 ///wanderer_menufunc_wanderer_quit()
2911 void wanderer_menufunc_wanderer_quit(void)
2913 if (OpenWorkbenchObject("WANDERER:Tools/Quit", TAG_DONE))
2917 else
2919 if (MUI_RequestA(_WandererIntern_AppObj, NULL, 0, wand_namestr, _(MSG_YESNO), _(MSG_REALLYQUIT), NULL))
2920 DoMethod(_WandererIntern_AppObj, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
2926 ///wanderer_menufunc_wanderer_shutdown()
2927 void wanderer_menufunc_wanderer_shutdown(void)
2929 LONG action;
2931 #if defined(__AROS_ARCH_pc__) && defined(__i386__)
2932 action = MUI_RequestA(_WandererIntern_AppObj, NULL, 0,
2933 _(MSG_SHUTDOWN_TITLE), strchr(_(MSG_SHUTDOWN_BUTTONS), '|') + 1,
2934 _(MSG_SHUTDOWN_BODY), NULL);
2935 if (action != 0)
2936 action++;
2937 #else
2938 action = MUI_RequestA(_WandererIntern_AppObj, NULL, 0, _(MSG_SHUTDOWN_TITLE), _(MSG_SHUTDOWN_BUTTONS), _(MSG_SHUTDOWN_BODY), NULL);
2939 #endif
2940 switch (action) {
2941 case 0:
2942 return;
2943 case 1:
2944 ShutdownA(SD_ACTION_POWEROFF);
2945 break;
2946 case 2:
2947 ShutdownA(SD_ACTION_COLDREBOOT);
2948 break;
2949 case 3:
2950 ColdReboot();
2952 MUI_RequestA(_WandererIntern_AppObj, NULL, 0, _(MSG_SHUTDOWN_TITLE), _(MSG_OK), _(MSG_ACTION_NOT_SUPPORTED), NULL);
2957 ///FindMenuitem()
2958 /**************************************************************************
2959 This function returns a Menu Object with the given id
2960 **************************************************************************/
2961 Object *FindMenuitem(Object* strip, int id)
2963 return (Object*)DoMethod(strip, MUIM_FindUData, id);
2967 ///DoMenuNotify()
2968 /**************************************************************************
2969 This connects a notify to the given menu entry id
2970 **************************************************************************/
2971 VOID DoMenuNotify(Object* strip, int id, IPTR trigattrib, void *function, void *arg)
2973 Object *entry;
2974 entry = FindMenuitem(strip,id);
2975 if (entry)
2977 DoMethod
2979 entry, MUIM_Notify, trigattrib, MUIV_EveryTime,
2980 (IPTR) entry, 4, MUIM_CallHook, (IPTR) &_WandererIntern_hook_standard,
2981 (IPTR) function, (IPTR) arg
2987 ///SetMenuDefaultNotifies()
2988 VOID SetMenuDefaultNotifies(Object *wanderer, Object *strip, STRPTR path)
2990 Object *item;
2992 if (!strip) return;
2994 DoMenuNotify(strip, MEN_WANDERER_EXECUTE, MUIA_Menuitem_Trigger,
2995 wanderer_menufunc_wanderer_execute, path);
2996 DoMenuNotify(strip, MEN_WANDERER_SHELL, MUIA_Menuitem_Trigger,
2997 wanderer_menufunc_wanderer_shell, path);
2998 DoMenuNotify(strip, MEN_WANDERER_AROS_GUISETTINGS, MUIA_Menuitem_Trigger,
2999 wanderer_menufunc_wanderer_AROS_guisettings, NULL);
3000 DoMenuNotify(strip, MEN_WANDERER_AROS_ABOUT, MUIA_Menuitem_Trigger,
3001 wanderer_menufunc_wanderer_AROS_about, NULL);
3002 DoMenuNotify(strip, MEN_WANDERER_ABOUT, MUIA_Menuitem_Trigger,
3003 wanderer_menufunc_wanderer_about, wanderer);
3004 DoMenuNotify(strip, MEN_WANDERER_QUIT, MUIA_Menuitem_Trigger,
3005 wanderer_menufunc_wanderer_quit, NULL);
3006 DoMenuNotify(strip, MEN_WANDERER_SHUTDOWN, MUIA_Menuitem_Trigger,
3007 wanderer_menufunc_wanderer_shutdown, NULL);
3009 DoMenuNotify(strip, MEN_WINDOW_NEW_DRAWER, MUIA_Menuitem_Trigger,
3010 wanderer_menufunc_window_newdrawer, path);
3011 DoMenuNotify(strip, MEN_WINDOW_OPEN_PARENT, MUIA_Menuitem_Trigger,
3012 wanderer_menufunc_window_openparent, path);
3013 DoMenuNotify(strip, MEN_WINDOW_CLOSE, MUIA_Menuitem_Trigger,
3014 wanderer_menufunc_window_close, NULL);
3015 DoMenuNotify(strip, MEN_WINDOW_UPDATE, MUIA_Menuitem_Trigger,
3016 wanderer_menufunc_window_update, NULL);
3017 DoMenuNotify(strip, MEN_WINDOW_CLEAR, MUIA_Menuitem_Trigger,
3018 wanderer_menufunc_window_clear, NULL);
3020 DoMenuNotify(strip, MEN_WINDOW_SNAP_WIN, MUIA_Menuitem_Trigger,
3021 wanderer_menufunc_window_snapshot, FALSE);
3022 DoMenuNotify(strip, MEN_WINDOW_SNAP_ALL, MUIA_Menuitem_Trigger,
3023 wanderer_menufunc_window_snapshot, (APTR)TRUE);
3025 DoMenuNotify(strip, MEN_WINDOW_SELECT, MUIA_Menuitem_Trigger,
3026 wanderer_menufunc_window_select, NULL);
3028 DoMenuNotify(strip, MEN_WINDOW_VIEW_ICON, MUIA_Menuitem_Trigger,
3029 wanderer_menufunc_window_view_modeicon, strip);
3030 DoMenuNotify(strip, MEN_WINDOW_VIEW_DETAIL, MUIA_Menuitem_Trigger,
3031 wanderer_menufunc_window_view_modelist, strip);
3032 DoMenuNotify(strip, MEN_WINDOW_VIEW_ALL, MUIA_Menuitem_Trigger,
3033 wanderer_menufunc_window_view_iconsonly, strip);
3034 // DoMenuNotify(strip, MEN_WINDOW_VIEW_HIDDEN, MUIA_Menuitem_Trigger,
3035 // wanderer_menufunc_window_view_hidden, strip);
3038 DoMenuNotify(strip, MEN_WINDOW_SORT_NOW, MUIA_Menuitem_Trigger,
3039 wanderer_menufunc_window_cleanup, NULL);
3040 DoMenuNotify(strip, MEN_WINDOW_SORT_ENABLE, MUIA_Menuitem_Trigger,
3041 wanderer_menufunc_window_sort_enable, strip);
3042 DoMenuNotify(strip, MEN_WINDOW_SORT_NAME, MUIA_Menuitem_Trigger,
3043 wanderer_menufunc_window_sort_name, strip);
3044 DoMenuNotify(strip, MEN_WINDOW_SORT_TYPE, MUIA_Menuitem_Trigger,
3045 wanderer_menufunc_window_sort_type, strip);
3046 DoMenuNotify(strip, MEN_WINDOW_SORT_DATE, MUIA_Menuitem_Trigger,
3047 wanderer_menufunc_window_sort_date, strip);
3048 DoMenuNotify(strip, MEN_WINDOW_SORT_SIZE, MUIA_Menuitem_Trigger,
3049 wanderer_menufunc_window_sort_size, strip);
3050 DoMenuNotify(strip, MEN_WINDOW_SORT_REVERSE, MUIA_Menuitem_Trigger,
3051 wanderer_menufunc_window_sort_reverse, strip);
3052 DoMenuNotify(strip, MEN_WINDOW_SORT_TOPDRAWERS, MUIA_Menuitem_Trigger,
3053 wanderer_menufunc_window_sort_topdrawers, strip);
3055 DoMenuNotify(strip, MEN_WINDOW_FIND, MUIA_Menuitem_Trigger,
3056 wanderer_menufunc_window_find, strip);
3058 DoMenuNotify(strip, MEN_ICON_OPEN, MUIA_Menuitem_Trigger,
3059 wanderer_menufunc_icon_open, NULL);
3060 DoMenuNotify(strip, MEN_ICON_RENAME, MUIA_Menuitem_Trigger,
3061 wanderer_menufunc_icon_rename, NULL);
3062 DoMenuNotify(strip, MEN_ICON_INFORMATION, MUIA_Menuitem_Trigger,
3063 wanderer_menufunc_icon_information, NULL);
3064 DoMenuNotify(strip, MEN_ICON_SNAPSHOT, MUIA_Menuitem_Trigger,
3065 wanderer_menufunc_icon_snapshot, (APTR)TRUE);
3066 DoMenuNotify(strip, MEN_ICON_UNSNAPSHOT, MUIA_Menuitem_Trigger,
3067 wanderer_menufunc_icon_snapshot, FALSE);
3068 DoMenuNotify(strip, MEN_ICON_LEAVEOUT, MUIA_Menuitem_Trigger,
3069 wanderer_menufunc_icon_leaveout, NULL);
3070 DoMenuNotify(strip, MEN_ICON_PUTAWAY, MUIA_Menuitem_Trigger,
3071 wanderer_menufunc_icon_putaway, NULL);
3072 DoMenuNotify(strip, MEN_ICON_DELETE, MUIA_Menuitem_Trigger,
3073 wanderer_menufunc_icon_delete, NULL);
3074 DoMenuNotify(strip, MEN_ICON_FORMAT, MUIA_Menuitem_Trigger,
3075 wanderer_menufunc_icon_format, NULL);
3076 DoMenuNotify(strip, MEN_ICON_EMPTYTRASH, MUIA_Menuitem_Trigger,
3077 wanderer_menufunc_icon_emptytrash, NULL);
3079 if ((item = FindMenuitem(strip, MEN_WANDERER_BACKDROP)))
3081 DoMethod
3083 item, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime,
3084 (IPTR) _WandererIntern_AppObj, 7, MUIM_Application_PushMethod,
3085 (IPTR) _WandererIntern_AppObj, 4, MUIM_CallHook, (IPTR) &_WandererIntern_hook_standard,
3086 (IPTR) wanderer_menufunc_wanderer_backdrop, (IPTR) strip
3092 #define MENF_ICON_OPEN (1 << 0)
3093 #define MENF_ICON_RENAME (1 << 1)
3094 #define MENF_ICON_INFORMATION (1 << 2)
3095 #define MENF_ICON_SNAPSHOT (1 << 3)
3096 #define MENF_ICON_UNSNAPSHOT (1 << 4)
3097 #define MENF_ICON_LEAVEOUT (1 << 5)
3098 #define MENF_ICON_PUTAWAY (1 << 6)
3099 #define MENF_ICON_DELETE (1 << 7)
3100 #define MENF_ICON_FORMAT (1 << 8)
3101 #define MENF_ICON_EMPTYTRASH (1 << 9)
3103 ///Wanderer__Func_UpdateMenuStates()
3104 VOID Wanderer__Func_UpdateMenuStates(Object *WindowObj, Object *IconlistObj)
3106 IPTR isRoot = 0, current_DispFlags = 0, current_SortFlags = 0;
3107 Object *current_Menustrip = NULL, *current_MenuItem = NULL;
3108 struct IconList_Entry *icon_entry = (IPTR)MUIV_IconList_NextIcon_Start;
3109 ULONG iconmenustate = 0xFFFFFFFF; /* All enabled */
3110 LONG selectedcount = 0;
3112 if (IconlistObj == NULL)
3113 return;
3115 D(bug("[Wanderer]: %s(IconList @ %p)\n", __PRETTY_FUNCTION__, IconlistObj));
3117 GET(IconlistObj, MUIA_IconList_SortFlags, &current_SortFlags);
3118 GET(IconlistObj, MUIA_IconList_DisplayFlags, &current_DispFlags);
3119 GET(WindowObj, MUIA_Window_Menustrip, &current_Menustrip);
3120 GET(WindowObj, MUIA_IconWindow_IsRoot, &isRoot);
3122 D(bug("[Wanderer] %s: Menu @ %p, Display Flags : %x, Sort Flags : %x\n", __PRETTY_FUNCTION__, current_Menustrip, current_DispFlags, current_SortFlags));
3126 DoMethod(IconlistObj, MUIM_IconList_NextIcon, MUIV_IconList_NextIcon_Selected, (IPTR)&icon_entry);
3128 if ((IPTR)icon_entry != MUIV_IconList_NextIcon_End)
3130 if (isRoot && (icon_entry->type == ST_ROOT))
3132 /* Disks can't be: */
3133 iconmenustate &= ~MENF_ICON_LEAVEOUT;
3134 iconmenustate &= ~MENF_ICON_PUTAWAY;
3135 iconmenustate &= ~MENF_ICON_DELETE;
3136 iconmenustate &= ~MENF_ICON_EMPTYTRASH;
3138 if (isRoot && ((icon_entry->type == ST_LINKDIR) || (icon_entry->type == ST_LINKFILE)))
3140 /* Leave outed icons can't be: */
3141 iconmenustate &= ~MENF_ICON_LEAVEOUT;
3142 iconmenustate &= ~MENF_ICON_DELETE;
3143 iconmenustate &= ~MENF_ICON_FORMAT;
3144 iconmenustate &= ~MENF_ICON_EMPTYTRASH;
3146 if (!(isRoot) && ((icon_entry->type == ST_USERDIR) || (icon_entry->type == ST_FILE)))
3148 /* Normal files/drawers can't be: */
3149 iconmenustate &= ~MENF_ICON_PUTAWAY;
3150 iconmenustate &= ~MENF_ICON_FORMAT;
3151 iconmenustate &= ~MENF_ICON_EMPTYTRASH;
3153 if (isRoot && (icon_entry->type == ILE_TYPE_APPICON))
3156 struct AppIcon * ai = (struct AppIcon *)icon_entry->ile_IconEntry->ie_User1;
3157 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsOpen))
3158 iconmenustate &= ~MENF_ICON_OPEN;
3159 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsRename))
3160 iconmenustate &= ~MENF_ICON_RENAME;
3161 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsInformation))
3162 iconmenustate &= ~MENF_ICON_INFORMATION;
3163 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsSnapshot))
3164 iconmenustate &= ~MENF_ICON_SNAPSHOT;
3165 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsUnSnapshot))
3166 iconmenustate &= ~MENF_ICON_UNSNAPSHOT;
3167 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsLeaveOut))
3168 iconmenustate &= ~MENF_ICON_LEAVEOUT;
3169 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsPutAway))
3170 iconmenustate &= ~MENF_ICON_PUTAWAY;
3171 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsDelete))
3172 iconmenustate &= ~MENF_ICON_DELETE;
3173 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsFormatDisk))
3174 iconmenustate &= ~MENF_ICON_FORMAT;
3175 if (!AppIcon_Supports(ai, WBAPPICONA_SupportsEmptyTrash))
3176 iconmenustate &= ~MENF_ICON_EMPTYTRASH;
3178 selectedcount++;
3180 else
3182 break;
3184 } while (TRUE);
3186 if (selectedcount == 0) iconmenustate = 0x00000000;
3188 if (current_Menustrip != NULL)
3190 /* Icon menu */
3191 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_OPEN)) != NULL)
3193 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_OPEN));
3195 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_RENAME)) != NULL)
3197 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_RENAME));
3199 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_INFORMATION)) != NULL)
3201 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_INFORMATION));
3203 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_SNAPSHOT)) != NULL)
3205 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_SNAPSHOT));
3207 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_UNSNAPSHOT)) != NULL)
3209 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_UNSNAPSHOT));
3211 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_DELETE)) != NULL)
3213 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_DELETE));
3215 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_FORMAT)) != NULL)
3217 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_FORMAT));
3219 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_LEAVEOUT)) != NULL)
3221 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_LEAVEOUT));
3223 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_PUTAWAY)) != NULL)
3225 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_PUTAWAY));
3227 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_ICON_EMPTYTRASH)) != NULL)
3229 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, !!(iconmenustate & MENF_ICON_EMPTYTRASH));
3231 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_CLEAR)) != NULL)
3233 NNSET(current_MenuItem, MUIA_Menuitem_Enabled, TRUE);
3236 /* Window menu */
3237 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_VIEW_ALL)) != NULL)
3239 NNSET(current_MenuItem, MUIA_Menuitem_Checked, !(current_DispFlags & ICONLIST_DISP_SHOWINFO) ? TRUE : FALSE);
3241 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_VIEW_ICON)) != NULL)
3243 NNSET(current_MenuItem, MUIA_Menuitem_Checked, (current_DispFlags & ICONLIST_DISP_MODEDEFAULT) ? TRUE : FALSE);
3245 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_VIEW_DETAIL)) != NULL)
3247 NNSET(current_MenuItem, MUIA_Menuitem_Checked, (current_DispFlags & ICONLIST_DISP_MODELIST) ? TRUE : FALSE);
3249 // if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_VIEW_HIDDEN)) != NULL)
3250 // {
3251 // NNSET(current_MenuItem, MUIA_Menuitem_Checked, (current_DispFlags & ICONLIST_DISP_SHOWHIDDEN) ? TRUE : FALSE);
3252 // }
3253 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_SORT_NAME)) != NULL)
3255 NNSET(current_MenuItem, MUIA_Menuitem_Checked, ((current_SortFlags & MUIV_IconList_Sort_ByName) ? TRUE : FALSE));
3257 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_SORT_DATE)) != NULL)
3259 NNSET(current_MenuItem, MUIA_Menuitem_Checked, ((current_SortFlags & MUIV_IconList_Sort_ByDate) ? TRUE : FALSE));
3261 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_SORT_SIZE)) != NULL)
3263 NNSET(current_MenuItem, MUIA_Menuitem_Checked, ((current_SortFlags & MUIV_IconList_Sort_BySize) ? TRUE : FALSE));
3265 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_SORT_TYPE)) != NULL)
3267 NNSET(current_MenuItem, MUIA_Menuitem_Checked, ((current_SortFlags & MUIV_IconList_Sort_ByType) ? TRUE : FALSE));
3269 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_SORT_REVERSE)) != NULL)
3271 NNSET(current_MenuItem, MUIA_Menuitem_Checked, ((current_SortFlags & MUIV_IconList_Sort_Reverse) == MUIV_IconList_Sort_Reverse) ? TRUE : FALSE);
3273 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_SORT_TOPDRAWERS)) != NULL)
3275 NNSET(current_MenuItem, MUIA_Menuitem_Checked, ((current_SortFlags & MUIV_IconList_Sort_DrawersMixed) == MUIV_IconList_Sort_DrawersMixed) ? FALSE : TRUE);
3277 if ((current_MenuItem = FindMenuitem(current_Menustrip, MEN_WINDOW_SORT_ENABLE)) != NULL)
3279 NNSET(current_MenuItem, MUIA_Menuitem_Checked, ((current_SortFlags & MUIV_IconList_Sort_AutoSort) == 0) ? FALSE : TRUE);
3284 ///Wanderer__HookFunc_UpdateMenuStatesFunc()
3285 #ifdef __AROS__
3286 AROS_UFH3
3288 ULONG, Wanderer__HookFunc_UpdateMenuStatesFunc,
3289 AROS_UFHA(struct Hook *, hook, A0),
3290 AROS_UFHA(APTR *, obj, A2),
3291 AROS_UFHA(APTR, param, A1)
3294 #else
3295 HOOKPROTO(Wanderer__HookFunc_UpdateMenuStatesFunc, ULONG, struct dCopyStruct *obj, APTR param)
3297 #endif
3298 AROS_USERFUNC_INIT
3300 __unused Object *self = ( Object *)obj;
3301 Object *window = *( Object **)param;
3302 Object *iconlist = NULL;
3304 D(bug("[Wanderer]: %s(self @ %p, window @ %p)\n", __PRETTY_FUNCTION__, self, window));
3306 GET(window, MUIA_IconWindow_IconList, &iconlist);
3308 D(bug("[Wanderer] %s: iconlist @ %p\n", __PRETTY_FUNCTION__, iconlist));
3310 Wanderer__Func_UpdateMenuStates(window, iconlist);
3312 D(bug("[Wanderer] %s: Update Complete.\n", __PRETTY_FUNCTION__));
3314 return 0;
3316 AROS_USERFUNC_EXIT
3319 /*** Methods ****************************************************************/
3320 ///OM_NEW()
3321 Object *Wanderer__OM_NEW(Class *CLASS, Object *self, struct opSet *message)
3323 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
3325 self = (Object *) DoSuperNewTags
3327 CLASS, self, NULL,
3329 MUIA_Application_Title, (IPTR) wand_namestr,
3330 MUIA_Application_Base, (IPTR) "WANDERER",
3331 MUIA_Application_Version, (IPTR) VERSION,
3332 MUIA_Application_Description, (IPTR) _(MSG_DESCRIPTION),
3333 MUIA_Application_SingleTask, TRUE,
3335 MUIA_Application_Version, (IPTR) wand_versionstr,
3336 MUIA_Application_Copyright, (IPTR) wand_copyrightstr,
3337 MUIA_Application_Author, (IPTR) wand_authorstr,
3339 TAG_MORE, (IPTR) message->ops_AttrList
3342 if (self != NULL)
3344 SETUP_WANDERER_INST_DATA;
3346 TEXT buff[16];
3348 // ULONG updatedIcons;
3349 D(bug("[Wanderer] %s: Wanderer Obj @ %p, Instance data @ %p\n", __PRETTY_FUNCTION__, self, data));
3351 _WandererIntern_CLASS = CLASS;
3353 NewList(&_WandererIntern_FSHandlerList);
3355 D(bug("[Wanderer] %s: FSHandlerList @ %p\n", __PRETTY_FUNCTION__, &_WandererIntern_FSHandlerList));
3357 if (GetVar(wand_backdropprefs, buff, sizeof(buff), GVF_GLOBAL_ONLY) != -1) {
3358 data->wd_Option_BackDropMode = (Stricmp(buff, "True") == 0) ? TRUE : FALSE;
3359 } else {
3360 #if defined(WANDERER_DEFAULT_BACKDROP)
3361 data->wd_Option_BackDropMode = TRUE;
3362 #else
3363 data->wd_Option_BackDropMode = FALSE;
3364 #endif
3367 /*-- Setup hooks structures ----------------------------------------*/
3368 #ifdef __AROS__
3369 _WandererIntern_hook_standard.h_Entry = (HOOKFUNC) Wanderer__HookFunc_StandardFunc;
3370 _WandererIntern_hook_action.h_Entry = (HOOKFUNC) Wanderer__HookFunc_ActionFunc;
3371 _WandererIntern_hook_backdrop.h_Entry = (HOOKFUNC) Wanderer__HookFunc_BackdropFunc;
3372 #else
3373 _WandererIntern_hook_standard = &Hook_StandardFunc;
3374 _WandererIntern_hook_action = &Hook_ActionFunc;
3375 _WandererIntern_hook_backdrop = &Hook_BackdropFunc;
3376 #endif
3378 // ---
3379 if ((data->wd_CommandPort = CreateMsgPort()) == NULL)
3381 CoerceMethod(CLASS, self, OM_DISPOSE);
3382 return NULL;
3385 if ((data->wd_NotifyPort = CreateMsgPort()) == NULL)
3387 CoerceMethod(CLASS, self, OM_DISPOSE);
3388 return NULL;
3391 RegisterWorkbench(data->wd_CommandPort);
3393 /* Setup command port handler --------------------------------------*/
3394 data->wd_CommandIHN.ihn_Signals = 1UL << data->wd_CommandPort->mp_SigBit;
3395 data->wd_CommandIHN.ihn_Object = self;
3396 data->wd_CommandIHN.ihn_Method = MUIM_Wanderer_HandleCommand;
3398 DoMethod
3400 self, MUIM_Application_AddInputHandler, (IPTR) &data->wd_CommandIHN
3403 /* Setup timer handler ---------------------------------------------*/
3404 data->wd_TimerIHN.ihn_Flags = MUIIHNF_TIMER;
3405 data->wd_TimerIHN.ihn_Millis = 1000;
3406 data->wd_TimerIHN.ihn_Object = self;
3407 data->wd_TimerIHN.ihn_Method = MUIM_Wanderer_HandleTimer;
3409 DoMethod
3411 self, MUIM_Application_AddInputHandler, (IPTR) &data->wd_TimerIHN
3414 /* Setup filesystem notification handler ---------------------------*/
3415 data->wd_NotifyIHN.ihn_Signals = 1UL << data->wd_NotifyPort->mp_SigBit;
3416 data->wd_NotifyIHN.ihn_Object = self;
3417 data->wd_NotifyIHN.ihn_Method = MUIM_Wanderer_HandleNotify;
3419 DoMethod
3421 self, MUIM_Application_AddInputHandler, (IPTR) &data->wd_NotifyIHN
3424 // All the following should be moved to InitWandererPrefs
3426 #ifdef __AROS__
3427 data->wd_Prefs = (Object *)WandererPrefsObject,
3428 MUIA_Wanderer_FileSysNotifyPort, (IPTR)data->wd_NotifyPort,
3429 End; // FIXME: error handling
3430 #else
3431 data->wd_Prefs = NewObject(WandererPrefs_CLASS->mcc_Class, NULL, TAG_DONE); // FIXME: error handling
3432 #endif
3434 if (data->wd_Prefs)
3436 D(bug("[Wanderer] %s: Prefs-Screentitle = '%s'\n", __PRETTY_FUNCTION__, XGET(data->wd_Prefs, MUIA_IconWindowExt_ScreenTitle_String)));
3440 D(bug("[Wanderer] %s: WandererObj @ %p\n", __PRETTY_FUNCTION__, self));
3441 return self;
3445 ///OM_DISPOSE()
3446 IPTR Wanderer__OM_DISPOSE(Class *CLASS, Object *self, Msg message)
3448 SETUP_WANDERER_INST_DATA;
3450 if (data->wd_CommandPort)
3452 /* InputHandler's have only been added if the creation
3453 of the msg port was successful */
3454 DoMethod(self, MUIM_Application_RemInputHandler, (IPTR) &data->wd_TimerIHN);
3455 DoMethod(self, MUIM_Application_RemInputHandler, (IPTR) &data->wd_CommandIHN);
3456 DoMethod(self, MUIM_Application_RemInputHandler, (IPTR) &data->wd_NotifyIHN);
3458 UnregisterWorkbench(data->wd_CommandPort);
3460 DeleteMsgPort(data->wd_NotifyPort);
3461 data->wd_NotifyPort = NULL;
3463 DeleteMsgPort(data->wd_CommandPort);
3464 data->wd_CommandPort = NULL;
3466 DisposeObject(data->wd_Prefs);
3467 data->wd_Prefs = NULL;
3470 return DoSuperMethodA(CLASS, self, (Msg) message);
3474 ///OM_SET()
3475 IPTR Wanderer__OM_SET(Class *CLASS, Object *self, struct opSet *message)
3477 SETUP_WANDERER_INST_DATA;
3478 struct TagItem *tstate = message->ops_AttrList, *tag;
3480 while ((tag = NextTagItem((TAGITEM)&tstate)) != NULL)
3482 switch (tag->ti_Tag)
3484 case MUIA_Wanderer_Screen:
3485 D(bug("[Wanderer] %s: MUIA_Wanderer_Screen = %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
3486 D(bug("[Wanderer] %s: setting MUIA_Wanderer_Screen isnt yet handled!\n", __PRETTY_FUNCTION__));
3487 break;
3489 case MUIA_Wanderer_ActiveWindow:
3490 data->wd_ActiveWindow = (Object *) tag->ti_Data;
3491 D(bug("[Wanderer] %s: MUIA_Wanderer_ActiveWindow = %p\n", __PRETTY_FUNCTION__, tag->ti_Data));
3492 if (!(XGET(data->wd_ActiveWindow, MUIA_Window_Activate)))
3494 NNSET(data->wd_ActiveWindow, MUIA_Window_Activate, TRUE);
3496 Object *activatewin_Iconlist = NULL;
3498 GET(data->wd_ActiveWindow, MUIA_IconWindow_IconList, &activatewin_Iconlist);
3499 Wanderer__Func_UpdateMenuStates(data->wd_ActiveWindow, activatewin_Iconlist);
3500 break;
3502 case MUIA_Application_Iconified:
3503 /* Wanderer does not allow iconifying of itself */
3504 tag->ti_Tag = TAG_IGNORE;
3505 break;
3509 return DoSuperMethodA(CLASS, self, (Msg) message);
3513 ///OM_GET()
3514 IPTR Wanderer__OM_GET(Class *CLASS, Object *self, struct opGet *message)
3516 SETUP_WANDERER_INST_DATA;
3517 IPTR *store = message->opg_Storage;
3518 IPTR rv = TRUE;
3520 switch (message->opg_AttrID)
3522 case MUIA_Wanderer_Screen:
3523 *store = (IPTR)data->wd_Screen;
3524 break;
3526 case MUIA_Wanderer_Prefs:
3527 *store = (IPTR)data->wd_Prefs;
3528 break;
3530 case MUIA_Wanderer_ActiveWindow:
3531 *store = (IPTR)data->wd_ActiveWindow;
3532 break;
3534 case MUIA_Wanderer_WorkbenchWindow:
3535 *store = (IPTR)data->wd_WorkbenchWindow;
3536 break;
3538 case MUIA_Wanderer_FileSysNotifyPort:
3539 *store = (IPTR)data->wd_NotifyPort;
3540 break;
3542 case MUIA_Wanderer_FileSysNotifyList:
3543 *store = (IPTR)&_WandererIntern_FSHandlerList;
3544 break;
3546 case MUIA_Version:
3547 *store = (IPTR)WANDERERVERS;
3548 break;
3550 case MUIA_Revision:
3551 *store = (IPTR)WANDERERREV;
3552 break;
3554 case MUIA_Application_Iconified:
3555 /* Wanderer does not allow iconifying of itself */
3556 *store = (IPTR)FALSE;
3557 break;
3559 default:
3560 rv = DoSuperMethodA(CLASS, self, (Msg) message);
3563 return rv;
3567 ///Wanderer__MUIM_Application_Execute()
3568 /* Main entry point for Wanderer Application Object */
3570 When the executable creates our object it calls zune
3571 to handle basic "control" ... which results in Zune
3572 calling this method ..
3574 IPTR Wanderer__MUIM_Application_Execute
3576 Class *CLASS, Object *self, Msg message
3579 SETUP_WANDERER_INST_DATA;
3581 D(bug("[Wanderer] %s() ##\n[Wanderer] %s: Creating 'Workbench' Window..\n", __PRETTY_FUNCTION__, __PRETTY_FUNCTION__));
3583 data->wd_WorkbenchWindow = (Object *) DoMethod
3585 self, MUIM_Wanderer_CreateDrawerWindow, (IPTR) NULL
3588 if (data->wd_WorkbenchWindow != NULL)
3590 D(bug("[Wanderer] %s: Workbench Window Obj @ %x\n", __PRETTY_FUNCTION__, data->wd_WorkbenchWindow));
3592 Detach();
3594 #ifdef __AROS__
3595 D(bug("[Wanderer] %s: Really handing control to Zune ..\n", __PRETTY_FUNCTION__));
3597 DoSuperMethodA(CLASS, self, message);
3598 #else
3600 IPTR sigs = 0;
3601 while (DoMethod(self,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
3603 if (sigs)
3605 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
3606 if (sigs & SIGBREAKF_CTRL_C) break;
3609 return 0;
3611 #endif
3612 return RETURN_OK;
3615 /* TODO: Report an error if we fail to create the Workbench's window ... */
3617 return RETURN_ERROR;
3621 ///Wanderer__MUIM_Wanderer_HandleTimer()
3622 /*This function uses GetScreenTitle() function...*/
3624 IPTR Wanderer__MUIM_Wanderer_HandleTimer
3626 Class *CLASS, Object *self, Msg message
3629 SETUP_WANDERER_INST_DATA;
3630 Object *cstate = (Object*)(((struct List*)XGET(self, MUIA_Application_WindowList))->lh_Head);
3631 Object *child = NULL;
3633 STRPTR scr_title = GetUserScreenTitle(data->wd_Prefs);
3635 // D(bug("[Wanderer] Timer event, user screen title %s\n", scr_title));
3637 while ((child = NextObject(&cstate)))
3639 /* Set the Wanderer title to each window's screen title */
3640 STRPTR current_title = NULL;
3642 GET(child, MUIA_Window_ScreenTitle, &current_title);
3643 // D(bug("[Wanderer] Current title %s\n", current_title));
3645 if ((current_title == NULL) || (strcmp(current_title, scr_title) != 0))
3647 /* Limit the menu bar flickering */
3648 SET(child, MUIA_Window_ScreenTitle, (IPTR) scr_title);
3651 /* Request rate-limited, conditional refresh */
3652 DoMethod(child, MUIM_IconWindow_RateLimitRefresh);
3655 CleanAppIconReplyMessages();
3657 return TRUE;
3661 ///Wanderer__MUIM_Wanderer_HandleCommand()
3662 IPTR Wanderer__MUIM_Wanderer_HandleCommand
3664 Class *CLASS, Object *self, Msg message
3667 SETUP_WANDERER_INST_DATA;
3668 struct WBHandlerMessage *wbhm = NULL;
3669 struct List *pub_screen_list;
3670 struct PubScreenNode *pub_screen_node;
3671 WORD visitor_count = 0;
3672 D(bug("[Wanderer] %s()\n", __PRETTY_FUNCTION__));
3673 D(bug("[Wanderer] %s: Received signal at notification port\n", __PRETTY_FUNCTION__));
3675 while ((wbhm = WBHM(GetMsg(data->wd_CommandPort))) != NULL)
3677 D(bug("[Wanderer] %s: Received message from handler, type = %ld\n", __PRETTY_FUNCTION__, wbhm->wbhm_Type));
3679 switch (wbhm->wbhm_Type)
3681 case WBHM_TYPE_SHOW:
3682 D(bug("[Wanderer] %s: WBHM_TYPE_SHOW\n", __PRETTY_FUNCTION__));
3683 if ((data->wd_Screen = LockPubScreen(NULL)) != NULL)
3685 D(bug("[Wanderer] %s: Unlocking access to screen @ %x\n", __PRETTY_FUNCTION__, data->wd_Screen));
3686 UnlockPubScreen(NULL, data->wd_Screen);
3687 SET(self, MUIA_ShowMe, TRUE);
3689 else
3691 /* TODO: We need to handle the possiblity that we fail to lock the pubscreen... */
3692 D(bug("[Wanderer] %s: Couldnt Lock WB Screen!!\n", __PRETTY_FUNCTION__));
3694 break;
3696 case WBHM_TYPE_HIDE:
3697 D(bug("[Wanderer] %s: WBHM_TYPE_HIDE\n", __PRETTY_FUNCTION__));
3698 pub_screen_list = LockPubScreenList();
3700 #ifdef __AROS__
3701 ForeachNode (pub_screen_list, pub_screen_node)
3702 #else
3703 Foreach_Node(pub_screen_list, pub_screen_node);
3704 #endif
3706 if (pub_screen_node->psn_Screen == data->wd_Screen)
3707 visitor_count = pub_screen_node->psn_VisitorCount;
3709 UnlockPubScreenList();
3710 if (visitor_count == 0)
3711 SET(self, MUIA_ShowMe, FALSE);
3712 break;
3714 case WBHM_TYPE_UPDATE:
3715 D(bug("[Wanderer] %s: WBHM_TYPE_UPDATE\n", __PRETTY_FUNCTION__));
3717 CONST_STRPTR name = wbhm->wbhm_Data.Update.Name;
3718 ULONG length;
3719 BOOL windowned = FALSE, refreshroot = FALSE;
3721 switch (wbhm->wbhm_Data.Update.Type)
3723 case WBDISK:
3724 case WBDRAWER:
3725 case WBGARBAGE:
3726 length = strlen(name);
3727 windowned = TRUE;
3728 break;
3729 case WBAPPICON:
3730 refreshroot = TRUE;
3731 break;
3732 default:
3733 length = PathPart(name) - name;
3734 break;
3737 D(bug("[Wanderer] %s: name = %s, length = %ld\n", __PRETTY_FUNCTION__, name, length));
3739 if (windowned)
3741 Object *cstate = (Object*)(((struct List*)XGET(self, MUIA_Application_WindowList))->lh_Head);
3742 Object *child = NULL;
3744 while ((child = NextObject(&cstate)))
3746 if (XGET(child, MUIA_UserData))
3748 STRPTR child_drawer = (STRPTR)XGET(child, MUIA_IconWindow_Location);
3752 child_drawer != NULL
3753 && strncmp(name, child_drawer, length) == 0
3754 && strlen(child_drawer) == length
3757 Object *iconlist = (Object *) XGET(child, MUIA_IconWindow_IconList);
3759 D(bug("[Wanderer] %s: Drawer found: %s!\n", __PRETTY_FUNCTION__, child_drawer));
3761 if (iconlist != NULL)
3763 DoMethod(iconlist, MUIM_IconList_Update);
3764 DoMethod(iconlist, MUIM_IconList_Sort);
3766 break;
3772 if (refreshroot)
3774 Object * root = (Object *)XGET(self, MUIA_Wanderer_WorkbenchWindow);
3775 if (root)
3777 Object *iconlist = (Object *)XGET(root, MUIA_IconWindow_IconList);
3778 if (iconlist != NULL)
3780 DoMethod(iconlist, MUIM_IconList_Update);
3781 DoMethod(iconlist, MUIM_IconList_Sort);
3786 break;
3788 case WBHM_TYPE_OPEN:
3789 D(bug("[Wanderer] %s: WBHM_TYPE_OPEN\n", __PRETTY_FUNCTION__));
3792 Object *cstate = (Object*)(((struct List*)XGET(self, MUIA_Application_WindowList))->lh_Head);
3793 Object *child;
3794 CONST_STRPTR buf = wbhm->wbhm_Data.Open.Name;
3796 while ((child = NextObject(&cstate)))
3798 if (XGET(child, MUIA_UserData))
3800 STRPTR child_drawer = (STRPTR)XGET(child, MUIA_IconWindow_Location);
3801 if (child_drawer && !Stricmp(buf,child_drawer))
3803 int is_open = XGET(child, MUIA_Window_Open);
3804 if (!is_open)
3805 DoMethod(child, MUIM_IconWindow_Open);
3806 else
3808 DoMethod(child, MUIM_Window_ToFront);
3809 SET(child, MUIA_Window_Activate, TRUE);
3811 return 0;
3816 DoMethod
3818 self, MUIM_Wanderer_CreateDrawerWindow, (IPTR) buf
3821 break;
3822 } /* switch */
3824 ReplyMsg((struct Message *) wbhm);
3827 return 0;
3831 ///Wanderer__MUIM_Wanderer_HandleNotify()
3832 IPTR Wanderer__MUIM_Wanderer_HandleNotify
3834 Class *CLASS, Object *self, Msg message
3837 SETUP_WANDERER_INST_DATA;
3838 struct Message *plainMessage = NULL;
3839 struct Wanderer_FSHandler *nodeFSHandler;
3841 while ((plainMessage = GetMsg(data->wd_NotifyPort)) != NULL)
3843 struct NotifyMessage *notifyMessage = (struct NotifyMessage *) plainMessage;
3844 IPTR notifyMessage_UserData = notifyMessage->nm_NReq->nr_UserData;
3845 D(bug("[Wanderer] %s: got FS notification ('%s' @ 0x%p) userdata = 0x%p!\n", __PRETTY_FUNCTION__, notifyMessage->nm_NReq->nr_Name, notifyMessage, notifyMessage_UserData));
3847 if (notifyMessage_UserData != (IPTR)NULL)
3849 /* Only IconWindowDrawerList, IconWindowVolumeList class at the moment */
3850 D(bug("[Wanderer] %s: Icon Window contents changed .. Updating\n", __PRETTY_FUNCTION__));
3851 nodeFSHandler = (struct Wanderer_FSHandler *)notifyMessage_UserData;
3852 nodeFSHandler->HandleFSUpdate(nodeFSHandler->target, notifyMessage);
3853 continue;
3856 ForeachNode(&_WandererIntern_FSHandlerList, nodeFSHandler)
3858 if ((notifyMessage_UserData == (IPTR)NULL) && (strcmp(notifyMessage->nm_NReq->nr_Name, nodeFSHandler->fshn_Node.ln_Name) == 0))
3860 D(bug("[Wanderer] %s: Notification for special handler for '%s'\n", __PRETTY_FUNCTION__, notifyMessage->nm_NReq->nr_Name));
3862 nodeFSHandler->HandleFSUpdate(self, notifyMessage);
3865 ReplyMsg((struct Message *)notifyMessage);
3868 return 0;
3872 ///Wanderer__Func_CreateWandererIntuitionMenu()
3873 /* Some differences here between volumes and subwindows */
3874 Object * Wanderer__Func_CreateWandererIntuitionMenu( BOOL isRoot, BOOL isBackdrop)
3876 Object *_NewWandIntMenu__menustrip = NULL;
3877 IPTR _NewWandIntMenu__OPTION_BACKDROP = CHECKIT|MENUTOGGLE;
3878 IPTR _NewWandIntMenu__OPTION_SHOWALL = CHECKIT|MENUTOGGLE;
3880 if (isBackdrop)
3882 _NewWandIntMenu__OPTION_BACKDROP |= CHECKED;
3885 if ( isRoot )
3887 struct NewMenu nm[] = {
3888 {NM_TITLE, _(MSG_MEN_WANDERER) },
3889 {NM_ITEM, _(MSG_MEN_BACKDROP), _(MSG_MEN_SC_BACKDROP) , _NewWandIntMenu__OPTION_BACKDROP , 0, (APTR) MEN_WANDERER_BACKDROP },
3890 {NM_ITEM, _(MSG_MEN_EXECUTE), _(MSG_MEN_SC_EXECUTE) , 0 , 0, (APTR) MEN_WANDERER_EXECUTE },
3891 {NM_ITEM, _(MSG_MEN_SHELL), _(MSG_MEN_SC_SHELL) , 0 , 0, (APTR) MEN_WANDERER_SHELL },
3892 #if defined(__AROS__)
3893 {NM_ITEM, "AROS" },
3894 {NM_SUB, _(MSG_MEN_ABOUT), NULL , 0 , 0, (APTR) MEN_WANDERER_AROS_ABOUT },
3895 {NM_SUB, _(MSG_MEN_GUISET), NULL , 0 , 0, (APTR) MEN_WANDERER_AROS_GUISETTINGS },
3896 #endif
3897 {NM_ITEM, _(MSG_MEN_ABOUT), NULL , 0 , 0, (APTR) MEN_WANDERER_ABOUT },
3898 {NM_ITEM, _(MSG_MEN_QUIT) , _(MSG_MEN_SC_QUIT) , 0 , 0, (APTR) MEN_WANDERER_QUIT },
3899 {NM_ITEM, _(MSG_MEN_SHUTDOWN), NULL , 0 , 0, (APTR) MEN_WANDERER_SHUTDOWN },
3900 {NM_TITLE, _(MSG_MEN_WINDOW), NULL , 0 },
3901 {NM_ITEM, _(MSG_MEN_UPDATE), NULL , 0 , 0, (APTR) MEN_WINDOW_UPDATE },
3902 {NM_ITEM, NM_BARLABEL },
3903 {NM_ITEM, _(MSG_MEN_CONTENTS), _(MSG_MEN_SC_CONTENTS) , 0 , 0, (APTR) MEN_WINDOW_SELECT },
3904 {NM_ITEM, _(MSG_MEN_CLRSEL), _(MSG_MEN_SC_CLRSEL) , 0 , 0, (APTR) MEN_WINDOW_CLEAR },
3905 {NM_ITEM, NM_BARLABEL },
3906 {NM_ITEM, _(MSG_MEN_SNAPSHT) },
3907 {NM_SUB, _(MSG_MEN_WINDOW), NULL , 0 , 0, (APTR) MEN_WINDOW_SNAP_WIN },
3908 {NM_SUB, _(MSG_MEN_ALL), NULL , 0 , 0, (APTR) MEN_WINDOW_SNAP_ALL },
3909 {NM_ITEM, NM_BARLABEL },
3910 {NM_ITEM, _(MSG_MEN_VIEW) },
3911 {NM_SUB, _(MSG_MEN_ICVIEW), NULL , CHECKIT|CHECKED , ~((1 << 0)|(1 << 3)), (APTR) MEN_WINDOW_VIEW_ICON },
3912 {NM_SUB, _(MSG_MEN_DCVIEW), NULL , CHECKIT|NM_ITEMDISABLED , ~((1 << 1)|(1 << 3)), (APTR) MEN_WINDOW_VIEW_DETAIL },
3913 {NM_SUB, NM_BARLABEL },
3914 {NM_SUB, _(MSG_MEN_ALLFIL), NULL , _NewWandIntMenu__OPTION_SHOWALL|NM_ITEMDISABLED, 0, (APTR) MEN_WINDOW_VIEW_ALL },
3915 {NM_ITEM, _(MSG_MEN_SORTIC) },
3916 {NM_SUB, _(MSG_MEN_CLNUP), _(MSG_MEN_SC_CLNUP) , 0 , 0, (APTR) MEN_WINDOW_SORT_NOW },
3917 {NM_SUB, _(MSG_MEN_ICONSORTING), NULL , CHECKIT|MENUTOGGLE|CHECKED , 0, (APTR) MEN_WINDOW_SORT_ENABLE },
3918 {NM_SUB, NM_BARLABEL },
3919 {NM_SUB, _(MSG_MEN_BYNAME), NULL , CHECKIT , ~((1 << 3)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_NAME },
3920 {NM_SUB, _(MSG_MEN_BYDATE), NULL , CHECKIT|NM_ITEMDISABLED , ~((1 << 4)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_DATE },
3921 {NM_SUB, _(MSG_MEN_BYSIZE), NULL , CHECKIT|NM_ITEMDISABLED , ~((1 << 5)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_SIZE },
3922 {NM_SUB, _(MSG_MEN_BYTYPE), NULL , CHECKIT|NM_ITEMDISABLED , ~((1 << 6)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_TYPE },
3923 {NM_SUB, NM_BARLABEL },
3924 {NM_SUB, _(MSG_MEN_REVERSE), NULL , CHECKIT|MENUTOGGLE , 0, (APTR) MEN_WINDOW_SORT_REVERSE },
3925 {NM_SUB, _(MSG_MEN_DRWFRST), NULL , CHECKIT|MENUTOGGLE|NM_ITEMDISABLED , 0, (APTR) MEN_WINDOW_SORT_TOPDRAWERS },
3926 {NM_SUB, _(MSG_MEN_GROUPICONS), NULL , CHECKIT|MENUTOGGLE|NM_ITEMDISABLED , 0, (APTR) MEN_WINDOW_SORT_GROUP },
3927 {NM_ITEM, NM_BARLABEL },
3928 {NM_ITEM, _(MSG_MEN_FIND), _(MSG_MEN_SC_FIND) , 0 , 0, (APTR) MEN_WINDOW_FIND },
3929 {NM_TITLE, _(MSG_MEN_ICON), NULL , 0 },
3930 {NM_ITEM, _(MSG_MEN_OPEN), _(MSG_MEN_SC_OPEN) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_OPEN },
3931 {NM_ITEM, _(MSG_MEN_RENAME), _(MSG_MEN_SC_RENAME) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_RENAME },
3932 {NM_ITEM, _(MSG_MEN_INFO), _(MSG_MEN_SC_INFO) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_INFORMATION },
3933 {NM_ITEM, _(MSG_MEN_SNAPSHOT), _(MSG_MEN_SC_SNAPSHOT) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_SNAPSHOT },
3934 {NM_ITEM, _(MSG_MEN_UNSNAPSHOT), _(MSG_MEN_SC_UNSNAPSHOT), NM_ITEMDISABLED , 0, (APTR) MEN_ICON_UNSNAPSHOT },
3935 {NM_ITEM, _(MSG_MEN_LEAVE_OUT), _(MSG_MEN_SC_LEAVE_OUT) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_LEAVEOUT },
3936 {NM_ITEM, _(MSG_MEN_PUT_AWAY), _(MSG_MEN_SC_PUT_AWAY) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_PUTAWAY },
3937 {NM_ITEM, NM_BARLABEL },
3938 {NM_ITEM, _(MSG_MEN_DELETE), NULL , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_DELETE },
3939 {NM_ITEM, _(MSG_MEN_FORMAT), NULL , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_FORMAT },
3940 {NM_ITEM, _(MSG_EMPTY_TRASH), NULL , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_EMPTYTRASH},
3941 {NM_TITLE, _(MSG_MEN_TOOLS), NULL , NM_MENUDISABLED },
3942 {NM_END}
3944 _NewWandIntMenu__menustrip = MUI_MakeObject(MUIO_MenustripNM, nm, (IPTR) NULL);
3946 else
3948 struct NewMenu nm[] = {
3949 {NM_TITLE, _(MSG_MEN_WANDERER) },
3950 {NM_ITEM, _(MSG_MEN_BACKDROP), _(MSG_MEN_SC_BACKDROP) , _NewWandIntMenu__OPTION_BACKDROP , 0, (APTR) MEN_WANDERER_BACKDROP },
3951 {NM_ITEM, _(MSG_MEN_EXECUTE), _(MSG_MEN_SC_EXECUTE) , 0 , 0, (APTR) MEN_WANDERER_EXECUTE },
3952 {NM_ITEM, _(MSG_MEN_SHELL), _(MSG_MEN_SC_SHELL) , 0 , 0, (APTR) MEN_WANDERER_SHELL },
3953 #if defined(__AROS__)
3954 {NM_ITEM, "AROS" },
3955 {NM_SUB, _(MSG_MEN_ABOUT), NULL , 0 , 0, (APTR) MEN_WANDERER_AROS_ABOUT },
3956 {NM_SUB, _(MSG_MEN_GUISET), NULL , 0 , 0, (APTR) MEN_WANDERER_AROS_GUISETTINGS },
3957 #endif
3958 {NM_ITEM, _(MSG_MEN_ABOUT), NULL , 0 , 0, (APTR) MEN_WANDERER_ABOUT },
3959 {NM_ITEM, _(MSG_MEN_QUIT) , _(MSG_MEN_SC_QUIT) , 0 , 0, (APTR) MEN_WANDERER_QUIT },
3960 {NM_ITEM, _(MSG_MEN_SHUTDOWN), NULL , 0 , 0, (APTR) MEN_WANDERER_SHUTDOWN },
3961 {NM_TITLE, _(MSG_MEN_WINDOW), NULL , 0 },
3962 {NM_ITEM, _(MSG_MEN_NEWDRAW), _(MSG_MEN_SC_NEWDRAW) , 0 , 0, (APTR) MEN_WINDOW_NEW_DRAWER },
3963 {NM_ITEM, _(MSG_MEN_OPENPAR), NULL , 0 , 0, (APTR) MEN_WINDOW_OPEN_PARENT },
3964 {NM_ITEM, _(MSG_MEN_CLOSE), _(MSG_MEN_SC_CLOSE) , 0 , 0, (APTR) MEN_WINDOW_CLOSE },
3965 {NM_ITEM, _(MSG_MEN_UPDATE), NULL , 0 , 0, (APTR) MEN_WINDOW_UPDATE },
3966 {NM_ITEM, NM_BARLABEL },
3967 {NM_ITEM, _(MSG_MEN_CONTENTS), _(MSG_MEN_SC_CONTENTS) , 0 , 0, (APTR) MEN_WINDOW_SELECT },
3968 {NM_ITEM, _(MSG_MEN_CLRSEL), _(MSG_MEN_SC_CLRSEL) , 0 , 0, (APTR) MEN_WINDOW_CLEAR },
3969 {NM_ITEM, NM_BARLABEL },
3970 {NM_ITEM, _(MSG_MEN_SNAPSHT) },
3971 {NM_SUB, _(MSG_MEN_WINDOW), NULL , 0 , 0, (APTR) MEN_WINDOW_SNAP_WIN },
3972 {NM_SUB, _(MSG_MEN_ALL), NULL , 0 , 0, (APTR) MEN_WINDOW_SNAP_ALL },
3973 {NM_ITEM, NM_BARLABEL },
3974 {NM_ITEM, _(MSG_MEN_VIEW)},
3975 {NM_SUB, _(MSG_MEN_ICVIEW), NULL , CHECKIT|CHECKED ,~((1 << 0)|(1 << 3)), (APTR) MEN_WINDOW_VIEW_ICON },
3976 {NM_SUB, _(MSG_MEN_DCVIEW), NULL , CHECKIT ,~((1 << 1)|(1 << 3)), (APTR) MEN_WINDOW_VIEW_DETAIL },
3977 {NM_SUB, NM_BARLABEL },
3978 {NM_SUB, _(MSG_MEN_ALLFIL), NULL , _NewWandIntMenu__OPTION_SHOWALL , 0, (APTR) MEN_WINDOW_VIEW_ALL },
3979 {NM_ITEM, _(MSG_MEN_SORTIC)},
3980 {NM_SUB, _(MSG_MEN_CLNUP), _(MSG_MEN_SC_CLNUP) , 0 , 0, (APTR) MEN_WINDOW_SORT_NOW },
3981 {NM_SUB, _(MSG_MEN_ICONSORTING), NULL , CHECKIT|MENUTOGGLE|CHECKED , 0, (APTR) MEN_WINDOW_SORT_ENABLE },
3982 {NM_SUB, NM_BARLABEL },
3983 {NM_SUB, _(MSG_MEN_BYNAME), NULL , CHECKIT , ~((1 << 3)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_NAME },
3984 {NM_SUB, _(MSG_MEN_BYDATE), NULL , CHECKIT , ~((1 << 4)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_DATE },
3985 {NM_SUB, _(MSG_MEN_BYSIZE), NULL , CHECKIT , ~((1 << 5)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_SIZE },
3986 {NM_SUB, _(MSG_MEN_BYTYPE), NULL , CHECKIT|NM_ITEMDISABLED , ~((1 << 6)|(1 << 1)|(1 << 8)|(1 << 9)|(1 << 10)), (APTR) MEN_WINDOW_SORT_TYPE },
3987 {NM_SUB, NM_BARLABEL },
3988 {NM_SUB, _(MSG_MEN_REVERSE), NULL , CHECKIT|MENUTOGGLE , 0, (APTR) MEN_WINDOW_SORT_REVERSE },
3989 {NM_SUB, _(MSG_MEN_DRWFRST), NULL , CHECKIT|MENUTOGGLE|CHECKED , 0, (APTR) MEN_WINDOW_SORT_TOPDRAWERS },
3990 {NM_SUB, _(MSG_MEN_GROUPICONS), NULL , CHECKIT|MENUTOGGLE|NM_ITEMDISABLED , 0, (APTR) MEN_WINDOW_SORT_GROUP },
3991 {NM_ITEM, NM_BARLABEL },
3992 {NM_ITEM, _(MSG_MEN_FIND), _(MSG_MEN_SC_FIND) , 0 , 0, (APTR) MEN_WINDOW_FIND },
3993 {NM_TITLE, _(MSG_MEN_ICON), NULL , 0 },
3994 {NM_ITEM, _(MSG_MEN_OPEN), _(MSG_MEN_SC_OPEN) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_OPEN },
3995 {NM_ITEM, _(MSG_MEN_RENAME), _(MSG_MEN_SC_RENAME) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_RENAME },
3996 {NM_ITEM, _(MSG_MEN_INFO), _(MSG_MEN_SC_INFO) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_INFORMATION },
3997 {NM_ITEM, _(MSG_MEN_SNAPSHOT), _(MSG_MEN_SC_SNAPSHOT) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_SNAPSHOT },
3998 {NM_ITEM, _(MSG_MEN_UNSNAPSHOT), _(MSG_MEN_SC_UNSNAPSHOT), NM_ITEMDISABLED , 0, (APTR) MEN_ICON_UNSNAPSHOT },
3999 {NM_ITEM, _(MSG_MEN_LEAVE_OUT), _(MSG_MEN_SC_LEAVE_OUT) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_LEAVEOUT },
4000 {NM_ITEM, _(MSG_MEN_PUT_AWAY), _(MSG_MEN_SC_PUT_AWAY) , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_PUTAWAY },
4001 {NM_ITEM, NM_BARLABEL },
4002 {NM_ITEM, _(MSG_MEN_DELETE), NULL , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_DELETE },
4003 {NM_ITEM, _(MSG_MEN_FORMAT), NULL , NM_ITEMDISABLED },
4004 {NM_ITEM, _(MSG_EMPTY_TRASH), NULL , NM_ITEMDISABLED , 0, (APTR) MEN_ICON_EMPTYTRASH},
4005 {NM_TITLE, _(MSG_MEN_TOOLS), NULL , NM_MENUDISABLED },
4006 {NM_END}
4008 _NewWandIntMenu__menustrip = MUI_MakeObject(MUIO_MenustripNM, nm, (IPTR) NULL);
4010 return _NewWandIntMenu__menustrip;
4014 ///Wanderer__MUIM_Wanderer_CreateDrawerWindow()
4015 Object *Wanderer__MUIM_Wanderer_CreateDrawerWindow
4017 Class *CLASS, Object *self,
4018 struct MUIP_Wanderer_CreateDrawerWindow *message
4021 SETUP_WANDERER_INST_DATA;
4023 Object *window = NULL;
4024 BOOL isWorkbenchWindow = FALSE;
4025 BOOL useBackdrop = FALSE;
4026 IPTR TAG_IconWindow_Drawer;
4027 Object *_NewWandDrawerMenu__menustrip;
4029 Object *window_IconList = NULL;
4031 D(bug("[Wanderer]: %s()\n", __PRETTY_FUNCTION__));
4033 if ((isWorkbenchWindow = (message->drawer == NULL ? TRUE : FALSE)))
4035 useBackdrop = data->wd_Option_BackDropMode;
4038 TAG_IconWindow_Drawer = isWorkbenchWindow ? TAG_IGNORE : MUIA_IconWindow_Location;
4040 data->wd_Screen = LockPubScreen(NULL);
4042 if(data->wd_Screen == NULL)
4044 D(bug("[Wanderer] %s: Couldn't lock screen!\n", __PRETTY_FUNCTION__));
4045 CoerceMethod(CLASS, self, OM_DISPOSE);
4046 return NULL;
4048 D(bug("[Wanderer] %s: Using Screen @ %p\n", __PRETTY_FUNCTION__, data->wd_Screen));
4050 _NewWandDrawerMenu__menustrip = Wanderer__Func_CreateWandererIntuitionMenu (isWorkbenchWindow, useBackdrop);
4052 /* Create a new icon drawer window with the correct drawer being set */
4053 #ifdef __AROS__
4054 window = (Object *)IconWindowObject,
4055 MUIA_UserData, 1,
4056 MUIA_Wanderer_Prefs, (IPTR)data->wd_Prefs,
4057 MUIA_Wanderer_Screen, (IPTR)data->wd_Screen,
4058 MUIA_Window_ScreenTitle, (IPTR)GetUserScreenTitle(data->wd_Prefs),
4059 MUIA_Window_Menustrip, (IPTR) _NewWandDrawerMenu__menustrip,
4060 TAG_IconWindow_Drawer, (IPTR) message->drawer,
4061 MUIA_IconWindow_ActionHook, (IPTR) &_WandererIntern_hook_action,
4062 MUIA_IconWindow_IsRoot, isWorkbenchWindow ? TRUE : FALSE,
4063 isWorkbenchWindow ? MUIA_IconWindow_IsBackdrop : TAG_IGNORE, useBackdrop,
4064 MUIA_Wanderer_FileSysNotifyPort, (IPTR)data->wd_NotifyPort,
4065 isWorkbenchWindow ? TAG_IGNORE : MUIA_Wanderer_FileSysNotifyList, (IPTR)&_WandererIntern_FSHandlerList,
4066 MUIA_Window_IsSubWindow, isWorkbenchWindow ? FALSE : TRUE,
4067 End;
4068 #else
4069 window = NewObject(IconWindow_CLASS->mcc_Class, NULL,
4070 MUIA_UserData, 1,
4071 MUIA_Wanderer_Prefs, data->wd_Prefs,
4072 MUIA_Wanderer_Screen, data->wd_Screen,
4073 MUIA_Window_ScreenTitle, GetUserScreenTitle(data->wd_Prefs),
4074 MUIA_Window_Menustrip, (IPTR) _NewWandDrawerMenu__menustrip,
4075 TAG_IconWindow_Drawer, (IPTR) message->drawer,
4076 MUIA_IconWindow_ActionHook, (IPTR) &_WandererIntern_hook_action,
4077 MUIA_IconWindow_IsRoot, isWorkbenchWindow ? TRUE : FALSE,
4078 isWorkbenchWindow ? MUIA_IconWindow_IsBackdrop : TAG_IGNORE, useBackdrop,
4079 MUIA_Wanderer_FileSysNotifyPort, data->wd_NotifyPort,
4080 isWorkbenchWindow ? TAG_IGNORE : MUIA_Wanderer_FileSysNotifyList, (IPTR)&_WandererIntern_FSHandlerList,
4081 MUIA_Window_IsSubWindow, isWorkbenchWindow ? FALSE : TRUE,
4082 TAG_DONE);
4083 #endif
4085 if (data->wd_Screen)
4087 D(bug("[Wanderer] %s: Unlocking access to screen @ %p\n", __PRETTY_FUNCTION__, data->wd_Screen));
4088 UnlockPubScreen(NULL, data->wd_Screen);
4091 if (window != NULL)
4093 D(bug("[Wanderer] %s: window != NULL\n", __PRETTY_FUNCTION__));
4094 /* Get the drawer path back so we can use it also outside this function */
4095 STRPTR drw = NULL;
4096 BOOL freeDrwStr = FALSE;
4098 if (!isWorkbenchWindow) drw = (STRPTR) XGET(window, MUIA_IconWindow_Location);
4099 else
4101 D(bug("[Wanderer] %s: call AllocVec()\n", __PRETTY_FUNCTION__));
4102 drw = AllocVec ( 5, MEMF_CLEAR );
4103 sprintf ( drw, "RAM:" );
4104 freeDrwStr = TRUE;
4107 if (isWorkbenchWindow)
4109 D(bug("[Wanderer] %s: isWorkbenchWindow\n", __PRETTY_FUNCTION__));
4110 DoMethod
4112 window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
4113 (IPTR)self, 3, MUIM_CallHook, (IPTR)&_WandererIntern_hook_standard, (IPTR)wanderer_menufunc_wanderer_quit
4116 else
4118 DoMethod
4120 window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
4121 (IPTR)_app(self), 4, MUIM_Application_PushMethod, (IPTR)window, 1, MUIM_IconWindow_Remove
4125 D(bug("[Wanderer] %s: call get with MUIA_IconWindow_IconList\n", __PRETTY_FUNCTION__));
4126 GET(window, MUIA_IconWindow_IconList, &window_IconList);
4128 D(bug("[Wanderer] %s: IconWindows IconList @ %p\n", __PRETTY_FUNCTION__, window_IconList));
4130 if (window_IconList != NULL)
4132 struct Hook *_wand_UpdateMenuStates_hook = NULL;
4134 if ((_wand_UpdateMenuStates_hook = AllocMem(sizeof(struct Hook), MEMF_CLEAR|MEMF_PUBLIC)) != NULL)
4136 _wand_UpdateMenuStates_hook->h_Entry = ( HOOKFUNC )Wanderer__HookFunc_UpdateMenuStatesFunc;
4137 DoMethod
4139 window_IconList, MUIM_Notify, MUIA_IconList_SelectionChanged, MUIV_EveryTime,
4140 (IPTR) self, 3,
4141 MUIM_CallHook, _wand_UpdateMenuStates_hook, (IPTR)window
4144 Wanderer__Func_UpdateMenuStates(window, window_IconList);
4146 D(bug("[Wanderer] %s: setup notifications\n", __PRETTY_FUNCTION__));
4147 DoMethod
4149 window, MUIM_Notify, MUIA_Window_Activate, TRUE,
4150 (IPTR)_app(self), 3, MUIM_Set, MUIA_Wanderer_ActiveWindow, (IPTR) window
4153 #if 1
4154 DoMethod
4156 window, MUIM_Notify, MUIA_IconWindow_IsBackdrop, MUIV_EveryTime,
4157 (IPTR)_app(self), 5, MUIM_Application_PushMethod, (IPTR)_app(self), 2, MUIM_CallHook, (IPTR)&_WandererIntern_hook_backdrop
4159 #else
4160 DoMethod
4162 window, MUIM_Notify, MUIA_IconWindow_IsBackdrop, MUIV_EveryTime,
4163 (IPTR)_app(self), 2, MUIM_CallHook, (IPTR) &_WandererIntern_hook_backdrop
4165 #endif
4166 D(bug("[Wanderer] %s: execute all notifies\n", __PRETTY_FUNCTION__));
4167 /* If "Execute Command" entry is clicked open the execute window */
4168 SetMenuDefaultNotifies(self, _NewWandDrawerMenu__menustrip, drw);
4170 D(bug("[Wanderer] %s: add window to app\n", __PRETTY_FUNCTION__));
4171 /* Add the window to the application */
4172 #ifdef __AROS__
4173 DoMethod(_app(self), OM_ADDMEMBER, (IPTR) window);
4174 #else
4175 DoMethod(self, OM_ADDMEMBER, (IPTR) window);
4176 #endif
4177 D(bug("[Wanderer] %s: open window\n", __PRETTY_FUNCTION__));
4178 /* And now open it */
4179 DoMethod(window, MUIM_IconWindow_Open);
4180 D(bug("[Wanderer] %s: clean up memory\n", __PRETTY_FUNCTION__));
4181 /* Clean up ram string */
4182 if ( freeDrwStr && drw ) FreeVec ( drw );
4184 D(bug("[Wanderer] %s: exit\n", __PRETTY_FUNCTION__));
4185 return window;
4188 /*** Setup ******************************************************************/
4189 ZUNE_CUSTOMCLASS_9
4191 Wanderer, NULL, MUIC_Application, NULL,
4192 OM_NEW, struct opSet *,
4193 OM_DISPOSE, Msg,
4194 OM_SET, struct opSet *,
4195 OM_GET, struct opGet *,
4196 MUIM_Application_Execute, Msg,
4197 MUIM_Wanderer_HandleTimer, Msg,
4198 MUIM_Wanderer_HandleCommand, Msg,
4199 MUIM_Wanderer_HandleNotify, Msg,
4200 MUIM_Wanderer_CreateDrawerWindow, struct MUIP_Wanderer_CreateDrawerWindow *