Author: tlsa
Date: Thu Sep 23 10:06:58 2010
New Revision: 10825
URL:
http://source.netsurf-browser.org?rev=10825&view=rev
Log:
Fix tree icon loading to handle path in native platform format.
Modified:
branches/jmb/treeview-redux/desktop/tree.c
branches/jmb/treeview-redux/riscos/gui.c
Modified: branches/jmb/treeview-redux/desktop/tree.c
URL:
http://source.netsurf-browser.org/branches/jmb/treeview-redux/desktop/tre...
==============================================================================
--- branches/jmb/treeview-redux/desktop/tree.c (original)
+++ branches/jmb/treeview-redux/desktop/tree.c Thu Sep 23 10:06:58 2010
@@ -38,6 +38,7 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
+#include "utils/url.h"
typedef enum {
TREE_NO_DRAG = 0,
@@ -2522,38 +2523,49 @@
*/
hlcache_handle *tree_load_icon(const char *name)
{
- char *buffer = NULL;
- const char *icon_path;
+ char *url = NULL;
+ const char *icon_url = NULL;
int len;
hlcache_handle *c;
/* TODO: something like bitmap_from_disc is needed here */
if (!strncmp(name, "file://", 7)) {
- icon_path = name;
+ icon_url = name;
} else {
+ char *native_path;
+
if (option_tree_icons_dir == NULL)
return NULL;
- len = SLEN("file://") + strlen(option_tree_icons_dir) +
- strlen(name) + 1;
- buffer = malloc(len * sizeof(char));
- if (buffer == NULL) {
+ /* path + separator + leafname + '\0' */
+ len = strlen(option_tree_icons_dir) + 1 + strlen(name) + 1;
+ native_path = malloc(len);
+ if (native_path == NULL) {
LOG(("malloc failed"));
warn_user("NoMemory", 0);
return NULL;
}
- sprintf(buffer, "%s%s%s", "file://", option_tree_icons_dir,
- name);
- icon_path = buffer;
- }
-
- hlcache_handle_retrieve(icon_path, 0, 0, 0,
+ /* Build native path */
+ memcpy(native_path, option_tree_icons_dir,
+ strlen(option_tree_icons_dir) + 1);
+ path_add_part(native_path, len, name);
+
+ /* Convert native path to URL */
+ url = path_to_url(native_path);
+
+ free(native_path);
+ icon_url = url;
+ }
+
+ /* Fetch the icon */
+ hlcache_handle_retrieve(icon_url, 0, 0, 0,
tree_icon_callback, 0, 0, 0, &c);
- if (buffer != NULL)
- free(buffer);
+ /* If we built the URL here, free it */
+ if (url != NULL)
+ free(url);
return c;
}
Modified: branches/jmb/treeview-redux/riscos/gui.c
URL:
http://source.netsurf-browser.org/branches/jmb/treeview-redux/riscos/gui....
==============================================================================
--- branches/jmb/treeview-redux/riscos/gui.c (original)
+++ branches/jmb/treeview-redux/riscos/gui.c Thu Sep 23 10:06:58 2010
@@ -355,7 +355,7 @@
if (!option_theme_save)
option_theme_save = strdup(CHOICES_PREFIX "Themes");
if (!option_tree_icons_dir)
- option_tree_icons_dir = strdup("NetSurf:/Resources/Icons/");
+ option_tree_icons_dir = strdup("NetSurf:Resources.Icons");
if (!option_theme || ! option_toolbar_browser ||
!option_toolbar_hotlist || !option_toolbar_history ||