Compare commits
6 Commits
28f0fdb520
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b52d247977 | |||
| 1a33db1bf5 | |||
| 4c6f260bb9 | |||
| b91d093b1f | |||
| c968774e62 | |||
| 441e903c67 |
@@ -5,15 +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
|
||||
win32gtkdownloader.h win32gtkdownloader.cpp
|
||||
|
||||
utils/whereami.c utils/whereami.h
|
||||
info_over_me.h info_over_me.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
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ typedef void GtkColorChooser;
|
||||
typedef void GtkSpinButton;
|
||||
typedef void GdkMonitor;
|
||||
typedef void GdkScreen;
|
||||
typedef void GtkAboutDialog;
|
||||
|
||||
typedef int gboolean;
|
||||
typedef int gint;
|
||||
@@ -580,6 +581,34 @@ typedef struct _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)
|
||||
@@ -645,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))
|
||||
@@ -712,6 +742,16 @@ DECL(void, gdk_monitor_get_geometry, (GdkMonitor* monitor, GdkRectangle* geometr
|
||||
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))
|
||||
|
||||
@@ -15,18 +15,27 @@ extern "C" {
|
||||
#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;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
extern "C" {
|
||||
#include "gtk-imports.h"
|
||||
}
|
||||
|
||||
#include <list>
|
||||
#include <filesystem>
|
||||
|
||||
@@ -28,10 +29,8 @@ std::string InfoOverMe::containingFolder()
|
||||
std::filesystem::path p(path);
|
||||
if (std::filesystem::is_regular_file(p)) {
|
||||
std::filesystem::path pp = p.parent_path();
|
||||
std::cout << pp << std::endl;
|
||||
return pp.string();
|
||||
} else {
|
||||
std::cout << p << std::endl;
|
||||
return p.string();
|
||||
}
|
||||
}
|
||||
|
||||
17
main.cpp
17
main.cpp
@@ -27,13 +27,26 @@ static void activate (GtkApplication* app, gpointer user_data)
|
||||
#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;
|
||||
InfoOverMe w;
|
||||
|
||||
std::cout << w.myOsHostname() << std::endl;
|
||||
|
||||
srand(time(NULL)); // seed with current time
|
||||
|
||||
try {
|
||||
|
||||
4
tr.cpp
4
tr.cpp
@@ -96,6 +96,10 @@ tr::tr()
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "win32gtkdownloader.h"
|
||||
|
||||
Win32GtkDownloader::Win32GtkDownloader() {}
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef WIN32GTKDOWNLOADER_H
|
||||
#define WIN32GTKDOWNLOADER_H
|
||||
|
||||
class Win32GtkDownloader
|
||||
{
|
||||
public:
|
||||
Win32GtkDownloader();
|
||||
};
|
||||
|
||||
#endif // WIN32GTKDOWNLOADER_H
|
||||
@@ -48,6 +48,14 @@ public:
|
||||
std::string os_host;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
NONE,
|
||||
BOTTOM_RIGHT,
|
||||
BOTTOM,
|
||||
RIGHT
|
||||
} YellowNoteResize_t;
|
||||
|
||||
|
||||
|
||||
class YellowNote
|
||||
{
|
||||
@@ -110,6 +118,8 @@ private:
|
||||
bool _resize_right;
|
||||
bool _resize_bottom;
|
||||
bool _resize_edge;
|
||||
YellowNoteResize_t _resize_type;
|
||||
|
||||
int _x_orig;
|
||||
int _y_orig;
|
||||
|
||||
@@ -250,6 +260,7 @@ 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);
|
||||
@@ -540,6 +551,7 @@ void YellowNotes::popupTrayMenu(void *sender)
|
||||
|
||||
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);
|
||||
@@ -557,6 +569,7 @@ 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);
|
||||
|
||||
@@ -566,6 +579,7 @@ void YellowNotes::popupTrayMenu(void *sender)
|
||||
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();
|
||||
@@ -857,6 +871,37 @@ 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;
|
||||
@@ -1107,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;
|
||||
@@ -1216,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)) {
|
||||
@@ -1337,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()
|
||||
@@ -1709,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)) {
|
||||
@@ -1716,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;
|
||||
}
|
||||
@@ -1796,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);
|
||||
@@ -1816,18 +1879,21 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
|
||||
return false;
|
||||
}
|
||||
|
||||
#define YELLOWNOTE_VERSION 3
|
||||
|
||||
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;
|
||||
@@ -2027,7 +2093,7 @@ void YellowNote::save()
|
||||
std::filesystem::path p(_filename);
|
||||
FILE *f = fopen(_filename.c_str(), "wt");
|
||||
if (f) {
|
||||
fprintf(f, "%d\n", YELLOWNOTE_VERSION);
|
||||
fprintf(f, "%d\n", YELLOWNOTE_FILE_VERSION);
|
||||
|
||||
|
||||
fprintf(f, "%s\n", storeKind(_hidden, [](const StoredCoords &c) { return c.hidden; }).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,
|
||||
@@ -83,6 +91,8 @@ public:
|
||||
bool setupDel(GtkWidget *sender, void *evt);
|
||||
void remove(YellowNote *n);
|
||||
void checkMonitors();
|
||||
void about(void *sender);
|
||||
|
||||
|
||||
public:
|
||||
std::string currentLang();
|
||||
|
||||
Reference in New Issue
Block a user