comparison gtk/dw.c @ 2117:37060de79102

GTK: Versions of Glib prior to May 2019 don't support GFileIcon for notifications. Also fix a GVariant warning in g_simple_action_new().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Jun 2020 09:37:37 +0000
parents 79e5842fb609
children c3f088266bcd
comparison
equal deleted inserted replaced
2116:cdc5124b6525 2117:37060de79102
2139 _DWApp = g_application_new(_dw_app_id, G_APPLICATION_FLAGS_NONE); 2139 _DWApp = g_application_new(_dw_app_id, G_APPLICATION_FLAGS_NONE);
2140 if(g_application_register(_DWApp, NULL, NULL)) 2140 if(g_application_register(_DWApp, NULL, NULL))
2141 { 2141 {
2142 #if GLIB_CHECK_VERSION(2,40,0) 2142 #if GLIB_CHECK_VERSION(2,40,0)
2143 /* Creat our notification handler for any notifications */ 2143 /* Creat our notification handler for any notifications */
2144 GSimpleAction *action = g_simple_action_new("notification", "t"); 2144 GSimpleAction *action = g_simple_action_new("notification", G_VARIANT_TYPE_UINT64);
2145 2145
2146 g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(_dw_notification_handler), NULL); 2146 g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(_dw_notification_handler), NULL);
2147 g_action_map_add_action(G_ACTION_MAP(_DWApp), G_ACTION(action)); 2147 g_action_map_add_action(G_ACTION_MAP(_DWApp), G_ACTION(action));
2148 #endif 2148 #endif
2149 g_application_activate(_DWApp); 2149 g_application_activate(_DWApp);
12387 } 12387 }
12388 /* check if we can read from this file (it exists and read permission) */ 12388 /* check if we can read from this file (it exists and read permission) */
12389 if(imagepath && access(imagepath, 04 ) != 0) 12389 if(imagepath && access(imagepath, 04 ) != 0)
12390 { 12390 {
12391 GFile *file = g_file_new_for_path(imagepath); 12391 GFile *file = g_file_new_for_path(imagepath);
12392 GBytes *bytes = g_file_load_bytes(file, NULL, NULL, NULL);
12392 12393
12393 if(file) 12394 if(bytes)
12394 { 12395 {
12395 GIcon *icon = g_file_icon_new(file); 12396 GIcon *icon = g_bytes_icon_new(bytes);
12396 12397
12397 if(icon) 12398 if(icon)
12398 g_notification_set_icon(notification, G_ICON(icon)); 12399 g_notification_set_icon(notification, G_ICON(icon));
12399 } 12400 }
12400 } 12401 }