Skip to content

Commit 6af82e3

Browse files
committed
* Fix opening the text editor in Flatpak environment
* Include GLib tarball in the repo * Change the release date
1 parent cc1c4b7 commit 6af82e3

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

com.github.donadigo.appeditor.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
"sources": [
2626
{
2727
"type": "archive",
28-
"url": "https://download.gnome.org/sources/glib/2.70/glib-2.70.0.tar.xz",
28+
"path": "external/glib-2.70.0.tar.xz",
2929
"sha256": "200d7df811c5ba634afbf109f14bb40ba7fde670e89389885da14e27c0840742"
3030
},
3131
{
3232
"type": "patch",
33-
"path": "glib-appinfo.patch"
33+
"path": "external/glib-appinfo.patch"
3434
}
3535
]
3636
},

data/com.github.donadigo.appeditor.appdata.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</screenshot>
3232
</screenshots>
3333
<releases>
34-
<release version="1.1.2" date="2021-12-12">
34+
<release version="1.1.2" date="2021-12-18">
3535
<description>
3636
<p>This release makes AppEditor available on elementary OS 6.0.</p>
3737
<p>New translations:</p>

external/glib-2.70.0.tar.xz

4.57 MB
Binary file not shown.
File renamed without changes.

src/AppInfoView.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public class AppEditor.AppInfoView : Gtk.Box {
421421

422422
private void on_open_source_button_clicked () {
423423
try {
424-
desktop_app.open_default_handler (get_screen ());
424+
desktop_app.open_default_handler ();
425425
} catch (Error e) {
426426
var message_dialog = new Granite.MessageDialog.with_image_from_icon_name (
427427
_("Could Not Open This Entry"),

src/DesktopApp.vala

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
* with this program. If not, see http://www.gnu.org/licenses/.
1616
*/
1717

18+
[DBus (name = "org.freedesktop.portal.OpenURI")]
19+
public interface FDODesktopPortal : Object {
20+
public abstract string open_file (string parent_window, UnixInputStream fd, HashTable<string, Variant> options) throws GLib.Error;
21+
}
22+
1823
public class AppEditor.DesktopApp : Object {
1924
public const char DEFAULT_LIST_SEPARATOR = ';';
2025
public const string LOCAL_APP_NAME_PREFIX = "appeditor-local-application-";
@@ -36,6 +41,7 @@ public class AppEditor.DesktopApp : Object {
3641
public DesktopAppInfo info { get; construct set; }
3742

3843
private static Icon default_icon;
44+
private static FDODesktopPortal? desktop_portal = null;
3945

4046
static construct {
4147
default_icon = new ThemedIcon (DEFAULT_ICON_NAME);
@@ -53,13 +59,39 @@ public class AppEditor.DesktopApp : Object {
5359
Object (info: info);
5460
}
5561

56-
public void open_default_handler (Gdk.Screen? screen) throws Error {
62+
private static FDODesktopPortal? get_desktop_portal () throws Error {
63+
if (desktop_portal == null) {
64+
try {
65+
desktop_portal = Bus.get_proxy_sync (
66+
BusType.SESSION,
67+
"org.freedesktop.portal.Desktop",
68+
"/org/freedesktop/portal/desktop"
69+
);
70+
} catch (Error e) {
71+
throw e;
72+
}
73+
}
74+
75+
return desktop_portal;
76+
}
77+
78+
public void open_default_handler () throws Error {
79+
// Gtk.show_uri_on_window does not seem to fully work in a Flatpak environment
80+
// so instead we directly call the freedesktop OpenURI DBus interface instead.
5781
var file = File.new_for_path (info.get_filename ());
82+
InputStream ios = file.read ();
83+
var stream = new UnixInputStream (((UnixInputStream)ios).get_fd (), true);
5884
try {
59-
Gtk.show_uri (screen, file.get_uri (), Gtk.get_current_event_time ());
85+
var portal = get_desktop_portal ();
86+
if (portal != null) {
87+
portal.open_file ("", stream, new GLib.HashTable<string, GLib.Variant> (null, null));
88+
}
6089
} catch (Error e) {
90+
stream.close ();
6191
throw e;
6292
}
93+
94+
stream.close ();
6395
}
6496

6597
public bool get_only_local () {

0 commit comments

Comments
 (0)