Skip to content

Commit

Permalink
fix: Use libportal to open script files
Browse files Browse the repository at this point in the history
There's a bug in GLib that makes Text Pieces to open script files
in Text Pieces itself:
https://gitlab.gnome.org/GNOME/glib/-/issues/2851

I fixed it by using `libportal`'s `Xdp.Portal.open_uri` instead of
`gtk4`'s `Gtk.show_uri`.

Fixes liferooter#118
  • Loading branch information
liferooter committed Dec 21, 2022
1 parent bbe8c0b commit e844f77
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
27 changes: 20 additions & 7 deletions build-aux/flatpak/com.github.liferooter.textpieces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ cleanup:

modules:

- name: blueprint
buildsystem: meson
sources:
- type: git
url: https://gitlab.gnome.org/jwestman/blueprint-compiler
branch: main

- name: textpieces
builddir: true
buildsystem: meson
Expand All @@ -46,6 +39,13 @@ modules:
path: ../..

modules:
- name: blueprint
buildsystem: meson
sources:
- type: git
url: https://gitlab.gnome.org/jwestman/blueprint-compiler
branch: main

- name: python3-pyyaml
buildsystem: simple
build-commands:
Expand All @@ -55,3 +55,16 @@ modules:
- type: file
url: https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz
sha256: 68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2

- name: libportal
buildsystem: meson
config-opts:
- -Dbackend-gtk3=disabled
- -Dbackend-gtk4=enabled
- -Dbackend-qt5=disabled
- -Ddocs=false
- -Dtests=false
sources:
- type: git
url: https://github.com/flatpak/libportal
tag: main
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ textpieces_deps = [
dependency('gio-unix-2.0', version: '>= 2.50'),
dependency('gtk4', version: '>= 4.2'),
dependency('gee-0.8', version: '>= 0.8'),
dependency('libportal', version: '>= 0.6'),
dependency('libportal-gtk4', version: '>= 0.6'),
json_glib_dep,
gtksourceview_dep,
libadwaita_dep,
Expand Down
7 changes: 4 additions & 3 deletions src/tools/Tool.vala
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ namespace TextPieces {
*/
public void open (Gtk.Window? window)
requires (!this.is_system) {
Gtk.show_uri (
window,
new Xdp.Portal ().open_uri.begin (
Xdp.parent_new_gtk(window),
File.new_build_filename (
Tool.CUSTOM_TOOLS_DIR.get (), this.script
).get_uri (),
Gdk.CURRENT_TIME
ASK | WRITABLE,
null
);
}

Expand Down

0 comments on commit e844f77

Please sign in to comment.