Unverified Commit 35d3a14f authored by Erik Reider's avatar Erik Reider Committed by GitHub

Fixed image-path not being considered as theme icon (#515)

parent 01eb2221
...@@ -18,15 +18,15 @@ namespace SwayNotificationCenter { ...@@ -18,15 +18,15 @@ namespace SwayNotificationCenter {
Gtk.Image img, Gtk.Image img,
int icon_size, int icon_size,
int radius, int radius,
bool file_exists) { bool file_exists,
bool is_theme_icon = false) {
const string URI_PREFIX = "file://"; const string URI_PREFIX = "file://";
const uint PREFIX_SIZE = 7; bool is_uri = (uri.length >= URI_PREFIX.length
bool is_uri = (uri.length >= PREFIX_SIZE && uri.slice (0, URI_PREFIX.length) == URI_PREFIX);
&& uri.slice (0, PREFIX_SIZE) == URI_PREFIX); if (!is_theme_icon && (is_uri || file_exists)) {
if (is_uri || file_exists) {
// Try as a URI (file:// is the only URI schema supported right now) // Try as a URI (file:// is the only URI schema supported right now)
try { try {
if (is_uri) uri = uri.slice (PREFIX_SIZE, uri.length); if (is_uri) uri = uri.slice (URI_PREFIX.length, uri.length);
var pixbuf = new Gdk.Pixbuf.from_file_at_scale ( var pixbuf = new Gdk.Pixbuf.from_file_at_scale (
uri, uri,
......
...@@ -690,15 +690,25 @@ namespace SwayNotificationCenter { ...@@ -690,15 +690,25 @@ namespace SwayNotificationCenter {
int app_icon_size = notification_icon_size / 3; int app_icon_size = notification_icon_size / 3;
img_app_icon.set_pixel_size (app_icon_size); img_app_icon.set_pixel_size (app_icon_size);
var img_path_exists = File.new_for_uri ( bool img_path_is_theme_icon = false;
bool img_path_exists = File.new_for_uri (
param.image_path ?? "").query_exists (); param.image_path ?? "").query_exists ();
if (param.image_path != null && !img_path_exists) { if (param.image_path != null && !img_path_exists) {
// Check if it's not a URI // Check if it's not a URI
img_path_exists = File.new_for_path ( img_path_exists = File.new_for_path (
param.image_path ?? "").query_exists (); param.image_path ?? "").query_exists ();
// Check if it's a freedesktop.org-compliant icon
if (!img_path_exists) {
unowned Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default ();
Gtk.IconInfo? info = icon_theme.lookup_icon (param.image_path,
notification_icon_size,
Gtk.IconLookupFlags.USE_BUILTIN);
img_path_exists = info != null;
img_path_is_theme_icon = img_path_exists;
}
} }
var app_icon_exists = File.new_for_uri ( var app_icon_exists = File.new_for_uri (app_icon_uri ?? "").query_exists ();
app_icon_uri ?? "").query_exists ();
if (app_icon_uri != null && !img_path_exists) { if (app_icon_uri != null && !img_path_exists) {
// Check if it's not a URI // Check if it's not a URI
app_icon_exists = File.new_for_path ( app_icon_exists = File.new_for_path (
...@@ -722,9 +732,10 @@ namespace SwayNotificationCenter { ...@@ -722,9 +732,10 @@ namespace SwayNotificationCenter {
param.image_path != "" && param.image_path != "" &&
img_path_exists) { img_path_exists) {
Functions.set_image_uri (param.image_path, img, Functions.set_image_uri (param.image_path, img,
notification_icon_size, notification_icon_size,
radius, radius,
img_path_exists); img_path_exists,
img_path_is_theme_icon);
} else if (param.icon_data.is_initialized) { } else if (param.icon_data.is_initialized) {
Functions.set_image_data (param.icon_data, img, Functions.set_image_data (param.icon_data, img,
notification_icon_size, radius); notification_icon_size, radius);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment