Add support for KDE search completion

KDE krunner supports DBus plugins that allow search completion
comparable to the already supported gnome-shell searchprovider.

Exporting the contents of the runner directory enables us to enable
search results from within flatpack applications.
This commit is contained in:
Cajus Pollmeier
2024-09-18 11:17:13 +02:00
committed by Patrick
parent 117c825fb8
commit fb37012475
5 changed files with 31 additions and 0 deletions

View File

@@ -236,6 +236,7 @@ collect_exports (GFile *base,
"share/icons", /* Icons */
"share/dbus-1/services", /* D-Bus service files */
"share/gnome-shell/search-providers", /* Search providers */
"share/krunner/dbusplugins", /* KDE krunner DBus plugins */
"share/appdata", /* Copy appdata/metainfo files (legacy path) */
"share/metainfo", /* Copy appdata/metainfo files */
NULL,

View File

@@ -3181,6 +3181,10 @@ flatpak_context_get_allowed_exports (FlatpakContext *context,
{
g_ptr_array_add (allowed_extensions, g_strdup (".ini"));
}
else if (strcmp (source_path, "share/krunner/dbusplugins") == 0)
{
g_ptr_array_add (allowed_extensions, g_strdup (".desktop"));
}
else if (strcmp (source_path, "share/mime/packages") == 0)
{
g_ptr_array_add (allowed_extensions, g_strdup (".xml"));

View File

@@ -7604,6 +7604,15 @@ export_desktop_file (const char *app,
/* Add a marker so consumers can easily find out that this launches a sandbox */
g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-Flatpak", app);
/* Disable krunner dbusplugins by default, so that flatpak applications cannot
* unintentionally grab sensible search data.
*/
if (g_key_file_get_boolean (keyfile, G_KEY_FILE_DESKTOP_GROUP,
"X-KDE-PluginInfo-EnabledByDefault", NULL))
{
g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-KDE-PluginInfo-EnabledByDefault", "false");
}
/* If the app has been renamed, add its old .desktop filename to
* X-Flatpak-RenamedFrom in the new .desktop file, taking care not to
* introduce duplicates.
@@ -8074,6 +8083,7 @@ flatpak_export_dir (GFile *source,
"share/icons", "../..",
"share/dbus-1/services", "../../..",
"share/gnome-shell/search-providers", "../../..",
"share/krunner/dbusplugins", "../../..",
"share/mime/packages", "../../..",
"share/metainfo", "../..",
"bin", "..",

View File

@@ -114,6 +114,20 @@ ObjectPath=/org/test/Hello/SearchProvider
Version=2
EOF
mkdir -p ${DIR}/files/share/krunner/dbusplugins
cat > ${DIR}/files/share/krunner/dbusplugins/org.test.Hello.desktop <<EOF
[Desktop Entry]
Name=Hello
X-KDE-ServiceTypes=Plasma/Runner
Type=Service
Icon=org.test.Hello
X-KDE-ServiceTypes=Plasma/Runner
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-API=DBus
X-Plasma-DBusRunner-Service=org.test.Hello.KRunner
X-Plasma-DBusRunner-Path=/org/test/Hello/KRunner
EOF
mkdir -p ${DIR}/files/share/icons/hicolor/64x64/apps
cp $(dirname $0)/org.test.Hello.png ${DIR}/files/share/icons/hicolor/64x64/apps/${APP_ID}.png
cp $(dirname $0)/org.test.Hello.png ${DIR}/files/share/icons/hicolor/64x64/apps/dont-export.png

View File

@@ -50,6 +50,8 @@ assert_has_file $FL_DIR/exports/share/metainfo/org.test.Hello.cmd.appdata.xml
assert_file_has_content $FL_DIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*flatpak run --branch=stable --arch=$ARCH --command=hello\.sh org\.test\.Hello$"
assert_has_file $FL_DIR/exports/share/gnome-shell/search-providers/org.test.Hello.search-provider.ini
assert_file_has_content $FL_DIR/exports/share/gnome-shell/search-providers/org.test.Hello.search-provider.ini "^DefaultDisabled=true$"
assert_has_file $FL_DIR/exports/share/krunner/dbusplugins/org.test.Hello.desktop
assert_file_has_content $FL_DIR/exports/share/krunner/dbusplugins/org.test.Hello.desktop "^X-KDE-PluginInfo-EnabledByDefault=false$"
assert_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/org.test.Hello.png
assert_not_has_file $FL_DIR/exports/share/icons/hicolor/64x64/apps/dont-export.png
assert_has_file $FL_DIR/exports/share/icons/HighContrast/64x64/apps/org.test.Hello.png