mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-08 20:12:01 +03:00
Complete Amiga corewindow implementation and migration from old treeviews
Merge branch 'chris/amiga-corewindow'
This commit is contained in:
commit
bf3ba5c97b
@ -803,6 +803,7 @@ nserror global_history_fini(void)
|
||||
|
||||
/* Destroy the global history treeview */
|
||||
err = treeview_destroy(gh_ctx.tree);
|
||||
gh_ctx.tree = NULL;
|
||||
|
||||
/* Free global history treeview entry fields */
|
||||
for (i = 0; i < N_FIELDS; i++)
|
||||
|
@ -36,7 +36,7 @@ MESSAGES_FILTER=ami
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# sources purely for the Amiga build
|
||||
S_FRONTEND := gui.c tree.c history.c hotlist.c schedule.c file.c \
|
||||
S_FRONTEND := gui.c history.c hotlist.c schedule.c file.c \
|
||||
misc.c bitmap.c font.c filetype.c utf8.c login.c memory.c \
|
||||
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
|
||||
cookies.c ctxmenu.c clipboard.c help.c font_scan.c \
|
||||
@ -46,7 +46,7 @@ S_FRONTEND := gui.c tree.c history.c hotlist.c schedule.c file.c \
|
||||
stringview/stringview.c stringview/urlhistory.c rtg.c \
|
||||
agclass/amigaguide_class.c os3support.c font_diskfont.c \
|
||||
selectmenu.c hash/xxhash.c font_cache.c font_bullet.c \
|
||||
nsoption.c desktop-tree.c corewindow.c
|
||||
nsoption.c corewindow.c
|
||||
|
||||
# This is the final source build list
|
||||
# Note this is deliberately *not* expanded here as common and image
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "amiga/gui.h"
|
||||
#include "amiga/download.h"
|
||||
#include "amiga/hotlist.h"
|
||||
#include "amiga/tree.h"
|
||||
#include "amiga/libs.h"
|
||||
#include "amiga/misc.h"
|
||||
#include "amiga/theme.h"
|
||||
@ -665,9 +664,9 @@ RXHOOKF(rx_hotlist)
|
||||
cmd->ac_RC = 0;
|
||||
|
||||
if(strcasecmp((char *)cmd->ac_ArgList[0], "OPEN") == 0) {
|
||||
ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
|
||||
ami_hotlist_present();
|
||||
} else if(strcasecmp((char *)cmd->ac_ArgList[0], "CLOSE") == 0) {
|
||||
ami_tree_close(hotlist_window);
|
||||
ami_hotlist_close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -706,7 +706,6 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
|
||||
int width, int height, struct BitMap *friendbm)
|
||||
{
|
||||
if(bitmap == NULL) return NULL;
|
||||
LOG("Getting native BitMap for %p", bitmap);
|
||||
|
||||
if(__builtin_expect(ami_plot_screen_is_palettemapped() == true, 0)) {
|
||||
return ami_bitmap_get_palettemapped(bitmap, width, height, friendbm);
|
||||
|
@ -258,7 +258,7 @@ static void ami_cookies_menulabs(struct ami_menu_data **md)
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
|
||||
ami_cookies_menu_item_project_snapshot, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE, NM_ITEM, "CloseWindow", 0, "TBImages:list_cancel",
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
|
||||
ami_cookies_menu_item_project_close, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_COOKIE_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include <reaction/reaction_macros.h>
|
||||
|
||||
#include "amiga/corewindow.h"
|
||||
#include "amiga/drag.h"
|
||||
#include "amiga/memory.h"
|
||||
#include "amiga/misc.h"
|
||||
#include "amiga/object.h"
|
||||
@ -106,13 +107,27 @@ ami_cw_coord_amiga_to_ns(struct ami_corewindow *ami_cw, int *restrict x, int *re
|
||||
|
||||
/**
|
||||
* check if mouse has moved since position was stored
|
||||
* @param ami_cw corewindow
|
||||
* @param x current x position
|
||||
* @param y current y position
|
||||
* @param click true to check since last click, false since last drag (press)
|
||||
* @return true if it has, false otherwise
|
||||
*/
|
||||
static bool
|
||||
ami_cw_mouse_moved(struct ami_corewindow *ami_cw, int x, int y)
|
||||
ami_cw_mouse_moved(struct ami_corewindow *ami_cw, int x, int y, bool click)
|
||||
{
|
||||
if(abs(x - ami_cw->mouse_x_click) > 5) return true;
|
||||
if(abs(y - ami_cw->mouse_y_click) > 5) return true;
|
||||
int mx, my;
|
||||
|
||||
if(click == true) {
|
||||
mx = ami_cw->mouse_x_click;
|
||||
my = ami_cw->mouse_y_click;
|
||||
} else {
|
||||
mx = ami_cw->drag_x_start;
|
||||
my = ami_cw->drag_y_start;
|
||||
}
|
||||
|
||||
if(abs(x - mx) > 5) return true;
|
||||
if(abs(y - my) > 5) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -137,11 +152,10 @@ ami_cw_mouse_pos(struct ami_corewindow *ami_cw, int *restrict x, int *restrict y
|
||||
xm -= bbox->Left;
|
||||
ym -= bbox->Top;
|
||||
|
||||
ami_gui_free_space_box(bbox);
|
||||
|
||||
if((xm < 0) || (ym < 0) || (xm > bbox->Width) || (ym > bbox->Height))
|
||||
return false;
|
||||
|
||||
ami_gui_free_space_box(bbox);
|
||||
ami_cw_scroller_top(ami_cw, &xs, &ys);
|
||||
|
||||
xm += xs;
|
||||
@ -451,6 +465,78 @@ HOOKF(void, ami_cw_idcmp_hook, Object *, object, struct IntuiMessage *)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag start
|
||||
*/
|
||||
static void
|
||||
ami_cw_drag_start(struct ami_corewindow *ami_cw, int x, int y)
|
||||
{
|
||||
if(ami_cw->dragging == true) return;
|
||||
|
||||
ami_cw->dragging = true;
|
||||
ami_cw->drag_x_start = x;
|
||||
ami_cw->drag_y_start = y;
|
||||
|
||||
switch(ami_cw->drag_status) {
|
||||
case CORE_WINDOW_DRAG_SELECTION:
|
||||
break;
|
||||
|
||||
case CORE_WINDOW_DRAG_MOVE:
|
||||
ami_drag_icon_show(ami_cw->win, "project");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag progress
|
||||
*/
|
||||
static void
|
||||
ami_cw_drag_progress(struct ami_corewindow *ami_cw, int x, int y)
|
||||
{
|
||||
if(ami_cw->dragging == false) return;
|
||||
|
||||
switch(ami_cw->drag_status) {
|
||||
case CORE_WINDOW_DRAG_SELECTION:
|
||||
break;
|
||||
|
||||
case CORE_WINDOW_DRAG_MOVE:
|
||||
ami_drag_icon_move();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drag end
|
||||
*/
|
||||
static void
|
||||
ami_cw_drag_end(struct ami_corewindow *ami_cw, int x, int y)
|
||||
{
|
||||
if(ami_cw->dragging == false) return;
|
||||
|
||||
switch(ami_cw->drag_status) {
|
||||
case CORE_WINDOW_DRAG_SELECTION:
|
||||
break;
|
||||
|
||||
case CORE_WINDOW_DRAG_MOVE:
|
||||
ami_drag_icon_close(ami_cw->win);
|
||||
if((ami_cw != ami_window_at_pointer(AMINS_COREWINDOW)) && (ami_cw->drag_end != NULL)) {
|
||||
ami_cw->drag_end(ami_cw, scrn->MouseX, scrn->MouseY);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ami_cw->drag_status = CORE_WINDOW_DRAG_NONE;
|
||||
ami_cw->dragging = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main event loop for our core window
|
||||
@ -479,66 +565,110 @@ ami_cw_event(void *w)
|
||||
|
||||
switch(result & WMHI_CLASSMASK) {
|
||||
case WMHI_MOUSEMOVE:
|
||||
if(ami_cw_mouse_pos(ami_cw, &x, &y)) {
|
||||
key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
if(ami_cw_mouse_pos(ami_cw, &x, &y) == true) {
|
||||
if(ami_cw_mouse_moved(ami_cw, x, y, false)) {
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
|
||||
/* Start button 1 drag */
|
||||
ami_cw->mouse(ami_cw, BROWSER_MOUSE_DRAG_1, x, y);
|
||||
/* Replace PRESS with HOLDING and declare drag in progress */
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON;
|
||||
} else if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2) {
|
||||
/* Start button 2 drag */
|
||||
ami_cw->mouse(ami_cw, BROWSER_MOUSE_DRAG_2, x, y);
|
||||
/* Replace PRESS with HOLDING and declare drag in progress */
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON;
|
||||
}
|
||||
key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_DRAG_ON) {
|
||||
ami_cw_drag_start(ami_cw, x, y);
|
||||
}
|
||||
} else {
|
||||
key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
}
|
||||
}
|
||||
ami_cw_drag_progress(ami_cw, x, y);
|
||||
break;
|
||||
|
||||
case WMHI_MOUSEBUTTONS:
|
||||
if(ami_cw_mouse_pos(ami_cw, &x, &y) == false)
|
||||
break;
|
||||
if(ami_cw_mouse_pos(ami_cw, &x, &y) == true) {
|
||||
key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
|
||||
switch(code) {
|
||||
case SELECTDOWN:
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
|
||||
ami_cw->drag_x_start = x;
|
||||
ami_cw->drag_y_start = y;
|
||||
break;
|
||||
|
||||
key_state = ami_gui_get_quals(ami_cw->objects[GID_CW_WIN]);
|
||||
case MIDDLEDOWN:
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
|
||||
ami_cw->drag_x_start = x;
|
||||
ami_cw->drag_y_start = y;
|
||||
break;
|
||||
|
||||
switch(code) {
|
||||
case SELECTDOWN:
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_PRESS_1;
|
||||
break;
|
||||
case SELECTUP:
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
|
||||
CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
|
||||
|
||||
case MIDDLEDOWN:
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_PRESS_2;
|
||||
break;
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
|
||||
|
||||
case SELECTUP:
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_1) {
|
||||
CurrentTime((ULONG *)&curtime.tv_sec, (ULONG *)&curtime.tv_usec);
|
||||
if(ami_cw->lastclick.tv_sec) {
|
||||
if((ami_cw_mouse_moved(ami_cw, x, y, true) == false) &&
|
||||
(DoubleClick(ami_cw->lastclick.tv_sec,
|
||||
ami_cw->lastclick.tv_usec,
|
||||
curtime.tv_sec, curtime.tv_usec)))
|
||||
ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
|
||||
}
|
||||
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_CLICK_1;
|
||||
ami_cw->mouse_x_click = x;
|
||||
ami_cw->mouse_y_click = y;
|
||||
|
||||
if(ami_cw->lastclick.tv_sec) {
|
||||
if((ami_cw_mouse_moved(ami_cw, x, y) == false) &&
|
||||
(DoubleClick(ami_cw->lastclick.tv_sec,
|
||||
ami_cw->lastclick.tv_usec,
|
||||
curtime.tv_sec, curtime.tv_usec)))
|
||||
ami_cw->mouse_state |= BROWSER_MOUSE_DOUBLE_CLICK;
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
|
||||
ami_cw->lastclick.tv_sec = 0;
|
||||
ami_cw->lastclick.tv_usec = 0;
|
||||
} else {
|
||||
ami_cw->lastclick.tv_sec = curtime.tv_sec;
|
||||
ami_cw->lastclick.tv_usec = curtime.tv_usec;
|
||||
}
|
||||
}
|
||||
|
||||
ami_cw->mouse_x_click = x;
|
||||
ami_cw->mouse_y_click = y;
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
|
||||
break;
|
||||
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_DOUBLE_CLICK) {
|
||||
ami_cw->lastclick.tv_sec = 0;
|
||||
ami_cw->lastclick.tv_usec = 0;
|
||||
} else {
|
||||
ami_cw->lastclick.tv_sec = curtime.tv_sec;
|
||||
ami_cw->lastclick.tv_usec = curtime.tv_usec;
|
||||
}
|
||||
}
|
||||
case MIDDLEUP:
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
|
||||
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
|
||||
break;
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
|
||||
break;
|
||||
}
|
||||
|
||||
case MIDDLEUP:
|
||||
if(ami_cw->mouse_state & BROWSER_MOUSE_PRESS_2)
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_CLICK_2;
|
||||
if(ami_cw->mouse_state == BROWSER_MOUSE_HOVER) {
|
||||
ami_cw_drag_end(ami_cw, x, y);
|
||||
}
|
||||
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
|
||||
break;
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
} else {
|
||||
/* event is happening away from our corewindow area */
|
||||
switch(code) {
|
||||
case SELECTUP:
|
||||
case MIDDLEUP:
|
||||
ami_cw->mouse_state = BROWSER_MOUSE_HOVER;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(ami_cw->mouse_state == BROWSER_MOUSE_HOVER) {
|
||||
ami_cw_drag_end(ami_cw, x, y);
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state,
|
||||
ami_cw->drag_x_start, ami_cw->drag_y_start); // placate core
|
||||
}
|
||||
}
|
||||
ami_cw->mouse(ami_cw, ami_cw->mouse_state | key_state, x, y);
|
||||
break;
|
||||
|
||||
case WMHI_RAWKEY:
|
||||
@ -722,9 +852,10 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
|
||||
ami_cw->scroll_x_visible = true;
|
||||
ami_cw->scroll_y_visible = true;
|
||||
ami_cw->in_border_scroll = false;
|
||||
ami_cw->dragging = false;
|
||||
|
||||
/* allocate drawing area etc */
|
||||
ami_init_layers(&ami_cw->gg, 0, 0, false);
|
||||
ami_init_layers(&ami_cw->gg, 100, 100, false); // force tiles to save memory
|
||||
ami_cw->gg.shared_pens = ami_AllocMinList();
|
||||
|
||||
ami_cw->deferred_rects = NewObjList();
|
||||
|
@ -58,6 +58,10 @@ struct ami_corewindow {
|
||||
int mouse_y_click;
|
||||
int mouse_state;
|
||||
|
||||
bool dragging;
|
||||
int drag_x_start;
|
||||
int drag_y_start;
|
||||
|
||||
bool close_window; // set to true to close the window during event loop
|
||||
|
||||
APTR deferred_rects_pool;
|
||||
@ -128,6 +132,31 @@ struct ami_corewindow {
|
||||
*/
|
||||
BOOL (*event)(struct ami_corewindow *ami_cw, ULONG result);
|
||||
|
||||
/**
|
||||
* callback for drag end on Amiga core window
|
||||
* ie. a drag *from* this window to a different window
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param x mouse x position **in screen co-ordinates**
|
||||
* \param y mouse y position **in screen co-ordinates**
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
nserror (*drag_end)(struct ami_corewindow *ami_cw, int x, int y);
|
||||
|
||||
/**
|
||||
* callback for icon drop on Amiga core window
|
||||
* ie. a drag has ended *above* this window
|
||||
* \todo this may not be very flexible but serves our current purposes
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param url url of dropped icon
|
||||
* \param title title of dropped icon
|
||||
* \param x mouse x position **in screen co-ordinates**
|
||||
* \param y mouse y position **in screen co-ordinates**
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
nserror (*icon_drop)(struct ami_corewindow *ami_cw, struct nsurl *url, const char *title, int x, int y);
|
||||
|
||||
/**
|
||||
* callback to close an Amiga core window
|
||||
*
|
||||
|
@ -1,353 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* deprecated compatibility layer for new treeview modules. Do not use.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "netsurf/misc.h"
|
||||
#include "netsurf/browser_window.h"
|
||||
#include "netsurf/core_window.h"
|
||||
#include "content/content.h"
|
||||
#include "content/hlcache.h"
|
||||
#include "desktop/gui_internal.h"
|
||||
#include "desktop/treeview.h"
|
||||
#include "desktop/hotlist.h"
|
||||
#include "desktop/cookie_manager.h"
|
||||
#include "desktop/global_history.h"
|
||||
#include "desktop/sslcert_viewer.h"
|
||||
|
||||
#include "amiga/desktop-tree.h"
|
||||
|
||||
struct tree {
|
||||
unsigned int flags; /* Tree flags */
|
||||
tree_drag_type drag;
|
||||
const struct treeview_table *callbacks;
|
||||
void *client_data; /* User assigned data for the callbacks */
|
||||
};
|
||||
|
||||
|
||||
struct sslcert_session_data *ssl_current_session = NULL;
|
||||
const char *tree_hotlist_path = NULL;
|
||||
|
||||
static void treeview_test_redraw_request(struct core_window *cw,
|
||||
const struct rect *r)
|
||||
{
|
||||
struct tree *tree = (struct tree *)cw;
|
||||
|
||||
tree->callbacks->redraw_request(r->x0, r->y0,
|
||||
r->x1 - r->x0, r->y1 - r->y0,
|
||||
tree->client_data);
|
||||
}
|
||||
|
||||
static void treeview_test_update_size(struct core_window *cw,
|
||||
int width, int height)
|
||||
{
|
||||
struct tree *tree = (struct tree *)cw;
|
||||
|
||||
tree->callbacks->resized(tree, width, height, tree->client_data);
|
||||
}
|
||||
|
||||
static void treeview_test_scroll_visible(struct core_window *cw,
|
||||
const struct rect *r)
|
||||
{
|
||||
}
|
||||
|
||||
static void treeview_test_get_window_dimensions(struct core_window *cw,
|
||||
int *width, int *height)
|
||||
{
|
||||
struct tree *tree = (struct tree *)cw;
|
||||
|
||||
tree->callbacks->get_window_dimensions(width, height,
|
||||
tree->client_data);
|
||||
}
|
||||
|
||||
static void treeview_test_drag_status(struct core_window *cw,
|
||||
core_window_drag_status ds)
|
||||
{
|
||||
struct tree *tree = (struct tree *)cw;
|
||||
|
||||
switch (ds) {
|
||||
case CORE_WINDOW_DRAG_NONE:
|
||||
tree->drag = TREE_NO_DRAG;
|
||||
break;
|
||||
|
||||
case CORE_WINDOW_DRAG_SELECTION:
|
||||
tree->drag = TREE_SELECT_DRAG;
|
||||
break;
|
||||
|
||||
case CORE_WINDOW_DRAG_MOVE:
|
||||
tree->drag = TREE_MOVE_DRAG;
|
||||
break;
|
||||
|
||||
case CORE_WINDOW_DRAG_TEXT_SELECTION:
|
||||
tree->drag = TREE_TEXTAREA_DRAG;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct core_window_callback_table cw_t = {
|
||||
.redraw_request = treeview_test_redraw_request,
|
||||
.update_size = treeview_test_update_size,
|
||||
.scroll_visible = treeview_test_scroll_visible,
|
||||
.get_window_dimensions = treeview_test_get_window_dimensions,
|
||||
.drag_status = treeview_test_drag_status
|
||||
};
|
||||
|
||||
static bool treeview_test_init(struct tree *tree)
|
||||
{
|
||||
nserror err;
|
||||
|
||||
switch (tree->flags) {
|
||||
case TREE_COOKIES:
|
||||
err = cookie_manager_init(&cw_t, (struct core_window *)tree);
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't init new cookie manager.", 0);
|
||||
break;
|
||||
case TREE_HISTORY:
|
||||
err = global_history_init(&cw_t, (struct core_window *)tree);
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't init new global history.", 0);
|
||||
break;
|
||||
case TREE_HOTLIST:
|
||||
err = hotlist_init(tree_hotlist_path);
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't init new hotlist.", 0);
|
||||
err = hotlist_manager_init(&cw_t, (struct core_window *)tree);
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't init hotlist manager.", 0);
|
||||
break;
|
||||
case TREE_SSLCERT:
|
||||
assert(ssl_current_session == NULL &&
|
||||
"Call sslcert_viewer_init directly, "
|
||||
"this compat. layer can't cope with simultanious "
|
||||
"sslcert viewers");
|
||||
err = sslcert_viewer_init(&cw_t, (struct core_window *)tree,
|
||||
ssl_current_session);
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't init new sslcert viewer.", 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool treeview_test_fini(struct tree *tree)
|
||||
{
|
||||
nserror err;
|
||||
|
||||
switch (tree->flags) {
|
||||
case TREE_COOKIES:
|
||||
err = cookie_manager_fini();
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't finalise cookie manager.", 0);
|
||||
break;
|
||||
case TREE_HISTORY:
|
||||
err = global_history_fini();
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't finalise cookie manager.", 0);
|
||||
break;
|
||||
case TREE_HOTLIST:
|
||||
err = hotlist_fini(tree_hotlist_path);
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't finalise hotlist.", 0);
|
||||
break;
|
||||
case TREE_SSLCERT:
|
||||
assert(ssl_current_session != NULL &&
|
||||
"Can't use sslcert window after sslcert_viewer_fini()");
|
||||
err = sslcert_viewer_fini(ssl_current_session);
|
||||
ssl_current_session = NULL;
|
||||
if (err != NSERROR_OK)
|
||||
guit->misc->warning("Couldn't finalise sslcert viewer.", 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool treeview_test_redraw(struct tree *tree, int x, int y,
|
||||
int clip_x, int clip_y, int clip_width, int clip_height,
|
||||
const struct redraw_context *ctx)
|
||||
{
|
||||
struct rect clip;
|
||||
|
||||
clip.x0 = clip_x;
|
||||
clip.y0 = clip_y;
|
||||
clip.x1 = clip_x + clip_width;
|
||||
clip.y1 = clip_y + clip_height;
|
||||
|
||||
switch (tree->flags) {
|
||||
case TREE_SSLCERT:
|
||||
if (ssl_current_session != NULL) {
|
||||
sslcert_viewer_redraw(ssl_current_session, x, y, &clip, ctx);
|
||||
}
|
||||
return true;
|
||||
case TREE_COOKIES:
|
||||
cookie_manager_redraw(x, y, &clip, ctx);
|
||||
return true;
|
||||
case TREE_HISTORY:
|
||||
global_history_redraw(x, y, &clip, ctx);
|
||||
return true;
|
||||
case TREE_HOTLIST:
|
||||
hotlist_redraw(x, y, &clip, ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool treeview_test_mouse_action(struct tree *tree,
|
||||
browser_mouse_state mouse, int x, int y)
|
||||
{
|
||||
switch (tree->flags) {
|
||||
case TREE_SSLCERT:
|
||||
assert(ssl_current_session != NULL &&
|
||||
"Can't use sslcert window after sslcert_viewer_fini()");
|
||||
sslcert_viewer_mouse_action(ssl_current_session, mouse, x, y);
|
||||
return true;
|
||||
case TREE_COOKIES:
|
||||
cookie_manager_mouse_action(mouse, x, y);
|
||||
return true;
|
||||
case TREE_HISTORY:
|
||||
global_history_mouse_action(mouse, x, y);
|
||||
return true;
|
||||
case TREE_HOTLIST:
|
||||
hotlist_mouse_action(mouse, x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
|
||||
{
|
||||
switch (tree->flags) {
|
||||
case TREE_SSLCERT:
|
||||
assert(ssl_current_session != NULL &&
|
||||
"Can't use sslcert window after sslcert_viewer_fini()");
|
||||
sslcert_viewer_keypress(ssl_current_session, key);
|
||||
return true;
|
||||
case TREE_COOKIES:
|
||||
cookie_manager_keypress(key);
|
||||
return true;
|
||||
case TREE_HISTORY:
|
||||
global_history_keypress(key);
|
||||
return true;
|
||||
case TREE_HOTLIST:
|
||||
hotlist_keypress(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
struct tree *tree_create(unsigned int flags,
|
||||
const struct treeview_table *callbacks, void *client_data)
|
||||
{
|
||||
struct tree *tree;
|
||||
|
||||
tree = calloc(sizeof(struct tree), 1);
|
||||
if (tree == NULL) {
|
||||
LOG("calloc failed");
|
||||
guit->misc->warning(messages_get_errorcode(NSERROR_NOMEM), 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tree->flags = flags;
|
||||
tree->drag = TREE_NO_DRAG;
|
||||
tree->callbacks = callbacks;
|
||||
tree->client_data = client_data;
|
||||
|
||||
treeview_test_init(tree);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
void tree_delete(struct tree *tree)
|
||||
{
|
||||
treeview_test_fini(tree);
|
||||
free(tree);
|
||||
}
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
void tree_draw(struct tree *tree, int x, int y,
|
||||
int clip_x, int clip_y, int clip_width, int clip_height,
|
||||
const struct redraw_context *ctx)
|
||||
{
|
||||
assert(tree != NULL);
|
||||
|
||||
treeview_test_redraw(tree, x, y, clip_x, clip_y,
|
||||
clip_width, clip_height, ctx);
|
||||
}
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
|
||||
int y)
|
||||
{
|
||||
assert(tree != NULL);
|
||||
|
||||
if (treeview_test_mouse_action(tree, mouse, x, y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
|
||||
int x1, int y1)
|
||||
{
|
||||
assert(tree != NULL);
|
||||
|
||||
treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER, x1, y1);
|
||||
}
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
bool tree_keypress(struct tree *tree, uint32_t key)
|
||||
{
|
||||
if (treeview_test_keypress(tree, key)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
tree_drag_type tree_drag_status(struct tree *tree)
|
||||
{
|
||||
assert(tree != NULL);
|
||||
return tree->drag;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
|
||||
* Copyright 2009 Paul Blokus <paul_pl@users.sourceforge.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* deprecated compatibility layer for new treeview modules. Do not use.
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_DESKTOP_TREE_H_
|
||||
#define _NETSURF_DESKTOP_TREE_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "netsurf/mouse.h"
|
||||
|
||||
struct sslcert_session_data;
|
||||
struct tree;
|
||||
struct redraw_context;
|
||||
|
||||
/**
|
||||
* Current ssl session data for treeview
|
||||
*
|
||||
* @todo FIXME global certificate treeview state must go away, this is
|
||||
* just wrong.
|
||||
*/
|
||||
extern struct sslcert_session_data *ssl_current_session;
|
||||
extern const char *tree_hotlist_path;
|
||||
|
||||
/* Tree flags */
|
||||
enum tree_flags {
|
||||
TREE_HISTORY,
|
||||
TREE_COOKIES,
|
||||
TREE_SSLCERT,
|
||||
TREE_HOTLIST
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TREE_NO_DRAG = 0,
|
||||
TREE_SELECT_DRAG,
|
||||
TREE_MOVE_DRAG,
|
||||
TREE_TEXTAREA_DRAG, /** < A drag that is passed to a textarea */
|
||||
TREE_UNKNOWN_DRAG /** < A drag the tree itself won't handle */
|
||||
} tree_drag_type;
|
||||
|
||||
/** callbacks to perform necessary operations on treeview. */
|
||||
struct treeview_table {
|
||||
void (*redraw_request)(int x, int y, int width, int height,
|
||||
void *data); /**< request a redraw. */
|
||||
void (*resized)(struct tree *tree, int width, int height,
|
||||
void *data); /**< resize treeview area. */
|
||||
void (*scroll_visible)(int y, int height, void *data); /**< scroll visible treeview area. */
|
||||
void (*get_window_dimensions)(int *width, int *height, void *data); /**< get dimensions of window */
|
||||
};
|
||||
|
||||
struct tree *tree_create(unsigned int flags,
|
||||
const struct treeview_table *callbacks,
|
||||
void *client_data);
|
||||
|
||||
/** deprecated compatibility layer for new treeview modules. Do not use. */
|
||||
void tree_delete(struct tree *tree);
|
||||
tree_drag_type tree_drag_status(struct tree *tree);
|
||||
void tree_draw(struct tree *tree, int x, int y,
|
||||
int clip_x, int clip_y, int clip_width, int clip_height,
|
||||
const struct redraw_context *ctx);
|
||||
bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse,
|
||||
int x, int y);
|
||||
void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
|
||||
int x1, int y1);
|
||||
bool tree_keypress(struct tree *tree, uint32_t key);
|
||||
|
||||
|
||||
#endif
|
@ -46,6 +46,9 @@
|
||||
|
||||
static struct Hook aslhookfunc;
|
||||
|
||||
struct FileRequester *filereq;
|
||||
struct FileRequester *savereq;
|
||||
|
||||
HOOKF(ULONG, ami_file_asl_mime_hook, struct FileRequester *, fr, struct AnchorPathOld *)
|
||||
{
|
||||
char fname[1024];
|
||||
|
@ -21,8 +21,8 @@ struct hlcache_object;
|
||||
struct selection;
|
||||
struct gui_window_2;
|
||||
|
||||
struct FileRequester *filereq;
|
||||
struct FileRequester *savereq;
|
||||
extern struct FileRequester *filereq;
|
||||
extern struct FileRequester *savereq;
|
||||
|
||||
enum {
|
||||
AMINS_SAVE_SOURCE,
|
||||
|
@ -118,7 +118,6 @@
|
||||
#include "desktop/searchweb.h"
|
||||
|
||||
/* NetSurf Amiga platform includes */
|
||||
#include "amiga/desktop-tree.h"
|
||||
#include "amiga/gui.h"
|
||||
#include "amiga/arexx.h"
|
||||
#include "amiga/bitmap.h"
|
||||
@ -151,7 +150,6 @@
|
||||
#include "amiga/search.h"
|
||||
#include "amiga/selectmenu.h"
|
||||
#include "amiga/theme.h"
|
||||
#include "amiga/tree.h"
|
||||
#include "amiga/utf8.h"
|
||||
#include "amiga/sslcert.h"
|
||||
|
||||
@ -547,6 +545,17 @@ static void ami_set_screen_defaults(struct Screen *screen)
|
||||
nsoption_default_set_int(cookies_window_xsize, width);
|
||||
nsoption_default_set_int(cookies_window_ysize, height);
|
||||
|
||||
nsoption_default_set_int(history_window_ypos, top);
|
||||
nsoption_default_set_int(history_window_xpos, left);
|
||||
nsoption_default_set_int(history_window_xsize, width);
|
||||
nsoption_default_set_int(history_window_ysize, height);
|
||||
|
||||
nsoption_default_set_int(hotlist_window_ypos, top);
|
||||
nsoption_default_set_int(hotlist_window_xpos, left);
|
||||
nsoption_default_set_int(hotlist_window_xsize, width);
|
||||
nsoption_default_set_int(hotlist_window_ysize, height);
|
||||
|
||||
|
||||
nsoption_default_set_int(window_x, 0);
|
||||
nsoption_default_set_int(window_y, screen->BarHeight + 1);
|
||||
nsoption_default_set_int(window_width, screen->Width);
|
||||
@ -1013,8 +1022,7 @@ static void gui_init2(int argc, char** argv)
|
||||
}
|
||||
/**/
|
||||
|
||||
ami_hotlist_initialise(nsoption_charp(hotlist_file));
|
||||
ami_global_history_initialise();
|
||||
hotlist_init(nsoption_charp(hotlist_file));
|
||||
search_web_select_provider(nsoption_int(search_provider));
|
||||
|
||||
if (notalreadyrunning &&
|
||||
@ -3037,8 +3045,7 @@ static void gui_quit(void)
|
||||
|
||||
urldb_save(nsoption_charp(url_file));
|
||||
urldb_save_cookies(nsoption_charp(cookie_file));
|
||||
ami_hotlist_free(nsoption_charp(hotlist_file));
|
||||
ami_global_history_free();
|
||||
hotlist_fini(nsoption_charp(hotlist_file));
|
||||
#ifdef __amigaos4__
|
||||
if(IApplication && ami_appid)
|
||||
UnregisterApplication(ami_appid, NULL);
|
||||
@ -3182,7 +3189,7 @@ static bool ami_gui_hotlist_add(void *userdata, int level, int item,
|
||||
return true;
|
||||
}
|
||||
|
||||
static int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, struct gui_window_2 *gwin)
|
||||
static int ami_gui_hotlist_scan(struct List *speed_button_list, struct gui_window_2 *gwin)
|
||||
{
|
||||
struct ami_gui_tb_userdata userdata;
|
||||
userdata.gw = gwin;
|
||||
@ -3204,7 +3211,7 @@ static void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
|
||||
|
||||
NewList(&gwin->hotlist_toolbar_list);
|
||||
|
||||
if(ami_gui_hotlist_scan(ami_tree_get_tree(hotlist_window), &gwin->hotlist_toolbar_list, gwin) > 0) {
|
||||
if(ami_gui_hotlist_scan(&gwin->hotlist_toolbar_list, gwin) > 0) {
|
||||
gwin->objects[GID_HOTLIST] =
|
||||
SpeedBarObj,
|
||||
GA_ID, GID_HOTLIST,
|
||||
@ -3303,7 +3310,7 @@ static void ami_gui_hotlist_toolbar_update(struct gui_window_2 *gwin)
|
||||
|
||||
ami_gui_hotlist_toolbar_free(gwin, &gwin->hotlist_toolbar_list);
|
||||
|
||||
if(ami_gui_hotlist_scan(ami_tree_get_tree(hotlist_window), &gwin->hotlist_toolbar_list, gwin) > 0) {
|
||||
if(ami_gui_hotlist_scan(&gwin->hotlist_toolbar_list, gwin) > 0) {
|
||||
SetGadgetAttrs((struct Gadget *)gwin->objects[GID_HOTLIST],
|
||||
gwin->win, NULL,
|
||||
SPEEDBAR_Buttons, &gwin->hotlist_toolbar_list,
|
||||
|
451
frontends/amiga/history.c
Executable file → Normal file
451
frontends/amiga/history.c
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -16,28 +16,449 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of Amiga global history viewer using core windows.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <proto/exec.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils/errors.h"
|
||||
#include "netsurf/mouse.h"
|
||||
#include "netsurf/window.h"
|
||||
#include <proto/asl.h>
|
||||
#include <proto/dos.h>
|
||||
#include <proto/intuition.h>
|
||||
|
||||
#include <classes/window.h>
|
||||
#include <gadgets/layout.h>
|
||||
#include <gadgets/space.h>
|
||||
|
||||
#include <reaction/reaction_macros.h>
|
||||
|
||||
#include "desktop/global_history.h"
|
||||
#include "netsurf/browser_window.h"
|
||||
#include "netsurf/keypress.h"
|
||||
#include "netsurf/plotters.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
||||
#include "amiga/corewindow.h"
|
||||
#include "amiga/drag.h"
|
||||
#include "amiga/file.h"
|
||||
#include "amiga/history.h"
|
||||
#include "amiga/tree.h"
|
||||
#include "amiga/tree.h"
|
||||
#include "amiga/libs.h"
|
||||
#include "amiga/theme.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
struct treeview_window *global_history_window = NULL;
|
||||
enum {
|
||||
/* Project menu */
|
||||
AMI_HISTORY_M_PROJECT = 0,
|
||||
AMI_HISTORY_M_EXPORT,
|
||||
AMI_HISTORY_M_BAR_P1,
|
||||
AMI_HISTORY_M_EXPAND,
|
||||
AMI_HISTORY_M_EXPAND_ALL,
|
||||
AMI_HISTORY_M_EXPAND_FOLDERS,
|
||||
AMI_HISTORY_M_EXPAND_LINKS,
|
||||
AMI_HISTORY_M_COLLAPSE,
|
||||
AMI_HISTORY_M_COLLAPSE_ALL,
|
||||
AMI_HISTORY_M_COLLAPSE_FOLDERS,
|
||||
AMI_HISTORY_M_COLLAPSE_LINKS,
|
||||
AMI_HISTORY_M_BAR_P2,
|
||||
AMI_HISTORY_M_SNAPSHOT,
|
||||
AMI_HISTORY_M_BAR_P3,
|
||||
AMI_HISTORY_M_CLOSE,
|
||||
/* Edit menu */
|
||||
AMI_HISTORY_M_EDIT,
|
||||
AMI_HISTORY_M_SELECTALL,
|
||||
AMI_HISTORY_M_CLEAR,
|
||||
AMI_HISTORY_M_BAR_E1,
|
||||
AMI_HISTORY_M_DELETE,
|
||||
AMI_HISTORY_M_LAST
|
||||
};
|
||||
|
||||
void ami_global_history_initialise(void)
|
||||
/**
|
||||
* Amiga history viewer window context
|
||||
*/
|
||||
struct ami_history_global_window {
|
||||
/** Amiga core window context */
|
||||
struct ami_corewindow core;
|
||||
|
||||
struct ami_menu_data *menu_data[AMI_HISTORY_M_LAST + 1];
|
||||
struct Menu *imenu; /* Intuition menu */
|
||||
};
|
||||
|
||||
static struct ami_history_global_window *history_window = NULL;
|
||||
|
||||
|
||||
static void
|
||||
ami_history_global_menu_free(struct ami_history_global_window *history_win)
|
||||
{
|
||||
global_history_window = ami_tree_create(TREE_HISTORY, NULL);
|
||||
|
||||
if(!global_history_window) return;
|
||||
SetAttrs(history_win->core.objects[GID_CW_WIN],
|
||||
WINDOW_MenuStrip, NULL,
|
||||
TAG_DONE);
|
||||
|
||||
ami_menu_free_menu(history_win->menu_data, AMI_HISTORY_M_LAST, history_win->imenu);
|
||||
}
|
||||
|
||||
void ami_global_history_free()
|
||||
/**
|
||||
* destroy a previously created history view
|
||||
*/
|
||||
static void
|
||||
ami_history_global_destroy(struct ami_corewindow *ami_cw)
|
||||
{
|
||||
ami_tree_destroy(global_history_window);
|
||||
global_history_window = NULL;
|
||||
nserror res;
|
||||
|
||||
if(history_window == NULL)
|
||||
return;
|
||||
|
||||
res = global_history_fini();
|
||||
if (res == NSERROR_OK) {
|
||||
ami_history_global_menu_free(history_window);
|
||||
res = ami_corewindow_fini(&history_window->core); /* closes the window for us, frees history_win */
|
||||
history_window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* callback for mouse action for history viewer on core window
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param mouse_state netsurf mouse state on event
|
||||
* \param x location of event
|
||||
* \param y location of event
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_history_global_mouse(struct ami_corewindow *ami_cw,
|
||||
browser_mouse_state mouse_state,
|
||||
int x, int y)
|
||||
{
|
||||
global_history_mouse_action(mouse_state, x, y);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* callback for keypress for history viewer on core window
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param nskey The netsurf key code
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_history_global_key(struct ami_corewindow *ami_cw, uint32_t nskey)
|
||||
{
|
||||
if (global_history_keypress(nskey)) {
|
||||
return NSERROR_OK;
|
||||
}
|
||||
return NSERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* callback on draw event for history viewer on core window
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param r The rectangle of the window that needs updating.
|
||||
* \param ctx The drawing context
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_history_global_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
|
||||
{
|
||||
global_history_redraw(x, y, r, ctx);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* callback on drag end for history viewer
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param x mouse x co-ordinate
|
||||
* \param y mouse y co-ordinate
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_history_global_drag_end(struct ami_corewindow *ami_cw, int x, int y)
|
||||
{
|
||||
struct nsurl *url = NULL;
|
||||
const char *title = NULL;
|
||||
bool ok = false;
|
||||
struct gui_window_2 *gwin;
|
||||
struct ami_corewindow *cw;
|
||||
|
||||
if(global_history_has_selection()) {
|
||||
ok = global_history_get_selection(&url, &title);
|
||||
}
|
||||
|
||||
if((ok == false) || (url == NULL)) {
|
||||
DisplayBeep(scrn);
|
||||
} else if(url) {
|
||||
if((gwin = ami_window_at_pointer(AMINS_WINDOW))) {
|
||||
browser_window_navigate(gwin->gw->bw,
|
||||
url,
|
||||
NULL,
|
||||
BW_NAVIGATE_HISTORY,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
} else if((cw = (struct ami_corewindow *)ami_window_at_pointer(AMINS_COREWINDOW)) &&
|
||||
(ami_cw->icon_drop != NULL)) {
|
||||
cw->icon_drop(cw, url, title, x, y);
|
||||
}
|
||||
}
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu stuff
|
||||
*/
|
||||
|
||||
/* menu hook functions */
|
||||
HOOKF(void, ami_history_global_menu_item_project_export, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
char fname[1024];
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
if(AslRequestTags(savereq,
|
||||
ASLFR_Window, ami_cw->win,
|
||||
ASLFR_SleepWindow, TRUE,
|
||||
ASLFR_TitleText, messages_get("NetSurf"),
|
||||
ASLFR_Screen, scrn,
|
||||
ASLFR_InitialFile, "history.html",
|
||||
TAG_DONE)) {
|
||||
strlcpy(fname, savereq->fr_Drawer, 1024);
|
||||
AddPart(fname, savereq->fr_File, 1024);
|
||||
ami_update_pointer(ami_cw->win, GUI_POINTER_WAIT);
|
||||
global_history_export(fname, NULL);
|
||||
ami_update_pointer(ami_cw->win, GUI_POINTER_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_expand(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_expand_folders, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_expand(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_expand_links, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_expand(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_contract(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_collapse_folders, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_contract(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_collapse_links, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_contract(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
nsoption_set_int(history_window_ypos, ami_cw->win->TopEdge);
|
||||
nsoption_set_int(history_window_xpos, ami_cw->win->LeftEdge);
|
||||
nsoption_set_int(history_window_xsize, ami_cw->win->Width);
|
||||
nsoption_set_int(history_window_ysize, ami_cw->win->Height);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_project_close, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
ami_cw->close_window = true;
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_keypress(NS_KEY_SELECT_ALL);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_keypress(NS_KEY_CLEAR_SELECTION);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_history_global_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
global_history_keypress(NS_KEY_DELETE_LEFT);
|
||||
}
|
||||
|
||||
|
||||
/* menu setup */
|
||||
|
||||
static void ami_history_global_menulabs(struct ami_menu_data **md)
|
||||
{
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_EXPORT, NM_ITEM, "TreeExport", 'S', "TBImages:list_save",
|
||||
ami_history_global_menu_item_project_export, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
|
||||
ami_history_global_menu_item_project_expand_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_FOLDERS, NM_SUB, "Folders", 0, NULL,
|
||||
ami_history_global_menu_item_project_expand_folders, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_EXPAND_LINKS, NM_SUB, "Links", 0, NULL,
|
||||
ami_history_global_menu_item_project_expand_links, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
|
||||
ami_history_global_menu_item_project_collapse_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", 0, NULL,
|
||||
ami_history_global_menu_item_project_collapse_folders, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_COLLAPSE_LINKS, NM_SUB, "Links", 0, NULL,
|
||||
ami_history_global_menu_item_project_collapse_links, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
|
||||
ami_history_global_menu_item_project_snapshot, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
|
||||
ami_history_global_menu_item_project_close, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
|
||||
ami_history_global_menu_item_edit_select_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
|
||||
ami_history_global_menu_item_edit_clear, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
|
||||
ami_history_global_menu_item_edit_delete, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_HISTORY_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
static struct Menu *
|
||||
ami_history_global_menu_create(struct ami_history_global_window *history_win)
|
||||
{
|
||||
ami_history_global_menulabs(history_win->menu_data);
|
||||
history_win->imenu = ami_menu_layout(history_win->menu_data, AMI_HISTORY_M_LAST);
|
||||
if(history_win->imenu == NULL) return NULL;
|
||||
|
||||
return history_win->imenu;
|
||||
}
|
||||
|
||||
|
||||
static nserror
|
||||
ami_history_global_create_window(struct ami_history_global_window *history_win)
|
||||
{
|
||||
struct ami_corewindow *ami_cw = (struct ami_corewindow *)&history_win->core;
|
||||
|
||||
ami_cw->objects[GID_CW_WIN] = WindowObj,
|
||||
WA_ScreenTitle, ami_gui_get_screen_title(),
|
||||
WA_Title, ami_cw->wintitle,
|
||||
WA_Activate, TRUE,
|
||||
WA_DepthGadget, TRUE,
|
||||
WA_DragBar, TRUE,
|
||||
WA_CloseGadget, TRUE,
|
||||
WA_SizeGadget, TRUE,
|
||||
WA_SizeBRight, TRUE,
|
||||
WA_Top, nsoption_int(history_window_ypos),
|
||||
WA_Left, nsoption_int(history_window_xpos),
|
||||
WA_Width, nsoption_int(history_window_xsize),
|
||||
WA_Height, nsoption_int(history_window_ysize),
|
||||
WA_PubScreen, scrn,
|
||||
WA_ReportMouse, TRUE,
|
||||
WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
|
||||
IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
|
||||
IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
|
||||
WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
|
||||
WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
|
||||
WINDOW_SharedPort, sport,
|
||||
WINDOW_HorizProp, 1,
|
||||
WINDOW_VertProp, 1,
|
||||
WINDOW_UserData, history_win,
|
||||
WINDOW_MenuStrip, ami_history_global_menu_create(history_win),
|
||||
WINDOW_MenuUserData, WGUD_HOOK,
|
||||
WINDOW_IconifyGadget, FALSE,
|
||||
WINDOW_Position, WPOS_CENTERSCREEN,
|
||||
WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
|
||||
LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
|
||||
GA_ID, GID_CW_DRAW,
|
||||
SPACE_Transparent, TRUE,
|
||||
SPACE_BevelStyle, BVS_DISPLAY,
|
||||
GA_RelVerify, TRUE,
|
||||
SpaceEnd,
|
||||
EndGroup,
|
||||
EndWindow;
|
||||
|
||||
if(ami_cw->objects[GID_CW_WIN] == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* exported interface documented in amiga/cookies.h */
|
||||
nserror ami_history_global_present(void)
|
||||
{
|
||||
struct ami_history_global_window *ncwin;
|
||||
nserror res;
|
||||
|
||||
if(history_window != NULL) {
|
||||
//windowtofront()
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
ncwin = calloc(1, sizeof(struct ami_history_global_window));
|
||||
if (ncwin == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("GlobalHistory"));
|
||||
|
||||
res = ami_history_global_create_window(ncwin);
|
||||
if (res != NSERROR_OK) {
|
||||
LOG("SSL UI builder init failed");
|
||||
ami_utf8_free(ncwin->core.wintitle);
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* initialise Amiga core window */
|
||||
ncwin->core.draw = ami_history_global_draw;
|
||||
ncwin->core.key = ami_history_global_key;
|
||||
ncwin->core.mouse = ami_history_global_mouse;
|
||||
ncwin->core.close = ami_history_global_destroy;
|
||||
ncwin->core.event = NULL;
|
||||
ncwin->core.drag_end = ami_history_global_drag_end;
|
||||
ncwin->core.icon_drop = NULL;
|
||||
|
||||
res = ami_corewindow_init(&ncwin->core);
|
||||
if (res != NSERROR_OK) {
|
||||
ami_utf8_free(ncwin->core.wintitle);
|
||||
DisposeObject(ncwin->core.objects[GID_CW_WIN]);
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = global_history_init(ncwin->core.cb_table, (struct core_window *)ncwin);
|
||||
if (res != NSERROR_OK) {
|
||||
ami_utf8_free(ncwin->core.wintitle);
|
||||
DisposeObject(ncwin->core.objects[GID_CW_WIN]);
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
history_window = ncwin;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
16
frontends/amiga/history.h
Executable file → Normal file
16
frontends/amiga/history.h
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -16,14 +16,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef AMIGA_HISTORY_H
|
||||
#define AMIGA_HISTORY_H
|
||||
#include "amiga/desktop-tree.h"
|
||||
#ifndef AMIGA_HISTORY_GLOBAL_H
|
||||
#define AMIGA_HISTORY_GLOBAL_H
|
||||
|
||||
#define GLOBAL_HISTORY_RECENT_URLS 16
|
||||
|
||||
void ami_global_history_initialise(void);
|
||||
void ami_global_history_free(void);
|
||||
|
||||
extern struct treeview_window *global_history_window;
|
||||
/** Open the global history viewer */
|
||||
nserror ami_history_global_present(void);
|
||||
#endif
|
||||
|
||||
|
520
frontends/amiga/hotlist.c
Executable file → Normal file
520
frontends/amiga/hotlist.c
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2008, 2009, 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -16,16 +16,84 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of Amiga hotlist viewer using core windows.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <proto/exec.h>
|
||||
|
||||
#include "utils/nsurl.h"
|
||||
#include <proto/asl.h>
|
||||
#include <proto/dos.h>
|
||||
#include <proto/intuition.h>
|
||||
|
||||
#include <classes/window.h>
|
||||
#include <gadgets/layout.h>
|
||||
#include <gadgets/space.h>
|
||||
|
||||
#include <reaction/reaction_macros.h>
|
||||
|
||||
#include "desktop/hotlist.h"
|
||||
#include "netsurf/mouse.h"
|
||||
#include "netsurf/window.h"
|
||||
#include "netsurf/browser_window.h"
|
||||
#include "netsurf/keypress.h"
|
||||
#include "netsurf/plotters.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
||||
#include "amiga/corewindow.h"
|
||||
#include "amiga/drag.h"
|
||||
#include "amiga/file.h"
|
||||
#include "amiga/hotlist.h"
|
||||
#include "amiga/tree.h"
|
||||
#include "amiga/libs.h"
|
||||
#include "amiga/theme.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
enum {
|
||||
/* Project menu */
|
||||
AMI_HOTLIST_M_PROJECT = 0,
|
||||
AMI_HOTLIST_M_EXPORT,
|
||||
AMI_HOTLIST_M_BAR_P1,
|
||||
AMI_HOTLIST_M_EXPAND,
|
||||
AMI_HOTLIST_M_EXPAND_ALL,
|
||||
AMI_HOTLIST_M_EXPAND_FOLDERS,
|
||||
AMI_HOTLIST_M_EXPAND_LINKS,
|
||||
AMI_HOTLIST_M_COLLAPSE,
|
||||
AMI_HOTLIST_M_COLLAPSE_ALL,
|
||||
AMI_HOTLIST_M_COLLAPSE_FOLDERS,
|
||||
AMI_HOTLIST_M_COLLAPSE_LINKS,
|
||||
AMI_HOTLIST_M_BAR_P2,
|
||||
AMI_HOTLIST_M_SNAPSHOT,
|
||||
AMI_HOTLIST_M_BAR_P3,
|
||||
AMI_HOTLIST_M_CLOSE,
|
||||
/* Edit menu */
|
||||
AMI_HOTLIST_M_EDIT,
|
||||
AMI_HOTLIST_M_NEWFOLDER,
|
||||
AMI_HOTLIST_M_NEWLINK,
|
||||
AMI_HOTLIST_M_EDIT_EDIT,
|
||||
AMI_HOTLIST_M_BAR_E1,
|
||||
AMI_HOTLIST_M_SELECTALL,
|
||||
AMI_HOTLIST_M_CLEAR,
|
||||
AMI_HOTLIST_M_BAR_E2,
|
||||
AMI_HOTLIST_M_DELETE,
|
||||
AMI_HOTLIST_M_LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* Amiga hotlist viewer window context
|
||||
*/
|
||||
struct ami_hotlist_window {
|
||||
/** Amiga core window context */
|
||||
struct ami_corewindow core;
|
||||
|
||||
struct ami_menu_data *menu_data[AMI_HOTLIST_M_LAST + 1];
|
||||
struct Menu *imenu; /* Intuition menu */
|
||||
};
|
||||
|
||||
static struct ami_hotlist_window *hotlist_window = NULL;
|
||||
|
||||
struct ami_hotlist_ctx {
|
||||
void *userdata;
|
||||
@ -37,22 +105,7 @@ struct ami_hotlist_ctx {
|
||||
bool (*cb)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder);
|
||||
};
|
||||
|
||||
struct treeview_window *hotlist_window = NULL;
|
||||
|
||||
void ami_hotlist_initialise(const char *hotlist_file)
|
||||
{
|
||||
tree_hotlist_path = hotlist_file;
|
||||
hotlist_window = ami_tree_create(TREE_HOTLIST, NULL);
|
||||
if(!hotlist_window) return;
|
||||
}
|
||||
|
||||
void ami_hotlist_free(const char *hotlist_file)
|
||||
{
|
||||
ami_tree_destroy(hotlist_window);
|
||||
hotlist_window = NULL;
|
||||
}
|
||||
|
||||
|
||||
/** hotlist scanner */
|
||||
static nserror ami_hotlist_folder_enter_cb(void *ctx, const char *title)
|
||||
{
|
||||
struct ami_hotlist_ctx *menu_ctx = (struct ami_hotlist_ctx *)ctx;
|
||||
@ -118,3 +171,426 @@ nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder,
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* callback for mouse action for hotlist viewer on core window
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param mouse_state netsurf mouse state on event
|
||||
* \param x location of event
|
||||
* \param y location of event
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_hotlist_mouse(struct ami_corewindow *ami_cw,
|
||||
browser_mouse_state mouse_state,
|
||||
int x, int y)
|
||||
{
|
||||
hotlist_mouse_action(mouse_state, x, y);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* callback for keypress for hotlist viewer on core window
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param nskey The netsurf key code
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_hotlist_key(struct ami_corewindow *ami_cw, uint32_t nskey)
|
||||
{
|
||||
if (hotlist_keypress(nskey)) {
|
||||
return NSERROR_OK;
|
||||
}
|
||||
return NSERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* callback on draw event for hotlist viewer on core window
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param r The rectangle of the window that needs updating.
|
||||
* \param ctx The drawing context
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_hotlist_draw(struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
|
||||
{
|
||||
hotlist_redraw(x, y, r, ctx);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* callback for drag end on Amiga core window
|
||||
* ie. a drag *from* this window has ended
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param x mouse x co-ordinate
|
||||
* \param y mouse y co-ordinate
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_hotlist_drag_end(struct ami_corewindow *ami_cw, int x, int y)
|
||||
{
|
||||
nsurl *url = NULL;
|
||||
const char *title = NULL;
|
||||
bool ok = false;
|
||||
struct gui_window_2 *gwin;
|
||||
struct ami_corewindow *cw;
|
||||
|
||||
if(hotlist_has_selection()) {
|
||||
ok = hotlist_get_selection(&url, &title);
|
||||
}
|
||||
|
||||
if((ok == false) || (url == NULL)) {
|
||||
DisplayBeep(scrn);
|
||||
} else if(url) {
|
||||
if((gwin = ami_window_at_pointer(AMINS_WINDOW))) {
|
||||
browser_window_navigate(gwin->gw->bw,
|
||||
url,
|
||||
NULL,
|
||||
BW_NAVIGATE_HISTORY,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
} else if((cw = (struct ami_corewindow *)ami_window_at_pointer(AMINS_COREWINDOW)) &&
|
||||
(ami_cw->icon_drop != NULL)) {
|
||||
cw->icon_drop(cw, url, title, x, y);
|
||||
}
|
||||
}
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* callback for icon drop on Amiga core window
|
||||
* ie. a drag has ended *above* this window
|
||||
* \todo this may not be very flexible but serves our current purposes
|
||||
*
|
||||
* \param ami_cw The Amiga core window structure.
|
||||
* \param url url of dropped icon
|
||||
* \param title title of dropped icon
|
||||
* \param x mouse x co-ordinate
|
||||
* \param y mouse y co-ordinate
|
||||
* \return NSERROR_OK on success otherwise apropriate error code
|
||||
*/
|
||||
static nserror
|
||||
ami_hotlist_icon_drop(struct ami_corewindow *ami_cw, struct nsurl *url, const char *title, int x, int y)
|
||||
{
|
||||
hotlist_add_entry(url, title, true, y);
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu stuff
|
||||
*/
|
||||
|
||||
static void
|
||||
ami_hotlist_menu_free(struct ami_hotlist_window *hotlist_win)
|
||||
{
|
||||
SetAttrs(hotlist_win->core.objects[GID_CW_WIN],
|
||||
WINDOW_MenuStrip, NULL,
|
||||
TAG_DONE);
|
||||
|
||||
ami_menu_free_menu(hotlist_win->menu_data, AMI_HOTLIST_M_LAST, hotlist_win->imenu);
|
||||
}
|
||||
|
||||
/* menu hook functions */
|
||||
HOOKF(void, ami_hotlist_menu_item_project_export, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
char fname[1024];
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
if(AslRequestTags(savereq,
|
||||
ASLFR_Window, ami_cw->win,
|
||||
ASLFR_SleepWindow, TRUE,
|
||||
ASLFR_TitleText, messages_get("NetSurf"),
|
||||
ASLFR_Screen, scrn,
|
||||
ASLFR_InitialFile, "hotlist.html",
|
||||
TAG_DONE)) {
|
||||
strlcpy(fname, savereq->fr_Drawer, 1024);
|
||||
AddPart(fname, savereq->fr_File, 1024);
|
||||
ami_update_pointer(ami_cw->win, GUI_POINTER_WAIT);
|
||||
hotlist_export(fname, NULL);
|
||||
ami_update_pointer(ami_cw->win, GUI_POINTER_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_expand(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_expand_folders, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_expand(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_expand_links, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_expand(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_contract(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_collapse_folders, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_contract(true);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_collapse_links, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_contract(false);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
nsoption_set_int(hotlist_window_ypos, ami_cw->win->TopEdge);
|
||||
nsoption_set_int(hotlist_window_xpos, ami_cw->win->LeftEdge);
|
||||
nsoption_set_int(hotlist_window_xsize, ami_cw->win->Width);
|
||||
nsoption_set_int(hotlist_window_ysize, ami_cw->win->Height);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_project_close, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
struct ami_corewindow *ami_cw;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&ami_cw);
|
||||
|
||||
ami_cw->close_window = true;
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_edit_newfolder, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_add_folder(NULL, false, 0);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_edit_newlink, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_add_entry(NULL, NULL, false, 0);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_edit_edit, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_edit_selection();
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_keypress(NS_KEY_SELECT_ALL);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_keypress(NS_KEY_CLEAR_SELECTION);
|
||||
}
|
||||
|
||||
HOOKF(void, ami_hotlist_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
hotlist_keypress(NS_KEY_DELETE_LEFT);
|
||||
}
|
||||
|
||||
|
||||
/* menu setup */
|
||||
|
||||
static void ami_hotlist_menulabs(struct ami_menu_data **md)
|
||||
{
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_PROJECT, NM_TITLE, "Tree", 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPORT, NM_ITEM, "TreeExport", 'S', "TBImages:list_save",
|
||||
ami_hotlist_menu_item_project_export, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND, NM_ITEM, "Expand", 0, "TBImages:list_folderunfold", NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_ALL, NM_SUB, "All", '+', NULL,
|
||||
ami_hotlist_menu_item_project_expand_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_FOLDERS, NM_SUB, "Folders", 0, NULL,
|
||||
ami_hotlist_menu_item_project_expand_folders, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_EXPAND_LINKS, NM_SUB, "Links", 0, NULL,
|
||||
ami_hotlist_menu_item_project_expand_links, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE, NM_ITEM, "Collapse", 0, "TBImages:list_folderfold", NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_ALL, NM_SUB, "All", '-', NULL,
|
||||
ami_hotlist_menu_item_project_collapse_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_FOLDERS, NM_SUB, "Folders", 0, NULL,
|
||||
ami_hotlist_menu_item_project_collapse_folders, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_COLLAPSE_LINKS, NM_SUB, "Links", 0, NULL,
|
||||
ami_hotlist_menu_item_project_collapse_links, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_SNAPSHOT, NM_ITEM, "SnapshotWindow", 0, "TBImages:list_hold",
|
||||
ami_hotlist_menu_item_project_snapshot, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_CLOSE, NM_ITEM, "CloseWindow", 'K', "TBImages:list_cancel",
|
||||
ami_hotlist_menu_item_project_close, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWFOLDER, NM_ITEM, "TreeNewFolder", 'N', "TBImages:list_drawer",
|
||||
ami_hotlist_menu_item_edit_newfolder, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_NEWLINK, NM_ITEM, "TreeNewLink", 0, "TBImages:list_favouriteadd",
|
||||
ami_hotlist_menu_item_edit_newlink, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_EDIT_EDIT, NM_ITEM, "TreeEdit", 'E', "TBImages:list_edit",
|
||||
ami_hotlist_menu_item_edit_edit, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_SELECTALL, NM_ITEM, "SelectAllNS", 'A', NSA_SPACE,
|
||||
ami_hotlist_menu_item_edit_select_all, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_CLEAR, NM_ITEM, "ClearNS", 0, NSA_SPACE,
|
||||
ami_hotlist_menu_item_edit_clear, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL, 0);
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_DELETE, NM_ITEM, "TreeDelete", 0, "TBImages:list_delete",
|
||||
ami_hotlist_menu_item_edit_delete, NULL, 0);
|
||||
|
||||
ami_menu_alloc_item(md, AMI_HOTLIST_M_LAST, NM_END, NULL, 0, NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
static struct Menu *
|
||||
ami_hotlist_menu_create(struct ami_hotlist_window *hotlist_win)
|
||||
{
|
||||
ami_hotlist_menulabs(hotlist_win->menu_data);
|
||||
hotlist_win->imenu = ami_menu_layout(hotlist_win->menu_data, AMI_HOTLIST_M_LAST);
|
||||
if(hotlist_win->imenu == NULL) return NULL;
|
||||
|
||||
return hotlist_win->imenu;
|
||||
}
|
||||
|
||||
|
||||
static nserror
|
||||
ami_hotlist_create_window(struct ami_hotlist_window *hotlist_win)
|
||||
{
|
||||
struct ami_corewindow *ami_cw = (struct ami_corewindow *)&hotlist_win->core;
|
||||
|
||||
ami_cw->objects[GID_CW_WIN] = WindowObj,
|
||||
WA_ScreenTitle, ami_gui_get_screen_title(),
|
||||
WA_Title, ami_cw->wintitle,
|
||||
WA_Activate, TRUE,
|
||||
WA_DepthGadget, TRUE,
|
||||
WA_DragBar, TRUE,
|
||||
WA_CloseGadget, TRUE,
|
||||
WA_SizeGadget, TRUE,
|
||||
WA_SizeBRight, TRUE,
|
||||
WA_Top, nsoption_int(hotlist_window_ypos),
|
||||
WA_Left, nsoption_int(hotlist_window_xpos),
|
||||
WA_Width, nsoption_int(hotlist_window_xsize),
|
||||
WA_Height, nsoption_int(hotlist_window_ysize),
|
||||
WA_PubScreen, scrn,
|
||||
WA_ReportMouse, TRUE,
|
||||
WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
|
||||
IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
|
||||
IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY,
|
||||
WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
|
||||
WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE,
|
||||
WINDOW_SharedPort, sport,
|
||||
WINDOW_HorizProp, 1,
|
||||
WINDOW_VertProp, 1,
|
||||
WINDOW_UserData, hotlist_win,
|
||||
WINDOW_MenuStrip, ami_hotlist_menu_create(hotlist_win),
|
||||
WINDOW_MenuUserData, WGUD_HOOK,
|
||||
WINDOW_IconifyGadget, FALSE,
|
||||
WINDOW_Position, WPOS_CENTERSCREEN,
|
||||
WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
|
||||
LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
|
||||
GA_ID, GID_CW_DRAW,
|
||||
SPACE_Transparent, TRUE,
|
||||
SPACE_BevelStyle, BVS_DISPLAY,
|
||||
GA_RelVerify, TRUE,
|
||||
SpaceEnd,
|
||||
EndGroup,
|
||||
EndWindow;
|
||||
|
||||
if(ami_cw->objects[GID_CW_WIN] == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy a previously created hotlist view
|
||||
*/
|
||||
static void
|
||||
ami_hotlist_destroy(struct ami_corewindow *ami_cw)
|
||||
{
|
||||
nserror res;
|
||||
|
||||
if(hotlist_window == NULL)
|
||||
return;
|
||||
|
||||
res = hotlist_manager_fini();
|
||||
if (res == NSERROR_OK) {
|
||||
ami_hotlist_menu_free(hotlist_window);
|
||||
res = ami_corewindow_fini(&hotlist_window->core); /* closes the window for us, frees hotlist_win */
|
||||
hotlist_window = NULL;
|
||||
}
|
||||
|
||||
ami_gui_hotlist_update_all();
|
||||
}
|
||||
|
||||
|
||||
/* exported interface documented in amiga/hotlist.h */
|
||||
nserror ami_hotlist_present(void)
|
||||
{
|
||||
struct ami_hotlist_window *ncwin;
|
||||
nserror res;
|
||||
|
||||
if(hotlist_window != NULL) {
|
||||
//windowtofront()
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
ncwin = calloc(1, sizeof(struct ami_hotlist_window));
|
||||
if (ncwin == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
|
||||
ncwin->core.wintitle = ami_utf8_easy((char *)messages_get("Hotlist"));
|
||||
|
||||
res = ami_hotlist_create_window(ncwin);
|
||||
if (res != NSERROR_OK) {
|
||||
LOG("SSL UI builder init failed");
|
||||
ami_utf8_free(ncwin->core.wintitle);
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
/* initialise Amiga core window */
|
||||
ncwin->core.draw = ami_hotlist_draw;
|
||||
ncwin->core.key = ami_hotlist_key;
|
||||
ncwin->core.mouse = ami_hotlist_mouse;
|
||||
ncwin->core.close = ami_hotlist_destroy;
|
||||
ncwin->core.event = NULL;
|
||||
ncwin->core.drag_end = ami_hotlist_drag_end;
|
||||
ncwin->core.icon_drop = ami_hotlist_icon_drop;
|
||||
|
||||
res = ami_corewindow_init(&ncwin->core);
|
||||
if (res != NSERROR_OK) {
|
||||
ami_utf8_free(ncwin->core.wintitle);
|
||||
DisposeObject(ncwin->core.objects[GID_CW_WIN]);
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
res = hotlist_manager_init(ncwin->core.cb_table, (struct core_window *)ncwin);
|
||||
if (res != NSERROR_OK) {
|
||||
ami_utf8_free(ncwin->core.wintitle);
|
||||
DisposeObject(ncwin->core.objects[GID_CW_WIN]);
|
||||
free(ncwin);
|
||||
return res;
|
||||
}
|
||||
|
||||
hotlist_window = ncwin;
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* exported interface documented in amiga/hotlist.h */
|
||||
void ami_hotlist_close(void)
|
||||
{
|
||||
ami_hotlist_destroy((struct ami_corewindow *)hotlist_window);
|
||||
}
|
||||
|
||||
|
22
frontends/amiga/hotlist.h
Executable file → Normal file
22
frontends/amiga/hotlist.h
Executable file → Normal file
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2017 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -19,16 +19,18 @@
|
||||
#ifndef AMIGA_HOTLIST_H
|
||||
#define AMIGA_HOTLIST_H
|
||||
|
||||
struct nsurl;
|
||||
struct treeview_window;
|
||||
#include "utils/nsurl.h"
|
||||
|
||||
extern struct treeview_window *hotlist_window;
|
||||
|
||||
void ami_hotlist_initialise(const char *hotlist_file);
|
||||
|
||||
void ami_hotlist_free(const char *hotlist_file);
|
||||
|
||||
nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder, bool (*cb_add_item)(void *userdata, int level, int item, const char *title, struct nsurl *url, bool folder));
|
||||
/** Open the hotlist viewer */
|
||||
nserror ami_hotlist_present(void);
|
||||
|
||||
/** Close the hotlist viewer
|
||||
* normally this shouldn't be used; only exists for ARexx use
|
||||
*/
|
||||
void ami_hotlist_close(void);
|
||||
|
||||
/** Scan the hotlist */
|
||||
nserror ami_hotlist_scan(void *userdata, int first_item, const char *folder,
|
||||
bool (*cb_add_item)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder));
|
||||
#endif
|
||||
|
||||
|
@ -73,7 +73,6 @@
|
||||
#include "amiga/print.h"
|
||||
#include "amiga/search.h"
|
||||
#include "amiga/theme.h"
|
||||
#include "amiga/tree.h"
|
||||
#include "amiga/utf8.h"
|
||||
#include "amiga/schedule.h"
|
||||
|
||||
@ -106,7 +105,7 @@ static bool menu_glyphs_loaded = false;
|
||||
const char * const netsurf_version;
|
||||
const char * const verdate;
|
||||
|
||||
static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md);
|
||||
static nserror ami_menu_scan(struct ami_menu_data **md);
|
||||
void ami_menu_arexx_scan(struct ami_menu_data **md);
|
||||
|
||||
void ami_menu_set_check_toggled(void)
|
||||
@ -362,7 +361,7 @@ HOOKF(void, ami_menu_item_browser_localhistory, APTR, window, struct IntuiMessag
|
||||
|
||||
HOOKF(void, ami_menu_item_browser_globalhistory, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
ami_tree_open(global_history_window,AMI_TREE_HISTORY);
|
||||
ami_history_global_present();
|
||||
}
|
||||
|
||||
HOOKF(void, ami_menu_item_browser_cookies, APTR, window, struct IntuiMessage *)
|
||||
@ -456,7 +455,7 @@ HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *)
|
||||
|
||||
HOOKF(void, ami_menu_item_hotlist_show, APTR, window, struct IntuiMessage *)
|
||||
{
|
||||
ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
|
||||
ami_hotlist_present();
|
||||
}
|
||||
|
||||
HOOKF(void, ami_menu_item_hotlist_entries, APTR, window, struct IntuiMessage *)
|
||||
@ -992,7 +991,7 @@ void ami_menu_free_menu(struct ami_menu_data **md, int max, struct Menu *imenu)
|
||||
struct Menu *ami_menu_create(struct gui_window_2 *gwin)
|
||||
{
|
||||
ami_init_menulabs(gwin->menu_data);
|
||||
ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin->menu_data); //\todo this needs to be MenuClass created
|
||||
ami_menu_scan(gwin->menu_data); //\todo this needs to be MenuClass created
|
||||
ami_menu_arexx_scan(gwin->menu_data);
|
||||
gwin->imenu = ami_menu_layout(gwin->menu_data, AMI_MENU_AREXX_MAX);
|
||||
|
||||
@ -1092,7 +1091,7 @@ static bool ami_menu_hotlist_add(void *userdata, int level, int item, const char
|
||||
return true;
|
||||
}
|
||||
|
||||
static nserror ami_menu_scan(struct tree *tree, struct ami_menu_data **md)
|
||||
static nserror ami_menu_scan(struct ami_menu_data **md)
|
||||
{
|
||||
return ami_hotlist_scan((void *)md, AMI_MENU_HOTLIST, messages_get("HotlistMenu"), ami_menu_hotlist_add);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef AMIGA_TREE_H
|
||||
#define AMIGA_TREE_H
|
||||
|
||||
#include <exec/types.h>
|
||||
#include <intuition/classusr.h>
|
||||
#include "amiga/os3support.h"
|
||||
#include "amiga/desktop-tree.h"
|
||||
|
||||
struct treeview_window;
|
||||
|
||||
enum
|
||||
{
|
||||
AMI_TREE_HOTLIST,
|
||||
AMI_TREE_HISTORY,
|
||||
AMI_TREE_COOKIES,
|
||||
AMI_TREE_SSLCERT
|
||||
};
|
||||
|
||||
struct treeview_window *ami_tree_create(int flags,
|
||||
struct sslcert_session_data *ssl_data);
|
||||
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(void *w); /* for Arexx interface only */
|
||||
|
||||
extern const struct treeview_table ami_tree_callbacks;
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user