Compare commits
11 Commits
4c10bb6b9f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b52d247977 | |||
| 1a33db1bf5 | |||
| 4c6f260bb9 | |||
| b91d093b1f | |||
| c968774e62 | |||
| 441e903c67 | |||
| 28f0fdb520 | |||
| 5023b63a7e | |||
| bf62ec97dc | |||
| f2e3242d82 | |||
| e82038e7cf |
@@ -5,14 +5,23 @@ project(yellownotes LANGUAGES CXX C)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_executable(yellownotes main.cpp
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
enable_language("RC")
|
||||
set (WIN32_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/app.rc)
|
||||
endif()
|
||||
|
||||
add_executable(yellownotes WIN32 main.cpp
|
||||
gtk-imports.h
|
||||
gtkloader.h gtkloader.cpp
|
||||
gtk-imports.c
|
||||
yellownotes.h yellownotes.cpp
|
||||
tr.h tr.cpp
|
||||
|
||||
utils/whereami.c utils/whereami.h
|
||||
exe_path.h exe_path.cpp)
|
||||
info_over_me.h info_over_me.cpp
|
||||
${WIN32_RESOURCES}
|
||||
)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS yellownotes
|
||||
|
||||
8
Makefile
8
Makefile
@@ -5,12 +5,14 @@ all: release
|
||||
|
||||
install: release
|
||||
mkdir -p /opt/yellownotes
|
||||
cp build/release/yellownotes *.svg *.png /opt/yellownotes
|
||||
cp build/release/yellownotes /opt/yellownotes
|
||||
mkdir -p /opt/yellownotes/images
|
||||
cp *.svg *.png /opt/yellownotes/images
|
||||
|
||||
release: build/release/yellownotes
|
||||
|
||||
build/release/yellownotes: exe_path.cpp gtk-imports.c gtkloader.cpp main.cpp tr.cpp yellownotes.cpp utils/whereami.c \
|
||||
exe_path.h gtk-imports.h gtkloader.h tr.h yellownotes.h utils/whereami.h
|
||||
build/release/yellownotes: info_over_me.cpp gtk-imports.c gtkloader.cpp main.cpp tr.cpp yellownotes.cpp utils/whereami.c \
|
||||
info_over_me.h gtk-imports.h gtkloader.h tr.h yellownotes.h utils/whereami.h
|
||||
cmake -S . -B build/release
|
||||
cmake --build build/release --target all
|
||||
|
||||
|
||||
20
exe_path.cpp
20
exe_path.cpp
@@ -1,20 +0,0 @@
|
||||
#include "exe_path.h"
|
||||
|
||||
#include "utils/whereami.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
std::string WhereAmI::containing_folder()
|
||||
{
|
||||
int len = wai_getExecutablePath(NULL, 0, NULL);
|
||||
|
||||
char *path = static_cast<char *>(malloc(len + 1));
|
||||
wai_getExecutablePath(path, len, NULL);
|
||||
path[len] = '\0';
|
||||
|
||||
std::string p(path);
|
||||
std::cout << p << std::endl;
|
||||
return p;
|
||||
}
|
||||
|
||||
WhereAmI::WhereAmI() {}
|
||||
14
exe_path.h
14
exe_path.h
@@ -1,14 +0,0 @@
|
||||
#ifndef EXE_PATH_H
|
||||
#define EXE_PATH_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class WhereAmI
|
||||
{
|
||||
public:
|
||||
std::string containing_folder();
|
||||
public:
|
||||
WhereAmI();
|
||||
};
|
||||
|
||||
#endif // EXE_PATH_H
|
||||
@@ -1,4 +1,8 @@
|
||||
#ifdef TARGET_OS_OSX
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#define GTK_DECLARE_FUNCS
|
||||
#include "gtk-imports.h"
|
||||
|
||||
@@ -74,6 +74,9 @@ typedef void GtkGrid;
|
||||
typedef void GtkColorButton;
|
||||
typedef void GtkColorChooser;
|
||||
typedef void GtkSpinButton;
|
||||
typedef void GdkMonitor;
|
||||
typedef void GdkScreen;
|
||||
typedef void GtkAboutDialog;
|
||||
|
||||
typedef int gboolean;
|
||||
typedef int gint;
|
||||
@@ -142,14 +145,14 @@ typedef enum {
|
||||
PANGO_ELLIPSIZE_END = 3
|
||||
} PangoEllipsizeMode;
|
||||
|
||||
struct GdkRectangle {
|
||||
typedef struct _GdkRectangle {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
} GdkRectangle;
|
||||
|
||||
typedef struct GdkRectangle GtkAllocation;
|
||||
typedef struct _GdkRectangle GtkAllocation;
|
||||
|
||||
#define G_VALUE_INIT { 0, { { 0 } } }
|
||||
|
||||
@@ -570,6 +573,42 @@ typedef struct _GdkEventVisibility
|
||||
GdkVisibilityState state;
|
||||
} GdkEventVisibility;
|
||||
|
||||
typedef struct _GList {
|
||||
gpointer data;
|
||||
gpointer next;
|
||||
gpointer prev;
|
||||
} GList;
|
||||
|
||||
typedef void GListModel;
|
||||
|
||||
typedef enum {
|
||||
GTK_LICENSE_UNKNOWN,
|
||||
GTK_LICENSE_CUSTOM,
|
||||
|
||||
GTK_LICENSE_GPL_2_0,
|
||||
GTK_LICENSE_GPL_3_0,
|
||||
|
||||
GTK_LICENSE_LGPL_2_1,
|
||||
GTK_LICENSE_LGPL_3_0,
|
||||
|
||||
GTK_LICENSE_BSD,
|
||||
GTK_LICENSE_MIT_X11,
|
||||
|
||||
GTK_LICENSE_ARTISTIC,
|
||||
|
||||
GTK_LICENSE_GPL_2_0_ONLY,
|
||||
GTK_LICENSE_GPL_3_0_ONLY,
|
||||
GTK_LICENSE_LGPL_2_1_ONLY,
|
||||
GTK_LICENSE_LGPL_3_0_ONLY,
|
||||
|
||||
GTK_LICENSE_AGPL_3_0,
|
||||
GTK_LICENSE_AGPL_3_0_ONLY,
|
||||
|
||||
GTK_LICENSE_BSD_3,
|
||||
GTK_LICENSE_APACHE_2_0,
|
||||
GTK_LICENSE_MPL_2_0
|
||||
} GtkLicense;
|
||||
|
||||
#define G_TYPE_FUNDAMENTAL_SHIFT (2)
|
||||
#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
|
||||
#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6)
|
||||
@@ -635,6 +674,7 @@ DECL(const gchar*, gtk_window_get_title, (GtkWindow* window))
|
||||
DECL(void, gtk_widget_destroy, (GtkWidget* widget))
|
||||
DECL(void, gtk_container_add, (GtkContainer* container, GtkWidget* widget))
|
||||
DECL(void, gtk_container_remove, (GtkContainer* container, GtkWidget* widget))
|
||||
DECL(void, gtk_container_set_border_width, (GtkContainer *container, guint width));
|
||||
|
||||
DECL(gboolean, gtk_widget_is_visible, (GtkWidget* widget))
|
||||
DECL(GtkWidget*, gtk_label_new, (const char* str))
|
||||
@@ -693,6 +733,25 @@ DECL(GtkWidget*, gtk_dialog_get_content_area, (GtkDialog* dialog ))
|
||||
DECL(gboolean, gtk_combo_box_set_active_id, ( GtkComboBox* combo_box, const gchar* active_id ))
|
||||
DECL(const gchar*, gtk_combo_box_get_active_id, (GtkComboBox* combo_box))
|
||||
|
||||
// Gdk Monitor/Screen
|
||||
|
||||
DECL(GdkDisplay*, gdk_display_get_default, (void))
|
||||
DECL(int, gdk_display_get_n_monitors, (GdkDisplay* display))
|
||||
DECL(GdkMonitor*, gdk_display_get_monitor, (GdkDisplay* display, int monitor_num))
|
||||
DECL(void, gdk_monitor_get_geometry, (GdkMonitor* monitor, GdkRectangle* geometry))
|
||||
DECL(GList*, gdk_screen_get_window_stack, (GdkScreen* screen))
|
||||
DECL(GdkScreen*, gdk_screen_get_default, (void))
|
||||
|
||||
// About
|
||||
|
||||
DECL(GtkWidget*, gtk_about_dialog_new, (void))
|
||||
DECL(void, gtk_about_dialog_set_authors, (GtkAboutDialog* about,const gchar** authors))
|
||||
DECL(void, gtk_about_dialog_set_copyright, (GtkAboutDialog* about, const gchar* copyright ))
|
||||
DECL(void, gtk_about_dialog_set_license_type, (GtkAboutDialog* about, GtkLicense license_type))
|
||||
DECL(void, gtk_about_dialog_set_logo, (GtkAboutDialog* about, GdkPixbuf* logo ))
|
||||
DECL(void, gtk_about_dialog_set_program_name, (GtkAboutDialog* about,const gchar* name))
|
||||
DECL(void, gtk_about_dialog_set_version, (GtkAboutDialog* about, const gchar* version))
|
||||
|
||||
// GObject / GValue
|
||||
DECL(void, g_object_unref, (GObject* object))
|
||||
DECL(void, g_object_ref, (GObject* object))
|
||||
|
||||
@@ -11,22 +11,31 @@ extern "C" {
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux
|
||||
#if defined(__linux) || defined(TARGET_OS_OSX)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include "info_over_me.h"
|
||||
|
||||
void GtkLoader::loadLibraryWin64(const char *lib, void **handle)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#define DIR "C:\\devel\\yellownotes\\gtk3\\bin"
|
||||
InfoOverMe info;
|
||||
|
||||
//#define DIR "C:\\devel\\yellownotes\\gtk3\\bin"
|
||||
HMODULE dll = nullptr;
|
||||
std::string dir = DIR;
|
||||
std::string my_dir = info.containingFolder();
|
||||
std::string dir = my_dir + "\\gtk3";
|
||||
|
||||
std::cout << "my folder = " << dir << std::endl;
|
||||
|
||||
*handle = nullptr;
|
||||
|
||||
auto mklibname = [](const char *libname) {
|
||||
auto mklibname = [dir](const char *libname) {
|
||||
std::string dll;
|
||||
dll = std::string(DIR) + "\\" + libname + ".dll";
|
||||
dll = std::string(libname) + ".dll";
|
||||
std::cout << "library: " << dll << std::endl;
|
||||
return dll;
|
||||
};
|
||||
|
||||
@@ -60,6 +69,33 @@ void GtkLoader::loadLibraryLinux(const char *lib, void **handle)
|
||||
#endif
|
||||
}
|
||||
|
||||
void GtkLoader::loadLibraryOSX(const char *lib, void **handle)
|
||||
{
|
||||
#ifdef TARGET_OS_OSX
|
||||
std::string full_lib_path = std::string("/opt/homebrew/lib/") + lib;
|
||||
*handle = ::dlopen(full_lib_path.c_str(), RTLD_LAZY);
|
||||
if (*handle == NULL) {
|
||||
throw std::string("Cannot load library '") + lib + "'";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GtkLoader::loadFunctionOSX(const char *func, void **func_ptr)
|
||||
{
|
||||
#ifdef TARGET_OS_OSX
|
||||
*func_ptr = nullptr;
|
||||
std::list<void *>::const_iterator it = library_handles.begin();
|
||||
while(*func_ptr == nullptr && it != library_handles.end()) {
|
||||
void *handle = *it;
|
||||
*func_ptr = dlsym(handle, func);
|
||||
it++;
|
||||
}
|
||||
if (*func_ptr == nullptr) {
|
||||
throw std::string("Cannot load function '") + func;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GtkLoader::loadFunctionWin64(const char *func, void **func_ptr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@@ -132,6 +168,23 @@ void GtkLoader::dlopen()
|
||||
loadLibraryLinux(libs[i], &lib);
|
||||
if (lib) { library_handles.push_back(lib); }
|
||||
}
|
||||
#endif
|
||||
#ifdef TARGET_OS_OSX
|
||||
const char *libs[] = {
|
||||
"libgtk-3.0.dylib",
|
||||
"libgobject-2.0.dylib",
|
||||
"libgio-2.0.dylib",
|
||||
"libglib-2.0.dylib",
|
||||
"libgdk-3.dylib",
|
||||
"libgdk_pixbuf-2.0.dylib",
|
||||
NULL
|
||||
};
|
||||
int i;
|
||||
for(i = 0; libs[i] != NULL; i++) {
|
||||
void *lib;
|
||||
loadLibraryOSX(libs[i], &lib);
|
||||
if (lib) { library_handles.push_back(lib); }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -144,6 +197,9 @@ void GtkLoader::loadFunction(const char *func, void **func_ptr)
|
||||
#ifdef __linux
|
||||
loadFunctionLinux(func, func_ptr);
|
||||
#endif
|
||||
#ifdef TARGET_OS_OSX
|
||||
loadFunctionOSX(func, func_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void loader(const char *func, void **func_ptr, void *user_data)
|
||||
|
||||
@@ -13,6 +13,8 @@ private:
|
||||
void loadFunctionWin64(const char *func, void **func_ptr);
|
||||
void loadLibraryLinux(const char *lib, void **handle);
|
||||
void loadFunctionLinux(const char *func, void **func_ptr);
|
||||
void loadLibraryOSX(const char *lib, void **handle);
|
||||
void loadFunctionOSX(const char *func, void **func_ptr);
|
||||
|
||||
public:
|
||||
void dlopen();
|
||||
|
||||
119
info_over_me.cpp
Normal file
119
info_over_me.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include "info_over_me.h"
|
||||
|
||||
#include "utils/whereami.h"
|
||||
|
||||
#include <iostream>
|
||||
#if defined(__linux) || defined(TARGET_OS_OSX)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "gtk-imports.h"
|
||||
}
|
||||
|
||||
#include <list>
|
||||
#include <filesystem>
|
||||
|
||||
std::string InfoOverMe::containingFolder()
|
||||
{
|
||||
int len = wai_getExecutablePath(NULL, 0, NULL);
|
||||
|
||||
char *path = static_cast<char *>(malloc(len + 1));
|
||||
wai_getExecutablePath(path, len, NULL);
|
||||
path[len] = '\0';
|
||||
|
||||
std::filesystem::path p(path);
|
||||
if (std::filesystem::is_regular_file(p)) {
|
||||
std::filesystem::path pp = p.parent_path();
|
||||
return pp.string();
|
||||
} else {
|
||||
return p.string();
|
||||
}
|
||||
}
|
||||
|
||||
std::string InfoOverMe::myHostname()
|
||||
{
|
||||
char buf[10240];
|
||||
#if defined(__linux) || defined(TARGET_OS_OSX)
|
||||
int r = gethostname(buf, 10240);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
DWORD size = 10240;
|
||||
bool r = GetComputerNameA(buf, &size);
|
||||
buf[size] = '\0';
|
||||
if (!r) { sprintf(buf, "unknown"); }
|
||||
#endif
|
||||
std::string name(buf);
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string InfoOverMe::myOsHostname()
|
||||
{
|
||||
std::string os;
|
||||
#ifdef __linux
|
||||
os = "linux";
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
os = "windows";
|
||||
#else
|
||||
#ifdef TARGET_OS_OSX
|
||||
os = "osx";
|
||||
#else
|
||||
os = "unknown";
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
return os + "_" + myHostname();
|
||||
}
|
||||
|
||||
std::string InfoOverMe::myId()
|
||||
{
|
||||
|
||||
std::list<GdkRectangle> l;
|
||||
GdkDisplay *d = gdk_display_get_default();
|
||||
int n = gdk_display_get_n_monitors(d);
|
||||
int i;
|
||||
for(i = 0; i < n; i++) {
|
||||
GdkMonitor *m = gdk_display_get_monitor(d, i);
|
||||
GdkRectangle r;
|
||||
gdk_monitor_get_geometry(m, &r);
|
||||
l.push_back(r);
|
||||
//std::cout << r.width << ", " << r.height << ", x = " << r.x << ", y = " << r.y << std::endl;
|
||||
}
|
||||
|
||||
auto compare = [](const GdkRectangle &a, const GdkRectangle &b) {
|
||||
if (a.x < b.x) {
|
||||
return true;
|
||||
} else if (a.x > b. x) {
|
||||
return false;
|
||||
} else if (a.y < b.y) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
l.sort(compare);
|
||||
std::list<GdkRectangle>::iterator it;
|
||||
std::string monitor_id;
|
||||
std::string sep = "";
|
||||
for(it = l.begin(); it != l.end(); it++) {
|
||||
char buf[200];
|
||||
const GdkRectangle &r = *it;
|
||||
sprintf(buf, "%d-%d-%d-%d", r.x, r.y, r.width, r.height);
|
||||
std::string geom(buf);
|
||||
monitor_id += sep;
|
||||
monitor_id += geom;
|
||||
sep = "-";
|
||||
}
|
||||
|
||||
monitor_id = myOsHostname() + "/" + monitor_id;
|
||||
|
||||
return monitor_id;
|
||||
}
|
||||
|
||||
InfoOverMe::InfoOverMe() {}
|
||||
20
info_over_me.h
Normal file
20
info_over_me.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef INFO_OVER_ME_H
|
||||
#define INFO_OVER_ME_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class InfoOverMe
|
||||
{
|
||||
public:
|
||||
std::string containingFolder();
|
||||
|
||||
public:
|
||||
std::string myHostname();
|
||||
std::string myOsHostname();
|
||||
std::string myId();
|
||||
|
||||
public:
|
||||
InfoOverMe();
|
||||
};
|
||||
|
||||
#endif // INFO_OVER_ME_H
|
||||
33
main.cpp
33
main.cpp
@@ -6,10 +6,13 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "yellownotes.h"
|
||||
#include "exe_path.h"
|
||||
|
||||
SIGNAL(YellowNotes, on_tray_activate, popupTrayMenu)
|
||||
#include "info_over_me.h"
|
||||
|
||||
#ifndef TARGET_OS_OSX
|
||||
SIGNAL(YellowNotes, on_tray_activate, popupTrayMenu);
|
||||
#else
|
||||
BSIGNAL2(YellowNotes, on_tray_btn, popupTrayMenuBtn, GdkEventButton);
|
||||
#endif
|
||||
static void activate (GtkApplication* app, gpointer user_data)
|
||||
{
|
||||
GtkWidget *window;
|
||||
@@ -17,22 +20,40 @@ static void activate (GtkApplication* app, gpointer user_data)
|
||||
|
||||
std::string img_file = notes->imageFile("yellownotes");
|
||||
GtkStatusIcon *tray = gtk_status_icon_new_from_file(img_file.c_str());
|
||||
#ifdef TARGET_OS_OSX
|
||||
g_signal_connect(tray, "button_press_event", on_tray_btn, notes);
|
||||
#else
|
||||
g_signal_connect(tray, "activate", on_tray_activate, notes);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int runMain(int argc, char **argv);
|
||||
|
||||
#ifdef _WIN32
|
||||
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
return runMain(__argc, __argv);
|
||||
}
|
||||
#else
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return runMain(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
int runMain(int argc, char **argv)
|
||||
{
|
||||
|
||||
GtkLoader l;
|
||||
WhereAmI w;
|
||||
InfoOverMe w;
|
||||
|
||||
srand(time(NULL)); // seed with current time
|
||||
|
||||
std::string my_path = w.containing_folder();
|
||||
|
||||
try {
|
||||
l.loadGtk();
|
||||
} catch(std::string msg) {
|
||||
std::cerr << msg << std::endl;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
GtkApplication *app;
|
||||
|
||||
5
tr.cpp
5
tr.cpp
@@ -95,6 +95,11 @@ tr::tr()
|
||||
nl("Grey", "Grijs");
|
||||
nl("Font size:", "Lettertype Grootte:");
|
||||
nl("Actual Font Size in Note", "Werkelijke lettertype grootte in de notitie");
|
||||
nl("Reorder Notes", "Notities opnieuw ordenen");
|
||||
nl("About", "Over...");
|
||||
nl("(c) 2025", "(c) 2025");
|
||||
nl("Version %s, file format version: %d", "Versie %s, bestandsformaat versie: %d");
|
||||
nl("Yellow Notes", "Geeltjes");
|
||||
|
||||
_lang = "en";
|
||||
}
|
||||
|
||||
388
yellownotes.cpp
388
yellownotes.cpp
@@ -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>
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <shobjidl.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
@@ -21,7 +22,9 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "tr.h"
|
||||
|
||||
#include "info_over_me.h"
|
||||
#include <functional>
|
||||
#include <sstream>
|
||||
#include <math.h>
|
||||
|
||||
static void trim(std::string &s) {
|
||||
@@ -34,6 +37,25 @@ static void trim(std::string &s) {
|
||||
s = s.substr(start, end - start + 1);
|
||||
}
|
||||
|
||||
class StoredCoords
|
||||
{
|
||||
public:
|
||||
bool hidden;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
std::string os_host;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
NONE,
|
||||
BOTTOM_RIGHT,
|
||||
BOTTOM,
|
||||
RIGHT
|
||||
} YellowNoteResize_t;
|
||||
|
||||
|
||||
|
||||
class YellowNote
|
||||
{
|
||||
@@ -65,6 +87,8 @@ private:
|
||||
std::string _note;
|
||||
std::string _title;
|
||||
|
||||
std::list<StoredCoords> _stored_coords;
|
||||
|
||||
bool _hidden;
|
||||
bool _hidden_loaded;
|
||||
|
||||
@@ -94,6 +118,8 @@ private:
|
||||
bool _resize_right;
|
||||
bool _resize_bottom;
|
||||
bool _resize_edge;
|
||||
YellowNoteResize_t _resize_type;
|
||||
|
||||
int _x_orig;
|
||||
int _y_orig;
|
||||
|
||||
@@ -143,6 +169,7 @@ public:
|
||||
bool textSaveTimeout();
|
||||
bool windowPresented(void *sender, GdkEventVisibility *evt);
|
||||
void showNote(GtkWidget *sender);
|
||||
void moveTo(int x, int y);
|
||||
|
||||
public:
|
||||
std::string title();
|
||||
@@ -232,30 +259,42 @@ SIGNAL(YellowNotes, on_to_back, notesToDesktop);
|
||||
SIGNAL(YellowNotes, on_reload, reloadNotes);
|
||||
SIGNAL(YellowNotes, on_setup, setup);
|
||||
SIGNAL(YellowNotes, on_quit, quit)
|
||||
SIGNAL(YellowNotes, on_reorder, reOrder);
|
||||
SIGNAL(YellowNotes, on_about, about);
|
||||
SIGNAL(YellowNotes, on_hide_toplevel, topLevelHidden)
|
||||
SIGNAL(YellowNotes, on_setup_ok, setupClose);
|
||||
SIGNAL(YellowNotes, on_setup_close, setupCancel);
|
||||
BSIGNAL2(YellowNotes, on_setup_del, setupDel, void);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -271,6 +310,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";
|
||||
|
||||
@@ -326,6 +370,11 @@ void YellowNotes::updateWidgetCss(GtkWidget *w, ColorType_t col)
|
||||
set_style(w);
|
||||
}
|
||||
|
||||
GtkWidget *YellowNotes::getWindow()
|
||||
{
|
||||
return topLevel();
|
||||
}
|
||||
|
||||
std::string YellowNotes::getFgColor(ColorType_t type)
|
||||
{
|
||||
char buf[100];
|
||||
@@ -464,6 +513,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)
|
||||
{
|
||||
@@ -496,6 +550,8 @@ void YellowNotes::popupTrayMenu(void *sender)
|
||||
GtkWidget *sep1 = gtk_separator_menu_item_new();
|
||||
|
||||
GtkMenuItem *setup = gtk_menu_item_new_with_label(_("Setup"));
|
||||
GtkMenuItem *reorder = gtk_menu_item_new_with_label(_("Reorder Notes"));
|
||||
GtkMenuItem *about = gtk_menu_item_new_with_label(_("About"));
|
||||
GtkMenuItem *quit = gtk_menu_item_new_with_label(_("Quit"));
|
||||
|
||||
gtk_menu_shell_append(tray_menu, new_yellow);
|
||||
@@ -512,6 +568,8 @@ void YellowNotes::popupTrayMenu(void *sender)
|
||||
|
||||
gtk_menu_shell_append(tray_menu, sep1);
|
||||
gtk_menu_shell_append(tray_menu, setup);
|
||||
gtk_menu_shell_append(tray_menu, reorder);
|
||||
gtk_menu_shell_append(tray_menu, about);
|
||||
gtk_menu_shell_append(tray_menu, quit);
|
||||
gtk_widget_show_all(tray_menu);
|
||||
|
||||
@@ -520,6 +578,8 @@ void YellowNotes::popupTrayMenu(void *sender)
|
||||
g_signal_connect(notes_to_back, "activate", on_to_back, this);
|
||||
g_signal_connect(reload_notes, "activate", on_reload, this);
|
||||
g_signal_connect(setup, "activate", on_setup, this);
|
||||
g_signal_connect(reorder, "activate", on_reorder, this);
|
||||
g_signal_connect(about, "activate", on_about, this);
|
||||
g_signal_connect(quit, "activate", on_quit, this);
|
||||
w_it = hidden.begin();
|
||||
it = h_notes.begin();
|
||||
@@ -811,6 +871,53 @@ void YellowNotes::setup(void *sender)
|
||||
gtk_widget_show_all(dlg);
|
||||
}
|
||||
|
||||
void YellowNotes::about(void *sender)
|
||||
{
|
||||
const char *authors[] = { "Hans Dijkema", nullptr };
|
||||
|
||||
GtkWidget *dlg = gtk_about_dialog_new();
|
||||
gtk_about_dialog_set_authors(dlg, authors);
|
||||
gtk_about_dialog_set_copyright(dlg, _("(c) 2025"));
|
||||
gtk_about_dialog_set_license_type(dlg, GTK_LICENSE_GPL_2_0);
|
||||
|
||||
char buf[200];
|
||||
sprintf(buf, _("Version %s, file format version: %d"),
|
||||
YELLOWNOTE_VERSION,
|
||||
YELLOWNOTE_FILE_VERSION
|
||||
);
|
||||
gtk_about_dialog_set_version(dlg, buf);
|
||||
|
||||
int width = 100;
|
||||
int height = 100;
|
||||
GdkPixbuf *logo_pixbuf = gdk_pixbuf_new_from_file_at_size(imageFile("yellownotes").c_str(),
|
||||
width, height, nullptr
|
||||
);
|
||||
gtk_about_dialog_set_logo(dlg, logo_pixbuf);
|
||||
g_object_unref(logo_pixbuf);
|
||||
|
||||
gtk_about_dialog_set_program_name(dlg, _("Yellow Notes"));
|
||||
|
||||
gtk_dialog_run(dlg);
|
||||
|
||||
gtk_widget_destroy(dlg);
|
||||
}
|
||||
|
||||
void YellowNotes::reOrder(void *sender)
|
||||
{
|
||||
int x = 50;
|
||||
int y = 50;
|
||||
|
||||
std::list<YellowNote *>::iterator it;
|
||||
for(it = _notes.begin(); it != _notes.end(); it++, x += 25, y += 25) {
|
||||
(*it)->moveTo(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void YellowNotes::monitorsChanged(void *sender)
|
||||
{
|
||||
this->reloadNotes(sender);
|
||||
}
|
||||
|
||||
void YellowNotes::reloadNotes(void *sender)
|
||||
{
|
||||
std::list<YellowNote *>::const_iterator it = _notes.begin();
|
||||
@@ -911,6 +1018,87 @@ void YellowNotes::topLevelHidden(GtkWidget *sender)
|
||||
g_timeout_add(500, show_notes_timed, this);
|
||||
}
|
||||
|
||||
void YellowNotes::checkMonitors()
|
||||
{
|
||||
auto compare = [](const Geom_t &a, const Geom_t &b) {
|
||||
if (a.x < b.x) {
|
||||
return true;
|
||||
} else if (a.x > b. x) {
|
||||
return false;
|
||||
} else if (a.y < b.y) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
GdkDisplay *d = gdk_display_get_default();
|
||||
int n = gdk_display_get_n_monitors(d);
|
||||
|
||||
if (_monitors.empty()) {
|
||||
int i;
|
||||
for(i = 0; i < n; i++) {
|
||||
GdkMonitor *m = gdk_display_get_monitor(d, i);
|
||||
GdkRectangle r;
|
||||
gdk_monitor_get_geometry(m, &r);
|
||||
Geom_t g;
|
||||
g.x = r.x;
|
||||
g.y = r.y;
|
||||
g.width = r.width;
|
||||
g.height = r.height;
|
||||
_monitors.push_back(g);
|
||||
}
|
||||
_monitors.sort(compare);
|
||||
} else {
|
||||
if (n != _monitors.size()) {
|
||||
_monitors.clear();
|
||||
checkMonitors();
|
||||
monitorsChanged(nullptr);
|
||||
} else {
|
||||
std::list<Geom_t> l;
|
||||
int i;
|
||||
for(i = 0; i < n; i++) {
|
||||
GdkMonitor *m = gdk_display_get_monitor(d, i);
|
||||
GdkRectangle r;
|
||||
gdk_monitor_get_geometry(m, &r);
|
||||
Geom_t g;
|
||||
g.x = r.x;
|
||||
g.y = r.y;
|
||||
g.width = r.width;
|
||||
g.height = r.height;
|
||||
l.push_back(g);
|
||||
}
|
||||
l.sort(compare);
|
||||
std::list<Geom_t>::iterator m_it = _monitors.begin();
|
||||
std::list<Geom_t>::iterator l_it = l.begin();
|
||||
while(l_it != l.end()) {
|
||||
Geom_t g_l = *l_it;
|
||||
Geom_t g_m = *m_it;
|
||||
if (g_l.x != g_m.x || g_l.y != g_m.y || g_l.width != g_m.width || g_l.height != g_m.height) {
|
||||
_monitors.clear();
|
||||
checkMonitors();
|
||||
monitorsChanged(nullptr);
|
||||
}
|
||||
l_it++;
|
||||
m_it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static YellowNotes *_the_notes = nullptr;
|
||||
|
||||
gboolean monitor_monitors(void *data)
|
||||
{
|
||||
YellowNotes *n = reinterpret_cast<YellowNotes *>(data);
|
||||
if (_the_notes == nullptr) {
|
||||
return false;
|
||||
} else {
|
||||
n->checkMonitors();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWindow *YellowNotes::topLevel()
|
||||
{
|
||||
if (_toplevel == nullptr) {
|
||||
@@ -927,11 +1115,14 @@ YellowNotes::YellowNotes(void *app)
|
||||
_tray_menu = nullptr;
|
||||
_font_size = 15;
|
||||
_toplevel = nullptr;
|
||||
_the_notes = this;
|
||||
g_timeout_add(1000, monitor_monitors, this); // Beware monitor_monitors checks _the_notes.
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
YellowNotes::~YellowNotes()
|
||||
{
|
||||
_the_notes = nullptr;
|
||||
if (_tray_menu) { gtk_widget_destroy(reinterpret_cast<GtkMenu *>(_tray_menu)); }
|
||||
clearNotes();
|
||||
gtk_widget_destroy(_toplevel);
|
||||
@@ -961,6 +1152,7 @@ YellowNote::YellowNote(YellowNotes *notes, const std::string &filename)
|
||||
_resize_bottom = false;
|
||||
_resize_edge = false;
|
||||
_resize_right = false;
|
||||
_resize_type = NONE;
|
||||
|
||||
_color = ColorType_t::YELLOW;
|
||||
_color_changed = false;
|
||||
@@ -1070,6 +1262,8 @@ YellowNote::YellowNote(YellowNotes *notes, const std::string &filename)
|
||||
gtk_container_add(_evt_box, _frame);
|
||||
gtk_container_add(_note_widget, _evt_box);
|
||||
|
||||
gtk_container_set_border_width(_evt_box, 0);
|
||||
|
||||
gtk_widget_show_all(_note_widget);
|
||||
|
||||
/*while (!gtk_widget_is_visible(_note_widget)) {
|
||||
@@ -1191,6 +1385,7 @@ void YellowNote::deleteMe()
|
||||
void YellowNote::updateTitle()
|
||||
{
|
||||
gtk_label_set_label(_title_label, _title.c_str());
|
||||
gtk_window_set_title(_note_widget, _title.c_str());
|
||||
}
|
||||
|
||||
void YellowNote::updateTitleOnly()
|
||||
@@ -1228,6 +1423,13 @@ void YellowNote::showNote(GtkWidget *sender)
|
||||
show();
|
||||
}
|
||||
|
||||
void YellowNote::moveTo(int x, int y)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
void YellowNote::setLoaded()
|
||||
{
|
||||
_pos_loaded = true;
|
||||
@@ -1299,12 +1501,20 @@ void YellowNote::toFront()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void YellowNote::toDesktop()
|
||||
{
|
||||
#ifdef __linux
|
||||
gtk_window_set_type_hint(_note_widget, GdkWindowTypeHint::GDK_WINDOW_TYPE_HINT_DESKTOP);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
GdkWindow *notes_win = gtk_widget_get_window(_notes->getWindow());
|
||||
HWND nw = gdk_win32_window_get_handle(notes_win);
|
||||
SetWindowPos(nw, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
|
||||
GdkWindow *win = gtk_widget_get_window(_note_widget);
|
||||
HWND w = gdk_win32_window_get_handle(win);
|
||||
SetWindowPos(w, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void YellowNote::fromDesktop()
|
||||
@@ -1548,6 +1758,7 @@ bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
|
||||
|
||||
int threshold = 8;
|
||||
|
||||
/*
|
||||
if (AROUND(y, frame_bottom) && AROUND(x, frame_right)) {
|
||||
_resize_edge = true;
|
||||
} else if (AROUND(y, frame_bottom)) {
|
||||
@@ -1555,6 +1766,14 @@ bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
|
||||
} else if (AROUND(x, frame_right)) {
|
||||
_resize_right = true;
|
||||
}
|
||||
*/
|
||||
if (_resize_type == BOTTOM_RIGHT) {
|
||||
_resize_edge = true;
|
||||
} else if (_resize_type == BOTTOM) {
|
||||
_resize_bottom = true;
|
||||
} else if (_resize_type == RIGHT) {
|
||||
_resize_right = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1635,18 +1854,23 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
||||
GdkWindow *window = gtk_widget_get_window(_frame);
|
||||
GdkCursor *c;
|
||||
|
||||
int threshold = 8;
|
||||
int threshold = 16;
|
||||
|
||||
if (y >= header_top && y <= header_bottom) {
|
||||
c = gdk_cursor_new(GDK_LEFT_PTR);
|
||||
_resize_type = NONE;
|
||||
} else if (AROUND(x, frame_right) && AROUND(y, frame_bottom)) {
|
||||
c = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER);
|
||||
_resize_type = BOTTOM_RIGHT;
|
||||
} else if (AROUND(x, frame_right)) {
|
||||
c = gdk_cursor_new(GDK_RIGHT_SIDE);
|
||||
_resize_type = RIGHT;
|
||||
} else if (AROUND(y, frame_bottom)) {
|
||||
c = gdk_cursor_new(GDK_BOTTOM_SIDE);
|
||||
_resize_type = BOTTOM;
|
||||
} else {
|
||||
c = nullptr;
|
||||
_resize_type = NONE;
|
||||
}
|
||||
|
||||
gdk_window_set_cursor(window, c);
|
||||
@@ -1655,18 +1879,21 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
||||
return false;
|
||||
}
|
||||
|
||||
#define YELLOWNOTE_VERSION 2
|
||||
|
||||
void YellowNote::load()
|
||||
{
|
||||
auto readInt = [](FILE *f, int default_value) {
|
||||
char buffer[100];
|
||||
fgets(buffer, 100, f);
|
||||
int v = atoi(buffer);
|
||||
if (default_value >= 0 && v == 0) {
|
||||
std::string s = buffer;
|
||||
trim(s);
|
||||
std::string::iterator sit = s.begin();
|
||||
while(sit != s.end() && (*sit >= '0' && *sit <= '9')) { sit++; }
|
||||
if (sit != s.end()) {
|
||||
return default_value;
|
||||
}
|
||||
} else {
|
||||
int v = atoi(buffer);
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
_in_transaction = true;
|
||||
@@ -1678,6 +1905,68 @@ void YellowNote::load()
|
||||
std::string title;
|
||||
bool title_only;
|
||||
|
||||
InfoOverMe info;
|
||||
std::string my_name = info.myId();
|
||||
|
||||
auto readKind = [my_name, this](std::string line, std::function<void (const std::string &os_host, int val)> f) {
|
||||
// Split line in parts.
|
||||
std::istringstream inp(line);
|
||||
std::string part;
|
||||
bool found = false;
|
||||
while(std::getline(inp, part, ',')) {
|
||||
std::string os_host;
|
||||
int val;
|
||||
int idx;
|
||||
idx = part.find(":");
|
||||
if (idx >= 0) {
|
||||
os_host = part.substr(0, idx);
|
||||
std::string s = part.substr(idx + 1);
|
||||
val = atoi(s.c_str());
|
||||
f(os_host,val);
|
||||
if (os_host == my_name) { found = true; }
|
||||
}
|
||||
}
|
||||
return found;
|
||||
};
|
||||
|
||||
auto getStoredCoord = [this](const std::string &os_host, bool &created) {
|
||||
std::list<StoredCoords>::iterator it = _stored_coords.begin();
|
||||
while(it != _stored_coords.end() && it->os_host != os_host) {
|
||||
it++;
|
||||
}
|
||||
if (it == _stored_coords.end()) {
|
||||
StoredCoords c;
|
||||
c.os_host = os_host;
|
||||
_stored_coords.push_back(c);
|
||||
StoredCoords *r = &(_stored_coords.back());
|
||||
created = true;
|
||||
return r;
|
||||
} else {
|
||||
StoredCoords *r = &(*it);
|
||||
created = false;
|
||||
return r;
|
||||
}
|
||||
};
|
||||
|
||||
auto setStoredCoordVar = [this, getStoredCoord, readKind](std::string line, std::function<void(StoredCoords *c, int v)> f) {
|
||||
auto setter = [f, this, getStoredCoord](const std::string &os_name, int val) {
|
||||
bool created;
|
||||
StoredCoords *r = getStoredCoord(os_name, created);
|
||||
f(r, val);
|
||||
};
|
||||
readKind(line, setter);
|
||||
};
|
||||
|
||||
auto readLine = [](FILE *f) {
|
||||
char buf[10240];
|
||||
fgets(buf, 10240, f);
|
||||
std::string l(buf);
|
||||
trim(l);
|
||||
return l;
|
||||
};
|
||||
|
||||
_stored_coords.clear();
|
||||
|
||||
size_t s = 0;
|
||||
if (std::filesystem::is_regular_file(p)) {
|
||||
s = std::filesystem::file_size(p);
|
||||
@@ -1687,11 +1976,36 @@ void YellowNote::load()
|
||||
if (f) {
|
||||
int version = readInt(f, -1);
|
||||
|
||||
if (version <= 2) {
|
||||
hidden = readInt(f, -1);
|
||||
x = readInt(f, 200);
|
||||
y = readInt(f, 200);
|
||||
width = readInt(f, 300);
|
||||
height = readInt(f, 200);
|
||||
} else {
|
||||
// fill in the dots.
|
||||
setStoredCoordVar(readLine(f), [](StoredCoords *c, int val) { c->hidden = val; });
|
||||
setStoredCoordVar(readLine(f), [](StoredCoords *c, int val) { c->x = val; });
|
||||
setStoredCoordVar(readLine(f), [](StoredCoords *c, int val) { c->y = val; });
|
||||
setStoredCoordVar(readLine(f), [](StoredCoords *c, int val) { c->width = val; });
|
||||
setStoredCoordVar(readLine(f), [](StoredCoords *c, int val) { c->height = val; });
|
||||
|
||||
bool created;
|
||||
StoredCoords *r = getStoredCoord(my_name, created);
|
||||
if (created) {
|
||||
r->hidden = false;
|
||||
r->x = 100;
|
||||
r->y = 100;
|
||||
r->width = 300;
|
||||
r->height = 200;
|
||||
}
|
||||
|
||||
hidden = r->hidden;
|
||||
x = r->x;
|
||||
y = r->y;
|
||||
width = r->width;
|
||||
height = r->height;
|
||||
}
|
||||
|
||||
int color;
|
||||
color = readInt(f, ColorType_t::YELLOW);
|
||||
@@ -1751,15 +2065,43 @@ void YellowNote::save()
|
||||
return;
|
||||
}
|
||||
|
||||
InfoOverMe info;
|
||||
std::string my_name = info.myId();
|
||||
|
||||
auto storeKind = [my_name, this](int val, std::function<int (const StoredCoords &)> f) {
|
||||
std::string line("");
|
||||
std::list<StoredCoords>::iterator it;
|
||||
std::string comma("");
|
||||
bool stored = false;
|
||||
for(it = _stored_coords.begin(); it != _stored_coords.end(); it++) {
|
||||
const StoredCoords &c = *it;
|
||||
int num = (my_name == c.os_host) ? val : f(c);
|
||||
if (my_name == c.os_host) { stored = true; }
|
||||
char buf[100];
|
||||
sprintf(buf, "%d", num);
|
||||
line += comma + c.os_host + ":" + buf;
|
||||
comma = ",";
|
||||
}
|
||||
if (!stored) {
|
||||
char buf[100];
|
||||
sprintf(buf, "%d", val);
|
||||
line += comma + my_name + ":" + buf;
|
||||
}
|
||||
return line;
|
||||
};
|
||||
|
||||
std::filesystem::path p(_filename);
|
||||
FILE *f = fopen(_filename.c_str(), "wt");
|
||||
if (f) {
|
||||
fprintf(f, "%d\n", YELLOWNOTE_VERSION);
|
||||
fprintf(f, "%d\n", _hidden);
|
||||
fprintf(f, "%d\n", _x);
|
||||
fprintf(f, "%d\n", _y);
|
||||
fprintf(f, "%d\n", _width);
|
||||
fprintf(f, "%d\n", _height);
|
||||
fprintf(f, "%d\n", YELLOWNOTE_FILE_VERSION);
|
||||
|
||||
|
||||
fprintf(f, "%s\n", storeKind(_hidden, [](const StoredCoords &c) { return c.hidden; }).c_str());
|
||||
fprintf(f, "%s\n", storeKind(_x, [](const StoredCoords &c) { return c.x; }).c_str());
|
||||
fprintf(f, "%s\n", storeKind(_y, [](const StoredCoords &c) { return c.y; }).c_str());
|
||||
fprintf(f, "%s\n", storeKind(_width, [](const StoredCoords &c) { return c.width; }).c_str());
|
||||
fprintf(f, "%s\n", storeKind(_height, [](const StoredCoords &c) { return c.height; }).c_str());
|
||||
|
||||
fprintf(f, "%d\n", _color);
|
||||
fprintf(f, "%d\n", _title_only);
|
||||
fprintf(f, "%s\n", _title.c_str());
|
||||
|
||||
@@ -12,6 +12,14 @@ extern "C" {
|
||||
class YellowNote;
|
||||
class SettingContainer;
|
||||
|
||||
#define YELLOWNOTE_MAJOR "1"
|
||||
#define YELLOWNOTE_MINOR "0"
|
||||
#define YELLOWNOTE_PATCH "3"
|
||||
#define YELLOWNOTE_VERSION YELLOWNOTE_MAJOR "." YELLOWNOTE_MINOR "." YELLOWNOTE_PATCH
|
||||
#define YELLOWNOTE_FILE_VERSION 3
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
DARK = 0,
|
||||
FIRST= DARK,
|
||||
@@ -25,6 +33,11 @@ typedef enum {
|
||||
LAST = GREY
|
||||
} ColorType_t;
|
||||
|
||||
class Geom_t {
|
||||
public:
|
||||
int x, y, width, height;
|
||||
};
|
||||
|
||||
class YellowNotes
|
||||
{
|
||||
private:
|
||||
@@ -34,12 +47,13 @@ private:
|
||||
void *_langs;
|
||||
|
||||
std::list<SettingContainer *> _settings_containers;
|
||||
|
||||
std::list<YellowNote *> _notes;
|
||||
int _font_size;
|
||||
GtkWindow *_toplevel;
|
||||
std::unordered_map<std::string, std::string> _cfg;
|
||||
|
||||
std::list<Geom_t> _monitors;
|
||||
|
||||
private:
|
||||
void loadConfig();
|
||||
void saveConfig();
|
||||
@@ -61,18 +75,24 @@ public:
|
||||
|
||||
public:
|
||||
void popupTrayMenu(void *sender);
|
||||
bool popupTrayMenuBtn(void *sender, GdkEventButton *evt);
|
||||
void newNote(void *sender);
|
||||
void showNotes(void *sender);
|
||||
void notesToDesktop(void *sender);
|
||||
void notesFromDesktop(void *sender);
|
||||
void reloadNotes(void *sender);
|
||||
void monitorsChanged(void *sender);
|
||||
void quit(void *sender);
|
||||
void topLevelHidden(GtkWidget *sender);
|
||||
void setup(void *sender);
|
||||
void reOrder(void *sender);
|
||||
void setupClose(GtkWidget *sender);
|
||||
void setupCancel(GtkWidget *sender);
|
||||
bool setupDel(GtkWidget *sender, void *evt);
|
||||
void remove(YellowNote *n);
|
||||
void checkMonitors();
|
||||
void about(void *sender);
|
||||
|
||||
|
||||
public:
|
||||
std::string currentLang();
|
||||
@@ -86,6 +106,7 @@ public:
|
||||
std::string fromRGBA(const GdkRGBA &rgba);
|
||||
void toRGBA(const std::string &col, GdkRGBA &rgba);
|
||||
void updateWidgetCss(GtkWidget *w, ColorType_t col);
|
||||
GtkWidget *getWindow();
|
||||
|
||||
public:
|
||||
YellowNotes(void *app);
|
||||
@@ -103,6 +124,7 @@ public:
|
||||
static void func(GObject *obj, void *arg, gpointer user_data) { type *o = reinterpret_cast<type *>(user_data); o->member(obj, reinterpret_cast<argtype *>(arg)); }
|
||||
|
||||
#define BSIGNAL2(type, func, member, argtype) \
|
||||
static gboolean func(GObject *obj, void *arg, gpointer user_data) { type *o = reinterpret_cast<type *>(user_data); return o->member(obj, reinterpret_cast<argtype *>(arg)); }
|
||||
static gboolean func(GObject *obj, void *arg, gpointer user_data) { \
|
||||
type *o = reinterpret_cast<type *>(user_data); return o->member(obj, reinterpret_cast<argtype *>(arg)); }
|
||||
|
||||
#endif // YELLOWNOTES_H
|
||||
|
||||
Reference in New Issue
Block a user