Fix inconsistent message log action state (GTK client) (#2167)

This commit is contained in:
Mike Gelfand 2021-11-15 15:26:44 +03:00 committed by GitHub
parent 250a2e3cc5
commit a26400c3dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 12 deletions

View File

@ -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<int> 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<int> 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")

View File

@ -16,6 +16,7 @@
#include <libtransmission/transmission.h>
#include <libtransmission/log.h>
#include "Actions.h"
#include "HigWorkarea.h"
#include "MessageLogWindow.h"
#include "Prefs.h"
@ -548,5 +549,17 @@ MessageLogWindow::Impl::Impl(MessageLogWindow& window, Glib::RefPtr<Session> 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);
}

View File

@ -24,6 +24,9 @@ public:
protected:
MessageLogWindow(Gtk::Window& parent, Glib::RefPtr<Session> const& core);
void on_show() override;
void on_hide() override;
private:
class Impl;
std::unique_ptr<Impl> const impl_;