diff gtk3/dw.c @ 2114:251d050d306b

Change dw_notification_new() to take an image path instead of an in-memory HPIXMAP. After examining all the platforms, several require the image to be on disk. It is easier to specify the path and load it on platforms requiring it in memory than to save it to disk on platforms that require it on disk. Currently it does not automatically pick an extension like some other functions, may need to add that feature here too soon. Only tested on Windows in this commit.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Jun 2020 07:48:29 +0000
parents aaea278c2356
children 79e5842fb609
line wrap: on
line diff
--- a/gtk3/dw.c	Mon Jun 22 04:44:47 2020 +0000
+++ b/gtk3/dw.c	Tue Jun 23 07:48:29 2020 +0000
@@ -11062,7 +11062,7 @@
  * Creates a new system notification if possible.
  * Parameters:
  *         title: The short title of the notification.
- *         pixmap: Handle to an image to display or NULL if none.
+ *         imagepath: Path to an image to display or NULL if none.
  *         description: A longer description of the notification,
  *                      or NULL if none is necessary.
  * Returns:
@@ -11072,7 +11072,7 @@
  *          This will create a system notification that will show in the notifaction panel
  *          on supported systems, which may be clicked to perform another task.
  */
-HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...)
+HWND dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
 {
 #if GLIB_CHECK_VERSION(2,40,0)
    GNotification *notification = g_notification_new(title);
@@ -11090,8 +11090,18 @@
 
          g_notification_set_body(notification, outbuf);
       }
-      if(pixmap && pixmap->pixbuf)
-         g_notification_set_icon(notification, G_ICON(pixmap->pixbuf));
+      if(imagepath)
+      {
+         GFile *file = g_file_new_for_path(imagepath);
+         
+         if(file)
+         {
+            GFileIcon *icon = g_file_icon_new(file);
+            
+            if(icon)
+               g_notification_set_icon(notification, G_ICON(icon));
+         }
+      }
       g_notification_set_default_action_and_target(notification, "app.notification", "t", (guint64)notification); 
    }
    return (HWND)notification;