17#ifdef FREECIV_HAVE_DIRENT_H
45 static GtkCssProvider *fc_css_provider = NULL;
47 char buf[strlen(
directory) + strlen(theme_name) + 32];
49 if (fc_css_provider == NULL) {
50 fc_css_provider = gtk_css_provider_new();
51 gtk_style_context_add_provider(gtk_widget_get_style_context(
toplevel),
52 GTK_STYLE_PROVIDER(fc_css_provider),
53 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
60 gtk_css_provider_load_from_path(fc_css_provider, buf, &error);
63 g_warning(
"%s\n", error->message);
66 gtk_style_context_invalidate(gtk_widget_get_style_context(
toplevel));
89 static GtkCssProvider *default_provider = NULL;
91 if (default_provider == NULL) {
92 default_provider = gtk_css_provider_new();
94 gtk_style_context_add_provider_for_screen(
96 GTK_STYLE_PROVIDER(default_provider),
97 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
121 char buf[strlen(dir_name) + strlen(
"/themes/gtk3") + 1];
123 fc_snprintf(buf,
sizeof(buf),
"%s/themes/gtk3", dir_name);
130 standard_dir =
"../share/themes";
132 standard_dir =
"/usr/share/themes";
139 char buf[strlen(home_dir) + 16];
141 fc_snprintf(buf,
sizeof(buf),
"%s/.themes/", home_dir);
157 struct dirent *
entry;
158 char **theme_names =
fc_malloc(
sizeof(
char *) * 2);
171 while ((
entry = readdir(dir))) {
173 struct stat stat_result;
178 if (
fc_stat(buf, &stat_result) != 0) {
183 if (!S_ISREG(stat_result.st_mode)) {
191 if (*count == t_size) {
192 theme_names =
fc_realloc(theme_names, t_size * 2 *
sizeof(
char *));
DIR * fc_opendir(const char *dir_to_open)
#define GUI_GTK_DEFAULT_THEME_NAME
#define GUI_GTK_OPTION(optname)
char ** get_gui_specific_themes_directories(int *count)
void gui_clear_theme(void)
void gui_load_theme(const char *directory, const char *theme_name)
#define fc_realloc(ptr, sz)
char * user_home_dir(void)
const struct strvec * get_data_dirs(void)
size_t strvec_size(const struct strvec *psv)
#define strvec_iterate(psv, str)
#define strvec_iterate_end
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_stat(const char *filename, struct stat *buf)
#define sz_strlcpy(dest, src)
struct theme_directory * directories
get_usable_themes_in_directory