Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Flatpack support/CI #2

Merged
merged 10 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Flatpak improvements
Use libportal, fixup missing application icon
  • Loading branch information
v1993 committed Oct 24, 2023
commit e89486031704a8b5c92273a5da0a2faa82dd1a92
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/.flatpak-builder
.flatpak-builder/
2 changes: 2 additions & 0 deletions flatpak/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto-generated with a custom command for gnome builder
org.v1993.NXDumpClient.yml.json
32 changes: 32 additions & 0 deletions flatpak/modules/libportal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "libportal",
"buildsystem": "meson",
"config-opts": [
"-Dauto_features=disabled",
"-Dbackend-gtk4=enabled",
"-Ddocs=false",
"-Dtests=false"
],
"cleanup": [
"/include",
"/lib/pkgconfig",
"/lib/girepository-1.0",
"/man",
"/share/aclocal",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"/share/gir-1.0",
"/share/vala",
"*.la",
"*.a"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/flatpak/libportal/releases/download/0.7.1/libportal-0.7.1.tar.xz",
"sha256": "297b90b263fad22190a26b8c7e8ea938fe6b18fb936265e588927179920d3805"
}
]
}
2 changes: 2 additions & 0 deletions flatpak/org.v1993.NXDumpClient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ finish-args:
modules:
- shared-modules/libusb/libusb.json
- modules/libgusb.json
- modules/libportal.json
- modules/blueprint-compiler.json

- name: nxdumpclient
buildsystem: meson
config-opts:
- -Dudev_rules=disabled
- -Duse_libportal=enabled
sources:
- type: dir
path: ..
Expand Down
23 changes: 20 additions & 3 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

extern const string NXDC_VERSION;
extern const string NXDC_ICONS_PATH;

namespace NXDumpClient {
/// A convenience method to show errors to user
Expand All @@ -37,10 +38,14 @@ namespace NXDumpClient {
private UsbContext usb_ctx;
private Window? main_window = null;

#if WITH_LIBPORTAL
public Xdp.Portal? portal { get; private set; default = null; }
#endif

public void show_error(string desc, string message) {
if (main_window != null) {
if (main_window != null && main_window.is_active) {
var toast = new Adw.Toast.format("<span color=\"red\">%s</span>: %s", desc, message) {
timeout = 10,
timeout = 5,
priority = HIGH
};
main_window.show_toast((owned)toast);
Expand All @@ -49,7 +54,6 @@ namespace NXDumpClient {
notif.set_body(message);
notif.set_category("device.error");
notif.set_priority(HIGH);
// FIXME: icon does not show. Is it on KDE or me?
notif.set_icon(new ThemedIcon("dialog-error"));
send_notification(null, notif);
}
Expand Down Expand Up @@ -123,6 +127,19 @@ namespace NXDumpClient {
}

device_list = new ListStore(typeof(UsbDeviceClient));

#if WITH_LIBPORTAL
try {
portal = new Xdp.Portal.initable_new();
} catch(Error e) {
warning("Failed to initialize libportal: %s", e.message);
}

if (Xdp.Portal.running_under_flatpak()) {
// Fix About dialog icon
Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).add_search_path(NXDC_ICONS_PATH);
}
#endif
}

private static void unset_main_window(Window win, Application app) {
Expand Down
3 changes: 2 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ executable('nxdumpclient', nxdc_sources, nxdc_blueprint_tgt,

c_args: [
'-DGETTEXT_PACKAGE="nxdumpclient"',
'-DNXDC_VERSION="@0@"'.format(meson.project_version())
'-DNXDC_VERSION="@0@"'.format(meson.project_version()),
'-DNXDC_ICONS_PATH="@0@"'.format(get_option('datadir') / 'icons'),
],
)