From 2b75869c80f25464cf02a7f167eb1fb9d2887e4c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 1 Jun 2024 04:50:51 -0500 Subject: [PATCH] fix: cert-err58 warning in declaration of TrayIconName, AppIconName, AppName (#6861) --- gtk/SystemTrayIcon.cc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/gtk/SystemTrayIcon.cc b/gtk/SystemTrayIcon.cc index 2734bdc0d..f603ee401 100644 --- a/gtk/SystemTrayIcon.cc +++ b/gtk/SystemTrayIcon.cc @@ -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());