mirror of
https://github.com/swaywm/sway.git
synced 2026-04-17 06:46:32 -04:00
Extends former behavior to include loading of icons if they are
specified as an absolute path. Fixes size selection for SVG (scalable) icons relying on whose nominal size read via gdk-pixbuf loader may not correctly indicate that they can be scaled to neatly fill the available scale e.g., symbolic icons from Adwaita specify a nominal size of 16x16.
This commit is contained in:
parent
aeeb99c5a3
commit
17dc5071fd
4 changed files with 50 additions and 23 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <sfdo-basedir.h>
|
||||
#include <sfdo-desktop.h>
|
||||
|
|
@ -6,16 +7,24 @@
|
|||
#include "log.h"
|
||||
#include "sfdo.h"
|
||||
|
||||
// this extends libsfdo's behavior to also handle icons specified as absolute paths
|
||||
char *sfdo_icon_lookup_extended(struct sfdo *sfdo, char *icon_name, int target_size, int scale) {
|
||||
int lookup_options = SFDO_ICON_THEME_LOOKUP_OPTIONS_DEFAULT;
|
||||
struct sfdo_icon_file *icon_file = \
|
||||
sfdo_icon_theme_lookup(sfdo->icon_theme, icon_name, SFDO_NT, \
|
||||
target_size, scale, lookup_options);
|
||||
char *icon_path = NULL;
|
||||
if (icon_file && icon_file != SFDO_ICON_FILE_INVALID) {
|
||||
icon_path = strdup(sfdo_icon_file_get_path(icon_file, NULL));
|
||||
if (icon_name[0] == '/') {
|
||||
struct stat sb;
|
||||
if (!stat(icon_name, &sb)) {
|
||||
icon_path = strdup(icon_name);
|
||||
}
|
||||
} else {
|
||||
int lookup_options = SFDO_ICON_THEME_LOOKUP_OPTIONS_DEFAULT;
|
||||
struct sfdo_icon_file *icon_file = \
|
||||
sfdo_icon_theme_lookup(sfdo->icon_theme, icon_name, SFDO_NT, \
|
||||
target_size, scale, lookup_options);
|
||||
if (icon_file && icon_file != SFDO_ICON_FILE_INVALID) {
|
||||
icon_path = strdup(sfdo_icon_file_get_path(icon_file, NULL));
|
||||
}
|
||||
sfdo_icon_file_destroy(icon_file);
|
||||
}
|
||||
sfdo_icon_file_destroy(icon_file);
|
||||
return icon_path;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue