Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
30297a04d9 | |||
5ee226fcef | |||
1436bbba43 | |||
1067f4caa1 | |||
e8f250165b | |||
3e3379187b | |||
b7ab6ee660 | |||
1b2e221fd0 | |||
7751e78167 | |||
19d231446f | |||
498fba072c | |||
24556b3273 |
7 changed files with 123 additions and 18 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.vscode/
|
||||
build/
|
||||
.flatpak-builder
|
28
README.md
28
README.md
|
@ -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
|
||||
```
|
||||
|
|
|
@ -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
8
sources/flatpak.sh
Normal 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"
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue