mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
refactor: remove tr_strip_positional_args() (#2881)
* refactor: use fmt in gtk/SystemIconTray * refactor: use fmt in gtk/MakeDialog * refactor: remove unused tr_strip_positional_args() Co-authored-by: Mike Gelfand <mikedld@mikedld.com>
This commit is contained in:
@@ -48,6 +48,8 @@ private:
|
||||
void activated();
|
||||
void popup(guint button, guint when);
|
||||
|
||||
[[nodiscard]] std::string make_tooltip_text() const;
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Session> const core_;
|
||||
|
||||
@@ -87,42 +89,7 @@ void SystemTrayIcon::Impl::popup(guint /*button*/, guint /*when*/)
|
||||
|
||||
void SystemTrayIcon::Impl::refresh()
|
||||
{
|
||||
double KBps;
|
||||
double limit;
|
||||
Glib::ustring upLimit;
|
||||
Glib::ustring downLimit;
|
||||
char const* const idle = _("Idle");
|
||||
auto* session = core_->get_session();
|
||||
|
||||
/* up */
|
||||
KBps = tr_sessionGetRawSpeed_KBps(session, TR_UP);
|
||||
|
||||
auto const up = KBps < 0.001 ? idle : tr_formatter_speed_KBps(KBps);
|
||||
|
||||
/* up limit */
|
||||
if (tr_sessionGetActiveSpeedLimit_KBps(session, TR_UP, &limit))
|
||||
{
|
||||
upLimit = gtr_sprintf(_(" (Limit: %s)"), tr_formatter_speed_KBps(limit));
|
||||
}
|
||||
|
||||
/* down */
|
||||
KBps = tr_sessionGetRawSpeed_KBps(session, TR_DOWN);
|
||||
|
||||
auto const down = KBps < 0.001 ? idle : tr_formatter_speed_KBps(KBps);
|
||||
|
||||
/* down limit */
|
||||
if (tr_sessionGetActiveSpeedLimit_KBps(session, TR_DOWN, &limit))
|
||||
{
|
||||
downLimit = gtr_sprintf(_(" (Limit: %s)"), tr_formatter_speed_KBps(limit));
|
||||
}
|
||||
|
||||
/* %1$s: current upload speed
|
||||
* %2$s: current upload limit, if any
|
||||
* %3$s: current download speed
|
||||
* %4$s: current download limit, if any */
|
||||
auto const tip = gtr_sprintf(_("Transmission\nUp: %1$s %2$s\nDown: %3$s %4$s"), up, upLimit, down, downLimit);
|
||||
|
||||
icon_->set_tooltip_text(tip);
|
||||
icon_->set_tooltip_text(make_tooltip_text());
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -187,3 +154,12 @@ SystemTrayIcon::Impl::Impl(Gtk::Window& main_window, Glib::RefPtr<Session> const
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string SystemTrayIcon::Impl::make_tooltip_text() const
|
||||
{
|
||||
auto const* const session = core_->get_session();
|
||||
return fmt::format(
|
||||
_("{upload_speed} ▲ {download_speed} ▼"),
|
||||
fmt::arg("upload_speed", tr_formatter_speed_KBps(tr_sessionGetRawSpeed_KBps(session, TR_UP))),
|
||||
fmt::arg("download_speed", tr_formatter_speed_KBps(tr_sessionGetRawSpeed_KBps(session, TR_DOWN))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user