From 6e44adabf16fabdf21131486b6793019b1a0062f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 26 Aug 2022 19:45:46 -0500 Subject: [PATCH] Revert "fix(gtk): fix conflicting hotkeys (#2201)" (#3718) This reverts commit a0305a3a1224d9037c86fb079ccb5a986afce27b. --- gtk/Actions.cc | 52 +++++++++-------------------- gtk/Actions.h | 5 +-- gtk/Application.cc | 5 ++- gtk/MainWindow.cc | 46 ++++++-------------------- gtk/MainWindow.h | 9 ++---- gtk/transmission-ui.xml | 72 ++++++++++++++++++++--------------------- 6 files changed, 66 insertions(+), 123 deletions(-) diff --git a/gtk/Actions.cc b/gtk/Actions.cc index 10525ec99..85525fd5d 100644 --- a/gtk/Actions.cc +++ b/gtk/Actions.cc @@ -62,39 +62,36 @@ std::array const pref_toggle_entries = { "show-toolbar"sv, // }; -std::array const window_entries = { - "open-torrent-from-url"sv, // - "open-torrent"sv, // - "show-stats"sv, // - "donate"sv, // - "pause-all-torrents"sv, // - "start-all-torrents"sv, // - "new-torrent"sv, // - "quit"sv, // - "edit-preferences"sv, // - "show-about-dialog"sv, // - "help"sv, // - "present-main-window"sv, // -}; - -std::array const torrent_entries = { +std::array const entries = { "copy-magnet-link-to-clipboard"sv, + "open-torrent-from-url"sv, + "open-torrent"sv, "torrent-start"sv, "torrent-start-now"sv, + "show-stats"sv, + "donate"sv, "torrent-verify"sv, "torrent-stop"sv, + "pause-all-torrents"sv, + "start-all-torrents"sv, "relocate-torrent"sv, "remove-torrent"sv, "delete-torrent"sv, + "new-torrent"sv, + "quit"sv, "select-all"sv, "deselect-all"sv, + "edit-preferences"sv, "show-torrent-properties"sv, "open-torrent-folder"sv, + "show-about-dialog"sv, + "help"sv, "torrent-reannounce"sv, "queue-move-top"sv, "queue-move-up"sv, "queue-move-down"sv, "queue-move-bottom"sv, + "present-main-window"sv, }; Gtk::Builder* myBuilder = nullptr; @@ -108,9 +105,7 @@ void gtr_actions_set_core(Glib::RefPtr const& core) myCore = gtr_get_ptr(core); } -Glib::RefPtr gtr_actions_init_window( - Glib::RefPtr const& builder, - gpointer callback_user_data) +Glib::RefPtr gtr_actions_init(Glib::RefPtr const& builder, gpointer callback_user_data) { myBuilder = gtr_get_ptr(builder); @@ -147,24 +142,7 @@ Glib::RefPtr gtr_actions_init_window( key_to_action.try_emplace(action_name, action); } - for (auto const& action_name_view : window_entries) - { - auto const action_name = Glib::ustring(std::string(action_name_view)); - auto const action = Gio::SimpleAction::create(action_name); - action->signal_activate().connect([a = gtr_get_ptr(action), callback_user_data](auto const& /*value*/) - { action_cb(*a, callback_user_data); }); - action_group->add_action(action); - key_to_action.try_emplace(action_name, action); - } - - return action_group; -} - -Glib::RefPtr gtr_actions_init_torrent(gpointer callback_user_data) -{ - auto const action_group = Gio::SimpleActionGroup::create(); - - for (auto const& action_name_view : torrent_entries) + for (auto const& action_name_view : entries) { auto const action_name = Glib::ustring(std::string(action_name_view)); auto const action = Gio::SimpleAction::create(action_name); diff --git a/gtk/Actions.h b/gtk/Actions.h index bbcdd0b4d..b4f8c54ef 100644 --- a/gtk/Actions.h +++ b/gtk/Actions.h @@ -11,10 +11,7 @@ class Session; -Glib::RefPtr gtr_actions_init_window( - Glib::RefPtr const& builder, - gpointer callback_user_data); -Glib::RefPtr gtr_actions_init_torrent(gpointer callback_user_data); +Glib::RefPtr gtr_actions_init(Glib::RefPtr const& builder, gpointer callback_user_data); void gtr_actions_set_core(Glib::RefPtr const& core); void gtr_actions_handler(Glib::ustring const& action_name, gpointer user_data); diff --git a/gtk/Application.cc b/gtk/Application.cc index ba4a01043..7f3046ef1 100644 --- a/gtk/Application.cc +++ b/gtk/Application.cc @@ -562,13 +562,12 @@ void Application::Impl::on_startup() /* init the ui manager */ ui_builder_ = Gtk::Builder::create_from_resource(gtr_get_full_resource_path("transmission-ui.xml"s)); - auto const actions_window = gtr_actions_init_window(ui_builder_, this); - auto const actions_torrent = gtr_actions_init_torrent(this); + auto const actions = gtr_actions_init(ui_builder_, this); app_.set_menubar(gtr_action_get_object("main-window-menu")); /* create main window now to be a parent to any error dialogs */ - wind_ = MainWindow::create(app_, actions_window, actions_torrent, core_); + wind_ = MainWindow::create(app_, actions, core_); wind_->signal_size_allocate().connect(sigc::mem_fun(*this, &Impl::on_main_window_size_allocated)); app_.hold(); app_setup(); diff --git a/gtk/MainWindow.cc b/gtk/MainWindow.cc index 2cc2eefe0..af26ef349 100644 --- a/gtk/MainWindow.cc +++ b/gtk/MainWindow.cc @@ -24,11 +24,7 @@ class MainWindow::Impl { public: - Impl( - MainWindow& window, - Glib::RefPtr const& actions_window, - Glib::RefPtr const& actions_torrent, - Glib::RefPtr const& core); + Impl(MainWindow& window, Glib::RefPtr const& actions, Glib::RefPtr const& core); ~Impl(); TR_DISABLE_COPY_MOVE(Impl) @@ -40,7 +36,7 @@ public: void prefsChanged(tr_quark key); private: - Gtk::TreeView* makeview(Glib::RefPtr const& model, Glib::RefPtr const& actions_torrent); + Gtk::TreeView* makeview(Glib::RefPtr const& model); Gtk::Menu* createOptionsMenu(); Gtk::Menu* createSpeedMenu(tr_direction dir); @@ -122,9 +118,7 @@ bool tree_view_search_equal_func( } // namespace -Gtk::TreeView* MainWindow::Impl::makeview( - Glib::RefPtr const& model, - Glib::RefPtr const& actions_torrent) +Gtk::TreeView* MainWindow::Impl::makeview(Glib::RefPtr const& model) { auto* view = Gtk::make_managed(); view->set_search_column(torrent_cols.name_collated); @@ -160,16 +154,6 @@ Gtk::TreeView* MainWindow::Impl::makeview( { return on_tree_view_button_released(view, event); }); view->signal_row_activated().connect([](auto const& /*path*/, auto* /*column*/) { gtr_action_activate("show-torrent-properties"); }); - view->signal_state_flags_changed().connect( - [this, view, actions_torrent](Gtk::StateFlags previous) - { - Gtk::StateFlags changed = previous ^ view->get_state_flags(); - if (changed & Gtk::StateFlags::STATE_FLAG_FOCUSED) - { - view->has_focus() ? window_.insert_action_group("torrent", actions_torrent) : - window_.remove_action_group("torrent"); - } - }); view->set_model(model); @@ -408,31 +392,22 @@ void MainWindow::Impl::onOptionsClicked(Gtk::Button* button) std::unique_ptr MainWindow::create( Gtk::Application& app, - Glib::RefPtr const& actions_window, - Glib::RefPtr const& actions_torrent, + Glib::RefPtr const& actions, Glib::RefPtr const& core) { - return std::unique_ptr(new MainWindow(app, actions_window, actions_torrent, core)); + return std::unique_ptr(new MainWindow(app, actions, core)); } -MainWindow::MainWindow( - Gtk::Application& app, - Glib::RefPtr const& actions_window, - Glib::RefPtr const& actions_torrent, - Glib::RefPtr const& core) +MainWindow::MainWindow(Gtk::Application& app, Glib::RefPtr const& actions, Glib::RefPtr const& core) : Gtk::ApplicationWindow() - , impl_(std::make_unique(*this, actions_window, actions_torrent, core)) + , impl_(std::make_unique(*this, actions, core)) { app.add_window(*this); } MainWindow::~MainWindow() = default; -MainWindow::Impl::Impl( - MainWindow& window, - Glib::RefPtr const& actions_window, - Glib::RefPtr const& actions_torrent, - Glib::RefPtr const& core) +MainWindow::Impl::Impl(MainWindow& window, Glib::RefPtr const& actions, Glib::RefPtr const& core) : window_(window) , core_(core) { @@ -458,8 +433,7 @@ MainWindow::Impl::Impl( window.maximize(); } - window.insert_action_group("win", actions_window); - window.insert_action_group("torrent", actions_torrent); + window.insert_action_group("win", actions); /* Add style provider to the window. */ /* Please move it to separate .css file if you’re adding more styles here. */ auto const* style = ".tr-workarea.frame {border-left-width: 0; border-right-width: 0; border-radius: 0;}"; @@ -555,7 +529,7 @@ MainWindow::Impl::Impl( *** Workarea **/ - view_ = makeview(filter_->get_filter_model(), actions_torrent); + view_ = makeview(filter_->get_filter_model()); scroll_ = Gtk::make_managed(); scroll_->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); scroll_->set_shadow_type(Gtk::SHADOW_OUT); diff --git a/gtk/MainWindow.h b/gtk/MainWindow.h index 626ba7b81..2658b6a7c 100644 --- a/gtk/MainWindow.h +++ b/gtk/MainWindow.h @@ -22,8 +22,7 @@ public: static std::unique_ptr create( Gtk::Application& app, - Glib::RefPtr const& actions_window, - Glib::RefPtr const& actions_torrent, + Glib::RefPtr const& actions, Glib::RefPtr const& core); Glib::RefPtr get_selection() const; @@ -32,11 +31,7 @@ public: void refresh(); protected: - MainWindow( - Gtk::Application& app, - Glib::RefPtr const& actions_window, - Glib::RefPtr const& actions_torrent, - Glib::RefPtr const& core); + MainWindow(Gtk::Application& app, Glib::RefPtr const& actions, Glib::RefPtr const& core); private: class Impl; diff --git a/gtk/transmission-ui.xml b/gtk/transmission-ui.xml index 6f65d3e3d..4dbbc628f 100644 --- a/gtk/transmission-ui.xml +++ b/gtk/transmission-ui.xml @@ -54,13 +54,13 @@ _Edit
- torrent.select-all + win.select-all edit-select-all Select _All <control>A - torrent.deselect-all + win.deselect-all Dese_lect All <shift><control>A @@ -77,14 +77,14 @@ _Torrent
- torrent.show-torrent-properties + win.show-torrent-properties document-properties _Properties <alt>Return Torrent properties - torrent.open-torrent-folder + win.open-torrent-folder document-open Open Fold_er <control>E @@ -92,21 +92,21 @@
- torrent.torrent-start + win.torrent-start media-playback-start _Start <control>S Start torrent - torrent.torrent-start-now + win.torrent-start-now media-playback-start Start _Now <shift><control>S Start torrent now - torrent.torrent-reannounce + win.torrent-reannounce network-workgroup Ask Tracker for _More Peers @@ -114,29 +114,29 @@ _Queue
- torrent.queue-move-top + win.queue-move-top go-top Move to _Top - torrent.queue-move-up + win.queue-move-up go-up Move _Up - torrent.queue-move-down + win.queue-move-down go-down Move _Down - torrent.queue-move-bottom + win.queue-move-bottom go-bottom Move to _Bottom
- torrent.torrent-stop + win.torrent-stop media-playback-pause _Pause <control>P @@ -145,29 +145,29 @@
- torrent.relocate-torrent + win.relocate-torrent Set _Location… - torrent.torrent-verify + win.torrent-verify _Verify Local Data <control>V - torrent.copy-magnet-link-to-clipboard + win.copy-magnet-link-to-clipboard edit-copy Copy _Magnet Link to Clipboard
- torrent.remove-torrent + win.remove-torrent list-remove Remove torrent Delete - torrent.delete-torrent + win.delete-torrent edit-delete _Delete Files and Remove <shift>Delete @@ -309,7 +309,7 @@ True False Start torrent - torrent.torrent-start + win.torrent-start _Start True media-playback-start @@ -324,7 +324,7 @@ True False Pause torrent - torrent.torrent-stop + win.torrent-stop _Pause True media-playback-pause @@ -338,7 +338,7 @@ True False - torrent.remove-torrent + win.remove-torrent Remove torrent True list-remove @@ -364,7 +364,7 @@ False Torrent properties True - torrent.show-torrent-properties + win.show-torrent-properties _Properties True document-properties @@ -379,14 +379,14 @@
- torrent.show-torrent-properties + win.show-torrent-properties document-properties _Properties <alt>Return Torrent properties - torrent.open-torrent-folder + win.open-torrent-folder document-open Open Fold_er <control>E @@ -452,21 +452,21 @@
- torrent.torrent-start + win.torrent-start media-playback-start _Start <control>S Start torrent - torrent.torrent-start-now + win.torrent-start-now media-playback-start Start _Now <shift><control>S Start torrent now - torrent.torrent-reannounce + win.torrent-reannounce network-workgroup Ask Tracker for _More Peers @@ -474,29 +474,29 @@ _Queue
- torrent.queue-move-top + win.queue-move-top go-top Move to _Top - torrent.queue-move-up + win.queue-move-up go-up Move _Up - torrent.queue-move-down + win.queue-move-down go-down Move _Down - torrent.queue-move-bottom + win.queue-move-bottom go-bottom Move to _Bottom
- torrent.torrent-stop + win.torrent-stop media-playback-pause _Pause <control>P @@ -505,29 +505,29 @@
- torrent.relocate-torrent + win.relocate-torrent Set _Location… - torrent.torrent-verify + win.torrent-verify _Verify Local Data <control>V - torrent.copy-magnet-link-to-clipboard + win.copy-magnet-link-to-clipboard edit-copy Copy _Magnet Link to Clipboard
- torrent.remove-torrent + win.remove-torrent list-remove Remove torrent Delete - torrent.delete-torrent + win.delete-torrent edit-delete _Delete Files and Remove <shift>Delete