mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
gtk-demo: Dark theme support for dnd demo
Add minimal dark theme support to the dnd demo, by picking suitable default colors for our items.
This commit is contained in:
parent
230107cd84
commit
42902085e5
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user