Skip to content

Commit

Permalink
add basic theming for macOS + GTK3
Browse files Browse the repository at this point in the history
  • Loading branch information
AllinCottrell committed Dec 20, 2024
1 parent 01832c6 commit 6409b0b
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions gui/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,12 +1467,21 @@ static const char **get_list_setting_strings (void *var, int *n)
}
#endif

#if defined(MAC_THEMING)
#if defined(MAC_THEMING) && GTK_MAJOR_VERSION < 3
else if (var == themepref) {
static const char *theme_strs[] = {
"Adwaita", "Adwaita-dark", "Clearlooks", "Raleigh"
};

strs = theme_strs;
*n = sizeof theme_strs / sizeof theme_strs[0];
}
#elif defined(MAC_THEMING) && GTK_MAJOR_VERSION == 3
else if (var == themepref) {
static const char *theme_strs[] = {
"Adwaita", "Adwaita-dark"
};

strs = theme_strs;
*n = sizeof theme_strs / sizeof theme_strs[0];
}
Expand Down Expand Up @@ -3505,12 +3514,12 @@ void workdir_dialog1 (void)

#endif /* not GRETL_EDIT */

#if defined(MAC_THEMING)
#if defined(MAC_THEMING) && GTK_MAJOR_VERSION < 3

void set_up_mac_look (void)
{
if (!strcmp(themepref, "Lion-like")) {
/* 2024-12-19: fallback for broken theme */
/* 2024-12-19: fallback for broken GTK2 theme */
strcpy(themepref, "Adwaita");
}

Expand Down Expand Up @@ -3542,6 +3551,18 @@ void set_up_mac_look (void)
}
}

#elif defined(MAC_THEMING) && GTK_MAJOR_VERSION == 3

void set_up_mac_look (void)
{
GtkSettings *settings = gtk_settings_get_default();

if (strstr(themepref, "dark") != NULL) {
g_object_set(G_OBJECT(settings), "gtk-application-prefer-dark-theme",
TRUE, NULL);
}
}

#elif defined (G_OS_WIN32) && GTK_MAJOR_VERSION < 3

void set_up_windows_look (void)
Expand Down

0 comments on commit 6409b0b

Please sign in to comment.