correct menu_bar.ui
This commit is contained in:
parent
a328b57c3c
commit
77b14d2fe3
4 changed files with 86 additions and 8 deletions
19
main.cpp
19
main.cpp
|
@ -1,7 +1,24 @@
|
|||
#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");
|
||||
return app->make_window_and_run<learn_gtkmm4::HelloWorld>(argc, argv);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue