summaryrefslogtreecommitdiff
path: root/atari/hotlist.c
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-12-21 00:56:50 +0100
committerOle Loots <ole@monochrom.net>2012-12-21 00:56:50 +0100
commitf7ee2a03876bf4a5cf66b3a433955e4e55d91362 (patch)
tree146748923e9aaa464fac29306cc51cb06ef589ec /atari/hotlist.c
parent3019368c93600a335445c09178c9554074c7f656 (diff)
downloadnetsurf-f7ee2a03876bf4a5cf66b3a433955e4e55d91362.tar.gz
netsurf-f7ee2a03876bf4a5cf66b3a433955e4e55d91362.tar.bz2
- started to work on settings dialog
- some WIP in treeview widgets. Changed destroy / and init handling. It requires some optimization, when the widget is closed it must remove itself from the guiwin list, for perfomance.
Diffstat (limited to 'atari/hotlist.c')
-rwxr-xr-xatari/hotlist.c105
1 files changed, 57 insertions, 48 deletions
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 66e7560ea..ccba088a6 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -44,6 +44,9 @@
#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
+//TODO: remove/add guiwin handle on close / open - so that the list
+// is kept tiny.
+
extern GRECT desk_area;
struct atari_hotlist hl;
@@ -86,7 +89,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
break;
case WM_CLOSED:
- hotlist_close();
+ hotlist_destroy();
break;
default: break;
@@ -101,49 +104,51 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
void hotlist_init(void)
{
- 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 = 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 = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
- if( hl.window == NULL ) {
- LOG(("Failed to allocate Hotlist"));
- return;
+ 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 );
}
- wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist"));
- guiwin_set_toolbar(hl.window, tree, 0, 0);
- hl.tv = atari_treeview_create(
- hotlist_get_tree_flags(),
- hl.window,
- handle_event
- );
- if (hl.tv == NULL) {
- /* handle it properly, clean up previous allocs */
- LOG(("Failed to allocate treeview"));
- return;
- }
-
- hotlist_initialise(
- hl.tv->tree,
- (char*)&hl.path,
- "dir.png"
- );
- } else {
+ LOG(("Hotlist: %s", (char*)&hl.path ));
+
+ if( hl.window == NULL ){
+ int flags = ATARI_TREEVIEW_WIDGETS;
+ short handle = -1;
+ GRECT desk;
+ OBJECT * tree = 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 = guiwin_add(handle, GW_FLAG_DEFAULTS, NULL);
+ if( hl.window == NULL ) {
+ LOG(("Failed to allocate Hotlist"));
+ return;
+ }
+ wind_set_str(handle, WF_NAME, (char*)messages_get("Hotlist"));
+ guiwin_set_toolbar(hl.window, tree, 0, 0);
+ hl.tv = atari_treeview_create(
+ hotlist_get_tree_flags(),
+ hl.window,
+ handle_event
+ );
+ if (hl.tv == NULL) {
+ /* handle it properly, clean up previous allocs */
+ LOG(("Failed to allocate treeview"));
+ return;
+ }
+
+ hotlist_initialise(
+ hl.tv->tree,
+ (char*)&hl.path,
+ "dir.png"
+ );
+
+ } else {
+ }
}
hl.init = true;
}
@@ -151,6 +156,7 @@ void hotlist_init(void)
void hotlist_open(void)
{
+ hotlist_init();
if( hl.init == false ) {
return;
}
@@ -181,17 +187,12 @@ void hotlist_close(void)
void hotlist_destroy(void)
{
-void hotlist_redraw(void)
-{
- int i = 01;
- atari_treeview_redraw(hl.tv);
-}
- if( hl.init == false ) {
+ if( hl.init == false) {
return;
}
if( hl.window != NULL ) {
hotlist_cleanup( (char*)&hl.path );
- if( hl.open )
+ if (hl.open)
hotlist_close();
wind_delete(guiwin_get_handle(hl.window));
guiwin_remove(hl.window);
@@ -202,6 +203,12 @@ void hotlist_redraw(void)
LOG(("done"));
}
+void hotlist_redraw(void)
+{
+ int i = 01;
+ atari_treeview_redraw(hl.tv);
+}
+
struct node;
void atari_hotlist_add_page( const char * url, const char * title )
@@ -212,6 +219,8 @@ void atari_hotlist_add_page( const char * url, const char * title )
NSTREEVIEW tv = hl.tv;
if(hl.tv == NULL )
return;
+ // TODO: do no open hotlist, and remove guiwin on close...
+ hotlist_open();
if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){
hotlist_add_page_xy( url, hl.tv->click.x, hl.tv->click.y );
} else {