From 47379c04442c805af95ba16b9932fbdb549a7594 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Fri, 30 Dec 2016 13:06:42 +0000 Subject: Update treeviews to use event callback --- frontends/amiga/gui.c | 24 ++++++++++++++---------- frontends/amiga/gui.h | 4 ++-- frontends/amiga/search.c | 4 ++-- frontends/amiga/tree.c | 20 ++++++++++++++------ frontends/amiga/tree.h | 3 +-- 5 files changed, 33 insertions(+), 22 deletions(-) (limited to 'frontends') diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index ad00557b2..e55e1da2a 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -1925,7 +1925,7 @@ static void ami_handle_msg(void) w = node->objstruct; if(node->Type == AMINS_TVWINDOW) { - if(ami_tree_event((struct treeview_window *)w)) { + if(w->tbl->event(w)) { ami_try_quit(); break; } else { @@ -2957,7 +2957,7 @@ void ami_quit_netsurf(void) { struct nsObject *node; struct nsObject *nnode; - struct gui_window_2 *gwin; + struct ami_generic_window *w; /* Disable the multiple tabs open warning */ nsoption_set_bool(tab_close_warn, false); @@ -2967,18 +2967,18 @@ void ami_quit_netsurf(void) do { nnode=(struct nsObject *)GetSucc((struct Node *)node); - gwin = node->objstruct; + w = node->objstruct; switch(node->Type) { case AMINS_TVWINDOW: - ami_tree_close((struct treeview_window *)gwin); + w->tbl->close(w); break; case AMINS_WINDOW: /* This also closes windows that are attached to the * gui_window, such as local history and find. */ - ShowWindow(gwin->win, WINDOW_BACKMOST); // do we need this?? - gwin->w.tbl->close(gwin); + //ShowWindow(gwin->win, WINDOW_BACKMOST); // do we need this?? + w->tbl->close(w); break; case AMINS_GUIOPTSWINDOW: @@ -2986,7 +2986,7 @@ void ami_quit_netsurf(void) break; case AMINS_DLWINDOW: - ami_download_window_abort((struct gui_download_window *)gwin); + ami_download_window_abort((struct gui_download_window *)w); break; } } while((node = nnode)); @@ -3828,7 +3828,7 @@ HOOKF(void, ami_scroller_hook, Object *, object, struct IntuiMessage *) } /* exported function documented in gui.h */ -nserror ami_gui_win_list_add(void *win, int type, struct ami_win_event_table *table) +nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table) { struct nsObject *node = AddObject(window_list, type); if(node == NULL) return NSERROR_NOMEM; @@ -3846,10 +3846,14 @@ void ami_gui_win_list_remove(void *win) { struct ami_generic_window *w = (struct ami_generic_window *)win; - DelObject(w->node); + if(w->node->Type == AMINS_TVWINDOW) { + DelObjectNoFree(w->node); + } else { + DelObject(w->node); + } } -static struct ami_win_event_table ami_gui_table = { +static const struct ami_win_event_table ami_gui_table = { ami_gui_event, ami_gui_close_window, }; diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h index da60c6749..b76efdce4 100644 --- a/frontends/amiga/gui.h +++ b/frontends/amiga/gui.h @@ -107,7 +107,7 @@ struct ami_win_event_table { struct ami_generic_window { struct nsObject *node; - struct ami_win_event_table *tbl; + const struct ami_win_event_table *tbl; }; struct gui_window_2 { @@ -276,7 +276,7 @@ void ami_gui_switch_to_new_tab(struct gui_window_2 *gwin); /** * Add a window to the NetSurf window list (to enable event processing) */ -nserror ami_gui_win_list_add(void *win, int type, struct ami_win_event_table *table); +nserror ami_gui_win_list_add(void *win, int type, const struct ami_win_event_table *table); /** * Remove a window from the NetSurf window list diff --git a/frontends/amiga/search.c b/frontends/amiga/search.c index 7e2b9a45a..99ee5b41e 100755 --- a/frontends/amiga/search.c +++ b/frontends/amiga/search.c @@ -94,9 +94,9 @@ static struct gui_search_table search_table = { ami_search_set_back_state, }; -static struct ami_win_event_table ami_search_table = { +static const struct ami_win_event_table ami_search_table = { ami_search_event, - NULL, /* we don't explicitly close the search window n the frontend */ + NULL, /* we don't explicitly close the search window on quit */ }; struct gui_search_table *amiga_search_table = &search_table; diff --git a/frontends/amiga/tree.c b/frontends/amiga/tree.c index 79753a7d3..f1c5327c7 100644 --- a/frontends/amiga/tree.c +++ b/frontends/amiga/tree.c @@ -89,7 +89,7 @@ enum { struct treeview_window { - struct nsObject *node; + struct ami_generic_window w; struct Window *win; Object *objects[GID_TREE_LAST]; int type; @@ -121,6 +121,13 @@ struct ami_tree_redraw_req { struct treeview_window *twin; }; +static BOOL ami_tree_event(void *w); + +static const struct ami_win_event_table ami_tree_table = { + ami_tree_event, + ami_tree_close, +}; + #if 0 void ami_tree_draw(struct treeview_window *twin); static void ami_tree_resized(struct tree *tree, int width, @@ -877,21 +884,21 @@ void ami_tree_open(struct treeview_window *twin,int type) ICA_TARGET,ICTARGET_IDCMP, TAG_DONE); - twin->node = AddObject(window_list,AMINS_TVWINDOW); - twin->node->objstruct = twin; + ami_gui_win_list_add(twin, AMINS_TVWINDOW, &ami_tree_table); ami_tree_update_buttons(twin); ami_tree_resized(twin->tree, twin->max_width, twin->max_height, twin); ami_tree_draw(twin); } -void ami_tree_close(struct treeview_window *twin) +void ami_tree_close(void *w) { + struct treeview_window *twin = (struct treeview_window *)w; int i; twin->win = NULL; DisposeObject(twin->objects[OID_MAIN]); - DelObjectNoFree(twin->node); + ami_gui_win_list_remove(twin); ami_plot_release_pens(twin->shared_pens); ami_free_layers(&twin->globals); @@ -942,9 +949,10 @@ static void ami_tree_update_quals(struct treeview_window *twin) } } -BOOL ami_tree_event(struct treeview_window *twin) +static BOOL ami_tree_event(void *w) { /* return TRUE if window destroyed */ + struct treeview_window *twin = (struct treeview_window *)w; ULONG result,storage = 0; uint16 code; struct MenuItem *item; diff --git a/frontends/amiga/tree.h b/frontends/amiga/tree.h index 39a71d70d..aa3c052e9 100755 --- a/frontends/amiga/tree.h +++ b/frontends/amiga/tree.h @@ -40,8 +40,7 @@ void ami_tree_destroy(struct treeview_window *twin); struct tree *ami_tree_get_tree(struct treeview_window *twin); void ami_tree_open(struct treeview_window *twin,int type); -void ami_tree_close(struct treeview_window *twin); -BOOL ami_tree_event(struct treeview_window *twin); +void ami_tree_close(void *w); /* for Arexx interface only */ extern const struct treeview_table ami_tree_callbacks; -- cgit v1.2.3