Mercurial > dwindows
comparison gtk3/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 |
---|---|
2067 _DWApp = g_application_new(_dw_app_id, G_APPLICATION_FLAGS_NONE); | 2067 _DWApp = g_application_new(_dw_app_id, G_APPLICATION_FLAGS_NONE); |
2068 if(_DWApp && g_application_register(_DWApp, NULL, NULL)) | 2068 if(_DWApp && g_application_register(_DWApp, NULL, NULL)) |
2069 { | 2069 { |
2070 #if GLIB_CHECK_VERSION(2,40,0) | 2070 #if GLIB_CHECK_VERSION(2,40,0) |
2071 /* Creat our notification handler for any notifications */ | 2071 /* Creat our notification handler for any notifications */ |
2072 GSimpleAction *action = g_simple_action_new("notification", "t"); | 2072 GSimpleAction *action = g_simple_action_new("notification", G_VARIANT_TYPE_UINT64); |
2073 | 2073 |
2074 g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(_dw_notification_handler), NULL); | 2074 g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(_dw_notification_handler), NULL); |
2075 g_action_map_add_action(G_ACTION_MAP(_DWApp), G_ACTION(action)); | 2075 g_action_map_add_action(G_ACTION_MAP(_DWApp), G_ACTION(action)); |
2076 #endif | 2076 #endif |
2077 g_application_activate(_DWApp); | 2077 g_application_activate(_DWApp); |
11092 } | 11092 } |
11093 /* check if we can read from this file (it exists and read permission) */ | 11093 /* check if we can read from this file (it exists and read permission) */ |
11094 if(imagepath && access(imagepath, 04 ) != 0) | 11094 if(imagepath && access(imagepath, 04 ) != 0) |
11095 { | 11095 { |
11096 GFile *file = g_file_new_for_path(imagepath); | 11096 GFile *file = g_file_new_for_path(imagepath); |
11097 GBytes *bytes = g_file_load_bytes(file, NULL, NULL, NULL); | |
11097 | 11098 |
11098 if(file) | 11099 if(bytes) |
11099 { | 11100 { |
11100 GIcon *icon = g_file_icon_new(file); | 11101 GIcon *icon = g_bytes_icon_new(bytes); |
11101 | 11102 |
11102 if(icon) | 11103 if(icon) |
11103 g_notification_set_icon(notification, G_ICON(icon)); | 11104 g_notification_set_icon(notification, G_ICON(icon)); |
11104 } | 11105 } |
11105 } | 11106 } |