mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 21:16:50 +03:00
Remove tree_url_node module. Had to disable treeview scanning in amiga and cocoa front ends. Amiga front end very likely broken.
This commit is contained in:
parent
28a948bd32
commit
5c7ca39ada
@ -44,7 +44,6 @@
|
||||
#include "desktop/hotlist_old.h"
|
||||
#include "desktop/searchweb.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "render/form.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/messages.h"
|
||||
@ -1220,11 +1219,11 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
|
||||
break;
|
||||
|
||||
case CMID_TREE_EDITTITLE:
|
||||
tree_url_node_edit_title(tree, userdata);
|
||||
warn_user("TODO.", 0);
|
||||
break;
|
||||
|
||||
case CMID_TREE_EDITLINK:
|
||||
tree_url_node_edit_url(tree, userdata);
|
||||
warn_user("TODO.", 0);
|
||||
break;
|
||||
|
||||
case CMID_TREE_NEWFOLDER:
|
||||
@ -1236,15 +1235,15 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
|
||||
break;
|
||||
|
||||
case CMID_TREE_SETDEFAULT:
|
||||
hotlist_old_set_default_folder(false);
|
||||
warn_user("TODO.", 0);
|
||||
break;
|
||||
|
||||
case CMID_TREE_CLEARDEFAULT:
|
||||
hotlist_old_set_default_folder(true);
|
||||
warn_user("TODO.", 0);
|
||||
break;
|
||||
|
||||
case CMID_TREE_ADDHOTLIST:
|
||||
hotlist_old_add_page(tree_url_node_get_url(userdata));
|
||||
warn_user("TODO.", 0);
|
||||
break;
|
||||
|
||||
case CMID_TREE_DELETE:
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "desktop/searchweb.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "image/ico.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
@ -2857,6 +2856,7 @@ void ami_update_buttons(struct gui_window_2 *gwin)
|
||||
void ami_gui_hotlist_scan_2(struct tree *tree, struct node *root, WORD *gen, int *item,
|
||||
struct List *speed_button_list, struct gui_window_2 *gwin)
|
||||
{
|
||||
#if 0
|
||||
struct node *tempnode;
|
||||
struct node_element *element=NULL;
|
||||
struct node *node;
|
||||
@ -2889,10 +2889,12 @@ void ami_gui_hotlist_scan_2(struct tree *tree, struct node *root, WORD *gen, int
|
||||
}
|
||||
|
||||
*gen = *gen - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, struct gui_window_2 *gwin)
|
||||
{
|
||||
#if 0
|
||||
struct node *root = tree_node_get_child(tree_get_root(tree));
|
||||
struct node *node;
|
||||
struct node_element *element;
|
||||
@ -2910,6 +2912,9 @@ int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, stru
|
||||
}
|
||||
|
||||
return item;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
|
||||
|
@ -58,7 +58,6 @@
|
||||
#include "amiga/theme.h"
|
||||
#include "amiga/tree.h"
|
||||
#include "amiga/utf8.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "desktop/hotlist_old.h"
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/gui.h"
|
||||
@ -540,6 +539,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
|
||||
|
||||
ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
|
||||
{
|
||||
#if 0
|
||||
struct node *root = tree_node_get_child(tree_get_root(tree));
|
||||
struct node *node;
|
||||
struct node_element *element;
|
||||
@ -560,11 +560,15 @@ ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
|
||||
}
|
||||
|
||||
return(item - AMI_MENU_HOTLIST);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
|
||||
int *item, struct gui_window_2 *gwin)
|
||||
{
|
||||
#if 0
|
||||
struct node *tempnode;
|
||||
struct node_element *element=NULL;
|
||||
struct node *node;
|
||||
@ -602,6 +606,7 @@ void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
|
||||
}
|
||||
|
||||
*gen = *gen - 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ami_menu_update_checked(struct gui_window_2 *gwin)
|
||||
|
13
amiga/tree.c
13
amiga/tree.c
@ -59,7 +59,6 @@
|
||||
#include "desktop/history_global_core.h"
|
||||
#include "desktop/hotlist_old.h"
|
||||
#include "desktop/sslcert_viewer.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/messages.h"
|
||||
|
||||
@ -193,18 +192,6 @@ void ami_tree_get_window_dimensions(int *width, int *height, void *data)
|
||||
if(height) *height = bbox->Height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a content_type to the name of a respective icon
|
||||
*
|
||||
* \param content_type content type
|
||||
* \param buffer buffer for the icon name
|
||||
*/
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
const char *ftype = ami_content_type_to_file_type(type);
|
||||
sprintf(buffer, "def_%s.info", ftype);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls the tree to make an element visible
|
||||
*
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "desktop/browser.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/history_global_core.h"
|
||||
#include "desktop/browser.h"
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/hotlist_old.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
@ -527,23 +526,3 @@ void atari_treeview_get_dimensions(int *width, int *height,
|
||||
*height = work.g_h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a content_type to the name of a respective icon
|
||||
*
|
||||
* \param content_type content type
|
||||
* \param buffer buffer for the icon name
|
||||
*/
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case CONTENT_HTML:
|
||||
case CONTENT_TEXTPLAIN:
|
||||
case CONTENT_CSS:
|
||||
case CONTENT_IMAGE:
|
||||
default:
|
||||
strcpy( buffer, "content.png" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
extern "C" {
|
||||
#include "utils/config.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
}
|
||||
|
||||
const char tree_directory_icon_name[] = "directory.png";
|
||||
@ -34,23 +33,3 @@ const char tree_content_icon_name[] = "content.png";
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Translates a content_type to the name of a respective icon
|
||||
*
|
||||
* \param content_type content type
|
||||
* \param buffer buffer for the icon name
|
||||
*/
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
// TODO: design/acquire icons
|
||||
switch (type) {
|
||||
case CONTENT_HTML:
|
||||
case CONTENT_TEXTPLAIN:
|
||||
case CONTENT_CSS:
|
||||
case CONTENT_IMAGE:
|
||||
default:
|
||||
sprintf(buffer, tree_content_icon_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
#import "desktop/browser_private.h"
|
||||
#import "desktop/hotlist_old.h"
|
||||
#import "desktop/tree.h"
|
||||
#import "desktop/tree_url_node.h"
|
||||
#import "utils/messages.h"
|
||||
|
||||
@interface BookmarksController ()
|
||||
@ -85,6 +84,7 @@ static const char *cocoa_hotlist_path( void )
|
||||
|
||||
- (void) menuNeedsUpdate: (NSMenu *)menu
|
||||
{
|
||||
#if 0
|
||||
for (NSMenuItem *item in [menu itemArray]) {
|
||||
if ([item hasSubmenu]) NSMapRemove( nodeForMenu, [item submenu] );
|
||||
[menu removeItem: item];
|
||||
@ -125,6 +125,7 @@ static const char *cocoa_hotlist_path( void )
|
||||
[item setAction: @selector( openBookmarkURL: )];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (IBAction) openBookmarkURL: (id) sender;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "utils/utils.h"
|
||||
#import "desktop/tree_url_node.h"
|
||||
|
||||
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
|
||||
|
||||
@ -55,12 +54,3 @@ bool path_add_part(char *path, int length, const char *newpart)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
strcpy( buffer, "content.png" );
|
||||
break;
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
S_DESKTOP := cookie_manager.c cookies_old.c history_global_core.c hotlist_old.c knockout.c \
|
||||
hotlist.c mouse.c plot_style.c print.c search.c searchweb.c \
|
||||
scrollbar.c sslcert_viewer.c textarea.c thumbnail.c tree.c \
|
||||
tree_url_node.c version.c system_colour.c global_history.c treeview.c
|
||||
version.c system_colour.c global_history.c treeview.c
|
||||
|
||||
S_DESKTOP := $(addprefix desktop/,$(S_DESKTOP))
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "desktop/global_history.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
@ -1,972 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Creation of URL nodes with use of trees (implementation)
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <dom/dom.h>
|
||||
#include <dom/bindings/hubbub/parser.h>
|
||||
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "content/urldb.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/libdom.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/** Flags for each type of url tree node. */
|
||||
enum tree_element_url {
|
||||
TREE_ELEMENT_URL = 0x01,
|
||||
TREE_ELEMENT_LAST_VISIT = 0x02,
|
||||
TREE_ELEMENT_VISITS = 0x03,
|
||||
TREE_ELEMENT_THUMBNAIL = 0x04,
|
||||
};
|
||||
|
||||
#define MAX_ICON_NAME_LEN 256
|
||||
|
||||
static bool initialised = false;
|
||||
|
||||
static hlcache_handle *folder_icon;
|
||||
|
||||
struct icon_entry {
|
||||
content_type type;
|
||||
hlcache_handle *icon;
|
||||
};
|
||||
|
||||
struct icon_entry icon_table[] = {
|
||||
{CONTENT_HTML, NULL},
|
||||
{CONTENT_TEXTPLAIN, NULL},
|
||||
{CONTENT_CSS, NULL},
|
||||
{CONTENT_IMAGE, NULL},
|
||||
{CONTENT_NONE, NULL},
|
||||
|
||||
/* this serves as a sentinel */
|
||||
{CONTENT_HTML, NULL}
|
||||
};
|
||||
|
||||
static uint32_t tun_users = 0;
|
||||
|
||||
void tree_url_node_init(const char *folder_icon_name)
|
||||
{
|
||||
struct icon_entry *entry;
|
||||
char icon_name[MAX_ICON_NAME_LEN];
|
||||
|
||||
tun_users++;
|
||||
|
||||
if (initialised)
|
||||
return;
|
||||
initialised = true;
|
||||
|
||||
folder_icon = tree_load_icon(folder_icon_name);
|
||||
|
||||
entry = icon_table;
|
||||
do {
|
||||
|
||||
tree_icon_name_from_content_type(icon_name, entry->type);
|
||||
entry->icon = tree_load_icon(icon_name);
|
||||
|
||||
++entry;
|
||||
} while (entry->type != CONTENT_HTML);
|
||||
}
|
||||
|
||||
|
||||
void tree_url_node_cleanup()
|
||||
{
|
||||
struct icon_entry *entry;
|
||||
|
||||
tun_users--;
|
||||
|
||||
if (tun_users > 0)
|
||||
return;
|
||||
|
||||
if (!initialised)
|
||||
return;
|
||||
initialised = false;
|
||||
|
||||
hlcache_handle_release(folder_icon);
|
||||
|
||||
entry = icon_table;
|
||||
do {
|
||||
hlcache_handle_release(entry->icon);
|
||||
++entry;
|
||||
} while (entry->type != CONTENT_HTML);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a tree entry for a URL, and links it into the tree
|
||||
*
|
||||
* \param parent the node to link to
|
||||
* \param url the URL (copied)
|
||||
* \param data the URL data to use
|
||||
* \param title custom title to use or NULL to use url
|
||||
* \return the node created, or NULL for failure
|
||||
*/
|
||||
struct node *tree_create_URL_node(struct tree *tree, struct node *parent,
|
||||
nsurl *url, const char *title,
|
||||
tree_node_user_callback user_callback, void *callback_data)
|
||||
{
|
||||
struct node *node = NULL;
|
||||
struct node_element *element;
|
||||
|
||||
if (title == NULL) {
|
||||
node = tree_create_leaf_node(tree,
|
||||
parent,
|
||||
nsurl_access(url),
|
||||
true, false, false);
|
||||
} else {
|
||||
char *squashed;
|
||||
|
||||
squashed = squash_whitespace(title);
|
||||
if (squashed != NULL) {
|
||||
node = tree_create_leaf_node(tree,
|
||||
parent,
|
||||
squashed,
|
||||
true, false, false);
|
||||
free(squashed);
|
||||
}
|
||||
}
|
||||
if (node == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (user_callback != NULL) {
|
||||
tree_set_node_user_callback(node, user_callback,
|
||||
callback_data);
|
||||
}
|
||||
|
||||
tree_create_node_element(node, NODE_ELEMENT_BITMAP,
|
||||
TREE_ELEMENT_THUMBNAIL, false);
|
||||
tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_VISITS,
|
||||
false);
|
||||
tree_create_node_element(node, NODE_ELEMENT_TEXT,
|
||||
TREE_ELEMENT_LAST_VISIT, false);
|
||||
element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
|
||||
TREE_ELEMENT_URL, true);
|
||||
if (element != NULL) {
|
||||
char *text_cp = strdup(nsurl_access(url));
|
||||
if (text_cp == NULL) {
|
||||
tree_delete_node(tree, node, false);
|
||||
LOG(("malloc failed"));
|
||||
warn_user("NoMemory", 0);
|
||||
return NULL;
|
||||
}
|
||||
tree_update_node_element(tree, element, text_cp, NULL);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a read only tree entry for a URL, and links it into the tree.
|
||||
*
|
||||
* \param parent the node to link to
|
||||
* \param url the URL
|
||||
* \param data the URL data to use
|
||||
* \return the node created, or NULL for failure
|
||||
*/
|
||||
struct node *tree_create_URL_node_readonly(struct tree *tree,
|
||||
struct node *parent, nsurl *url,
|
||||
const struct url_data *data,
|
||||
tree_node_user_callback user_callback, void *callback_data)
|
||||
{
|
||||
struct node *node;
|
||||
struct node_element *element;
|
||||
const char *title;
|
||||
|
||||
assert(url && data);
|
||||
|
||||
if (data->title != NULL) {
|
||||
title = data->title;
|
||||
} else {
|
||||
title = nsurl_access(url);
|
||||
}
|
||||
|
||||
node = tree_create_leaf_node(tree, parent, title, false, false, false);
|
||||
if (node == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (user_callback != NULL) {
|
||||
tree_set_node_user_callback(node, user_callback,
|
||||
callback_data);
|
||||
}
|
||||
|
||||
tree_create_node_element(node, NODE_ELEMENT_BITMAP,
|
||||
TREE_ELEMENT_THUMBNAIL, false);
|
||||
tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_VISITS,
|
||||
false);
|
||||
tree_create_node_element(node, NODE_ELEMENT_TEXT,
|
||||
TREE_ELEMENT_LAST_VISIT, false);
|
||||
element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
|
||||
TREE_ELEMENT_URL, false);
|
||||
if (element != NULL) {
|
||||
tree_update_node_element(tree, element, nsurl_access(url),
|
||||
NULL);
|
||||
}
|
||||
|
||||
tree_update_URL_node(tree, node, url, data);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the node details for a URL node.
|
||||
*
|
||||
* \param node the node to update
|
||||
*/
|
||||
void tree_update_URL_node(struct tree *tree, struct node *node,
|
||||
nsurl *url, const struct url_data *data)
|
||||
{
|
||||
struct node_element *element;
|
||||
struct bitmap *bitmap = NULL;
|
||||
struct icon_entry *entry;
|
||||
char *text_cp;
|
||||
|
||||
assert(node != NULL);
|
||||
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
|
||||
if (element == NULL)
|
||||
return;
|
||||
|
||||
if (data != NULL) {
|
||||
if (data->title == NULL)
|
||||
urldb_set_url_title(url, nsurl_access(url));
|
||||
|
||||
if (data->title == NULL)
|
||||
return;
|
||||
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_TITLE,
|
||||
NULL);
|
||||
|
||||
text_cp = strdup(data->title);
|
||||
if (text_cp == NULL) {
|
||||
LOG(("malloc failed"));
|
||||
warn_user("NoMemory", 0);
|
||||
return;
|
||||
}
|
||||
tree_update_node_element(tree, element, text_cp, NULL);
|
||||
} else {
|
||||
data = urldb_get_url_data(url);
|
||||
if (data == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
entry = icon_table;
|
||||
do {
|
||||
if (entry->type == data->type) {
|
||||
if (entry->icon != NULL)
|
||||
tree_set_node_icon(tree, node, entry->icon);
|
||||
break;
|
||||
}
|
||||
++entry;
|
||||
} while (entry->type != CONTENT_HTML);
|
||||
|
||||
/* update last visit text */
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_LAST_VISIT, element);
|
||||
tree_update_element_text(tree,
|
||||
element,
|
||||
messages_get_buff("TreeLast",
|
||||
(data->last_visit > 0) ?
|
||||
ctime((time_t *)&data->last_visit) :
|
||||
messages_get("TreeUnknown")));
|
||||
|
||||
|
||||
/* update number of visits text */
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_VISITS, element);
|
||||
tree_update_element_text(tree,
|
||||
element,
|
||||
messages_get_buff("TreeVisits", data->visits));
|
||||
|
||||
|
||||
/* update thumbnail */
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_THUMBNAIL, element);
|
||||
if (element != NULL) {
|
||||
bitmap = urldb_get_thumbnail(url);
|
||||
|
||||
if (bitmap != NULL) {
|
||||
tree_update_node_element(tree, element, NULL, bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *tree_url_node_get_title(struct node *node)
|
||||
{
|
||||
struct node_element *element;
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
|
||||
if (element == NULL)
|
||||
return NULL;
|
||||
return tree_node_element_get_text(element);
|
||||
}
|
||||
|
||||
|
||||
const char *tree_url_node_get_url(struct node *node)
|
||||
{
|
||||
struct node_element *element;
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
|
||||
if (element == NULL)
|
||||
return NULL;
|
||||
return tree_node_element_get_text(element);
|
||||
}
|
||||
|
||||
|
||||
struct bitmap *tree_url_node_get_icon(struct node *node)
|
||||
{
|
||||
struct node_element *element;
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
|
||||
if (element == NULL)
|
||||
return NULL;
|
||||
return tree_node_element_get_icon(element);
|
||||
}
|
||||
|
||||
|
||||
void tree_url_node_edit_title(struct tree *tree, struct node *node)
|
||||
{
|
||||
struct node_element *element;
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
|
||||
tree_start_edit(tree, element);
|
||||
}
|
||||
|
||||
void tree_url_node_edit_url(struct tree *tree, struct node *node)
|
||||
{
|
||||
struct node_element *element;
|
||||
element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
|
||||
tree_start_edit(tree, element);
|
||||
}
|
||||
|
||||
node_callback_resp tree_url_node_callback(void *user_data,
|
||||
struct node_msg_data *msg_data)
|
||||
{
|
||||
struct tree *tree;
|
||||
struct node_element *element;
|
||||
nsurl *url;
|
||||
nserror error;
|
||||
const char *text;
|
||||
char *norm_text;
|
||||
const struct url_data *data;
|
||||
|
||||
/** @todo memory leaks on non-shared folder deletion. */
|
||||
switch (msg_data->msg) {
|
||||
case NODE_DELETE_ELEMENT_TXT:
|
||||
switch (msg_data->flag) {
|
||||
/* only history is using non-editable url
|
||||
* elements so only history deletion will run
|
||||
* this code
|
||||
*/
|
||||
case TREE_ELEMENT_URL:
|
||||
/* reset URL characteristics */
|
||||
error = nsurl_create(msg_data->data.text, &url);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
return NODE_CALLBACK_REJECT;
|
||||
}
|
||||
urldb_reset_url_visit_data(url);
|
||||
nsurl_unref(url);
|
||||
return NODE_CALLBACK_HANDLED;
|
||||
case TREE_ELEMENT_TITLE:
|
||||
return NODE_CALLBACK_HANDLED;
|
||||
}
|
||||
break;
|
||||
case NODE_DELETE_ELEMENT_IMG:
|
||||
if (msg_data->flag == TREE_ELEMENT_THUMBNAIL ||
|
||||
msg_data->flag == TREE_ELEMENT_TITLE)
|
||||
return NODE_CALLBACK_HANDLED;
|
||||
break;
|
||||
case NODE_LAUNCH:
|
||||
element = tree_node_find_element(msg_data->node,
|
||||
TREE_ELEMENT_URL, NULL);
|
||||
if (element != NULL) {
|
||||
nserror error;
|
||||
enum browser_window_nav_flags flags;
|
||||
|
||||
text = tree_node_element_get_text(element);
|
||||
|
||||
error = nsurl_create(text, &url);
|
||||
if (error == NSERROR_OK) {
|
||||
struct browser_window *clone = NULL;
|
||||
|
||||
flags = BROWSER_WINDOW_VERIFIABLE |
|
||||
BROWSER_WINDOW_HISTORY;
|
||||
if (msg_data->flag == TREE_ELEMENT_LAUNCH_IN_TABS) {
|
||||
flags |= BROWSER_WINDOW_TAB;
|
||||
clone = msg_data->data.bw;
|
||||
}
|
||||
error = browser_window_create(flags,
|
||||
url,
|
||||
NULL,
|
||||
clone,
|
||||
&msg_data->data.bw);
|
||||
nsurl_unref(url);
|
||||
}
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user(messages_get_errorcode(error), 0);
|
||||
}
|
||||
|
||||
return NODE_CALLBACK_HANDLED;
|
||||
}
|
||||
break;
|
||||
|
||||
case NODE_ELEMENT_EDIT_FINISHING:
|
||||
|
||||
text = msg_data->data.text;
|
||||
|
||||
if (msg_data->flag == TREE_ELEMENT_URL) {
|
||||
size_t len;
|
||||
error = nsurl_create(text, &url);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
return NODE_CALLBACK_REJECT;
|
||||
}
|
||||
error = nsurl_get(url, NSURL_WITH_FRAGMENT,
|
||||
&norm_text, &len);
|
||||
if (error != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
return NODE_CALLBACK_REJECT;
|
||||
}
|
||||
|
||||
msg_data->data.text = norm_text;
|
||||
|
||||
data = urldb_get_url_data(url);
|
||||
if (data == NULL) {
|
||||
urldb_add_url(url);
|
||||
urldb_set_url_persistence(url, true);
|
||||
data = urldb_get_url_data(url);
|
||||
if (data == NULL) {
|
||||
nsurl_unref(url);
|
||||
return NODE_CALLBACK_REJECT;
|
||||
}
|
||||
}
|
||||
tree = user_data;
|
||||
tree_update_URL_node(tree, msg_data->node,
|
||||
url, NULL);
|
||||
nsurl_unref(url);
|
||||
}
|
||||
else if (msg_data->flag == TREE_ELEMENT_TITLE) {
|
||||
while (isspace(*text))
|
||||
text++;
|
||||
norm_text = strdup(text);
|
||||
if (norm_text == NULL) {
|
||||
LOG(("malloc failed"));
|
||||
warn_user("NoMemory", 0);
|
||||
return NODE_CALLBACK_REJECT;
|
||||
}
|
||||
/* don't allow zero length entry text, return
|
||||
false */
|
||||
if (norm_text[0] == '\0') {
|
||||
warn_user("NoNameError", 0);
|
||||
msg_data->data.text = NULL;
|
||||
return NODE_CALLBACK_CONTINUE;
|
||||
}
|
||||
msg_data->data.text = norm_text;
|
||||
}
|
||||
|
||||
return NODE_CALLBACK_HANDLED;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NODE_CALLBACK_NOT_HANDLED;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
struct tree *tree;
|
||||
struct node *directory;
|
||||
tree_node_user_callback callback;
|
||||
void *callback_data;
|
||||
bool last_was_h4;
|
||||
dom_string *title;
|
||||
} tree_url_load_ctx;
|
||||
|
||||
static void tree_url_load_directory(dom_node *ul, tree_url_load_ctx *ctx);
|
||||
|
||||
/**
|
||||
* Parse an entry represented as a li.
|
||||
*
|
||||
* \param li DOM node for parsed li
|
||||
* \param directory directory to add this entry to
|
||||
*/
|
||||
static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
|
||||
{
|
||||
dom_node *a;
|
||||
dom_string *title1;
|
||||
dom_string *url1;
|
||||
char *title, *url2;
|
||||
nsurl *url;
|
||||
const struct url_data *data;
|
||||
struct node *entry;
|
||||
dom_exception derror;
|
||||
nserror error;
|
||||
|
||||
/* The li must contain an "a" element */
|
||||
a = libdom_find_first_element(li, corestring_lwc_a);
|
||||
if (a == NULL) {
|
||||
warn_user("TreeLoadError", "(Missing <a> in <li>)");
|
||||
return;
|
||||
}
|
||||
|
||||
derror = dom_node_get_text_content(a, &title1);
|
||||
if (derror != DOM_NO_ERR) {
|
||||
warn_user("TreeLoadError", "(No title)");
|
||||
dom_node_unref(a);
|
||||
return;
|
||||
}
|
||||
|
||||
derror = dom_element_get_attribute(a, corestring_dom_href, &url1);
|
||||
if (derror != DOM_NO_ERR || url1 == NULL) {
|
||||
warn_user("TreeLoadError", "(No URL)");
|
||||
dom_string_unref(title1);
|
||||
dom_node_unref(a);
|
||||
return;
|
||||
}
|
||||
|
||||
if (title1 != NULL) {
|
||||
title = strndup(dom_string_data(title1),
|
||||
dom_string_byte_length(title1));
|
||||
dom_string_unref(title1);
|
||||
} else {
|
||||
title = strdup("");
|
||||
}
|
||||
if (title == NULL) {
|
||||
warn_user("NoMemory", NULL);
|
||||
dom_string_unref(url1);
|
||||
dom_node_unref(a);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We're loading external input.
|
||||
* This may be garbage, so attempt to normalise via nsurl
|
||||
*/
|
||||
url2 = strndup(dom_string_data(url1), dom_string_byte_length(url1));
|
||||
if (url2 == NULL) {
|
||||
warn_user("NoMemory", NULL);
|
||||
free(title);
|
||||
dom_string_unref(url1);
|
||||
dom_node_unref(a);
|
||||
return;
|
||||
}
|
||||
|
||||
dom_string_unref(url1);
|
||||
|
||||
error = nsurl_create(url2, &url);
|
||||
|
||||
if (error != NSERROR_OK) {
|
||||
LOG(("Failed normalising '%s'", url2));
|
||||
|
||||
free(url2);
|
||||
|
||||
warn_user(messages_get_errorcode(error), NULL);
|
||||
|
||||
free(title);
|
||||
dom_node_unref(a);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
free(url2);
|
||||
|
||||
data = urldb_get_url_data(url);
|
||||
if (data == NULL) {
|
||||
/* No entry in database, so add one */
|
||||
urldb_add_url(url);
|
||||
/* now attempt to get url data */
|
||||
data = urldb_get_url_data(url);
|
||||
}
|
||||
if (data == NULL) {
|
||||
nsurl_unref(url);
|
||||
free(title);
|
||||
dom_node_unref(a);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make this URL persistent */
|
||||
urldb_set_url_persistence(url, true);
|
||||
|
||||
/* Force the title in the hotlist */
|
||||
urldb_set_url_title(url, title);
|
||||
|
||||
entry = tree_create_URL_node(ctx->tree, ctx->directory, url, title,
|
||||
ctx->callback, ctx->callback_data);
|
||||
|
||||
if (entry == NULL) {
|
||||
/** \todo why isn't this fatal? */
|
||||
warn_user("NoMemory", 0);
|
||||
} else {
|
||||
tree_update_URL_node(ctx->tree, entry, url, data);
|
||||
}
|
||||
|
||||
nsurl_unref(url);
|
||||
free(title);
|
||||
dom_node_unref(a);
|
||||
}
|
||||
|
||||
static nserror tree_url_load_directory_cb(dom_node *node, void *ctx)
|
||||
{
|
||||
/* TODO: return appropriate errors */
|
||||
tree_url_load_ctx *tctx = ctx;
|
||||
dom_string *name;
|
||||
dom_exception error;
|
||||
|
||||
/* The ul may contain entries as a li, or directories as
|
||||
* an h4 followed by a ul. Non-element nodes may be present
|
||||
* (eg. text, comments), and are ignored. */
|
||||
|
||||
error = dom_node_get_node_name(node, &name);
|
||||
if (error != DOM_NO_ERR || name == NULL)
|
||||
return NSERROR_NOMEM;
|
||||
|
||||
if (dom_string_caseless_lwc_isequal(name, corestring_lwc_li)) {
|
||||
/* entry */
|
||||
tree_url_load_entry(node, tctx);
|
||||
tctx->last_was_h4 = false;
|
||||
} else if (dom_string_caseless_lwc_isequal(name, corestring_lwc_h4)) {
|
||||
/* directory (a) */
|
||||
dom_string *title;
|
||||
|
||||
error = dom_node_get_text_content(node, &title);
|
||||
if (error != DOM_NO_ERR || title == NULL) {
|
||||
warn_user("TreeLoadError", "(Empty <h4> "
|
||||
"or memory exhausted.)");
|
||||
dom_string_unref(name);
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
if (tctx->title != NULL)
|
||||
dom_string_unref(tctx->title);
|
||||
tctx->title = title;
|
||||
tctx->last_was_h4 = true;
|
||||
} else if (tctx->last_was_h4 && dom_string_caseless_lwc_isequal(name,
|
||||
corestring_lwc_ul)) {
|
||||
/* directory (b) */
|
||||
dom_string *id;
|
||||
bool dir_is_default;
|
||||
struct node *dir;
|
||||
char *title;
|
||||
tree_url_load_ctx new_ctx;
|
||||
|
||||
error = dom_element_get_attribute(node, corestring_dom_id, &id);
|
||||
if (error != DOM_NO_ERR) {
|
||||
dom_string_unref(name);
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
if (id != NULL) {
|
||||
dir_is_default = dom_string_caseless_lwc_isequal(id,
|
||||
corestring_lwc_default);
|
||||
|
||||
dom_string_unref(id);
|
||||
} else {
|
||||
dir_is_default = false;
|
||||
}
|
||||
|
||||
title = strndup(dom_string_data(tctx->title),
|
||||
dom_string_byte_length(tctx->title));
|
||||
if (title == NULL) {
|
||||
dom_string_unref(name);
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
dir = tree_create_folder_node(tctx->tree, tctx->directory,
|
||||
title, true, false, false);
|
||||
free(title);
|
||||
if (dir == NULL) {
|
||||
dom_string_unref(name);
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
if (dir_is_default)
|
||||
tree_set_default_folder_node(tctx->tree, dir);
|
||||
|
||||
if (tctx->callback != NULL)
|
||||
tree_set_node_user_callback(dir, tctx->callback,
|
||||
tctx->callback_data);
|
||||
|
||||
if (folder_icon != NULL)
|
||||
tree_set_node_icon(tctx->tree, dir, folder_icon);
|
||||
|
||||
new_ctx.tree = tctx->tree;
|
||||
new_ctx.directory = dir;
|
||||
new_ctx.callback = tctx->callback;
|
||||
new_ctx.callback_data = tctx->callback_data;
|
||||
new_ctx.last_was_h4 = false;
|
||||
new_ctx.title = NULL;
|
||||
|
||||
tree_url_load_directory(node, &new_ctx);
|
||||
|
||||
if (new_ctx.title != NULL) {
|
||||
dom_string_unref(new_ctx.title);
|
||||
new_ctx.title = NULL;
|
||||
}
|
||||
tctx->last_was_h4 = false;
|
||||
} else {
|
||||
tctx->last_was_h4 = false;
|
||||
}
|
||||
|
||||
dom_string_unref(name);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a directory represented as a ul.
|
||||
*
|
||||
* \param ul DOM node for parsed ul
|
||||
* \param directory directory to add this directory to
|
||||
*/
|
||||
static void tree_url_load_directory(dom_node *ul, tree_url_load_ctx *ctx)
|
||||
{
|
||||
assert(ul != NULL);
|
||||
assert(ctx != NULL);
|
||||
assert(ctx->directory != NULL);
|
||||
|
||||
libdom_iterate_child_elements(ul, tree_url_load_directory_cb, ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an url tree from a specified file.
|
||||
*
|
||||
* \param filename name of file to read
|
||||
* \param tree empty tree which data will be read into
|
||||
* \return the file represented as a tree, or NULL on failure
|
||||
*/
|
||||
bool tree_urlfile_load(const char *filename, struct tree *tree,
|
||||
tree_node_user_callback callback, void *callback_data)
|
||||
{
|
||||
dom_document *document;
|
||||
dom_node *html, *body, *ul;
|
||||
struct node *root;
|
||||
nserror error;
|
||||
tree_url_load_ctx ctx;
|
||||
|
||||
if (filename == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
error = libdom_parse_file(filename, "iso-8859-1", &document);
|
||||
if (error != NSERROR_OK) {
|
||||
if (error != NSERROR_NOT_FOUND) {
|
||||
warn_user("TreeLoadError", messages_get("ParsingFail"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
html = libdom_find_first_element((dom_node *) document,
|
||||
corestring_lwc_html);
|
||||
if (html == NULL) {
|
||||
dom_node_unref(document);
|
||||
warn_user("TreeLoadError", "(<html> not found)");
|
||||
return false;
|
||||
}
|
||||
|
||||
body = libdom_find_first_element(html, corestring_lwc_body);
|
||||
if (body == NULL) {
|
||||
dom_node_unref(html);
|
||||
dom_node_unref(document);
|
||||
warn_user("TreeLoadError", "(<html>...<body> not found)");
|
||||
return false;
|
||||
}
|
||||
|
||||
ul = libdom_find_first_element(body, corestring_lwc_ul);
|
||||
if (ul == NULL) {
|
||||
dom_node_unref(body);
|
||||
dom_node_unref(html);
|
||||
dom_node_unref(document);
|
||||
warn_user("TreeLoadError",
|
||||
"(<html>...<body>...<ul> not found.)");
|
||||
return false;
|
||||
}
|
||||
|
||||
root = tree_get_root(tree);
|
||||
|
||||
ctx.tree = tree;
|
||||
ctx.directory = root;
|
||||
ctx.callback = callback;
|
||||
ctx.callback_data = callback_data;
|
||||
ctx.last_was_h4 = false;
|
||||
ctx.title = NULL;
|
||||
|
||||
tree_url_load_directory(ul, &ctx);
|
||||
tree_set_node_expanded(tree, root, true, false, false);
|
||||
|
||||
if (ctx.title != NULL) {
|
||||
dom_string_unref(ctx.title);
|
||||
ctx.title = NULL;
|
||||
}
|
||||
|
||||
dom_node_unref(ul);
|
||||
dom_node_unref(body);
|
||||
dom_node_unref(html);
|
||||
dom_node_unref(document);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an entry to the HTML tree for saving.
|
||||
*
|
||||
* The node must contain a sequence of node_elements in the following order:
|
||||
*
|
||||
* \param entry hotlist entry to add
|
||||
* \param fp File to write to
|
||||
* \return true on success, false on memory exhaustion
|
||||
*/
|
||||
static bool tree_url_save_entry(struct node *entry, FILE *fp)
|
||||
{
|
||||
const char *href, *text;
|
||||
char *latin1_href, *latin1_text;
|
||||
utf8_convert_ret ret;
|
||||
|
||||
text = tree_url_node_get_title(entry);
|
||||
if (text == NULL)
|
||||
return false;
|
||||
|
||||
href = tree_url_node_get_url(entry);
|
||||
if (href == NULL)
|
||||
return false;
|
||||
|
||||
ret = utf8_to_html(text, "iso-8859-1", strlen(text), &latin1_text);
|
||||
if (ret != UTF8_CONVERT_OK)
|
||||
return false;
|
||||
|
||||
ret = utf8_to_html(href, "iso-8859-1", strlen(href), &latin1_href);
|
||||
if (ret != UTF8_CONVERT_OK) {
|
||||
free(latin1_text);
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf(fp, "<li><a href=\"%s\">%s</a></li>",
|
||||
latin1_href, latin1_text);
|
||||
|
||||
free(latin1_href);
|
||||
free(latin1_text);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a directory to the HTML tree for saving.
|
||||
*
|
||||
* \param directory hotlist directory to add
|
||||
* \param fp File to write to
|
||||
* \return true on success, false on memory exhaustion
|
||||
*/
|
||||
static bool tree_url_save_directory(struct node *directory, FILE *fp)
|
||||
{
|
||||
struct node *child;
|
||||
|
||||
fputs("<ul", fp);
|
||||
if (tree_node_is_default(directory))
|
||||
fputs(" id=\"default\"", fp);
|
||||
fputc('>', fp);
|
||||
|
||||
if (tree_node_get_child(directory) != NULL)
|
||||
fputc('\n', fp);
|
||||
|
||||
for (child = tree_node_get_child(directory); child != NULL;
|
||||
child = tree_node_get_next(child)) {
|
||||
if (tree_node_is_folder(child) == false) {
|
||||
/* entry */
|
||||
if (tree_url_save_entry(child, fp) == false)
|
||||
return false;
|
||||
} else {
|
||||
/* directory */
|
||||
/* invalid HTML */
|
||||
const char *text;
|
||||
char *latin1_text;
|
||||
utf8_convert_ret ret;
|
||||
|
||||
text = tree_url_node_get_title(child);
|
||||
if (text == NULL)
|
||||
return false;
|
||||
|
||||
ret = utf8_to_html(text, "iso-8859-1",
|
||||
strlen(text), &latin1_text);
|
||||
if (ret != UTF8_CONVERT_OK)
|
||||
return false;
|
||||
|
||||
fprintf(fp, "<h4>%s</h4>\n", latin1_text);
|
||||
|
||||
free(latin1_text);
|
||||
|
||||
if (tree_url_save_directory(child, fp) == false)
|
||||
return false;
|
||||
}
|
||||
|
||||
fputc('\n', fp);
|
||||
}
|
||||
|
||||
fputs("</ul>", fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform a save to a specified file in the form of a html page
|
||||
*
|
||||
* \param filename the file to save to
|
||||
* \param page_title title of the page
|
||||
*/
|
||||
bool tree_urlfile_save(struct tree *tree, const char *filename,
|
||||
const char *page_title)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(filename, "w");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Unfortunately the Browse Hotlist format is invalid HTML,
|
||||
* so this is a lie.
|
||||
*/
|
||||
fputs("<!DOCTYPE html "
|
||||
"PUBLIC \"//W3C/DTD HTML 4.01//EN\" "
|
||||
"\"http://www.w3.org/TR/html4/strict.dtd\">\n", fp);
|
||||
fputs("<html>\n<head>\n", fp);
|
||||
fputs("<meta http-equiv=\"Content-Type\" "
|
||||
"content=\"text/html; charset=iso-8859-1\">\n", fp);
|
||||
fprintf(fp, "<title>%s</title>\n", page_title);
|
||||
fputs("</head>\n<body>", fp);
|
||||
|
||||
if (tree_url_save_directory(tree_get_root(tree), fp) == false) {
|
||||
warn_user("HotlistSaveError", 0);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs("</body>\n</html>\n", fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005 Richard Wilson <info@tinct.net>
|
||||
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Creation of URL nodes with use of trees public API
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_DESKTOP_TREE_URL_NODE_H_
|
||||
#define _NETSURF_DESKTOP_TREE_URL_NODE_H_
|
||||
|
||||
|
||||
#include "desktop/tree.h"
|
||||
#include "utils/nsurl.h"
|
||||
|
||||
struct url_data;
|
||||
|
||||
void tree_url_node_init(const char *folder_icon_name);
|
||||
void tree_url_node_cleanup(void);
|
||||
struct node *tree_create_URL_node(struct tree *tree,
|
||||
struct node *parent, nsurl *url, const char *title,
|
||||
tree_node_user_callback, void *callback_data);
|
||||
struct node *tree_create_URL_node_readonly(struct tree *tree,
|
||||
struct node *parent, nsurl *url,
|
||||
const struct url_data *data,
|
||||
tree_node_user_callback, void *callback_data);
|
||||
void tree_update_URL_node(struct tree *tree, struct node *node,
|
||||
nsurl *url, const struct url_data *data);
|
||||
const char *tree_url_node_get_title(struct node *node);
|
||||
const char *tree_url_node_get_url(struct node *node);
|
||||
struct bitmap *tree_url_node_get_icon(struct node *node);
|
||||
void tree_url_node_edit_title(struct tree *tree, struct node *node);
|
||||
void tree_url_node_edit_url(struct tree *tree, struct node *node);
|
||||
|
||||
node_callback_resp tree_url_node_callback(void *user_data,
|
||||
struct node_msg_data *msg_data);
|
||||
|
||||
bool tree_urlfile_load(const char *filename, struct tree *tree,
|
||||
tree_node_user_callback, void *callback_data);
|
||||
bool tree_urlfile_save(struct tree *tree, const char *filename,
|
||||
const char *page_title);
|
||||
|
||||
/* front end specific */
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type);
|
||||
|
||||
#endif
|
@ -17,29 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
|
||||
const char tree_directory_icon_name[] = "directory.png";
|
||||
const char tree_content_icon_name[] = "content.png";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Translates a content_type to the name of a respective icon
|
||||
*
|
||||
* \param content_type content type
|
||||
* \param buffer buffer for the icon name
|
||||
*/
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
// TODO: design/acquire icons
|
||||
switch (type) {
|
||||
case CONTENT_HTML:
|
||||
case CONTENT_TEXTPLAIN:
|
||||
case CONTENT_CSS:
|
||||
case CONTENT_IMAGE:
|
||||
default:
|
||||
sprintf(buffer, tree_content_icon_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "gtk/compat.h"
|
||||
#include "gtk/gui.h"
|
||||
@ -88,26 +87,6 @@ static void nsgtk_tree_resized(struct tree *tree, int width, int height, void *d
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a content_type to the name of a respective icon
|
||||
*
|
||||
* \param content_type content type
|
||||
* \param buffer buffer for the icon name
|
||||
*/
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
// TODO: design/acquire icons
|
||||
switch (type) {
|
||||
case CONTENT_HTML:
|
||||
case CONTENT_TEXTPLAIN:
|
||||
case CONTENT_CSS:
|
||||
case CONTENT_IMAGE:
|
||||
default:
|
||||
sprintf(buffer, tree_content_icon_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls the tree to make an element visible
|
||||
*
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "desktop/tree_url_node.h"
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "utils/url.h"
|
||||
#include "utils/utf8.h"
|
||||
@ -137,9 +135,4 @@ utf8_from_local_encoding(const char *string, size_t len,
|
||||
return (*result == NULL) ? UTF8_CONVERT_NOMEM : UTF8_CONVERT_OK;
|
||||
}
|
||||
|
||||
void
|
||||
tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
sprintf(buffer, "%s", "content.png");
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,6 @@
|
||||
#include "utils/nsoption.h"
|
||||
#include "desktop/save_complete.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "render/font.h"
|
||||
#include "riscos/content-handlers/artworks.h"
|
||||
#include "riscos/bitmap.h"
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/textinput.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
#include "riscos/bitmap.h"
|
||||
#include "riscos/dialog.h"
|
||||
#include "riscos/gui.h"
|
||||
@ -1294,25 +1293,3 @@ int ro_treeview_get_help(help_full_message_request *message_data)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a content type into an icon name.
|
||||
*
|
||||
* \todo -- Currently we don't have any icons apart from the default.
|
||||
*
|
||||
* \param *buffer A buffer to return the icon name
|
||||
* \param type The content type to return an icon name for.
|
||||
*/
|
||||
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case CONTENT_HTML:
|
||||
case CONTENT_TEXTPLAIN:
|
||||
case CONTENT_CSS:
|
||||
case CONTENT_IMAGE:
|
||||
default:
|
||||
sprintf(buffer, tree_content_icon_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,29 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/tree_url_node.h"
|
||||
|
||||
|
||||
const char tree_directory_icon_name[] = "directory.png";
|
||||
const char tree_content_icon_name[] = "content.png";
|
||||
|
||||
|
||||
/**
|
||||
* Translates a content_type to the name of a respective icon
|
||||
*
|
||||
* \param content_type content type
|
||||
* \param buffer buffer for the icon name
|
||||
*/
|
||||
void tree_icon_name_from_content_type(char *buffer, content_type type)
|
||||
{
|
||||
// TODO: design/acquire icons
|
||||
switch (type) {
|
||||
case CONTENT_HTML:
|
||||
case CONTENT_TEXTPLAIN:
|
||||
case CONTENT_CSS:
|
||||
case CONTENT_IMAGE:
|
||||
default:
|
||||
sprintf(buffer, tree_content_icon_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user