summaryrefslogtreecommitdiff
path: root/atari/hotlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'atari/hotlist.c')
-rwxr-xr-xatari/hotlist.c189
1 files changed, 115 insertions, 74 deletions
diff --git a/atari/hotlist.c b/atari/hotlist.c
index bdd10d922..3684a9a85 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+
#include "desktop/browser.h"
#include "content/content.h"
#include "content/hlcache.h"
@@ -40,91 +41,115 @@
#include "atari/treeview.h"
#include "atari/hotlist.h"
#include "atari/findfile.h"
+#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;
-static void evnt_hl_toolbar( WINDOW *win, short buff[8]) {
- /* handle toolbar object (index in buff[4] ) */
- switch( buff[4] ) {
- case TOOLBAR_HOTLIST_CREATE_FOLDER:
- hotlist_add_folder(true);
- break;
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
+ NSTREEVIEW tv=NULL;
+ GRECT tb_area;
- case TOOLBAR_HOTLIST_ADD:
- atari_hotlist_add_page("http://www.de", "");
- break;
+ if(ev_out->emo_events & MU_MESAG){
+ switch (msg[0]) {
- case TOOLBAR_HOTLIST_DELETE:
- hotlist_delete_selected();
- break;
+ case WM_TOOLBAR:
- case TOOLBAR_HOTLIST_EDIT:
- hotlist_edit_selected();
- break;
- }
- ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
-}
+ tv = (NSTREEVIEW) gemtk_wm_get_user_data(win);
+ switch (msg[4]) {
+ case TOOLBAR_HOTLIST_CREATE_FOLDER:
+ hotlist_add_folder(true);
+ break;
-static void __CDECL evnt_hl_close( WINDOW *win, short buff[8] )
-{
- hotlist_close();
-}
+ case TOOLBAR_HOTLIST_ADD:
+ atari_hotlist_add_page("http://www.de", "");
+ break;
+ case TOOLBAR_HOTLIST_DELETE:
+ hotlist_delete_selected();
+ gemtk_wm_send_redraw(tv->window, NULL);
+ break;
-static void __CDECL evnt_hl_mbutton( WINDOW *win, short buff[8] )
-{
- /* todo: implement popup?
- if(evnt.mbut & 2) {
+ case TOOLBAR_HOTLIST_EDIT:
+ hotlist_edit_selected();
+ 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_send_redraw(tv->window, &tb_area);
+ break;
+ case WM_CLOSED:
+ hotlist_close();
+ break;
+
+ default: break;
+ }
}
- */
+
+ // TODO: implement selectable objects in toolbar API:
+ // ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
+
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;
- OBJECT * tree = get_tree(TOOLBAR_HOTLIST);
- assert( tree );
- hl.open = false;
- hl.window = WindCreate( flags, 40, 40, app.w, app.h );
- if( hl.window == NULL ) {
- LOG(("Failed to allocate Hotlist"));
- return;
- }
- WindSetStr( hl.window, WF_NAME, (char*)messages_get("Hotlist") );
- WindSetPtr( hl.window, WF_TOOLBAR, tree, evnt_hl_toolbar );
- EvntAttach( hl.window, WM_CLOSED, evnt_hl_close );
- EvntAttach( hl.window, WM_XBUTTON,evnt_hl_mbutton );
- hl.tv = atari_treeview_create(
- hotlist_get_tree_flags(),
- hl.window
- );
- if (hl.tv == NULL) {
- /* handle it properly, clean up previous allocs */
- LOG(("Failed to allocate treeview"));
- 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 );
}
- 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 = 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 ) {
+ LOG(("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);
+ 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;
}
@@ -132,45 +157,59 @@ void hotlist_init(void)
void hotlist_open(void)
{
- GRECT pos = {app.w - (app.w/3), app.y, app.w/3, app.h/2};
-
+ hotlist_init();
if( hl.init == false ) {
return;
}
if( hl.open == false ) {
- WindOpen( hl.window, pos.g_x, pos.g_y, pos.g_w, pos.g_h);
+
+ 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 {
- WindTop( hl.window );
+ wind_set(gemtk_wm_get_handle(hl.window), WF_TOP, 1, 0, 0, 0);
}
}
void hotlist_close(void)
{
- WindClose(hl.window);
+ wind_close(gemtk_wm_get_handle(hl.window));
hl.open = false;
- atari_treeview_close( hl.tv );
+ atari_treeview_close(hl.tv);
}
void hotlist_destroy(void)
{
- 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();
- WindDelete( hl.window );
+ wind_delete(gemtk_wm_get_handle(hl.window));
+ gemtk_wm_remove(hl.window);
hl.window = NULL;
- atari_treeview_destroy( hl.tv );
+ atari_treeview_destroy(hl.tv);
hl.init = false;
}
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 )
@@ -181,6 +220,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 {