Skip to content

Commit

Permalink
Fixed remapping of colourscheme options
Browse files Browse the repository at this point in the history
  • Loading branch information
realh committed Aug 18, 2023
1 parent c761d70 commit f115e45
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/configlet.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,18 @@ static char *configlet_get_configured_name(ConfigletList *cl)

g_return_val_if_fail(optkey, NULL);
const char *default_name;
const char *default_value;
if (strcmp(cl->family, "Colours"))
{
default_name = "Default";
} else {
default_name = global_options_system_theme_is_dark(NULL) ?
"Nocturne" : "GTK";
g_debug("Getting colour scheme for configlet: key %s, default %s",
optkey, default_name);
}
return options_lookup_string_with_default(cl->cg->capp.options, optkey,
strcmp(cl->family, "Colours") ? "Default" : "GTK");
strcmp(cl->family, "Colours") ? "Default" : default_name);
}

static void configlet_list_build(ConfigletList *cl)
Expand Down
26 changes: 22 additions & 4 deletions src/optsfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ char *options_file_lookup_string_with_default(
char *result;
const char *alt_key = NULL;

if (!strcmp(group_name, "Global") ||
g_str_has_prefix(group_name, "Profile"))
if (!strcmp(group_name, "roxterm options") ||
!strcmp(group_name, "roxterm profile"))
{
if (!strcmp(key, "colour_scheme"))
{
Expand All @@ -381,6 +381,7 @@ char *options_file_lookup_string_with_default(
"colour_scheme_dark" : "colour_scheme_light";
default_value = global_options_system_theme_is_dark(NULL) ?
"Nocturne" : "GTK";
g_debug("Looking up %s/%s instead of %s", group_name, alt_key, key);
}
else if (g_str_has_prefix(key, "colour_scheme_"))
{
Expand All @@ -389,16 +390,33 @@ char *options_file_lookup_string_with_default(
*/
alt_key = key;
key = "colour_scheme";
g_debug("Looking up %s/%s with fallback %s",
group_name, alt_key, key);
}
}

if (alt_key)
{
result = options_file_do_lookup_string(kf, group_name, alt_key);
if (result) return result;
if (result)
{
g_debug("%s/%s is %s", group_name, alt_key, result);
return result;
}
}
result = options_file_do_lookup_string(kf, group_name, key);
if (!result) result = g_strdup(default_value);
if (!result)
{
result = g_strdup(default_value);
if (alt_key)
{
g_debug("%s/%s was null, default %s", group_name, key, result);
}
}
else if (alt_key)
{
g_debug("%s/%s fallback is %s", group_name, key, result);
}

return result;
}
Expand Down
6 changes: 6 additions & 0 deletions src/roxterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4464,6 +4464,7 @@ static void on_dark_theme_pref_changed(GSettings *gsettings,
return;
}
gboolean prefer_dark = global_options_system_theme_is_dark(gsettings);
g_debug("System theme changed to %s", prefer_dark ? "dark" : "light");
const char *pref_key = prefer_dark ?
"colour_scheme_dark" : "colour_scheme_light";
GList *link;
Expand All @@ -4475,6 +4476,11 @@ static void on_dark_theme_pref_changed(GSettings *gsettings,
if (!theme)
{
theme = global_options_lookup_string(pref_key);
g_debug("Applying global theme: %s", theme);
}
else
{
g_debug("Applying theme from profile: %s", theme);
}
if (theme)
{
Expand Down

0 comments on commit f115e45

Please sign in to comment.