Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start to use Tooltypes for configs #16

Merged
merged 14 commits into from
Jan 7, 2024
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Mnemosyne: $(OBJ)
# Files and Dependances
src/funcs.o: src/funcs.h src/funcs.c

src/main.o: src/main.c src/scan.h src/window.h
src/main.o: src/main.c src/scan.h src/window.h src/funcs.h

src/scan.o: src/scan.h src/scan.c src/funcs.h

Expand Down
2 changes: 1 addition & 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.1.1
Version: 1.2.0
Architecture: m68k-amigaos >= 3.0.0
Distribution: Aminet
Replaces: util/misc/Mnemosyne.lha
Expand Down
Binary file added build/Guide_Images/Tooltypes.iff
Binary file not shown.
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.
62 changes: 59 additions & 3 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.1.1
@$VER: Mnemosyne.Guide 1.2.0
@(c) 2023 Aris (Arisamiga) Sokianos
@Node "Main" "Mnemosyne"

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

@{jright}Version 1.1.1
@{jright}Version 1.2.0

@{jcenter}

Expand All @@ -29,6 +29,7 @@ which can be used to see how much disk space your files and folders are taking u
@{" Requirements " Link "Requirements"}
@{" Installation " Link "Installation"}
@{" Usage " Link "Usage"}
@{" Tooltypes " Link "Tooltypes"}
@{" Notes " Link "Notes"}

@EndNode
Expand Down Expand Up @@ -231,11 +232,62 @@ There are 2 ways to use Mnemosyne:
+ Quit: Quits Mnemosyne.


@EndNode

@Node "Tooltypes" "Tooltypes"
@Next "Notes"
@Prev "Usage"
@Toc "Main"

@{jleft}@{lindent 3}
@{b}Tooltypes@{ub}
***************

Mnemosyne has available tooltypes already in the .info file.

These tooltypes can be used to change the behavior of Mnemosyne
to use or not use certain features.

How to use Tooltypes:
---------------------

To use tooltypes,
you need to @{b}open the Mnemosyne icon
information window@{ub} and click on the @{b}"Icon"@{ub} tab.

There you will see a list of tooltypes that you can use.

There will be mostly words with @{b}()@{ub} around them
which means that the specific feature is @{b}disabled@{ub}.
To enable it, just remove the @{b}()@{ub}.

Using the Tooltypes on the Menu Bar:
------------------------------------
You can also change the features you want by
using Mnemosyne's Menu Bar.
They will be under @{b}Settings@{ub} on menu.
@{lindent 8}@{IMG "GUIDEDIR:Guide_Images/Tooltypes.iff"}@{lindent 0}
The features that are @{b}enabled@{ub} will have a @{b}*@{ub} next to them.

Note: The Settings Names are @{b}not the same as the tooltypes names@{ub}.
(If you want to know the tooltype name try to enable the feature
and then open the icon information window and see the tooltype name)



The available tooltypes are:
----------------------------

+ @{b}NOROUND@{ub} - This will disable the rounding of certain size values
(Mainly the overall size of a folder).



@EndNode


@Node "Notes" "Notes"
@Prev "Usage"
@Prev "Tooltypes"
@Toc "Main"

@{jleft}@{lindent 3}
Expand All @@ -256,4 +308,8 @@ as some files and folders have a very small contribution
to the total size of the directory and having them
rounded up will cause the total to be more than 100%.

- The rounding of the overall size of a folder is done
by rounding a number DOWN to the nearest integer so for example
19.9MB will be rounded to 19MB.

@EndNode
Binary file modified build/Mnemosyne.info
Binary file not shown.
Binary file added images/Tooltypes.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.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.
106 changes: 106 additions & 0 deletions src/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/listbrowser.h>
#include <proto/icon.h>

#include <workbench/icon.h>

#include <exec/types.h>

#include "funcs.h"

BOOL NoRoundOption = FALSE;

int returnFormatValue(STRPTR format){
if(strcmp(format, "B") == 0)
{
Expand Down Expand Up @@ -235,3 +240,104 @@ size_t safeStrlen(const char *str)
}
return len;
}

// Get path from where the program is running

char* getProgramPath() {
char* path = AllocVec(sizeof(char) * 256, MEMF_CLEAR);
if (path == NULL) {
// Handle error
return NULL;
}

BPTR lock = Lock("", ACCESS_READ);
if (lock)
{
NameFromLock(lock, path, 256);
// Append Mnemosyne to the path
strcat(path, "Mnemosyne");
UnLock(lock);
}
return path;
}

void initializeIconTooltypes(void)
{

// Get path from where the program is running
char* path = getProgramPath();

if (IconBase)
{
struct DiskObject *diskObj = GetDiskObjectNew(path);
if(diskObj)
{
// Check if the tooltypes are empty
if (diskObj->do_ToolTypes == NULL)
{
// printf("Empty\n");
NoRoundOption = FALSE;
FreeDiskObject(diskObj);
return;
}

char *buf = AllocVec(sizeof(char) * 256, MEMF_CLEAR);

for (STRPTR *tool_types = diskObj->do_ToolTypes; (buf = *tool_types); ++tool_types)
{
// printf("%s\n", buf);
if (strncmp(buf, "NOROUND", 7) == 0)
{
NoRoundOption = TRUE;
}
}
// printf("%s\n", result);
FreeVec(buf);
FreeDiskObject(diskObj);
}
}
}

void updateIconTooltypes (void)
{
// Get path from where the program is running
char* path = getProgramPath();

if (IconBase)
{
struct DiskObject *diskObj = GetIconTags(path, TAG_DONE);
if(diskObj)
{
// Create array with the new tooltypes
char **newToolTypes = AllocVec(sizeof(char *) * 2, MEMF_CLEAR);
if (newToolTypes)
{
if (NoRoundOption)
{
newToolTypes[0] = "NOROUND";
}
else
{
newToolTypes[0] = "(NOROUND)";
}
newToolTypes[1] = NULL;

diskObj->do_ToolTypes = (STRPTR *)newToolTypes;

LONG errorCode;
BOOL success;
success = PutIconTags(path, diskObj,
ICONPUTA_DropNewIconToolTypes, TRUE,
ICONA_ErrorCode, &errorCode,
TAG_DONE);

if(success == FALSE)
{
printf("Error: %ld\n", errorCode);
}

FreeVec(newToolTypes);
}
}
}
}
6 changes: 6 additions & 0 deletions src/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ char* getLastTwoChars(const char*);
size_t strlcpy(char *dest, const char *source, size_t size);
char *string_to_lower(const char *, size_t);
size_t safeStrlen(const char *str);
void initializeIconTooltypes(void);
void updateIconTooltypes (void);
// ------------ Varibles ------------

extern BOOL NoRoundOption;

#endif
38 changes: 27 additions & 11 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#include <proto/exec.h>

#include "scan.h"
#include "funcs.h"
#include "window.h"

// Mnemosyne Version
char *vers = "\0$VER: Mnemosyne 1.1.1";
char *vers = "\0$VER: Mnemosyne 1.2.0";

struct IntuitionBase *IntuitionBase;
struct Library *UtilityBase;
Expand All @@ -16,6 +17,7 @@ struct Library *ButtonBase;
struct Library *GetFileBase;
struct Library *GadToolsBase;
struct Library *WorkbenchBase;
struct Library *IconBase;

// Declare functions after main
void info(void);
Expand Down Expand Up @@ -61,11 +63,6 @@ BOOL openLibraries(void)
printf( "Failed to open gadtools.library! Make sure the version is above v39.\n");
return FALSE;
}
if ((WorkbenchBase = OpenLibrary("workbench.library", 39)) == NULL) {
printf( "Failed to open workbench.library! Make sure the version is above v39.\n");
return FALSE;
}

return TRUE;
}

Expand All @@ -91,9 +88,32 @@ void closeLibraries(void)
CloseLibrary(WorkbenchBase);
}

BOOL openToolTypeLibraries(void)
{
if ((WorkbenchBase = OpenLibrary("workbench.library", 39)) == NULL) {
printf( "Failed to open workbench.library! Make sure the version is above v39.\n");
return FALSE;
}
if ((IconBase = OpenLibrary("icon.library", 39)) == NULL) {
printf( "Failed to open icon.library! Make sure the version is above v39.\n");
return FALSE;
}
return TRUE;
}



int main(int argc, char **argv)
{
if (argc > 1 && argv[1][0] == '?' && !argv[1][1])
{
info();
return 0;
}

if (openToolTypeLibraries()){
initializeIconTooltypes();
}
if (argc <= 1)
{
if (openLibraries())
Expand All @@ -111,16 +131,12 @@ int main(int argc, char **argv)
closeLibraries();
return 0;
}
if (argv[1][0] == '?')
{
info();
return 0;
}
// Printf a line
printf("\n----------------------------------------\n");
printf("Scanning: %s\n\n", argv[1]);
printf("| Name: \t\t Size: \n\n");
scanPath(argv[1], FALSE, FALSE);
closeLibraries();
return 0;
}

Expand Down
Loading
Loading