Cache GdkPixbuf in notification structure
This commit is contained in:
parent
088907488c
commit
cd09d5a88e
17
src/icon.c
17
src/icon.c
@ -224,22 +224,7 @@ GdkPixbuf *get_pixbuf_from_raw_image(const struct raw_image *raw_image)
|
||||
|
||||
cairo_surface_t *icon_get_for_notification(const struct notification *n)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (n->raw_icon)
|
||||
pixbuf = get_pixbuf_from_raw_image(n->raw_icon);
|
||||
else if (n->iconname)
|
||||
pixbuf = get_pixbuf_from_icon(n->iconname);
|
||||
else
|
||||
return NULL;
|
||||
|
||||
ASSERT_OR_RET(pixbuf, NULL);
|
||||
|
||||
pixbuf = icon_pixbuf_scale(pixbuf);
|
||||
|
||||
cairo_surface_t *ret = gdk_pixbuf_to_cairo_surface(pixbuf);
|
||||
g_object_unref(pixbuf);
|
||||
return ret;
|
||||
return gdk_pixbuf_to_cairo_surface(n->icon);
|
||||
}
|
||||
|
||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "dbus.h"
|
||||
#include "dunst.h"
|
||||
#include "icon.h"
|
||||
#include "log.h"
|
||||
#include "markup.h"
|
||||
#include "menu.h"
|
||||
@ -23,6 +24,7 @@
|
||||
#include "settings.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void notification_update_icon(struct notification *n);
|
||||
static void notification_extract_urls(struct notification *n);
|
||||
static void notification_format_message(struct notification *n);
|
||||
|
||||
@ -363,10 +365,25 @@ void notification_init(struct notification *n)
|
||||
rule_apply_all(n);
|
||||
|
||||
/* UPDATE derived fields */
|
||||
notification_update_icon(n);
|
||||
notification_extract_urls(n);
|
||||
notification_format_message(n);
|
||||
}
|
||||
|
||||
static void notification_update_icon(struct notification *n)
|
||||
{
|
||||
g_return_if_fail(n);
|
||||
|
||||
g_clear_object(&n->icon);
|
||||
|
||||
if (n->raw_icon)
|
||||
n->icon = get_pixbuf_from_raw_image(n->raw_icon);
|
||||
else if (n->iconname)
|
||||
n->icon = get_pixbuf_from_icon(n->iconname);
|
||||
|
||||
n->icon = icon_pixbuf_scale(n->icon);
|
||||
}
|
||||
|
||||
static void notification_format_message(struct notification *n)
|
||||
{
|
||||
g_clear_pointer(&n->msg, g_free);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#ifndef DUNST_NOTIFICATION_H
|
||||
#define DUNST_NOTIFICATION_H
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <glib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -56,6 +57,7 @@ struct notification {
|
||||
char *category;
|
||||
enum urgency urgency;
|
||||
|
||||
GdkPixbuf *icon;
|
||||
char *iconname; /**< plain icon information (may be a path or just a name) */
|
||||
struct raw_image *raw_icon; /**< passed icon data of notification, takes precedence over icon */
|
||||
|
||||
|
@ -796,6 +796,8 @@ gpointer run_threaded_tests(gpointer data)
|
||||
|
||||
SUITE(suite_dbus)
|
||||
{
|
||||
settings.icon_path = "";
|
||||
|
||||
GTestDBus *dbus_bus;
|
||||
g_test_dbus_unset();
|
||||
queues_init();
|
||||
@ -813,6 +815,8 @@ SUITE(suite_dbus)
|
||||
g_object_unref(dbus_bus);
|
||||
g_thread_unref(thread_tests);
|
||||
g_main_loop_unref(loop);
|
||||
|
||||
settings.icon_path = NULL;
|
||||
}
|
||||
|
||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||
|
@ -698,6 +698,8 @@ TEST test_queues_timeout_before_paused(void)
|
||||
|
||||
SUITE(suite_queues)
|
||||
{
|
||||
settings.icon_path = "";
|
||||
|
||||
RUN_TEST(test_datachange_beginning_empty);
|
||||
RUN_TEST(test_datachange_endless);
|
||||
RUN_TEST(test_datachange_endless_agethreshold);
|
||||
@ -722,6 +724,8 @@ SUITE(suite_queues)
|
||||
RUN_TEST(test_queues_update_seeping);
|
||||
RUN_TEST(test_queues_update_xmore);
|
||||
RUN_TEST(test_queues_timeout_before_paused);
|
||||
|
||||
settings.icon_path = NULL;
|
||||
}
|
||||
|
||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||
|
Loading…
x
Reference in New Issue
Block a user