[gtkmm-documentation] Menu examples: Use the templated Gtk::Builder::get_object<>()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Menu examples: Use the templated Gtk::Builder::get_object<>()
- Date: Mon, 11 Jul 2022 17:06:27 +0000 (UTC)
commit 3c63b2fd0d4895be81beac9f1ca1e17305c28b53
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon Jul 11 19:02:49 2022 +0200
Menu examples: Use the templated Gtk::Builder::get_object<>()
* examples/book/menus/main_menu/exampleapplication.cc:
* examples/book/menus/popup/examplewindow.cc:
* examples/book/menus_and_toolbars/examplewindow.cc:
Use m_refBuilder->get_object<Gio::Menu>("menu"). That's what
the tutorial describes.
examples/book/menus/main_menu/exampleapplication.cc | 4 ++--
examples/book/menus/popup/examplewindow.cc | 5 +----
examples/book/menus_and_toolbars/examplewindow.cc | 5 ++---
3 files changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/examples/book/menus/main_menu/exampleapplication.cc
b/examples/book/menus/main_menu/exampleapplication.cc
index 47d1cbf..7210e2c 100644
--- a/examples/book/menus/main_menu/exampleapplication.cc
+++ b/examples/book/menus/main_menu/exampleapplication.cc
@@ -57,6 +57,7 @@ void ExampleApplication::on_startup()
set_accel_for_action("app.quit", "<Primary>q");
set_accel_for_action("win.copy", "<Primary>c");
set_accel_for_action("win.paste", "<Primary>v");
+
m_refBuilder = Gtk::Builder::create();
//Layout the actions in a menubar and a menu:
@@ -170,8 +171,7 @@ void ExampleApplication::on_startup()
}
//Get the menubar and the app menu, and add them to the application:
- auto object = m_refBuilder->get_object("menu-example");
- auto gmenu = std::dynamic_pointer_cast<Gio::Menu>(object);
+ auto gmenu = m_refBuilder->get_object<Gio::Menu>("menu-example");
if (!gmenu)
{
g_warning("GMenu not found");
diff --git a/examples/book/menus/popup/examplewindow.cc b/examples/book/menus/popup/examplewindow.cc
index 3a07e7a..5b0f2bf 100644
--- a/examples/book/menus/popup/examplewindow.cc
+++ b/examples/book/menus/popup/examplewindow.cc
@@ -92,10 +92,7 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
}
//Get the menu:
- auto object =
- m_refBuilder->get_object("menu-examplepopup");
- auto gmenu =
- std::dynamic_pointer_cast<Gio::Menu>(object);
+ auto gmenu = m_refBuilder->get_object<Gio::Menu>("menu-examplepopup");
if(!gmenu)
g_warning("GMenu not found");
diff --git a/examples/book/menus_and_toolbars/examplewindow.cc
b/examples/book/menus_and_toolbars/examplewindow.cc
index da0cc21..5367b22 100644
--- a/examples/book/menus_and_toolbars/examplewindow.cc
+++ b/examples/book/menus_and_toolbars/examplewindow.cc
@@ -53,7 +53,7 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
m_refBuilder = Gtk::Builder::create();
//Layout the actions in a menubar and toolbar:
- const char* ui_info =
+ const Glib::ustring ui_info =
"<interface>"
" <menu id='menubar'>"
" <submenu>"
@@ -118,8 +118,7 @@ ExampleWindow::ExampleWindow(const Glib::RefPtr<Gtk::Application>& app)
}
//Get the menubar:
- auto object = m_refBuilder->get_object("menubar");
- auto gmenu = std::dynamic_pointer_cast<Gio::Menu>(object);
+ auto gmenu = m_refBuilder->get_object<Gio::Menu>("menubar");
if (!gmenu)
g_warning("GMenu not found");
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]