[gtkmm] Gtk::Application: Simplify make_window_and_run()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::Application: Simplify make_window_and_run()
- Date: Tue, 22 Mar 2022 13:46:23 +0000 (UTC)
commit b79cc797a5ce0bfddd5f03198f68c3d91bc1c445
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Mar 22 14:42:36 2022 +0100
Gtk::Application: Simplify make_window_and_run()
Use Window::set_manage() (via Gtk::make_managed()) and Window::destroy().
See #114
gtk/src/application.hg | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/gtk/src/application.hg b/gtk/src/application.hg
index afb723da..c9464c55 100644
--- a/gtk/src/application.hg
+++ b/gtk/src/application.hg
@@ -298,15 +298,9 @@ int Application::make_window_and_run(int argc, char** argv, T_Args&&... args)
signal_activate().connect([this, &args...] () {
// The created window is managed. Thus, the C++ wrapper is deleted
- // by Gtk::Object::destroy_notify_() when the window is destroyed.
+ // by Gtk::Object::destroy_notify_() when the C window is destroyed.
// https://gitlab.gnome.org/GNOME/gtkmm/-/issues/114
- //TODO: Simplify when Gtk::Window::set_manage() can make a Gtk::Window managed.
- //auto window = make_managed<T_Window>(std::forward<T_Args>(args)...);
- auto window = new T_Window(std::forward<T_Args>(args)...);
- bool was_floating = g_object_is_floating(window->gobj());
- window->Gtk::Object::set_manage();
- if (!was_floating && g_object_is_floating(window->gobj()))
- g_object_ref_sink(window->gobj());
+ auto window = make_managed<T_Window>(std::forward<T_Args>(args)...);
m_run_window = window;
add_window(*window);
window->show();
@@ -315,8 +309,8 @@ int Application::make_window_and_run(int argc, char** argv, T_Args&&... args)
signal_window_removed().connect([this] (Window* window) {
if (window == m_run_window)
{
- if (window && window->gobj())
- gtk_window_destroy(window->gobj());
+ if (window)
+ window->destroy();
m_run_window = nullptr;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]