show app icon in desktop notification
This commit is contained in:
parent
35b8630d1c
commit
7c41b22881
2 changed files with 11 additions and 34 deletions
|
@ -66,31 +66,6 @@ namespace Webpin {
|
||||||
});
|
});
|
||||||
headerbar.pack_start (stay_open);
|
headerbar.pack_start (stay_open);
|
||||||
|
|
||||||
var mute_notifications = new Gtk.ToggleButton ();
|
|
||||||
mute_notifications.active = desktop_file.mute_notifications;
|
|
||||||
if (mute_notifications.active) {
|
|
||||||
mute_notifications.image = new Gtk.Image.from_icon_name ("notification-disabled-symbolic", Gtk.IconSize.MENU);
|
|
||||||
mute_notifications.tooltip_text = _("Unmute notifications");
|
|
||||||
} else {
|
|
||||||
mute_notifications.image = new Gtk.Image.from_icon_name ("notification-symbolic", Gtk.IconSize.MENU);
|
|
||||||
mute_notifications.tooltip_text = _("Mute notifications");
|
|
||||||
}
|
|
||||||
mute_notifications.toggled.connect (() => {
|
|
||||||
desktop_file.edit_propertie ("WebpinMuteNotifications", mute_notifications.active.to_string ());
|
|
||||||
desktop_file.save_to_file ();
|
|
||||||
if (mute_notifications.active) {
|
|
||||||
mute_notifications.image = new Gtk.Image.from_icon_name ("notification-disabled-symbolic", Gtk.IconSize.MENU);
|
|
||||||
mute_notifications.tooltip_text = _("Unmute notifications");
|
|
||||||
} else {
|
|
||||||
mute_notifications.image = new Gtk.Image.from_icon_name ("notification-symbolic", Gtk.IconSize.MENU);
|
|
||||||
mute_notifications.tooltip_text = _("Mute notifications");
|
|
||||||
desktop_notification.set_title (desktop_file.name);
|
|
||||||
desktop_notification.set_body (_("Desktop notifications are enabled"));
|
|
||||||
WebpinApp.instance.send_notification (null, desktop_notification);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
headerbar.pack_start (mute_notifications);
|
|
||||||
|
|
||||||
this.set_titlebar (headerbar);
|
this.set_titlebar (headerbar);
|
||||||
|
|
||||||
var width = desktop_file.info.get_string ("WebpinWindowWidth");
|
var width = desktop_file.info.get_string ("WebpinWindowWidth");
|
||||||
|
@ -129,12 +104,11 @@ namespace Webpin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
web_app.desktop_notification.connect ((title, body) => {
|
web_app.desktop_notification.connect ((title, body, icon) => {
|
||||||
if (!desktop_file.mute_notifications) {
|
|
||||||
desktop_notification.set_title (title);
|
desktop_notification.set_title (title);
|
||||||
desktop_notification.set_body (body);
|
desktop_notification.set_body (body);
|
||||||
|
desktop_notification.set_icon (icon);
|
||||||
WebpinApp.instance.send_notification (null, desktop_notification);
|
WebpinApp.instance.send_notification (null, desktop_notification);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
web_app.request_begin.connect (() => {
|
web_app.request_begin.connect (() => {
|
||||||
|
|
|
@ -37,11 +37,12 @@ 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;
|
||||||
|
GLib.Icon icon_for_notification;
|
||||||
|
|
||||||
public signal void external_request (WebKit.NavigationAction action);
|
public signal void external_request (WebKit.NavigationAction action);
|
||||||
public signal void request_begin ();
|
public signal void request_begin ();
|
||||||
public signal void request_finished ();
|
public signal void request_finished ();
|
||||||
public signal void desktop_notification (string title, string body);
|
public signal void desktop_notification (string title, string body, GLib.Icon icon);
|
||||||
|
|
||||||
|
|
||||||
public WebApp (string app_url) {
|
public WebApp (string app_url) {
|
||||||
|
@ -106,6 +107,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));
|
||||||
|
icon_for_notification = GLib.Icon.new_for_string (file.icon);
|
||||||
|
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
warning (e.message);
|
warning (e.message);
|
||||||
|
@ -113,6 +115,7 @@ namespace Webpin {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
icon = new Gtk.Image.from_icon_name (file.icon, Gtk.IconSize.DIALOG);
|
icon = new Gtk.Image.from_icon_name (file.icon, Gtk.IconSize.DIALOG);
|
||||||
|
icon_for_notification = new GLib.ThemedIcon (file.icon);
|
||||||
}
|
}
|
||||||
container.pack_start(icon, true, true, 0);
|
container.pack_start(icon, true, true, 0);
|
||||||
|
|
||||||
|
@ -134,8 +137,8 @@ namespace Webpin {
|
||||||
});
|
});
|
||||||
|
|
||||||
app_view.show_notification.connect ((notification) => {
|
app_view.show_notification.connect ((notification) => {
|
||||||
desktop_notification (notification.title, notification.body);
|
desktop_notification (notification.title, notification.body, icon_for_notification);
|
||||||
return false;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
app_view.permission_request.connect ((permission) => {
|
app_view.permission_request.connect ((permission) => {
|
||||||
|
|
Loading…
Reference in a new issue