Skip to content
Myr

Merge branch 'optional-svg' into master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Daniel Eklöf · committed by Daniel Eklöf · parents bbb68f1, 16ad12a · Browse files · 11 files+39 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+39 added−4 removed

  • other:+39 added−4 removed

11 files+39 added−4 removed

modified:application.c+7 added-1 removed
1#include "application.h"23#include <stdbool.h>4#include <stdlib.h>5#include <string.h>6#include <errno.h>7#include <assert.h>89#include <sys/types.h>10#include <sys/stat.h>11#include <unistd.h>12#include <fcntl.h>1314#define LOG_MODULE "application"15#define LOG_ENABLE_DBG 0
214 unmodified lines
230 free(app->comment);231 free(app->icon.name);232 if (app->icon.type == ICON_SURFACE)233 cairo_surface_destroy(app->icon.surface);231 else if (app->icon.type == ICON_SVG)234 else if (app->icon.type == ICON_SVG) {235#ifdef FUZZEL_ENABLE_SVG236 g_object_unref(app->icon.svg);237#endif238 }239 }240 free(apps->v);241 free(apps);242}
modified:application.h+4 added
1 unmodified line
23#include <stdbool.h>45#include <cairo.h>6#ifdef FUZZEL_ENABLE_SVG7#include <librsvg/rsvg.h>8#endif910#include "prompt.h"1112enum icon_type { ICON_NONE, ICON_SURFACE, ICON_SVG };
2 unmodified lines
15 char *name;16 enum icon_type type;17 union {18 cairo_surface_t *surface;19#ifdef FUZZEL_ENABLE_SVG20 RsvgHandle *svg;21#endif22 };23};2425struct application {
18 unmodified lines
modified:dmenu.c+4 added
1#include "dmenu.h"23#include <stdlib.h>4#include <stdbool.h>5#include <string.h>6#include <stdio.h>7#include <errno.h>8#include <sys/types.h>910#include <tllist.h>1112#define LOG_MODULE "dmenu"
58 unmodified lines
modified:icon.c+10 added-1 removed
8 unmodified lines
910#include <sys/stat.h>11#include <fcntl.h>1213#ifdef FUZZEL_ENABLE_SVG14#include <librsvg/rsvg.h>15#endif1617#include <tllist.h>1819#define LOG_MODULE "icon"
259 unmodified lines
279 icon->surface = surf;280 return true;281}282283#ifdef FUZZEL_ENABLE_SVG284static bool285icon_from_svg(struct icon *icon, RsvgHandle *svg)286{287 icon->type = ICON_SVG;288 icon->svg = svg;289 return true;290}291#endif292293static void294icon_reset(struct icon *icon)295{296 if (icon->type == ICON_SURFACE) {297 cairo_surface_destroy(icon->surface);298 icon->surface = NULL;299 } else if (icon->type == ICON_SVG) {300#ifdef FUZZEL_ENABLE_SVG301 g_object_unref(icon->svg);302 icon->svg = NULL;303#endif304 }305 icon->type = ICON_NONE;306}307
69 unmodified lines
377 } else {378 /* Use anyone available */379 }380381#ifdef FUZZEL_ENABLE_SVG382 RsvgHandle *svg = rsvg_handle_new_from_file(full_path, NULL);383 if (svg != NULL) {384 LOG_DBG("%s: %s scalable", name, full_path);385 free(full_path);386 return icon_from_svg(icon, svg);387 }381388#endif389 cairo_surface_t *surf = cairo_image_surface_create_from_png(full_path);390 if (cairo_surface_status(surf) == CAIRO_STATUS_SUCCESS) {391 if (scalable)392 LOG_DBG("%s: %s: scalable", name, full_path);
22 unmodified lines
415 char path[strlen(it->item) + 1 +416 strlen("pixmaps") + 1 +417 strlen(name) + strlen(".svg") + 1];418419#ifdef FUZZEL_ENABLE_SVG420 /* Try SVG variant first */421 sprintf(path, "%s/pixmaps/%s.svg", it->item, name);422 RsvgHandle *svg = rsvg_handle_new_from_file(path, NULL);423 if (svg != NULL) {424 xdg_data_dirs_destroy(dirs);425 return icon_from_svg(icon, svg);426 }427#endif428429 /* No SVG, look for PNG instead */430 sprintf(path, "%s/pixmaps/%s.png", it->item, name);431 cairo_surface_t *surf = cairo_image_surface_create_from_png(path);
21 unmodified lines
modified:main.c+1 added
1#include <stdlib.h>2#include <stdio.h>3#include <stdbool.h>4#include <string.h>5#include <getopt.h>67#include <locale.h>8
435 unmodified lines
modified:match.c+1 added
1#include "match.h"23#include <stdlib.h>4#include <wctype.h>5#include <assert.h>67struct matches {
196 unmodified lines
added:meson_options.txt+1 added
1option('enable-svg', type: 'boolean', value: true)
modified:meson.build+5 added-1 removed
47 unmodified lines
4849pixman = dependency('pixman-1')50cairo = dependency('cairo')51cairo_ft = dependency('cairo-ft')52librsvg = dependency('librsvg-2.0')52librsvg = dependency('librsvg-2.0', required: get_option('enable-svg'))53wayland_protocols = dependency('wayland-protocols')54wayland_client = dependency('wayland-client')55wayland_cursor = dependency('wayland-cursor')56xkb = dependency('xkbcommon')5758if get_option('enable-svg')59 add_project_arguments('-DFUZZEL_ENABLE_SVG=1', language: 'c')60endif6162tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')63fcft = dependency('fcft', version: ['>=2.0.0', '<3.0.0'], fallback: 'fcft')6465wayland_protocols_datadir = wayland_protocols.get_pkgconfig_variable('pkgdatadir')
65 unmodified lines
modified:render.c+4 added-1 removed
233 unmodified lines
234 * there's "enough" free space, render a large235 * representation of the icon */236237 if (match->application->icon.type == ICON_SVG) {238#ifdef FUZZEL_ENABLE_SVG239 RsvgHandle *svg = match->application->icon.svg;240 RsvgDimensionData dim;241 rsvg_handle_get_dimensions(svg, &dim);242
24 unmodified lines
267 if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS)268 rsvg_handle_render_cairo(svg, buf->cairo);269 cairo_restore(buf->cairo);270 }271#endif272 }271273 /* Hightlight selected entry */274 const struct rgba *sc = &render->options.selection_color;275 cairo_set_source_rgba(buf->cairo, sc->r, sc->g, sc->b, sc->a);276 cairo_set_operator(buf->cairo, CAIRO_OPERATOR_SOURCE);
41 unmodified lines
318 break;319 }320321 case ICON_SVG: {322#ifdef FUZZEL_ENABLE_SVG323 RsvgHandle *svg = match->application->icon.svg;324325 RsvgDimensionData dim;326 rsvg_handle_get_dimensions(svg, &dim);
13 unmodified lines
340 if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS)341 rsvg_handle_render_cairo(svg, buf->cairo);342 cairo_restore(buf->cairo);343 break;344#endif345 }346 }347348 cur_x += row_height;
97 unmodified lines
modified:wayland.c+1 added
1#include "wayland.h"23#include <stdlib.h>4#include <string.h>5#include <wctype.h>6#include <unistd.h>7#include <errno.h>8#include <locale.h>
1562 unmodified lines
modified:xdg.c+1 added
4 unmodified lines
5#include <string.h>6#include <stdbool.h>7#include <wchar.h>8#include <unistd.h>9#include <limits.h>1011#include <sys/types.h>12#include <sys/stat.h>13#include <dirent.h>
310 unmodified lines