Skip to content

Commit

Permalink
Merge pull request #6 from Arisamiga/open-results-in-Window
Browse files Browse the repository at this point in the history
Implementation of -g flag
  • Loading branch information
Arisamiga authored Oct 30, 2023
2 parents da50b35 + aac93e4 commit 13dc659
Show file tree
Hide file tree
Showing 22 changed files with 133 additions and 97 deletions.
13 changes: 12 additions & 1 deletion aminet.readme
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Short: Disk usage statistics+file/folder utility
Uploader: [email protected] (Aris Sokianos)
Author: Aris (arisamiga) Sokianos
Type: util/misc
Version: 1.0.2
Version: 1.1.0
Architecture: m68k-amigaos >= 3.0.0
Distribution: Aminet
Replaces: util/misc/Mnemosyne.lha
Expand Down Expand Up @@ -41,6 +41,17 @@ https://github.com/Arisamiga/Mnemosyne/issues
------------------------------------------------------------------------------
**ChangeLog**

-> Update 1.1.0 (2023-10-30)
* Added -g flag to open a window for scans from the shell.
* Using proper Semantic Versioning now.
* Current version moving to 1.0.2 -> 1.1.0
* Made Mnemosyne program from: 32.440B to 32.504B
* New Guide images updated to fit the version
* .guide finally has a proper icon now.
* Fixed Duplications in scanning procedure code.
* Prevent wrongful appending of file path.


-> Update 1.0.2 (2023-10-27)
* Made Mnemosyne program able to be used on AmigaOS 3.1 and 3.1.4 and 3.9
(For AmigaOS 3.1 and 3.1.4 you need to install ClassAct33)
Expand Down
Binary file modified build/Guide_Images/mnemosyne.iff
Binary file not shown.
Binary file modified build/Guide_Images/mnemosyne_back.iff
Binary file not shown.
Binary file modified build/Guide_Images/mnemosyne_folder_ready.iff
Binary file not shown.
Binary file modified build/Guide_Images/mnemosyne_ready.iff
Binary file not shown.
Binary file modified build/Guide_Images/mnemosyne_result.iff
Binary file not shown.
Binary file modified build/Guide_Images/mnemosyne_scanning.iff
Binary file not shown.
Binary file modified build/Guide_Images/pressdrawer.iff
Binary file not shown.
14 changes: 12 additions & 2 deletions build/Mnemosyne.guide
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@database Mnemosyne.guide

@author "Aris (Arisamiga) Sokianos"
@$VER: Mnemosyne.Guide 1.0.2
@$VER: Mnemosyne.Guide 1.1.0
@(c) 2023 Aris (Arisamiga) Sokianos
@Node "Main" "Mnemosyne"

Expand All @@ -15,7 +15,7 @@
|_| |_|_| |_|\\___|_| |_| |_|\\___/|___/\\___ |_| |_|\\___|
|___/

@{jright}Version 1.0.2
@{jright}Version 1.1.0

@{jcenter}

Expand Down Expand Up @@ -136,6 +136,16 @@ There are 2 ways to use Mnemosyne:
@{b}Mnemosyne <path>@{ub}

Where <path> is the path to the directory you want to scan.


Using the -g CLI Flag:
-------------------------

@{b}Mnemosyne -g <path>@{ub}

Where <path> is the path to the directory you want to scan.

Adding the -g flag will open the GUI and start the scanning process.



Expand Down
Binary file added build/Mnemosyne.guide.info
Binary file not shown.
Binary file modified images/mnemosyne.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mnemosyneG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mnemosyne_Gresult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mnemosyne_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mnemosyne_folder_ready.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mnemosyne_ready.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mnemosyne_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mnemosyne_scanning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/pressdrawer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "window.h"

// Mnemosyne Version
char *vers = "\0$VER: Mnemosyne 1.0.2";
char *vers = "\0$VER: Mnemosyne 1.1.0";

struct IntuitionBase *IntuitionBase;
struct Library *UtilityBase;
Expand Down Expand Up @@ -98,7 +98,15 @@ int main(int argc, char **argv)
{
if (openLibraries())
{
createWindow();
createWindow(NULL);
}
closeLibraries();
return 0;
}
if (argv[1][0] == '-' && (argv[1][1] == 'g' || argv[1][1] == 'G') && !argv[1][2] && argc >= 3){
if (openLibraries())
{
createWindow(argv[2]);
}
closeLibraries();
return 0;
Expand All @@ -118,5 +126,5 @@ int main(int argc, char **argv)

void info(void)
{
printf("Mnemosyne: Starts Application\nMnemosyne (PATH): Scans Selected Path\n");
printf("Mnemosyne: Starts GUI Application\nMnemosyne (PATH): Scans Selected Path\nMnemosyne -g (PATH): Scans Selected Path in GUI\n");
}
187 changes: 97 additions & 90 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum
OID_MENU_QUIT,
OID_SCAN_BUTTON,
OID_SCAN_OPEN,
OID_GIVEN_PATH,
OID_LAST
};

Expand Down Expand Up @@ -263,7 +264,77 @@ void fileRequesterSequence(Object *fileRequester,
SetAttrs(listBrowser, LISTBROWSER_TitleClickable, FALSE, TAG_DONE);
}
}
void scanningSequence(int type,
struct Window *intuiwin,
Object *windowObject,
Object *bottomText,
Object *scanButton,
Object *backButton,
struct Gadget *listBrowser,
Object *fileRequester,
BOOL doneFirst,
BOOL scanning,
struct Hook CompareHook,
char *givenPath)
{
if (scanning)
{
// printf("Scanning already in progress\n");
return;
}

if (!fileEntered)
{
// printf("No file entered\n");
updateBottomText(bottomText, windowObject, "Please Select a folder");
return;
}

BPTR lockPath = Lock(givenPath, ACCESS_READ);
if (!lockPath)
{
updateBottomText(bottomText, windowObject, "Invalid Path, Select a valid path");
return;
}
UnLock(lockPath);

scanning = TRUE;

char *parentName = AllocVec(sizeof(char) * MAX_BUFFER, MEMF_CLEAR);

getNameFromPath(givenPath, parentName, MAX_BUFFER);

if (type == OID_MAIN_LIST || type == OID_GIVEN_PATH)
updatePathText(fileRequester, givenPath);

updateBottomTextW2Text(bottomText, windowObject, "Scanning: ", parentName, FALSE);

SetAttrs(scanButton, GA_Disabled, TRUE, TAG_DONE);

toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, TRUE, TRUE);

scanPath(givenPath, FALSE, listBrowser);

scanning = FALSE;

toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, FALSE, FALSE);

DoGadgetMethod(listBrowser, intuiwin, NULL, LBM_SORT, NULL, 1, LBMSORT_REVERSE, &CompareHook);
ColumnSorting[1].Sorting = LBMSORT_REVERSE;
if(type == OID_BACK_BUTTON)
updatePathText(fileRequester, givenPath);

updateMenuItems(intuiwin, TRUE);

STRPTR TotalText = returnFormatWithTotal();
updateBottomTextW2AndTotal(bottomText, windowObject, "Current: ", parentName, TotalText, TRUE);

// Remove focus from the listbrowser
SetAttrs(listBrowser, LISTBROWSER_Selected, -1, TAG_DONE);

FreeVec(TotalText);
FreeVec(parentName);
}

// -------------
// Main Window Functions
Expand All @@ -279,9 +350,10 @@ void processEvents(Object *windowObject,
struct Hook NameHook,
Object *bottomText,
Object *fileRequester,
Object *scanButton);
Object *scanButton,
char *givenPath);

void createWindow(void)
void createWindow(char *Path)
{
struct Window *intuiwin = NULL;
Object *windowObject = NULL;
Expand Down Expand Up @@ -426,7 +498,7 @@ void createWindow(void)
WINDOW_Icon, GetDiskObject("PROGDIR:Mnemosyne"),
WINDOW_AppPort, appPort,
WA_Activate, TRUE,
WA_Title, "Mnemosyne 1.0.2",
WA_Title, "Mnemosyne 1.1.0",
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_DepthGadget, TRUE,
Expand All @@ -442,7 +514,7 @@ void createWindow(void)
if (!(intuiwin = (struct Window *)DoMethod(windowObject, WM_OPEN, NULL)))
cleanexit(windowObject, appPort);
UpdateMenu(intuiwin, TRUE);
processEvents(windowObject, intuiwin, listBrowser, backButton, doneFirst, CompareHook, NameHook, bottomText, fileRequester, scanButton);
processEvents(windowObject, intuiwin, listBrowser, backButton, doneFirst, CompareHook, NameHook, bottomText, fileRequester, scanButton, Path);
DoMethod(windowObject, WM_CLOSE);
clearList(contents);
cleanexit(windowObject, appPort);
Expand All @@ -456,7 +528,8 @@ void processEvents(Object *windowObject,
struct Hook NameHook,
Object *bottomText,
Object *fileRequester,
Object *scanButton)
Object *scanButton,
char *givenPath)
{
ULONG windowsignal;
ULONG receivedsignal;
Expand All @@ -465,6 +538,17 @@ void processEvents(Object *windowObject,
BOOL end = FALSE;
BOOL scanning = FALSE;

if (givenPath != NULL){
fileEntered = TRUE;
if (getLastCharSafely(givenPath) != ':')
{
__asm_strncat(givenPath, "/",2);
}
updatePathText(fileRequester, givenPath);
scanningSequence(OID_GIVEN_PATH, intuiwin, windowObject, bottomText, scanButton, backButton, listBrowser, fileRequester, doneFirst, scanning, CompareHook, givenPath);
doneFirst = TRUE;
}

GetAttr(WINDOW_SigMask, windowObject, &windowsignal);
while (!end)
{
Expand Down Expand Up @@ -499,6 +583,7 @@ void processEvents(Object *windowObject,
{
case OID_SCAN_OPEN:
{
updatePathText(fileRequester, "");
fileRequesterSequence(fileRequester,
intuiwin,
bottomText,
Expand Down Expand Up @@ -552,6 +637,7 @@ void processEvents(Object *windowObject,
{
case OID_FILE_REQUESTER:
{
updatePathText(fileRequester, "");
fileRequesterSequence(fileRequester,
intuiwin,
bottomText,
Expand All @@ -572,39 +658,15 @@ void processEvents(Object *windowObject,
getParentPath(pastPath, parentPath, MAX_BUFFER);
// printf("Parent Path: %s\n", parentPath);

char *parentName = AllocVec(sizeof(char) * MAX_BUFFER, MEMF_CLEAR);
getNameFromPath(parentPath, parentName, MAX_BUFFER);

if (getLastCharSafely(parentPath) != ':')
{
__asm_strncat(parentPath, "/",2);
}

updateBottomTextW2Text(bottomText, windowObject, "Scanning: ", parentName, FALSE);

toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, TRUE, TRUE);

scanning = TRUE;

scanPath(parentPath, FALSE, listBrowser);

scanning = FALSE;

DoGadgetMethod((struct Gadget*)listBrowser, intuiwin, NULL, LBM_SORT, NULL, 1, LBMSORT_REVERSE, &CompareHook);
ColumnSorting[1].Sorting = LBMSORT_REVERSE;

updatePathText(fileRequester, parentPath);

updateMenuItems(intuiwin, TRUE);

STRPTR TotalText = returnFormatWithTotal();
updateBottomTextW2AndTotal(bottomText, windowObject, "Current: ", parentName, TotalText, FALSE);

toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, FALSE, TRUE);
scanningSequence(OID_BACK_BUTTON, intuiwin, windowObject, bottomText, scanButton, backButton, listBrowser, fileRequester, doneFirst, scanning, CompareHook, parentPath);
doneFirst = TRUE;

FreeVec(TotalText);
FreeVec(parentPath);
FreeVec(parentName);
break;
}
case OID_SCAN_BUTTON:
Expand All @@ -622,46 +684,16 @@ void processEvents(Object *windowObject,
break;
}

scanning = TRUE;
TEXT *buffer = AllocVec(sizeof(char) * MAX_BUFFER, MEMF_CLEAR);
ULONG pathPtr;

GetAttr(GETFILE_FullFile, fileRequester, &pathPtr);

snprintf(buffer, MAX_BUFFER, "%s", (char *)pathPtr);

char *parentName = AllocVec(sizeof(char) * MAX_BUFFER, MEMF_CLEAR);

getNameFromPath(buffer, parentName, MAX_BUFFER);

updateBottomTextW2Text(bottomText, windowObject, "Scanning: ", (STRPTR)parentName, FALSE);

SetAttrs(scanButton, GA_Disabled, TRUE, TAG_DONE);

toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, TRUE, TRUE);


scanPath((char *)pathPtr, FALSE, listBrowser);

FreeVec(buffer);

scanning = FALSE;

toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, FALSE, FALSE);

scanningSequence(OID_SCAN_BUTTON, intuiwin, windowObject, bottomText, scanButton, backButton, listBrowser, fileRequester, doneFirst, scanning, CompareHook, buffer);
doneFirst = TRUE;

DoGadgetMethod((struct Gadget*)listBrowser, intuiwin, NULL, LBM_SORT, NULL, 1, LBMSORT_REVERSE, &CompareHook);
ColumnSorting[1].Sorting = LBMSORT_REVERSE;

updateMenuItems(intuiwin, TRUE);

// printf("Donefirst: %d\n", doneFirst);
STRPTR TotalText = returnFormatWithTotal();
updateBottomTextW2AndTotal(bottomText, windowObject, "Current: ", parentName, TotalText, TRUE);

FreeVec(parentName);
FreeVec(TotalText);
FreeVec(buffer);
break;
}
case OID_MAIN_LIST:
Expand Down Expand Up @@ -732,34 +764,9 @@ void processEvents(Object *windowObject,
}

snprintf(newPath, MAX_BUFFER, "%s%s", pastPath, text);
updatePathText(fileRequester, newPath);
updateBottomTextW2Text(bottomText, windowObject, "Scanning: ", text, FALSE);
toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, TRUE, TRUE);

scanning = TRUE;

scanPath(newPath, FALSE, listBrowser);

toggleButtons(windowObject, backButton, listBrowser, fileRequester, pastPath, doneFirst, FALSE, FALSE);

scanning = FALSE;
scanningSequence(OID_MAIN_LIST, intuiwin, windowObject, bottomText, scanButton, backButton, listBrowser, fileRequester, doneFirst, scanning, CompareHook, newPath);
doneFirst = TRUE;
}

DoGadgetMethod((struct Gadget*)listBrowser, intuiwin, NULL, LBM_SORT, NULL, 1, LBMSORT_REVERSE, &CompareHook);
ColumnSorting[1].Sorting = LBMSORT_REVERSE;

updateMenuItems(intuiwin, TRUE);
// printf("Donefirst: %d\n", doneFirst);
char *parentName = AllocVec(sizeof(char) * MAX_BUFFER, MEMF_CLEAR);
getNameFromPath(pastPath, parentName, MAX_BUFFER);
STRPTR TotalText = returnFormatWithTotal();
updateBottomTextW2AndTotal(bottomText, windowObject, "Current: ", parentName, TotalText, TRUE);

// Remove focus from the listbrowser
SetAttrs(listBrowser, LISTBROWSER_Selected, -1, TAG_DONE);

FreeVec(TotalText);
FreeVec(parentName);
FreeVec(parentPath);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/window.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef WINDOW_H
#define WINDOW_H
void createWindow(void);
void createWindow(char *);
#endif

0 comments on commit 13dc659

Please sign in to comment.