]> git.mdlowis.com Git - proto/labwc.git/commitdiff
icon-loader: support absolute icon names
authorJohan Malm <jgm323@gmail.com>
Sat, 28 Sep 2024 10:21:19 +0000 (11:21 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 28 Sep 2024 11:38:18 +0000 (12:38 +0100)
src/icon-loader.c

index 076e41a990ea03db73de542b33a26ae709aa97ee..a3009ac1796ad6a731918bcfe8ab25e476af4653 100644 (file)
@@ -118,7 +118,20 @@ out:
 static int
 process_abs_name(struct icon_ctx *ctx, const char *icon_name)
 {
-       wlr_log(WLR_ERROR, "absolute paths not yet supported");
+       ctx->path = xstrdup(icon_name);
+       if (str_endswith(icon_name, ".png")) {
+               ctx->format = SFDO_ICON_FILE_FORMAT_PNG;
+       } else if (str_endswith(icon_name, ".svg")) {
+               ctx->format = SFDO_ICON_FILE_FORMAT_SVG;
+       } else if (str_endswith(icon_name, ".xpm")) {
+               ctx->format = SFDO_ICON_FILE_FORMAT_XPM;
+       } else {
+               goto err;
+       }
+       return 0;
+err:
+       wlr_log(WLR_ERROR, "'%s' has invalid file extension", icon_name);
+       free(ctx->path);
        return -1;
 }