NetSurf
Typedefs | Functions
hotlist.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "utils/errors.h"
#include "netsurf/mouse.h"
Include dependency graph for hotlist.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef nserror(* hotlist_folder_enter_cb) (void *ctx, const char *title)
 Client callback for hotlist_iterate, reporting entry into folder. More...
 
typedef nserror(* hotlist_address_cb) (void *ctx, struct nsurl *url, const char *title)
 Client callback for hotlist_iterate, reporting a hotlist address. More...
 
typedef nserror(* hotlist_folder_leave_cb) (void *ctx)
 Client callback for hotlist_iterate, reporting a hotlist folder departure. More...
 

Functions

nserror hotlist_init (const char *load_path, const char *save_path)
 Initialise the hotlist. More...
 
nserror hotlist_manager_init (void *core_window_handle)
 Initialise the hotlist manager. More...
 
nserror hotlist_manager_fini (void)
 Finalise the hotlist manager. More...
 
nserror hotlist_fini (void)
 Finalise the hotlist. More...
 
nserror hotlist_add_url (struct nsurl *url)
 Add an entry to the hotlist for given URL. More...
 
bool hotlist_has_url (struct nsurl *url)
 Check whether given URL is present in hotlist. More...
 
void hotlist_remove_url (struct nsurl *url)
 Remove any entries matching the given URL from the hotlist. More...
 
void hotlist_update_url (struct nsurl *url)
 Update given URL, e.g. More...
 
nserror hotlist_add_entry (struct nsurl *url, const char *title, bool at_y, int y)
 Add an entry to the hotlist for given Title/URL. More...
 
nserror hotlist_add_folder (const char *title, bool at_y, int y)
 Add a folder to the hotlist. More...
 
nserror hotlist_export (const char *path, const char *title)
 Save hotlist to file. More...
 
nserror hotlist_iterate (void *ctx, hotlist_folder_enter_cb enter_cb, hotlist_address_cb address_cb, hotlist_folder_leave_cb leave_cb)
 Walk (depth first) the hotlist, calling callbacks on entering folders, address nodes, and on leaving folders. More...
 
void hotlist_redraw (int x, int y, struct rect *clip, const struct redraw_context *ctx)
 Redraw the hotlist. More...
 
void hotlist_mouse_action (enum browser_mouse_state mouse, int x, int y)
 Handles all kinds of mouse action. More...
 
bool hotlist_keypress (uint32_t key)
 Key press handling. More...
 
bool hotlist_has_selection (void)
 Determine whether there is a selection. More...
 
bool hotlist_get_selection (struct nsurl **url, const char **title)
 Get the first selected node. More...
 
void hotlist_edit_selection (void)
 Edit the first selected node. More...
 
nserror hotlist_expand (bool only_folders)
 Expand the treeview's nodes. More...
 
nserror hotlist_contract (bool all)
 Contract the treeview's nodes. More...
 

Typedef Documentation

◆ hotlist_address_cb

typedef nserror(* hotlist_address_cb) (void *ctx, struct nsurl *url, const char *title)

Client callback for hotlist_iterate, reporting a hotlist address.

Parameters
ctxClient context
urlThe entry's address
titleThe entry's title
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 163 of file hotlist.h.

◆ hotlist_folder_enter_cb

typedef nserror(* hotlist_folder_enter_cb) (void *ctx, const char *title)

Client callback for hotlist_iterate, reporting entry into folder.

Parameters
ctxClient context
titleThe entered folder's title
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 153 of file hotlist.h.

◆ hotlist_folder_leave_cb

typedef nserror(* hotlist_folder_leave_cb) (void *ctx)

Client callback for hotlist_iterate, reporting a hotlist folder departure.

Parameters
ctxClient context
titleThe departed folder's title
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 172 of file hotlist.h.

Function Documentation

◆ hotlist_add_entry()

nserror hotlist_add_entry ( struct nsurl url,
const char *  title,
bool  at_y,
int  y 
)

Add an entry to the hotlist for given Title/URL.

Parameters
urlURL for entry to be added, or NULL
titleTitle for entry being added (copied), or NULL
at_yIff true, insert at y-offest
yY-offset in px from top of hotlist. Ignored if (!at_y).
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1623 of file hotlist.c.

References hl_ctx, hotlist_add_entry_internal(), NSERROR_OK, nsurl_create(), nsurl_ref(), nsurl_unref(), hotlist_ctx::tree, treeview_get_relation(), and treeview_update_url_walk_ctx::url.

Referenced by ami_hotlist_icon_drop(), atari_hotlist_add_page(), HOOKF(), hotlist_menu_select(), and MENUHANDLER().

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

◆ hotlist_add_folder()

nserror hotlist_add_folder ( const char *  title,
bool  at_y,
int  y 
)

Add a folder to the hotlist.

Parameters
titleTitle for folder being added, or NULL
at_yIff true, insert at y-offest
yY-offset in px from top of hotlist. Ignored if (!at_y).
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1660 of file hotlist.c.

References hl_ctx, hotlist_add_folder_internal(), NSERROR_OK, hotlist_ctx::tree, and treeview_get_relation().

Referenced by ami_hotlist_scan(), handle_event(), HOOKF(), hotlist_menu_select(), hotlist_toolbar_click(), and MENUHANDLER().

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

◆ hotlist_add_url()

nserror hotlist_add_url ( struct nsurl url)

Add an entry to the hotlist for given URL.

Parameters
urlURL for node being added
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1430 of file hotlist.c.

References hotlist_ctx::default_folder, hotlist_folder::folder, hl_ctx, hotlist_add_entry_internal(), hotlist_add_folder_internal(), hotlist_schedule_save(), messages_get(), NSERROR_NOMEM, NSERROR_OK, hotlist_ctx::tree, TREE_REL_FIRST_CHILD, and treeview_node_expand().

Referenced by addbookmarks_button_clicked_cb(), ami_gui_event(), HOOKF(), nsgtk_on_link_bookmark_activate_menu(), ro_gui_hotlist_add_page(), ro_gui_hotlist_addurl_bounce(), and toolbar_favorite_click().

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

◆ hotlist_contract()

nserror hotlist_contract ( bool  all)

Contract the treeview's nodes.

Parameters
allIff false, only entries are contracted.
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1747 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_contract().

Referenced by HOOKF(), hotlist_menu_select(), hotlist_toolbar_click(), and MENUHANDLER().

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

◆ hotlist_edit_selection()

void hotlist_edit_selection ( void  )

Edit the first selected node.

Definition at line 1733 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_edit_selection().

Referenced by handle_event(), HOOKF(), hotlist_menu_select(), and MENUHANDLER().

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

◆ hotlist_expand()

nserror hotlist_expand ( bool  only_folders)

Expand the treeview's nodes.

Parameters
only_foldersIff true, only folders are expanded.
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1740 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_expand().

Referenced by HOOKF(), hotlist_menu_select(), hotlist_toolbar_click(), and MENUHANDLER().

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

◆ hotlist_export()

nserror hotlist_export ( const char *  path,
const char *  title 
)

Save hotlist to file.

Parameters
pathThe path to save hotlist to
titleThe title to give the hotlist, or NULL for default
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 1086 of file hotlist.c.

References treeview_export_walk_ctx::fp, hl_ctx, hotlist_export_enter_cb(), hotlist_export_leave_cb(), NSERROR_OK, NSERROR_SAVE_FAILED, path(), hotlist_ctx::tree, TREE_NODE_ENTRY, TREE_NODE_FOLDER, and treeview_walk().

Referenced by HOOKF(), hotlist_save(), MENUHANDLER(), and ro_gui_save_content().

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

◆ hotlist_fini()

nserror hotlist_fini ( void  )

Finalise the hotlist.

This destroys the hotlist treeview and the hotlist module's internal data. After calling this if hotlist is required again, hotlist_init must be called.

Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1387 of file hotlist.c.

References hotlist_ctx::built, treeview_field_desc::field, hotlist_ctx::fields, guit, hl_ctx, HL_N_FIELDS, hotlist_save(), hotlist_schedule_save_cb(), netsurf_table::misc, NSERROR_OK, NSLOG, hotlist_ctx::save_path, hotlist_ctx::save_scheduled, gui_misc_table::schedule, hotlist_ctx::tree, treeview_destroy(), and treeview_fini().

Referenced by atari_hotlist_finish(), gui_quit(), nsgtk_finalise(), nsw32_hotlist_finalise(), and ro_gui_hotlist_finalise().

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

◆ hotlist_get_selection()

bool hotlist_get_selection ( struct nsurl **  url,
const char **  title 
)

Get the first selected node.

Parameters
urlUpdated to the selected entry's address, or NULL
titleUpdated to the selected entry's title, or NULL
Returns
true iff hotlist has a selection

Definition at line 1711 of file hotlist.c.

References hotlist_entry::data, hl_ctx, HL_TITLE, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_get_selection(), type, hotlist_entry::url, and treeview_field_data::value.

Referenced by ami_hotlist_drag_end().

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

◆ hotlist_has_selection()

bool hotlist_has_selection ( void  )

Determine whether there is a selection.

Returns
true iff there is a selection

Definition at line 1704 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_has_selection().

Referenced by ami_hotlist_drag_end(), hotlist_menu_prepare(), and hotlist_toolbar_update().

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

◆ hotlist_has_url()

bool hotlist_has_url ( struct nsurl url)

Check whether given URL is present in hotlist.

Parameters
urlAddress to look for in hotlist
Returns
true iff url is present in hotlist, false otherwise

Definition at line 1493 of file hotlist.c.

References hotlist_ctx::built, treeview_has_url_walk_ctx::found, hl_ctx, hotlist_has_url_walk_cb(), NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_walk(), and treeview_has_url_walk_ctx::url.

Referenced by ami_gui_event(), ami_gui_update_hotlist_button(), atari_hotlist_add_page(), ro_gui_hotlist_has_page(), ro_gui_hotlist_remove_page(), and toolbar_favorite_click().

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

◆ hotlist_init()

nserror hotlist_init ( const char *  load_path,
const char *  save_path 
)

Initialise the hotlist.

This opens the hotlist file, construct the hostlist, and creates a treeview. If there's no hotlist file, it generates a default hotlist.

This must be called before any other hotlist_* function. It must be called before URLs can be added to the hotlist, and before the hotlist can be queried to ask if URLs are present in the hotlist.

In read-only mode the hotlist can be modified, but changes will not persist over sessions.

Parameters
load_pathThe path to load hotlist from.
save_pathThe path to save hotlist to, or NULL for read-only mode.
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1290 of file hotlist.c.

References hotlist_ctx::built, hotlist_ctx::default_folder, hotlist_ctx::fields, hl_ctx, HL_N_FIELDS, hl_tree_cb_t, hotlist_initialise_entry_fields(), hotlist_populate(), NSERROR_NOMEM, NSERROR_OK, NSLOG, hotlist_ctx::save_path, hotlist_ctx::tree, treeview_create(), treeview_init(), and TREEVIEW_SEARCHABLE.

Referenced by atari_hotlist_init(), gui_init(), gui_init2(), nsgtk_setup(), and WinMain().

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

◆ hotlist_iterate()

nserror hotlist_iterate ( void *  ctx,
hotlist_folder_enter_cb  enter_cb,
hotlist_address_cb  address_cb,
hotlist_folder_leave_cb  leave_cb 
)

Walk (depth first) the hotlist, calling callbacks on entering folders, address nodes, and on leaving folders.

Parameters
ctxClient context, passed back to callback function
enter_cbFunction to call on entering nodes, or NULL
address_cbFunction to call on address nodes, or NULL
leave_cbFunction to call on leaving nodes, or NULL
Returns
NSERROR_OK on success, or appropriate error otherwise

Example usage: Generate a menu containing hotlist entries. For flat list set enter_cb and leave_cb to NULL, or for hierarchical menu provide the folder callbacks.

Definition at line 1164 of file hotlist.c.

References hotlist_iterate_ctx::address_cb, hotlist_iterate_ctx::ctx, hotlist_iterate_ctx::enter_cb, hl_ctx, hotlist_iterate_enter_cb(), hotlist_iterate_leave_cb(), hotlist_iterate_ctx::leave_cb, NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, TREE_NODE_FOLDER, and treeview_walk().

Referenced by ami_hotlist_scan().

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

◆ hotlist_keypress()

bool hotlist_keypress ( uint32_t  key)

Key press handling.

Parameters
keyThe ucs4 character codepoint
Returns
true if the keypress is dealt with, false otherwise.

Definition at line 1697 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_keypress().

Referenced by ami_hotlist_key(), atari_hotlist_keypress(), handle_event(), HOOKF(), hotlist_key(), hotlist_menu_select(), hotlist_toolbar_click(), MENUHANDLER(), nsgtk_hotlist_key(), and nsw32_hotlist_key().

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

◆ hotlist_manager_fini()

nserror hotlist_manager_fini ( void  )

Finalise the hotlist manager.

This simply disconnects the underlying treeview from its corewindow, allowing destruction of a GUI hotlist window, without finalising the hotlist module.

Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1372 of file hotlist.c.

References hl_ctx, NSERROR_OK, hotlist_ctx::tree, and treeview_cw_detach().

Referenced by ami_hotlist_destroy(), and nsgtk_hotlist_destroy().

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

◆ hotlist_manager_init()

nserror hotlist_manager_init ( void *  core_window_handle)

Initialise the hotlist manager.

This connects the underlying hotlist treeview to a corewindow for display.

The provided core window handle must be valid until hotlist_fini is called.

Parameters
core_window_handleThe handle in which the hotlist is shown
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1354 of file hotlist.c.

References hl_ctx, NSERROR_OK, hotlist_ctx::tree, treeview_cw_attach(), and treeview_get_height().

Referenced by ami_hotlist_present(), atari_hotlist_init_phase2(), nsgtk_hotlist_init(), nsw32_hotlist_init(), and ro_hotlist_init().

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

◆ hotlist_mouse_action()

void hotlist_mouse_action ( enum browser_mouse_state  mouse,
int  x,
int  y 
)

Handles all kinds of mouse action.

Parameters
mouseThe current mouse state
xX coordinate
yY coordinate

Definition at line 1690 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_mouse_action().

Referenced by ami_hotlist_mouse(), atari_hotlist_mouse_action(), hotlist_mouse(), nsgtk_hotlist_mouse(), and nsw32_hotlist_mouse().

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

◆ hotlist_redraw()

void hotlist_redraw ( int  x,
int  y,
struct rect clip,
const struct redraw_context ctx 
)

Redraw the hotlist.

Parameters
xX coordinate to render treeview at
yY coordinate to render treeview at
clipCurrent clip rectangle (wrt tree origin)
ctxCurrent redraw context

Definition at line 1682 of file hotlist.c.

References clip(), hl_ctx, hotlist_ctx::tree, and treeview_redraw().

Referenced by ami_hotlist_draw(), atari_hotlist_draw(), hotlist_draw(), nsgtk_hotlist_draw(), and nsw32_hotlist_draw().

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

◆ hotlist_remove_url()

void hotlist_remove_url ( struct nsurl url)

Remove any entries matching the given URL from the hotlist.

Parameters
urlAddress to look for in hotlist

Definition at line 1535 of file hotlist.c.

References hotlist_ctx::built, hl_ctx, hotlist_remove_url_walk_cb(), NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_walk(), and treeview_remove_url_walk_ctx::url.

Referenced by ami_gui_event(), ro_gui_hotlist_remove_confirmed(), ro_gui_hotlist_remove_page(), and toolbar_favorite_click().

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

◆ hotlist_update_url()

void hotlist_update_url ( struct nsurl url)

Update given URL, e.g.

new visited data

Parameters
urlAddress to update entries for

Definition at line 1602 of file hotlist.c.

References hotlist_ctx::built, hl_ctx, hotlist_update_url_walk_cb(), NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_walk(), and treeview_update_url_walk_ctx::url.

Referenced by browser_window_content_done().

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