2024-03-23 18:41:26 -07:00
|
|
|
#include "main.h"
|
|
|
|
#include "main_window.hpp"
|
2024-03-26 18:39:02 -07:00
|
|
|
#include <assets/assets.h>
|
|
|
|
#include <license.hpp>
|
2024-03-23 18:41:26 -07:00
|
|
|
std::string GtkBackend::get_id() {
|
|
|
|
return "gtk";
|
|
|
|
}
|
|
|
|
std::string GtkBackend::get_name() {
|
|
|
|
return "GTK frontend";
|
|
|
|
}
|
|
|
|
int GtkBackend::run(std::vector<std::string> realArgs, int argc, char **argv) {
|
|
|
|
int ret = UIBackend::run(realArgs, argc, argv);
|
|
|
|
if (ret != 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
2024-03-26 18:39:02 -07:00
|
|
|
Glib::set_application_name("Looper");
|
2024-04-09 10:15:05 -07:00
|
|
|
auto app = Gtk::Application::create("com.complecwaft.Looper.GTK", Gio::Application::Flags::NON_UNIQUE);
|
2024-03-26 18:39:02 -07:00
|
|
|
char *gtk_frontend_css = (char*)malloc(gtk_frontend_css_size + 1);
|
|
|
|
memcpy(gtk_frontend_css, gtk_frontend_css_data, gtk_frontend_css_size);
|
|
|
|
gtk_frontend_css[gtk_frontend_css_size] = '\0';
|
|
|
|
std::string gtk_frontend_css_str = std::string(gtk_frontend_css);
|
|
|
|
free(gtk_frontend_css);
|
|
|
|
auto provider = Gtk::CssProvider::create();
|
|
|
|
provider->load_from_string(gtk_frontend_css_str);
|
|
|
|
app->signal_startup().connect([=,this]() {
|
|
|
|
app->add_action("quit", [app]() {
|
|
|
|
app->quit();
|
|
|
|
});
|
|
|
|
Gtk::StyleContext::add_provider_for_display(Gdk::Display::get_default(), provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
2024-03-23 18:41:26 -07:00
|
|
|
});
|
2024-03-26 18:39:02 -07:00
|
|
|
app->signal_activate().connect([=,this] {
|
|
|
|
auto *win = new MainWindow(playback, app);
|
|
|
|
win->present();
|
|
|
|
});
|
2024-04-09 10:15:05 -07:00
|
|
|
app_ptr = app.get();
|
2024-03-26 18:39:02 -07:00
|
|
|
ret = app->run(argc, argv);
|
2024-04-09 10:15:05 -07:00
|
|
|
app_ptr = nullptr;
|
2024-03-26 18:39:02 -07:00
|
|
|
return ret;
|
|
|
|
}
|
2024-04-09 10:15:05 -07:00
|
|
|
void GtkBackend::QuitHandler() {
|
|
|
|
if (app_ptr != nullptr) {
|
|
|
|
((Gtk::Application*)app_ptr)->quit();
|
|
|
|
}
|
|
|
|
}
|
2024-03-26 18:39:02 -07:00
|
|
|
void GtkBackend::add_licenses() {
|
|
|
|
auto &license_data = get_license_data();
|
|
|
|
auto gtkmm = LicenseData("GtkMM", "lgpl-2.1");
|
|
|
|
auto glibmm = LicenseData("GlibMM", "lgpl-2.1");
|
|
|
|
auto glib = LicenseData("Glib", "lgpl-2.1-or-later");
|
|
|
|
auto gtk = LicenseData("GTK", "lgpl-2.0");
|
|
|
|
LOAD_LICENSE(gtkmm, lgpl_2_1);
|
|
|
|
LOAD_LICENSE(glibmm, lgpl_2_1);
|
|
|
|
LOAD_LICENSE(glib, lgpl_2_1);
|
|
|
|
LOAD_LICENSE(gtk, lgpl_2_0);
|
|
|
|
license_data.insert(gtkmm);
|
|
|
|
license_data.insert(glibmm);
|
|
|
|
license_data.insert(glib);
|
|
|
|
license_data.insert(gtk);
|
2024-03-23 18:41:26 -07:00
|
|
|
}
|