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
Provenance
- Commit
17bc1dc- Tree
cd66d5f- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent 1
bbb68f1- Parent 2
16ad12a
11 files changed+39 added−4 removed
modified:application.c+7 added-1 removed
1 #include "application.h"2 3 #include <stdbool.h>4+#include <stdlib.h>5+#include <string.h>6 #include <errno.h>7 #include <assert.h>8 9 #include <sys/types.h>10 #include <sys/stat.h>11+#include <unistd.h>12 #include <fcntl.h>13 14 #define LOG_MODULE "application"15 #define LOG_ENABLE_DBG 0214 unmodified lines230 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 line2 3 #include <stdbool.h>4 5 #include <cairo.h>6+#ifdef FUZZEL_ENABLE_SVG7 #include <librsvg/rsvg.h>8+#endif9 10 #include "prompt.h"11 12 enum icon_type { ICON_NONE, ICON_SURFACE, ICON_SVG };2 unmodified lines15 char *name;16 enum icon_type type;17 union {18 cairo_surface_t *surface;19+#ifdef FUZZEL_ENABLE_SVG20 RsvgHandle *svg;21+#endif22 };23 };24 25 struct application {18 unmodified linesmodified:dmenu.c+4 added
1 #include "dmenu.h"2 3+#include <stdlib.h>4 #include <stdbool.h>5+#include <string.h>6+#include <stdio.h>7 #include <errno.h>8+#include <sys/types.h>9 10 #include <tllist.h>11 12 #define LOG_MODULE "dmenu"58 unmodified linesmodified:icon.c+10 added-1 removed
8 unmodified lines9 10 #include <sys/stat.h>11 #include <fcntl.h>12 13+#ifdef FUZZEL_ENABLE_SVG14 #include <librsvg/rsvg.h>15+#endif16 17 #include <tllist.h>18 19 #define LOG_MODULE "icon"259 unmodified lines279 icon->surface = surf;280 return true;281 }282 283+#ifdef FUZZEL_ENABLE_SVG284 static bool285 icon_from_svg(struct icon *icon, RsvgHandle *svg)286 {287 icon->type = ICON_SVG;288 icon->svg = svg;289 return true;290 }291+#endif292 293 static void294 icon_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 lines377 } else {378 /* Use anyone available */379 }380 381+#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 }381-388+#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 lines415 char path[strlen(it->item) + 1 +416 strlen("pixmaps") + 1 +417 strlen(name) + strlen(".svg") + 1];418 419+#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+#endif428 429 /* 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 linesmodified:main.c+1 added
1 #include <stdlib.h>2 #include <stdio.h>3 #include <stdbool.h>4+#include <string.h>5 #include <getopt.h>6 7 #include <locale.h>8 435 unmodified linesmodified:match.c+1 added
1 #include "match.h"2 3+#include <stdlib.h>4 #include <wctype.h>5 #include <assert.h>6 7 struct matches {196 unmodified linesadded:meson_options.txt+1 added
1+option('enable-svg', type: 'boolean', value: true)modified:meson.build+5 added-1 removed
47 unmodified lines48 49 pixman = dependency('pixman-1')50 cairo = dependency('cairo')51 cairo_ft = dependency('cairo-ft')52-librsvg = dependency('librsvg-2.0')52+librsvg = dependency('librsvg-2.0', required: get_option('enable-svg'))53 wayland_protocols = dependency('wayland-protocols')54 wayland_client = dependency('wayland-client')55 wayland_cursor = dependency('wayland-cursor')56 xkb = dependency('xkbcommon')57 58+if get_option('enable-svg')59+ add_project_arguments('-DFUZZEL_ENABLE_SVG=1', language: 'c')60+endif61+62 tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')63 fcft = dependency('fcft', version: ['>=2.0.0', '<3.0.0'], fallback: 'fcft')64 65 wayland_protocols_datadir = wayland_protocols.get_pkgconfig_variable('pkgdatadir')65 unmodified linesmodified:render.c+4 added-1 removed
233 unmodified lines234 * there's "enough" free space, render a large235 * representation of the icon */236 237 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 lines267 if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS)268 rsvg_handle_render_cairo(svg, buf->cairo);269 cairo_restore(buf->cairo);270 }271+#endif272 }271-273 /* 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 lines318 break;319 }320 321 case ICON_SVG: {322+#ifdef FUZZEL_ENABLE_SVG323 RsvgHandle *svg = match->application->icon.svg;324 325 RsvgDimensionData dim;326 rsvg_handle_get_dimensions(svg, &dim);13 unmodified lines340 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 }347 348 cur_x += row_height;97 unmodified linesmodified:wayland.c+1 added
1 #include "wayland.h"2 3 #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 linesmodified:xdg.c+1 added
4 unmodified lines5 #include <string.h>6 #include <stdbool.h>7 #include <wchar.h>8 #include <unistd.h>9+#include <limits.h>10 11 #include <sys/types.h>12 #include <sys/stat.h>13 #include <dirent.h>310 unmodified lines