From f3bb6efd96f84dbd3641da37ffe8e054259a66fa Mon Sep 17 00:00:00 2001 From: BlackAngelTVdev Date: Mon, 28 Sep 2026 22:21:24 +0200 Subject: [PATCH] feat(MINE): add <> WIP --- CMakeLists.txt | 47 ++++++++++++++++++++++++++++-- resources/icons/plugin-package.svg | 6 ++++ resources/mime/fws-pacmanager.xml | 44 ++++++++++++++++++++++++++++ resources/mime/mimeapps.list | 29 ++++++++++++++++++ 4 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 resources/icons/plugin-package.svg create mode 100644 resources/mime/fws-pacmanager.xml create mode 100644 resources/mime/mimeapps.list diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d8cf32..b973a3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,49 @@ endif() install(FILES resources/icons/package.svg DESTINATION share/icons/hicolor/scalable/apps RENAME org.fws.PacManager.svg) + +# Same route for the .fwspacm plugin packages, which the entry above does not +# cover: the Flatpak types are declared by flatpak itself, so Dolphin already +# knows them, but nothing declares ours. The XML gives the extension a MIME +# type (and the icon a name), mimeapps.list says which application opens it. +# +# update-mime-database is run at install time because the spec requires it: it +# is what merges the XML into the shared database the file managers read. It is +# a hard requirement for .fwspacm to be recognised at all, so a missing one +# fails the install rather than leaving a half-configured desktop behind. +install(FILES resources/mime/fws-pacmanager.xml + DESTINATION share/mime/packages) +# Beside the desktop entry, which is the location XDG_DATA_DIRS/applications +# reads. No patching needed: it names the desktop entry, not an absolute path. +install(FILES resources/mime/mimeapps.list + DESTINATION share/applications) +install(FILES resources/icons/plugin-package.svg + DESTINATION share/icons/hicolor/scalable/apps + RENAME application-vnd.fws.pacmanager.plugin-package.svg) +# Refreshing the database is a system-wide side effect, so it is skipped when +# installing into a staging root (DESTDIR set): the packager runs it against the +# real prefix once the package is deployed. That also means a packaging build +# never needs shared-mime-info installed on the build machine. +install(CODE " + if(NOT \"\$ENV{DESTDIR}\" STREQUAL \"\") + message(STATUS \"Skipping update-mime-database (DESTDIR is set)\") + else() + find_program(UPDATE_MIME_DATABASE update-mime-database) + if(NOT UPDATE_MIME_DATABASE) + message(FATAL_ERROR + \"update-mime-database not found: install shared-mime-info, or \" + \".fwspacm files will not be recognised by the desktop\") + endif() + execute_process( + COMMAND \"\${UPDATE_MIME_DATABASE}\" \"\${CMAKE_INSTALL_PREFIX}/share/mime\" + RESULT_VARIABLE MIME_RESULT + OUTPUT_VARIABLE MIME_OUTPUT + ERROR_VARIABLE MIME_OUTPUT) + if(NOT MIME_RESULT EQUAL 0) + message(FATAL_ERROR \"update-mime-database failed: \${MIME_OUTPUT}\") + endif() + endif() +") install(CODE " set(DESKTOP_DIR \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/share/applications\") file(MAKE_DIRECTORY \"\${DESKTOP_DIR}\") @@ -143,10 +186,10 @@ Exec=${CMAKE_INSTALL_PREFIX}/bin/PacManager %U Icon=org.fws.PacManager Terminal=false Categories=System;PackageManager;Qt; -MimeType=application/vnd.flatpak.ref;application/vnd.flatpak.repo;application/vnd.flatpak; +MimeType=application/vnd.flatpak.ref;application/vnd.flatpak.repo;application/vnd.flatpak;application/vnd.fws.pacmanager.plugin-package; StartupNotify=true \") -") + ") install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME}) # Tests diff --git a/resources/icons/plugin-package.svg b/resources/icons/plugin-package.svg new file mode 100644 index 0000000..4ab1340 --- /dev/null +++ b/resources/icons/plugin-package.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/resources/mime/fws-pacmanager.xml b/resources/mime/fws-pacmanager.xml new file mode 100644 index 0000000..aa11cc6 --- /dev/null +++ b/resources/mime/fws-pacmanager.xml @@ -0,0 +1,44 @@ + + + + + Paquet de plugin PacManager + PacManager plugin package + + + + + + + + + + diff --git a/resources/mime/mimeapps.list b/resources/mime/mimeapps.list new file mode 100644 index 0000000..2d8b441 --- /dev/null +++ b/resources/mime/mimeapps.list @@ -0,0 +1,29 @@ +# Which files PacManager opens, and how. +# +# The MIME database (resources/mime/fws-pacmanager.xml) only says what a file +# *is*; it cannot choose an application. That is this file's job, and it is the +# reason installing the app is enough to make the association show up in a file +# manager -- no xdg-mime call is needed afterwards. +# +# [Default Applications] -- a double click opens the file with PacManager. +# Only the plugin packages are claimed outright: nothing else handles them, the +# type is private, and a package is useless without the application that reads +# it. The Flatpak formats are deliberately *not* here: a .flatpakref belongs to +# the Flatpak world, and stealing the double click from it would be rude to +# whoever installed flatpak. +# +# [Added Associations] -- PacManager appears in "Ouvrir avec" (and stays out of +# the default). The user picks it when they mean it; their own default set in +# the system settings keeps winning. This is what the desktop entry's MimeType +# line advertises. +# +# Both sections are additive for the types they name and touch nothing else, so +# a user's own choices in ~/.config/mimeapps.list still override them. + +[Default Applications] +application/vnd.fws.pacmanager.plugin-package=org.fws.PacManager.desktop + +[Added Associations] +application/vnd.flatpak.ref=org.fws.PacManager.desktop; +application/vnd.flatpak.repo=org.fws.PacManager.desktop; +application/vnd.flatpak=org.fws.PacManager.desktop;