Skip to content

Commit ec1edef

Browse files
rilian-la-teLars Uebernickel
authored andcommitted
gfdonotificationbackend: support themed icons
The spec allows setting the "image-path" hint to an icon name as well. https://bugzilla.gnome.org/show_bug.cgi?id=745634
1 parent b9c8cec commit ec1edef

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

gio/gfdonotificationbackend.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "gdbusconnection.h"
2828
#include "gactiongroup.h"
2929
#include "gaction.h"
30+
#include "gthemedicon.h"
3031
#include "gfileicon.h"
3132
#include "gfile.h"
3233
#include "gdbusutils.h"
@@ -262,13 +263,23 @@ call_notify (GDBusConnection *con,
262263
urgency = urgency_from_priority (g_notification_get_priority (notification));
263264
g_variant_builder_add (&hints_builder, "{sv}", "urgency", g_variant_new_byte (urgency));
264265
icon = g_notification_get_icon (notification);
265-
if (icon != NULL && G_IS_FILE_ICON (icon))
266+
if (icon != NULL)
266267
{
267-
GFile *file;
268+
if (G_IS_FILE_ICON (icon))
269+
{
270+
GFile *file;
268271

269-
file = g_file_icon_get_file (G_FILE_ICON (icon));
270-
g_variant_builder_add (&hints_builder, "{sv}", "image-path",
271-
g_variant_new_take_string (g_file_get_path (file)));
272+
file = g_file_icon_get_file (G_FILE_ICON (icon));
273+
g_variant_builder_add (&hints_builder, "{sv}", "image-path",
274+
g_variant_new_take_string (g_file_get_path (file)));
275+
}
276+
else if (G_IS_THEMED_ICON (icon))
277+
{
278+
const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON (icon));
279+
/* Take first name from GThemedIcon */
280+
g_variant_builder_add (&hints_builder, "{sv}", "image-path",
281+
g_variant_new_string (icon_names[0]));
282+
}
272283
}
273284

274285
body = g_notification_get_body (notification);

0 commit comments

Comments
 (0)