summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-07-16 13:13:33 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-07-16 13:13:33 +0100
commit07c2add5cc28efa18f7bcaae239879a3bc12a700 (patch)
tree9d84bed9a2d322db30de3a443ea21ea43dad9b45
parent28a04f6da778afe03bc2639c0ecce947b5f36b7f (diff)
downloadnetsurf-07c2add5cc28efa18f7bcaae239879a3bc12a700.tar.gz
netsurf-07c2add5cc28efa18f7bcaae239879a3bc12a700.tar.bz2
Add function to add to global history. Fix add_entry to actually add new entry after removing an existing one. Implement directory deletion.
-rw-r--r--desktop/global_history.c39
-rw-r--r--desktop/global_history.h11
2 files changed, 45 insertions, 5 deletions
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 573bf84b8..05822d741 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -462,7 +462,6 @@ static bool global_history_add_entry(nsurl *url,
const struct url_data *data)
{
int slot;
- struct global_history_entry *e;
time_t visit_date;
time_t earliest_date = gh_ctx.today - (N_DAYS - 1) * N_SEC_PER_DAY;
bool got_treeview = gh_ctx.tree != NULL;
@@ -483,13 +482,12 @@ static bool global_history_add_entry(nsurl *url,
if (got_treeview == true) {
/* The treeview for global history already exists */
+ struct global_history_entry *e;
- /* See if there's already an entry for this URL */
+ /* Delete any existing entry for this URL */
e = global_history_find(url);
if (e != NULL) {
- /* Existing entry. */
treeview_delete_node(gh_ctx.tree, e->entry);
- return true;
}
}
@@ -643,12 +641,26 @@ static nserror global_history_init_entries(void)
static nserror global_history_tree_node_folder_cb(
struct treeview_node_msg msg, void *data)
{
+ struct global_history_folder *f = data;
+
+ switch (msg.msg) {
+ case TREE_MSG_NODE_DELETE:
+ f->folder = NULL;
+ break;
+
+ case TREE_MSG_NODE_EDIT:
+ break;
+
+ case TREE_MSG_NODE_LAUNCH:
+ break;
+ }
+
return NSERROR_OK;
}
static nserror global_history_tree_node_entry_cb(
struct treeview_node_msg msg, void *data)
{
- struct global_history_entry *e = (struct global_history_entry *)data;
+ struct global_history_entry *e = data;
switch (msg.msg) {
case TREE_MSG_NODE_DELETE:
@@ -782,6 +794,23 @@ nserror global_history_fini(void)
/* Exported interface, documented in global_history.h */
+nserror global_history_add(nsurl *url)
+{
+ const struct url_data *data;
+
+ data = urldb_get_url_data(url);
+ if (data == NULL) {
+ LOG(("Can't add URL to history that's not present in urldb."));
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ global_history_add_entry(url, data);
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in global_history.h */
void global_history_redraw(int x, int y, struct rect *clip,
const struct redraw_context *ctx)
{
diff --git a/desktop/global_history.h b/desktop/global_history.h
index 591b1fe6f..3863e8151 100644
--- a/desktop/global_history.h
+++ b/desktop/global_history.h
@@ -22,6 +22,7 @@
#include <stdbool.h>
#include "desktop/core_window.h"
+#include "utils/nsurl.h"
/**
@@ -51,6 +52,16 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
nserror global_history_fini(void);
/**
+ * Add an entry to the global history.
+ *
+ * If the URL already exists in the global history, the old node is removed.
+ *
+ * \param url URL for node being added
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror global_history_add(nsurl *url);
+
+/**
* Redraw the global history.
*
* \param x X coordinate to render treeview at