2005-02-07 17:28:43 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Global history (implementation).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2005-02-09 02:37:41 +03:00
|
|
|
#include <time.h>
|
2005-02-07 17:28:43 +03:00
|
|
|
#include "oslib/wimp.h"
|
|
|
|
#include "oslib/wimpspriteop.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "content/urldb.h"
|
|
|
|
#include "desktop/tree.h"
|
|
|
|
#include "riscos/dialog.h"
|
|
|
|
#include "riscos/global_history.h"
|
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/menus.h"
|
|
|
|
#include "riscos/options.h"
|
|
|
|
#include "riscos/theme.h"
|
|
|
|
#include "riscos/treeview.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/url.h"
|
|
|
|
#include "utils/utils.h"
|
2005-02-07 17:28:43 +03:00
|
|
|
|
|
|
|
#define MAXIMUM_URL_LENGTH 1024
|
2005-02-09 02:37:41 +03:00
|
|
|
#define MAXIMUM_BASE_NODES 16
|
2005-02-07 17:28:43 +03:00
|
|
|
|
2005-02-09 02:37:41 +03:00
|
|
|
static struct node *global_history_base_node[MAXIMUM_BASE_NODES];
|
|
|
|
static int global_history_base_node_time[MAXIMUM_BASE_NODES];
|
|
|
|
static int global_history_base_node_count = 0;
|
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
static char *global_history_recent_url[GLOBAL_HISTORY_RECENT_URLS];
|
|
|
|
static int global_history_recent_count = 0;
|
|
|
|
|
2005-06-23 21:22:28 +04:00
|
|
|
static bool global_history_init;
|
|
|
|
|
2005-12-31 07:36:24 +03:00
|
|
|
static bool ro_gui_global_history_click(wimp_pointer *pointer);
|
2005-02-09 02:37:41 +03:00
|
|
|
static void ro_gui_global_history_initialise_nodes(void);
|
2005-04-08 00:46:22 +04:00
|
|
|
static void ro_gui_global_history_initialise_node(const char *title,
|
|
|
|
time_t base, int days_back);
|
2006-01-06 05:56:00 +03:00
|
|
|
static struct node *ro_gui_global_history_find(const char *url);
|
2006-04-11 06:39:55 +04:00
|
|
|
static bool global_history_add_internal(const char *url,
|
|
|
|
const struct url_data *data);
|
2006-01-06 05:56:00 +03:00
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/* The history window, toolbar and plot origins */
|
2005-02-07 17:28:43 +03:00
|
|
|
static wimp_w global_history_window;
|
|
|
|
struct tree *global_history_tree;
|
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/**
|
|
|
|
* Initialise global history tree
|
|
|
|
*/
|
|
|
|
void ro_gui_global_history_initialise(void)
|
|
|
|
{
|
2005-02-07 17:28:43 +03:00
|
|
|
char s[MAXIMUM_URL_LENGTH];
|
|
|
|
FILE *fp;
|
|
|
|
|
2006-01-07 00:25:34 +03:00
|
|
|
/* create our window */
|
|
|
|
global_history_window = ro_gui_dialog_create("tree");
|
|
|
|
ro_gui_set_window_title(global_history_window,
|
|
|
|
messages_get("GlobalHistory"));
|
2005-12-31 07:36:24 +03:00
|
|
|
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);
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/* Create an empty tree */
|
2005-02-07 17:28:43 +03:00
|
|
|
global_history_tree = calloc(sizeof(struct tree), 1);
|
|
|
|
if (!global_history_tree) {
|
2005-04-08 00:46:22 +04:00
|
|
|
warn_user("NoMemory", 0);
|
2005-02-07 17:28:43 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
global_history_tree->root = tree_create_folder_node(NULL, "Root");
|
|
|
|
if (!global_history_tree->root) {
|
2005-04-08 00:46:22 +04:00
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
free(global_history_tree);
|
|
|
|
global_history_tree = NULL;
|
2005-02-07 17:28:43 +03:00
|
|
|
}
|
|
|
|
global_history_tree->root->expanded = true;
|
2005-02-09 02:37:41 +03:00
|
|
|
ro_gui_global_history_initialise_nodes();
|
2005-02-07 17:28:43 +03:00
|
|
|
global_history_tree->handle = (int)global_history_window;
|
2005-02-09 02:37:41 +03:00
|
|
|
global_history_tree->movable = false;
|
2005-12-31 07:36:24 +03:00
|
|
|
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);
|
2005-02-07 17:28:43 +03:00
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/* Create our toolbar */
|
2005-03-19 02:52:38 +03:00
|
|
|
global_history_tree->toolbar = ro_gui_theme_create_toolbar(NULL,
|
2005-02-07 17:28:43 +03:00
|
|
|
THEME_HISTORY_TOOLBAR);
|
2005-03-19 02:52:38 +03:00
|
|
|
if (global_history_tree->toolbar)
|
|
|
|
ro_gui_theme_attach_toolbar(global_history_tree->toolbar,
|
2005-02-07 17:28:43 +03:00
|
|
|
global_history_window);
|
2005-04-08 00:46:22 +04:00
|
|
|
|
|
|
|
/* load recent URLs */
|
2006-01-08 04:51:33 +03:00
|
|
|
fp = fopen(option_recent_path, "r");
|
2005-02-07 17:28:43 +03:00
|
|
|
if (!fp)
|
|
|
|
LOG(("Failed to open file '%s' for reading",
|
2006-01-08 04:51:33 +03:00
|
|
|
option_recent_path));
|
2005-02-07 17:28:43 +03:00
|
|
|
else {
|
|
|
|
while (fgets(s, MAXIMUM_URL_LENGTH, fp)) {
|
2005-04-08 00:46:22 +04:00
|
|
|
if (s[strlen(s) - 1] == '\n')
|
|
|
|
s[strlen(s) - 1] = '\0';
|
2005-02-07 17:28:43 +03:00
|
|
|
global_history_add_recent(s);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2005-03-13 01:32:43 +03:00
|
|
|
|
2005-12-31 07:36:24 +03:00
|
|
|
global_history_init = true;
|
2006-04-11 06:39:55 +04:00
|
|
|
urldb_iterate_entries(global_history_add_internal);
|
2006-01-08 04:51:33 +03:00
|
|
|
global_history_init = false;
|
2006-07-13 16:46:02 +04:00
|
|
|
tree_initialise(global_history_tree);
|
2005-02-07 17:28:43 +03:00
|
|
|
}
|
|
|
|
|
2005-02-09 02:37:41 +03:00
|
|
|
/**
|
|
|
|
* Initialises the base nodes
|
|
|
|
*/
|
2006-04-10 03:21:13 +04:00
|
|
|
void ro_gui_global_history_initialise_nodes(void)
|
|
|
|
{
|
2005-02-09 02:37:41 +03:00
|
|
|
struct tm *full_time;
|
|
|
|
time_t t;
|
|
|
|
int weekday;
|
|
|
|
int i;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2005-02-09 02:37:41 +03:00
|
|
|
/* get the current time */
|
|
|
|
t = time(NULL);
|
|
|
|
if (t == -1)
|
|
|
|
return;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2005-02-09 02:37:41 +03:00
|
|
|
/* get the time at the start of today */
|
|
|
|
full_time = localtime(&t);
|
|
|
|
weekday = full_time->tm_wday;
|
|
|
|
full_time->tm_sec = 0;
|
|
|
|
full_time->tm_min = 0;
|
|
|
|
full_time->tm_hour = 0;
|
|
|
|
t = mktime(full_time);
|
|
|
|
if (t == -1)
|
|
|
|
return;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2005-02-09 02:37:41 +03:00
|
|
|
ro_gui_global_history_initialise_node(messages_get("DateToday"), t, 0);
|
|
|
|
if (weekday > 0)
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_global_history_initialise_node(
|
|
|
|
messages_get("DateYesterday"), t, -1);
|
2005-02-09 02:37:41 +03:00
|
|
|
for (i = 2; i <= weekday; i++)
|
|
|
|
ro_gui_global_history_initialise_node(NULL, t, -i);
|
|
|
|
ro_gui_global_history_initialise_node(messages_get("Date1Week"),
|
|
|
|
t, -weekday - 7);
|
|
|
|
ro_gui_global_history_initialise_node(messages_get("Date2Week"),
|
|
|
|
t, -weekday - 14);
|
|
|
|
ro_gui_global_history_initialise_node(messages_get("Date3Week"),
|
|
|
|
t, -weekday - 21);
|
|
|
|
}
|
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/**
|
|
|
|
* Create and initialise a node
|
|
|
|
*/
|
|
|
|
void ro_gui_global_history_initialise_node(const char *title,
|
|
|
|
time_t base, int days_back)
|
|
|
|
{
|
2005-02-09 02:37:41 +03:00
|
|
|
struct tm *full_time;
|
|
|
|
char buffer[64];
|
|
|
|
struct node *node;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2005-02-09 02:37:41 +03:00
|
|
|
base += days_back * 60 * 60 * 24;
|
|
|
|
if (!title) {
|
|
|
|
full_time = localtime(&base);
|
|
|
|
strftime((char *)&buffer, (size_t)64, "%A", full_time);
|
|
|
|
node = tree_create_folder_node(NULL, buffer);
|
|
|
|
} else
|
|
|
|
node = tree_create_folder_node(NULL, title);
|
|
|
|
|
|
|
|
if (!node)
|
|
|
|
return;
|
|
|
|
|
|
|
|
node->retain_in_memory = true;
|
|
|
|
node->deleted = true;
|
|
|
|
node->editable = false;
|
|
|
|
global_history_base_node[global_history_base_node_count] = node;
|
|
|
|
global_history_base_node_time[global_history_base_node_count] = base;
|
|
|
|
global_history_base_node_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/**
|
2005-12-31 07:36:24 +03:00
|
|
|
* Saves the global history's recent URL data.
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2006-04-10 03:21:13 +04:00
|
|
|
void ro_gui_global_history_save(void)
|
|
|
|
{
|
2005-02-07 17:28:43 +03:00
|
|
|
FILE *fp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* save recent URLs */
|
2006-01-08 04:51:33 +03:00
|
|
|
fp = fopen(option_recent_save, "w");
|
2005-02-07 17:28:43 +03:00
|
|
|
if (!fp)
|
|
|
|
LOG(("Failed to open file '%s' for writing",
|
2006-01-08 04:51:33 +03:00
|
|
|
option_recent_save));
|
2005-02-07 17:28:43 +03:00
|
|
|
else {
|
|
|
|
for (i = global_history_recent_count - 1; i >= 0; i--)
|
2005-04-08 00:46:22 +04:00
|
|
|
if (strlen(global_history_recent_url[i]) <
|
|
|
|
MAXIMUM_URL_LENGTH)
|
|
|
|
fprintf(fp, "%s\n",
|
|
|
|
global_history_recent_url[i]);
|
2005-02-07 17:28:43 +03:00
|
|
|
fclose(fp);
|
|
|
|
}
|
2005-03-13 01:32:43 +03:00
|
|
|
}
|
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Respond to a mouse click
|
|
|
|
*
|
|
|
|
* \param pointer the pointer state
|
2006-04-10 03:21:13 +04:00
|
|
|
* \return true to indicate click handled
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2006-04-10 03:21:13 +04:00
|
|
|
bool ro_gui_global_history_click(wimp_pointer *pointer)
|
|
|
|
{
|
2005-02-07 17:28:43 +03:00
|
|
|
ro_gui_tree_click(pointer, global_history_tree);
|
|
|
|
if (pointer->buttons == wimp_CLICK_MENU)
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_create(global_history_menu, pointer->pos.x,
|
|
|
|
pointer->pos.y, pointer->w);
|
2005-02-07 17:28:43 +03:00
|
|
|
else
|
2005-04-08 00:46:22 +04:00
|
|
|
ro_gui_menu_prepare_action(pointer->w, TREE_SELECTION, false);
|
2005-12-31 07:36:24 +03:00
|
|
|
return true;
|
2005-02-07 17:28:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds to the global history
|
2006-04-10 03:21:13 +04:00
|
|
|
*
|
|
|
|
* \param url The URL to add
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2006-04-10 03:21:13 +04:00
|
|
|
void global_history_add(const char *url)
|
|
|
|
{
|
|
|
|
const struct url_data *data;
|
2006-04-11 06:39:55 +04:00
|
|
|
|
|
|
|
data = urldb_get_url_data(url);
|
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
global_history_add_internal(url, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal routine to actually perform global history addition
|
|
|
|
*
|
|
|
|
* \param url The URL to add
|
|
|
|
* \param data URL data associated with URL
|
|
|
|
* \return true (for urldb_iterate_entries)
|
|
|
|
*/
|
|
|
|
bool global_history_add_internal(const char *url,
|
|
|
|
const struct url_data *data)
|
|
|
|
{
|
|
|
|
int i, j;
|
2005-04-08 00:46:22 +04:00
|
|
|
struct node *parent = NULL;
|
|
|
|
struct node *link;
|
|
|
|
struct node *node;
|
|
|
|
bool before = false;
|
2005-12-31 07:36:24 +03:00
|
|
|
int visit_date;
|
|
|
|
|
2006-04-11 06:39:55 +04:00
|
|
|
assert(url && data);
|
2005-12-31 07:36:24 +03:00
|
|
|
|
|
|
|
visit_date = data->last_visit;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2006-04-14 04:27:49 +04:00
|
|
|
/* find parent node */
|
2005-04-08 00:46:22 +04:00
|
|
|
for (i = 0; i < global_history_base_node_count; i++) {
|
|
|
|
if (global_history_base_node_time[i] <= visit_date) {
|
|
|
|
parent = global_history_base_node[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-05 02:24:50 +03:00
|
|
|
/* the entry is too old to care about */
|
|
|
|
if (!parent)
|
2006-04-11 06:39:55 +04:00
|
|
|
return true;
|
2005-12-31 07:36:24 +03:00
|
|
|
|
2006-04-14 04:27:49 +04:00
|
|
|
if (parent->deleted) {
|
|
|
|
/* parent was deleted, so find place to insert it */
|
|
|
|
link = global_history_tree->root;
|
|
|
|
|
|
|
|
for (j = global_history_base_node_count - 1; j >= 0; j--) {
|
|
|
|
if (!global_history_base_node[j]->deleted &&
|
|
|
|
global_history_base_node_time[j] >
|
|
|
|
global_history_base_node_time[i]) {
|
|
|
|
link = global_history_base_node[j];
|
|
|
|
before = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-04 01:47:45 +03:00
|
|
|
tree_set_node_selected(global_history_tree,
|
|
|
|
parent, false);
|
|
|
|
tree_set_node_expanded(global_history_tree,
|
|
|
|
parent, false);
|
2006-04-14 04:27:49 +04:00
|
|
|
tree_link_node(link, parent, before);
|
|
|
|
|
|
|
|
if (!global_history_init) {
|
2007-03-04 01:47:45 +03:00
|
|
|
tree_recalculate_node(global_history_tree, parent, true);
|
|
|
|
tree_recalculate_node_positions(global_history_tree,
|
|
|
|
global_history_tree->root);
|
2006-04-14 04:27:49 +04:00
|
|
|
tree_redraw_area(global_history_tree,
|
|
|
|
0, 0, 16384, 16384);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/* find any previous occurance */
|
|
|
|
if (!global_history_init) {
|
|
|
|
node = ro_gui_global_history_find(url);
|
|
|
|
if (node) {
|
|
|
|
/* \todo: calculate old/new positions and redraw
|
|
|
|
* only the relevant portion */
|
2005-04-08 00:46:22 +04:00
|
|
|
tree_redraw_area(global_history_tree,
|
2006-01-05 02:24:50 +03:00
|
|
|
0, 0, 16384, 16384);
|
2006-04-10 03:21:13 +04:00
|
|
|
tree_update_URL_node(node, url, data);
|
|
|
|
tree_delink_node(node);
|
|
|
|
tree_link_node(parent, node, false);
|
2006-01-05 02:24:50 +03:00
|
|
|
tree_handle_node_changed(global_history_tree,
|
|
|
|
node, false, true);
|
|
|
|
/* ro_gui_tree_scroll_visible(hotlist_tree,
|
|
|
|
&node->data);
|
2006-04-11 06:39:55 +04:00
|
|
|
*/ return true;
|
2006-04-10 03:21:13 +04:00
|
|
|
}
|
2006-01-05 02:24:50 +03:00
|
|
|
}
|
2005-03-13 01:32:43 +03:00
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/* Add the node at the bottom */
|
|
|
|
node = tree_create_URL_node_shared(parent, url, data);
|
2006-01-05 02:24:50 +03:00
|
|
|
if ((!global_history_init) && (node)) {
|
|
|
|
tree_redraw_area(global_history_tree,
|
|
|
|
node->box.x - NODE_INSTEP,
|
|
|
|
0, NODE_INSTEP, 16384);
|
|
|
|
tree_handle_node_changed(global_history_tree, node,
|
|
|
|
true, false);
|
2005-12-31 07:36:24 +03:00
|
|
|
}
|
2006-04-11 06:39:55 +04:00
|
|
|
|
|
|
|
return true;
|
2005-12-31 07:36:24 +03:00
|
|
|
}
|
|
|
|
|
2006-04-10 03:21:13 +04:00
|
|
|
/**
|
|
|
|
* Find an entry in the global history
|
|
|
|
*
|
|
|
|
* \param url The URL to find
|
|
|
|
* \return Pointer to node, or NULL if not found
|
|
|
|
*/
|
|
|
|
struct node *ro_gui_global_history_find(const char *url)
|
|
|
|
{
|
2005-12-31 07:36:24 +03:00
|
|
|
int i;
|
|
|
|
struct node *node;
|
|
|
|
struct node_element *element;
|
|
|
|
|
|
|
|
for (i = 0; i < global_history_base_node_count; i++) {
|
|
|
|
if (!global_history_base_node[i]->deleted) {
|
|
|
|
for (node = global_history_base_node[i]->child;
|
|
|
|
node; node = node->next) {
|
|
|
|
element = tree_find_element(node,
|
|
|
|
TREE_ELEMENT_URL);
|
2006-04-12 12:10:05 +04:00
|
|
|
if ((element) && !strcmp(url, element->text))
|
2005-12-31 07:36:24 +03:00
|
|
|
return node;
|
2005-04-08 00:46:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-12-31 07:36:24 +03:00
|
|
|
return NULL;
|
2005-02-07 17:28:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2006-04-10 03:21:13 +04:00
|
|
|
* Adds an URL to the recently used list
|
2005-02-07 17:28:43 +03:00
|
|
|
*
|
2006-04-10 03:21:13 +04:00
|
|
|
* \param url the URL to add (copied)
|
2005-02-07 17:28:43 +03:00
|
|
|
*/
|
2006-04-10 03:21:13 +04:00
|
|
|
void global_history_add_recent(const char *url)
|
|
|
|
{
|
2005-02-07 17:28:43 +03:00
|
|
|
int i;
|
|
|
|
int j = -1;
|
|
|
|
char *current;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/* try to find a string already there */
|
|
|
|
for (i = 0; i < global_history_recent_count; i++)
|
2006-04-10 03:21:13 +04:00
|
|
|
if (global_history_recent_url[i] &&
|
|
|
|
!strcmp(global_history_recent_url[i], url))
|
2005-02-07 17:28:43 +03:00
|
|
|
j = i;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
/* already at head of list */
|
|
|
|
if (j == 0)
|
|
|
|
return;
|
2005-04-08 00:46:22 +04:00
|
|
|
|
2005-02-07 17:28:43 +03:00
|
|
|
if (j < 0) {
|
2006-04-10 03:21:13 +04:00
|
|
|
/* add to head of list */
|
|
|
|
free(global_history_recent_url[
|
|
|
|
GLOBAL_HISTORY_RECENT_URLS - 1]);
|
2005-02-07 17:28:43 +03:00
|
|
|
memmove(&global_history_recent_url[1],
|
|
|
|
&global_history_recent_url[0],
|
2005-04-08 00:46:22 +04:00
|
|
|
(GLOBAL_HISTORY_RECENT_URLS - 1) *
|
|
|
|
sizeof(char *));
|
2006-04-10 03:21:13 +04:00
|
|
|
global_history_recent_url[0] = strdup(url);
|
2005-02-07 17:28:43 +03:00
|
|
|
global_history_recent_count++;
|
|
|
|
if (global_history_recent_count > GLOBAL_HISTORY_RECENT_URLS)
|
2005-04-08 00:46:22 +04:00
|
|
|
global_history_recent_count =
|
|
|
|
GLOBAL_HISTORY_RECENT_URLS;
|
2005-02-07 17:28:43 +03:00
|
|
|
if (global_history_recent_count == 1)
|
|
|
|
ro_gui_window_prepare_navigate_all();
|
|
|
|
} else {
|
|
|
|
/* move to head of list */
|
|
|
|
current = global_history_recent_url[j];
|
|
|
|
for (i = j; i > 0; i--)
|
|
|
|
global_history_recent_url[i] =
|
|
|
|
global_history_recent_url[i - 1];
|
|
|
|
global_history_recent_url[0] = current;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets details of the currently used URL list.
|
|
|
|
*
|
|
|
|
* \param count set to the current number of entries in the URL array on exit
|
|
|
|
* \return the current URL array
|
|
|
|
*/
|
2006-04-10 03:21:13 +04:00
|
|
|
char **global_history_get_recent(int *count)
|
|
|
|
{
|
2005-02-07 17:28:43 +03:00
|
|
|
*count = global_history_recent_count;
|
|
|
|
return global_history_recent_url;
|
|
|
|
}
|