This commit is contained in:
2025-11-27 09:46:00 +01:00
7 changed files with 107 additions and 23 deletions

View File

@@ -4,7 +4,7 @@
#include <filesystem>
#include <vector>
#ifdef __linux
#if defined(__linux) || defined(TARGET_OS_OSX)
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
@@ -260,22 +260,31 @@ SIGNAL(YellowNotes, on_monitors_changed, monitorsChanged);
std::string YellowNotes::imageFile(const char *name)
{
#ifdef _WIN32
#if defined(_WIN32) || defined(TARGET_OS_OSX)
std::string ext = ".png";
#else
std::string ext = ".svg";
#endif
return appDir() + "/" + name + ext;
std::string file = name + ext;
std::string path1 = appDir() + "/images/" + file;
if (std::filesystem::is_regular_file(path1)) {
return path1;
} else {
std::string path2 = appDir() + "/../../" + file;
if (std::filesystem::is_regular_file(path2)) {
return path2;
} else {
std::cerr << "No such image file: " << path2 << std::endl;
throw std::string("No such image file: " + file);
}
}
}
std::string YellowNotes::appDir()
{
#ifdef __linux
std::string base = "/home/hans/src/yellownotes";
#endif
#ifdef _WIN32
std::string base = "c:/devel/yellownotes";
#endif
InfoOverMe info;
std::string base = info.containingFolder();
return base;
}
@@ -291,6 +300,11 @@ std::string YellowNotes::notesDir()
snprintf(homedir, 10240, "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
#endif
#ifdef TARGET_OS_OSX
struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir;
#endif
std::string home_dir = homedir;
std::string notes_dir = home_dir + "/yellownotes";
@@ -489,6 +503,11 @@ int YellowNotes::iconSize()
return _font_size * 1.5;
}
bool YellowNotes::popupTrayMenuBtn(void *sender, GdkEventButton *evt)
{
popupTrayMenu(sender);
return true;
}
void YellowNotes::popupTrayMenu(void *sender)
{