Skip to content

Commit

Permalink
Read Appdata From Installed Flatpak Apps (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marukesu authored Jul 15, 2021
1 parent d04dae0 commit 63cb558
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
18 changes: 13 additions & 5 deletions io.elementary.feedback.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
app-id: io.elementary.feedback
runtime: io.elementary.Platform
runtime-version: '0.1.0'
runtime-version: daily
sdk: io.elementary.Sdk
command: io.elementary.feedback
finish-args:
# for host metadata, '--filesystem=/usr/share/metainfo:ro' won't work.
- '--filesystem=host:ro'
- '--filesystem=/var/lib/flatpak:ro' # for flatpak metadata

- '--share=ipc'
- '--share=network'
- '--socket=fallback-x11'
Expand All @@ -12,9 +16,6 @@ finish-args:
# needed for perfers-color-scheme
- '--system-talk-name=org.freedesktop.Accounts'

# needed to read app metadata
- '--filesystem=host:ro'

- '--metadata=X-DConf=migrate-path=/io/elementary/feedback/'
cleanup:
- '/include'
Expand All @@ -28,6 +29,8 @@ cleanup:
modules:
- name: appstream
buildsystem: meson
cleanup:
- /bin
config-opts:
- '-Dvapi=true'
- '-Dapidocs=false'
Expand All @@ -40,8 +43,9 @@ modules:
- name: xapian
cleanup:
- '/lib/cmake'
- '/share/alocal'
- '/share/aclocal'
- '/share/doc'
- '/bin'
sources:
- type: archive
url: https://oligarchy.co.uk/xapian/1.4.17/xapian-core-1.4.17.tar.xz
Expand All @@ -59,11 +63,15 @@ modules:
url: https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz
md5: 12e517cac2b57a0121cda351570f1e63
- name: xmlto
cleanup:
- '/bin'
sources:
- type: archive
url: https://releases.pagure.org/xmlto/xmlto-0.0.28.tar.bz2
md5: 93bab48d446c826399d130d959fe676f
- name: lmdb
cleanup:
- '/bin'
no-autogen: true
make-install-args:
- 'prefix=/app'
Expand Down
6 changes: 6 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

public class Feedback.Application : Gtk.Application {
public static GLib.Settings settings;
public static bool sandboxed;
private MainWindow main_window;

public Application () {
Expand All @@ -31,6 +32,7 @@ public class Feedback.Application : Gtk.Application {

static construct {
settings = new Settings ("io.elementary.feedback");
sandboxed = FileUtils.test ("/.flatpak-info", FileTest.EXISTS);
}

protected override void activate () {
Expand All @@ -39,6 +41,10 @@ public class Feedback.Application : Gtk.Application {
return;
}

if (sandboxed) {
Gtk.IconTheme.get_default ().prepend_search_path ("/var/lib/flatpak/exports/share/icons");
}

main_window = new MainWindow (this);

int window_x, window_y;
Expand Down
15 changes: 9 additions & 6 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow {
listbox.set_sort_func (sort_function);

var appstream_pool = new AppStream.Pool ();
appstream_pool.clear_metadata_locations ();
try {
bool sandboxed = FileUtils.test ("/.flatpak-info", FileTest.EXISTS);

if (sandboxed) {
if (Application.sandboxed) {
appstream_pool.add_metadata_location ("/run/host/usr/share/metainfo/");
} else {
appstream_pool.set_flags (AppStream.PoolFlags.READ_METAINFO);
}

// flatpak's appstream files exists only inside they sandbox
var appdata_dir = "/var/lib/flatpak/app/%s/current/active/files/share/appdata";
foreach (var app in app_entries) {
appstream_pool.add_metadata_location (appdata_dir.printf (app));
}

appstream_pool.load ();
Expand Down Expand Up @@ -266,7 +269,7 @@ public class Feedback.MainWindow : Gtk.ApplicationWindow {
"org.pantheon.mail",
"io.elementary.music",
"io.elementary.photos",
"io.elementary.screenshot-tool",
"io.elementary.screenshot",
"io.elementary.terminal",
"io.elementary.videos"
};
Expand Down

0 comments on commit 63cb558

Please sign in to comment.