Removed old treeview files

This commit is contained in:
Ole Loots 2013-09-25 20:28:20 +02:00
parent c1085580ed
commit 7f92060041
4 changed files with 0 additions and 487 deletions

View File

@ -1,170 +0,0 @@
/*
* Copyright 2010 Ole Loots <ole@monochrom.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/>.
*/
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "desktop/browser.h"
#include "utils/nsoption.h"
#include "desktop/tree.h"
#include "desktop/gui.h"
#include "desktop/global_history.h"
#include "desktop/browser.h"
#include "utils/messages.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "utils/log.h"
#include "atari/treeview.h"
#include "atari/findfile.h"
#include "atari/res/netsurf.rsh"
#include "atari/history.h"
//TODO: remove/add guiwin handle on close / open - so that the list
// is kept tiny.
extern GRECT desk_area;
struct s_atari_global_history gl_history;
void atari_global_history_open( void )
{
/* TODO: call this in gui.c and move global_history_init() into history.c */
atari_global_history_init();
if (gl_history.init == false ) {
return;
}
if( gl_history.open == false ) {
GRECT pos;
wind_get_grect(0, WF_WORKXYWH, &pos);
pos.g_x = desk_area.g_w - desk_area.g_w / 4;
pos.g_y = desk_area.g_y;
pos.g_w = desk_area.g_w / 4;
pos.g_h = desk_area.g_h;
wind_open(gemtk_wm_get_handle(gl_history.window), pos.g_x, pos.g_y,
pos.g_w, pos.g_h);
gl_history.open = true;
atari_treeview_open(gl_history.tv);
} else {
wind_set(gemtk_wm_get_handle(gl_history.window), WF_TOP, 1, 0, 0, 0);
}
}
void atari_global_history_close( void )
{
wind_close(gemtk_wm_get_handle(gl_history.window));
gl_history.open = false;
atari_treeview_close(gl_history.tv);
}
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
NSTREEVIEW tv=NULL;
//printf("Hotlist event %d, open: %d\n", ev_out->emo_events, gl_history.open);
if(ev_out->emo_events & MU_MESAG){
switch (msg[0]) {
case WM_CLOSED:
atari_global_history_close();
break;
default: break;
}
}
// TODO: implement selectable objects in toolbar API:
// ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
/* TODO: add call to global_history_init() */
bool atari_global_history_init( void )
{
if( gl_history.init == false ) {
short handle;
GRECT desk;
int flags = ATARI_TREEVIEW_WIDGETS;
// initialize state options:
gl_history.open = false;
// Create an AES window:
handle = wind_create(flags, 40, 40, desk_area.g_w, desk_area.g_h);
// add the AES window to the gemtk window manager:
gl_history.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
if( gl_history.window == NULL ) {
LOG(("Failed to allocate history window"));
return( false );
}
// Set window title:
wind_set_str(handle, WF_NAME, (char*)messages_get("GlobalHistory"));
// Make the window part of the netsurf treeview framework:
gl_history.tv = atari_treeview_create(TREE_HISTORY,
gl_history.window, handle_event);
gemtk_wm_unlink(gl_history.window);
if (gl_history.tv == NULL) {
/* TODO: handle it properly, clean up previous allocs */
LOG(("Failed to allocate history treeview"));
return( false );
}
gl_history.init = true;
}
return( true );
}
void atari_global_history_destroy( void )
{
if( gl_history.init == false ) {
return;
}
if( gl_history.window != NULL ) {
if( gl_history.open )
atari_global_history_close();
wind_delete(gemtk_wm_get_handle(gl_history.window));
gemtk_wm_remove(gl_history.window);
gl_history.window = NULL;
atari_treeview_destroy(gl_history.tv);
gl_history.init = false;
}
LOG(("done"));
}
void atari_global_history_redraw( void )
{
atari_treeview_redraw( gl_history.tv );
}

View File

@ -1,45 +0,0 @@
/*
* Copyright 2010 Ole Loots <ole@monochrom.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/>.
*/
#ifndef NS_ATARI_HISTORY_H
#define NS_ATARI_HISTORY_H
#include <stdbool.h>
#include "desktop/tree.h"
#include "atari/treeview.h"
#include "atari/gemtk/gemtk.h"
struct s_atari_global_history {
GUIWIN *window; /*< The GEMTK window ref */
NSTREEVIEW tv; /*< The history treeview handle. */
bool open;
bool init;
};
extern struct s_atari_global_history gl_history;
bool atari_global_history_init( void );
void atari_global_history_destroy( void );
void atari_global_history_open( void );
void atari_global_history_close( void );
void atari_global_history_redraw( void );
#endif

View File

@ -1,226 +0,0 @@
/*
* Copyright 2010 Ole Loots <ole@monochrom.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/>.
*/
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "desktop/browser.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "utils/nsoption.h"
#include "desktop/hotlist.h"
#include "desktop/tree.h"
#include "desktop/gui.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
#include "atari/gui.h"
#include "atari/misc.h"
#include "atari/treeview.h"
#include "atari/hotlist.h"
#include "atari/findfile.h"
#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
extern GRECT desk_area;
struct atari_hotlist hl;
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
NSTREEVIEW tv=NULL;
GRECT tb_area;
if(ev_out->emo_events & MU_MESAG){
switch (msg[0]) {
case WM_TOOLBAR:
tv = (NSTREEVIEW) gemtk_wm_get_user_data(win);
switch (msg[4]) {
case TOOLBAR_HOTLIST_CREATE_FOLDER:
hotlist_add_folder(NULL, false, 0);
break;
case TOOLBAR_HOTLIST_ADD:
atari_hotlist_add_page(NULL, NULL);
break;
case TOOLBAR_HOTLIST_DELETE:
hotlist_keypress(KEY_DELETE_LEFT);
gemtk_wm_exec_redraw(tv->window, NULL);
break;
case TOOLBAR_HOTLIST_EDIT:
hotlist_edit_selection();
break;
}
gemtk_obj_get_tree(TOOLBAR_HOTLIST)[msg[4]].ob_state &= ~OS_SELECTED;
gemtk_wm_get_grect(tv->window, GEMTK_WM_AREA_TOOLBAR, &tb_area);
evnt_timer(150);
gemtk_wm_exec_redraw(tv->window, &tb_area);
break;
case WM_CLOSED:
atari_hotlist_close();
break;
default: break;
}
}
// TODO: implement selectable objects in toolbar API:
// ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
void atari_hotlist_init(void)
{
if (hl.init == false) {
if( strcmp(nsoption_charp(hotlist_file), "") == 0 ){
atari_find_resource( (char*)&hl.path, "hotlist", "hotlist" );
} else {
strncpy( (char*)&hl.path, nsoption_charp(hotlist_file), PATH_MAX-1 );
}
LOG(("Hotlist: %s", (char*)&hl.path ));
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
short handle = -1;
GRECT desk;
OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_HOTLIST);
assert( tree );
hl.open = false;
handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
hl.window = gemtk_wm_add(handle, GEMTK_WM_FLAG_DEFAULTS, NULL);
if( hl.window == NULL ) {
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
"Failed to allocate Hotlist");
return;
}
wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist"));
gemtk_wm_set_toolbar(hl.window, tree, 0, 0);
gemtk_wm_unlink(hl.window);
tree_hotlist_path = (const char*)&hl.path;
hl.tv = atari_treeview_create(
TREE_HOTLIST,
hl.window,
handle_event
);
if (hl.tv == NULL) {
/* handle it properly, clean up previous allocs */
LOG(("Failed to allocate treeview"));
return;
}
} else {
}
}
hl.init = true;
}
void atari_hotlist_open(void)
{
if( hl.init == false ) {
return;
}
if( hl.open == false ) {
GRECT pos;
pos.g_x = desk_area.g_w - desk_area.g_w / 4;
pos.g_y = desk_area.g_y;
pos.g_w = desk_area.g_w / 4;
pos.g_h = desk_area.g_h;
wind_open_grect(gemtk_wm_get_handle(hl.window), &pos);
hl.open = true;
atari_treeview_open( hl.tv );
} else {
wind_set(gemtk_wm_get_handle(hl.window), WF_TOP, 1, 0, 0, 0);
}
}
void atari_hotlist_close(void)
{
wind_close(gemtk_wm_get_handle(hl.window));
hl.open = false;
atari_treeview_close(hl.tv);
}
void atari_hotlist_destroy(void)
{
if( hl.init == false) {
return;
}
if( hl.window != NULL ) {
if (hl.open)
atari_hotlist_close();
wind_delete(gemtk_wm_get_handle(hl.window));
gemtk_wm_remove(hl.window);
hl.window = NULL;
atari_treeview_destroy(hl.tv);
hl.init = false;
}
LOG(("done"));
}
void atari_hotlist_redraw(void)
{
int i = 01;
atari_treeview_redraw(hl.tv);
}
struct node;
void atari_hotlist_add_page( const char * url, const char * title )
{
struct node * root;
struct node * selected = NULL;
struct node * folder = NULL;
nsurl *nsurl;
NSTREEVIEW tv = hl.tv;
if(hl.tv == NULL )
return;
atari_hotlist_open();
if (nsurl_create(url, &nsurl) != NSERROR_OK)
return;
if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){
hotlist_add_entry( nsurl, title, true, hl.tv->click.y );
} else {
hotlist_add_url( nsurl );
}
nsurl_unref(nsurl);
}

View File

@ -1,46 +0,0 @@
/*
* Copyright 2010 Ole Loots <ole@monochrom.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/>.
*/
#ifndef NS_ATARI_HOTLIST_H
#define NS_ATARI_HOTLIST_H
#include <stdbool.h>
#include "desktop/tree.h"
#include "atari/gemtk/gemtk.h"
#include "atari/treeview.h"
/* The hotlist window, toolbar and treeview data. */
struct atari_hotlist {
GUIWIN * window;
NSTREEVIEW tv; /*< The hotlist treeview handle. */
bool open;
bool init;
char path[PATH_MAX];
};
extern struct atari_hotlist hl;
void atari_hotlist_init( void );
void atari_hotlist_open( void );
void atari_hotlist_close( void );
void atari_hotlist_destroy( void );
void atari_hotlist_add_page( const char * url, const char * title );
void atari_hotlist_redraw( void );
#endif