mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
Finds paths to icon files using libsfdo. Libsfdo is currently an
optional compile time dependency. This means the former code paths are all retained and new ones are wrapped in #if HAVE_LIBSFDO. Behavior should be identical now between the two code paths. Later commits will add the handling of icons specified as absolute paths which both former swaybar code and libsfdo have thus far avoided.
This commit is contained in:
parent
3a21b8c6f1
commit
aeeb99c5a3
14 changed files with 220 additions and 93 deletions
|
|
@ -70,6 +70,14 @@ void free_bar_config(struct bar_config *bar) {
|
|||
free(bar->colors.binding_mode_border);
|
||||
free(bar->colors.binding_mode_bg);
|
||||
free(bar->colors.binding_mode_text);
|
||||
|
||||
// this is to cover the case where tray support is not compiled in
|
||||
// but we have libsfdo support which implies at least a default
|
||||
// icon_theme string was allocated
|
||||
#if HAVE_LIBSFDO && !HAVE_TRAY
|
||||
free(bar->icone_theme);
|
||||
#endif
|
||||
|
||||
#if HAVE_TRAY
|
||||
list_free_items_and_destroy(bar->tray_outputs);
|
||||
free(bar->icon_theme);
|
||||
|
|
@ -170,6 +178,13 @@ struct bar_config *default_bar_config(void) {
|
|||
bar->colors.binding_mode_bg = NULL;
|
||||
bar->colors.binding_mode_text = NULL;
|
||||
|
||||
// we need some default when we initialize sfdo
|
||||
#if HAVE_LIBSFDO
|
||||
if (!(bar->icon_theme = strdup("Hicolor"))) {
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_TRAY
|
||||
bar->tray_padding = 2;
|
||||
wl_list_init(&bar->tray_bindings);
|
||||
|
|
|
|||
|
|
@ -71,9 +71,7 @@
|
|||
#endif
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
#include <sfdo-basedir.h>
|
||||
#include <sfdo-desktop.h>
|
||||
#include <sfdo-icon.h>
|
||||
#include "sfdo.h"
|
||||
#endif
|
||||
|
||||
#define SWAY_XDG_SHELL_VERSION 5
|
||||
|
|
@ -570,73 +568,3 @@ void server_run(struct sway_server *server) {
|
|||
server->socket);
|
||||
wl_display_run(server->wl_display);
|
||||
}
|
||||
|
||||
#if HAVE_LIBSFDO
|
||||
struct sfdo *sfdo_create(char *theme) {
|
||||
struct sfdo *sfdo = calloc(1, sizeof(struct sfdo));
|
||||
if (!sfdo) {
|
||||
goto error_calloc;
|
||||
}
|
||||
|
||||
struct sfdo_basedir_ctx *basedir_ctx = sfdo_basedir_ctx_create();
|
||||
if (!basedir_ctx) {
|
||||
goto error_basedir_ctx;
|
||||
}
|
||||
|
||||
sfdo->desktop_ctx = sfdo_desktop_ctx_create(basedir_ctx);
|
||||
if (!sfdo->desktop_ctx) {
|
||||
goto error_desktop_ctx;
|
||||
}
|
||||
|
||||
sfdo->icon_ctx = sfdo_icon_ctx_create(basedir_ctx);
|
||||
if (!sfdo->icon_ctx) {
|
||||
goto error_icon_ctx;
|
||||
}
|
||||
|
||||
sfdo->desktop_db = sfdo_desktop_db_load(sfdo->desktop_ctx, NULL);
|
||||
if (!sfdo->desktop_db) {
|
||||
goto error_desktop_db;
|
||||
}
|
||||
|
||||
int load_options = SFDO_ICON_THEME_LOAD_OPTIONS_DEFAULT
|
||||
| SFDO_ICON_THEME_LOAD_OPTION_ALLOW_MISSING
|
||||
| SFDO_ICON_THEME_LOAD_OPTION_RELAXED;
|
||||
|
||||
sfdo->icon_theme = sfdo_icon_theme_load(sfdo->icon_ctx, theme, load_options);
|
||||
if (!sfdo->icon_theme) {
|
||||
goto error_icon_theme;
|
||||
}
|
||||
|
||||
sfdo_basedir_ctx_destroy(basedir_ctx);
|
||||
|
||||
sway_log(SWAY_DEBUG, "Successfully setup sfdo");
|
||||
return sfdo;
|
||||
|
||||
error_icon_theme:
|
||||
sfdo_desktop_db_destroy(sfdo->desktop_db);
|
||||
error_desktop_db:
|
||||
sfdo_icon_ctx_destroy(sfdo->icon_ctx);
|
||||
error_icon_ctx:
|
||||
sfdo_desktop_ctx_destroy(sfdo->desktop_ctx);
|
||||
error_desktop_ctx:
|
||||
sfdo_basedir_ctx_destroy(basedir_ctx);
|
||||
error_basedir_ctx:
|
||||
free(sfdo);
|
||||
error_calloc:
|
||||
sway_log(SWAY_ERROR, "Failed to setup sfdo");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void sfdo_destroy(struct sfdo *sfdo) {
|
||||
if (!sfdo) {
|
||||
sway_log(SWAY_DEBUG, "Null sfdo passed in");
|
||||
return;
|
||||
}
|
||||
|
||||
sfdo_icon_theme_destroy(sfdo->icon_theme);
|
||||
sfdo_desktop_db_destroy(sfdo->desktop_db);
|
||||
sfdo_icon_ctx_destroy(sfdo->icon_ctx);
|
||||
sfdo_desktop_ctx_destroy(sfdo->desktop_ctx);
|
||||
sway_log(SWAY_DEBUG, "Successfully destroyed sfdo");
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue