osx
This commit is contained in:
@@ -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>
|
||||
@@ -259,22 +259,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;
|
||||
}
|
||||
|
||||
@@ -290,6 +299,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";
|
||||
|
||||
@@ -488,6 +502,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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user