[glib] gfdonotificationbackend: support themed icons



commit ec1edef3ab171f1fa24d62858a2643de6e582f58
Author: ria freelander gmail com <ria freelander gmail com>
Date:   Thu Mar 5 13:07:00 2015 +0000

    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

 gio/gfdonotificationbackend.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gio/gfdonotificationbackend.c b/gio/gfdonotificationbackend.c
index 1603f6e..7b98027 100644
--- a/gio/gfdonotificationbackend.c
+++ b/gio/gfdonotificationbackend.c
@@ -27,6 +27,7 @@
 #include "gdbusconnection.h"
 #include "gactiongroup.h"
 #include "gaction.h"
+#include "gthemedicon.h"
 #include "gfileicon.h"
 #include "gfile.h"
 #include "gdbusutils.h"
@@ -262,13 +263,23 @@ call_notify (GDBusConnection     *con,
   urgency = urgency_from_priority (g_notification_get_priority (notification));
   g_variant_builder_add (&hints_builder, "{sv}", "urgency", g_variant_new_byte (urgency));
   icon = g_notification_get_icon (notification);
-  if (icon != NULL && G_IS_FILE_ICON (icon))
+  if (icon != NULL)
     {
-      GFile *file;
+      if (G_IS_FILE_ICON (icon))
+        {
+           GFile *file;
 
-      file = g_file_icon_get_file (G_FILE_ICON (icon));
-      g_variant_builder_add (&hints_builder, "{sv}", "image-path",
-                             g_variant_new_take_string (g_file_get_path (file)));
+           file = g_file_icon_get_file (G_FILE_ICON (icon));
+           g_variant_builder_add (&hints_builder, "{sv}", "image-path",
+                                  g_variant_new_take_string (g_file_get_path (file)));
+        }
+      else if (G_IS_THEMED_ICON (icon))
+        {
+           const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON (icon));
+           /* Take first name from GThemedIcon */
+           g_variant_builder_add (&hints_builder, "{sv}", "image-path",
+                                  g_variant_new_string (icon_names[0]));
+        }
     }
 
   body = g_notification_get_body (notification);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]