[project @ 2005-12-31 04:36:24 by rjw]

Read data from url_store, use new wimp_event system.

svn path=/import/netsurf/; revision=1913
This commit is contained in:
Richard Wilson 2005-12-31 04:36:24 +00:00
parent 28f51bfcf5
commit 442f0e2a2c
3 changed files with 203 additions and 276 deletions

View File

@ -24,6 +24,7 @@
#include "netsurf/riscos/menus.h" #include "netsurf/riscos/menus.h"
#include "netsurf/riscos/theme.h" #include "netsurf/riscos/theme.h"
#include "netsurf/riscos/treeview.h" #include "netsurf/riscos/treeview.h"
#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/messages.h" #include "netsurf/utils/messages.h"
#include "netsurf/utils/log.h" #include "netsurf/utils/log.h"
#include "netsurf/utils/url.h" #include "netsurf/utils/url.h"
@ -34,8 +35,6 @@
#define GLOBAL_HISTORY_RECENT_READ "Choices:WWW.NetSurf.Recent" #define GLOBAL_HISTORY_RECENT_READ "Choices:WWW.NetSurf.Recent"
#define GLOBAL_HISTORY_RECENT_WRITE "<Choices$Write>.WWW.NetSurf.Recent" #define GLOBAL_HISTORY_RECENT_WRITE "<Choices$Write>.WWW.NetSurf.Recent"
#define GLOBAL_HISTORY_READ "Choices:WWW.NetSurf.History"
#define GLOBAL_HISTORY_WRITE "<Choices$Write>.WWW.NetSurf.History"
static struct node *global_history_base_node[MAXIMUM_BASE_NODES]; static struct node *global_history_base_node[MAXIMUM_BASE_NODES];
@ -47,13 +46,11 @@ static int global_history_recent_count = 0;
static bool global_history_init; static bool global_history_init;
static bool ro_gui_global_history_click(wimp_pointer *pointer);
static void ro_gui_global_history_initialise_nodes(void); static void ro_gui_global_history_initialise_nodes(void);
static void ro_gui_global_history_initialise_node(const char *title, static void ro_gui_global_history_initialise_node(const char *title,
time_t base, int days_back); time_t base, int days_back);
static void ro_gui_global_history_add(char *title, char *url, int visit_date, struct node *ro_gui_global_history_find(const char *url);
int filetype);
static void ro_gui_global_history_save_node(struct node *node, FILE *fp);
/* A basic window for the history /* A basic window for the history
*/ */
@ -98,10 +95,11 @@ void ro_gui_global_history_initialise(void) {
FILE *fp; FILE *fp;
const char *title; const char *title;
os_error *error; os_error *error;
char *node_title; struct hostname_data *hostname;
char *node_url; struct url_data *url;
int node_filetype; int url_count = 0;
int node_visited; struct url_content **url_block;
int i = 0;
/* Create our window /* Create our window
*/ */
@ -119,6 +117,12 @@ void ro_gui_global_history_initialise(void) {
error->errnum, error->errmess)); error->errnum, error->errmess));
die(error->errmess); die(error->errmess);
} }
ro_gui_wimp_event_register_redraw_window(global_history_window,
ro_gui_tree_redraw);
ro_gui_wimp_event_register_open_window(global_history_window,
ro_gui_tree_open);
ro_gui_wimp_event_register_mouse_click(global_history_window,
ro_gui_global_history_click);
/* Create an empty tree /* Create an empty tree
*/ */
@ -138,6 +142,10 @@ void ro_gui_global_history_initialise(void) {
tree_initialise(global_history_tree); tree_initialise(global_history_tree);
global_history_tree->handle = (int)global_history_window; global_history_tree->handle = (int)global_history_window;
global_history_tree->movable = false; global_history_tree->movable = false;
ro_gui_wimp_event_set_user_data(global_history_window,
global_history_tree);
ro_gui_wimp_event_register_keypress(global_history_window,
ro_gui_tree_keypress);
/* Create our toolbar /* Create our toolbar
*/ */
@ -161,60 +169,40 @@ void ro_gui_global_history_initialise(void) {
fclose(fp); fclose(fp);
} }
/* load global history */ /* count the number of URLs to add */
fp = fopen(GLOBAL_HISTORY_READ, "r"); for (hostname = url_store_hostnames; hostname;
if (!fp) hostname = hostname->next)
LOG(("Failed to open file '%s' for reading", for (url = hostname->url; url; url = url->next)
GLOBAL_HISTORY_READ)); url_count++;
else { if (url_count == 0)
global_history_init = true;
while (fgets(s, MAXIMUM_URL_LENGTH, fp)) {
if (s[strlen(s) - 1] == '\n')
s[strlen(s) - 1] = '\0';
node_title = strdup(s);
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) {
LOG(("Error reading global history"));
warn_user("HistoryCorrupt", 0);
fclose(fp);
global_history_init = false;
return; return;
}
if (s[strlen(s) - 1] == '\n') /* place pointers to the URL data in a single block of memory so
s[strlen(s) - 1] = '\0'; * they can be quickly sorted */
node_url = strdup(s); url_block = (struct url_content **)malloc(
if ((!node_title) || (!node_url)) { url_count * sizeof(struct url_content *));
LOG(("No memory to read global history node")); if (!url_block) {
warn_user("NoMemory", 0); warn_user("NoMemory", 0);
fclose(fp); LOG(("Insufficient memory for malloc()"));
global_history_init = false;
return; return;
} }
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) { for (hostname = url_store_hostnames; hostname;
LOG(("Error reading global history")); hostname = hostname->next)
warn_user("HistoryCorrupt", 0); for (url = hostname->url; url; url = url->next)
fclose(fp); url_block[i++] = &url->data;
assert(i == url_count);
/* sort information by the last_visit information */
qsort(url_block, url_count, sizeof(struct url_content *),
url_store_compare_last_visit);
/* add URLs to the global history */
global_history_init = true;
for (i = 0; i < url_count; i++)
global_history_add(url_block[i]);
global_history_init = false; global_history_init = false;
return; free(url_block);
}
node_filetype = atoi(s);
if (!fgets(s, MAXIMUM_URL_LENGTH, fp)) {
LOG(("Error reading global history"));
warn_user("HistoryCorrupt", 0);
fclose(fp);
global_history_init = false;
return;
}
node_visited = atoi(s);
ro_gui_global_history_add(node_title, node_url,
node_visited, node_filetype);
free(node_title);
node_title = NULL;
free(node_url);
node_url = NULL;
}
global_history_init = false;
fclose(fp);
}
} }
@ -283,7 +271,7 @@ static void ro_gui_global_history_initialise_node(const char *title,
/** /**
* Saves the global history and recent URL data. * Saves the global history's recent URL data.
*/ */
void ro_gui_global_history_save(void) { void ro_gui_global_history_save(void) {
FILE *fp; FILE *fp;
@ -302,44 +290,6 @@ void ro_gui_global_history_save(void) {
global_history_recent_url[i]); global_history_recent_url[i]);
fclose(fp); fclose(fp);
} }
/* save global history tree */
fp = fopen(GLOBAL_HISTORY_WRITE, "w");
if (!fp)
LOG(("Failed to open file '%s' for writing",
GLOBAL_HISTORY_WRITE));
else {
ro_gui_global_history_save_node(global_history_tree->root, fp);
fclose(fp);
}
}
/**
* Saves the global history for a tree node.
*/
void ro_gui_global_history_save_node(struct node *node, FILE *fp) {
struct node_element *element;
for (; node; node = node->next) {
if (node->folder) {
ro_gui_global_history_save_node(node->child, fp);
} else {
element = tree_find_element(node, TREE_ELEMENT_URL);
if (element) {
fprintf(fp, "%s\n%s\n%i\n", node->data.text,
element->text,
element->user_data);
element = tree_find_element(node,
TREE_ELEMENT_VISITED);
if (element)
fprintf(fp, "%i\n", element->user_data);
else
fprintf(fp, "-1\n");
}
}
}
} }
@ -348,13 +298,14 @@ void ro_gui_global_history_save_node(struct node *node, FILE *fp) {
* *
* \param pointer the pointer state * \param pointer the pointer state
*/ */
void ro_gui_global_history_click(wimp_pointer *pointer) { bool ro_gui_global_history_click(wimp_pointer *pointer) {
ro_gui_tree_click(pointer, global_history_tree); ro_gui_tree_click(pointer, global_history_tree);
if (pointer->buttons == wimp_CLICK_MENU) if (pointer->buttons == wimp_CLICK_MENU)
ro_gui_menu_create(global_history_menu, pointer->pos.x, ro_gui_menu_create(global_history_menu, pointer->pos.x,
pointer->pos.y, pointer->w); pointer->pos.y, pointer->w);
else else
ro_gui_menu_prepare_action(pointer->w, TREE_SELECTION, false); ro_gui_menu_prepare_action(pointer->w, TREE_SELECTION, false);
return true;
} }
@ -372,46 +323,20 @@ int ro_gui_global_history_help(int x, int y) {
/** /**
* Adds to the global history * Adds to the global history
*
* \param g the gui_window to add to the global history
*/ */
void global_history_add(struct gui_window *g) { void global_history_add(struct url_content *data) {
url_func_result res;
char *norm_url = NULL;
assert(g);
if ((!g->bw->current_content) || (!global_history_tree))
return;
res = url_normalize(g->bw->current_content->url, &norm_url);
if (res != URL_FUNC_OK) {
warn_user("NoMemory", 0);
return;
}
ro_gui_global_history_add(g->bw->current_content->title,
norm_url, time(NULL),
ro_content_filetype(g->bw->current_content));
free(norm_url);
}
/**
* Adds to the global history
*
* \param title the page title
* \param url the page URL
* \param visit_date the visit date
*/
void ro_gui_global_history_add(char *title, char *url, int visit_date,
int filetype) {
int i, j; int i, j;
struct node *parent = NULL; struct node *parent = NULL;
struct node *link; struct node *link;
struct node *node; struct node *node;
struct node_element *element;
bool before = false; bool before = false;
int visit_date;
int filetype;
assert(data);
visit_date = data->last_visit;
filetype = ro_content_filetype_from_type(data->type);
/* Find/create the node to link into /* Find/create the node to link into
*/ */
@ -439,10 +364,28 @@ void ro_gui_global_history_add(char *title, char *url, int visit_date,
} }
if (parent) { if (parent) {
/* find any previous occurance */
if (!global_history_init) {
node = ro_gui_global_history_find(data->url);
if (node) {
/* \todo: calculate old/new positions and redraw
* only the relevant portion */
tree_redraw_area(global_history_tree,
0, 0, 16384, 16384);
tree_update_URL_node(node);
tree_delink_node(node);
tree_link_node(parent, node, false);
tree_handle_node_changed(global_history_tree,
node, false, true);
/* ro_gui_tree_scroll_visible(hotlist_tree,
&node->data);
*/ return;
}
}
/* Add the node at the bottom /* Add the node at the bottom
*/ */
node = tree_create_URL_node_brief(parent, title, url, filetype, node = tree_create_URL_node_shared(parent, data);
visit_date);
if (node && !global_history_init) if (node && !global_history_init)
tree_redraw_area(global_history_tree, tree_redraw_area(global_history_tree,
node->box.x - NODE_INSTEP, node->box.x - NODE_INSTEP,
@ -451,21 +394,27 @@ void ro_gui_global_history_add(char *title, char *url, int visit_date,
tree_handle_node_changed(global_history_tree, node, tree_handle_node_changed(global_history_tree, node,
true, false); true, false);
/* Remove any duplicate URL from within the parent node. }
* This must be done after the duplicate has been created as }
* deleting all children of a child automatically collapses
* the display.
*/ struct node *ro_gui_global_history_find(const char *url) {
for (node = parent->child; node && (node->next); int i;
node = node->next) { struct node *node;
element = tree_find_element(node, TREE_ELEMENT_URL); struct node_element *element;
if ((element) && (!strcmp(url, element->text))) {
tree_delete_node(global_history_tree, node, for (i = 0; i < global_history_base_node_count; i++) {
false); if (!global_history_base_node[i]->deleted) {
break; for (node = global_history_base_node[i]->child;
node; node = node->next) {
element = tree_find_element(node,
TREE_ELEMENT_URL);
if ((element) && (url == element->text))
return node;
} }
} }
} }
return NULL;
} }

View File

@ -12,19 +12,13 @@
#ifndef _NETSURF_RISCOS_GLOBALHISTORY_H_ #ifndef _NETSURF_RISCOS_GLOBALHISTORY_H_
#define _NETSURF_RISCOS_GLOBALHISTORY_H_ #define _NETSURF_RISCOS_GLOBALHISTORY_H_
#include <stdbool.h>
#include "oslib/wimp.h"
#include "netsurf/content/url_store.h" #include "netsurf/content/url_store.h"
#include "netsurf/desktop/browser.h"
#define GLOBAL_HISTORY_RECENT_URLS 16 #define GLOBAL_HISTORY_RECENT_URLS 16
void ro_gui_global_history_initialise(void); void ro_gui_global_history_initialise(void);
void ro_gui_global_history_save(void);
void ro_gui_global_history_click(wimp_pointer *pointer);
void ro_gui_global_history_dialog_click(wimp_pointer *pointer);
void ro_gui_global_history_menu_closed(void);
int ro_gui_global_history_help(int x, int y); int ro_gui_global_history_help(int x, int y);
void ro_gui_global_history_save(void);
#endif #endif

View File

@ -30,6 +30,7 @@
#include "netsurf/riscos/tinct.h" #include "netsurf/riscos/tinct.h"
#include "netsurf/riscos/treeview.h" #include "netsurf/riscos/treeview.h"
#include "netsurf/riscos/wimp.h" #include "netsurf/riscos/wimp.h"
#include "netsurf/riscos/wimp_event.h"
#include "netsurf/utils/log.h" #include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h" #include "netsurf/utils/messages.h"
#include "netsurf/utils/utils.h" #include "netsurf/utils/utils.h"
@ -38,6 +39,7 @@
static void ro_gui_hotlist_visited(struct content *content, struct tree *tree, static void ro_gui_hotlist_visited(struct content *content, struct tree *tree,
struct node *node); struct node *node);
static bool ro_gui_hotlist_click(wimp_pointer *pointer);
/* A basic window for the hotlist /* A basic window for the hotlist
*/ */
@ -89,6 +91,7 @@ void ro_gui_hotlist_initialise(void) {
const char *title; const char *title;
os_error *error; os_error *error;
struct node *node; struct node *node;
struct url_content *data;
/* Create our window /* Create our window
*/ */
@ -106,6 +109,12 @@ void ro_gui_hotlist_initialise(void) {
error->errnum, error->errmess)); error->errnum, error->errmess));
die(error->errmess); die(error->errmess);
} }
ro_gui_wimp_event_register_redraw_window(hotlist_window,
ro_gui_tree_redraw);
ro_gui_wimp_event_register_open_window(hotlist_window,
ro_gui_tree_open);
ro_gui_wimp_event_register_mouse_click(hotlist_window,
ro_gui_hotlist_click);
/* Either load or create a hotlist /* Either load or create a hotlist
*/ */
@ -126,9 +135,11 @@ void ro_gui_hotlist_initialise(void) {
node = tree_create_folder_node(hotlist_tree->root, "NetSurf"); node = tree_create_folder_node(hotlist_tree->root, "NetSurf");
if (!node) if (!node)
node = hotlist_tree->root; node = hotlist_tree->root;
tree_create_URL_node(node, messages_get("HotlistHomepage"), data = url_store_find("http://netsurf.sourceforge.net/");
"http://netsurf.sourceforge.net/", 0xfaf, if (data) {
time(NULL), -1, 0); tree_create_URL_node(node, data,
messages_get("HotlistHomepage"));
}
tree_initialise(hotlist_tree); tree_initialise(hotlist_tree);
} else { } else {
fclose(fp); fclose(fp);
@ -137,6 +148,9 @@ void ro_gui_hotlist_initialise(void) {
if (!hotlist_tree) return; if (!hotlist_tree) return;
hotlist_tree->handle = (int)hotlist_window; hotlist_tree->handle = (int)hotlist_window;
hotlist_tree->movable = true; hotlist_tree->movable = true;
ro_gui_wimp_event_set_user_data(hotlist_window, hotlist_tree);
ro_gui_wimp_event_register_keypress(hotlist_window,
ro_gui_tree_keypress);
/* Create our toolbar /* Create our toolbar
*/ */
@ -172,13 +186,14 @@ void ro_gui_hotlist_save(void) {
* *
* \param pointer the pointer state * \param pointer the pointer state
*/ */
void ro_gui_hotlist_click(wimp_pointer *pointer) { bool ro_gui_hotlist_click(wimp_pointer *pointer) {
ro_gui_tree_click(pointer, hotlist_tree); ro_gui_tree_click(pointer, hotlist_tree);
if (pointer->buttons == wimp_CLICK_MENU) if (pointer->buttons == wimp_CLICK_MENU)
ro_gui_menu_create(hotlist_menu, pointer->pos.x, ro_gui_menu_create(hotlist_menu, pointer->pos.x,
pointer->pos.y, pointer->w); pointer->pos.y, pointer->w);
else else
ro_gui_menu_prepare_action(pointer->w, TREE_SELECTION, false); ro_gui_menu_prepare_action(pointer->w, TREE_SELECTION, false);
return true;
} }
@ -210,16 +225,6 @@ void ro_gui_hotlist_visited(struct content *content, struct tree *tree,
element = tree_find_element(node, TREE_ELEMENT_URL); element = tree_find_element(node, TREE_ELEMENT_URL);
if ((element) && (!strcmp(element->text, if ((element) && (!strcmp(element->text,
content->url))) { content->url))) {
element->user_data =
ro_content_filetype(content);
element = tree_find_element(node,
TREE_ELEMENT_VISITS);
if (element)
element->user_data += 1;
element = tree_find_element(node,
TREE_ELEMENT_LAST_VISIT);
if (element)
element->user_data = time(NULL);
tree_update_URL_node(node); tree_update_URL_node(node);
tree_handle_node_changed(tree, node, true, tree_handle_node_changed(tree, node, true,
false); false);
@ -237,17 +242,20 @@ void ro_gui_hotlist_visited(struct content *content, struct tree *tree,
* \param node the node to prepare the dialogue for, or NULL * \param node the node to prepare the dialogue for, or NULL
*/ */
void ro_gui_hotlist_prepare_folder_dialog(struct node *node) { void ro_gui_hotlist_prepare_folder_dialog(struct node *node) {
const char *name;
const char *title;
dialog_folder_node = node; dialog_folder_node = node;
if (node) { if (node) {
ro_gui_set_window_title(dialog_folder, title = messages_get("EditFolder");
messages_get("EditFolder")); name = node->data.text;
ro_gui_set_icon_string(dialog_folder, 1, node->data.text);
} else { } else {
ro_gui_set_window_title(dialog_folder, title = messages_get("NewFolder");
messages_get("NewFolder")); name = messages_get("Folder");
ro_gui_set_icon_string(dialog_folder, 1,
messages_get("Folder"));
} }
ro_gui_set_window_title(dialog_folder, title);
ro_gui_set_icon_string(dialog_folder, ICON_FOLDER_NAME, name);
ro_gui_wimp_event_memorise(dialog_folder);
} }
@ -258,135 +266,111 @@ void ro_gui_hotlist_prepare_folder_dialog(struct node *node) {
*/ */
void ro_gui_hotlist_prepare_entry_dialog(struct node *node) { void ro_gui_hotlist_prepare_entry_dialog(struct node *node) {
struct node_element *element; struct node_element *element;
const char *name;
const char *title;
const char *url = "";
dialog_entry_node = node; dialog_entry_node = node;
if (node) { if (node) {
ro_gui_set_window_title(dialog_entry, messages_get("EditLink")); title = messages_get("EditLink");
ro_gui_set_icon_string(dialog_entry, 1, node->data.text); name = node->data.text;
element = tree_find_element(node, TREE_ELEMENT_URL); if ((element = tree_find_element(node, TREE_ELEMENT_URL)))
if (element) url = element->text;
ro_gui_set_icon_string(dialog_entry, 3, element->text);
else
ro_gui_set_icon_string(dialog_entry, 3, "");
} else { } else {
ro_gui_set_window_title(dialog_entry, messages_get("NewLink")); title = messages_get("NewLink");
ro_gui_set_icon_string(dialog_entry, 1, messages_get("Link")); name = messages_get("Link");
ro_gui_set_icon_string(dialog_entry, 3, "");
} }
ro_gui_set_window_title(dialog_entry, title);
ro_gui_set_icon_string(dialog_entry, ICON_ENTRY_NAME, name);
ro_gui_set_icon_string(dialog_entry, ICON_ENTRY_URL, url);
ro_gui_wimp_event_memorise(dialog_entry);
} }
/** /**
* Respond to a mouse click * Apply the settings of dialog window (folder/entry edit)
* *
* \param pointer the pointer state * \param w the window to apply
*/ */
void ro_gui_hotlist_dialog_click(wimp_pointer *pointer) { bool ro_gui_hotlist_dialog_apply(wimp_w w) {
struct node_element *element; struct node_element *element;
struct node *node; struct node *node;
char *title = NULL; char *title;
char *icon;
char *url = NULL; char *url = NULL;
char *old_value; url_func_result res = URL_FUNC_OK;
int icon = pointer->i; struct url_content *data;
int close_icon, ok_icon;
url_func_result res;
if (pointer->w == dialog_entry) { /* get our data */
title = strip(ro_gui_get_icon_string(pointer->w, 1)); if (w == dialog_entry) {
url = strip(ro_gui_get_icon_string(pointer->w, 3)); icon = strip(ro_gui_get_icon_string(w, ICON_ENTRY_URL));
close_icon = 4; if (strlen(icon) == 0) {
ok_icon = 5;
node = dialog_entry_node;
} else {
title = strip(ro_gui_get_icon_string(pointer->w, 1));
close_icon = 2;
ok_icon = 3;
node = dialog_folder_node;
}
if (icon == close_icon) {
if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_dialog_close(pointer->w);
xwimp_create_menu((wimp_menu *)-1, 0, 0);
} else {
if (pointer->w == dialog_folder)
ro_gui_hotlist_prepare_folder_dialog(
dialog_folder_node);
else
ro_gui_hotlist_prepare_entry_dialog(
dialog_entry_node);
}
return;
}
if (icon != ok_icon)
return;
/* Check we have valid values
*/
if ((title != NULL) && (strlen(title) == 0)) {
warn_user("NoNameError", 0);
return;
}
if ((url != NULL) && (strlen(url) == 0)) {
warn_user("NoURLError", 0); warn_user("NoURLError", 0);
return; return false;
} }
res = url_normalize(icon, &url);
/* Update/insert our data title = strip(ro_gui_get_icon_string(w, ICON_ENTRY_NAME));
*/
if (!node) {
if (pointer->w == dialog_folder) {
dialog_folder_node = tree_create_folder_node(
hotlist_tree->root,
title);
node = dialog_folder_node;
} else {
dialog_entry_node = tree_create_URL_node(
hotlist_tree->root,
title, url, 0xfaf, time(NULL), -1, 0);
node = dialog_entry_node; node = dialog_entry_node;
} else {
title = strip(ro_gui_get_icon_string(w, ICON_FOLDER_NAME));
node = dialog_folder_node;
}
title = strdup(title);
/* check for failed functions or lack of text */
if ((title == NULL) || (strlen(title) == 0) || (res != URL_FUNC_OK)) {
free(url);
free(title);
node = NULL;
if ((title == NULL) || (res != URL_FUNC_OK))
warn_user("NoMemory", 0);
else if (strlen(title) == 0)
warn_user("NoNameError", 0);
return false;
}
ro_gui_set_icon_string(w,
(url ? ICON_ENTRY_NAME : ICON_FOLDER_NAME), title);
/* update/insert our data */
if (!node) {
if (url) {
data = url_store_find(url);
if (!data) {
free(url);
free(title);
return false;
}
if (!data->title)
data->title = strdup(title);
node = dialog_entry_node = tree_create_URL_node(
hotlist_tree->root, data, title);
} else {
node = dialog_folder_node = tree_create_folder_node(
hotlist_tree->root, title);
}
free(url);
free(title);
if (!node) {
warn_user("NoMemory", 0);
return false;
} }
tree_handle_node_changed(hotlist_tree, node, true, false); tree_handle_node_changed(hotlist_tree, node, true, false);
ro_gui_tree_scroll_visible(hotlist_tree, &node->data); ro_gui_tree_scroll_visible(hotlist_tree, &node->data);
tree_redraw_area(hotlist_tree, node->box.x - NODE_INSTEP, tree_redraw_area(hotlist_tree, node->box.x - NODE_INSTEP,
0, NODE_INSTEP, 16384); 0, NODE_INSTEP, 16384);
} else { } else {
if (url) {
element = tree_find_element(node, TREE_ELEMENT_URL); element = tree_find_element(node, TREE_ELEMENT_URL);
if (element) { if (element) {
old_value = element->text; free(element->text);
res = url_normalize(url, &element->text); element->text = url;
if (res != URL_FUNC_OK) { ro_gui_set_icon_string(w, ICON_ENTRY_URL, url);
warn_user("NoMemory", 0);
element->text = old_value;
return;
}
free(old_value);
}
}
if (title) {
old_value = node->data.text;
node->data.text = strdup(title);
if (!node->data.text) {
warn_user("NoMemory", 0);
node->data.text = old_value;
return;
}
free(old_value);
} }
free(node->data.text);
node->data.text = title;
tree_handle_node_changed(hotlist_tree, node, true, false); tree_handle_node_changed(hotlist_tree, node, true, false);
} }
return true;
if (pointer->buttons == wimp_CLICK_SELECT) {
ro_gui_dialog_close(pointer->w);
ro_gui_menu_closed();
return;
}
if (pointer->w == dialog_folder)
ro_gui_hotlist_prepare_folder_dialog(dialog_folder_node);
else
ro_gui_hotlist_prepare_entry_dialog(dialog_entry_node);
} }