Compare commits

...

12 commits

Author SHA1 Message Date
Dovi Cowan 30297a04d9
try to implement download via Portals 2022-06-19 18:42:53 +01:00
Dovi Cowan 5ee226fcef
allow create access to xdg-download 2022-06-19 18:42:23 +01:00
Dovi Cowan 1436bbba43
removed hole in flatpak for xdg-pictures
not needed now due to using Portal
2022-06-19 18:41:52 +01:00
Dovi Cowan 1067f4caa1
update README 2022-02-24 19:19:28 +00:00
Dovi Cowan e8f250165b
switch FileChooserDialog to FileChooserNative
access the filesystem in a flatpak
2022-02-23 19:34:07 +00:00
Dovi Cowan 3e3379187b
give access to xdg-pictures/webpin
temp - until filepicker portal integrated
2022-02-17 17:53:23 +00:00
Dovi Cowan b7ab6ee660
update README with flatpak build instructions 2022-02-17 17:45:57 +00:00
Dovi Cowan 1b2e221fd0
update to SDK 6.1 2022-02-17 17:38:13 +00:00
Dovi Cowan 7751e78167
add flatpak script
required so that flatpak run is a valid command inside the container
2022-02-17 15:19:30 +00:00
Dovi Cowan 19d231446f
add required permissions 2022-02-17 15:18:03 +00:00
Dovi Cowan 498fba072c
use flatpak run to launch 2022-02-17 15:16:54 +00:00
Dovi Cowan 24556b3273
ignore flatpak build files 2022-02-15 21:52:22 +00:00
7 changed files with 123 additions and 18 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
.vscode/
build/
.flatpak-builder

View file

@ -6,6 +6,8 @@
[![Build Status](https://travis-ci.org/artemanufrij/webpin.svg?branch=master)](https://travis-ci.org/artemanufrij/webpin)
Note: You can see current FlatPak dev updates at https://github.com/artemanufrij/webpin/issues/143
### Donate
<a href="https://www.paypal.me/ArtemAnufrij">PayPal</a> | <a href="https://liberapay.com/Artem/donate">LiberaPay</a> | <a href="https://www.patreon.com/ArtemAnufrij">Patreon</a>
@ -23,7 +25,31 @@
</p>
## Install from Github.
## Install from Github
### With FlatPak
Install the [elementaryOS developer enviroment](https://docs.elementary.io/develop/writing-apps/the-basic-setup#flatpak)
Clone and enter repository
```
git clone https://github.com/artemanufrij/webpin.git
cd webpin
```
Build with `flatpak-builder`
```
flatpak-builder build com.github.artemanufrij.webpin.yml --user --install --force-clean
```
#### Debugging
[Debugging FlatPak Applications](https://docs.flatpak.org/en/latest/debugging.html)
To enter the container for debugging
```
flatpak run --command=sh com.github.artemanufrij.webpin
```
### Legacy method
As first you need elementary SDK
```

View file

@ -5,7 +5,7 @@ app-id: com.github.artemanufrij.webpin
# we can use a convenient pre-made runtime and SDK. For this example, we'll be
# using the runtime and SDK provided by elementary.
runtime: io.elementary.Platform
runtime-version: '6'
runtime-version: '6.1'
sdk: io.elementary.Sdk
# This should match the exec line in your .desktop file and usually is the same
@ -18,12 +18,28 @@ command: com.github.artemanufrij.webpin
finish-args:
- '--share=ipc'
- '--socket=fallback-x11'
- '--socket=session-bus'
- '--socket=wayland'
- '--share=network'
- '--filesystem=xdg-data/applications:create'
- '--filesystem=~/.var/app/com.github.artemanufrij.webpin/'
# Need this so that we can find the download dir
- '--filesystem=xdg-download:create'
# DRI - Direct Rendering - without this, rendering is really slow
- '--device=dri'
# This section is where you list all the source code required to build your app.
# If we had external dependencies that weren't included in our SDK, we would list
# them here.
modules:
- name: flatpak-script
buildsystem: simple
build-commands:
- install -D flatpak.sh /app/bin/flatpak
sources:
- type: file
path: sources/flatpak.sh
- name: webpin
buildsystem: meson
sources:

8
sources/flatpak.sh Normal file
View file

@ -0,0 +1,8 @@
#!/bin/bash
# The build system puts this file as /app/bin/flatpak
# in the container
# This is required so that the container sees "flatpak" as a valid command
# so that it will read the .desktop files
echo "flatpak"

View file

@ -34,7 +34,7 @@ namespace Webpin {
Name=Webpin
GenericName=Web app
Comment=Webpin web app
Exec=com.github.artemanufrij.webpin
Exec=flatpak run com.github.artemanufrij.webpin
Keywords=webpin;webapp;internet;
Icon=application-default-icon
Terminal=false
@ -49,7 +49,7 @@ namespace Webpin {
[Desktop Action Remove]
Name=Remove Webapp
Exec=com.github.artemanufrij.webpin --remove
Exec=flatpak run com.github.artemanufrij.webpin --remove
Icon=edit-delete-symbolic
""";
@ -132,12 +132,12 @@ namespace Webpin {
file.set_string ("Desktop Entry", "Name", name);
file.set_string ("Desktop Entry", "GenericName", name);
file.set_string ("Desktop Entry", "X-GNOME-FullName", name);
file.set_string ("Desktop Entry", "Exec", "com.github.artemanufrij.webpin " + url);
file.set_string ("Desktop Entry", "Exec", "flatpak run com.github.artemanufrij.webpin " + url);
file.set_string ("Desktop Entry", "Icon", icon);
file.set_string ("Desktop Entry", "StartupWMClass", url);
file.set_string ("Desktop Entry", "X-Webpin-StayOpen", stay_open.to_string ());
file.set_string ("Desktop Entry", "X-Webpin-View-Mode", minimal_ui ? "minimal" : "default");
file.set_string ("Desktop Action Remove", "Exec", "com.github.artemanufrij.webpin --remove " + url);
file.set_string ("Desktop Action Remove", "Exec", "flatpak run com.github.artemanufrij.webpin --remove " + url);
}
public DesktopFile.from_desktopappinfo (GLib.DesktopAppInfo info) {
@ -151,7 +151,10 @@ namespace Webpin {
this.name = info.get_display_name ();
this.icon = info.get_icon ().to_string ();
try {
this.url = file.get_string ("Desktop Entry", "Exec").substring (31);
// The exec string is "flatpak run com.github.artemanufrij.webpin [url]"
this.url = file.get_string ("Desktop Entry", "Exec");
var url = this.url.split(" ");
this.url = url[3];
} catch (Error err) {
warning (err.message);
}

View file

@ -35,6 +35,8 @@ namespace Webpin.Widgets {
Gtk.Box container;
Granite.Widgets.Toast app_notification;
GLib.Icon icon_for_notification;
// For saving downloads
Gtk.FileChooserNative file_chooser;
public signal void external_request (WebKit.NavigationAction action);
public signal void request_begin ();
@ -164,6 +166,54 @@ namespace Webpin.Widgets {
}
return base.key_press_event (event);
});
web_view.web_context.download_started.connect ((event) => {
file_chooser = new Gtk.FileChooserNative (_("Choose download location"),
WebpinApp.instance.mainwindow,
Gtk.FileChooserAction.SAVE,
_("Save"),
_("Cancel"));
var download_dir = GLib.Environment.get_user_special_dir (GLib.UserDirectory.DOWNLOAD);
file_chooser.set_current_folder (download_dir);
event.decide_destination.connect ((download_event) => {
file_chooser.set_current_name (download_event);
if (file_chooser.run () == Gtk.ResponseType.ACCEPT) {
var filename = file_chooser.get_filename ();
event.set_destination (filename);
warning (filename);
file_chooser.destroy ();
app_notification.title = _ ("Download successful");
app_notification.send_notification ();
return false;
} else {
app_notification.title = _ ("Download failed or was cancelled");
app_notification.send_notification ();
event.cancel ();
return false;
}
});
event.failed.connect((failed_event) => {
error ("Download failed!");
});
event.created_destination.connect ((created_event) => {
message ("Destination created successfully");
});
event.finished.connect ((finished_event) => {
message ("Download finished successfully");
});
});
}
public void go_home () {

View file

@ -43,7 +43,7 @@ namespace Webpin.Widgets.Views {
Gtk.CheckButton stay_open_when_closed;
Gtk.CheckButton minimal_view_mode;
Gtk.Popover icon_selector_popover;
Gtk.FileChooserDialog file_chooser;
Gtk.FileChooserNative file_chooser;
Gtk.Button accept_button;
Gtk.ColorButton primary_color_button;
GLib.Regex protocol_regex;
@ -432,10 +432,11 @@ namespace Webpin.Widgets.Views {
filter.set_filter_name (_ ("Images"));
filter.add_mime_type ("image/*");
file_chooser = new Gtk.FileChooserDialog (_("Choose icon"), WebpinApp.instance.mainwindow,
file_chooser = new Gtk.FileChooserNative (_("Choose icon"), WebpinApp.instance.mainwindow,
Gtk.FileChooserAction.OPEN,
_ ("Cancel"), Gtk.ResponseType.CANCEL,
_ ("Open"), Gtk.ResponseType.ACCEPT);
_("Open"),
_("Cancel"));
file_chooser.set_select_multiple (false);
file_chooser.add_filter (filter);