ELinks 0.18.0
dialogs.c File Reference
#include <string.h>
#include "elinks.h"
#include "bfu/dialog.h"
#include "bfu/hierbox.h"
#include "bfu/listbox.h"
#include "bookmarks/bookmarks.h"
#include "bookmarks/dialogs.h"
#include "dialogs/edit.h"
#include "intl/libintl.h"
#include "main/object.h"
#include "protocol/uri.h"
#include "session/session.h"
#include "terminal/terminal.h"
#include "util/conv.h"
#include "util/error.h"
#include "util/memory.h"
#include "util/time.h"
Include dependency graph for dialogs.c:

Data Structures

struct  bookmark_search_ctx
 

Macros

#define _GNU_SOURCE   /* XXX: we _WANT_ strcasestr() ! */
 
#define BOOKMARKS_RESAVE   1
 
#define NULL_BOOKMARK_SEARCH_CTX   {NULL, NULL, 0, 0, -1, -1}
 

Enumerations

enum  move_bookmark_flags { MOVE_BOOKMARK_NONE = 0x00 , MOVE_BOOKMARK_MOVED = 0x01 , MOVE_BOOKMARK_CYCLE = 0x02 }
 

Functions

static void lock_bookmark (struct listbox_item *item)
 
static void unlock_bookmark (struct listbox_item *item)
 
static int is_bookmark_used (struct listbox_item *item)
 
static char * get_bookmark_text (struct listbox_item *item, struct terminal *term)
 
static void add_converted_bytes_to_string (void *data, char *buf, int buflen)
 A callback for convert_string().
 
static char * get_bookmark_info (struct listbox_item *item, struct terminal *term)
 
static struct uriget_bookmark_uri (struct listbox_item *item)
 
static struct listbox_itemget_bookmark_root (struct listbox_item *item)
 
static int can_delete_bookmark (struct listbox_item *item)
 
static void delete_bookmark_item (struct listbox_item *item, int last)
 
static widget_handler_status_T push_add_button (struct dialog_data *dlg_data, struct widget_data *widget_data)
 
static void launch_bm_search_doc_dialog (struct terminal *, struct dialog_data *, struct session *)
 
static widget_handler_status_T push_search_button (struct dialog_data *dlg_data, struct widget_data *widget_data)
 
static void move_bookmark_after_selected (struct bookmark *bookmark, struct bookmark *selected)
 
static void do_add_bookmark (struct terminal *term, struct dialog_data *dlg_data, const char *title, const char *url)
 Add a bookmark; if called from the bookmark manager, also move the bookmark to the right place and select it in the manager.
 
static void do_add_folder (struct dialog_data *dlg_data, char *foldername)
 Add a bookmark folder.
 
static widget_handler_status_T push_add_folder_button (struct dialog_data *dlg_data, struct widget_data *widget_data)
 Prepare to add a bookmark folder.
 
static widget_handler_status_T push_add_separator_button (struct dialog_data *dlg_data, struct widget_data *widget_data)
 Add a bookmark separator.
 
static void bookmark_edit_done (void *data)
 
static void bookmark_edit_cancel (struct dialog *dlg)
 
static widget_handler_status_T push_edit_button (struct dialog_data *dlg_data, struct widget_data *edit_btn)
 
static void update_depths (struct listbox_item *parent)
 
static unsigned int do_move_bookmark (struct bookmark *dest, int insert_as_child, struct bookmark list *src, struct listbox_data *box)
 
static widget_handler_status_T push_move_button (struct dialog_data *dlg_data, struct widget_data *blah)
 
static widget_handler_status_T push_toggle_display_button (struct dialog_data *dlg_data, struct widget_data *blah)
 
 struct_hierbox_browser (bookmark_browser, N_("Bookmark manager"), bookmark_buttons, &bookmarks_listbox_ops)
 
void bookmark_manager (struct session *ses)
 
static int test_search (struct listbox_item *item, void *data_, int *offset)
 
void free_last_searched_bookmark (void)
 
static int memorize_last_searched_bookmark (const char *title, const char *url)
 
static void bookmark_search_do (void *data)
 
static void bookmark_add_add (void *data)
 
void launch_bm_add_dialog (struct terminal *term, struct dialog_data *parent, struct session *ses, char *title, char *url)
 Open a dialog box for adding a bookmark.
 
void launch_bm_add_doc_dialog (struct terminal *term, struct dialog_data *parent, struct session *ses)
 
void launch_bm_add_link_dialog (struct terminal *term, struct dialog_data *parent, struct session *ses)
 
static void bookmark_terminal_tabs_ok (void *term_void, char *foldername)
 
void bookmark_terminal_tabs_dialog (struct terminal *term)
 

Variables

static int with_urls = 0
 
static struct listbox_ops_messages bookmarks_messages
 
static const struct listbox_ops bookmarks_listbox_ops
 
static struct bookmarkmove_cache_root_avoid
 
static const struct hierbox_browser_button bookmark_buttons []
 
static char * bm_last_searched_title = NULL
 
static char * bm_last_searched_url = NULL
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   /* XXX: we _WANT_ strcasestr() ! */

◆ BOOKMARKS_RESAVE

#define BOOKMARKS_RESAVE   1

◆ NULL_BOOKMARK_SEARCH_CTX

#define NULL_BOOKMARK_SEARCH_CTX   {NULL, NULL, 0, 0, -1, -1}

Enumeration Type Documentation

◆ move_bookmark_flags

Enumerator
MOVE_BOOKMARK_NONE 
MOVE_BOOKMARK_MOVED 
MOVE_BOOKMARK_CYCLE 

Function Documentation

◆ add_converted_bytes_to_string()

static void add_converted_bytes_to_string ( void * data,
char * buf,
int buflen )
static

A callback for convert_string().

This ignores errors and can result in truncated strings if out of memory. Accordingly, the resulting string may be displayed in the UI but should not be saved to a file or given to another program.

◆ bookmark_add_add()

static void bookmark_add_add ( void * data)
static

◆ bookmark_edit_cancel()

static void bookmark_edit_cancel ( struct dialog * dlg)
static

◆ bookmark_edit_done()

static void bookmark_edit_done ( void * data)
static

◆ bookmark_manager()

void bookmark_manager ( struct session * ses)

◆ bookmark_search_do()

static void bookmark_search_do ( void * data)
static

◆ bookmark_terminal_tabs_dialog()

void bookmark_terminal_tabs_dialog ( struct terminal * term)

◆ bookmark_terminal_tabs_ok()

static void bookmark_terminal_tabs_ok ( void * term_void,
char * foldername )
static
Todo
Report the error
Todo
Report the error

◆ can_delete_bookmark()

static int can_delete_bookmark ( struct listbox_item * item)
static

◆ delete_bookmark_item()

static void delete_bookmark_item ( struct listbox_item * item,
int last )
static

◆ do_add_bookmark()

static void do_add_bookmark ( struct terminal * term,
struct dialog_data * dlg_data,
const char * title,
const char * url )
static

Add a bookmark; if called from the bookmark manager, also move the bookmark to the right place and select it in the manager.

And possibly save the bookmarks.

Parameters
termThe terminal whose user told ELinks to add the bookmark. Currently, term affects only the charset interpretation of title and url. In the future, this function could also display error messages in term.
dlg_dataThe bookmark manager dialog, or NULL if the bookmark is being added without involving the bookmark manager. If dlg_data is not NULL, dlg_data->win->term should be term.
titleThe title of the new bookmark, in the encoding of term. Must not be NULL. "-" means add a separator.
urlThe URL of the new bookmark, in the encoding of term. NULL or "" means add a bookmark folder, unless title is "-".

◆ do_add_folder()

static void do_add_folder ( struct dialog_data * dlg_data,
char * foldername )
static

Add a bookmark folder.

This is called when the user pushes the OK button in the input dialog that asks for the folder name.

Parameters
dlg_dataThe bookmark manager. Must not be NULL.
foldernameThe folder name that the user typed in the input dialog. This is in the charset of the terminal.

◆ do_move_bookmark()

static unsigned int do_move_bookmark ( struct bookmark * dest,
int insert_as_child,
struct bookmark list * src,
struct listbox_data * box )
static

◆ free_last_searched_bookmark()

void free_last_searched_bookmark ( void )

◆ get_bookmark_info()

static char * get_bookmark_info ( struct listbox_item * item,
struct terminal * term )
static

◆ get_bookmark_root()

static struct listbox_item * get_bookmark_root ( struct listbox_item * item)
static

◆ get_bookmark_text()

static char * get_bookmark_text ( struct listbox_item * item,
struct terminal * term )
static

◆ get_bookmark_uri()

static struct uri * get_bookmark_uri ( struct listbox_item * item)
static
Todo
Bug 1066: Tell the URI layer that bookmark->url is UTF-8.

◆ is_bookmark_used()

static int is_bookmark_used ( struct listbox_item * item)
static

◆ launch_bm_add_dialog()

void launch_bm_add_dialog ( struct terminal * term,
struct dialog_data * parent,
struct session * ses,
char * title,
char * url )

Open a dialog box for adding a bookmark.

Parameters
termThe terminal in which the dialog box should appear.
parentThe bookmark manager, or NULL if the user requested this action from somewhere else.
sesIf title or url is NULL, get defaults from the current document of ses.
titleThe initial title of the new bookmark, in the encoding of term. NULL means use ses.
urlThe initial URL of the new bookmark, in the encoding of term. NULL means use ses.

◆ launch_bm_add_doc_dialog()

void launch_bm_add_doc_dialog ( struct terminal * term,
struct dialog_data * parent,
struct session * ses )

◆ launch_bm_add_link_dialog()

void launch_bm_add_link_dialog ( struct terminal * term,
struct dialog_data * parent,
struct session * ses )

◆ launch_bm_search_doc_dialog()

static void launch_bm_search_doc_dialog ( struct terminal * term,
struct dialog_data * parent,
struct session * ses )
static

◆ lock_bookmark()

static void lock_bookmark ( struct listbox_item * item)
static

◆ memorize_last_searched_bookmark()

static int memorize_last_searched_bookmark ( const char * title,
const char * url )
static

◆ move_bookmark_after_selected()

static void move_bookmark_after_selected ( struct bookmark * bookmark,
struct bookmark * selected )
static

◆ push_add_button()

static widget_handler_status_T push_add_button ( struct dialog_data * dlg_data,
struct widget_data * widget_data )
static

◆ push_add_folder_button()

static widget_handler_status_T push_add_folder_button ( struct dialog_data * dlg_data,
struct widget_data * widget_data )
static

Prepare to add a bookmark folder.

This is called when the user pushes the "Add folder" button in the bookmark manager.

Parameters
dlg_dataThe bookmark manager. Must not be NULL.
widget_dataThe "Add folder" button.

◆ push_add_separator_button()

static widget_handler_status_T push_add_separator_button ( struct dialog_data * dlg_data,
struct widget_data * widget_data )
static

Add a bookmark separator.

This is called when the user pushes the "Add separator" button in the bookmark manager.

Parameters
dlg_dataThe bookmark manager. Must not be NULL.
widget_dataThe "Add separator" button.

◆ push_edit_button()

static widget_handler_status_T push_edit_button ( struct dialog_data * dlg_data,
struct widget_data * edit_btn )
static

◆ push_move_button()

static widget_handler_status_T push_move_button ( struct dialog_data * dlg_data,
struct widget_data * blah )
static

◆ push_search_button()

static widget_handler_status_T push_search_button ( struct dialog_data * dlg_data,
struct widget_data * widget_data )
static

◆ push_toggle_display_button()

static widget_handler_status_T push_toggle_display_button ( struct dialog_data * dlg_data,
struct widget_data * blah )
static

◆ struct_hierbox_browser()

struct_hierbox_browser ( bookmark_browser ,
N_("Bookmark manager") ,
bookmark_buttons ,
& bookmarks_listbox_ops )

◆ test_search()

static int test_search ( struct listbox_item * item,
void * data_,
int * offset )
static
Todo
Tell the user that the string could not be converted.

◆ unlock_bookmark()

static void unlock_bookmark ( struct listbox_item * item)
static

◆ update_depths()

static void update_depths ( struct listbox_item * parent)
static

Variable Documentation

◆ bm_last_searched_title

char* bm_last_searched_title = NULL
static

◆ bm_last_searched_url

char* bm_last_searched_url = NULL
static

◆ bookmark_buttons

const struct hierbox_browser_button bookmark_buttons[]
static
Initial value:
= {
{ N_("~Goto"), push_hierbox_goto_button, 1 },
{ N_("~Edit"), push_edit_button, 0 },
{ N_("~Delete"), push_hierbox_delete_button, 0 },
{ N_("~Toggle display"), push_toggle_display_button, 1 },
{ N_("~Add"), push_add_button, 0 },
{ N_("Add se~parator"), push_add_separator_button, 0 },
{ N_("Add ~folder"), push_add_folder_button, 0 },
{ N_("~Move"), push_move_button, 0 },
{ N_("~Search"), push_search_button, 1 },
}
static widget_handler_status_T push_toggle_display_button(struct dialog_data *dlg_data, struct widget_data *blah)
Definition dialogs.c:605
static widget_handler_status_T push_add_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
Definition dialogs.c:211
static widget_handler_status_T push_search_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
Definition dialogs.c:226
static widget_handler_status_T push_add_folder_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
Prepare to add a bookmark folder.
Definition dialogs.c:340
static widget_handler_status_T push_move_button(struct dialog_data *dlg_data, struct widget_data *blah)
Definition dialogs.c:542
static widget_handler_status_T push_edit_button(struct dialog_data *dlg_data, struct widget_data *edit_btn)
Definition dialogs.c:399
static widget_handler_status_T push_add_separator_button(struct dialog_data *dlg_data, struct widget_data *widget_data)
Add a bookmark separator.
Definition dialogs.c:363
#define N_(msg)
Definition libintl.h:25
widget_handler_status_T push_hierbox_goto_button(struct dialog_data *dlg_data, struct widget_data *button)
Definition hierbox.c:499
widget_handler_status_T push_hierbox_delete_button(struct dialog_data *dlg_data, struct widget_data *button)
Definition hierbox.c:799

◆ bookmarks_listbox_ops

const struct listbox_ops bookmarks_listbox_ops
static
Initial value:
= {
}
static struct listbox_item * get_bookmark_root(struct listbox_item *item)
Definition dialogs.c:136
static void delete_bookmark_item(struct listbox_item *item, int last)
Definition dialogs.c:150
static struct uri * get_bookmark_uri(struct listbox_item *item)
Definition dialogs.c:126
static void lock_bookmark(struct listbox_item *item)
Definition dialogs.c:38
static void unlock_bookmark(struct listbox_item *item)
Definition dialogs.c:44
static int can_delete_bookmark(struct listbox_item *item)
Definition dialogs.c:144
static int is_bookmark_used(struct listbox_item *item)
Definition dialogs.c:50
static char * get_bookmark_text(struct listbox_item *item, struct terminal *term)
Definition dialogs.c:58
static char * get_bookmark_info(struct listbox_item *item, struct terminal *term)
Definition dialogs.c:100
static struct listbox_ops_messages bookmarks_messages
Definition dialogs.c:163
#define NULL
Definition explodename.c:35

◆ bookmarks_messages

struct listbox_ops_messages bookmarks_messages
static
Initial value:
= {
N_("Sorry, but the bookmark \"%s\" cannot be deleted."),
N_("Sorry, but the bookmark \"%s\" is being used by something else."),
N_("Sorry, but the folder \"%s\" cannot be deleted."),
N_("Sorry, but the folder \"%s\" is being used by something else."),
N_("Delete marked bookmarks"),
N_("Delete marked bookmarks?"),
N_("Delete folder"),
N_("Delete the folder \"%s\" and all bookmarks in it?"),
N_("Delete bookmark"),
N_("Delete this bookmark?"),
N_("Clear all bookmarks"),
N_("Do you really want to remove all bookmarks?"),
}

◆ move_cache_root_avoid

struct bookmark* move_cache_root_avoid
static

◆ with_urls

int with_urls = 0
static