Fix: Notification

This commit is contained in:
Artem Anufrij 2018-02-22 19:33:38 +01:00
parent e2816f9a5d
commit 2fed86ac36
2 changed files with 58 additions and 48 deletions

View file

@ -40,7 +40,8 @@ namespace Webpin {
Terminal=false Terminal=false
Type=Application Type=Application
Categories=Network; Categories=Network;
X-GNOME-FullName=webpin X-GNOME-Gettext-Domain=com.github.artemanufrij.webpin
X-GNOME-UsesNotifications=true
StartupWMClass=Webpin StartupWMClass=Webpin
X-Webpin-PrimaryColor=rgba (222,222,222,1)"""; X-Webpin-PrimaryColor=rgba (222,222,222,1)""";

View file

@ -63,7 +63,10 @@ namespace Webpin.Widgets {
cookie_manager.set_persistent_storage (cookie_db + "cookies.db", WebKit.CookiePersistentStorage.SQLITE); cookie_manager.set_persistent_storage (cookie_db + "cookies.db", WebKit.CookiePersistentStorage.SQLITE);
web_view = new WebKit.WebView.with_context (WebKit.WebContext.get_default ()) { web_view = new WebKit.WebView.with_context (WebKit.WebContext.get_default ()) {
settings = new WebKit.Settings () { enable_webgl = true } settings = new WebKit.Settings () {
enable_webgl = true,
user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36"
}
}; };
web_view.load_uri (desktop_file.url); web_view.load_uri (desktop_file.url);
@ -106,15 +109,17 @@ namespace Webpin.Widgets {
} }
container.pack_start (icon, true, true, 0); container.pack_start (icon, true, true, 0);
web_view.create.connect ((action) => { web_view.create.connect (
app_notification.title = _("Open request in an external application…"); (action) => {
app_notification.title = _ ("Open request in an external application…");
app_notification.send_notification (); app_notification.send_notification ();
external_request (action); external_request (action);
return new WebKit.WebView (); return new WebKit.WebView ();
}); });
web_view.load_changed.connect ((load_event) => { web_view.load_changed.connect (
(load_event) => {
request_begin (); request_begin ();
if (load_event == WebKit.LoadEvent.FINISHED) { if (load_event == WebKit.LoadEvent.FINISHED) {
visible_child_name = "app"; visible_child_name = "app";
@ -125,12 +130,14 @@ namespace Webpin.Widgets {
} }
}); });
web_view.show_notification.connect ((notification) => { web_view.show_notification.connect (
(notification) => {
desktop_notification (notification.title, notification.body, icon_for_notification); desktop_notification (notification.title, notification.body, icon_for_notification);
return true; return true;
}); });
web_view.permission_request.connect ((permission) => { web_view.permission_request.connect (
(permission) => {
var permission_type = permission as WebKit.NotificationPermissionRequest; var permission_type = permission as WebKit.NotificationPermissionRequest;
if (permission_type != null) { if (permission_type != null) {
permission_type.allow (); permission_type.allow ();
@ -138,7 +145,8 @@ namespace Webpin.Widgets {
return false; return false;
}); });
web_view.button_press_event.connect ((event) => { web_view.button_press_event.connect (
(event) => {
if (event.button == 8) { if (event.button == 8) {
web_view.go_back (); web_view.go_back ();
return true; return true;
@ -149,7 +157,8 @@ namespace Webpin.Widgets {
return base.button_press_event (event); return base.button_press_event (event);
}); });
web_view.key_press_event.connect ((event) => { web_view.key_press_event.connect (
(event) => {
if (event.keyval == Gdk.Key.Back) { if (event.keyval == Gdk.Key.Back) {
web_view.go_back (); web_view.go_back ();
return true; return true;