From 8057dc67cb11c865cb5daf2142fbef35631e7c6d Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Mon, 16 Sep 2013 02:26:43 +0200 Subject: Replaced atari_treeview wrapper with a new one (removed all modules which used the old tree API) --- atari/history.c | 183 +++++--------------------------------------------------- 1 file changed, 16 insertions(+), 167 deletions(-) mode change 100755 => 100644 atari/history.c (limited to 'atari/history.c') diff --git a/atari/history.c b/atari/history.c old mode 100755 new mode 100644 index 6da8eebce..dfed6d037 --- a/atari/history.c +++ b/atari/history.c @@ -1,168 +1,17 @@ -/* - * Copyright 2010 Ole Loots - * - * 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 . +/* + * Copyright 2013 Ole Loots + * + * 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 . */ - -#include -#include -#include -#include -#include -#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 ) -{ - 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 ); -} - -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 ); -} - - -- cgit v1.2.3