[gnome-software/1087-default-handlers-for-apt-and-snap] misc: Conditional mime type handlers



commit 99378d582a3df61ae50a7468462c613c09110ba1
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 3 18:43:06 2021 +0100

    misc: Conditional mime type handlers
    
    Define -Dapt=true in the configure time to enable apt: scheme handler
    in the org.gnome.Software.desktop file. Similarly handle the snap:
    scheme only if the span plugin is enabled.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1087

 meson_options.txt                 |  1 +
 src/meson.build                   | 19 +++++++++++++++++--
 src/org.gnome.Software.desktop.in |  2 +-
 3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/meson_options.txt b/meson_options.txt
index 83ebcc00e..57c55fc56 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -12,6 +12,7 @@ option('malcontent', type : 'boolean', value : true, description : 'enable paren
 option('rpm_ostree', type : 'boolean', value : false, description : 'enable rpm-ostree support')
 option('odrs', type : 'boolean', value : true, description : 'enable ODRS support')
 option('gudev', type : 'boolean', value : true, description : 'enable GUdev support')
+option('apt', type : 'boolean', value : false, description : 'enable apt: URL handler in the .desktop file')
 option('snap', type : 'boolean', value : false, description : 'enable Snap support')
 option('external_appstream', type : 'boolean', value : false, description : 'enable external AppStream 
support')
 option('valgrind', type : 'boolean', value : true, description : 'enable Valgrind debugging integration')
diff --git a/src/meson.build b/src/meson.build
index edb8f5e1a..72f56fc98 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -151,6 +151,16 @@ executable(
 cdata = configuration_data()
 cdata.set('bindir', join_paths(get_option('prefix'),
                                get_option('bindir')))
+if (get_option('apt'))
+  cdata.set('apthandler', 'x-scheme-handler/apt;')
+else
+  cdata.set('apthandler', '')
+endif
+if (get_option('snap'))
+  cdata.set('snaphandler', 'x-scheme-handler/snap;')
+else
+  cdata.set('snaphandler', '')
+endif
 
 # replace @bindir@
 configure_file(
@@ -168,9 +178,14 @@ configure_file(
   configuration : cdata
 )
 
-# replace @bindir@
 i18n.merge_file(
-  input: 'org.gnome.Software.desktop.in',
+  input:
+    # replace mime-type handlers
+    configure_file(
+      input : 'org.gnome.Software.desktop.in',
+      output : 'org.gnome.Software.desktop.tmp',
+      configuration : cdata
+    ),
   output: 'org.gnome.Software.desktop',
   type: 'desktop',
   po_dir: join_paths(meson.source_root(), 'po'),
diff --git a/src/org.gnome.Software.desktop.in b/src/org.gnome.Software.desktop.in
index dde6bad1c..71dcb1524 100644
--- a/src/org.gnome.Software.desktop.in
+++ b/src/org.gnome.Software.desktop.in
@@ -10,7 +10,7 @@ Categories=GNOME;GTK;System;PackageManager;
 # Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list 
MUST also end with a semicolon!
 Keywords=Updates;Upgrade;Sources;Repositories;Preferences;Install;Uninstall;Program;Software;App;Store;
 StartupNotify=true
-MimeType=x-scheme-handler/appstream;x-scheme-handler/apt;x-scheme-handler/snap;
+MimeType=x-scheme-handler/appstream;@apthandler@@snaphandler@
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-software
 X-GNOME-Bugzilla-Component=gnome-software


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]