Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 58 additions & 57 deletions src/includes.h
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
#ifndef INCLUDES_H
#define INCLUDES_H

#define STREQUAL(s1, s2) (strcmp(s1, s2) == 0)

#include <stdlib.h>
#include <stdio.h>

#include <exec/types.h>
#include <libraries/gadtools.h>
#include <intuition/intuition.h>
#include <exec/execbase.h>

#include <classes/window.h>
#include <gadgets/layout.h>
#include <proto/layout.h>
#include <proto/window.h>

#include <gadgets/button.h>
#include <proto/listbrowser.h>
#include <gadgets/listbrowser.h>
#include <proto/integer.h>
#include <gadgets/integer.h>
#include <proto/checkbox.h>
#include <gadgets/checkbox.h>
#include <proto/label.h>
#include <images/label.h>
#include <proto/getfile.h>
#include <gadgets/getfile.h>
#include <proto/chooser.h>
#include <gadgets/chooser.h>
#include <proto/string.h>
#include <gadgets/string.h>

#include <workbench/workbench.h>
#include <proto/dos.h>

#define ALL_REACTION_MACROS
#define ALL_REACTION_CLASSES
#include <reaction/reaction.h>
#include <reaction/reaction_macros.h>

#define ASM __asm
#define REG(x) register __ ## x

#define BASEDEF(base) struct Library *base##Base = NULL
#define OPENLIB(base,name) if (!((base##Base) = OpenLibrary ((name),0))) CloseLibs()
#define CLOSELIB(base) if (base##Base) {CloseLibrary (base##Base); base##Base=NULL;}

#define NAME_MAX 0X020
#define PATH_MAX 0X100
#define MAX_LISTED_ADF 0X200
#define BUFFERSIZE 0X200

#include <string.h>

#endif
#ifndef INCLUDES_H
#define INCLUDES_H

#define STREQUAL(s1, s2) (strcmp(s1, s2) == 0)

#include <stdlib.h>
#include <stdio.h>

#include <exec/types.h>
#include <libraries/gadtools.h>
#include <intuition/intuition.h>
#include <exec/execbase.h>

#include <classes/window.h>
#include <gadgets/layout.h>
#include <proto/layout.h>
#include <proto/window.h>

#include <gadgets/button.h>
#include <proto/listbrowser.h>
#include <gadgets/listbrowser.h>
#include <proto/integer.h>
#include <gadgets/integer.h>
#include <proto/checkbox.h>
#include <gadgets/checkbox.h>
#include <proto/label.h>
#include <images/label.h>
#include <proto/getfile.h>
#include <gadgets/getfile.h>
#include <proto/chooser.h>
#include <gadgets/chooser.h>
#include <proto/string.h>
#include <gadgets/string.h>

#include <workbench/startup.h>
#include <workbench/workbench.h>
#include <proto/dos.h>

#define ALL_REACTION_MACROS
#define ALL_REACTION_CLASSES
#include <reaction/reaction.h>
#include <reaction/reaction_macros.h>

#define ASM __asm
#define REG(x) register __ ## x

#define BASEDEF(base) struct Library *base##Base = NULL
#define OPENLIB(base,name) if (!((base##Base) = OpenLibrary ((name),0))) CloseLibs()
#define CLOSELIB(base) if (base##Base) {CloseLibrary (base##Base); base##Base=NULL;}

#define NAME_MAX 0X020
#define PATH_MAX 0X100
#define MAX_LISTED_ADF 0X200
#define BUFFERSIZE 0X200

#include <string.h>

#endif
188 changes: 129 additions & 59 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,70 @@ int makeMenu(APTR MenuVisualInfo)
return( 0L );
}

void ejectADFMenu(struct AppMessage *EjectADFMsg)
{
ULONG i = 0, j = 0;
char VolName[104];
int index = -1;

/* Make sure our list is up-to-date before searching it */
createADFList();

for(i = 0; i < EjectADFMsg->am_NumArgs; i++) {
if(EjectADFMsg->am_ArgList[i].wa_Name[0] = 0) {
NameFromLock(EjectADFMsg->am_ArgList[i].wa_Lock, &VolName, 104);
VolName[strlen(VolName)-1] = 0;
for(j = 0; j < MAX_LISTED_ADF; j++) {
if(strcmp(col2[j], VolName) == 0) {
index = j;
break;
}
}
if(index>=0) Eject(col1[index]);
}
}

createADFList();
}

void removeEjectADFMenu(struct AppMenuItem *ejectADFItem, struct MsgPort *EjectADFMP)
{
struct AppMessage *appmsg = NULL;

RemoveAppMenuItem(ejectADFItem);

while(appmsg = (struct AppMessage *)GetMsg(EjectADFMP)) {
ReplyMsg((struct Message *)appmsg);
}
DeleteMsgPort(EjectADFMP);
}

struct MsgPort *addEjectADFMenu(struct AppMenuItem **ejectADFItem)
{
struct MsgPort *EjectADFMP = NULL;
struct AppMenuItem *appmenuitem = NULL;

if(EjectADFMP = CreateMsgPort()) {
appmenuitem = AddAppMenuItemA(0L, 0, "Eject ADF", EjectADFMP, NULL);
if(appmenuitem == NULL) {
DeleteMsgPort(EjectADFMP);
EjectADFMP = NULL;
}
}

*ejectADFItem = appmenuitem;
return EjectADFMP;
}

int appMain()
{
ULONG result;
UWORD code;
ULONG wait = 0;
struct MsgPort *EjectADFMP = NULL;
struct AppMenuItem *EjectADFItem = NULL;
ULONG EjectADFSignal = 0;
struct AppMessage *EjectADFMsg;

ScreenPtr = LockPubScreen(NULL);
VisualInfoPtr = GetVisualInfo(ScreenPtr, NULL);
Expand Down Expand Up @@ -328,80 +388,89 @@ int appMain()
makeMenu(VisualInfoPtr);
SetMenuStrip(WindowPtr, dacMenu);
createADFList();

EjectADFMP = addEjectADFMenu(&EjectADFItem);
EjectADFSignal = (1 << EjectADFMP->mp_SigBit);

GetAttr(WINDOW_SigMask, WindowObjectPtr, &signal);

while(!done)
{
Wait(signal | (1 << WindowPtr->UserPort->mp_SigBit));

while ((result = DoMethod(WindowObjectPtr, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
{ switch (result & WMHI_CLASSMASK)
{
case WMHI_CLOSEWINDOW:
done = TRUE;
break;

case WMHI_GADGETUP:
switch(result & WMHI_GADGETMASK)
{
wait = Wait(signal | (1 << WindowPtr->UserPort->mp_SigBit) | EjectADFSignal);

if(wait & EjectADFSignal) {
while(EjectADFMsg = (struct AppMessage *)GetMsg(EjectADFMP)) {
ejectADFMenu(EjectADFMsg);
ReplyMsg((struct Message *)EjectADFMsg);
}
} else {
while ((result = DoMethod(WindowObjectPtr, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
{ switch (result & WMHI_CLASSMASK)
{
case WMHI_CLOSEWINDOW:
done = TRUE;
break;

case WMHI_GADGETUP:
switch(result & WMHI_GADGETMASK)
{

case IDLOADCHANGE:
loadChangeAdfWin();
break;
case IDLOADCHANGE:
loadChangeAdfWin();
break;

case IDCREATE:
createAdfWin();
break;
case IDCREATE:
createAdfWin();
break;

case IDEJECT:
clickEject();
break;
case IDEJECT:
clickEject();
break;

case IDEJECTALL:
clickEjectAll();
break;

case IDREFRESH:
createADFList();
break;

case IDLISTBROWSER:
selectedIndex = code;
break;

default:
break;
}
break;
case IDEJECTALL:
clickEjectAll();
break;

case IDREFRESH:
createADFList();
break;

case IDLISTBROWSER:
selectedIndex = code;
break;

default:
break;
}
break;

case WMHI_ICONIFY: /* iconify / uniconify */
iconify();
break;
case WMHI_ICONIFY: /* iconify / uniconify */
iconify();
break;

case WMHI_MENUPICK:
ProcessMenuIDCMPdacMenu(code);
break;
case WMHI_MENUPICK:
ProcessMenuIDCMPdacMenu(code);
break;

case WMHI_RAWKEY:
switch(code)
{
case 0x45: // press ESC to quit
done=TRUE;
break;
case WMHI_RAWKEY:
switch(code)
{
case 0x45: // press ESC to quit
done=TRUE;
break;

default:
default:
break;
}
break;
}
break;


default:
break;
default:
break;
}
}
}
}
}

appTop = WindowPtr->TopEdge;
appLeft = WindowPtr->LeftEdge;
appWidth = WindowPtr->Width;
Expand All @@ -411,7 +480,8 @@ int appMain()
freeList(&adfList);
ClearMenuStrip(WindowPtr);
FreeVisualInfo(VisualInfoPtr);

removeEjectADFMenu(EjectADFItem, EjectADFMP);

// delete log file
Execute("Delete RAM:dacgui.log >NIL:", NULL, NULL);

Expand Down Expand Up @@ -1270,4 +1340,4 @@ void iconify(void)
{
done = TRUE;
}
}
}