windows changes

This commit is contained in:
2025-11-27 09:43:32 +01:00
parent 5023b63a7e
commit 441e903c67
12 changed files with 137 additions and 27 deletions

View File

@@ -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

BIN
app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

1
app.rc Normal file
View File

@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "app.ico"

View File

@@ -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)
@@ -712,6 +741,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))

View File

@@ -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;
};

View File

@@ -14,7 +14,9 @@
extern "C" {
#include "gtk-imports.h"
}
#include <list>
#include <filesystem>
std::string InfoOverMe::containingFolder()
{
@@ -25,8 +27,12 @@ std::string InfoOverMe::containingFolder()
path[len] = '\0';
std::string p(path);
std::cout << p << std::endl;
return p;
std::filesystem::path pp(p);
if (std::filesystem::is_regular_file(pp)) {
pp = pp.parent_path();
}
return pp.string();
}
std::string InfoOverMe::myHostname()

View File

@@ -20,13 +20,26 @@ static void activate (GtkApplication* app, gpointer user_data)
g_signal_connect(tray, "activate", on_tray_activate, notes);
}
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(argv, 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
std::string my_path = w.containingFolder();

4
tr.cpp
View File

@@ -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";
}

View File

@@ -1,3 +0,0 @@
#include "win32gtkdownloader.h"
Win32GtkDownloader::Win32GtkDownloader() {}

View File

@@ -1,10 +0,0 @@
#ifndef WIN32GTKDOWNLOADER_H
#define WIN32GTKDOWNLOADER_H
class Win32GtkDownloader
{
public:
Win32GtkDownloader();
};
#endif // WIN32GTKDOWNLOADER_H

View File

@@ -250,6 +250,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);
@@ -521,6 +522,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);
@@ -538,6 +540,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);
@@ -547,6 +550,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();
@@ -838,6 +842,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;
@@ -1797,8 +1832,6 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
return false;
}
#define YELLOWNOTE_VERSION 3
void YellowNote::load()
{
auto readInt = [](FILE *f, int default_value) {
@@ -2008,7 +2041,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());

View File

@@ -12,6 +12,14 @@ extern "C" {
class YellowNote;
class SettingContainer;
#define YELLOWNOTE_MAJOR "1"
#define YELLOWNOTE_MINOR "0"
#define YELLOWNOTE_PATCH "0"
#define YELLOWNOTE_VERSION YELLOWNOTE_MAJOR "." YELLOWNOTE_MINOR "." YELLOWNOTE_PATCH
#define YELLOWNOTE_FILE_VERSION 3
typedef enum {
DARK = 0,
FIRST= DARK,
@@ -82,6 +90,8 @@ public:
bool setupDel(GtkWidget *sender, void *evt);
void remove(YellowNote *n);
void checkMonitors();
void about(void *sender);
public:
std::string currentLang();