Skip to content

Conversation

@UtkarshVerma
Copy link

This commit implements customColor styling for SVG icons using librsvg. This is a rebased version of #1081 as master had changed quite a lot from that branch.

bynect and others added 15 commits August 4, 2025 16:53
Add the missing EmitsChangedSignal annotations to the *Length dbus
properties, which were given changed signals in dunst-project#1127 .
Fixes incorrect introspection mentioned in dunst-project#832 .
Make SIGUSR* signal handlers send a PropertiesChanged signal after
modifying the paused state. Fixes the remainder of dunst-project#832 .
These tests ensure that PropertiesChanged signals are sent when the
pause and unpause signals are handled.

Signal handler functions are called directly instead of emitting real
signals, as doing this might not be safe inside of a testing
environment.
Ensure PropertiesChanged signal is sent when handling SIGUSR*
Upon scripting inside my dunstrc I did encounter a little typo where this word was listed twice.
This commit implements customColor styling for SVG icons using librsvg.
@bynect
Copy link
Contributor

bynect commented Oct 11, 2025

could this possibly be tweaked to allow a svg_stylesheet instead of just the color?

@UtkarshVerma
Copy link
Author

UtkarshVerma commented Oct 12, 2025

I have implemented a version with a bit of templating as well. Please have a look. For now, it defaults to path: { fill: @foreground !important; }. I also allow the user to use @foreground and @background so that the color vary based on the active notification.

This is how the defaults look for me, for example.

image

Also, for the tests, I think librsvg needs to be added to the CI docker images.

@bynect
Copy link
Contributor

bynect commented Oct 12, 2025

Also, for the tests, I think librsvg needs to be added to the CI docker images

you are right I will do so

@bynect
Copy link
Contributor

bynect commented Oct 12, 2025

this seems to be a problem with librsvg itself?

@UtkarshVerma
Copy link
Author

All tests pass for me. make test-valgrind reports some errors but they are also the on master so I doubt it is from this PR.

@UtkarshVerma
Copy link
Author

How should I proceed with this PR?

@bynect
Copy link
Contributor

bynect commented Oct 16, 2025

The code seems good and I have no clue why the build is failing. It seems like the library includes are wrong??

@UtkarshVerma
Copy link
Author

It couldn't be the library includes. As I've stated before, make test-valgrind fails on master without my changes.

@bynect
Copy link
Contributor

bynect commented Oct 17, 2025

make test and make test-valgrind work normally for me on master. you might just have some messed up library version.
what the ci is failing on is the build step:

pod2man --name=dunst -c "Dunst Reference" --section=1 --release="v1.13.0-16-g95321a8" docs/dunst.1.pod > docs/dunst.1
src/icon.c:236:17: error: implicit declaration of function 'rsvg_handle_set_stylesheet' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                rsvg_handle_set_stylesheet(handle, (guint8 *)resolved_css, strlen(resolved_css), &error);
                ^
In file included from test/icon.c:1:
test/../src/icon.c:236:17: error: implicit declaration of function 'rsvg_handle_set_stylesheet' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                rsvg_handle_set_stylesheet(handle, (guint8 *)resolved_css, strlen(resolved_css), &error);
                ^
src/icon.c:236:17: note: did you mean 'rsvg_handle_get_type'?
test/../src/icon.c:236:17: note: did you mean 'rsvg_handle_get_type'?
/usr/include/librsvg-2.0/librsvg/rsvg.h:53:7: note: 'rsvg_handle_get_type' declared here
GType rsvg_handle_get_type (void);
      ^
/usr/include/librsvg-2.0/librsvg/rsvg.h:53:7: note: 'rsvg_handle_get_type' declared here
GType rsvg_handle_get_type (void);
      ^
In file included from src/icon.c:239:30: error: expected ';' after expression
                RsvgRectangle viewport = {
                             ^
                             ;
src/icon.c:239:17: error: use of undeclared identifier 'RsvgRectangle'
                RsvgRectangle viewport = {
                ^
test/icon.c:1:
test/../src/icon.c:239:30: error: expected ';' after expression
                RsvgRectangle viewport = {
                             ^
                             ;
test/../src/icon.c:239:17: error: use of undeclared identifier 'RsvgRectangle'
                RsvgRectangle viewport = {
                ^
test/../src/icon.c:239:31: error: use of undeclared identifier 'viewport'
                RsvgRectangle viewport = {
                              ^
test/../src/icon.c:239:42: error: expected expression
                RsvgRectangle viewport = {
                                         ^
test/../src/icon.c:245:17: error: implicit declaration of function 'rsvg_handle_render_document' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                rsvg_handle_render_document(handle, cr, &viewport, &error);
                ^
src/icon.c:239:31: error: use of undeclared identifier 'viewport'
                RsvgRectangle viewport = {
                              ^
src/icon.c:239:42: error: expected expression
                RsvgRectangle viewport = {
                                         ^
src/icon.c:245:17: error: implicit declaration of function 'rsvg_handle_render_document' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                rsvg_handle_render_document(handle, cr, &viewport, &error);
                ^
clang -o dunstify dunstify.o -g -std=gnu11 -pedantic -Wall -Wno-overlength-strings -Os -Werror     -pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lm -lrt  -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
src/icon.c:245:17: note: did you mean 'rsvg_handle_render_cairo'?
/usr/include/librsvg-2.0/librsvg/rsvg-cairo.h:37:13: note: 'rsvg_handle_render_cairo' declared here
gboolean    rsvg_handle_render_cairo     (RsvgHandle * handle, cairo_t * cr);
            ^
src/icon.c:245:58: error: use of undeclared identifier 'viewport'
                rsvg_handle_render_document(handle, cr, &viewport, &error);
                                                         ^
test/../src/icon.c:245:17: note: did you mean 'rsvg_handle_render_cairo'?
/usr/include/librsvg-2.0/librsvg/rsvg-cairo.h:37:13:7 errors generated.
 note: 'rsvg_handle_render_cairo' declared here
gboolean    rsvg_handle_render_cairo     (RsvgHandle * handle, cairo_t * cr);
            ^
In file included from test/icon.c:1:
test/../src/icon.c:245:58: error: use of undeclared identifier 'viewport'
                rsvg_handle_render_document(handle, cr, &viewport, &error);
                                                         ^
make: *** [Makefile:85: src/icon.o] Error 1
make: *** Waiting for unfinished jobs....
7 errors generated.
make: *** [Makefile:125: test/icon.o] Error 1

is this an old version of rsvg ? or an upstream bug? i never used the library myself so I can't tell at a glance

@fedang
Copy link
Contributor

fedang commented Nov 6, 2025

could you please rebase your code on the master branch?

also this error could be fixed by adding the flag -Wno-expansion-to-defined

 In file included from src/icon.c:6:
/usr/lib/pkgconfig/../../include/librsvg-2.0/librsvg/rsvg.h:1331:5: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
 1331 | #if LIBRSVG_CHECK_FEATURE(PIXBUF)
      |     ^
/usr/lib/pkgconfig/../../include/librsvg-2.0/librsvg/rsvg-features.h:127:41: note: expanded from macro 'LIBRSVG_CHECK_FEATURE'
  127 | #define LIBRSVG_CHECK_FEATURE(FEATURE) (defined(LIBRSVG_HAVE_##FEATURE) && LIBRSVG_HAVE_##FEATURE)
      |                                         ^
In file included from test/icon.c:1:
In file included from test/../src/icon.c:6:
/usr/lib/pkgconfig/../../include/librsvg-2.0/librsvg/rsvg.h:1331:5: error: macro expansion producing 'defined' has undefined behavior [-Werror,-Wexpansion-to-defined]
 1331 | #if LIBRSVG_CHECK_FEATURE(PIXBUF)
      |     ^
/usr/lib/pkgconfig/../../include/librsvg-2.0/librsvg/rsvg-features.h:127:41: note: expanded from macro 'LIBRSVG_CHECK_FEATURE'
  127 | #define LIBRSVG_CHECK_FEATURE(FEATURE) (defined(LIBRSVG_HAVE_##FEATURE) && LIBRSVG_HAVE_##FEATURE)
      |                                         ^
clang -o dunstify dunstify.o -g -std=gnu11 -pedantic -Wall -Wno-overlength-strings -Os -Werror     -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/webp -pthread -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lm -lrt  -lnotify -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
1 error generated.

@fedang
Copy link
Contributor

fedang commented Nov 6, 2025

It couldn't be the library includes. As I've stated before, make test-valgrind fails on master without my changes.

there seem to be a memory leak in your code. probably related to the new cairo surface. but since most of the pr diff comes from the merge it is quite difficult for me to debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants