Add function to add to global history. Fix add_entry to actually add new entry after removing an existing one. Implement directory deletion.

This commit is contained in:
Michael Drake 2013-07-16 13:13:33 +01:00
parent 28a04f6da7
commit 07c2add5cc
2 changed files with 45 additions and 5 deletions

View File

@ -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:
@ -781,6 +793,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)

View File

@ -22,6 +22,7 @@
#include <stdbool.h>
#include "desktop/core_window.h"
#include "utils/nsurl.h"
/**
@ -50,6 +51,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.
*