comparison 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
comparison
equal deleted inserted replaced
2113:aaea278c2356 2114:251d050d306b
11060 11060
11061 /* 11061 /*
11062 * Creates a new system notification if possible. 11062 * Creates a new system notification if possible.
11063 * Parameters: 11063 * Parameters:
11064 * title: The short title of the notification. 11064 * title: The short title of the notification.
11065 * pixmap: Handle to an image to display or NULL if none. 11065 * imagepath: Path to an image to display or NULL if none.
11066 * description: A longer description of the notification, 11066 * description: A longer description of the notification,
11067 * or NULL if none is necessary. 11067 * or NULL if none is necessary.
11068 * Returns: 11068 * Returns:
11069 * A handle to the notification which can be used to attach a "clicked" event if desired, 11069 * A handle to the notification which can be used to attach a "clicked" event if desired,
11070 * or NULL if it fails or notifications are not supported by the system. 11070 * or NULL if it fails or notifications are not supported by the system.
11071 * Remarks: 11071 * Remarks:
11072 * This will create a system notification that will show in the notifaction panel 11072 * This will create a system notification that will show in the notifaction panel
11073 * on supported systems, which may be clicked to perform another task. 11073 * on supported systems, which may be clicked to perform another task.
11074 */ 11074 */
11075 HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...) 11075 HWND dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
11076 { 11076 {
11077 #if GLIB_CHECK_VERSION(2,40,0) 11077 #if GLIB_CHECK_VERSION(2,40,0)
11078 GNotification *notification = g_notification_new(title); 11078 GNotification *notification = g_notification_new(title);
11079 11079
11080 if(notification) 11080 if(notification)
11088 vsnprintf(outbuf, 1024, description, args); 11088 vsnprintf(outbuf, 1024, description, args);
11089 va_end(args); 11089 va_end(args);
11090 11090
11091 g_notification_set_body(notification, outbuf); 11091 g_notification_set_body(notification, outbuf);
11092 } 11092 }
11093 if(pixmap && pixmap->pixbuf) 11093 if(imagepath)
11094 g_notification_set_icon(notification, G_ICON(pixmap->pixbuf)); 11094 {
11095 GFile *file = g_file_new_for_path(imagepath);
11096
11097 if(file)
11098 {
11099 GFileIcon *icon = g_file_icon_new(file);
11100
11101 if(icon)
11102 g_notification_set_icon(notification, G_ICON(icon));
11103 }
11104 }
11095 g_notification_set_default_action_and_target(notification, "app.notification", "t", (guint64)notification); 11105 g_notification_set_default_action_and_target(notification, "app.notification", "t", (guint64)notification);
11096 } 11106 }
11097 return (HWND)notification; 11107 return (HWND)notification;
11098 #else 11108 #else
11099 return NULL; 11109 return NULL;