Fix issues reported by clang-tidy `cert` checks (GTK client) (#4174)
* Fix `cert-err33-c` clang-tidy issues * Fix `cert-str34-c` clang-tidy issues * Fold free-standing functions into `FilterBar::Impl` This is in preparation to next commit fixing `cert-err58-cpp`. * Fix `cert-err58-cpp` clang-tidy issues * Extend clang-tidy configuration
This commit is contained in:
parent
5cb9e8c146
commit
2bd6c8aff4
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
Checks: >
|
||||
-*,
|
||||
cert-*,
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
|
|
|
@ -65,7 +65,7 @@ using StringValue = Glib::Value<Glib::ustring>;
|
|||
namespace
|
||||
{
|
||||
|
||||
auto const AppIconName = Glib::ustring("transmission"s);
|
||||
auto const AppIconName = "transmission"sv; // TODO(C++20): Use ""s
|
||||
|
||||
char const* const LICENSE =
|
||||
"Copyright 2005-2022. All code is copyrighted by the respective authors.\n"
|
||||
|
@ -549,7 +549,7 @@ void Application::Impl::on_startup()
|
|||
{
|
||||
IF_GTKMM4(Gtk::IconTheme::get_for_display(Gdk::Display::get_default()), Gtk::IconTheme::get_default())
|
||||
->add_resource_path(gtr_get_full_resource_path("icons"s));
|
||||
Gtk::Window::set_default_icon_name(AppIconName);
|
||||
Gtk::Window::set_default_icon_name(std::string(AppIconName));
|
||||
|
||||
/* Add style provider to the window. */
|
||||
auto css_provider = Gtk::CssProvider::create();
|
||||
|
@ -1396,7 +1396,7 @@ void Application::Impl::show_about_dialog()
|
|||
d->set_authors(authors);
|
||||
d->set_comments(_("A fast and easy BitTorrent client"));
|
||||
d->set_copyright(_("Copyright © The Transmission Project"));
|
||||
d->set_logo_icon_name(AppIconName);
|
||||
d->set_logo_icon_name(std::string(AppIconName));
|
||||
d->set_name(Glib::get_application_name());
|
||||
/* Translators: translate "translator-credits" as your name
|
||||
to have it appear in the credits in the "About"
|
||||
|
|
|
@ -1078,7 +1078,7 @@ namespace
|
|||
class WebseedModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
WebseedModelColumns()
|
||||
WebseedModelColumns() noexcept
|
||||
{
|
||||
add(key);
|
||||
add(was_updated);
|
||||
|
@ -1099,7 +1099,7 @@ WebseedModelColumns const webseed_cols;
|
|||
class PeerModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
PeerModelColumns()
|
||||
PeerModelColumns() noexcept
|
||||
{
|
||||
add(key);
|
||||
add(was_updated);
|
||||
|
@ -1958,7 +1958,7 @@ void buildTrackerSummary(
|
|||
class TrackerModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
TrackerModelColumns()
|
||||
TrackerModelColumns() noexcept
|
||||
{
|
||||
add(torrent_id);
|
||||
add(text);
|
||||
|
|
|
@ -33,8 +33,6 @@ using namespace std::literals;
|
|||
namespace
|
||||
{
|
||||
|
||||
auto const ColumnIdKey = Glib::Quark("tr-model-column-id-key");
|
||||
|
||||
enum
|
||||
{
|
||||
/* these two fields could be any number at all so long as they're not
|
||||
|
@ -46,7 +44,7 @@ enum
|
|||
class FileModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
FileModelColumns()
|
||||
FileModelColumns() noexcept
|
||||
{
|
||||
add(icon);
|
||||
add(label);
|
||||
|
@ -175,7 +173,7 @@ bool refreshFilesForeach(
|
|||
auto const file = tr_torrentFile(refresh_data.tor, index);
|
||||
|
||||
new_enabled = static_cast<int>(file.wanted);
|
||||
new_priority = file.priority;
|
||||
new_priority = int{ file.priority };
|
||||
new_have = file.have;
|
||||
new_size = file.length;
|
||||
new_progress = static_cast<int>(100 * file.progress);
|
||||
|
@ -694,7 +692,7 @@ bool FileList::Impl::onViewPathToggled(Gtk::TreeViewColumn* col, Gtk::TreeModel:
|
|||
|
||||
bool handled = false;
|
||||
|
||||
auto const cid = GPOINTER_TO_INT(col->get_data(ColumnIdKey));
|
||||
auto const cid = col->get_sort_column_id();
|
||||
auto* tor = core_->find_torrent(torrent_id_);
|
||||
|
||||
if (tor != nullptr && (cid == file_cols.priority.index() || cid == file_cols.enabled.index()))
|
||||
|
@ -986,7 +984,6 @@ FileList::Impl::Impl(
|
|||
width += 30; /* room for the sort indicator */
|
||||
auto* rend = Gtk::make_managed<Gtk::CellRendererToggle>();
|
||||
auto* col = Gtk::make_managed<Gtk::TreeViewColumn>(title, *rend);
|
||||
col->set_data(ColumnIdKey, GINT_TO_POINTER(file_cols.enabled.index()));
|
||||
col->set_fixed_width(width);
|
||||
col->set_sizing(TR_GTK_TREE_VIEW_COLUMN_SIZING(FIXED));
|
||||
col->set_cell_data_func(*rend, sigc::ptr_fun(&renderDownload));
|
||||
|
@ -1005,7 +1002,6 @@ FileList::Impl::Impl(
|
|||
rend->property_xalign() = 0.5F;
|
||||
rend->property_yalign() = 0.5F;
|
||||
auto* col = Gtk::make_managed<Gtk::TreeViewColumn>(title, *rend);
|
||||
col->set_data(ColumnIdKey, GINT_TO_POINTER(file_cols.priority.index()));
|
||||
col->set_fixed_width(width);
|
||||
col->set_sizing(TR_GTK_TREE_VIEW_COLUMN_SIZING(FIXED));
|
||||
col->set_sort_column(file_cols.priority);
|
||||
|
|
299
gtk/FilterBar.cc
299
gtk/FilterBar.cc
|
@ -21,15 +21,6 @@
|
|||
#include "Session.h" // torrent_cols
|
||||
#include "Utils.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
auto const DIRTY_KEY = Glib::Quark("tr-filter-dirty-key");
|
||||
auto const SESSION_KEY = Glib::Quark("tr-session-key");
|
||||
auto const TORRENT_MODEL_KEY = Glib::Quark("tr-filter-torrent-model-key");
|
||||
|
||||
} // namespace
|
||||
|
||||
class FilterBar::Impl
|
||||
{
|
||||
public:
|
||||
|
@ -44,19 +35,49 @@ private:
|
|||
template<typename T>
|
||||
T* get_template_child(char const* name) const;
|
||||
|
||||
void activity_combo_box_init(Gtk::ComboBox* combo, Glib::RefPtr<Gtk::TreeModel> const& tmodel);
|
||||
void tracker_combo_box_init(Gtk::ComboBox* combo, Glib::RefPtr<Gtk::TreeModel> const& tmodel);
|
||||
void activity_combo_box_init(Gtk::ComboBox& combo);
|
||||
static void render_activity_pixbuf_func(Gtk::CellRendererPixbuf& cell_renderer, Gtk::TreeModel::const_iterator const& iter);
|
||||
|
||||
void update_count_label_idle();
|
||||
|
||||
bool is_row_visible(Gtk::TreeModel::const_iterator const& iter);
|
||||
void tracker_combo_box_init(Gtk::ComboBox& combo);
|
||||
static void render_pixbuf_func(Gtk::CellRendererPixbuf& cell_renderer, Gtk::TreeModel::const_iterator const& iter);
|
||||
static void render_number_func(Gtk::CellRendererText& cell_renderer, Gtk::TreeModel::const_iterator const& iter);
|
||||
|
||||
void selection_changed_cb();
|
||||
bool update_count_label();
|
||||
void filter_entry_changed();
|
||||
|
||||
Glib::RefPtr<Gtk::ListStore> activity_filter_model_new();
|
||||
void activity_model_update_idle();
|
||||
bool activity_filter_model_update();
|
||||
void status_model_update_count(Gtk::TreeModel::iterator const& iter, int n);
|
||||
bool activity_is_it_a_separator(Gtk::TreeModel::const_iterator const& iter);
|
||||
|
||||
Glib::RefPtr<Gtk::TreeStore> tracker_filter_model_new();
|
||||
void tracker_model_update_idle();
|
||||
bool tracker_filter_model_update();
|
||||
void tracker_model_update_count(Gtk::TreeModel::iterator const& iter, int n);
|
||||
bool is_it_a_separator(Gtk::TreeModel::const_iterator const& iter);
|
||||
void favicon_ready_cb(Glib::RefPtr<Gdk::Pixbuf> const& pixbuf, Gtk::TreeRowReference& reference);
|
||||
|
||||
void update_count_label_idle();
|
||||
bool update_count_label();
|
||||
bool is_row_visible(Gtk::TreeModel::const_iterator const& iter);
|
||||
|
||||
bool test_tracker(tr_torrent const& tor, int active_tracker_type, Glib::ustring const& host);
|
||||
bool test_torrent_activity(tr_torrent& tor, int type);
|
||||
|
||||
static Glib::ustring get_name_from_host(std::string const& host);
|
||||
|
||||
static Gtk::CellRendererText* number_renderer_new();
|
||||
|
||||
static bool testText(tr_torrent const& tor, Glib::ustring const& key);
|
||||
|
||||
private:
|
||||
FilterBar& widget_;
|
||||
tr_session* const session_;
|
||||
Glib::RefPtr<Gtk::TreeModel> const torrent_model_;
|
||||
|
||||
Glib::RefPtr<Gtk::ListStore> const activity_model_;
|
||||
Glib::RefPtr<Gtk::TreeStore> const tracker_model_;
|
||||
|
||||
Gtk::ComboBox* activity_ = nullptr;
|
||||
Gtk::ComboBox* tracker_ = nullptr;
|
||||
|
@ -70,10 +91,12 @@ private:
|
|||
sigc::connection activity_model_row_changed_tag_;
|
||||
sigc::connection activity_model_row_inserted_tag_;
|
||||
sigc::connection activity_model_row_deleted_cb_tag_;
|
||||
sigc::connection activity_model_update_tag_;
|
||||
|
||||
sigc::connection torrent_model_row_changed_tag_;
|
||||
sigc::connection torrent_model_row_inserted_tag_;
|
||||
sigc::connection torrent_model_row_deleted_cb_tag_;
|
||||
sigc::connection tracker_model_row_changed_tag_;
|
||||
sigc::connection tracker_model_row_inserted_tag_;
|
||||
sigc::connection tracker_model_row_deleted_cb_tag_;
|
||||
sigc::connection tracker_model_update_tag_;
|
||||
|
||||
sigc::connection filter_model_row_deleted_tag_;
|
||||
sigc::connection filter_model_row_inserted_tag_;
|
||||
|
@ -102,7 +125,7 @@ enum
|
|||
class TrackerFilterModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
TrackerFilterModelColumns()
|
||||
TrackerFilterModelColumns() noexcept
|
||||
{
|
||||
add(displayname);
|
||||
add(count);
|
||||
|
@ -120,8 +143,10 @@ public:
|
|||
|
||||
TrackerFilterModelColumns const tracker_filter_cols;
|
||||
|
||||
} // namespace
|
||||
|
||||
/* human-readable name; ie, Legaltorrents */
|
||||
Glib::ustring get_name_from_host(std::string const& host)
|
||||
Glib::ustring FilterBar::Impl::get_name_from_host(std::string const& host)
|
||||
{
|
||||
std::string name = host;
|
||||
|
||||
|
@ -133,7 +158,7 @@ Glib::ustring get_name_from_host(std::string const& host)
|
|||
return name;
|
||||
}
|
||||
|
||||
void tracker_model_update_count(Gtk::TreeModel::iterator const& iter, int n)
|
||||
void FilterBar::Impl::tracker_model_update_count(Gtk::TreeModel::iterator const& iter, int n)
|
||||
{
|
||||
if (n != iter->get_value(tracker_filter_cols.count))
|
||||
{
|
||||
|
@ -141,7 +166,7 @@ void tracker_model_update_count(Gtk::TreeModel::iterator const& iter, int n)
|
|||
}
|
||||
}
|
||||
|
||||
void favicon_ready_cb(Glib::RefPtr<Gdk::Pixbuf> const& pixbuf, Gtk::TreeRowReference& reference)
|
||||
void FilterBar::Impl::favicon_ready_cb(Glib::RefPtr<Gdk::Pixbuf> const& pixbuf, Gtk::TreeRowReference& reference)
|
||||
{
|
||||
if (pixbuf != nullptr)
|
||||
{
|
||||
|
@ -155,10 +180,8 @@ void favicon_ready_cb(Glib::RefPtr<Gdk::Pixbuf> const& pixbuf, Gtk::TreeRowRefer
|
|||
}
|
||||
}
|
||||
|
||||
bool tracker_filter_model_update(Glib::RefPtr<Gtk::TreeStore> const& tracker_model)
|
||||
bool FilterBar::Impl::tracker_filter_model_update()
|
||||
{
|
||||
tracker_model->steal_data(DIRTY_KEY);
|
||||
|
||||
struct site_info
|
||||
{
|
||||
int count = 0;
|
||||
|
@ -176,8 +199,7 @@ bool tracker_filter_model_update(Glib::RefPtr<Gtk::TreeStore> const& tracker_mod
|
|||
* hosts s.t. we can merge it with the existing list */
|
||||
auto n_torrents = int{ 0 };
|
||||
auto site_infos = std::unordered_map<std::string /*site*/, site_info>{};
|
||||
auto* tmodel = static_cast<Gtk::TreeModel*>(tracker_model->get_data(TORRENT_MODEL_KEY));
|
||||
for (auto const& row : tmodel->children())
|
||||
for (auto const& row : torrent_model_->children())
|
||||
{
|
||||
auto const* tor = static_cast<tr_torrent const*>(row.get_value(torrent_cols.torrent));
|
||||
|
||||
|
@ -205,7 +227,7 @@ bool tracker_filter_model_update(Glib::RefPtr<Gtk::TreeStore> const& tracker_mod
|
|||
std::sort(std::begin(sites_v), std::end(sites_v));
|
||||
|
||||
// update the "all" count
|
||||
auto iter = tracker_model->children().begin();
|
||||
auto iter = tracker_model_->children().begin();
|
||||
if (iter)
|
||||
{
|
||||
tracker_model_update_count(iter, n_torrents);
|
||||
|
@ -255,22 +277,21 @@ bool tracker_filter_model_update(Glib::RefPtr<Gtk::TreeStore> const& tracker_mod
|
|||
// do something
|
||||
if (remove_row)
|
||||
{
|
||||
iter = tracker_model->erase(iter);
|
||||
iter = tracker_model_->erase(iter);
|
||||
}
|
||||
else if (insert_row)
|
||||
{
|
||||
auto* session = static_cast<tr_session*>(tracker_model->get_data(SESSION_KEY));
|
||||
auto const& site = sites_v.at(i);
|
||||
auto const add = tracker_model->insert(iter);
|
||||
auto const add = tracker_model_->insert(iter);
|
||||
add->set_value(tracker_filter_cols.sitename, Glib::ustring{ site.sitename });
|
||||
add->set_value(tracker_filter_cols.displayname, get_name_from_host(site.sitename));
|
||||
add->set_value(tracker_filter_cols.count, site.count);
|
||||
add->set_value(tracker_filter_cols.type, static_cast<int>(TRACKER_FILTER_TYPE_HOST));
|
||||
auto path = tracker_model->get_path(add);
|
||||
auto path = tracker_model_->get_path(add);
|
||||
gtr_get_favicon(
|
||||
session,
|
||||
session_,
|
||||
site.host,
|
||||
[ref = Gtk::TreeRowReference(tracker_model, path)](auto const& pixbuf) mutable
|
||||
[this, ref = Gtk::TreeRowReference(tracker_model_, path)](auto const& pixbuf) mutable
|
||||
{ favicon_ready_cb(pixbuf, ref); });
|
||||
// ++iter;
|
||||
++i;
|
||||
|
@ -286,7 +307,7 @@ bool tracker_filter_model_update(Glib::RefPtr<Gtk::TreeStore> const& tracker_mod
|
|||
return false;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gtk::TreeStore> tracker_filter_model_new(Glib::RefPtr<Gtk::TreeModel> const& tmodel)
|
||||
Glib::RefPtr<Gtk::TreeStore> FilterBar::Impl::tracker_filter_model_new()
|
||||
{
|
||||
auto store = Gtk::TreeStore::create(tracker_filter_cols);
|
||||
|
||||
|
@ -297,39 +318,34 @@ Glib::RefPtr<Gtk::TreeStore> tracker_filter_model_new(Glib::RefPtr<Gtk::TreeMode
|
|||
iter = store->append();
|
||||
iter->set_value(tracker_filter_cols.type, static_cast<int>(TRACKER_FILTER_TYPE_SEPARATOR));
|
||||
|
||||
store->set_data(TORRENT_MODEL_KEY, tmodel.get());
|
||||
tracker_filter_model_update(store);
|
||||
return store;
|
||||
}
|
||||
|
||||
bool is_it_a_separator(Glib::RefPtr<Gtk::TreeModel> const& /*model*/, Gtk::TreeModel::const_iterator const& iter)
|
||||
bool FilterBar::Impl::is_it_a_separator(Gtk::TreeModel::const_iterator const& iter)
|
||||
{
|
||||
return iter->get_value(tracker_filter_cols.type) == TRACKER_FILTER_TYPE_SEPARATOR;
|
||||
}
|
||||
|
||||
void tracker_model_update_idle(Glib::RefPtr<Gtk::TreeStore> const& tracker_model)
|
||||
void FilterBar::Impl::tracker_model_update_idle()
|
||||
{
|
||||
bool const pending = tracker_model->get_data(DIRTY_KEY) != nullptr;
|
||||
|
||||
if (!pending)
|
||||
if (!tracker_model_update_tag_.connected())
|
||||
{
|
||||
tracker_model->set_data(DIRTY_KEY, GINT_TO_POINTER(1));
|
||||
Glib::signal_idle().connect([tracker_model]() { return tracker_filter_model_update(tracker_model); });
|
||||
tracker_model_update_tag_ = Glib::signal_idle().connect([this]() { return tracker_filter_model_update(); });
|
||||
}
|
||||
}
|
||||
|
||||
void render_pixbuf_func(Gtk::CellRendererPixbuf* cell_renderer, Gtk::TreeModel::const_iterator const& iter)
|
||||
void FilterBar::Impl::render_pixbuf_func(Gtk::CellRendererPixbuf& cell_renderer, Gtk::TreeModel::const_iterator const& iter)
|
||||
{
|
||||
cell_renderer->property_width() = (iter->get_value(tracker_filter_cols.type) == TRACKER_FILTER_TYPE_HOST) ? 20 : 0;
|
||||
cell_renderer.property_width() = (iter->get_value(tracker_filter_cols.type) == TRACKER_FILTER_TYPE_HOST) ? 20 : 0;
|
||||
}
|
||||
|
||||
void render_number_func(Gtk::CellRendererText* cell_renderer, Gtk::TreeModel::const_iterator const& iter)
|
||||
void FilterBar::Impl::render_number_func(Gtk::CellRendererText& cell_renderer, Gtk::TreeModel::const_iterator const& iter)
|
||||
{
|
||||
auto const count = iter->get_value(tracker_filter_cols.count);
|
||||
cell_renderer->property_text() = count >= 0 ? fmt::format("{:L}", count) : "";
|
||||
cell_renderer.property_text() = count >= 0 ? fmt::format("{:L}", count) : "";
|
||||
}
|
||||
|
||||
Gtk::CellRendererText* number_renderer_new()
|
||||
Gtk::CellRendererText* FilterBar::Impl::number_renderer_new()
|
||||
{
|
||||
auto* r = Gtk::make_managed<Gtk::CellRendererText>();
|
||||
|
||||
|
@ -341,57 +357,49 @@ Gtk::CellRendererText* number_renderer_new()
|
|||
return r;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void FilterBar::Impl::tracker_combo_box_init(Gtk::ComboBox* combo, Glib::RefPtr<Gtk::TreeModel> const& tmodel)
|
||||
void FilterBar::Impl::tracker_combo_box_init(Gtk::ComboBox& combo)
|
||||
{
|
||||
/* create the tracker combobox */
|
||||
auto const cat_model = tracker_filter_model_new(tmodel);
|
||||
|
||||
combo->set_model(cat_model);
|
||||
combo->set_row_separator_func(&is_it_a_separator);
|
||||
combo->set_active(0);
|
||||
combo.set_model(tracker_model_);
|
||||
combo.set_row_separator_func(sigc::hide<0>(sigc::mem_fun(*this, &Impl::is_it_a_separator)));
|
||||
combo.set_active(0);
|
||||
|
||||
{
|
||||
auto* r = Gtk::make_managed<Gtk::CellRendererPixbuf>();
|
||||
combo->pack_start(*r, false);
|
||||
combo->set_cell_data_func(*r, [r](auto const& iter) { render_pixbuf_func(r, iter); });
|
||||
combo->add_attribute(r->property_pixbuf(), tracker_filter_cols.pixbuf);
|
||||
combo.pack_start(*r, false);
|
||||
combo.set_cell_data_func(*r, [r](auto const& iter) { render_pixbuf_func(*r, iter); });
|
||||
combo.add_attribute(r->property_pixbuf(), tracker_filter_cols.pixbuf);
|
||||
}
|
||||
|
||||
{
|
||||
auto* r = Gtk::make_managed<Gtk::CellRendererText>();
|
||||
combo->pack_start(*r, false);
|
||||
combo->add_attribute(r->property_text(), tracker_filter_cols.displayname);
|
||||
combo.pack_start(*r, false);
|
||||
combo.add_attribute(r->property_text(), tracker_filter_cols.displayname);
|
||||
}
|
||||
|
||||
{
|
||||
auto* r = number_renderer_new();
|
||||
combo->pack_end(*r, true);
|
||||
combo->set_cell_data_func(*r, [r](auto const& iter) { render_number_func(r, iter); });
|
||||
combo.pack_end(*r, true);
|
||||
combo.set_cell_data_func(*r, [r](auto const& iter) { render_number_func(*r, iter); });
|
||||
}
|
||||
|
||||
torrent_model_row_changed_tag_ = tmodel->signal_row_changed().connect(
|
||||
[cat_model](auto const& /*path*/, auto const& /*iter*/) { tracker_model_update_idle(cat_model); });
|
||||
torrent_model_row_inserted_tag_ = tmodel->signal_row_inserted().connect(
|
||||
[cat_model](auto const& /*path*/, auto const& /*iter*/) { tracker_model_update_idle(cat_model); });
|
||||
torrent_model_row_deleted_cb_tag_ = tmodel->signal_row_deleted().connect( //
|
||||
[cat_model](auto const& /*path*/) { tracker_model_update_idle(cat_model); });
|
||||
tracker_model_row_changed_tag_ = torrent_model_->signal_row_changed().connect( //
|
||||
[this](auto const& /*path*/, auto const& /*iter*/) { tracker_model_update_idle(); });
|
||||
tracker_model_row_inserted_tag_ = torrent_model_->signal_row_inserted().connect( //
|
||||
[this](auto const& /*path*/, auto const& /*iter*/) { tracker_model_update_idle(); });
|
||||
tracker_model_row_deleted_cb_tag_ = torrent_model_->signal_row_deleted().connect( //
|
||||
[this](auto const& /*path*/) { tracker_model_update_idle(); });
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool test_tracker(tr_torrent const* tor, int active_tracker_type, Glib::ustring const& host)
|
||||
bool FilterBar::Impl::test_tracker(tr_torrent const& tor, int active_tracker_type, Glib::ustring const& host)
|
||||
{
|
||||
if (active_tracker_type != TRACKER_FILTER_TYPE_HOST)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (size_t i = 0, n = tr_torrentTrackerCount(tor); i < n; ++i)
|
||||
for (size_t i = 0, n = tr_torrentTrackerCount(&tor); i < n; ++i)
|
||||
{
|
||||
if (auto const tracker = tr_torrentTracker(tor, i); std::data(tracker.sitename) == host)
|
||||
if (auto const tracker = tr_torrentTracker(&tor, i); std::data(tracker.sitename) == host)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -400,6 +408,9 @@ bool test_tracker(tr_torrent const* tor, int active_tracker_type, Glib::ustring
|
|||
return false;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
/***
|
||||
****
|
||||
**** ACTIVITY
|
||||
|
@ -422,7 +433,7 @@ enum
|
|||
class ActivityFilterModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
ActivityFilterModelColumns()
|
||||
ActivityFilterModelColumns() noexcept
|
||||
{
|
||||
add(name);
|
||||
add(count);
|
||||
|
@ -438,14 +449,16 @@ public:
|
|||
|
||||
ActivityFilterModelColumns const activity_filter_cols;
|
||||
|
||||
bool activity_is_it_a_separator(Glib::RefPtr<Gtk::TreeModel> const& /*model*/, Gtk::TreeModel::const_iterator const& iter)
|
||||
} // namespace
|
||||
|
||||
bool FilterBar::Impl::activity_is_it_a_separator(Gtk::TreeModel::const_iterator const& iter)
|
||||
{
|
||||
return iter->get_value(activity_filter_cols.type) == ACTIVITY_FILTER_SEPARATOR;
|
||||
}
|
||||
|
||||
bool test_torrent_activity(tr_torrent* tor, int type)
|
||||
bool FilterBar::Impl::test_torrent_activity(tr_torrent& tor, int type)
|
||||
{
|
||||
auto const* st = tr_torrentStatCached(tor);
|
||||
auto const* st = tr_torrentStatCached(&tor);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
@ -476,7 +489,7 @@ bool test_torrent_activity(tr_torrent* tor, int type)
|
|||
}
|
||||
}
|
||||
|
||||
void status_model_update_count(Gtk::TreeModel::iterator const& iter, int n)
|
||||
void FilterBar::Impl::status_model_update_count(Gtk::TreeModel::iterator const& iter, int n)
|
||||
{
|
||||
if (n != iter->get_value(activity_filter_cols.count))
|
||||
{
|
||||
|
@ -484,20 +497,16 @@ void status_model_update_count(Gtk::TreeModel::iterator const& iter, int n)
|
|||
}
|
||||
}
|
||||
|
||||
bool activity_filter_model_update(Glib::RefPtr<Gtk::ListStore> const& activity_model)
|
||||
bool FilterBar::Impl::activity_filter_model_update()
|
||||
{
|
||||
auto* tmodel = static_cast<Gtk::TreeModel*>(activity_model->get_data(TORRENT_MODEL_KEY));
|
||||
|
||||
activity_model->steal_data(DIRTY_KEY);
|
||||
|
||||
for (auto& row : activity_model->children())
|
||||
for (auto& row : activity_model_->children())
|
||||
{
|
||||
auto const type = row.get_value(activity_filter_cols.type);
|
||||
auto hits = 0;
|
||||
|
||||
for (auto const& torrent_row : tmodel->children())
|
||||
for (auto const& torrent_row : torrent_model_->children())
|
||||
{
|
||||
if (test_torrent_activity(static_cast<tr_torrent*>(torrent_row.get_value(torrent_cols.torrent)), type))
|
||||
if (test_torrent_activity(*static_cast<tr_torrent*>(torrent_row.get_value(torrent_cols.torrent)), type))
|
||||
{
|
||||
++hits;
|
||||
}
|
||||
|
@ -509,7 +518,7 @@ bool activity_filter_model_update(Glib::RefPtr<Gtk::ListStore> const& activity_m
|
|||
return false;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gtk::ListStore> activity_filter_model_new(Glib::RefPtr<Gtk::TreeModel> const& tmodel)
|
||||
Glib::RefPtr<Gtk::ListStore> FilterBar::Impl::activity_filter_model_new()
|
||||
{
|
||||
struct FilterTypeInfo
|
||||
{
|
||||
|
@ -544,64 +553,57 @@ Glib::RefPtr<Gtk::ListStore> activity_filter_model_new(Glib::RefPtr<Gtk::TreeMod
|
|||
iter->set_value(activity_filter_cols.icon_name, type.icon_name);
|
||||
}
|
||||
|
||||
store->set_data(TORRENT_MODEL_KEY, tmodel.get());
|
||||
activity_filter_model_update(store);
|
||||
return store;
|
||||
}
|
||||
|
||||
void render_activity_pixbuf_func(Gtk::CellRendererPixbuf* cell_renderer, Gtk::TreeModel::const_iterator const& iter)
|
||||
void FilterBar::Impl::render_activity_pixbuf_func(
|
||||
Gtk::CellRendererPixbuf& cell_renderer,
|
||||
Gtk::TreeModel::const_iterator const& iter)
|
||||
{
|
||||
auto const type = iter->get_value(activity_filter_cols.type);
|
||||
cell_renderer->property_width() = type == ACTIVITY_FILTER_ALL ? 0 : 20;
|
||||
cell_renderer->property_ypad() = type == ACTIVITY_FILTER_ALL ? 0 : 2;
|
||||
cell_renderer.property_width() = type == ACTIVITY_FILTER_ALL ? 0 : 20;
|
||||
cell_renderer.property_ypad() = type == ACTIVITY_FILTER_ALL ? 0 : 2;
|
||||
}
|
||||
|
||||
void activity_model_update_idle(Glib::RefPtr<Gtk::ListStore> const& activity_model)
|
||||
void FilterBar::Impl::activity_model_update_idle()
|
||||
{
|
||||
bool const pending = activity_model->get_data(DIRTY_KEY) != nullptr;
|
||||
|
||||
if (!pending)
|
||||
if (!activity_model_update_tag_.connected())
|
||||
{
|
||||
activity_model->set_data(DIRTY_KEY, GINT_TO_POINTER(1));
|
||||
Glib::signal_idle().connect([activity_model]() { return activity_filter_model_update(activity_model); });
|
||||
activity_model_update_tag_ = Glib::signal_idle().connect([this]() { return activity_filter_model_update(); });
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void FilterBar::Impl::activity_combo_box_init(Gtk::ComboBox* combo, Glib::RefPtr<Gtk::TreeModel> const& tmodel)
|
||||
void FilterBar::Impl::activity_combo_box_init(Gtk::ComboBox& combo)
|
||||
{
|
||||
auto const activity_model = activity_filter_model_new(tmodel);
|
||||
|
||||
combo->set_model(activity_model);
|
||||
combo->set_row_separator_func(&activity_is_it_a_separator);
|
||||
combo->set_active(0);
|
||||
combo.set_model(activity_model_);
|
||||
combo.set_row_separator_func(sigc::hide<0>(sigc::mem_fun(*this, &Impl::activity_is_it_a_separator)));
|
||||
combo.set_active(0);
|
||||
|
||||
{
|
||||
auto* r = Gtk::make_managed<Gtk::CellRendererPixbuf>();
|
||||
combo->pack_start(*r, false);
|
||||
combo->add_attribute(r->property_icon_name(), activity_filter_cols.icon_name);
|
||||
combo->set_cell_data_func(*r, [r](auto const& iter) { render_activity_pixbuf_func(r, iter); });
|
||||
combo.pack_start(*r, false);
|
||||
combo.add_attribute(r->property_icon_name(), activity_filter_cols.icon_name);
|
||||
combo.set_cell_data_func(*r, [r](auto const& iter) { render_activity_pixbuf_func(*r, iter); });
|
||||
}
|
||||
|
||||
{
|
||||
auto* r = Gtk::make_managed<Gtk::CellRendererText>();
|
||||
combo->pack_start(*r, true);
|
||||
combo->add_attribute(r->property_text(), activity_filter_cols.name);
|
||||
combo.pack_start(*r, true);
|
||||
combo.add_attribute(r->property_text(), activity_filter_cols.name);
|
||||
}
|
||||
|
||||
{
|
||||
auto* r = number_renderer_new();
|
||||
combo->pack_end(*r, true);
|
||||
combo->set_cell_data_func(*r, [r](auto const& iter) { render_number_func(r, iter); });
|
||||
combo.pack_end(*r, true);
|
||||
combo.set_cell_data_func(*r, [r](auto const& iter) { render_number_func(*r, iter); });
|
||||
}
|
||||
|
||||
activity_model_row_changed_tag_ = tmodel->signal_row_changed().connect(
|
||||
[activity_model](auto const& /*path*/, auto const& /*iter*/) { activity_model_update_idle(activity_model); });
|
||||
activity_model_row_inserted_tag_ = tmodel->signal_row_inserted().connect(
|
||||
[activity_model](auto const& /*path*/, auto const& /*iter*/) { activity_model_update_idle(activity_model); });
|
||||
activity_model_row_deleted_cb_tag_ = tmodel->signal_row_deleted().connect( //
|
||||
[activity_model](auto const& /*path*/) { activity_model_update_idle(activity_model); });
|
||||
activity_model_row_changed_tag_ = torrent_model_->signal_row_changed().connect( //
|
||||
[this](auto const& /*path*/, auto const& /*iter*/) { activity_model_update_idle(); });
|
||||
activity_model_row_inserted_tag_ = torrent_model_->signal_row_inserted().connect( //
|
||||
[this](auto const& /*path*/, auto const& /*iter*/) { activity_model_update_idle(); });
|
||||
activity_model_row_deleted_cb_tag_ = torrent_model_->signal_row_deleted().connect( //
|
||||
[this](auto const& /*path*/) { activity_model_update_idle(); });
|
||||
}
|
||||
|
||||
/****
|
||||
|
@ -610,10 +612,7 @@ void FilterBar::Impl::activity_combo_box_init(Gtk::ComboBox* combo, Glib::RefPtr
|
|||
*****
|
||||
****/
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool testText(tr_torrent const* tor, Glib::ustring const& key)
|
||||
bool FilterBar::Impl::testText(tr_torrent const& tor, Glib::ustring const& key)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
|
@ -624,20 +623,18 @@ bool testText(tr_torrent const* tor, Glib::ustring const& key)
|
|||
else
|
||||
{
|
||||
/* test the torrent name... */
|
||||
ret = Glib::ustring(tr_torrentName(tor)).casefold().find(key) != Glib::ustring::npos;
|
||||
ret = Glib::ustring(tr_torrentName(&tor)).casefold().find(key) != Glib::ustring::npos;
|
||||
|
||||
/* test the files... */
|
||||
for (tr_file_index_t i = 0, n = tr_torrentFileCount(tor); i < n && !ret; ++i)
|
||||
for (tr_file_index_t i = 0, n = tr_torrentFileCount(&tor); i < n && !ret; ++i)
|
||||
{
|
||||
ret = Glib::ustring(tr_torrentFile(tor, i).name).casefold().find(key) != Glib::ustring::npos;
|
||||
ret = Glib::ustring(tr_torrentFile(&tor, i).name).casefold().find(key) != Glib::ustring::npos;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void FilterBar::Impl::filter_entry_changed()
|
||||
{
|
||||
filter_text_ = gtr_str_strip(entry_->get_text().casefold());
|
||||
|
@ -652,10 +649,10 @@ void FilterBar::Impl::filter_entry_changed()
|
|||
|
||||
bool FilterBar::Impl::is_row_visible(Gtk::TreeModel::const_iterator const& iter)
|
||||
{
|
||||
auto* tor = static_cast<tr_torrent*>(iter->get_value(torrent_cols.torrent));
|
||||
auto* const tor = static_cast<tr_torrent*>(iter->get_value(torrent_cols.torrent));
|
||||
|
||||
return tor != nullptr && test_tracker(tor, active_tracker_type_, active_tracker_sitename_) &&
|
||||
test_torrent_activity(tor, active_activity_type_) && testText(tor, filter_text_);
|
||||
return tor != nullptr && test_tracker(*tor, active_tracker_type_, active_tracker_sitename_) &&
|
||||
test_torrent_activity(*tor, active_activity_type_) && testText(*tor, filter_text_);
|
||||
}
|
||||
|
||||
void FilterBar::Impl::selection_changed_cb()
|
||||
|
@ -715,17 +712,13 @@ bool FilterBar::Impl::update_count_label()
|
|||
_("_Show:") :
|
||||
fmt::format(_("_Show {count:L} of:"), fmt::arg("count", visibleCount)));
|
||||
|
||||
show_lb_->steal_data(DIRTY_KEY);
|
||||
return false;
|
||||
}
|
||||
|
||||
void FilterBar::Impl::update_count_label_idle()
|
||||
{
|
||||
bool const pending = show_lb_->get_data(DIRTY_KEY) != nullptr;
|
||||
|
||||
if (!pending)
|
||||
if (!update_count_label_tag_.connected())
|
||||
{
|
||||
show_lb_->set_data(DIRTY_KEY, GINT_TO_POINTER(1));
|
||||
update_count_label_tag_ = Glib::signal_idle().connect(sigc::mem_fun(*this, &Impl::update_count_label));
|
||||
}
|
||||
}
|
||||
|
@ -780,13 +773,20 @@ FilterBar::~FilterBar() = default;
|
|||
|
||||
FilterBar::Impl::Impl(FilterBar& widget, tr_session* session, Glib::RefPtr<Gtk::TreeModel> const& torrent_model)
|
||||
: widget_(widget)
|
||||
, session_(session)
|
||||
, torrent_model_(torrent_model)
|
||||
, activity_model_(activity_filter_model_new())
|
||||
, tracker_model_(tracker_filter_model_new())
|
||||
, activity_(get_template_child<Gtk::ComboBox>("activity_combo"))
|
||||
, tracker_(get_template_child<Gtk::ComboBox>("tracker_combo"))
|
||||
, entry_(get_template_child<Gtk::Entry>("text_entry"))
|
||||
, show_lb_(get_template_child<Gtk::Label>("show_label"))
|
||||
{
|
||||
activity_combo_box_init(activity_, torrent_model);
|
||||
tracker_combo_box_init(tracker_, torrent_model);
|
||||
activity_filter_model_update();
|
||||
tracker_filter_model_update();
|
||||
|
||||
activity_combo_box_init(*activity_);
|
||||
tracker_combo_box_init(*tracker_);
|
||||
|
||||
filter_model_ = Gtk::TreeModelFilter::create(torrent_model);
|
||||
filter_model_row_deleted_tag_ = filter_model_->signal_row_deleted().connect([this](auto const& /*path*/)
|
||||
|
@ -794,8 +794,6 @@ FilterBar::Impl::Impl(FilterBar& widget, tr_session* session, Glib::RefPtr<Gtk::
|
|||
filter_model_row_inserted_tag_ = filter_model_->signal_row_inserted().connect(
|
||||
[this](auto const& /*path*/, auto const& /*iter*/) { update_count_label_idle(); });
|
||||
|
||||
gtr_ptr_dynamic_cast<Gtk::TreeStore>(tracker_->get_model())->set_data(SESSION_KEY, session);
|
||||
|
||||
filter_model_->set_visible_func(sigc::mem_fun(*this, &Impl::is_row_visible));
|
||||
|
||||
tracker_->signal_changed().connect(sigc::mem_fun(*this, &Impl::selection_changed_cb));
|
||||
|
@ -814,18 +812,17 @@ FilterBar::Impl::Impl(FilterBar& widget, tr_session* session, Glib::RefPtr<Gtk::
|
|||
|
||||
FilterBar::Impl::~Impl()
|
||||
{
|
||||
if (update_count_label_tag_.connected())
|
||||
{
|
||||
update_count_label_tag_.disconnect();
|
||||
}
|
||||
update_count_label_tag_.disconnect();
|
||||
|
||||
filter_model_row_deleted_tag_.disconnect();
|
||||
filter_model_row_inserted_tag_.disconnect();
|
||||
|
||||
torrent_model_row_deleted_cb_tag_.disconnect();
|
||||
torrent_model_row_inserted_tag_.disconnect();
|
||||
torrent_model_row_changed_tag_.disconnect();
|
||||
activity_model_update_tag_.disconnect();
|
||||
tracker_model_row_deleted_cb_tag_.disconnect();
|
||||
tracker_model_row_inserted_tag_.disconnect();
|
||||
tracker_model_row_changed_tag_.disconnect();
|
||||
|
||||
activity_model_update_tag_.disconnect();
|
||||
activity_model_row_deleted_cb_tag_.disconnect();
|
||||
activity_model_row_inserted_tag_.disconnect();
|
||||
activity_model_row_changed_tag_.disconnect();
|
||||
|
|
|
@ -37,8 +37,6 @@ using FileListHandler = Glib::SListHandler<Glib::RefPtr<Gio::File>>;
|
|||
namespace
|
||||
{
|
||||
|
||||
auto const FileChosenKey = Glib::Quark("file-is-chosen");
|
||||
|
||||
class MakeProgressDialog : public Gtk::Dialog
|
||||
{
|
||||
public:
|
||||
|
@ -397,7 +395,6 @@ void MakeDialog::Impl::setFilename(std::string_view filename)
|
|||
|
||||
void MakeDialog::Impl::onChooserChosen(PathButton* chooser)
|
||||
{
|
||||
chooser->set_data(FileChosenKey, GINT_TO_POINTER(true));
|
||||
setFilename(chooser->get_filename());
|
||||
}
|
||||
|
||||
|
@ -405,14 +402,7 @@ void MakeDialog::Impl::onSourceToggled(Gtk::CheckButton* tb, PathButton* chooser
|
|||
{
|
||||
if (tb->get_active())
|
||||
{
|
||||
if (chooser->get_data(FileChosenKey) != nullptr)
|
||||
{
|
||||
onChooserChosen(chooser);
|
||||
}
|
||||
else
|
||||
{
|
||||
setFilename({});
|
||||
}
|
||||
onChooserChosen(chooser);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
class MessageLogColumnsModel : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
MessageLogColumnsModel()
|
||||
MessageLogColumnsModel() noexcept
|
||||
{
|
||||
add(sequence);
|
||||
add(name);
|
||||
|
|
|
@ -27,9 +27,9 @@ using UInt32VariantType = Glib::Variant<guint32>;
|
|||
namespace
|
||||
{
|
||||
|
||||
auto const NotificationsDbusName = Glib::ustring("org.freedesktop.Notifications"s);
|
||||
auto const NotificationsDbusCoreObject = Glib::ustring("/org/freedesktop/Notifications"s);
|
||||
auto const NotificationsDbusCoreInterface = Glib::ustring("org.freedesktop.Notifications"s);
|
||||
auto const NotificationsDbusName = "org.freedesktop.Notifications"sv; // TODO(C++20): Use ""s
|
||||
auto const NotificationsDbusCoreObject = "/org/freedesktop/Notifications"sv; // TODO(C++20): Use ""s
|
||||
auto const NotificationsDbusCoreInterface = "org.freedesktop.Notifications"sv; // TODO(C++20): Use ""s
|
||||
|
||||
struct TrNotification
|
||||
{
|
||||
|
@ -154,9 +154,9 @@ void gtr_notify_init()
|
|||
{
|
||||
Gio::DBus::Proxy::create_for_bus(
|
||||
TR_GIO_DBUS_BUS_TYPE(SESSION),
|
||||
NotificationsDbusName,
|
||||
NotificationsDbusCoreObject,
|
||||
NotificationsDbusCoreInterface,
|
||||
std::string(NotificationsDbusName),
|
||||
std::string(NotificationsDbusCoreObject),
|
||||
std::string(NotificationsDbusCoreInterface),
|
||||
&dbus_proxy_ready_callback,
|
||||
{},
|
||||
TR_GIO_DBUS_PROXY_FLAGS(DO_NOT_LOAD_PROPERTIES));
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "Session.h"
|
||||
#include "Utils.h" /* gtr_priority_combo_get_value() */
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
/****
|
||||
*****
|
||||
****/
|
||||
|
@ -28,7 +30,7 @@
|
|||
namespace
|
||||
{
|
||||
|
||||
auto const ShowOptionsDialogChoice = Glib::ustring("show_options_dialog");
|
||||
auto const ShowOptionsDialogChoice = "show_options_dialog"sv; // TODO(C++20): Use ""s
|
||||
|
||||
std::string get_source_file(tr_ctor& ctor)
|
||||
{
|
||||
|
@ -331,7 +333,7 @@ void TorrentFileChooserDialog::onOpenDialogResponse(int response, Glib::RefPtr<S
|
|||
gtr_pref_string_set(TR_KEY_open_dialog_dir, IF_GTKMM4(get_current_folder, get_current_folder_file)()->get_path());
|
||||
|
||||
bool const do_start = gtr_pref_flag_get(TR_KEY_start_added_torrents);
|
||||
bool const do_prompt = get_choice(ShowOptionsDialogChoice) == "true";
|
||||
bool const do_prompt = get_choice(std::string(ShowOptionsDialogChoice)) == "true";
|
||||
bool const do_notify = false;
|
||||
|
||||
#if GTKMM_CHECK_VERSION(4, 0, 0)
|
||||
|
@ -375,8 +377,8 @@ TorrentFileChooserDialog::TorrentFileChooserDialog(Gtk::Window& parent, Glib::Re
|
|||
IF_GTKMM4(set_current_folder, set_current_folder_file)(Gio::File::create_for_path(folder));
|
||||
}
|
||||
|
||||
add_choice(ShowOptionsDialogChoice, _("Show options dialog"));
|
||||
set_choice(ShowOptionsDialogChoice, gtr_pref_flag_get(TR_KEY_show_options_window) ? "true" : "false");
|
||||
add_choice(std::string(ShowOptionsDialogChoice), _("Show options dialog"));
|
||||
set_choice(std::string(ShowOptionsDialogChoice), gtr_pref_flag_get(TR_KEY_show_options_window) ? "true" : "false");
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
|
@ -257,7 +257,7 @@ void PageBase::init_time_combo(Gtk::ComboBox& combo, tr_quark const key)
|
|||
class TimeModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
TimeModelColumns()
|
||||
TimeModelColumns() noexcept
|
||||
{
|
||||
add(offset);
|
||||
add(title);
|
||||
|
@ -641,7 +641,7 @@ class RemotePage : public PageBase
|
|||
class WhitelistModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
WhitelistModelColumns()
|
||||
WhitelistModelColumns() noexcept
|
||||
{
|
||||
add(address);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ private:
|
|||
tr_session* session_ = nullptr;
|
||||
};
|
||||
|
||||
TorrentModelColumns::TorrentModelColumns()
|
||||
TorrentModelColumns::TorrentModelColumns() noexcept
|
||||
{
|
||||
add(name_collated);
|
||||
add(torrent);
|
||||
|
@ -1399,9 +1399,9 @@ void Session::Impl::update()
|
|||
namespace
|
||||
{
|
||||
|
||||
auto const SessionManagerServiceName = Glib::ustring("org.gnome.SessionManager"s);
|
||||
auto const SessionManagerInterface = Glib::ustring("org.gnome.SessionManager"s);
|
||||
auto const SessionManagerObjectPath = Glib::ustring("/org/gnome/SessionManager"s);
|
||||
auto const SessionManagerServiceName = "org.gnome.SessionManager"sv; // TODO(C++20): Use ""s
|
||||
auto const SessionManagerInterface = "org.gnome.SessionManager"sv; // TODO(C++20): Use ""s
|
||||
auto const SessionManagerObjectPath = "/org/gnome/SessionManager"sv; // TODO(C++20): Use ""s
|
||||
|
||||
bool gtr_inhibit_hibernation(guint32& cookie)
|
||||
{
|
||||
|
@ -1416,8 +1416,8 @@ bool gtr_inhibit_hibernation(guint32& cookie)
|
|||
auto const connection = Gio::DBus::Connection::get_sync(TR_GIO_DBUS_BUS_TYPE(SESSION));
|
||||
|
||||
auto response = connection->call_sync(
|
||||
SessionManagerObjectPath,
|
||||
SessionManagerInterface,
|
||||
std::string(SessionManagerObjectPath),
|
||||
std::string(SessionManagerInterface),
|
||||
"Inhibit",
|
||||
Glib::VariantContainerBase::create_tuple({
|
||||
Glib::Variant<Glib::ustring>::create(application),
|
||||
|
@ -1425,7 +1425,7 @@ bool gtr_inhibit_hibernation(guint32& cookie)
|
|||
Glib::Variant<Glib::ustring>::create(reason),
|
||||
Glib::Variant<guint32>::create(flags),
|
||||
}),
|
||||
SessionManagerServiceName,
|
||||
std::string(SessionManagerServiceName),
|
||||
1000);
|
||||
|
||||
cookie = Glib::VariantBase::cast_dynamic<Glib::Variant<guint32>>(response.get_child(0)).get();
|
||||
|
@ -1450,11 +1450,11 @@ void gtr_uninhibit_hibernation(guint inhibit_cookie)
|
|||
auto const connection = Gio::DBus::Connection::get_sync(TR_GIO_DBUS_BUS_TYPE(SESSION));
|
||||
|
||||
connection->call_sync(
|
||||
SessionManagerObjectPath,
|
||||
SessionManagerInterface,
|
||||
std::string(SessionManagerObjectPath),
|
||||
std::string(SessionManagerInterface),
|
||||
"Uninhibit",
|
||||
Glib::VariantContainerBase::create_tuple({ Glib::Variant<guint32>::create(inhibit_cookie) }),
|
||||
SessionManagerServiceName,
|
||||
std::string(SessionManagerServiceName),
|
||||
1000);
|
||||
|
||||
/* logging */
|
||||
|
|
|
@ -144,7 +144,7 @@ private:
|
|||
class TorrentModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
TorrentModelColumns();
|
||||
TorrentModelColumns() noexcept;
|
||||
|
||||
Gtk::TreeModelColumn<Glib::ustring> name_collated;
|
||||
Gtk::TreeModelColumn<gpointer> torrent;
|
||||
|
|
11
gtk/Utils.cc
11
gtk/Utils.cc
|
@ -491,7 +491,7 @@ namespace
|
|||
class EnumComboModelColumns : public Gtk::TreeModelColumnRecord
|
||||
{
|
||||
public:
|
||||
EnumComboModelColumns()
|
||||
EnumComboModelColumns() noexcept
|
||||
{
|
||||
add(value);
|
||||
add(label);
|
||||
|
@ -589,15 +589,10 @@ void gtr_priority_combo_init(Gtk::ComboBox& combo)
|
|||
****
|
||||
***/
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
auto const ChildHiddenKey = Glib::Quark("gtr-child-hidden");
|
||||
|
||||
} // namespace
|
||||
|
||||
void gtr_widget_set_visible(Gtk::Widget& widget, bool is_visible)
|
||||
{
|
||||
static auto const ChildHiddenKey = Glib::Quark("gtr-child-hidden");
|
||||
|
||||
auto* const widget_as_window = dynamic_cast<Gtk::Window*>(&widget);
|
||||
if (widget_as_window == nullptr)
|
||||
{
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
// It may be used under the MIT (SPDX: MIT) license.
|
||||
// License text can be found in the licenses/ folder.
|
||||
|
||||
#include <clocale>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include <glibmm.h>
|
||||
#include <glibmm/i18n.h>
|
||||
|
@ -41,7 +43,7 @@ Glib::OptionEntry create_option_entry(Glib::ustring const& long_name, gchar shor
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
/* init i18n */
|
||||
setlocale(LC_ALL, "");
|
||||
std::ignore = std::setlocale(LC_ALL, "");
|
||||
bindtextdomain(AppTranslationDomainName, TRANSMISSIONLOCALEDIR);
|
||||
bind_textdomain_codeset(AppTranslationDomainName, "UTF-8");
|
||||
textdomain(AppTranslationDomainName);
|
||||
|
|
Loading…
Reference in New Issue