/*  Copyright (C) 2001-2002  Kenichi Suto
 *
 *  This program 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; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/


#include "defs.h"
#include "global.h"
#include "dictheading.h"

extern GList *group_list;

void show_menu()
{
	EB_Position pos;
	SEARCH_RESULT *rp;
	BOOK_INFO *binfo;
	DICT_GROUP *group;
	DICT_MEMBER *member;
	GList *group_item;
	GList *member_item=NULL;

	clear_tree(tree_root);
	clear_search_result();

	group_item = g_list_first(group_list);
	while(group_item != NULL){
		group = (DICT_GROUP *)(group_item->data);
		if(group->active == TRUE){
			member_item = group->member;
			break;
		}
		group_item = g_list_next(group_item);
	}

	for( ; member_item != NULL ; member_item = g_list_next(member_item)){
		member = (DICT_MEMBER *)(member_item->data);
		if(member->active != TRUE) {
			continue;
		}
		binfo = member->binfo;

		if(binfo->search_method[SEARCH_METHOD_MENU] != TRUE)
			continue;
		ebook_menu(binfo, &pos);
		rp = (SEARCH_RESULT *)calloc(sizeof(SEARCH_RESULT), 1);
		rp->book_info = binfo;
		rp->heading = strdup(_("menu"));
		rp->pos_text = pos;
		search_result = g_list_append(search_result, rp);
	}
	show_result_tree();
}

void show_copyright()
{
	EB_Position pos;
	SEARCH_RESULT *rp;
	BOOK_INFO *binfo;
	DICT_GROUP *group;
	DICT_MEMBER *member;
	GList *group_item;
	GList *member_item=NULL;

	clear_tree(tree_root);
	clear_search_result();

	group_item = g_list_first(group_list);
	while(group_item != NULL){
		group = (DICT_GROUP *)(group_item->data);
		if(group->active == TRUE){
			member_item = group->member;
			break;
		}
		group_item = g_list_next(group_item);
	}

	for( ; member_item != NULL ; member_item = g_list_next(member_item)){
		member = (DICT_MEMBER *)(member_item->data);
		if(member->active != TRUE) {
			continue;
		}
		binfo = member->binfo;
		if(binfo->search_method[SEARCH_METHOD_COPYRIGHT] != TRUE)
			continue;
		ebook_copyright(binfo, &pos);
		rp = (SEARCH_RESULT *)calloc(sizeof(SEARCH_RESULT), 1);
		rp->book_info = binfo;
		rp->heading = strdup(_("copyright"));
		rp->pos_text = pos;
		search_result = g_list_append(search_result, rp);
	}
	show_result_tree();
}


syntax highlighted by Code2HTML, v. 0.9.1