mupp_plot: set its own macOS Dock icon and match musrview's icon style.

TGCocoa::SetIconPixmap()/SetClassHints() are no-ops on macOS, so the xpm
mupp_plot set on its TRootCanvas only ever applied on X11 - the Dock/window
icon stayed the generic ROOT one on macOS. Use the same Cocoa helper
(PMacDockIcon.mm's SetMacDockIcon()) already used by musrview/musrFT/musrt0
to set the Dock icon from a compiled-in PNG.

The new icon's tile shape and background were measured off
src/classes/icons/musrview-512.png and matched: a rounded-square tile with
~22% corner radius and a vertical light-to-medium blue gradient background,
instead of the previous plain white tile with a gray border.

Also:
- compile PMacDockIcon.mm into mupp_plot on Darwin and link Cocoa, mirroring
  src/classes/CMakeLists.txt
- fix MUSRFIT_XDG_DATA_DIR -> MUSRFIT_XDG_DATADIR in the Linux install rules
  (the former is not a defined variable, so install() was resolving to
  absolute paths at the filesystem root)
- install a 512x512 icon on Linux too (hicolor/512x512/apps), matching
  musrview, and list it in the rpm spec

Done for both the Qt6 and Qt5 plotter.
This commit is contained in:
suter_a committed 2026-10-29 10:23:15 +01:00
1 parent 002663edcc
commit 1719375bbc
10 files changed
+3407 -10

No files matched your search

+2 -2
View File
@@ -83,8 +83,8 @@ PMusrCanvas, the TCanvas based front end musrview used so far, has been removed
together with its dictionary.
musrFT, musrt0 and mupp_plot show their own window/dock icon instead of the
generic ROOT one. On Linux, matching .desktop files and icons are installed to
MUSRFIT_XDG_DATA_DIR.
generic ROOT one (on macOS set via Cocoa). On Linux, matching .desktop files and
icons are installed to MUSRFIT_XDG_DATA_DIR.
Release of V1.12.1, 2026/08/25
==============================
+1
View File
@@ -102,6 +102,7 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/icons/hicolor/48x48/apps/musrt0.png
%{_datadir}/applications/mupp_plot.desktop
%{_datadir}/icons/hicolor/48x48/apps/mupp_plot.png
%{_datadir}/icons/hicolor/512x512/apps/mupp_plot.png
%_prefix/share/musrfit
+18 -4
View File
@@ -63,7 +63,12 @@ set(DICT
)
#--- define executable --------------------------------------------------------
add_executable(mupp_plot ${SOURCE} ${DICT})
#--- on macOS the Dock icon cannot be set through ROOT, hence the Cocoa helper
#--- shared with musrview/musrFT/musrt0 is compiled in as well ----------------
add_executable(mupp_plot
${SOURCE} ${DICT}
$<$<PLATFORM_ID:Darwin>:${CMAKE_SOURCE_DIR}/src/classes/PMacDockIcon.mm>
)
#--- add all needed include directories ---------------------------------------
target_include_directories(mupp_plot
@@ -73,10 +78,14 @@ target_include_directories(mupp_plot
${CMAKE_CURRENT_BINARY_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
$<$<PLATFORM_ID:Darwin>:${CMAKE_SOURCE_DIR}/src/include>
)
#--- define all to be linked libs ---------------------------------------------
target_link_libraries(mupp_plot ${ROOT_LIBRARIES})
if (APPLE)
target_link_libraries(mupp_plot "-framework Cocoa")
endif (APPLE)
#--- install ------------------------------------------------------------------
if (APPLE)
@@ -96,15 +105,20 @@ if (UNIX AND NOT APPLE)
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/mupp_plot.desktop
DESTINATION ${MUSRFIT_XDG_DATA_DIR}/applications
DESTINATION ${MUSRFIT_XDG_DATADIR}/applications
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/mupp_plot.png
DESTINATION ${MUSRFIT_XDG_DATA_DIR}/icons/hicolor/48x48/apps
DESTINATION ${MUSRFIT_XDG_DATADIR}/icons/hicolor/48x48/apps
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/mupp_plot-512.png
DESTINATION ${MUSRFIT_XDG_DATADIR}/icons/hicolor/512x512/apps
RENAME mupp_plot.png
)
#--- a stale icon cache would hide the new icon, hence refresh an existing one
install(CODE "
set(icon_dir \"\$ENV{DESTDIR}${MUSRFIT_XDG_DATA_DIR}/icons/hicolor\")
set(icon_dir \"\$ENV{DESTDIR}${MUSRFIT_XDG_DATADIR}/icons/hicolor\")
find_program(GTK_UPDATE_ICON_CACHE gtk-update-icon-cache)
if (GTK_UPDATE_ICON_CACHE AND EXISTS \"\${icon_dir}/icon-theme.cache\")
execute_process(COMMAND \${GTK_UPDATE_ICON_CACHE} -q -t -f \"\${icon_dir}\")
@@ -45,6 +45,10 @@
#include "PMuppCanvas.h"
#include "icons/mupp_plot_icon.xpm"
#ifdef __APPLE__
#include "PMacDockIcon.h"
#include "icons/mupp_plot_icon_png.h"
#endif
static const char *gFiletypes[] = { "Data files", "*.dat",
"All files", "*",
@@ -247,6 +251,11 @@ void PMuppCanvas::InitMuppCanvas(const Char_t *title, Int_t wtopx, Int_t wtopy,
// replace the generic ROOT window icon; the class hint lets the desktop match mupp_plot.desktop
fImp->SetIconPixmap(const_cast<char**>(mupp_plot_icon_xpm));
fImp->SetClassHints("mupp_plot", "mupp_plot");
#ifdef __APPLE__
// on macOS, TGCocoa::SetIconPixmap()/SetClassHints() above are no-ops: the Dock icon
// is process-wide and must be set via NSApplication instead
SetMacDockIcon(mupp_plot_icon_png, mupp_plot_icon_png_len);
#endif
fImp->Connect("CloseWindow()", "PMuppCanvas", this, "WindowClosed()");
fBar = fImp->GetMenuBar();
fPopupMain = fBar->AddPopup("&Mupp");
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

File diff suppressed because it is too large. Load diff
+18 -4
View File
@@ -63,7 +63,12 @@ set(DICT
)
#--- define executable --------------------------------------------------------
add_executable(mupp_plot ${SOURCE} ${DICT})
#--- on macOS the Dock icon cannot be set through ROOT, hence the Cocoa helper
#--- shared with musrview/musrFT/musrt0 is compiled in as well ----------------
add_executable(mupp_plot
${SOURCE} ${DICT}
$<$<PLATFORM_ID:Darwin>:${CMAKE_SOURCE_DIR}/src/classes/PMacDockIcon.mm>
)
#--- add all needed include directories ---------------------------------------
target_include_directories(mupp_plot
@@ -73,10 +78,14 @@ target_include_directories(mupp_plot
${CMAKE_CURRENT_BINARY_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
$<$<PLATFORM_ID:Darwin>:${CMAKE_SOURCE_DIR}/src/include>
)
#--- define all to be linked libs ---------------------------------------------
target_link_libraries(mupp_plot ${ROOT_LIBRARIES})
if (APPLE)
target_link_libraries(mupp_plot "-framework Cocoa")
endif (APPLE)
#--- install ------------------------------------------------------------------
if (APPLE)
@@ -96,15 +105,20 @@ if (UNIX AND NOT APPLE)
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/mupp_plot.desktop
DESTINATION ${MUSRFIT_XDG_DATA_DIR}/applications
DESTINATION ${MUSRFIT_XDG_DATADIR}/applications
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/mupp_plot.png
DESTINATION ${MUSRFIT_XDG_DATA_DIR}/icons/hicolor/48x48/apps
DESTINATION ${MUSRFIT_XDG_DATADIR}/icons/hicolor/48x48/apps
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/mupp_plot-512.png
DESTINATION ${MUSRFIT_XDG_DATADIR}/icons/hicolor/512x512/apps
RENAME mupp_plot.png
)
#--- a stale icon cache would hide the new icon, hence refresh an existing one
install(CODE "
set(icon_dir \"\$ENV{DESTDIR}${MUSRFIT_XDG_DATA_DIR}/icons/hicolor\")
set(icon_dir \"\$ENV{DESTDIR}${MUSRFIT_XDG_DATADIR}/icons/hicolor\")
find_program(GTK_UPDATE_ICON_CACHE gtk-update-icon-cache)
if (GTK_UPDATE_ICON_CACHE AND EXISTS \"\${icon_dir}/icon-theme.cache\")
execute_process(COMMAND \${GTK_UPDATE_ICON_CACHE} -q -t -f \"\${icon_dir}\")
@@ -68,6 +68,10 @@
#include "PMuppCanvas.h"
#include "icons/mupp_plot_icon.xpm"
#ifdef __APPLE__
#include "PMacDockIcon.h"
#include "icons/mupp_plot_icon_png.h"
#endif
static const char *gFiletypes[] = { "Data files", "*.dat",
"All files", "*",
@@ -278,6 +282,11 @@ void PMuppCanvas::InitMuppCanvas(const Char_t *title, Int_t wtopx, Int_t wtopy,
// replace the generic ROOT window icon; the class hint lets the desktop match mupp_plot.desktop
fImp->SetIconPixmap(const_cast<char**>(mupp_plot_icon_xpm));
fImp->SetClassHints("mupp_plot", "mupp_plot");
#ifdef __APPLE__
// on macOS, TGCocoa::SetIconPixmap()/SetClassHints() above are no-ops: the Dock icon
// is process-wide and must be set via NSApplication instead
SetMacDockIcon(mupp_plot_icon_png, mupp_plot_icon_png_len);
#endif
fImp->Connect("CloseWindow()", "PMuppCanvas", this, "WindowClosed()");
fBar = fImp->GetMenuBar();
fPopupMain = fBar->AddPopup("&Mupp");
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

File diff suppressed because it is too large. Load diff