Skip to content

Commit 6203779

Browse files
fmuellnervkareh
authored andcommitted
theme: Allow disabling fallback colors in gtk:custom()
gtk:custom() requires a fallback color in case the GTK+ theme in use does not define the desired color. As in general the fallback color will approximate the intended color, there is the risk of typos going unnoticed. To make catching these kind of errors easier, allow to ignore the fallback color specified (and fall back to a nice shade of pink instead) by setting an environment variable. https://bugzilla.gnome.org/show_bug.cgi?id=656112
1 parent 18bfff3 commit 6203779

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/ui/theme.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,15 @@ meta_color_spec_new_from_string (const char *str,
11701170
str[8] == 'o' && str[9] == 'm')
11711171
{
11721172
const char *color_name_start, *fallback_str_start, *end;
1173-
char *color_name, *fallback_str;
1173+
char *color_name;
11741174
MetaColorSpec *fallback = NULL;
1175+
static gboolean debug, debug_set = FALSE;
1176+
1177+
if (!debug_set)
1178+
{
1179+
debug = g_getenv ("MUTTER_DISABLE_FALLBACK_COLOR") != NULL;
1180+
debug_set = TRUE;
1181+
}
11751182

11761183
if (str[10] != '(')
11771184
{
@@ -1212,9 +1219,18 @@ meta_color_spec_new_from_string (const char *str,
12121219
return NULL;
12131220
}
12141221

1215-
fallback_str = g_strndup (fallback_str_start, end - fallback_str_start);
1216-
fallback = meta_color_spec_new_from_string (fallback_str, err);
1217-
g_free (fallback_str);
1222+
if (!debug)
1223+
{
1224+
char *fallback_str;
1225+
fallback_str = g_strndup (fallback_str_start,
1226+
end - fallback_str_start);
1227+
fallback = meta_color_spec_new_from_string (fallback_str, err);
1228+
g_free (fallback_str);
1229+
}
1230+
else
1231+
{
1232+
fallback = meta_color_spec_new_from_string ("pink", err);
1233+
}
12181234

12191235
if (fallback == NULL)
12201236
return NULL;

0 commit comments

Comments
 (0)