diff options
author | Ole Loots <ole@monochrom.net> | 2012-06-19 23:04:38 +0000 |
---|---|---|
committer | Ole Loots <ole@monochrom.net> | 2012-06-19 23:04:38 +0000 |
commit | cd45e1f44720a563d9b7e9b9bc7ea2b410444d3f (patch) | |
tree | 7b1faf1d89cbbe1519943f792650ca1d97bd24da /atari | |
parent | 1f3d249c157cf731bc723f865c3721f684a408a5 (diff) | |
download | netsurf-cd45e1f44720a563d9b7e9b9bc7ea2b410444d3f.tar.gz netsurf-cd45e1f44720a563d9b7e9b9bc7ea2b410444d3f.tar.bz2 |
First attempt to implement the global history treeview. There is something wrong with the redraw ( the treeview area of the windo isn't redrawn, also it looks like the treeview content size isn't set )
svn path=/trunk/netsurf/; revision=13973
Diffstat (limited to 'atari')
-rwxr-xr-x | atari/global_evnt.c | 8 | ||||
-rwxr-xr-x | atari/gui.c | 14 | ||||
-rwxr-xr-x | atari/history.c | 129 | ||||
-rwxr-xr-x | atari/history.h | 10 |
4 files changed, 147 insertions, 14 deletions
diff --git a/atari/global_evnt.c b/atari/global_evnt.c index 535fe066c..24e65b511 100755 --- a/atari/global_evnt.c +++ b/atari/global_evnt.c @@ -41,7 +41,8 @@ #include "atari/browser_win.h"
#include "atari/toolbar.h"
#include "atari/browser.h"
-#include "atari/hotlist.h"
+#include "atari/hotlist.h" +#include "atari/history.h"
#include "atari/misc.h"
#include "atari/global_evnt.h"
#include "atari/browser_win.h"
@@ -321,10 +322,7 @@ static void __CDECL menu_lhistory(WINDOW *win, int item, int title, void *data) static void __CDECL menu_ghistory(WINDOW *win, int item, int title, void *data)
{
LOG(("%s", __FUNCTION__));
- char buf[PATH_MAX];
- strcpy((char*)&buf, "file://");
- strncat((char*)&buf, nsoption_charp(url_file), PATH_MAX - (strlen("file://")+1) );
- browser_window_create((char*)&buf, 0, 0, true, false);
+ global_history_open();
}
static void __CDECL menu_add_bookmark(WINDOW *win, int item, int title, void *data)
diff --git a/atari/gui.c b/atari/gui.c index 0bfaa326b..d0039d8a9 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -489,7 +489,7 @@ void gui_window_start_throbber(struct gui_window *w) schedule(100, throbber_advance, w );
ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
-
+
rendering = true;
}
@@ -505,14 +505,14 @@ void gui_window_stop_throbber(struct gui_window *w) /* refresh toolbar buttons: */
tb_update_buttons( w, -1 );
-
+
/* redraw throbber: */
mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
WF_WORKXYWH, &work);
- w->root->toolbar->throbber.running = false;
+ w->root->toolbar->throbber.running = false;
ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
-
+
rendering = false;
}
@@ -811,7 +811,8 @@ void gui_quit(void) browser_window_destroy(gw->browser->bw);
gw = tmp;
}
-
+ + global_history_destroy();
hotlist_destroy();
toolbar_exit(); @@ -981,7 +982,8 @@ static void gui_init2(int argc, char** argv) if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
menu_register( _AESapid, (char*)" NetSurf ");
}
- tree_set_icon_dir( nsoption_charp(tree_icons_path) );
+ tree_set_icon_dir( nsoption_charp(tree_icons_path) ); + global_history_init();
hotlist_init(); toolbar_init();
}
diff --git a/atari/history.c b/atari/history.c index 36edcda00..ee47edeba 100755 --- a/atari/history.c +++ b/atari/history.c @@ -16,16 +16,139 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "content/urldb.h" +#include <string.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include "desktop/browser.h" +#include "desktop/options.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" +#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" + +extern char * tree_directory_icon_name; + +struct s_atari_global_history {
+ WINDOW * window;
+ NSTREEVIEW tv; /*< The history treeview handle. */
+ bool open;
+ bool init;
+}; -void global_history_add_recent(const char *url) +static struct s_atari_global_history gl_history; + + + +void global_history_add_recent( const char *url ) { } -char **global_history_get_recent(int *count) +char **global_history_get_recent( int *count ) { return NULL; } + +void global_history_open( void ) +{ + if( gl_history.init == false ) { + printf("history not init"); + return; + } + if( gl_history.open == false ) { + WindOpen( gl_history.window, -1, -1, app.w/3, app.h/2); + gl_history.open = true; + atari_treeview_open( gl_history.tv ); + } else { + WindTop( gl_history.window ); + } +} + +void global_history_close( void ) +{ + WindClose(gl_history.window); + gl_history.open = false; + atari_treeview_close( gl_history.tv ); +} + + +static void __CDECL evnt_history_close( WINDOW *win, short buff[8] ) +{ + global_history_close(); +} + + +static void __CDECL evnt_history_mbutton( WINDOW *win, short buff[8] ) +{ + /* todo: implement popup? + if(evnt.mbut & 2) { + + } + */ +} + +bool global_history_init( void ) +{ + + if( gl_history.init == false ) { + + int flags = ATARI_TREEVIEW_WIDGETS; + gl_history.open = false; + gl_history.window = WindCreate( flags, 40, 40, app.w, app.h ); + if( gl_history.window == NULL ) { + LOG(("Failed to allocate history window")); + return( false ); + } + /* TODO: load hotlist strings from messages */ + WindSetStr( gl_history.window, WF_NAME, (char*)"History" ); + //WindSetPtr( gl_history.window, WF_TOOLBAR, tree, evnt_history_toolbar ); + EvntAttach( gl_history.window, WM_CLOSED, evnt_history_close ); + EvntAttach( gl_history.window, WM_XBUTTON,evnt_history_mbutton ); + + gl_history.tv = atari_treeview_create( + history_global_get_tree_flags(), + gl_history.window + ); + if (gl_history.tv == NULL) { + /* handle it properly, clean up previous allocs */ + LOG(("Failed to allocate history treeview")); + return( false ); + } + + history_global_initialise( gl_history.tv->tree, "dir.png" ); + gl_history.init = true; + } + return( true ); +} + + +void global_history_destroy( void ) +{ + if( gl_history.init == false ) { + return; + } + if( gl_history.window != NULL ) { + history_global_cleanup(); + if( gl_history.open ) + global_history_close(); + WindDelete( gl_history.window ); + gl_history.window = NULL; + atari_treeview_destroy( gl_history.tv ); + gl_history.init = false; + } + LOG(("done")); +} + + diff --git a/atari/history.h b/atari/history.h index 5899e4cf9..0dd571d01 100755 --- a/atari/history.h +++ b/atari/history.h @@ -19,4 +19,14 @@ #ifndef NS_ATARI_HISTORY_H #define NS_ATARI_HISTORY_H +#include <stdbool.h>
+#include <windom.h>
+#include "desktop/tree.h"
+#include "atari/treeview.h" + +bool global_history_init( void ); +void global_history_destroy( void ); +void global_history_open( void ); +void global_history_close( void ); + #endif |