NetSurf
Data Structures | Enumerations | Functions | Variables
hotlist.c File Reference

Implementation of Amiga hotlist viewer using core windows. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.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/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/libs.h"
#include "amiga/menu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
Include dependency graph for hotlist.c:

Go to the source code of this file.

Data Structures

struct  ami_hotlist_window
 Amiga hotlist viewer window context. More...
 
struct  ami_hotlist_ctx
 

Enumerations

enum  {
  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 , 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
}
 

Functions

static nserror ami_hotlist_folder_enter_cb (void *ctx, const char *title)
 hotlist scanner More...
 
static nserror ami_hotlist_address_cb (void *ctx, nsurl *url, const char *title)
 
static nserror ami_hotlist_folder_leave_cb (void *ctx)
 
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))
 Scan the hotlist. More...
 
static nserror ami_hotlist_mouse (struct ami_corewindow *ami_cw, browser_mouse_state mouse_state, int x, int y)
 callback for mouse action for hotlist viewer on core window More...
 
static nserror ami_hotlist_key (struct ami_corewindow *ami_cw, uint32_t nskey)
 callback for keypress for hotlist viewer on core window More...
 
static nserror ami_hotlist_draw (struct ami_corewindow *ami_cw, int x, int y, struct rect *r, struct redraw_context *ctx)
 callback on draw event for hotlist viewer on core window More...
 
static nserror ami_hotlist_drag_end (struct ami_corewindow *ami_cw, int x, int y)
 callback for drag end on Amiga core window ie. More...
 
static nserror ami_hotlist_icon_drop (struct ami_corewindow *ami_cw, struct nsurl *url, const char *title, int x, int y)
 callback for icon drop on Amiga core window ie. More...
 
static void ami_hotlist_menu_free (struct ami_hotlist_window *hotlist_win)
 menu stuff More...
 
 HOOKF (void, ami_hotlist_menu_item_project_export, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_expand_all, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_expand_folders, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_expand_links, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_collapse_all, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_collapse_folders, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_collapse_links, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_snapshot, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_project_close, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_edit_newfolder, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_edit_newlink, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_edit_edit, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_edit_select_all, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_edit_clear, APTR, window, struct IntuiMessage *)
 
 HOOKF (void, ami_hotlist_menu_item_edit_delete, APTR, window, struct IntuiMessage *)
 
static void ami_hotlist_menulabs (struct ami_menu_data **md)
 
static struct Menu * ami_hotlist_menu_create (struct ami_hotlist_window *hotlist_win)
 
static nserror ami_hotlist_create_window (struct ami_hotlist_window *hotlist_win)
 
static void ami_hotlist_destroy (struct ami_corewindow *ami_cw)
 destroy a previously created hotlist view More...
 
nserror ami_hotlist_present (void)
 Open the hotlist viewer. More...
 
void ami_hotlist_close (void)
 Close the hotlist viewer normally this shouldn't be used; only exists for ARexx use. More...
 

Variables

static struct ami_hotlist_windowhotlist_window = NULL
 

Detailed Description

Implementation of Amiga hotlist viewer using core windows.

Definition in file hotlist.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
AMI_HOTLIST_M_PROJECT 
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 
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 

Definition at line 56 of file hotlist.c.

Function Documentation

◆ ami_hotlist_address_cb()

static nserror ami_hotlist_address_cb ( void *  ctx,
nsurl url,
const char *  title 
)
static

Definition at line 127 of file hotlist.c.

References ami_hotlist_ctx::cb, ami_hotlist_ctx::in_menu, ami_hotlist_ctx::item, ami_hotlist_ctx::level, NSERROR_OK, and ami_hotlist_ctx::userdata.

Referenced by ami_hotlist_scan().

Here is the caller graph for this function:

◆ ami_hotlist_close()

void ami_hotlist_close ( void  )

Close the hotlist viewer normally this shouldn't be used; only exists for ARexx use.

Definition at line 603 of file hotlist.c.

References ami_hotlist_destroy(), and hotlist_window.

Referenced by RXHOOKF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_create_window()

static nserror ami_hotlist_create_window ( struct ami_hotlist_window hotlist_win)
static

Definition at line 468 of file hotlist.c.

References ami_gui_get_screen(), ami_gui_get_screen_title(), ami_gui_get_shared_msgport(), ami_hotlist_menu_create(), BVS_DISPLAY, ami_hotlist_window::core, GID_CW_DRAW, GID_CW_MAIN, GID_CW_WIN, IDCMP_EXTENDEDMOUSE, ami_corewindow::idcmp_hook, LayoutVObj, NSERROR_NOMEM, NSERROR_OK, nsoption_bool, nsoption_int, ami_corewindow::objects, SpaceObj, WindowObj, and ami_corewindow::wintitle.

Referenced by ami_hotlist_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_destroy()

static void ami_hotlist_destroy ( struct ami_corewindow ami_cw)
static

destroy a previously created hotlist view

Definition at line 528 of file hotlist.c.

References ami_corewindow_fini(), ami_gui_hotlist_update_all(), ami_hotlist_menu_free(), ami_hotlist_window::core, hotlist_manager_fini(), hotlist_window, and NSERROR_OK.

Referenced by ami_hotlist_close(), and ami_hotlist_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_drag_end()

static nserror ami_hotlist_drag_end ( struct ami_corewindow ami_cw,
int  x,
int  y 
)
static

callback for drag end on Amiga core window ie.

a drag from this window has ended

Parameters
ami_cwThe Amiga core window structure.
xmouse x co-ordinate
ymouse y co-ordinate
Returns
NSERROR_OK on success otherwise apropriate error code

Definition at line 241 of file hotlist.c.

References ami_gui2_get_browser_window(), ami_gui_beep(), ami_window_at_pointer(), AMINS_COREWINDOW, AMINS_WINDOW, browser_window_navigate(), BW_NAVIGATE_HISTORY, hotlist_get_selection(), hotlist_has_selection(), ami_corewindow::icon_drop, and NSERROR_OK.

Referenced by ami_hotlist_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_draw()

static nserror ami_hotlist_draw ( struct ami_corewindow ami_cw,
int  x,
int  y,
struct rect r,
struct redraw_context ctx 
)
static

callback on draw event for hotlist viewer on core window

Parameters
ami_cwThe Amiga core window structure.
xThe x coordinate of hotlist area to redraw
yThe y coordinate of hotlist area to redraw
rThe rectangle of the window that needs updating.
ctxThe drawing context
Returns
NSERROR_OK on success otherwise apropriate error code

Definition at line 223 of file hotlist.c.

References hotlist_redraw(), and NSERROR_OK.

Referenced by ami_hotlist_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_folder_enter_cb()

static nserror ami_hotlist_folder_enter_cb ( void *  ctx,
const char *  title 
)
static

hotlist scanner

Definition at line 110 of file hotlist.c.

References ami_hotlist_ctx::cb, ami_hotlist_ctx::folder, ami_hotlist_ctx::found, ami_hotlist_ctx::in_menu, ami_hotlist_ctx::item, ami_hotlist_ctx::level, NSERROR_OK, and ami_hotlist_ctx::userdata.

Referenced by ami_hotlist_scan().

Here is the caller graph for this function:

◆ ami_hotlist_folder_leave_cb()

static nserror ami_hotlist_folder_leave_cb ( void *  ctx)
static

Definition at line 139 of file hotlist.c.

References ami_hotlist_ctx::in_menu, ami_hotlist_ctx::level, and NSERROR_OK.

Referenced by ami_hotlist_scan().

Here is the caller graph for this function:

◆ ami_hotlist_icon_drop()

static nserror ami_hotlist_icon_drop ( struct ami_corewindow ami_cw,
struct nsurl url,
const char *  title,
int  x,
int  y 
)
static

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
Parameters
ami_cwThe Amiga core window structure.
urlurl of dropped icon
titletitle of dropped icon
xmouse x co-ordinate
ymouse y co-ordinate
Returns
NSERROR_OK on success otherwise apropriate error code

Definition at line 285 of file hotlist.c.

References hotlist_add_entry(), and NSERROR_OK.

Referenced by ami_hotlist_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_key()

static nserror ami_hotlist_key ( struct ami_corewindow ami_cw,
uint32_t  nskey 
)
static

callback for keypress for hotlist viewer on core window

Parameters
ami_cwThe Amiga core window structure.
nskeyThe netsurf key code
Returns
NSERROR_OK on success otherwise apropriate error code

Definition at line 204 of file hotlist.c.

References hotlist_keypress(), NSERROR_NOT_IMPLEMENTED, and NSERROR_OK.

Referenced by ami_hotlist_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_menu_create()

static struct Menu * ami_hotlist_menu_create ( struct ami_hotlist_window hotlist_win)
static

Definition at line 457 of file hotlist.c.

References AMI_HOTLIST_M_LAST, ami_hotlist_menulabs(), ami_menu_layout(), ami_hotlist_window::imenu, and ami_hotlist_window::menu_data.

Referenced by ami_hotlist_create_window().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_menu_free()

static void ami_hotlist_menu_free ( struct ami_hotlist_window hotlist_win)
static

menu stuff

Definition at line 296 of file hotlist.c.

References AMI_HOTLIST_M_LAST, ami_menu_free_menu(), ami_hotlist_window::core, GID_CW_WIN, ami_hotlist_window::imenu, ami_hotlist_window::menu_data, and ami_corewindow::objects.

Referenced by ami_hotlist_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_menulabs()

static void ami_hotlist_menulabs ( struct ami_menu_data **  md)
static

◆ ami_hotlist_mouse()

static nserror ami_hotlist_mouse ( struct ami_corewindow ami_cw,
browser_mouse_state  mouse_state,
int  x,
int  y 
)
static

callback for mouse action for hotlist viewer on core window

Parameters
ami_cwThe Amiga core window structure.
mouse_statenetsurf mouse state on event
xlocation of event
ylocation of event
Returns
NSERROR_OK on success otherwise apropriate error code

Definition at line 187 of file hotlist.c.

References hotlist_mouse_action(), and NSERROR_OK.

Referenced by ami_hotlist_present().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_present()

nserror ami_hotlist_present ( void  )

Open the hotlist viewer.

Definition at line 547 of file hotlist.c.

References ami_corewindow_init(), ami_hotlist_create_window(), ami_hotlist_destroy(), ami_hotlist_drag_end(), ami_hotlist_draw(), ami_hotlist_icon_drop(), ami_hotlist_key(), ami_hotlist_mouse(), ami_utf8_easy(), ami_utf8_free(), ami_corewindow::close, ami_hotlist_window::core, ami_corewindow::drag_end, ami_corewindow::draw, ami_corewindow::event, GID_CW_WIN, hotlist_manager_init(), hotlist_window, ami_corewindow::icon_drop, ami_corewindow::key, messages_get(), ami_corewindow::mouse, NSERROR_NOMEM, NSERROR_OK, NSLOG, ami_corewindow::objects, and ami_corewindow::wintitle.

Referenced by HOOKF(), and RXHOOKF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_hotlist_scan()

nserror ami_hotlist_scan ( void *  userdata,
int  first_item,
const char *  folder,
bool(*)(void *userdata, int level, int item, const char *title, nsurl *url, bool folder)  cb_add_item 
)

Scan the hotlist.

Definition at line 151 of file hotlist.c.

References ami_hotlist_address_cb(), ami_hotlist_folder_enter_cb(), ami_hotlist_folder_leave_cb(), ami_hotlist_ctx::cb, ami_hotlist_ctx::folder, ami_hotlist_ctx::found, hotlist_add_folder(), hotlist_iterate(), ami_hotlist_ctx::in_menu, ami_hotlist_ctx::item, ami_hotlist_ctx::level, NSERROR_OK, and ami_hotlist_ctx::userdata.

Referenced by ami_gui_hotlist_scan(), and ami_menu_scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HOOKF() [1/15]

HOOKF ( void  ,
ami_hotlist_menu_item_edit_clear  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 396 of file hotlist.c.

References hotlist_keypress(), and NS_KEY_CLEAR_SELECTION.

Here is the call graph for this function:

◆ HOOKF() [2/15]

HOOKF ( void  ,
ami_hotlist_menu_item_edit_delete  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 401 of file hotlist.c.

References hotlist_keypress(), and NS_KEY_DELETE_LEFT.

Here is the call graph for this function:

◆ HOOKF() [3/15]

HOOKF ( void  ,
ami_hotlist_menu_item_edit_edit  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 386 of file hotlist.c.

References hotlist_edit_selection().

Here is the call graph for this function:

◆ HOOKF() [4/15]

HOOKF ( void  ,
ami_hotlist_menu_item_edit_newfolder  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 376 of file hotlist.c.

References hotlist_add_folder().

Here is the call graph for this function:

◆ HOOKF() [5/15]

HOOKF ( void  ,
ami_hotlist_menu_item_edit_newlink  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 381 of file hotlist.c.

References hotlist_add_entry().

Here is the call graph for this function:

◆ HOOKF() [6/15]

HOOKF ( void  ,
ami_hotlist_menu_item_edit_select_all  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 391 of file hotlist.c.

References hotlist_keypress(), and NS_KEY_SELECT_ALL.

Here is the call graph for this function:

◆ HOOKF() [7/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_close  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 368 of file hotlist.c.

References ami_corewindow::close_window.

◆ HOOKF() [8/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_collapse_all  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 342 of file hotlist.c.

References hotlist_contract().

Here is the call graph for this function:

◆ HOOKF() [9/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_collapse_folders  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 347 of file hotlist.c.

References hotlist_contract().

Here is the call graph for this function:

◆ HOOKF() [10/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_collapse_links  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 352 of file hotlist.c.

References hotlist_contract().

Here is the call graph for this function:

◆ HOOKF() [11/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_expand_all  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 327 of file hotlist.c.

References hotlist_expand().

Here is the call graph for this function:

◆ HOOKF() [12/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_expand_folders  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 332 of file hotlist.c.

References hotlist_expand().

Here is the call graph for this function:

◆ HOOKF() [13/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_expand_links  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 337 of file hotlist.c.

References hotlist_expand().

Here is the call graph for this function:

◆ HOOKF() [14/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_export  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 306 of file hotlist.c.

References ami_gui_get_screen(), ami_update_pointer(), GUI_POINTER_DEFAULT, GUI_POINTER_WAIT, hotlist_export(), messages_get(), savereq, and ami_corewindow::win.

Here is the call graph for this function:

◆ HOOKF() [15/15]

HOOKF ( void  ,
ami_hotlist_menu_item_project_snapshot  ,
APTR  ,
window  ,
struct IntuiMessage *   
)

Definition at line 357 of file hotlist.c.

References nsoption_set_int, and ami_corewindow::win.

Variable Documentation

◆ hotlist_window

struct ami_hotlist_window* hotlist_window = NULL
static

Definition at line 97 of file hotlist.c.

Referenced by ami_hotlist_close(), ami_hotlist_destroy(), and ami_hotlist_present().