comparison gtk/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
12355 12355
12356 /* 12356 /*
12357 * Creates a new system notification if possible. 12357 * Creates a new system notification if possible.
12358 * Parameters: 12358 * Parameters:
12359 * title: The short title of the notification. 12359 * title: The short title of the notification.
12360 * pixmap: Handle to an image to display or NULL if none. 12360 * imagepath: Path to an image to display or NULL if none.
12361 * description: A longer description of the notification, 12361 * description: A longer description of the notification,
12362 * or NULL if none is necessary. 12362 * or NULL if none is necessary.
12363 * Returns: 12363 * Returns:
12364 * A handle to the notification which can be used to attach a "clicked" event if desired, 12364 * A handle to the notification which can be used to attach a "clicked" event if desired,
12365 * or NULL if it fails or notifications are not supported by the system. 12365 * or NULL if it fails or notifications are not supported by the system.
12383 vsnprintf(outbuf, 1024, description, args); 12383 vsnprintf(outbuf, 1024, description, args);
12384 va_end(args); 12384 va_end(args);
12385 12385
12386 g_notification_set_body(notification, outbuf); 12386 g_notification_set_body(notification, outbuf);
12387 } 12387 }
12388 #if GTK_MAJOR_VERSION > 1 12388 if(imagepath)
12389 /* GTK 1.x is not implemented as pixbuf, so only allow icons on 2.x */ 12389 {
12390 if(pixmap && pixmap->pixbuf) 12390 GFile *file = g_file_new_for_path(imagepath);
12391 g_notification_set_icon(notification, G_ICON(pixmap->pixbuf)); 12391
12392 #endif 12392 if(file)
12393 {
12394 GFileIcon *icon = g_file_icon_new(file);
12395
12396 if(icon)
12397 g_notification_set_icon(notification, G_ICON(icon));
12398 }
12399 }
12393 g_notification_set_default_action_and_target(notification, "app.notification", "t", (guint64)notification); 12400 g_notification_set_default_action_and_target(notification, "app.notification", "t", (guint64)notification);
12394 } 12401 }
12395 return (HWND)notification; 12402 return (HWND)notification;
12396 #else 12403 #else
12397 return NULL; 12404 return NULL;