fix: cert-err58 warning in declaration of TrayIconName, AppIconName, AppName (#6861)

This commit is contained in:
Charles Kerr 2024-06-01 04:50:51 -05:00 committed by GitHub
parent a18fca5950
commit 2b75869c80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 18 deletions

View File

@ -55,12 +55,12 @@ namespace
{
#if !defined(TR_SYS_TRAY_IMPL_NONE)
auto const TrayIconName = Glib::ustring("transmission-tray-icon"s);
auto const AppIconName = Glib::ustring("transmission"s);
char const* const TrayIconName = "transmission-tray-icon";
char const* const AppIconName = "transmission";
#endif
#if defined(TR_SYS_TRAY_IMPL_APPINDICATOR)
auto const AppName = Glib::ustring("transmission-gtk"s);
char const* const AppName = "transmission-gtk";
#endif
} // namespace
@ -138,23 +138,11 @@ namespace
Glib::ustring getIconName()
{
Glib::ustring icon_name;
// if the tray's icon is a 48x48 file, use it.
// otherwise, use the fallback builtin icon.
if (auto theme = Gtk::IconTheme::get_default(); !theme->has_icon(TrayIconName))
{
icon_name = AppIconName;
}
else
{
auto const icon_info = theme->lookup_icon(TrayIconName, 48, Gtk::ICON_LOOKUP_USE_BUILTIN);
bool const icon_is_builtin = icon_info.get_filename().empty();
icon_name = icon_is_builtin ? AppIconName : TrayIconName;
}
return icon_name;
auto const icon = Gtk::IconTheme::get_default()->lookup_icon(TrayIconName, 48, Gtk::ICON_LOOKUP_USE_BUILTIN);
return icon && !icon.get_filename().empty() ? TrayIconName : AppIconName;
}
#endif
@ -199,7 +187,7 @@ SystemTrayIcon::Impl::Impl([[maybe_unused]] Gtk::Window& main_window, Glib::RefP
#endif
#if defined(TR_SYS_TRAY_IMPL_APPINDICATOR)
indicator_ = app_indicator_new(AppName.c_str(), icon_name.c_str(), APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
indicator_ = app_indicator_new(AppName, icon_name.c_str(), APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
app_indicator_set_status(indicator_, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_menu(indicator_, Glib::unwrap(menu_));
app_indicator_set_title(indicator_, Glib::get_application_name().c_str());