mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 12:36:51 +03:00
Update treeviews to use event callback
This commit is contained in:
parent
9379a64c6d
commit
47379c0444
@ -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;
|
||||
|
||||
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,
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user