👷 add gtk4 branch
This commit is contained in:
parent
250819c596
commit
0aef4b8275
|
@ -23,17 +23,18 @@ pkg_check_modules(
|
|||
GTKMM
|
||||
REQUIRED
|
||||
IMPORTED_TARGET
|
||||
gtkmm-3.0)
|
||||
gtkmm-4.0)
|
||||
|
||||
FetchContent_Declare(fmt
|
||||
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
|
||||
GIT_TAG "3b6e409cd8573f63e4acad7717d9082bd898ec87"
|
||||
GIT_TAG "a44716f58e943905d1357160b98cae2618d053cf"
|
||||
)
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
|
||||
##
|
||||
## CONFIGURATION
|
||||
##
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--export-dynamic")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
|
|
79
meson.build
79
meson.build
|
@ -1,18 +1,35 @@
|
|||
project('cachyos-hello', 'cpp',
|
||||
version: '0.6.10',
|
||||
version: '0.6.9',
|
||||
license: 'GPLv3',
|
||||
meson_version: '>=0.55.0',
|
||||
default_options: ['cpp_std=c++17',
|
||||
'buildtype=debugoptimized',
|
||||
'warning_level=3',
|
||||
'werror=true',
|
||||
'werror=false',
|
||||
'b_ndebug=if-release'])
|
||||
|
||||
is_debug_build = get_option('buildtype').startswith('debug')
|
||||
cc = meson.get_compiler('cpp')
|
||||
if cc.get_id() == 'clang'
|
||||
specific_cc_flags = [
|
||||
'-nostdlib++',
|
||||
#'-stdlib=libc++',
|
||||
'-nodefaultlibs',
|
||||
]
|
||||
specific_link_flags = [
|
||||
'-fuse-ld=lld',
|
||||
]
|
||||
add_global_arguments(cc.get_supported_arguments(specific_cc_flags), language : 'cpp')
|
||||
add_global_link_arguments(cc.get_supported_link_arguments(specific_link_flags), language : 'cpp')
|
||||
endif
|
||||
|
||||
if is_debug_build
|
||||
add_global_arguments('-D_GLIBCXX_ASSERTIONS', language : 'cpp')
|
||||
endif
|
||||
|
||||
# Common dependencies
|
||||
fmt = dependency('fmt', version : ['>=8.0.0'], fallback : ['fmt', 'fmt_dep'])
|
||||
gtkmm = dependency('gtkmm-3.0', version : ['>=3.22.0'])
|
||||
gtkmm = dependency('gtkmm-4.0', version : ['>=1.8.0'])
|
||||
|
||||
src_files = files(
|
||||
'src/hello.cpp', 'src/hello.hpp',
|
||||
|
@ -20,43 +37,65 @@ src_files = files(
|
|||
)
|
||||
|
||||
possible_cc_flags = [
|
||||
'-Wshadow',
|
||||
'-Wshadow',
|
||||
|
||||
'-Wnon-virtual-dtor',
|
||||
'-Wnon-virtual-dtor',
|
||||
|
||||
'-Wcast-align',
|
||||
'-Wunused',
|
||||
'-Woverloaded-virtual',
|
||||
'-Wold-style-cast',
|
||||
'-Wcast-align',
|
||||
'-Wunused',
|
||||
'-Woverloaded-virtual',
|
||||
|
||||
'-Wpedantic', # non-standard C++
|
||||
'-Wconversion', # type conversion that may lose data
|
||||
'-Wnull-dereference',
|
||||
'-Wdouble-promotion', # float to double
|
||||
'-Wpedantic', # non-standard C++
|
||||
'-Wconversion', # type conversion that may lose data
|
||||
'-Wsign-conversion',
|
||||
'-Wnull-dereference',
|
||||
'-Wdouble-promotion', # float to double
|
||||
|
||||
'-Wformat=2',
|
||||
'-Wformat=2',
|
||||
'-Wimplicit-fallthrough', # fallthrough without an explicit annotation
|
||||
]
|
||||
|
||||
if cc.get_id() == 'gcc'
|
||||
possible_cc_flags += [
|
||||
'-Wmisleading-indentation',
|
||||
possible_cc_flags += [
|
||||
'-Wmisleading-indentation',
|
||||
|
||||
'-Wduplicated-cond',
|
||||
'-Wduplicated-branches',
|
||||
'-Wlogical-op',
|
||||
]
|
||||
'-Wduplicated-cond',
|
||||
'-Wduplicated-branches',
|
||||
'-Wlogical-op',
|
||||
'-Wuseless-cast',
|
||||
|
||||
'-Wsuggest-attribute=cold',
|
||||
'-Wsuggest-attribute=format',
|
||||
'-Wsuggest-attribute=malloc',
|
||||
'-Wsuggest-attribute=noreturn',
|
||||
'-Wsuggest-attribute=pure',
|
||||
'-Wsuggest-final-methods',
|
||||
'-Wsuggest-final-types',
|
||||
'-Wdiv-by-zero',
|
||||
'-Wanalyzer-double-fclose',
|
||||
'-Wanalyzer-double-free',
|
||||
'-Wanalyzer-malloc-leak',
|
||||
'-Wanalyzer-use-after-free',
|
||||
]
|
||||
endif
|
||||
|
||||
if get_option('buildtype') != 'debug'
|
||||
if not is_debug_build
|
||||
if cc.get_id() == 'gcc'
|
||||
possible_cc_flags += [
|
||||
'-flto',
|
||||
'-fwhole-program',
|
||||
'-fuse-linker-plugin',
|
||||
]
|
||||
else
|
||||
possible_cc_flags += [
|
||||
'-flto=thin',
|
||||
]
|
||||
endif
|
||||
|
||||
possible_cc_flags += ['-fdata-sections', '-ffunction-sections']
|
||||
possible_link_flags = ['-Wl,--gc-sections', '-Wl,--export-dynamic']
|
||||
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'cpp')
|
||||
endif
|
||||
|
||||
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'cpp')
|
||||
|
|
172
src/hello.cpp
172
src/hello.cpp
|
@ -88,30 +88,30 @@ void quick_message(Gtk::Window* parent, const std::string& message) {
|
|||
// Create the widgets
|
||||
const auto& flags = static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT);
|
||||
auto* dialog = gtk_dialog_new_with_buttons(message.c_str(),
|
||||
parent->gobj(),
|
||||
flags,
|
||||
_("_Offline"),
|
||||
GTK_RESPONSE_NO,
|
||||
_("_Online"),
|
||||
GTK_RESPONSE_YES,
|
||||
nullptr);
|
||||
parent->gobj(),
|
||||
flags,
|
||||
_("_Offline"),
|
||||
GTK_RESPONSE_NO,
|
||||
_("_Online"),
|
||||
GTK_RESPONSE_YES,
|
||||
nullptr);
|
||||
auto* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
auto* label = gtk_label_new(message.c_str());
|
||||
|
||||
// Add the label, and show everything we’ve added
|
||||
gtk_container_add(GTK_CONTAINER(content_area), label);
|
||||
gtk_widget_show_all(dialog);
|
||||
gtk_box_append(GTK_BOX(content_area), label);
|
||||
gtk_widget_show(dialog);
|
||||
|
||||
int result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
// int result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
std::vector<std::string> argv{};
|
||||
if (result == GTK_RESPONSE_NO) {
|
||||
argv = {fix_path("/usr/local/bin/calamares-offline.sh")};
|
||||
} else if (result == GTK_RESPONSE_YES) {
|
||||
argv = {fix_path("/usr/local/bin/calamares-online.sh")};
|
||||
} else {
|
||||
gtk_widget_destroy(dialog);
|
||||
return;
|
||||
}
|
||||
// if (result == GTK_RESPONSE_NO) {
|
||||
// argv = {fix_path("/usr/local/bin/calamares-offline.sh")};
|
||||
// } else if (result == GTK_RESPONSE_YES) {
|
||||
// argv = {fix_path("/usr/local/bin/calamares-online.sh")};
|
||||
// } else {
|
||||
// gtk_window_destroy(GTK_WINDOW(dialog));
|
||||
// return;
|
||||
// }
|
||||
|
||||
int child_stdout{};
|
||||
int child_stderr{};
|
||||
|
@ -119,31 +119,28 @@ void quick_message(Gtk::Window* parent, const std::string& message) {
|
|||
|
||||
// Spawn child process.
|
||||
try {
|
||||
Glib::spawn_async_with_pipes(".", argv, Glib::SpawnFlags::SPAWN_DO_NOT_REAP_CHILD, Glib::SlotSpawnChildSetup(), &child_pid, nullptr, &child_stdout, &child_stderr);
|
||||
Glib::spawn_async_with_pipes(".", argv, Glib::SpawnFlags::DO_NOT_REAP_CHILD, Glib::SlotSpawnChildSetup(), &child_pid, nullptr, &child_stdout, &child_stderr);
|
||||
} catch (Glib::Error& error) {
|
||||
g_critical("%s", error.what().c_str());
|
||||
g_critical("%s", error.what());
|
||||
}
|
||||
// Add a child watch function which will be called when the child process
|
||||
// exits.
|
||||
g_child_watch_add(child_pid, child_watch_cb, nullptr);
|
||||
|
||||
gtk_widget_destroy(dialog);
|
||||
gtk_window_destroy(GTK_WINDOW(dialog));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Hello::Hello(int argc, char** argv) {
|
||||
Hello::Hello(bool is_dev) {
|
||||
set_title("CachyOS Hello");
|
||||
set_border_width(6);
|
||||
if (argc > 1 && (strncmp(argv[1], "--dev", 5) == 0)) {
|
||||
m_dev = true;
|
||||
}
|
||||
// set_border_width(6);
|
||||
|
||||
g_refHello = this;
|
||||
|
||||
auto screen = Gdk::Screen::get_default();
|
||||
// auto screen = Gdk::Screen::get_default();
|
||||
|
||||
// Load preferences
|
||||
if (m_dev) {
|
||||
if (is_dev) {
|
||||
m_preferences = read_json("data/preferences.json");
|
||||
m_preferences["data_path"] = "data/";
|
||||
m_preferences["desktop_path"] = fmt::format("{}/{}.desktop", fs::current_path().string(), m_app);
|
||||
|
@ -159,54 +156,55 @@ Hello::Hello(int argc, char** argv) {
|
|||
m_save = (!fs::exists(save_path)) ? nlohmann::json({{"locale", ""}}) : read_json(save_path);
|
||||
|
||||
// Import Css
|
||||
auto provider = Gtk::CssProvider::create();
|
||||
provider->load_from_path(m_preferences["style_path"]);
|
||||
Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
// auto provider = Gtk::CssProvider::create();
|
||||
// provider->load_from_path(m_preferences["style_path"]);
|
||||
// Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
// Init window
|
||||
m_builder = Gtk::Builder::create_from_file(m_preferences["ui_path"]);
|
||||
gtk_builder_add_callback_symbol(m_builder->gobj(), "on_languages_changed", G_CALLBACK(on_languages_changed));
|
||||
gtk_builder_add_callback_symbol(m_builder->gobj(), "on_action_clicked", G_CALLBACK(on_action_clicked));
|
||||
gtk_builder_add_callback_symbol(m_builder->gobj(), "on_btn_clicked", G_CALLBACK(on_btn_clicked));
|
||||
gtk_builder_add_callback_symbol(m_builder->gobj(), "on_link_clicked", G_CALLBACK(on_link_clicked));
|
||||
gtk_builder_add_callback_symbol(m_builder->gobj(), "on_delete_window", G_CALLBACK(on_delete_window));
|
||||
gtk_builder_connect_signals(m_builder->gobj(), nullptr);
|
||||
Gtk::Window* ref_window;
|
||||
m_builder->get_widget("window", ref_window);
|
||||
gobject_ = reinterpret_cast<GObject*>(ref_window->gobj());
|
||||
// auto* scope = gtk_builder_get_scope(m_builder->gobj());
|
||||
|
||||
// gtk_builder_cscope_add_callback_symbols(scope, "on_languages_changed", G_CALLBACK(on_languages_changed));
|
||||
// gtk_builder_add_callback_symbol(m_builder->gobj(), "on_languages_changed", G_CALLBACK(on_languages_changed));
|
||||
// gtk_builder_add_callback_symbol(m_builder->gobj(), "on_action_clicked", G_CALLBACK(on_action_clicked));
|
||||
// gtk_builder_add_callback_symbol(m_builder->gobj(), "on_btn_clicked", G_CALLBACK(on_btn_clicked));
|
||||
// gtk_builder_add_callback_symbol(m_builder->gobj(), "on_link_clicked", G_CALLBACK(on_link_clicked));
|
||||
// gtk_builder_add_callback_symbol(m_builder->gobj(), "on_delete_window", G_CALLBACK(on_delete_window));
|
||||
// gtk_builder_connect_signals(m_builder->gobj(), nullptr);
|
||||
auto* ref_window = m_builder->get_widget<Gtk::Window>("window");
|
||||
gobject_ = reinterpret_cast<GObject*>(ref_window->gobj());
|
||||
|
||||
// Subtitle of headerbar
|
||||
Gtk::HeaderBar* header;
|
||||
m_builder->get_widget("headerbar", header);
|
||||
auto* header = m_builder->get_widget<Gtk::HeaderBar>("headerbar");
|
||||
const auto& lsb_info = get_lsb_infos();
|
||||
header->set_subtitle(lsb_info[0] + " " + lsb_info[1]);
|
||||
// header->set_title_widget(Gtk::Label(lsb_info[0] + " " + lsb_info[1], false));
|
||||
// header->set_subtitle(lsb_info[0] + " " + lsb_info[1]);
|
||||
|
||||
// Load images
|
||||
if (fs::is_regular_file(m_preferences["logo_path"])) {
|
||||
const auto& logo = Gdk::Pixbuf::create_from_file(m_preferences["logo_path"]);
|
||||
set_icon(logo);
|
||||
// const std::string& logo = m_preferences["logo_path"];
|
||||
// set_icon(logo);
|
||||
// Glib::Error err;
|
||||
// auto* native_er = err.gobj();
|
||||
// gtk_window_set_icon_from_file(this->gobj(), logo.c_str(), &native_er);
|
||||
|
||||
Gtk::Image* image;
|
||||
m_builder->get_widget("distriblogo", image);
|
||||
image->set(logo);
|
||||
// auto* image = m_builder->get_widget<Gtk::Image>("distriblogo");
|
||||
// image->set(logo);
|
||||
|
||||
Gtk::AboutDialog* dialog;
|
||||
m_builder->get_widget("aboutdialog", dialog);
|
||||
dialog->set_logo(logo);
|
||||
// auto* dialog = m_builder->get_widget<Gtk::AboutDialog>("aboutdialog");
|
||||
// dialog->set_logo(logo);
|
||||
}
|
||||
|
||||
Gtk::Box* social_box;
|
||||
m_builder->get_widget("social", social_box);
|
||||
/*
|
||||
auto* social_box = m_builder->get_widget<Gtk::Box>("social");
|
||||
for (const auto& btn : social_box->get_children()) {
|
||||
const auto& name = btn->get_name();
|
||||
const auto& icon_path = fmt::format("{}img/{}.png", m_preferences["data_path"], name.c_str());
|
||||
Gtk::Image* image;
|
||||
m_builder->get_widget(name, image);
|
||||
auto* image = m_builder->get_widget<Gtk::Image>(name);
|
||||
image->set(icon_path);
|
||||
}
|
||||
}*/
|
||||
|
||||
Gtk::Grid* homepage_grid;
|
||||
m_builder->get_widget("homepage", homepage_grid);
|
||||
/*auto* homepage_grid = m_builder->get_widget<Gtk::Grid>("homepage");
|
||||
for (const auto& widget : homepage_grid->get_children()) {
|
||||
if (!G_TYPE_CHECK_INSTANCE_TYPE(widget->gobj(), GTK_TYPE_BUTTON)) {
|
||||
continue;
|
||||
|
@ -221,29 +219,29 @@ Hello::Hello(int argc, char** argv) {
|
|||
image.set(image_path);
|
||||
image.set_margin_start(2);
|
||||
casted_widget->set_image(image);
|
||||
}
|
||||
}*/
|
||||
|
||||
// Create pages
|
||||
m_pages = fmt::format("{}pages/{}", m_preferences["data_path"], m_preferences["default_locale"]);
|
||||
|
||||
for (const auto& page : fs::directory_iterator(m_pages)) {
|
||||
auto* scrolled_window = gtk_scrolled_window_new(nullptr, nullptr);
|
||||
auto* scrolled_window = gtk_scrolled_window_new();
|
||||
auto* viewport = gtk_viewport_new(nullptr, nullptr);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(viewport), 10);
|
||||
// gtk_container_set_border_width(GTK_CONTAINER(viewport), 10);
|
||||
auto* label = gtk_label_new(nullptr);
|
||||
gtk_label_set_line_wrap(GTK_LABEL(label), true);
|
||||
auto* image = gtk_image_new_from_icon_name("go-previous", GTK_ICON_SIZE_BUTTON);
|
||||
gtk_label_set_wrap(GTK_LABEL(label), true);
|
||||
auto* image = gtk_image_new_from_icon_name("go-previous");
|
||||
auto* backBtn = gtk_button_new();
|
||||
gtk_button_set_image(GTK_BUTTON(backBtn), image);
|
||||
gtk_button_set_child(GTK_BUTTON(backBtn), image);
|
||||
gtk_widget_set_name(backBtn, "home");
|
||||
g_signal_connect(backBtn, "clicked", G_CALLBACK(&on_btn_clicked), nullptr);
|
||||
|
||||
auto* grid = GTK_GRID(gtk_grid_new());
|
||||
gtk_grid_attach(grid, backBtn, 0, 1, 1, 1);
|
||||
gtk_grid_attach(grid, label, 1, 2, 1, 1);
|
||||
gtk_container_add(GTK_CONTAINER(viewport), GTK_WIDGET(grid));
|
||||
gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(viewport));
|
||||
gtk_widget_show_all(scrolled_window);
|
||||
gtk_box_append(GTK_BOX(viewport), GTK_WIDGET(grid));
|
||||
gtk_box_append(GTK_BOX(scrolled_window), GTK_WIDGET(viewport));
|
||||
gtk_widget_show(scrolled_window);
|
||||
|
||||
Glib::RefPtr<Glib::Object> stack = m_builder->get_object("stack");
|
||||
const auto& child_name = page.path().filename().string() + "page";
|
||||
|
@ -252,26 +250,23 @@ Hello::Hello(int argc, char** argv) {
|
|||
|
||||
// Init translation
|
||||
const std::string& locale_path = m_preferences["locale_path"];
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(m_app, locale_path.c_str());
|
||||
bind_textdomain_codeset(m_app, "UTF-8");
|
||||
textdomain(m_app);
|
||||
Gtk::ComboBoxText* languages;
|
||||
m_builder->get_widget("languages", languages);
|
||||
auto* languages = m_builder->get_widget<Gtk::ComboBoxText>("languages");
|
||||
languages->set_active_id(get_best_locale());
|
||||
|
||||
// Set autostart switcher state
|
||||
m_autostart = fs::exists(fix_path(m_preferences["autostart_path"]));
|
||||
Gtk::Switch* autostart_switch;
|
||||
m_builder->get_widget("autostart", autostart_switch);
|
||||
m_autostart = fs::exists(fix_path(m_preferences["autostart_path"]));
|
||||
auto* autostart_switch = m_builder->get_widget<Gtk::Switch>("autostart");
|
||||
autostart_switch->set_active(m_autostart);
|
||||
|
||||
// Live systems
|
||||
if (fs::exists(m_preferences["live_path"]) && fs::is_regular_file(m_preferences["installer_path"])) {
|
||||
Gtk::Label* installlabel;
|
||||
m_builder->get_widget("installlabel", installlabel);
|
||||
auto* installlabel = m_builder->get_widget<Gtk::Label>("installlabel");
|
||||
installlabel->set_visible(true);
|
||||
Gtk::Button* install;
|
||||
m_builder->get_widget("install", install);
|
||||
auto* install = m_builder->get_widget<Gtk::Button>("install");
|
||||
install->set_visible(true);
|
||||
}
|
||||
}
|
||||
|
@ -361,8 +356,7 @@ void Hello::set_locale(const std::string_view& use_locale) noexcept {
|
|||
}
|
||||
for (const auto& elt : elts[method.key()].items()) {
|
||||
const std::string& elt_value = elt.value();
|
||||
Gtk::Widget* item;
|
||||
m_builder->get_widget(elt_value, item);
|
||||
auto* item = m_builder->get_widget<Gtk::Widget>(elt_value);
|
||||
if (!m_default_texts[method.key()].contains(elt_value)) {
|
||||
gchar* item_buf;
|
||||
g_object_get(G_OBJECT(item->gobj()), method.key().c_str(), &item_buf, nullptr);
|
||||
|
@ -377,19 +371,18 @@ void Hello::set_locale(const std::string_view& use_locale) noexcept {
|
|||
|
||||
// Change content of pages
|
||||
for (const auto& page : fs::directory_iterator(m_pages)) {
|
||||
Gtk::Stack* stack;
|
||||
m_builder->get_widget("stack", stack);
|
||||
auto* stack = m_builder->get_widget<Gtk::Stack>("stack");
|
||||
const auto& child = stack->get_child_by_name((page.path().filename().string() + "page").c_str());
|
||||
if (child == nullptr) {
|
||||
fmt::print(stderr, "child not found\n");
|
||||
continue;
|
||||
}
|
||||
const auto& first_child = reinterpret_cast<Gtk::Container*>(child)->get_children();
|
||||
const auto& second_child = reinterpret_cast<Gtk::Container*>(first_child[0])->get_children();
|
||||
const auto& third_child = reinterpret_cast<Gtk::Container*>(second_child[0])->get_children();
|
||||
// const auto& first_child = reinterpret_cast<Gtk::Container*>(child)->get_children();
|
||||
// const auto& second_child = reinterpret_cast<Gtk::Container*>(first_child[0])->get_children();
|
||||
// const auto& third_child = reinterpret_cast<Gtk::Container*>(second_child[0])->get_children();
|
||||
|
||||
const auto& label = reinterpret_cast<Gtk::Label*>(third_child[0]);
|
||||
label->set_markup(get_page(page.path().filename().string()));
|
||||
// const auto& label = reinterpret_cast<Gtk::Label*>(third_child[0]);
|
||||
// label->set_markup(get_page(page.path().filename().string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,23 +427,20 @@ void Hello::on_action_clicked(GtkWidget* widget) noexcept {
|
|||
return;
|
||||
}
|
||||
|
||||
Gtk::AboutDialog* dialog;
|
||||
g_refHello->m_builder->get_widget("aboutdialog", dialog);
|
||||
auto* dialog = g_refHello->m_builder->get_widget<Gtk::AboutDialog>("aboutdialog");
|
||||
dialog->set_decorated(false);
|
||||
dialog->run();
|
||||
dialog->hide();
|
||||
}
|
||||
|
||||
void Hello::on_btn_clicked(GtkWidget* widget) noexcept {
|
||||
const auto& name = gtk_widget_get_name(widget);
|
||||
Gtk::Stack* stack;
|
||||
g_refHello->m_builder->get_widget("stack", stack);
|
||||
auto* stack = g_refHello->m_builder->get_widget<Gtk::Stack>("stack");
|
||||
stack->set_visible_child(fmt::format("{}page", name).c_str());
|
||||
}
|
||||
void Hello::on_link_clicked(GtkWidget* widget) noexcept {
|
||||
const auto& name = gtk_widget_get_name(widget);
|
||||
const std::string uri = g_refHello->m_preferences["urls"][name];
|
||||
gtk_show_uri_on_window(nullptr, uri.c_str(), GDK_CURRENT_TIME, nullptr);
|
||||
gtk_show_uri(nullptr, uri.c_str(), GDK_CURRENT_TIME);
|
||||
}
|
||||
void Hello::on_delete_window(GtkWidget* /*widget*/) noexcept {
|
||||
write_json(g_refHello->m_preferences["save_path"].get<std::string>(), g_refHello->m_save);
|
||||
|
|
|
@ -1,12 +1,32 @@
|
|||
#ifndef HELLO_HPP_
|
||||
#define HELLO_HPP_
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#pragma clang diagnostic ignored "-Wsign-conversion"
|
||||
#pragma clang diagnostic ignored "-Wdouble-promotion"
|
||||
#else
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||
#pragma GCC diagnostic ignored "-Wuseless-cast"
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#else
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include <json.hpp>
|
||||
|
||||
class Hello final : public Gtk::Window {
|
||||
public:
|
||||
Hello(int argc, char** argv);
|
||||
Hello(bool is_dev);
|
||||
|
||||
protected:
|
||||
// Handlers
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
int main(int argc, char** argv) {
|
||||
auto app = Gtk::Application::create();
|
||||
|
||||
Hello hello(argc, argv);
|
||||
const bool is_dev = 1;
|
||||
|
||||
// Shows the window and returns when it is closed.
|
||||
return app->run(hello);
|
||||
return app->make_window_and_run<Hello>(argc, argv, is_dev);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue