diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c index 70ea875c1c..1aff3b1bcd 100644 --- a/demos/gtk-demo/dnd.c +++ b/demos/gtk-demo/dnd.c @@ -153,6 +153,30 @@ click_done (GtkGesture *gesture) gtk_widget_insert_after (item, canvas, last_child); } +static gboolean +theme_is_dark (void) +{ + GtkSettings *settings; + char *theme; + gboolean prefer_dark; + gboolean dark; + + settings = gtk_settings_get_default (); + g_object_get (settings, + "gtk-theme-name", &theme, + "gtk-application-prefer-dark-theme", &prefer_dark, + NULL); + + if ((strcmp (theme, "Adwaita") == 0 && prefer_dark) || strcmp (theme, "HighContrastInverse") == 0) + dark = TRUE; + else + dark = FALSE; + + g_free (theme); + + return dark; +} + static void canvas_item_init (CanvasItem *item) { @@ -180,7 +204,11 @@ canvas_item_init (CanvasItem *item) gtk_widget_set_name (item->label, id); g_free (id); - gdk_rgba_parse (&rgba, "yellow"); + if (theme_is_dark ()) + gdk_rgba_parse (&rgba, "blue"); + else + gdk_rgba_parse (&rgba, "yellow"); + set_color (item, &rgba); item->angle = 0;