2024-10-24 11:02:04 +02:00
|
|
|
#include "hello_world.hpp"
|
|
|
|
#include <gtkmm/application.h>
|
2024-10-28 18:58:19 +01:00
|
|
|
#include <gtkmm/builder.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <memory>
|
2024-10-24 11:02:04 +02:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
auto app = Gtk::Application::create("org.gtkmm.example");
|
2024-10-28 18:58:19 +01:00
|
|
|
|
|
|
|
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);
|
2024-10-24 11:02:04 +02:00
|
|
|
}
|