Support change to enum definitions in gtkmm/glibmm/pangomm (#3801)

Newer versions (gtkmm 4 and its dependencies) of these libraries have
switched from enums to enum classes. Wrap the names with macros to
support both.
This commit is contained in:
Mike Gelfand
2022-09-10 16:19:54 +03:00
committed by GitHub
parent 33f96810a1
commit 9f0fbb38ec
20 changed files with 236 additions and 148 deletions

View File

@@ -348,7 +348,7 @@ void register_magnet_link_handler()
auto const app = Gio::AppInfo::create_from_commandline(
"transmission-gtk",
"transmission-gtk",
Gio::APP_INFO_CREATE_SUPPORTS_URIS);
TR_GIO_APP_INFO_CREATE_FLAGS(SUPPORTS_URIS));
app->set_as_default_for_type(content_type);
}
catch (Gio::Error const& e)
@@ -653,7 +653,7 @@ std::string get_application_id(std::string const& config_dir)
} // namespace
Application::Application(std::string const& config_dir, bool start_paused, bool is_iconified)
: Gtk::Application(get_application_id(config_dir), Gio::APPLICATION_HANDLES_OPEN)
: Gtk::Application(get_application_id(config_dir), TR_GIO_APPLICATION_FLAGS(HANDLES_OPEN))
, impl_(std::make_unique<Impl>(*this, config_dir, start_paused, is_iconified))
{
}
@@ -724,14 +724,14 @@ void Application::Impl::app_setup()
_("Transmission is a file sharing program. When you run a torrent, its data will be "
"made available to others by means of upload. Any content you share is your sole responsibility."),
false,
Gtk::MESSAGE_OTHER,
Gtk::BUTTONS_NONE,
TR_GTK_MESSAGE_TYPE(OTHER),
TR_GTK_BUTTONS_TYPE(NONE),
true);
w.add_button(_("_Cancel"), Gtk::RESPONSE_REJECT);
w.add_button(_("I _Agree"), Gtk::RESPONSE_ACCEPT);
w.set_default_response(Gtk::RESPONSE_ACCEPT);
w.add_button(_("_Cancel"), TR_GTK_RESPONSE_TYPE(REJECT));
w.add_button(_("I _Agree"), TR_GTK_RESPONSE_TYPE(ACCEPT));
w.set_default_response(TR_GTK_RESPONSE_TYPE(ACCEPT));
if (w.run() == Gtk::RESPONSE_ACCEPT)
if (w.run() == TR_GTK_RESPONSE_TYPE(ACCEPT))
{
// only show it once
gtr_pref_flag_set(TR_KEY_user_has_given_informed_consent, true);
@@ -900,8 +900,8 @@ void Application::Impl::on_app_exit()
auto* p = Gtk::make_managed<Gtk::Grid>();
p->set_column_spacing(GUI_PAD_BIG);
p->set_halign(Gtk::ALIGN_CENTER);
p->set_valign(Gtk::ALIGN_CENTER);
p->set_halign(TR_GTK_ALIGN(CENTER));
p->set_valign(TR_GTK_ALIGN(CENTER));
c->add(*p);
auto* icon = Gtk::make_managed<Gtk::Image>("network-workgroup", Gtk::ICON_SIZE_DIALOG);
@@ -909,19 +909,19 @@ void Application::Impl::on_app_exit()
auto* top_label = Gtk::make_managed<Gtk::Label>();
top_label->set_markup(fmt::format(FMT_STRING("<b>{:s}</b>"), _("Closing Connections…")));
top_label->set_halign(Gtk::ALIGN_START);
top_label->set_valign(Gtk::ALIGN_CENTER);
top_label->set_halign(TR_GTK_ALIGN(START));
top_label->set_valign(TR_GTK_ALIGN(CENTER));
p->attach(*top_label, 1, 0, 1, 1);
auto* bottom_label = Gtk::make_managed<Gtk::Label>(_("Sending upload/download totals to tracker…"));
bottom_label->set_halign(Gtk::ALIGN_START);
bottom_label->set_valign(Gtk::ALIGN_CENTER);
bottom_label->set_halign(TR_GTK_ALIGN(START));
bottom_label->set_valign(TR_GTK_ALIGN(CENTER));
p->attach(*bottom_label, 1, 1, 1, 1);
auto* button = Gtk::make_managed<Gtk::Button>(_("_Quit Now"), true);
button->set_margin_top(GUI_PAD);
button->set_halign(Gtk::ALIGN_START);
button->set_valign(Gtk::ALIGN_END);
button->set_halign(TR_GTK_ALIGN(START));
button->set_valign(TR_GTK_ALIGN(END));
button->signal_clicked().connect([]() { ::exit(0); });
p->attach(*button, 1, 2, 1, 1);
@@ -959,7 +959,7 @@ void Application::Impl::show_torrent_errors(Glib::ustring const& primary, std::v
s << leader << ' ' << f << '\n';
}
Gtk::MessageDialog w(*wind_, primary, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
Gtk::MessageDialog w(*wind_, primary, false, TR_GTK_MESSAGE_TYPE(ERROR), TR_GTK_BUTTONS_TYPE(CLOSE));
w.set_secondary_text(s.str());
w.run();