forked from AuroraMiddleware/gtk
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);
|
||||
|
||||
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