[Xfce4-commits] [apps/xfce4-notifyd] 02/02: Handle desktop-id as fallback for appicon in the log
noreply at xfce.org
noreply at xfce.org
Tue Aug 29 23:39:45 CEST 2017
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-notifyd.
commit 9c87ae24b454b33583b91b33ffe3760a1c0cc443
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Tue Aug 29 23:39:26 2017 +0200
Handle desktop-id as fallback for appicon in the log
Many new gnome applications (like Gnome Software) don't provide
an appicon (like the notification spec demands) but only a
desktop-id. The notification daemon itself has handled this case
for a while, the log can also deal with it now.
---
xfce4-notifyd/xfce-notify-daemon.c | 43 ++++++++------------------------------
xfce4-notifyd/xfce-notify-log.c | 32 +++++++++++++++++++++++++---
xfce4-notifyd/xfce-notify-log.h | 5 ++++-
3 files changed, 42 insertions(+), 38 deletions(-)
diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index dcac2ee..6c6cfa2 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -1223,12 +1223,14 @@ notify_notify (XfceNotifyGBus *skeleton,
xndaemon->log_level_apps == 2 && application_is_muted == TRUE)
xfce_notify_log_insert (new_app_name, summary, body,
image_data, image_path, app_icon,
- expire_timeout, actions);
+ desktop_id, expire_timeout, actions);
}
- xfce_notify_gbus_complete_notify(skeleton, invocation, OUT_id);
- g_variant_unref(image_data);
- g_free(desktop_id);
+ xfce_notify_gbus_complete_notify (skeleton, invocation, OUT_id);
+ if (image_data)
+ g_variant_unref (image_data);
+ if (desktop_id)
+ g_free (desktop_id);
return TRUE;
}
}
@@ -1289,35 +1291,8 @@ notify_notify (XfceNotifyGBus *skeleton,
else if (app_icon && (g_strcmp0 (app_icon, "") != 0)) {
xfce_notify_window_set_icon_name (window, app_icon);
}
- else {
- if(desktop_id) {
- gchar *resource = g_strdup_printf("applications%c%s.desktop",
- G_DIR_SEPARATOR,
- desktop_id);
- XfceRc *rcfile = xfce_rc_config_open(XFCE_RESOURCE_DATA,
- resource, TRUE);
- if(rcfile) {
- if(xfce_rc_has_group(rcfile, "Desktop Entry")) {
- const gchar *icon_file;
- xfce_rc_set_group(rcfile, "Desktop Entry");
- icon_file = xfce_rc_read_entry(rcfile, "Icon", NULL);
- if(icon_file) {
- pix = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
- icon_file,
- 48,
- GTK_ICON_LOOKUP_FORCE_SIZE,
- NULL);
-
- if(pix) {
- xfce_notify_window_set_icon_pixbuf(window, pix);
- g_object_unref(G_OBJECT(pix));
- }
- }
- }
- xfce_rc_close(rcfile);
- }
- g_free(resource);
- }
+ else if (desktop_id) {
+ xfce_notify_window_set_icon_name (window, notify_icon_name_from_desktop_id (desktop_id));
}
if (xndaemon->notification_log == TRUE &&
@@ -1326,7 +1301,7 @@ notify_notify (XfceNotifyGBus *skeleton,
transient == FALSE)
xfce_notify_log_insert (new_app_name, summary, body,
image_data, image_path, app_icon,
- expire_timeout, actions);
+ desktop_id, expire_timeout, actions);
xfce_notify_window_set_icon_only(window, x_canonical);
diff --git a/xfce4-notifyd/xfce-notify-log.c b/xfce4-notifyd/xfce-notify-log.c
index 1b0fc25..fcb43ee 100644
--- a/xfce4-notifyd/xfce-notify-log.c
+++ b/xfce4-notifyd/xfce-notify-log.c
@@ -33,12 +33,13 @@
#include <gdk/gdkx.h>
#include <glib.h>
+#include <gtk/gtk.h>
#include "xfce-notify-daemon.h"
#include "xfce-notify-log.h"
GdkPixbuf *
-notify_pixbuf_from_image_data(GVariant *image_data)
+notify_pixbuf_from_image_data (GVariant *image_data)
{
GdkPixbuf *pix = NULL;
gint32 width, height, rowstride, bits_per_sample, channels;
@@ -83,6 +84,29 @@ notify_pixbuf_from_image_data(GVariant *image_data)
return pix;
}
+const gchar *
+notify_icon_name_from_desktop_id (const gchar *desktop_id)
+{
+ const gchar *icon_file;
+ gchar *resource;
+ XfceRc *rcfile;
+
+ resource = g_strdup_printf("applications%c%s.desktop",
+ G_DIR_SEPARATOR,
+ desktop_id);
+ rcfile = xfce_rc_config_open(XFCE_RESOURCE_DATA,
+ resource, TRUE);
+ if (rcfile) {
+ if (xfce_rc_has_group (rcfile, "Desktop Entry")) {
+ xfce_rc_set_group (rcfile, "Desktop Entry");
+ icon_file = xfce_rc_read_entry (rcfile, "Icon", NULL);
+ }
+ xfce_rc_close (rcfile);
+ }
+ g_free (resource);
+ return icon_file;
+}
+
GKeyFile *
xfce_notify_log_get (void)
{
@@ -110,6 +134,7 @@ void xfce_notify_log_insert (const gchar *app_name,
GVariant *image_data,
const gchar *image_path,
const gchar *app_icon,
+ const gchar *desktop_id,
gint expire_timeout,
const gchar **actions)
{
@@ -174,8 +199,9 @@ void xfce_notify_log_insert (const gchar *app_name,
else if (app_icon && (g_strcmp0 (app_icon, "") != 0)) {
g_key_file_set_string (notify_log, group, "app_icon", app_icon);
}
-// else
-// g_warning ("everything failed. :'(");
+ else if (desktop_id) {
+ g_key_file_set_string (notify_log, group, "app_icon", notify_icon_name_from_desktop_id(desktop_id));
+ }
timeout = g_strdup_printf ("%d", expire_timeout);
g_key_file_set_string (notify_log, group, "expire-timeout", timeout);
diff --git a/xfce4-notifyd/xfce-notify-log.h b/xfce4-notifyd/xfce-notify-log.h
index 07595ed..cfb1bac 100644
--- a/xfce4-notifyd/xfce-notify-log.h
+++ b/xfce4-notifyd/xfce-notify-log.h
@@ -24,7 +24,9 @@
#define XFCE_NOTIFY_LOG_FILE "xfce4/notifyd/log"
#define XFCE_NOTIFY_ICON_PATH "xfce4/notifyd/icons/"
-GdkPixbuf *notify_pixbuf_from_image_data(GVariant *image_data);
+GdkPixbuf *notify_pixbuf_from_image_data (GVariant *image_data);
+
+const gchar *notify_icon_name_from_desktop_id (const gchar *desktop_id);
GKeyFile *xfce_notify_log_get (void);
@@ -34,6 +36,7 @@ void xfce_notify_log_insert (const gchar *app_name,
GVariant *image_data,
const gchar *image_path,
const gchar *app_icon,
+ const gchar *desktop_id,
gint expire_timeout,
const gchar **actions);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list