Beispiel #1
0
/**
 * 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)
{
	xmlDoc *doc;
	xmlNode *html, *body, *ul;
	struct node *root;
	FILE *fp = NULL;

	if (filename == NULL) {
		return false;
	}

	fp = fopen(filename, "r");
	if (fp == NULL) {
		return false;
	}
	fclose(fp);

	doc = htmlParseFile(filename, "iso-8859-1");
	if (doc == NULL) {
		warn_user("TreeLoadError", messages_get("ParsingFail"));
		return false;
	}

	html = tree_url_find_xml_element((xmlNode *) doc, "html");
	body = tree_url_find_xml_element(html, "body");
	ul = tree_url_find_xml_element(body, "ul");
	if (ul == NULL) {
		xmlFreeDoc(doc);
		warn_user("TreeLoadError",
			  "(<html>...<body>...<ul> not found.)");
		return false;
	}

	root = tree_get_root(tree);
	tree_url_load_directory(ul, tree, root, callback, callback_data);
	tree_set_node_expanded(tree, root, true, false, false);

	xmlFreeDoc(doc);
	return true;
}
/**
 * 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;
	struct node *parent = NULL;
	struct node *link;
	struct node *node;
	bool before = false;
	int visit_date;

	assert(url && data);

	visit_date = data->last_visit;

	/* find parent node */
	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;
		}
	}

	/* the entry is too old to care about */
	if (!parent)
		return true;

	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;
			}
		}

		tree_set_node_selected(global_history_tree,
		 		parent, false);
		tree_set_node_expanded(global_history_tree,
		  		parent, false);
		tree_link_node(link, parent, before);

		if (!global_history_init) {
		  	tree_recalculate_node(global_history_tree, parent, true);
		  	tree_recalculate_node_positions(global_history_tree,
		  			global_history_tree->root);
			tree_redraw_area(global_history_tree,
					0, 0, 16384, 16384);
		}
	}

	/* 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 */
			tree_redraw_area(global_history_tree,
					0, 0, 16384, 16384);
			tree_update_URL_node(node, url, data);
			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 true;
		}
	}

	/* Add the node at the bottom */
	node = tree_create_URL_node_shared(parent, url, data);
	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);
	}

	return true;
}
Beispiel #3
0
BOOL ami_tree_event(struct treeview_window *twin)
{
	/* return TRUE if window destroyed */
	ULONG class,result,relevent = 0;
	ULONG column;
	uint16 code;
	struct MenuItem *item;
	struct node *treenode;
	struct Node *lbnode;
	struct node_element *element;
	char *text;
//	ULONG editcols[] = {TREE_ELEMENT_TITLE,TREE_ELEMENT_URL};
	static WORD gen=0;

	while((result = RA_HandleInput(twin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
	{
       	switch(result & WMHI_CLASSMASK) // class
   		{
			case WMHI_GADGETUP:
				switch(result & WMHI_GADGETMASK)
				{
					case GID_TREEBROWSER:
						GetAttrs(twin->gadgets[GID_TREEBROWSER],
							LISTBROWSER_RelEvent,&relevent,
							TAG_DONE);

							switch(relevent)
						{
							case LBRE_DOUBLECLICK:
								GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
								GetListBrowserNodeAttrs(lbnode,
									LBNA_UserData,(ULONG *)&treenode,
									TAG_DONE);
								ami_tree_launch_node(twin->tree,treenode);
							break;

							case LBRE_EDIT:
								GetAttrs(twin->gadgets[GID_TREEBROWSER],
									LISTBROWSER_SelectedNode,(ULONG *)&lbnode,
//									LISTBROWSER_RelColumn,(ULONG *)&column,
									TAG_DONE);

								GetListBrowserNodeAttrs(lbnode,
									LBNA_UserData,(ULONG *)&treenode,
									TAG_DONE);

								element = tree_find_element(treenode,TREE_ELEMENT_TITLE);
								GetListBrowserNodeAttrs(lbnode,
									LBNA_Column,column,
									LBNCA_Text,(ULONG *)&text,
									TAG_DONE);
								element->text = (char *)strdup(text);
								tree_handle_node_element_changed(twin->tree, element);
							break;

							case LBRE_HIDECHILDREN:
								GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
								GetListBrowserNodeAttrs(lbnode,
									LBNA_UserData,(ULONG *)&treenode,
									TAG_DONE);
								tree_set_node_expanded(twin->tree, treenode, false);
							break;

							case LBRE_SHOWCHILDREN:
								GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
								GetListBrowserNodeAttrs(lbnode,
									LBNA_UserData,(ULONG *)&treenode,
									TAG_DONE);
								tree_set_node_expanded(twin->tree, treenode, true);
							break;
						}
					break;

					case GID_OPEN:
						GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
						GetListBrowserNodeAttrs(lbnode,
							LBNA_UserData,(ULONG *)&treenode,
							TAG_DONE);
						ami_tree_launch_node(twin->tree,treenode);
					break;

					case GID_NEWF:
						GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
						if(lbnode)
						{
							GetListBrowserNodeAttrs(lbnode,
								LBNA_UserData,(ULONG *)&treenode,
								TAG_DONE);
						}
						else
						{
							treenode = twin->tree->root;
						}

						tree_create_folder_node(treenode,(char *)messages_get("TreeNewFolder"));

						ami_recreate_listbrowser(twin);
					break;

					case GID_NEWB:
						ami_new_bookmark(twin);
					break;

					case GID_UP:
						ami_move_node(twin,AMI_MOVE_UP);
					break;

					case GID_DOWN:
						ami_move_node(twin,AMI_MOVE_DOWN);
					break;

					case GID_LEFT:
						ami_move_node(twin,AMI_MOVE_OUT);
					break;

					case GID_DEL:
						GetAttr(LISTBROWSER_SelectedNode,twin->gadgets[GID_TREEBROWSER],(ULONG *)&lbnode);
						GetListBrowserNodeAttrs(lbnode,
							LBNA_UserData,(ULONG *)&treenode,
							TAG_DONE);
						tree_delete_node(twin->tree, treenode, false);
/* We are recreating the list from scratch as there is no obvious easy way
   to delete children from a listbrowser list */
						ami_recreate_listbrowser(twin);
					break;
				}
			break;

/* no menus yet, copied in as will probably need it later
			case WMHI_MENUPICK:
				item = ItemAddress(gwin->win->MenuStrip,code);
				while (code != MENUNULL)
				{
					ami_menupick(code,gwin);
					if(win_destroyed) break;
					code = item->NextSelect;
				}
			break;
*/

			case WMHI_CLOSEWINDOW:
				ami_tree_close(twin);
				return TRUE;
			break;
		}
	}
	return FALSE;
}
Beispiel #4
0
/**
 * Collapse history entries only.
 */
void hotlist_collapse_addresses(void)
{
	tree_set_node_expanded(hotlist_tree, 
			       hotlist_tree_root, false, false, true);
}
Beispiel #5
0
/**
 * Collapse grouping folders only.
 */
void hotlist_collapse_directories(void)
{
	tree_set_node_expanded(hotlist_tree, hotlist_tree_root,
			       false, true, false);
}
Beispiel #6
0
/**
 * Expand grouping folders and history entries.
 */
void hotlist_expand_all(void)
{
	tree_set_node_expanded(hotlist_tree, hotlist_tree_root,
			       true, true, true);
}