implement desktop notification
This commit is contained in:
parent
6f4a8f3813
commit
5e6e50a121
1 changed files with 21 additions and 0 deletions
|
@ -37,6 +37,7 @@ namespace Webpin {
|
||||||
private WebKit.CookieManager cookie_manager;
|
private WebKit.CookieManager cookie_manager;
|
||||||
private Gtk.Box container;
|
private Gtk.Box container;
|
||||||
Granite.Widgets.Toast app_notification;
|
Granite.Widgets.Toast app_notification;
|
||||||
|
Notification desktop_notification;
|
||||||
|
|
||||||
public signal void external_request (WebKit.NavigationAction action);
|
public signal void external_request (WebKit.NavigationAction action);
|
||||||
public signal void theme_color_changed(string color);
|
public signal void theme_color_changed(string color);
|
||||||
|
@ -76,6 +77,7 @@ namespace Webpin {
|
||||||
container.valign = Gtk.Align.FILL;
|
container.valign = Gtk.Align.FILL;
|
||||||
|
|
||||||
app_notification = new Granite.Widgets.Toast ("");
|
app_notification = new Granite.Widgets.Toast ("");
|
||||||
|
desktop_notification = new Notification ("");
|
||||||
|
|
||||||
//overlay trick to make snapshot work even with the spinner
|
//overlay trick to make snapshot work even with the spinner
|
||||||
var overlay = new Gtk.Overlay ();
|
var overlay = new Gtk.Overlay ();
|
||||||
|
@ -114,6 +116,7 @@ namespace Webpin {
|
||||||
if (icon_file.query_exists ()) {
|
if (icon_file.query_exists ()) {
|
||||||
try {
|
try {
|
||||||
icon = new Gtk.Image.from_pixbuf (new Gdk.Pixbuf.from_file_at_scale (file.icon, 48, 48, true));
|
icon = new Gtk.Image.from_pixbuf (new Gdk.Pixbuf.from_file_at_scale (file.icon, 48, 48, true));
|
||||||
|
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
warning (e.message);
|
warning (e.message);
|
||||||
icon = new Gtk.Image.from_icon_name ("artemanufrij.webpin", Gtk.IconSize.DIALOG);
|
icon = new Gtk.Image.from_icon_name ("artemanufrij.webpin", Gtk.IconSize.DIALOG);
|
||||||
|
@ -137,6 +140,21 @@ namespace Webpin {
|
||||||
determine_theme_color.begin();
|
determine_theme_color.begin();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app_view.show_notification.connect ((notification) => {
|
||||||
|
desktop_notification.set_title (notification.title);
|
||||||
|
desktop_notification.set_body (notification.body);
|
||||||
|
WebpinApp.instance.send_notification (null, desktop_notification);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
app_view.permission_request.connect ((permission) => {
|
||||||
|
var permission_type = permission as WebKit.NotificationPermissionRequest;
|
||||||
|
if (permission_type != null) {
|
||||||
|
permission_type.allow ();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public DesktopFile get_desktop_file () {
|
public DesktopFile get_desktop_file () {
|
||||||
|
@ -192,6 +210,9 @@ namespace Webpin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visible_child_name = "app";
|
visible_child_name = "app";
|
||||||
|
if (app_notification.reveal_child) {
|
||||||
|
app_notification.reveal_child = false;
|
||||||
|
}
|
||||||
request_finished ();
|
request_finished ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue