From a26400c3dcc10a3a23b08b9690f9ce0c9b1f2ad3 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Mon, 15 Nov 2021 15:26:44 +0300 Subject: [PATCH] Fix inconsistent message log action state (GTK client) (#2167) --- gtk/Application.cc | 14 +++----------- gtk/MessageLogWindow.cc | 15 ++++++++++++++- gtk/MessageLogWindow.h | 3 +++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gtk/Application.cc b/gtk/Application.cc index 7d1698005..f2df9301a 100644 --- a/gtk/Application.cc +++ b/gtk/Application.cc @@ -151,8 +151,6 @@ private: void on_add_torrent(tr_ctor* ctor); void on_prefs_changed(tr_quark key); - void on_message_window_closed(); - std::vector get_selected_torrent_ids() const; tr_torrent* get_first_selected_torrent() const; counts_data get_selected_torrent_counts() const; @@ -1320,11 +1318,6 @@ bool Application::Impl::call_rpc_for_selected_torrents(std::string const& method return invoked; } -void Application::Impl::on_message_window_closed() -{ - gtr_action_set_toggled("toggle-message-log", false); -} - void Application::Impl::remove_selected(bool delete_files) { std::vector l; @@ -1513,14 +1506,13 @@ void Application::Impl::actions_handler(Glib::ustring const& action_name) { if (msgwin_ == nullptr) { - gtr_action_set_toggled("toggle-message-log", true); msgwin_ = MessageLogWindow::create(*wind_, core_); - msgwin_->signal_hide().connect(sigc::mem_fun(*this, &Impl::on_message_window_closed)); + msgwin_->signal_hide().connect([this]() { msgwin_.reset(); }); + msgwin_->show(); } else { - gtr_action_set_toggled("toggle-message-log", false); - msgwin_.reset(); + msgwin_->hide(); } } else if (action_name == "show-about-dialog") diff --git a/gtk/MessageLogWindow.cc b/gtk/MessageLogWindow.cc index 1ec95d135..62f3613c4 100644 --- a/gtk/MessageLogWindow.cc +++ b/gtk/MessageLogWindow.cc @@ -16,6 +16,7 @@ #include #include +#include "Actions.h" #include "HigWorkarea.h" #include "MessageLogWindow.h" #include "Prefs.h" @@ -548,5 +549,17 @@ MessageLogWindow::Impl::Impl(MessageLogWindow& window, Glib::RefPtr con SECONDARY_WINDOW_REFRESH_INTERVAL_SECONDS); scroll_to_bottom(); - window_.show_all(); + window_.show_all_children(); +} + +void MessageLogWindow::on_show() +{ + Gtk::Window::on_show(); + gtr_action_set_toggled("toggle-message-log", true); +} + +void MessageLogWindow::on_hide() +{ + Gtk::Window::on_hide(); + gtr_action_set_toggled("toggle-message-log", false); } diff --git a/gtk/MessageLogWindow.h b/gtk/MessageLogWindow.h index 26f493683..1b42825ea 100644 --- a/gtk/MessageLogWindow.h +++ b/gtk/MessageLogWindow.h @@ -24,6 +24,9 @@ public: protected: MessageLogWindow(Gtk::Window& parent, Glib::RefPtr const& core); + void on_show() override; + void on_hide() override; + private: class Impl; std::unique_ptr const impl_;