comparison gtk3/dw.c @ 2113:aaea278c2356

GTK: Fix variant warning, needed to specify parameter type on action. Implemented notification clicked callback on GTK2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 22 Jun 2020 04:44:47 +0000
parents b33d020b04e7
children 251d050d306b
comparison
equal deleted inserted replaced
2112:b33d020b04e7 2113:aaea278c2356
1958 #if GLIB_CHECK_VERSION(2,40,0) 1958 #if GLIB_CHECK_VERSION(2,40,0)
1959 /* Handle system notification click callbacks */ 1959 /* Handle system notification click callbacks */
1960 static void _dw_notification_handler(GSimpleAction *action, GVariant *param, gpointer user_data) 1960 static void _dw_notification_handler(GSimpleAction *action, GVariant *param, gpointer user_data)
1961 { 1961 {
1962 char textbuf[101] = {0}; 1962 char textbuf[101] = {0};
1963 void (*func)(HWND, void *); 1963 int (*func)(HWND, void *);
1964 void *data; 1964 void *data;
1965 1965
1966 snprintf(textbuf, 100, "dw-notification-%llu-func", (unsigned long long)g_variant_get_uint64(param)); 1966 snprintf(textbuf, 100, "dw-notification-%llu-func", (unsigned long long)g_variant_get_uint64(param));
1967 func = g_object_get_data(G_OBJECT(_DWApp), textbuf); 1967 func = g_object_get_data(G_OBJECT(_DWApp), textbuf);
1968 g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL); 1968 g_object_set_data(G_OBJECT(_DWApp), textbuf, NULL);
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", NULL); 2072 GSimpleAction *action = g_simple_action_new("notification", "t");
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);
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)
11081 { 11081 {
11082 GVariant *param = g_variant_new_uint64((guint64)notification);
11083
11084 if(description) 11082 if(description)
11085 { 11083 {
11086 va_list args; 11084 va_list args;
11087 char outbuf[1025] = {0}; 11085 char outbuf[1025] = {0};
11088 11086
11092 11090
11093 g_notification_set_body(notification, outbuf); 11091 g_notification_set_body(notification, outbuf);
11094 } 11092 }
11095 if(pixmap && pixmap->pixbuf) 11093 if(pixmap && pixmap->pixbuf)
11096 g_notification_set_icon(notification, G_ICON(pixmap->pixbuf)); 11094 g_notification_set_icon(notification, G_ICON(pixmap->pixbuf));
11097 g_notification_set_default_action_and_target_value(notification, "app.notification", param); 11095 g_notification_set_default_action_and_target(notification, "app.notification", "t", (guint64)notification);
11098 } 11096 }
11099 return (HWND)notification; 11097 return (HWND)notification;
11100 #else 11098 #else
11101 return NULL; 11099 return NULL;
11102 #endif 11100 #endif