mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
Add support for GTK 4 (#3916)
* Make compact mode switch work for both GTK 3 and 4 * Implement GTK 4-specific view gesture handling * Fix torrents view context menu on GTK 4 * Explicitly show/hide menubar on startup/teardown * Switch from `Gtk::Pixbuf` to `Gio::Icon` for views * Support GTK 4 exceptions based on `std::exception` * Fix options menu setup with GTK 4 * Use `delete-event` (GTK 3) and `close-request` (GTK 4) signals to handle window clousure * Add custom file chooser button implementation GTK 4 drops FileChooserButton widget and suggests implementing it using Button. * Add helpers to set X11 hints with GTK 4 * Remove `HigWorkarea` class that's no longer used * Make main menu shortcuts work with GTK 4 * Make drops work in main window and make dialog with GTK 4 * Remove unused `gtr_action_get_widget()` helper * Fix text direction mark setup with GTK 4 (due to switch to enum class) * Fix file tree font size calculation with GTK 4 * Fix crash during shutdown with GTK 4 * Switch from `RadioButton` to `CheckButton` for compatibility with GTK 4 * Fix opening files with GTK 4 * Rework torrent cell renderer to support both GTK 3 and 4 * Disable system tray icon support with GTK 4 * Fix windows positioning with GTK 4 * Fix focus event handling with GTK 4 * Adapt to tree model row/iterator changes in GTK 4 * Adapt to toplevel/root window changes in GTK 4 * Adapt to clipboard changes in GTK 4 * Adapt to icon/theme changes in GTK 4 * Adapt to file/path changes in GTK 4 * Random leftover fixes for GTK 4 compatibility * Clean up unused code * Move GTK 3 *.ui files into a subdirectory * Add GTK 4 *.ui files * Search for both GTK 3 and 4 during configuration
This commit is contained in:
@@ -402,12 +402,12 @@ int compare_time(time_t a, time_t b)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int compare_by_name(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_name(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
return a->get_value(torrent_cols.name_collated).compare(b->get_value(torrent_cols.name_collated));
|
||||
}
|
||||
|
||||
int compare_by_queue(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_queue(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
auto const* const sa = tr_torrentStatCached(static_cast<tr_torrent*>(a->get_value(torrent_cols.torrent)));
|
||||
auto const* const sb = tr_torrentStatCached(static_cast<tr_torrent*>(b->get_value(torrent_cols.torrent)));
|
||||
@@ -415,7 +415,7 @@ int compare_by_queue(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator
|
||||
return sb->queuePosition - sa->queuePosition;
|
||||
}
|
||||
|
||||
int compare_by_ratio(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_ratio(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -435,7 +435,7 @@ int compare_by_ratio(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator
|
||||
return ret;
|
||||
}
|
||||
|
||||
int compare_by_activity(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_activity(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -463,7 +463,7 @@ int compare_by_activity(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::itera
|
||||
return ret;
|
||||
}
|
||||
|
||||
int compare_by_age(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_age(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
auto* const ta = static_cast<tr_torrent*>(a->get_value(torrent_cols.torrent));
|
||||
auto* const tb = static_cast<tr_torrent*>(b->get_value(torrent_cols.torrent));
|
||||
@@ -477,7 +477,7 @@ int compare_by_age(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator c
|
||||
return ret;
|
||||
}
|
||||
|
||||
int compare_by_size(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_size(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
auto const size_a = tr_torrentTotalSize(static_cast<tr_torrent*>(a->get_value(torrent_cols.torrent)));
|
||||
auto const size_b = tr_torrentTotalSize(static_cast<tr_torrent*>(b->get_value(torrent_cols.torrent)));
|
||||
@@ -491,7 +491,7 @@ int compare_by_size(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator
|
||||
return ret;
|
||||
}
|
||||
|
||||
int compare_by_progress(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_progress(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
auto const* const sa = tr_torrentStatCached(static_cast<tr_torrent*>(a->get_value(torrent_cols.torrent)));
|
||||
auto const* const sb = tr_torrentStatCached(static_cast<tr_torrent*>(b->get_value(torrent_cols.torrent)));
|
||||
@@ -510,7 +510,7 @@ int compare_by_progress(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::itera
|
||||
return ret;
|
||||
}
|
||||
|
||||
int compare_by_eta(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_eta(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
auto const* const sa = tr_torrentStatCached(static_cast<tr_torrent*>(a->get_value(torrent_cols.torrent)));
|
||||
auto const* const sb = tr_torrentStatCached(static_cast<tr_torrent*>(b->get_value(torrent_cols.torrent)));
|
||||
@@ -524,7 +524,7 @@ int compare_by_eta(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator c
|
||||
return ret;
|
||||
}
|
||||
|
||||
int compare_by_state(Gtk::TreeModel::iterator const& a, Gtk::TreeModel::iterator const& b)
|
||||
int compare_by_state(Gtk::TreeModel::const_iterator const& a, Gtk::TreeModel::const_iterator const& b)
|
||||
{
|
||||
auto const sa = a->get_value(torrent_cols.activity);
|
||||
auto const sb = b->get_value(torrent_cols.activity);
|
||||
@@ -820,8 +820,8 @@ Session::Impl::Impl(Session& core, tr_session* session)
|
||||
{
|
||||
raw_model_ = Gtk::ListStore::create(torrent_cols);
|
||||
sorted_model_ = Gtk::TreeModelSort::create(raw_model_);
|
||||
sorted_model_->set_default_sort_func([](Gtk::TreeModel::iterator const& /*a*/, Gtk::TreeModel::iterator const& /*b*/)
|
||||
{ return 0; });
|
||||
sorted_model_->set_default_sort_func(
|
||||
[](Gtk::TreeModel::const_iterator const& /*a*/, Gtk::TreeModel::const_iterator const& /*b*/) { return 0; });
|
||||
|
||||
/* init from prefs & listen to pref changes */
|
||||
on_pref_changed(TR_KEY_sort_mode);
|
||||
@@ -900,11 +900,11 @@ struct metadata_callback_data
|
||||
|
||||
Gtk::TreeModel::iterator find_row_from_torrent_id(Glib::RefPtr<Gtk::TreeModel> const& model, tr_torrent_id_t id)
|
||||
{
|
||||
for (auto const& row : model->children())
|
||||
for (auto& row : model->children())
|
||||
{
|
||||
if (id == row.get_value(torrent_cols.torrent_id))
|
||||
{
|
||||
return row;
|
||||
return TR_GTK_TREE_MODEL_CHILD_ITER(row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1325,7 +1325,7 @@ int gtr_compare_double(double const a, double const b, int decimal_places)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void update_foreach(Gtk::TreeModel::Row const& row)
|
||||
void update_foreach(Gtk::TreeModel::Row& row)
|
||||
{
|
||||
/* get the old states */
|
||||
auto* const tor = static_cast<tr_torrent*>(row.get_value(torrent_cols.torrent));
|
||||
@@ -1407,7 +1407,7 @@ void Session::start_now(tr_torrent_id_t id)
|
||||
void Session::Impl::update()
|
||||
{
|
||||
/* update the model */
|
||||
for (auto const& row : raw_model_->children())
|
||||
for (auto row : raw_model_->children())
|
||||
{
|
||||
update_foreach(row);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user