Files
yellownotes/main.cpp
2025-11-27 09:53:46 +01:00

77 lines
1.6 KiB
C++

#include <iostream>
#include "gtkloader.h"
extern "C" {
#include "gtk-imports.h"
}
#include "yellownotes.h"
#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;
YellowNotes *notes = YELLOWNOTES(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;
InfoOverMe w;
srand(time(NULL)); // seed with current time
try {
l.loadGtk();
} catch(std::string msg) {
std::cerr << msg << std::endl;
exit(2);
}
GtkApplication *app;
int status;
app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
YellowNotes notes(app);
g_signal_connect (app, "activate", activate, &notes);
status = g_application_run(app, argc, argv);
notes.loadNotes();
gtk_main();
g_object_unref (app);
return status;
}