comparison win/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 35abef6e33a9
children f9a2fc59611c
comparison
equal deleted inserted replaced
2113:aaea278c2356 2114:251d050d306b
9640 strcpy(file, filename); 9640 strcpy(file, filename);
9641 9641
9642 /* check if we can read from this file (it exists and read permission) */ 9642 /* check if we can read from this file (it exists and read permission) */
9643 if(access(file, 04) != 0) 9643 if(access(file, 04) != 0)
9644 { 9644 {
9645 /* Try with .bmp extention */ 9645 /* Try with .ico extention */
9646 strcat(file, ".ico"); 9646 strcat(file, ".ico");
9647 if(access(file, 04) != 0) 9647 if(access(file, 04) != 0)
9648 { 9648 {
9649 free(file); 9649 free(file);
9650 return 0; 9650 return 0;
12402 12402
12403 /* 12403 /*
12404 * Creates a new system notification if possible. 12404 * Creates a new system notification if possible.
12405 * Parameters: 12405 * Parameters:
12406 * title: The short title of the notification. 12406 * title: The short title of the notification.
12407 * pixmap: Handle to an image to display or NULL if none. 12407 * imagepath: Path to an image to display or NULL if none.
12408 * description: A longer description of the notification, 12408 * description: A longer description of the notification,
12409 * or NULL if none is necessary. 12409 * or NULL if none is necessary.
12410 * Returns: 12410 * Returns:
12411 * A handle to the notification which can be used to attach a "clicked" event if desired, 12411 * A handle to the notification which can be used to attach a "clicked" event if desired,
12412 * or NULL if it fails or notifications are not supported by the system. 12412 * or NULL if it fails or notifications are not supported by the system.
12413 * Remarks: 12413 * Remarks:
12414 * This will create a system notification that will show in the notifaction panel 12414 * This will create a system notification that will show in the notifaction panel
12415 * on supported systems, which may be clicked to perform another task. 12415 * on supported systems, which may be clicked to perform another task.
12416 */ 12416 */
12417 HWND API dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...) 12417 HWND API dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
12418 { 12418 {
12419 #ifdef BUILD_TOAST 12419 #ifdef BUILD_TOAST
12420 char outbuf[1025] = {0}; 12420 char outbuf[1025] = {0};
12421 12421
12422 if(description) 12422 if(description)
12425 12425
12426 va_start(args, description); 12426 va_start(args, description);
12427 vsnprintf(outbuf, 1024, description, args); 12427 vsnprintf(outbuf, 1024, description, args);
12428 va_end(args); 12428 va_end(args);
12429 } 12429 }
12430 return (HWND)_dw_notification_new(UTF8toWide(title), NULL, UTF8toWide(outbuf)); 12430 return (HWND)_dw_notification_new(UTF8toWide(title), imagepath ? UTF8toWide(imagepath) : NULL, UTF8toWide(outbuf));
12431 #else 12431 #else
12432 return NULL; 12432 return NULL;
12433 #endif 12433 #endif
12434 } 12434 }
12435 12435