diff options
author | Timo Sirainen <cras@irssi.org> | 2001-01-11 09:14:21 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-01-11 09:14:21 +0000 |
commit | 091e06387b18bbb976bccc23fb5c898eca7bc97c (patch) | |
tree | 7d3f130fa7220263865661fea347fc7e9cd292ac /src | |
parent | ebdaa110f1e7dd48483d0f0ebc606c13b2e44ba3 (diff) | |
download | irssi-091e06387b18bbb976bccc23fb5c898eca7bc97c.zip |
/SET theme - complains if theme isn't found. Setting theme's name to
"xxx.theme" now works, too many people tried it with the .theme suffix :)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1102 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/core/themes.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c index 64632849..deb71b11 100644 --- a/src/fe-common/core/themes.c +++ b/src/fe-common/core/themes.c @@ -617,14 +617,24 @@ static THEME_REC *theme_find(const char *name) return NULL; } -THEME_REC *theme_load(const char *name) +THEME_REC *theme_load(const char *setname) { THEME_REC *theme; struct stat statbuf; - char *fname; + char *fname, *name, *p; + + name = g_strdup(setname); + p = strrchr(name, '.'); + if (p != NULL && strcmp(p, ".theme") == 0) { + /* remove the trailing .theme */ + *p = '\0'; + } theme = theme_find(name); - if (theme != NULL) return theme; + if (theme != NULL) { + g_free(name); + return theme; + } /* check home dir */ fname = g_strdup_printf("%s/.irssi/%s.theme", g_get_home_dir(), name); @@ -635,6 +645,7 @@ THEME_REC *theme_load(const char *name) if (stat(fname, &statbuf) != 0) { /* theme not found */ g_free(fname); + g_free(name); return NULL; } } @@ -643,6 +654,7 @@ THEME_REC *theme_load(const char *name) theme_read(theme, theme->path, NULL); g_free(fname); + g_free(name); return theme; } @@ -999,7 +1011,12 @@ static void read_settings(void) theme = settings_get_str("theme"); if (strcmp(current_theme->name, theme) != 0) { rec = theme_load(theme); - if (rec != NULL) current_theme = rec; + if (rec != NULL) + current_theme = rec; + else { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + TXT_THEME_NOT_FOUND, theme); + } } } |