billy-gtk4-interface/main.cpp
2024-10-28 18:58:19 +01:00

25 lines
826 B
C++

#include "hello_world.hpp"
#include <gtkmm/application.h>
#include <gtkmm/builder.h>
#include <iostream>
#include <memory>
int main(int argc, char *argv[]) {
auto app = Gtk::Application::create("org.gtkmm.example");
const auto menu_model = []() -> Glib::RefPtr<Gio::Menu> {
try {
const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
return std::dynamic_pointer_cast<Gio::Menu>(builder->get_object("menu"));
} catch (const std::exception &e) {
std::cerr << e.what() << '\n';
return nullptr;
}
}();
if (menu_model == nullptr) {
std::cerr << "Menu model object is null. Down-cast failed.\n";
return EXIT_FAILURE;
}
return app->make_window_and_run<learn_gtkmm4::HelloWorld>(argc, argv, menu_model);
}