mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
* Use `Gio::List{Model,Store}` for torrents
Switch from `Gtk::{TreeModel,ListStore}` in preparation for cell
renderers deprecation in GTK 4.10. That will require switching to the
new view classes (`Gtk::{Column,List}View`) which only work with `Gio`
models. Implement an adapter to support GTK+ 3 where the old view class
(`Gtk::TreeView`) only works with `Gtk` models; it is effective enough
but requires a signal connection per item to notify on row changes.
Refactor filtering and sorting (which now happen over the new model) to
use compatible `Gtk::Filter` and `Gtk::Sorter` classes. Although these
classes are only present in GTK 4, the abstraction is suitable for GTK+
3 as well so make our subclasses work for both versions.
Since items (of `Torrent` class) of the new model provide only a very
limited (by design) layer of compatibility with GTK+ 3 way of doing
things, refactor selection handling to do it the new way. Move selection
helpers into `MainWindow` to abstract them away since new view classes
handle it differently.
* Improve session load performance based on profiling results
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
// This file Copyright © 2005-2022 Transmission authors and contributors.
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
// License text can be found in the licenses/ folder.
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include <glibmm.h>
|
|
#include <gtkmm.h>
|
|
|
|
#include <libtransmission/tr-macros.h>
|
|
|
|
class Session;
|
|
class Torrent;
|
|
|
|
class MainWindow : public Gtk::ApplicationWindow
|
|
{
|
|
public:
|
|
MainWindow(
|
|
BaseObjectType* cast_item,
|
|
Glib::RefPtr<Gtk::Builder> const& builder,
|
|
Gtk::Application& app,
|
|
Glib::RefPtr<Gio::ActionGroup> const& actions,
|
|
Glib::RefPtr<Session> const& core);
|
|
~MainWindow() override;
|
|
|
|
TR_DISABLE_COPY_MOVE(MainWindow)
|
|
|
|
static std::unique_ptr<MainWindow> create(
|
|
Gtk::Application& app,
|
|
Glib::RefPtr<Gio::ActionGroup> const& actions,
|
|
Glib::RefPtr<Session> const& core);
|
|
|
|
void for_each_selected_torrent(std::function<void(Glib::RefPtr<Torrent> const&)> callback) const;
|
|
bool for_each_selected_torrent_until(std::function<bool(Glib::RefPtr<Torrent> const&)> callback) const;
|
|
|
|
void select_all();
|
|
void unselect_all();
|
|
|
|
void set_busy(bool isBusy);
|
|
void refresh();
|
|
|
|
sigc::signal<void()>& signal_selection_changed();
|
|
|
|
private:
|
|
class Impl;
|
|
std::unique_ptr<Impl> const impl_;
|
|
};
|