From e7bb7c8684f04179f45f0ecbd95b5126f1ffacaf Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 4 Feb 2019 23:58:26 +0100 Subject: [PATCH] Enable "Set Rel" for directory bookmarks only with portable installation add a global variable to store if we are in a portable installation --- src/filesel.c | 3 ++- src/global.h | 3 +++ src/setup.c | 10 +++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/filesel.c b/src/filesel.c index e4ea7df4..1c75e3f0 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -1221,7 +1221,8 @@ static void Display_bookmark(T_Dropdown_button * Button, int bookmark_number) Window_dropdown_clear_items(Button); Window_dropdown_add_item(Button,0,"Set"); #if !(defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)) - Window_dropdown_add_item(Button,3,"Set Rel"); + if (Portable_Installation_Detected) + Window_dropdown_add_item(Button,3,"Set Rel"); #endif if (Config.Bookmark_directory[bookmark_number]) { diff --git a/src/global.h b/src/global.h index 02fef586..ecd7acb2 100644 --- a/src/global.h +++ b/src/global.h @@ -770,6 +770,9 @@ GFX2_GLOBAL signed char File_error; /// Current line number when reading/writing gfx2.ini GFX2_GLOBAL int Line_number_in_INI_file; +/// Set to true when the .cfg and .ini files are along the executable +GFX2_GLOBAL byte Portable_Installation_Detected; + // -- For iconv #ifdef ENABLE_FILENAMES_ICONV diff --git a/src/setup.c b/src/setup.c index 53ed4e6a..3b831258 100644 --- a/src/setup.c +++ b/src/setup.c @@ -52,6 +52,7 @@ #include "struct.h" #include "io.h" #include "setup.h" +#include "global.h" #if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) // This is a random default value ... @@ -192,7 +193,12 @@ void Set_config_directory(const char * program_dir, char * config_dir) strcpy(filename, config_dir); strcat(filename, CONFIG_FILENAME); - if (!File_exists(filename)) + if (File_exists(filename)) + { + // gfx2.cfg found, this is a portable installation + Portable_Installation_Detected = 1; + } + else { char *config_parent_dir; #if defined(__WIN32__) || defined(WIN32) @@ -227,6 +233,7 @@ void Set_config_directory(const char * program_dir, char * config_dir) config_parent_dir = getenv("HOME"); } #endif + Portable_Installation_Detected = 0; if (config_parent_dir && config_parent_dir[0]!='\0') { @@ -254,6 +261,7 @@ void Set_config_directory(const char * program_dir, char * config_dir) { // Echec: on se rabat sur le repertoire de l'executable. strcpy(config_dir,program_dir); + Portable_Installation_Detected = 1; #if defined(__macosx__) strcat(config_dir, "../"); #endif