diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2006-01-07 13:12:58 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2006-01-07 13:12:58 +0000 |
commit | 5f160daacbd3300bf83ca81d3985096da850602d (patch) | |
tree | 75d13c57dd5df3e553b8e1fd6654168e52cc1e2f /riscos/theme.c | |
parent | 07d4f5c57bdefaa2dd7c7813bf9ed5821dfe22bc (diff) | |
download | netsurf-5f160daacbd3300bf83ca81d3985096da850602d.tar.gz netsurf-5f160daacbd3300bf83ca81d3985096da850602d.tar.bz2 |
[project @ 2006-01-07 13:12:58 by jmb]
Fix duplication of currently selected theme in theme_descriptor list
svn path=/import/netsurf/; revision=2012
Diffstat (limited to 'riscos/theme.c')
-rw-r--r-- | riscos/theme.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/riscos/theme.c b/riscos/theme.c index a215c7db4..4495316ae 100644 --- a/riscos/theme.c +++ b/riscos/theme.c @@ -176,13 +176,18 @@ struct theme_descriptor *ro_gui_theme_get_available(void) { struct theme_descriptor *test; char pathname[256]; - /* close any descriptors we've got so far */ + /* close any descriptors we've got so far + * _except_ the current theme */ ro_gui_theme_free(theme_descriptors); - - /* add our default 'Aletheia' theme */ - snprintf(pathname, 256, "%s.Resources", NETSURF_DIR); - pathname[255] = '\0'; - ro_gui_theme_add_descriptor(pathname, "Aletheia"); + + assert(theme_descriptors == theme_current); + + if (strcmp(theme_current->name, "Aletheia") != 0) { + /* add our default 'Aletheia' theme */ + snprintf(pathname, 256, "%s.Resources", NETSURF_DIR); + pathname[255] = '\0'; + ro_gui_theme_add_descriptor(pathname, "Aletheia"); + } /* scan our choices directory */ snprintf(pathname, 256, "%s%s", THEME_PATH_R, THEME_LEAFNAME); @@ -212,6 +217,7 @@ struct theme_descriptor *ro_gui_theme_get_available(void) { while (theme_descriptors->previous) theme_descriptors = theme_descriptors->previous; } + return theme_descriptors; } @@ -262,7 +268,7 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) { os_fw file_handle; os_error *error; char *filename; - + /* create a full filename */ filename = malloc(strlen(folder) + strlen(leafname) + 2); if (!filename) { @@ -320,6 +326,13 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) { current->filename = filename; current->leafname = current->filename + strlen(folder) + 1; + if (strcmp(current->name, theme_current->name) == 0) { + /* Don't add if this theme matches the current one */ + free(current->filename); + free(current); + return false; + } + /* link in our new descriptor at the head*/ if (theme_descriptors) { current->next = theme_descriptors; @@ -327,7 +340,7 @@ bool ro_gui_theme_add_descriptor(const char *folder, const char *leafname) { } theme_descriptors = current; return true; - + } @@ -504,7 +517,7 @@ bool ro_gui_theme_open(struct theme_descriptor *descriptor, bool list) { } if (strncmp(sprite_name, "throbber", 8)) continue; - + /* get the max sprite width/height */ error = xosspriteop_read_sprite_info( osspriteop_USER_AREA, @@ -1206,7 +1219,7 @@ bool ro_gui_theme_attach_toolbar(struct toolbar *toolbar, wimp_w parent) { } return true; } - + error = xwimp_close_window(toolbar->toolbar_handle); if (error) { LOG(("xwimp_close_window: 0x%x: %s", |