2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2007-2022 Mnemosyne LLC.
|
2022-02-07 16:25:02 +00:00
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
2022-01-20 18:27:56 +00:00
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2022-07-26 02:45:54 +00:00
|
|
|
#include <algorithm> // std::max()
|
2021-12-16 22:58:58 +00:00
|
|
|
#include <cstring> // strchr()
|
2022-01-13 02:13:58 +00:00
|
|
|
#include <memory>
|
2022-03-21 14:15:48 +00:00
|
|
|
#include <optional>
|
2022-04-08 01:50:26 +00:00
|
|
|
#include <string>
|
2022-07-26 02:45:54 +00:00
|
|
|
#include <string_view>
|
2021-10-18 20:22:31 +00:00
|
|
|
|
|
|
|
#include <glibmm.h>
|
|
|
|
#include <glibmm/i18n.h>
|
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
#include <fmt/core.h>
|
|
|
|
|
2007-12-19 02:46:30 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2017-04-21 07:40:57 +00:00
|
|
|
#include <libtransmission/utils.h> /* tr_truncd() */
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-09-07 22:25:04 +00:00
|
|
|
#include "HigWorkarea.h" // GUI_PAD, GUI_PAD_SMALL
|
2021-11-01 00:11:23 +00:00
|
|
|
#include "IconCache.h"
|
|
|
|
#include "TorrentCellRenderer.h"
|
|
|
|
#include "Utils.h"
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2008-02-16 19:36:07 +00:00
|
|
|
/* #define TEST_RTL */
|
|
|
|
|
2007-12-19 02:46:30 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2021-12-14 08:43:27 +00:00
|
|
|
auto const DefaultBarHeight = 12;
|
|
|
|
auto const CompactBarWidth = 50;
|
|
|
|
auto const SmallScale = 0.9;
|
2022-10-08 22:50:03 +00:00
|
|
|
auto const CompactIconSize = IF_GTKMM4(Gtk::IconSize::NORMAL, Gtk::ICON_SIZE_MENU);
|
|
|
|
auto const FullIconSize = IF_GTKMM4(Gtk::IconSize::LARGE, Gtk::ICON_SIZE_DND);
|
2021-12-14 08:43:27 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto get_height(Gtk::Requisition const& req)
|
|
|
|
{
|
|
|
|
return req.IF_GTKMM4(get_height(), height);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto get_width(Gtk::Requisition const& req)
|
|
|
|
{
|
|
|
|
return req.IF_GTKMM4(get_width(), width);
|
|
|
|
}
|
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
auto getProgressString(tr_torrent const* tor, uint64_t total_size, tr_stat const* st)
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
Glib::ustring gstr;
|
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
bool const isDone = st->leftUntilDone == 0;
|
2017-04-20 16:02:19 +00:00
|
|
|
uint64_t const haveTotal = st->haveUnchecked + st->haveValid;
|
2021-12-08 16:55:52 +00:00
|
|
|
bool const isSeed = st->haveValid >= total_size;
|
2022-11-13 17:36:16 +00:00
|
|
|
double seedRatio = 0;
|
2017-04-30 16:25:26 +00:00
|
|
|
bool const hasSeedRatio = tr_torrentGetSeedRatio(tor, &seedRatio);
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
if (!isDone) // downloading
|
2009-03-01 16:00:41 +00:00
|
|
|
{
|
2022-03-21 14:15:48 +00:00
|
|
|
// 50 MB of 200 MB (25%)
|
|
|
|
gstr += fmt::format(
|
|
|
|
_("{current_size} of {complete_size} ({percent_done}%)"),
|
|
|
|
fmt::arg("current_size", tr_strlsize(haveTotal)),
|
|
|
|
fmt::arg("complete_size", tr_strlsize(st->sizeWhenDone)),
|
2022-04-01 16:29:05 +00:00
|
|
|
fmt::arg("percent_done", tr_strpercent(st->percentDone * 100.0)));
|
2009-03-01 16:00:41 +00:00
|
|
|
}
|
2022-03-21 14:15:48 +00:00
|
|
|
else if (!isSeed && hasSeedRatio) // partial seed, seed ratio
|
2009-03-01 16:00:41 +00:00
|
|
|
{
|
2022-03-21 14:15:48 +00:00
|
|
|
// 50 MB of 200 MB (25%), uploaded 30 MB (Ratio: X%, Goal: Y%)
|
|
|
|
gstr += fmt::format(
|
2022-06-08 06:04:17 +00:00
|
|
|
// xgettext:no-c-format
|
2022-03-21 14:15:48 +00:00
|
|
|
_("{current_size} of {complete_size} ({percent_complete}%), uploaded {uploaded_size} (Ratio: {ratio}, Goal: {seed_ratio})"),
|
|
|
|
fmt::arg("current_size", tr_strlsize(haveTotal)),
|
|
|
|
fmt::arg("complete_size", tr_strlsize(total_size)),
|
2022-04-01 16:29:05 +00:00
|
|
|
fmt::arg("percent_complete", tr_strpercent(st->percentComplete * 100.0)),
|
2022-03-21 14:15:48 +00:00
|
|
|
fmt::arg("uploaded_size", tr_strlsize(st->uploadedEver)),
|
|
|
|
fmt::arg("ratio", tr_strlratio(st->ratio)),
|
|
|
|
fmt::arg("seed_ratio", tr_strlratio(seedRatio)));
|
2009-03-01 16:00:41 +00:00
|
|
|
}
|
2022-03-21 14:15:48 +00:00
|
|
|
else if (!isSeed) // partial seed, no seed ratio
|
2009-03-01 16:00:41 +00:00
|
|
|
{
|
2022-03-21 14:15:48 +00:00
|
|
|
gstr += fmt::format(
|
2022-06-08 06:04:17 +00:00
|
|
|
// xgettext:no-c-format
|
2022-03-21 14:15:48 +00:00
|
|
|
_("{current_size} of {complete_size} ({percent_complete}%), uploaded {uploaded_size} (Ratio: {ratio})"),
|
|
|
|
fmt::arg("current_size", tr_strlsize(haveTotal)),
|
|
|
|
fmt::arg("complete_size", tr_strlsize(total_size)),
|
2022-04-01 16:29:05 +00:00
|
|
|
fmt::arg("percent_complete", tr_strpercent(st->percentComplete * 100.0)),
|
2022-03-21 14:15:48 +00:00
|
|
|
fmt::arg("uploaded_size", tr_strlsize(st->uploadedEver)),
|
|
|
|
fmt::arg("ratio", tr_strlratio(st->ratio)));
|
|
|
|
}
|
|
|
|
else if (hasSeedRatio) // seed, seed ratio
|
|
|
|
{
|
|
|
|
gstr += fmt::format(
|
|
|
|
_("{complete_size}, uploaded {uploaded_size} (Ratio: {ratio}, Goal: {seed_ratio})"),
|
|
|
|
fmt::arg("complete_size", tr_strlsize(total_size)),
|
|
|
|
fmt::arg("uploaded_size", tr_strlsize(st->uploadedEver)),
|
|
|
|
fmt::arg("ratio", tr_strlratio(st->ratio)),
|
|
|
|
fmt::arg("seed_ratio", tr_strlratio(seedRatio)));
|
|
|
|
}
|
|
|
|
else // seed, no seed ratio
|
|
|
|
{
|
|
|
|
gstr += fmt::format(
|
|
|
|
_("{complete_size}, uploaded {uploaded_size} (Ratio: {ratio})"),
|
|
|
|
fmt::arg("complete_size", tr_strlsize(total_size)),
|
|
|
|
fmt::arg("uploaded_size", tr_strlsize(st->uploadedEver)),
|
|
|
|
fmt::arg("ratio", tr_strlratio(st->ratio)));
|
2009-03-01 16:00:41 +00:00
|
|
|
}
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
// add time remaining when applicable
|
2017-04-30 16:25:26 +00:00
|
|
|
if (st->activity == TR_STATUS_DOWNLOAD || (hasSeedRatio && st->activity == TR_STATUS_SEED))
|
2008-02-09 16:05:29 +00:00
|
|
|
{
|
2017-04-20 16:02:19 +00:00
|
|
|
int const eta = st->eta;
|
2021-10-18 20:22:31 +00:00
|
|
|
gstr += " - ";
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
if (eta < 0)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
gstr += _("Remaining time unknown");
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
else
|
|
|
|
{
|
2022-06-15 02:56:27 +00:00
|
|
|
gstr += tr_format_time_left(eta);
|
2008-02-09 16:05:29 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-18 20:22:31 +00:00
|
|
|
|
|
|
|
return gstr;
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
std::string getShortTransferString(
|
|
|
|
tr_torrent const* const tor,
|
|
|
|
tr_stat const* const st,
|
2021-08-15 09:41:48 +00:00
|
|
|
double uploadSpeed_KBps,
|
2021-10-18 20:22:31 +00:00
|
|
|
double downloadSpeed_KBps)
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-03-21 14:15:48 +00:00
|
|
|
bool const have_meta = tr_torrentHasMetadata(tor);
|
2013-01-27 23:05:47 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
if (bool const have_down = have_meta && (st->peersSendingToUs > 0 || st->webseedsSendingToUs > 0); have_down)
|
2013-01-27 23:05:47 +00:00
|
|
|
{
|
2022-03-21 14:15:48 +00:00
|
|
|
return fmt::format(
|
2022-04-23 03:41:30 +00:00
|
|
|
_("{download_speed} ▼ {upload_speed} ▲"),
|
2022-03-25 17:16:29 +00:00
|
|
|
fmt::arg("upload_speed", tr_formatter_speed_KBps(uploadSpeed_KBps)),
|
|
|
|
fmt::arg("download_speed", tr_formatter_speed_KBps(downloadSpeed_KBps)));
|
2013-01-27 23:05:47 +00:00
|
|
|
}
|
2022-02-08 05:44:31 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
if (bool const have_up = have_meta && st->peersGettingFromUs > 0; have_up)
|
2013-01-27 23:05:47 +00:00
|
|
|
{
|
2022-08-01 14:34:30 +00:00
|
|
|
return fmt::format(_("{upload_speed} ▲"), fmt::arg("upload_speed", tr_formatter_speed_KBps(uploadSpeed_KBps)));
|
2013-01-27 23:05:47 +00:00
|
|
|
}
|
2022-02-08 05:44:31 +00:00
|
|
|
|
|
|
|
if (st->isStalled)
|
2013-01-27 23:05:47 +00:00
|
|
|
{
|
2022-02-08 05:44:31 +00:00
|
|
|
return _("Stalled");
|
2013-01-27 23:05:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-08 05:44:31 +00:00
|
|
|
return {};
|
2007-12-20 02:02:51 +00:00
|
|
|
}
|
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
std::string getShortStatusString(
|
|
|
|
tr_torrent const* const tor,
|
|
|
|
tr_stat const* const st,
|
|
|
|
double uploadSpeed_KBps,
|
|
|
|
double downloadSpeed_KBps)
|
2007-12-20 02:02:51 +00:00
|
|
|
{
|
2012-12-05 17:29:46 +00:00
|
|
|
switch (st->activity)
|
2007-12-19 18:11:10 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
case TR_STATUS_STOPPED:
|
2022-03-21 14:15:48 +00:00
|
|
|
return st->finished ? _("Finished") : _("Paused");
|
2011-08-08 16:38:22 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
case TR_STATUS_CHECK_WAIT:
|
2022-03-21 14:15:48 +00:00
|
|
|
return _("Queued for verification");
|
2011-08-01 22:24:24 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
case TR_STATUS_DOWNLOAD_WAIT:
|
2022-03-21 14:15:48 +00:00
|
|
|
return _("Queued for download");
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
case TR_STATUS_SEED_WAIT:
|
2022-03-21 14:15:48 +00:00
|
|
|
return _("Queued for seeding");
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
case TR_STATUS_CHECK:
|
2022-03-21 14:15:48 +00:00
|
|
|
return fmt::format(
|
2022-06-08 06:04:17 +00:00
|
|
|
// xgettext:no-c-format
|
2022-04-01 16:29:05 +00:00
|
|
|
_("Verifying local data ({percent_done}% tested)"),
|
2022-03-21 14:15:48 +00:00
|
|
|
fmt::arg("percent_done", tr_truncd(st->recheckProgress * 100.0, 1)));
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
case TR_STATUS_DOWNLOAD:
|
|
|
|
case TR_STATUS_SEED:
|
2022-03-21 14:15:48 +00:00
|
|
|
return fmt::format(
|
2022-03-30 19:59:13 +00:00
|
|
|
FMT_STRING("{:s} {:s}"),
|
2022-03-21 14:15:48 +00:00
|
|
|
getShortTransferString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps),
|
|
|
|
fmt::format(_("Ratio: {ratio}"), fmt::arg("ratio", tr_strlratio(st->ratio))));
|
2007-12-19 18:11:10 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
default:
|
2022-03-21 14:15:48 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-25 05:24:04 +00:00
|
|
|
std::optional<std::string> getErrorString(tr_stat const* st)
|
2022-03-21 14:15:48 +00:00
|
|
|
{
|
|
|
|
switch (st->error)
|
|
|
|
{
|
|
|
|
case TR_STAT_TRACKER_WARNING:
|
|
|
|
return fmt::format(_("Tracker warning: '{warning}'"), fmt::arg("warning", st->errorString));
|
|
|
|
|
|
|
|
case TR_STAT_TRACKER_ERROR:
|
|
|
|
return fmt::format(_("Tracker Error: '{error}'"), fmt::arg("error", st->errorString));
|
|
|
|
|
|
|
|
case TR_STAT_LOCAL_ERROR:
|
|
|
|
return fmt::format(_("Local error: '{error}'"), fmt::arg("error", st->errorString));
|
|
|
|
|
|
|
|
default:
|
|
|
|
return std::nullopt;
|
2007-12-19 18:11:10 +00:00
|
|
|
}
|
2022-03-21 14:15:48 +00:00
|
|
|
}
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-03-25 05:24:04 +00:00
|
|
|
auto getActivityString(
|
2022-03-21 14:15:48 +00:00
|
|
|
tr_torrent const* const tor,
|
|
|
|
tr_stat const* const st,
|
|
|
|
double const uploadSpeed_KBps,
|
|
|
|
double const downloadSpeed_KBps)
|
|
|
|
{
|
|
|
|
switch (st->activity)
|
|
|
|
{
|
|
|
|
case TR_STATUS_STOPPED:
|
|
|
|
case TR_STATUS_CHECK_WAIT:
|
|
|
|
case TR_STATUS_CHECK:
|
|
|
|
case TR_STATUS_DOWNLOAD_WAIT:
|
|
|
|
case TR_STATUS_SEED_WAIT:
|
|
|
|
return getShortStatusString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps);
|
|
|
|
|
|
|
|
case TR_STATUS_DOWNLOAD:
|
|
|
|
if (!tr_torrentHasMetadata(tor))
|
|
|
|
{
|
|
|
|
return fmt::format(
|
|
|
|
ngettext(
|
2022-06-08 06:04:17 +00:00
|
|
|
// xgettext:no-c-format
|
2022-07-18 15:33:11 +00:00
|
|
|
"Downloading metadata from {active_count} connected peer ({percent_done}% done)",
|
|
|
|
"Downloading metadata from {active_count} connected peers ({percent_done}% done)",
|
2022-03-21 14:15:48 +00:00
|
|
|
st->peersConnected),
|
|
|
|
fmt::arg("active_count", st->peersConnected),
|
2022-04-01 16:29:05 +00:00
|
|
|
fmt::arg("percent_done", tr_strpercent(st->metadataPercentComplete * 100.0)));
|
2022-03-21 14:15:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (st->peersSendingToUs != 0 && st->webseedsSendingToUs != 0)
|
|
|
|
{
|
|
|
|
return fmt::format(
|
|
|
|
ngettext(
|
|
|
|
"Downloading from {active_count} of {connected_count} connected peer and webseed",
|
|
|
|
"Downloading from {active_count} of {connected_count} connected peers and webseeds",
|
|
|
|
st->peersConnected + st->webseedsSendingToUs),
|
|
|
|
fmt::arg("active_count", st->peersSendingToUs + st->webseedsSendingToUs),
|
|
|
|
fmt::arg("connected_count", st->peersConnected + st->webseedsSendingToUs));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (st->webseedsSendingToUs != 0)
|
|
|
|
{
|
|
|
|
return fmt::format(
|
|
|
|
ngettext(
|
|
|
|
"Downloading from {active_count} webseed",
|
|
|
|
"Downloading from {active_count} webseeds",
|
|
|
|
st->webseedsSendingToUs),
|
|
|
|
fmt::arg("active_count", st->webseedsSendingToUs));
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt::format(
|
|
|
|
ngettext(
|
|
|
|
"Downloading from {active_count} of {connected_count} connected peer",
|
|
|
|
"Downloading from {active_count} of {connected_count} connected peers",
|
|
|
|
st->peersConnected),
|
|
|
|
fmt::arg("active_count", st->peersSendingToUs),
|
|
|
|
fmt::arg("connected_count", st->peersConnected));
|
|
|
|
|
|
|
|
case TR_STATUS_SEED:
|
|
|
|
return fmt::format(
|
|
|
|
ngettext(
|
|
|
|
"Seeding to {active_count} of {connected_count} connected peer",
|
|
|
|
"Seeding to {active_count} of {connected_count} connected peers",
|
|
|
|
st->peersConnected),
|
|
|
|
fmt::arg("active_count", st->peersGettingFromUs),
|
|
|
|
fmt::arg("connected_count", st->peersConnected));
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
return std::string{};
|
|
|
|
}
|
2007-12-19 18:11:10 +00:00
|
|
|
}
|
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
std::string getStatusString(
|
2021-08-15 09:41:48 +00:00
|
|
|
tr_torrent const* tor,
|
|
|
|
tr_stat const* st,
|
|
|
|
double const uploadSpeed_KBps,
|
2022-10-08 22:50:03 +00:00
|
|
|
double const downloadSpeed_KBps,
|
|
|
|
bool ignore_errors = false)
|
2007-12-19 18:11:10 +00:00
|
|
|
{
|
2022-10-08 22:50:03 +00:00
|
|
|
auto status_str = (ignore_errors ? std::nullopt : getErrorString(st))
|
|
|
|
.value_or(getActivityString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps));
|
2009-11-24 15:51:16 +00:00
|
|
|
|
2017-04-30 16:25:26 +00:00
|
|
|
if (st->activity != TR_STATUS_CHECK_WAIT && st->activity != TR_STATUS_CHECK && st->activity != TR_STATUS_DOWNLOAD_WAIT &&
|
|
|
|
st->activity != TR_STATUS_SEED_WAIT && st->activity != TR_STATUS_STOPPED)
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-03-21 14:15:48 +00:00
|
|
|
if (auto const buf = getShortTransferString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps); !std::empty(buf))
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2022-03-30 19:59:13 +00:00
|
|
|
status_str += fmt::format(FMT_STRING(" - {:s}"), buf);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-03-21 14:15:48 +00:00
|
|
|
return status_str;
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
} // namespace
|
|
|
|
|
2007-12-19 02:46:30 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
class TorrentCellRenderer::Impl
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-10-18 23:17:54 +00:00
|
|
|
using SnapshotPtr = TorrentCellRenderer::SnapshotPtr;
|
2022-10-08 22:50:03 +00:00
|
|
|
using IconSize = IF_GTKMM4(Gtk::IconSize, Gtk::BuiltinIconSize);
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
public:
|
2021-12-14 08:43:27 +00:00
|
|
|
explicit Impl(TorrentCellRenderer& renderer);
|
2021-10-18 20:22:31 +00:00
|
|
|
~Impl();
|
|
|
|
|
2021-12-14 08:43:27 +00:00
|
|
|
TR_DISABLE_COPY_MOVE(Impl)
|
|
|
|
|
2022-11-15 19:30:32 +00:00
|
|
|
Gtk::Requisition get_size_compact(Gtk::Widget& widget) const;
|
|
|
|
Gtk::Requisition get_size_full(Gtk::Widget& widget) const;
|
2021-10-18 20:22:31 +00:00
|
|
|
|
|
|
|
void render_compact(
|
2022-10-18 23:17:54 +00:00
|
|
|
SnapshotPtr const& snapshot,
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Widget& widget,
|
|
|
|
Gdk::Rectangle const& background_area,
|
|
|
|
Gtk::CellRendererState flags);
|
|
|
|
void render_full(
|
2022-10-18 23:17:54 +00:00
|
|
|
SnapshotPtr const& snapshot,
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Widget& widget,
|
|
|
|
Gdk::Rectangle const& background_area,
|
|
|
|
Gtk::CellRendererState flags);
|
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto& property_torrent()
|
|
|
|
{
|
|
|
|
return property_torrent_;
|
|
|
|
}
|
2009-08-07 20:49:06 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto& property_bar_height()
|
|
|
|
{
|
|
|
|
return property_bar_height_;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto& property_upload_speed_KBps()
|
|
|
|
{
|
|
|
|
return property_upload_speed_KBps_;
|
|
|
|
}
|
2009-08-07 20:49:06 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto& property_download_speed_KBps()
|
|
|
|
{
|
|
|
|
return property_download_speed_KBps_;
|
|
|
|
}
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto& property_compact()
|
|
|
|
{
|
|
|
|
return property_compact_;
|
|
|
|
}
|
2009-08-07 20:49:06 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
private:
|
2022-10-18 23:17:54 +00:00
|
|
|
void render_progress_bar(
|
|
|
|
SnapshotPtr const& snapshot,
|
|
|
|
Gtk::Widget& widget,
|
|
|
|
Gdk::Rectangle const& area,
|
|
|
|
Gtk::CellRendererState flags,
|
|
|
|
Gdk::RGBA const& color);
|
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
static void set_icon(Gtk::CellRendererPixbuf& renderer, Glib::RefPtr<Gio::Icon> const& icon, IconSize icon_size);
|
2022-10-18 23:17:54 +00:00
|
|
|
static void adjust_progress_bar_hue(
|
|
|
|
Cairo::RefPtr<Cairo::Surface> const& bg_surface,
|
|
|
|
Cairo::RefPtr<Cairo::Context> const& context,
|
|
|
|
Gdk::RGBA const& color,
|
|
|
|
Gdk::Rectangle const& area,
|
|
|
|
double bg_x,
|
|
|
|
double bg_y);
|
2022-10-08 22:50:03 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
private:
|
|
|
|
TorrentCellRenderer& renderer_;
|
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
Glib::Property<gpointer> property_torrent_;
|
|
|
|
Glib::Property<int> property_bar_height_;
|
|
|
|
Glib::Property<double> property_upload_speed_KBps_;
|
|
|
|
Glib::Property<double> property_download_speed_KBps_;
|
|
|
|
Glib::Property<bool> property_compact_;
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::CellRendererText* text_renderer_ = nullptr;
|
|
|
|
Gtk::CellRendererProgress* progress_renderer_ = nullptr;
|
|
|
|
Gtk::CellRendererPixbuf* icon_renderer_ = nullptr;
|
|
|
|
};
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2009-03-02 23:31:01 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
namespace
|
2009-03-02 23:31:01 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
Glib::RefPtr<Gio::Icon> get_icon(tr_torrent const* tor)
|
2021-10-18 20:22:31 +00:00
|
|
|
{
|
2022-04-26 23:24:07 +00:00
|
|
|
auto mime_type = std::string_view{};
|
2009-03-02 23:31:01 +00:00
|
|
|
|
2021-12-01 23:11:57 +00:00
|
|
|
if (auto const n_files = tr_torrentFileCount(tor); n_files == 0)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-12-14 08:43:27 +00:00
|
|
|
mime_type = UnknownMimeType;
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2021-11-28 03:17:47 +00:00
|
|
|
else if (n_files > 1)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-12-14 08:43:27 +00:00
|
|
|
mime_type = DirectoryMimeType;
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2009-03-02 23:31:01 +00:00
|
|
|
else
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2021-11-28 03:17:47 +00:00
|
|
|
auto const* const name = tr_torrentFile(tor, 0).name;
|
|
|
|
|
2022-04-26 23:24:07 +00:00
|
|
|
mime_type = strchr(name, '/') != nullptr ? DirectoryMimeType : tr_get_mime_type_for_filename(name);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2009-03-02 23:31:01 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
return gtr_get_mime_type_icon(mime_type);
|
2009-03-02 23:31:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
} // namespace
|
|
|
|
|
2009-03-02 23:31:01 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
void TorrentCellRenderer::Impl::set_icon(
|
|
|
|
Gtk::CellRendererPixbuf& renderer,
|
|
|
|
Glib::RefPtr<Gio::Icon> const& icon,
|
|
|
|
IconSize icon_size)
|
|
|
|
{
|
|
|
|
renderer.property_gicon() = icon;
|
|
|
|
#if GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
renderer.property_icon_size() = icon_size;
|
|
|
|
#else
|
|
|
|
renderer.property_stock_size() = icon_size;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-11-15 19:30:32 +00:00
|
|
|
Gtk::Requisition TorrentCellRenderer::Impl::get_size_compact(Gtk::Widget& widget) const
|
2009-03-02 23:31:01 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
int xpad = 0;
|
|
|
|
int ypad = 0;
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Requisition min_size;
|
|
|
|
Gtk::Requisition icon_size;
|
|
|
|
Gtk::Requisition name_size;
|
|
|
|
Gtk::Requisition stat_size;
|
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto* const tor = static_cast<tr_torrent*>(property_torrent_.get_value());
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const* const st = tr_torrentStatCached(tor);
|
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
auto const icon = get_icon(tor);
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const name = Glib::ustring(tr_torrentName(tor));
|
2022-11-13 17:36:16 +00:00
|
|
|
auto const gstr_stat = getShortStatusString(
|
|
|
|
tor,
|
|
|
|
st,
|
|
|
|
property_upload_speed_KBps_.get_value(),
|
|
|
|
property_download_speed_KBps_.get_value());
|
2021-10-18 20:22:31 +00:00
|
|
|
renderer_.get_padding(xpad, ypad);
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* get the idealized cell dimensions */
|
2022-10-08 22:50:03 +00:00
|
|
|
set_icon(*icon_renderer_, icon, CompactIconSize);
|
2021-10-18 20:22:31 +00:00
|
|
|
icon_renderer_->get_preferred_size(widget, min_size, icon_size);
|
|
|
|
text_renderer_->property_text() = name;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_ellipsize() = TR_PANGO_ELLIPSIZE_MODE(NONE);
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_scale() = 1.0;
|
|
|
|
text_renderer_->get_preferred_size(widget, min_size, name_size);
|
|
|
|
text_renderer_->property_text() = gstr_stat;
|
2021-12-14 08:43:27 +00:00
|
|
|
text_renderer_->property_scale() = SmallScale;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->get_preferred_size(widget, min_size, stat_size);
|
2009-08-10 20:04:08 +00:00
|
|
|
|
2009-03-02 23:31:01 +00:00
|
|
|
/**
|
|
|
|
*** LAYOUT
|
|
|
|
**/
|
|
|
|
|
2022-11-15 19:30:32 +00:00
|
|
|
return { xpad * 2 + get_width(icon_size) + GUI_PAD + CompactBarWidth + GUI_PAD + get_width(stat_size),
|
|
|
|
ypad * 2 + std::max(get_height(name_size), property_bar_height_.get_value()) };
|
2009-03-02 23:31:01 +00:00
|
|
|
}
|
|
|
|
|
2022-11-15 19:30:32 +00:00
|
|
|
Gtk::Requisition TorrentCellRenderer::Impl::get_size_full(Gtk::Widget& widget) const
|
2009-03-02 23:31:01 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
int xpad = 0;
|
|
|
|
int ypad = 0;
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Requisition min_size;
|
|
|
|
Gtk::Requisition icon_size;
|
|
|
|
Gtk::Requisition name_size;
|
|
|
|
Gtk::Requisition stat_size;
|
|
|
|
Gtk::Requisition prog_size;
|
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto* const tor = static_cast<tr_torrent*>(property_torrent_.get_value());
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const* const st = tr_torrentStatCached(tor);
|
2021-12-14 21:59:44 +00:00
|
|
|
auto const total_size = tr_torrentTotalSize(tor);
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
auto const icon = get_icon(tor);
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const name = Glib::ustring(tr_torrentName(tor));
|
2022-11-13 17:36:16 +00:00
|
|
|
auto const gstr_stat = getStatusString(
|
|
|
|
tor,
|
|
|
|
st,
|
|
|
|
property_upload_speed_KBps_.get_value(),
|
|
|
|
property_download_speed_KBps_.get_value(),
|
|
|
|
true);
|
2021-12-08 16:55:52 +00:00
|
|
|
auto const gstr_prog = getProgressString(tor, total_size, st);
|
2021-10-18 20:22:31 +00:00
|
|
|
renderer_.get_padding(xpad, ypad);
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* get the idealized cell dimensions */
|
2022-10-08 22:50:03 +00:00
|
|
|
set_icon(*icon_renderer_, icon, FullIconSize);
|
2021-10-18 20:22:31 +00:00
|
|
|
icon_renderer_->get_preferred_size(widget, min_size, icon_size);
|
|
|
|
text_renderer_->property_text() = name;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_weight() = TR_PANGO_WEIGHT(BOLD);
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_scale() = 1.0;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_ellipsize() = TR_PANGO_ELLIPSIZE_MODE(NONE);
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->get_preferred_size(widget, min_size, name_size);
|
|
|
|
text_renderer_->property_text() = gstr_prog;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_weight() = TR_PANGO_WEIGHT(NORMAL);
|
2021-12-14 08:43:27 +00:00
|
|
|
text_renderer_->property_scale() = SmallScale;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->get_preferred_size(widget, min_size, prog_size);
|
|
|
|
text_renderer_->property_text() = gstr_stat;
|
|
|
|
text_renderer_->get_preferred_size(widget, min_size, stat_size);
|
2009-08-10 20:04:08 +00:00
|
|
|
|
2009-03-02 23:31:01 +00:00
|
|
|
/**
|
|
|
|
*** LAYOUT
|
|
|
|
**/
|
|
|
|
|
2022-11-15 19:30:32 +00:00
|
|
|
return { xpad * 2 + get_width(icon_size) + GUI_PAD + std::max(get_width(prog_size), get_width(stat_size)),
|
|
|
|
ypad * 2 + get_height(name_size) + get_height(prog_size) + GUI_PAD_SMALL + property_bar_height_.get_value() +
|
|
|
|
GUI_PAD_SMALL + get_height(stat_size) };
|
2009-03-02 23:31:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void TorrentCellRenderer::get_preferred_width_vfunc(Gtk::Widget& widget, int& minimum_width, int& natural_width) const
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
if (impl_->property_torrent().get_value() != nullptr)
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-11-15 19:30:32 +00:00
|
|
|
auto const size = impl_->property_compact().get_value() ? impl_->get_size_compact(widget) :
|
|
|
|
impl_->get_size_full(widget);
|
2007-12-19 20:04:38 +00:00
|
|
|
|
2022-11-15 19:30:32 +00:00
|
|
|
minimum_width = get_width(size);
|
|
|
|
natural_width = minimum_width;
|
2021-10-18 20:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void TorrentCellRenderer::get_preferred_height_vfunc(Gtk::Widget& widget, int& minimum_height, int& natural_height) const
|
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
if (impl_->property_torrent().get_value() != nullptr)
|
2021-10-18 20:22:31 +00:00
|
|
|
{
|
2022-11-15 19:30:32 +00:00
|
|
|
auto const size = impl_->property_compact().get_value() ? impl_->get_size_compact(widget) :
|
|
|
|
impl_->get_size_full(widget);
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-11-15 19:30:32 +00:00
|
|
|
minimum_height = get_height(size);
|
|
|
|
natural_height = minimum_height;
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
namespace
|
|
|
|
{
|
2011-07-26 01:02:32 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
int get_percent_done(tr_torrent const* tor, tr_stat const* st)
|
2011-05-28 00:09:15 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
auto const seed = st->activity == TR_STATUS_SEED && tr_torrentGetSeedRatio(tor, nullptr);
|
2022-11-16 10:14:09 +00:00
|
|
|
return static_cast<int>((seed ? std::max(0.0F, st->seedRatioPercentDone) : std::max(0.0F, st->percentDone)) * 100);
|
2011-05-28 00:09:15 +00:00
|
|
|
}
|
|
|
|
|
2022-10-18 23:17:54 +00:00
|
|
|
Gdk::RGBA const& get_progress_bar_color(tr_stat const& st)
|
|
|
|
{
|
|
|
|
static auto const steelblue_color = Gdk::RGBA("steelblue");
|
|
|
|
static auto const forestgreen_color = Gdk::RGBA("forestgreen");
|
|
|
|
static auto const silver_color = Gdk::RGBA("silver");
|
|
|
|
|
|
|
|
return st.activity == TR_STATUS_DOWNLOAD ? steelblue_color :
|
|
|
|
(st.activity == TR_STATUS_SEED ? forestgreen_color : silver_color);
|
|
|
|
}
|
|
|
|
|
|
|
|
Cairo::RefPtr<Cairo::Surface> get_mask_surface(Cairo::RefPtr<Cairo::Surface> const& surface, Gdk::Rectangle const& area)
|
|
|
|
{
|
|
|
|
auto const mask_surface = Cairo::ImageSurface::create(TR_CAIRO_SURFACE_FORMAT(A8), area.get_width(), area.get_height());
|
|
|
|
auto const mask_context = Cairo::Context::create(mask_surface);
|
|
|
|
|
|
|
|
mask_context->set_source_rgb(0, 0, 0);
|
|
|
|
mask_context->rectangle(area.get_x(), area.get_y(), area.get_width(), area.get_height());
|
|
|
|
mask_context->fill();
|
|
|
|
|
|
|
|
mask_context->set_operator(TR_CAIRO_CONTEXT_OPERATOR(CLEAR));
|
|
|
|
mask_context->mask(surface, area.get_x(), area.get_y());
|
|
|
|
mask_context->fill();
|
|
|
|
|
|
|
|
return mask_surface;
|
|
|
|
}
|
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
template<typename... Ts>
|
|
|
|
void render_impl(Gtk::CellRenderer& renderer, Ts&&... args)
|
|
|
|
{
|
|
|
|
renderer.IF_GTKMM4(snapshot, render)(std::forward<Ts>(args)...);
|
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
} // namespace
|
2011-07-26 01:02:32 +00:00
|
|
|
|
2022-10-18 23:17:54 +00:00
|
|
|
void TorrentCellRenderer::Impl::adjust_progress_bar_hue(
|
|
|
|
Cairo::RefPtr<Cairo::Surface> const& bg_surface,
|
|
|
|
Cairo::RefPtr<Cairo::Context> const& context,
|
|
|
|
Gdk::RGBA const& color,
|
|
|
|
Gdk::Rectangle const& area,
|
|
|
|
double bg_x,
|
|
|
|
double bg_y)
|
|
|
|
{
|
|
|
|
using TrCairoContextOperator = IF_GTKMM4(Cairo::Context::Operator, Cairo::Operator);
|
|
|
|
|
|
|
|
auto const mask_surface = get_mask_surface(context->get_target(), area);
|
|
|
|
|
|
|
|
// Add background under the progress bar, for better results around the transparent areas
|
|
|
|
context->set_source(bg_surface, bg_x, bg_y);
|
|
|
|
context->set_operator(TR_CAIRO_CONTEXT_OPERATOR(DEST_OVER));
|
|
|
|
context->rectangle(area.get_x(), area.get_y(), area.get_width(), area.get_height());
|
|
|
|
context->fill();
|
|
|
|
|
|
|
|
// Adjust surface color
|
|
|
|
context->set_source_rgb(color.get_red(), color.get_green(), color.get_blue());
|
|
|
|
context->set_operator(static_cast<TrCairoContextOperator>(CAIRO_OPERATOR_HSL_COLOR));
|
|
|
|
context->rectangle(area.get_x(), area.get_y(), area.get_width(), area.get_height());
|
|
|
|
context->fill();
|
|
|
|
|
|
|
|
// Clear out masked (fully transparent) areas
|
|
|
|
context->set_operator(TR_CAIRO_CONTEXT_OPERATOR(CLEAR));
|
|
|
|
context->mask(mask_surface, area.get_x(), area.get_y());
|
|
|
|
context->fill();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TorrentCellRenderer::Impl::render_progress_bar(
|
|
|
|
SnapshotPtr const& snapshot,
|
|
|
|
Gtk::Widget& widget,
|
|
|
|
Gdk::Rectangle const& area,
|
|
|
|
Gtk::CellRendererState flags,
|
|
|
|
Gdk::RGBA const& color)
|
|
|
|
{
|
|
|
|
auto const temp_area = Gdk::Rectangle(0, 0, area.get_width(), area.get_height());
|
|
|
|
auto const temp_surface = Cairo::ImageSurface::create(TR_CAIRO_SURFACE_FORMAT(ARGB32), area.get_width(), area.get_height());
|
|
|
|
auto const temp_context = Cairo::Context::create(temp_surface);
|
|
|
|
|
|
|
|
{
|
|
|
|
#if GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
auto const temp_snapshot = Gtk::Snapshot::create();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
render_impl(*progress_renderer_, IF_GTKMM4(temp_snapshot, temp_context), widget, temp_area, temp_area, flags);
|
|
|
|
|
|
|
|
#if GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
temp_snapshot->reference();
|
|
|
|
auto const render_node = std::unique_ptr<GskRenderNode, void (*)(GskRenderNode*)>(
|
|
|
|
gtk_snapshot_free_to_node(Glib::unwrap(temp_snapshot)),
|
|
|
|
[](GskRenderNode* p) { gsk_render_node_unref(p); });
|
|
|
|
gsk_render_node_draw(render_node.get(), temp_context->cobj());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
auto const context = snapshot->append_cairo(area);
|
|
|
|
auto const surface = context->get_target();
|
|
|
|
#else
|
|
|
|
auto const context = snapshot;
|
|
|
|
auto const surface = Cairo::Surface::create(
|
|
|
|
context->get_target(),
|
|
|
|
area.get_x(),
|
|
|
|
area.get_y(),
|
|
|
|
area.get_width(),
|
|
|
|
area.get_height());
|
|
|
|
#endif
|
|
|
|
|
2022-11-09 16:58:36 +00:00
|
|
|
double dx = 0;
|
|
|
|
double dy = 0;
|
2022-10-18 23:17:54 +00:00
|
|
|
context->device_to_user(dx, dy);
|
|
|
|
|
|
|
|
adjust_progress_bar_hue(surface, temp_context, color, temp_area, dx - area.get_x(), dy - area.get_y());
|
|
|
|
|
|
|
|
context->set_source(temp_context->get_target(), area.get_x(), area.get_y());
|
|
|
|
context->rectangle(area.get_x(), area.get_y(), area.get_width(), area.get_height());
|
|
|
|
context->fill();
|
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void TorrentCellRenderer::Impl::render_compact(
|
2022-10-18 23:17:54 +00:00
|
|
|
SnapshotPtr const& snapshot,
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Widget& widget,
|
|
|
|
Gdk::Rectangle const& background_area,
|
|
|
|
Gtk::CellRendererState flags)
|
2011-07-26 01:02:32 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
int xpad = 0;
|
|
|
|
int ypad = 0;
|
|
|
|
int min_width = 0;
|
|
|
|
int width = 0;
|
2009-03-02 23:31:01 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto* const tor = static_cast<tr_torrent*>(property_torrent_.get_value());
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const* const st = tr_torrentStatCached(tor);
|
|
|
|
bool const active = st->activity != TR_STATUS_STOPPED && st->activity != TR_STATUS_DOWNLOAD_WAIT &&
|
2017-04-30 16:25:26 +00:00
|
|
|
st->activity != TR_STATUS_SEED_WAIT;
|
2022-11-13 17:36:16 +00:00
|
|
|
auto const percent_done = get_percent_done(tor, st);
|
2022-11-09 16:58:36 +00:00
|
|
|
bool const sensitive = active || st->error != 0;
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
if (st->activity == TR_STATUS_STOPPED)
|
|
|
|
{
|
|
|
|
flags |= TR_GTK_CELL_RENDERER_STATE(INSENSITIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (st->error != 0 && (flags & TR_GTK_CELL_RENDERER_STATE(SELECTED)) == Gtk::CellRendererState{})
|
|
|
|
{
|
|
|
|
text_renderer_->property_foreground() = "red";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text_renderer_->property_foreground_set() = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto const icon = get_icon(tor);
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const name = Glib::ustring(tr_torrentName(tor));
|
2022-10-18 23:17:54 +00:00
|
|
|
auto const& progress_color = get_progress_bar_color(*st);
|
2022-11-13 17:36:16 +00:00
|
|
|
auto const gstr_stat = getShortStatusString(
|
|
|
|
tor,
|
|
|
|
st,
|
|
|
|
property_upload_speed_KBps_.get_value(),
|
|
|
|
property_download_speed_KBps_.get_value());
|
2021-10-18 20:22:31 +00:00
|
|
|
renderer_.get_padding(xpad, ypad);
|
|
|
|
|
|
|
|
auto fill_area = background_area;
|
|
|
|
fill_area.set_x(fill_area.get_x() + xpad);
|
|
|
|
fill_area.set_y(fill_area.get_y() + ypad);
|
|
|
|
fill_area.set_width(fill_area.get_width() - xpad * 2);
|
|
|
|
fill_area.set_height(fill_area.get_height() - ypad * 2);
|
|
|
|
|
|
|
|
auto icon_area = fill_area;
|
2022-10-08 22:50:03 +00:00
|
|
|
set_icon(*icon_renderer_, icon, CompactIconSize);
|
2021-10-18 20:22:31 +00:00
|
|
|
icon_renderer_->get_preferred_width(widget, min_width, width);
|
|
|
|
icon_area.set_width(width);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
|
|
|
auto prog_area = fill_area;
|
2021-12-14 08:43:27 +00:00
|
|
|
prog_area.set_width(CompactBarWidth);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
|
|
|
auto stat_area = fill_area;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = gstr_stat;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_ellipsize() = TR_PANGO_ELLIPSIZE_MODE(NONE);
|
2021-12-14 08:43:27 +00:00
|
|
|
text_renderer_->property_scale() = SmallScale;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->get_preferred_width(widget, min_width, width);
|
|
|
|
stat_area.set_width(width);
|
|
|
|
|
2021-11-15 16:32:41 +00:00
|
|
|
auto name_area = fill_area;
|
|
|
|
name_area.set_width(
|
|
|
|
fill_area.get_width() - icon_area.get_width() - stat_area.get_width() - prog_area.get_width() - GUI_PAD * 3);
|
|
|
|
|
2022-09-10 13:19:54 +00:00
|
|
|
if ((renderer_.get_state(widget, flags) & TR_GTK_STATE_FLAGS(DIR_RTL)) == Gtk::StateFlags{})
|
2021-11-15 16:32:41 +00:00
|
|
|
{
|
|
|
|
icon_area.set_x(fill_area.get_x());
|
|
|
|
prog_area.set_x(fill_area.get_x() + fill_area.get_width() - prog_area.get_width());
|
|
|
|
stat_area.set_x(prog_area.get_x() - stat_area.get_width() - GUI_PAD);
|
|
|
|
name_area.set_x(icon_area.get_x() + icon_area.get_width() + GUI_PAD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
icon_area.set_x(fill_area.get_x() + fill_area.get_width() - icon_area.get_width());
|
|
|
|
prog_area.set_x(fill_area.get_x());
|
|
|
|
stat_area.set_x(prog_area.get_x() + prog_area.get_width() + GUI_PAD);
|
|
|
|
name_area.set_x(stat_area.get_x() + stat_area.get_width() + GUI_PAD);
|
|
|
|
}
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** RENDER
|
|
|
|
**/
|
2009-08-10 20:04:08 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
set_icon(*icon_renderer_, icon, CompactIconSize);
|
2021-10-18 20:22:31 +00:00
|
|
|
icon_renderer_->property_sensitive() = sensitive;
|
2022-10-18 23:17:54 +00:00
|
|
|
render_impl(*icon_renderer_, snapshot, widget, icon_area, icon_area, flags);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
2022-04-01 16:29:05 +00:00
|
|
|
progress_renderer_->property_value() = percent_done;
|
|
|
|
progress_renderer_->property_text() = fmt::format(FMT_STRING("{:d}%"), percent_done);
|
2021-10-18 20:22:31 +00:00
|
|
|
progress_renderer_->property_sensitive() = sensitive;
|
2022-10-18 23:17:54 +00:00
|
|
|
render_progress_bar(snapshot, widget, prog_area, flags, progress_color);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = gstr_stat;
|
2021-12-14 08:43:27 +00:00
|
|
|
text_renderer_->property_scale() = SmallScale;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_ellipsize() = TR_PANGO_ELLIPSIZE_MODE(END);
|
2022-10-18 23:17:54 +00:00
|
|
|
render_impl(*text_renderer_, snapshot, widget, stat_area, stat_area, flags);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = name;
|
|
|
|
text_renderer_->property_scale() = 1.0;
|
2022-10-18 23:17:54 +00:00
|
|
|
render_impl(*text_renderer_, snapshot, widget, name_area, name_area, flags);
|
2009-03-02 23:31:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
void TorrentCellRenderer::Impl::render_full(
|
2022-10-18 23:17:54 +00:00
|
|
|
SnapshotPtr const& snapshot,
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Widget& widget,
|
|
|
|
Gdk::Rectangle const& background_area,
|
|
|
|
Gtk::CellRendererState flags)
|
2009-03-02 23:31:01 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
int xpad = 0;
|
|
|
|
int ypad = 0;
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Requisition min_size;
|
|
|
|
Gtk::Requisition size;
|
2009-03-02 23:31:01 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
auto* const tor = static_cast<tr_torrent*>(property_torrent_.get_value());
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const* const st = tr_torrentStatCached(tor);
|
2021-12-14 21:59:44 +00:00
|
|
|
auto const total_size = tr_torrentTotalSize(tor);
|
2021-10-18 20:22:31 +00:00
|
|
|
bool const active = st->activity != TR_STATUS_STOPPED && st->activity != TR_STATUS_DOWNLOAD_WAIT &&
|
2017-04-30 16:25:26 +00:00
|
|
|
st->activity != TR_STATUS_SEED_WAIT;
|
2022-11-13 17:36:16 +00:00
|
|
|
auto const percent_done = get_percent_done(tor, st);
|
2022-11-09 16:58:36 +00:00
|
|
|
bool const sensitive = active || st->error != 0;
|
2021-10-18 20:22:31 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
if (st->activity == TR_STATUS_STOPPED)
|
|
|
|
{
|
|
|
|
flags |= TR_GTK_CELL_RENDERER_STATE(INSENSITIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (st->error != 0 && (flags & TR_GTK_CELL_RENDERER_STATE(SELECTED)) == Gtk::CellRendererState{})
|
|
|
|
{
|
|
|
|
text_renderer_->property_foreground() = "red";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text_renderer_->property_foreground_set() = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto const icon = get_icon(tor);
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const name = Glib::ustring(tr_torrentName(tor));
|
2022-10-18 23:17:54 +00:00
|
|
|
auto const& progress_color = get_progress_bar_color(*st);
|
2021-12-08 16:55:52 +00:00
|
|
|
auto const gstr_prog = getProgressString(tor, total_size, st);
|
2022-11-13 17:36:16 +00:00
|
|
|
auto const gstr_stat = getStatusString(
|
|
|
|
tor,
|
|
|
|
st,
|
|
|
|
property_upload_speed_KBps_.get_value(),
|
|
|
|
property_download_speed_KBps_.get_value());
|
2021-10-18 20:22:31 +00:00
|
|
|
renderer_.get_padding(xpad, ypad);
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* get the idealized cell dimensions */
|
2021-11-15 16:32:41 +00:00
|
|
|
Gdk::Rectangle icon_area;
|
2022-10-08 22:50:03 +00:00
|
|
|
set_icon(*icon_renderer_, icon, FullIconSize);
|
2021-10-18 20:22:31 +00:00
|
|
|
icon_renderer_->get_preferred_size(widget, min_size, size);
|
2022-11-13 17:36:16 +00:00
|
|
|
icon_area.set_width(get_width(size));
|
|
|
|
icon_area.set_height(get_height(size));
|
2021-11-15 16:32:41 +00:00
|
|
|
|
|
|
|
Gdk::Rectangle name_area;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = name;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_weight() = TR_PANGO_WEIGHT(BOLD);
|
|
|
|
text_renderer_->property_ellipsize() = TR_PANGO_ELLIPSIZE_MODE(NONE);
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_scale() = 1.0;
|
|
|
|
text_renderer_->get_preferred_size(widget, min_size, size);
|
2022-11-13 17:36:16 +00:00
|
|
|
name_area.set_height(get_height(size));
|
2021-11-15 16:32:41 +00:00
|
|
|
|
|
|
|
Gdk::Rectangle prog_area;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = gstr_prog;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_weight() = TR_PANGO_WEIGHT(NORMAL);
|
2021-12-14 08:43:27 +00:00
|
|
|
text_renderer_->property_scale() = SmallScale;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->get_preferred_size(widget, min_size, size);
|
2022-11-13 17:36:16 +00:00
|
|
|
prog_area.set_height(get_height(size));
|
2021-11-15 16:32:41 +00:00
|
|
|
|
|
|
|
Gdk::Rectangle stat_area;
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = gstr_stat;
|
|
|
|
text_renderer_->get_preferred_size(widget, min_size, size);
|
2022-11-13 17:36:16 +00:00
|
|
|
stat_area.set_height(get_height(size));
|
2009-08-10 20:04:08 +00:00
|
|
|
|
2021-11-15 16:32:41 +00:00
|
|
|
Gdk::Rectangle prct_area;
|
|
|
|
|
2009-03-02 23:31:01 +00:00
|
|
|
/**
|
|
|
|
*** LAYOUT
|
|
|
|
**/
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
auto fill_area = background_area;
|
|
|
|
fill_area.set_x(fill_area.get_x() + xpad);
|
|
|
|
fill_area.set_y(fill_area.get_y() + ypad);
|
|
|
|
fill_area.set_width(fill_area.get_width() - xpad * 2);
|
|
|
|
fill_area.set_height(fill_area.get_height() - ypad * 2);
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* icon */
|
2021-10-18 20:22:31 +00:00
|
|
|
icon_area.set_y(fill_area.get_y() + (fill_area.get_height() - icon_area.get_height()) / 2);
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* name */
|
2021-10-18 20:22:31 +00:00
|
|
|
name_area.set_y(fill_area.get_y());
|
2021-11-15 16:32:41 +00:00
|
|
|
name_area.set_width(fill_area.get_width() - GUI_PAD - icon_area.get_width());
|
|
|
|
|
2022-09-10 13:19:54 +00:00
|
|
|
if ((renderer_.get_state(widget, flags) & TR_GTK_STATE_FLAGS(DIR_RTL)) == Gtk::StateFlags{})
|
2021-11-15 16:32:41 +00:00
|
|
|
{
|
|
|
|
icon_area.set_x(fill_area.get_x());
|
|
|
|
name_area.set_x(fill_area.get_x() + fill_area.get_width() - name_area.get_width());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
icon_area.set_x(fill_area.get_x() + fill_area.get_width() - icon_area.get_width());
|
|
|
|
name_area.set_x(fill_area.get_x());
|
|
|
|
}
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* prog */
|
2021-10-18 20:22:31 +00:00
|
|
|
prog_area.set_x(name_area.get_x());
|
|
|
|
prog_area.set_y(name_area.get_y() + name_area.get_height());
|
|
|
|
prog_area.set_width(name_area.get_width());
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* progressbar */
|
2021-10-18 20:22:31 +00:00
|
|
|
prct_area.set_x(prog_area.get_x());
|
|
|
|
prct_area.set_y(prog_area.get_y() + prog_area.get_height() + GUI_PAD_SMALL);
|
|
|
|
prct_area.set_width(prog_area.get_width());
|
2022-11-13 17:36:16 +00:00
|
|
|
prct_area.set_height(property_bar_height_.get_value());
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/* status */
|
2021-10-18 20:22:31 +00:00
|
|
|
stat_area.set_x(prct_area.get_x());
|
|
|
|
stat_area.set_y(prct_area.get_y() + prct_area.get_height() + GUI_PAD_SMALL);
|
|
|
|
stat_area.set_width(prct_area.get_width());
|
2009-03-02 23:31:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** RENDER
|
|
|
|
**/
|
2009-08-10 20:04:08 +00:00
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
set_icon(*icon_renderer_, icon, FullIconSize);
|
2021-10-18 20:22:31 +00:00
|
|
|
icon_renderer_->property_sensitive() = sensitive;
|
2022-10-18 23:17:54 +00:00
|
|
|
render_impl(*icon_renderer_, snapshot, widget, icon_area, icon_area, flags);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = name;
|
|
|
|
text_renderer_->property_scale() = 1.0;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_ellipsize() = TR_PANGO_ELLIPSIZE_MODE(END);
|
|
|
|
text_renderer_->property_weight() = TR_PANGO_WEIGHT(BOLD);
|
2022-10-18 23:17:54 +00:00
|
|
|
render_impl(*text_renderer_, snapshot, widget, name_area, name_area, flags);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = gstr_prog;
|
2021-12-14 08:43:27 +00:00
|
|
|
text_renderer_->property_scale() = SmallScale;
|
2022-09-10 13:19:54 +00:00
|
|
|
text_renderer_->property_weight() = TR_PANGO_WEIGHT(NORMAL);
|
2022-10-18 23:17:54 +00:00
|
|
|
render_impl(*text_renderer_, snapshot, widget, prog_area, prog_area, flags);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
progress_renderer_->property_value() = percent_done;
|
2021-10-18 20:22:31 +00:00
|
|
|
progress_renderer_->property_text() = Glib::ustring();
|
|
|
|
progress_renderer_->property_sensitive() = sensitive;
|
2022-10-18 23:17:54 +00:00
|
|
|
render_progress_bar(snapshot, widget, prct_area, flags, progress_color);
|
2021-11-15 16:32:41 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_text() = gstr_stat;
|
2022-10-18 23:17:54 +00:00
|
|
|
render_impl(*text_renderer_, snapshot, widget, stat_area, stat_area, flags);
|
2009-03-02 23:31:01 +00:00
|
|
|
}
|
|
|
|
|
2022-10-08 22:50:03 +00:00
|
|
|
void TorrentCellRenderer::IF_GTKMM4(snapshot_vfunc, render_vfunc)(
|
2022-10-18 23:17:54 +00:00
|
|
|
SnapshotPtr const& snapshot,
|
2021-10-18 20:22:31 +00:00
|
|
|
Gtk::Widget& widget,
|
|
|
|
Gdk::Rectangle const& background_area,
|
|
|
|
Gdk::Rectangle const& /*cell_area*/,
|
|
|
|
Gtk::CellRendererState flags)
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2008-02-16 19:36:07 +00:00
|
|
|
#ifdef TEST_RTL
|
2021-10-18 20:22:31 +00:00
|
|
|
auto const real_dir = widget.get_direction();
|
|
|
|
widget.set_direction(Gtk::TEXT_DIR_RTL);
|
2008-02-16 19:36:07 +00:00
|
|
|
#endif
|
|
|
|
|
2022-11-13 17:36:16 +00:00
|
|
|
if (impl_->property_torrent().get_value() != nullptr)
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
if (impl_->property_compact().get_value())
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2022-10-18 23:17:54 +00:00
|
|
|
impl_->render_compact(snapshot, widget, background_area, flags);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2007-12-19 20:04:38 +00:00
|
|
|
else
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2022-10-18 23:17:54 +00:00
|
|
|
impl_->render_full(snapshot, widget, background_area, flags);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
2008-02-16 19:36:07 +00:00
|
|
|
|
|
|
|
#ifdef TEST_RTL
|
2021-10-18 20:22:31 +00:00
|
|
|
widget.set_direction(real_dir);
|
2008-02-16 19:36:07 +00:00
|
|
|
#endif
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
TorrentCellRenderer::Impl::~Impl()
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->unreference();
|
|
|
|
progress_renderer_->unreference();
|
|
|
|
icon_renderer_->unreference();
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
TorrentCellRenderer::TorrentCellRenderer()
|
|
|
|
: Glib::ObjectBase(typeid(TorrentCellRenderer))
|
|
|
|
, impl_(std::make_unique<Impl>(*this))
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
TorrentCellRenderer::~TorrentCellRenderer() = default;
|
2011-08-09 06:31:33 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
TorrentCellRenderer::Impl::Impl(TorrentCellRenderer& renderer)
|
2022-11-13 17:36:16 +00:00
|
|
|
: renderer_(renderer)
|
|
|
|
, property_torrent_(renderer, "torrent", nullptr)
|
|
|
|
, property_bar_height_(renderer, "bar-height", DefaultBarHeight)
|
|
|
|
, property_upload_speed_KBps_(renderer, "piece-upload-speed", 0)
|
|
|
|
, property_download_speed_KBps_(renderer, "piece-download-speed", 0)
|
|
|
|
, property_compact_(renderer, "compact", false)
|
|
|
|
, text_renderer_(Gtk::make_managed<Gtk::CellRendererText>())
|
|
|
|
, progress_renderer_(Gtk::make_managed<Gtk::CellRendererProgress>())
|
|
|
|
, icon_renderer_(Gtk::make_managed<Gtk::CellRendererPixbuf>())
|
|
|
|
{
|
2021-10-18 20:22:31 +00:00
|
|
|
text_renderer_->property_xpad() = 0;
|
|
|
|
text_renderer_->property_ypad() = 0;
|
2008-01-12 17:59:09 +00:00
|
|
|
}
|
|
|
|
|
2021-12-14 08:43:27 +00:00
|
|
|
Glib::PropertyProxy<gpointer> TorrentCellRenderer::property_torrent()
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
return impl_->property_torrent().get_proxy();
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Glib::PropertyProxy<double> TorrentCellRenderer::property_piece_upload_speed()
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
return impl_->property_upload_speed_KBps().get_proxy();
|
2021-10-18 20:22:31 +00:00
|
|
|
}
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Glib::PropertyProxy<double> TorrentCellRenderer::property_piece_download_speed()
|
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
return impl_->property_download_speed_KBps().get_proxy();
|
2021-10-18 20:22:31 +00:00
|
|
|
}
|
2007-12-19 02:46:30 +00:00
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Glib::PropertyProxy<int> TorrentCellRenderer::property_bar_height()
|
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
return impl_->property_bar_height().get_proxy();
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 20:22:31 +00:00
|
|
|
Glib::PropertyProxy<bool> TorrentCellRenderer::property_compact()
|
2007-12-19 02:46:30 +00:00
|
|
|
{
|
2022-11-13 17:36:16 +00:00
|
|
|
return impl_->property_compact().get_proxy();
|
2007-12-19 02:46:30 +00:00
|
|
|
}
|