A lot of typesafety in the older C UI code.
Some checks failed
CI / ubuntu-latest-html-tests (push) Has been cancelled
CI / ubuntu-latest-no-tls (push) Has been cancelled
CI / ubuntu-latest-mbedtls2 (push) Has been cancelled
CI / ubuntu-latest-openssl-3 (push) Has been cancelled
CI / ubuntu-latest-with-old-std (push) Has been cancelled
CI / ubuntu-20-04-openssl-1-1 (push) Has been cancelled
CI / alpine-mbedtls-3_6_0 (push) Has been cancelled
CI / macOS-13-openssl-1-1 (push) Has been cancelled
CI / macOS-13-openssl-3 (push) Has been cancelled
CI / freebsd-14-openssl-3 (push) Has been cancelled
CI / windows-mbedtls (push) Has been cancelled

More to come.
This commit is contained in:
2025-08-12 02:09:40 -04:00
parent 06a2b527a6
commit b4600db393
7 changed files with 131 additions and 130 deletions

View File

@ -1048,16 +1048,15 @@ typedef struct {
/**
* Ask for user/password and reload the page.
*/
static void Cache_auth_callback(void *vdata)
static void Cache_auth_callback(CacheAuthData_t *data)
{
CacheAuthData_t *data = (CacheAuthData_t *)vdata;
if (a_Auth_do_auth(data->auth, data->url))
a_Nav_reload(data->bw);
Cache_auth_free(data->auth);
delete data->url;
dFree(data);
Cache_auth_entry(NULL, NULL);
a_Timeout_remove();
Timeout::remove();
}
/**
@ -1079,7 +1078,7 @@ static void Cache_auth_entry(CacheEntry_t *entry, BrowserWindow *bw)
data->url = a_Url_dup(entry->Url).release();
data->bw = bw;
entry->Auth = NULL;
a_Timeout_add(0.0, Cache_auth_callback, data);
Timeout::add(0.0, [=]{ Cache_auth_callback( data ); } );
}
}
@ -1335,7 +1334,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
Cache_savelink_t *data = dNew(Cache_savelink_t, 1);
data->bw = Client_bw;
data->url = a_Url_dup(url).release();
a_Timeout_add(0.0, Cache_savelink_cb, data);
Timeout::add(0.0, [=]{ Cache_savelink_cb( data ); } );
}
}
delete url;
@ -1356,10 +1355,9 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
/**
* Callback function for Cache_delayed_process_queue.
*/
static void Cache_delayed_process_queue_callback(void *ptr)
static void Cache_delayed_process_queue_callback()
{
CacheEntry_t *entry;
(void) ptr; /* Unused */
while ((entry = (CacheEntry_t *)dList_nth_data(DelayedQueue, 0))) {
Cache_ref_data(entry);
@ -1369,7 +1367,7 @@ static void Cache_delayed_process_queue_callback(void *ptr)
}
}
DelayedQueueIdleId = 0;
a_Timeout_remove();
Timeout::remove();
}
/**
@ -1383,7 +1381,7 @@ static void Cache_delayed_process_queue(CacheEntry_t *entry)
if (DelayedQueueIdleId == 0) {
_MSG(" Setting timeout callback\n");
a_Timeout_add(0.0, Cache_delayed_process_queue_callback, NULL);
Timeout::add(0.0, []{ Cache_delayed_process_queue_callback(); } );
DelayedQueueIdleId = 1;
}
}

View File

@ -78,9 +78,9 @@ static void filemenu_cb(Fl_Widget*, void *data)
} else if (strcmp((char*)data, "ou") == 0) {
a_UIcmd_focus_location(popup_bw);
} else if (strcmp((char*)data, "cw") == 0) {
a_Timeout_add(0.0, a_UIcmd_close_bw, popup_bw);
Timeout::add(0.0, [=]{ a_UIcmd_close_bw( popup_bw ); } );
} else if (strcmp((char*)data, "ed") == 0) {
a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL);
Timeout::add(0.0, [=]{ a_UIcmd_close_all_bw( nullptr ); } );
}
}
@ -330,7 +330,7 @@ static void Menu_simple_popup_cb(void *data)
if (m && m->callback())
m->do_callback((Fl_Widget *)data);
a_Timeout_remove();
Timeout::remove();
}
static void Menu_popup_cb(void *data)
@ -346,7 +346,7 @@ static void Menu_popup_cb(void *data)
if (picked->callback())
picked->do_callback((Fl_Widget *)(d->menu));
}
a_Timeout_remove();
Timeout::remove();
}
/**
@ -427,7 +427,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
}
pm[3].user_data(popup_url.get());
a_Timeout_add(0.0, Menu_popup_cb, (void*)&page_data);
Timeout::add(0.0, [&]{ Menu_popup_cb( &page_data ); } );
}
static Fl_Menu_Item link_menu_[] = {
@ -558,7 +558,7 @@ void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *p
Menu_set_link_menu_user_data(popup_url.get(), page_url);
a_Timeout_add(0.0, Menu_popup_cb, (void*)&link_data);
Timeout::add(0.0, [&]{ Menu_popup_cb( &link_data ); } );
}
/**
@ -616,7 +616,7 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
pm[7].deactivate();
}
a_Timeout_add(0.0, Menu_popup_cb, (void*)&image_data);
Timeout::add(0.0, [&]{ Menu_popup_cb( &image_data ); } );
}
/**
@ -643,7 +643,7 @@ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
hiddens_visible = hidvis;
pm[2].label(hiddens_visible ? "Hide hiddens": "Show hiddens");
a_Timeout_add(0.0, Menu_popup_cb, (void*)&form_data);
Timeout::add(0.0, [&]{ Menu_popup_cb( &form_data ); } );
}
/**
@ -675,7 +675,7 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
popup_url.reset();
//pm->label(wid->visible() ? NULL : "File");
a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm);
Timeout::add(0.0, [=]{ Menu_simple_popup_cb( pm ); } );
}
/**
@ -698,7 +698,7 @@ void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
popup_bw = bw;
popup_url = a_Url_dup(url);
a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm);
Timeout::add(0.0, [=]{ Menu_simple_popup_cb( pm ); } );
}
/**
@ -735,7 +735,7 @@ void a_Menu_history_popup(BrowserWindow *bw, int x, int y, int direction)
pm[i].label(FL_NORMAL_LABEL, a_History_get_title(history_list[i], 1));
pm[i].callback(Menu_history_cb, INT2VOIDP(i+1));
}
a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm);
Timeout::add(0.0, [=]{ Menu_simple_popup_cb( pm ); } );
}
/**

View File

@ -362,11 +362,11 @@ static void Nav_repush(BrowserWindow *bw)
}
}
static void Nav_repush_callback(void *data)
static void Nav_repush_callback(BrowserWindow *data)
{
_MSG(">>>> Nav_repush_callback <<<<\n");
Nav_repush(reinterpret_cast< BrowserWindow * >( data ));
a_Timeout_remove();
Nav_repush( data );
Timeout::remove();
}
/*
@ -381,15 +381,14 @@ void a_Nav_repush(BrowserWindow *bw)
{
dReturn_if_fail (bw != NULL);
MSG(">>>> a_Nav_repush <<<<\n");
a_Timeout_add(0.0, Nav_repush_callback, (void*)bw);
Timeout::add(0.0, [bw] { Nav_repush_callback( bw ); } );
}
/*
* This one does a_Nav_redirection0's job.
*/
static void Nav_redirection0_callback(void *data)
static void Nav_redirection0_callback(BrowserWindow *bw)
{
BrowserWindow *bw = (BrowserWindow *)data;
const DilloUrl *referer_url = a_History_get_url(NAV_TOP_UIDX(bw));
_MSG(">>>> Nav_redirection0_callback <<<<\n");
@ -399,7 +398,7 @@ static void Nav_redirection0_callback(void *data)
}
bw->meta_refresh_url.reset();
bw->meta_refresh_status = 0;
a_Timeout_remove();
Timeout::remove();
}
/*
@ -414,7 +413,7 @@ void a_Nav_redirection0(BrowserWindow *bw, const DilloUrl *new_url)
a_Url_set_flags(bw->meta_refresh_url.get(),
URL_FLAGS(new_url)|URL_E2EQuery|URL_IgnoreScroll);
bw->meta_refresh_status = 2;
a_Timeout_add(0.0, Nav_redirection0_callback, (void*)bw);
Timeout::add(0.0, [=] { Nav_redirection0_callback( bw); } );
}
/*
@ -456,9 +455,8 @@ void a_Nav_home(BrowserWindow *bw)
/*
* This one does a_Nav_reload's job!
*/
static void Nav_reload_callback(void *data)
static void Nav_reload_callback(BrowserWindow *bw)
{
BrowserWindow *bw = reinterpret_cast< BrowserWindow * >( data );
const DilloUrl *h_url;
int choice, confirmed = 1;
@ -499,7 +497,7 @@ static void Nav_reload_callback(void *data)
void a_Nav_reload(BrowserWindow *bw)
{
dReturn_if_fail (bw != NULL);
a_Timeout_add(0.0, Nav_reload_callback, (void*)bw);
Timeout::add(0.0, [=]{ Nav_reload_callback( bw ); } );
}
/*

View File

@ -16,29 +16,47 @@
#include <FL/Fl.H>
#include "timeout.hh"
#include <memory>
// C++ functions with C linkage ----------------------------------------------
namespace
{
void
doCallback( void *const v_func_p )
{
std::unique_ptr< Timeout::Cb_t > func_p{ reinterpret_cast< Timeout::Cb_t * >( v_func_p ) };
auto &func= *func_p;
func();
}
}
/**
* Hook a one-time timeout function 'cb' after 't' seconds
* with 'cbdata" as its data.
*/
void a_Timeout_add(float t, TimeoutCb_t cb, void *cbdata)
void
Timeout::add( const float t, Cb_t cb )
{
Fl::add_timeout(t, cb, cbdata);
auto ownership= std::make_unique< Cb_t >( cb );
Fl::add_timeout( t, doCallback, ownership.release() );
}
/**
* To be called from inside the 'cb' function when it wants to keep running
*/
void a_Timeout_repeat(float t, TimeoutCb_t cb, void *cbdata)
void
Timeout::repeat( const float t, Cb_t cb )
{
Fl::add_timeout(t, cb, cbdata);
auto ownership= std::make_unique< Cb_t >( cb );
Fl::repeat_timeout( t, doCallback, ownership.release() );
}
/**
* Stop running a timeout function
*/
void a_Timeout_remove()
void Timeout::remove()
{
/* in FLTK, timeouts run one time by default */
}

View File

@ -1,20 +1,18 @@
static_assert( __cplusplus >= 2023'02 );
#ifndef __TIMEOUT_HH__
#define __TIMEOUT_HH__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <functional>
typedef void (*TimeoutCb_t)(void *data);
namespace Timeout
{
using Cb_t= std::function< void () >;
void a_Timeout_add(float t, TimeoutCb_t cb, void *cbdata);
void a_Timeout_repeat(float t, TimeoutCb_t cb, void *cbdata);
void a_Timeout_remove(void);
#ifdef __cplusplus
void add( float t, Cb_t cb );
void repeat( float t, Cb_t cb );
void remove();
}
#endif /* __cplusplus */
#endif /* __TIMEOUT_HH__ */

View File

@ -255,7 +255,7 @@ int CustTabs::handle(int e)
a_UIcmd_open_url_nw(bw, NULL);
ret = 1;
} else if (cmd == KEYS_CLOSE_ALL) {
a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL);
Timeout::add(0.0, []{ a_UIcmd_close_all_bw( nullptr ); } );
ret = 1;
}
} else if (e == FL_MOUSEWHEEL && prefs.scroll_switches_tabs) {
@ -540,7 +540,7 @@ static void win_cb (Fl_Widget *w, void *cb_data) {
/*
* Given a UI or UI child widget, return its bw.
*/
BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid)
BrowserWindow *a_UIcmd::a_UIcmd_get_bw_by_widget(void *v_wid)
{
BrowserWindow *bw;
for (int i = 0; i < a_Bw_num(); ++i) {
@ -556,7 +556,7 @@ BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid)
* Create a new UI and its associated BrowserWindow data structure.
* Use style from v_ui. If non-NULL it must be of type UI*.
*/
BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh,
BrowserWindow *a_UIcmd::a_UIcmd_browser_window_new(int ww, int wh,
uint32_t xid, const void *vbw)
{
BrowserWindow *old_bw = (BrowserWindow*)vbw;
@ -672,9 +672,8 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus)
/*
* Close one browser window
*/
void a_UIcmd_close_bw(void *vbw)
void a_UIcmd::a_UIcmd_close_bw(BrowserWindow *bw)
{
BrowserWindow *bw = (BrowserWindow *)vbw;
UI *ui = BW2UI(bw);
CustTabs *tabs = ui->tabs();
Layout *layout = (Layout*)bw->render_layout;
@ -711,7 +710,7 @@ void a_UIcmd_close_bw(void *vbw)
/*
* Close all the browser windows
*/
void a_UIcmd_close_all_bw(void *)
void a_UIcmd::a_UIcmd_close_all_bw(void *)
{
BrowserWindow *bw;
int choice = 1;
@ -722,7 +721,7 @@ void a_UIcmd_close_all_bw(void *)
"Quit", "Cancel", NULL);
if (choice == 1)
while ((bw = a_Bw_get(0)))
a_UIcmd_close_bw((void*)bw);
a_UIcmd_close_bw(bw);
}
/*
@ -757,13 +756,12 @@ static char *UIcmd_find_search_str(const char *str)
*
* our custom "file:" URIs are normalized here too.
*/
void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
void a_UIcmd::a_UIcmd_open_urlstr(BrowserWindow *bw, const char *urlstr)
{
char *new_urlstr;
char *search_urlstr = NULL;
DilloUrl *url;
int ch;
BrowserWindow *bw = (BrowserWindow*)vbw;
if ((search_urlstr = UIcmd_find_search_str(urlstr))) {
urlstr = search_urlstr;
@ -798,7 +796,7 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
/*
* Open a new URL in the given browser window
*/
void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd::a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
{
if (url) {
a_Nav_push(bw, url, NULL);
@ -833,7 +831,7 @@ static void UIcmd_open_url_nbw(BrowserWindow *new_bw, const DilloUrl *url)
/*
* Open a new URL in a new browser window
*/
void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd::a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
{
int w, h;
BrowserWindow *new_bw;
@ -849,9 +847,8 @@ void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
/*
* Open a new URL in a new tab in the same browser window
*/
void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
void a_UIcmd::a_UIcmd_open_url_nt(BrowserWindow *bw, const DilloUrl *url, int focus)
{
BrowserWindow *bw = (BrowserWindow *)vbw;
BrowserWindow *new_bw = UIcmd_tab_new(BW2UI(bw)->tabs(),
bw ? BW2UI(bw) : NULL, focus);
/* Preserve same zoom factor in new tab */
@ -862,7 +859,7 @@ void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
/*
* Send the browser back to previous page
*/
void a_UIcmd_back(void *vbw)
void a_UIcmd::a_UIcmd_back(void *vbw)
{
a_Nav_back((BrowserWindow*)vbw);
}
@ -870,7 +867,7 @@ void a_UIcmd_back(void *vbw)
/*
* Popup the navigation menu of the Back button
*/
void a_UIcmd_back_popup(void *vbw, int x, int y)
void a_UIcmd::a_UIcmd_back_popup(void *vbw, int x, int y)
{
a_Menu_history_popup((BrowserWindow*)vbw, x, y, -1);
}
@ -878,7 +875,7 @@ void a_UIcmd_back_popup(void *vbw, int x, int y)
/*
* Send the browser to next page in the history list
*/
void a_UIcmd_forw(void *vbw)
void a_UIcmd::a_UIcmd_forw(void *vbw)
{
a_Nav_forw((BrowserWindow*)vbw);
}
@ -886,7 +883,7 @@ void a_UIcmd_forw(void *vbw)
/*
* Popup the navigation menu of the Forward button
*/
void a_UIcmd_forw_popup(void *vbw, int x, int y)
void a_UIcmd::a_UIcmd_forw_popup(void *vbw, int x, int y)
{
a_Menu_history_popup((BrowserWindow*)vbw, x, y, 1);
}
@ -894,7 +891,7 @@ void a_UIcmd_forw_popup(void *vbw, int x, int y)
/*
* Send the browser to home URL
*/
void a_UIcmd_home(void *vbw)
void a_UIcmd::a_UIcmd_home(void *vbw)
{
a_UIcmd_open_url((BrowserWindow*)vbw, prefs.home);
}
@ -902,7 +899,7 @@ void a_UIcmd_home(void *vbw)
/*
* Reload current URL
*/
void a_UIcmd_reload(void *vbw)
void a_UIcmd::a_UIcmd_reload(void *vbw)
{
a_Nav_reload((BrowserWindow*)vbw);
}
@ -910,7 +907,7 @@ void a_UIcmd_reload(void *vbw)
/*
* Reload all active tabs
*/
void a_UIcmd_reload_all_active()
void a_UIcmd::a_UIcmd_reload_all_active()
{
struct Tabgroup *tg = tabgroups;
for (tg = tabgroups; tg; tg = tg->next) {
@ -923,7 +920,7 @@ void a_UIcmd_reload_all_active()
/*
* Repush current URL
*/
void a_UIcmd_repush(void *vbw)
void a_UIcmd::a_UIcmd_repush(void *vbw)
{
a_Nav_repush((BrowserWindow*)vbw);
}
@ -931,7 +928,7 @@ void a_UIcmd_repush(void *vbw)
/*
* Zero-delay URL redirection.
*/
void a_UIcmd_redirection0(void *vbw, const DilloUrl *url)
void a_UIcmd::a_UIcmd_redirection0(void *vbw, const DilloUrl *url)
{
a_Nav_redirection0((BrowserWindow*)vbw, url);
}
@ -939,7 +936,7 @@ void a_UIcmd_redirection0(void *vbw, const DilloUrl *url)
/*
* Zoom in
*/
void a_UIcmd_zoom_in(void *vbw)
void a_UIcmd::a_UIcmd_zoom_in(void *vbw)
{
BrowserWindow *bw = (BrowserWindow*) vbw;
bw->zoom += 0.10;
@ -955,7 +952,7 @@ void a_UIcmd_zoom_in(void *vbw)
/*
* Zoom out
*/
void a_UIcmd_zoom_out(void *vbw)
void a_UIcmd::a_UIcmd_zoom_out(void *vbw)
{
BrowserWindow *bw = (BrowserWindow*) vbw;
bw->zoom -= 0.10;
@ -971,7 +968,7 @@ void a_UIcmd_zoom_out(void *vbw)
/*
* Zoom reset
*/
void a_UIcmd_zoom_reset(void *vbw)
void a_UIcmd::a_UIcmd_zoom_reset(void *vbw)
{
BrowserWindow *bw = (BrowserWindow*) vbw;
bw->zoom = 1.0;
@ -1034,7 +1031,7 @@ static char *UIcmd_make_save_filename(const DilloUrl *url)
/*
* Set the default directory for saving files.
*/
void a_UIcmd_init(void)
void a_UIcmd::a_UIcmd_init(void)
{
const char *dir = prefs.save_dir;
@ -1107,7 +1104,7 @@ static void UIcmd_save(BrowserWindow *bw, const DilloUrl *url,
/*
* Save current URL
*/
void a_UIcmd_save(void *vbw)
void a_UIcmd::a_UIcmd_save(void *vbw)
{
BrowserWindow *bw = (BrowserWindow *)vbw;
const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
@ -1120,7 +1117,7 @@ void a_UIcmd_save(void *vbw)
/*
* Select a file
*/
const char *a_UIcmd_select_file()
const char *a_UIcmd::a_UIcmd_select_file()
{
return a_Dialog_select_file("Flenser: Select a File", NULL, NULL);
}
@ -1129,7 +1126,7 @@ const char *a_UIcmd_select_file()
* Stop network activity on this bw.
* The stop button was pressed: stop page (and images) downloads.
*/
void a_UIcmd_stop(void *vbw)
void a_UIcmd::a_UIcmd_stop(void *vbw)
{
BrowserWindow *bw = (BrowserWindow *)vbw;
@ -1142,7 +1139,7 @@ void a_UIcmd_stop(void *vbw)
/*
* Popup the tools menu
*/
void a_UIcmd_tools(void *vbw, int x, int y)
void a_UIcmd::a_UIcmd_tools(void *vbw, int x, int y)
{
a_Menu_tools_popup((BrowserWindow*)vbw, x, y);
}
@ -1150,7 +1147,7 @@ void a_UIcmd_tools(void *vbw, int x, int y)
/*
* Open URL with dialog chooser
*/
void a_UIcmd_open_file(void *vbw)
void a_UIcmd::a_UIcmd_open_file(void *vbw)
{
auto name = a_Dialog_open_file("Flenser: Open File", std::nullopt, "");
@ -1200,13 +1197,13 @@ static char *UIcmd_make_search_str(const char *str)
/*
* Get a query from a dialog and open it
*/
void a_UIcmd_search_dialog(void *vbw)
void a_UIcmd::a_UIcmd_search_dialog(BrowserWindow *bw)
{
const char *query;
if ((query = a_Dialog_input("Flenser: Search", "Search the Web:"))) {
char *url_str = UIcmd_make_search_str(query);
a_UIcmd_open_urlstr(vbw, url_str);
a_UIcmd_open_urlstr(bw, url_str);
dFree(url_str);
}
}
@ -1214,7 +1211,7 @@ void a_UIcmd_search_dialog(void *vbw)
/*
* Get password for user
*/
const char *a_UIcmd_get_passwd(const char *user)
const char *a_UIcmd::a_UIcmd_get_passwd(const char *user)
{
const char *passwd;
const char *title = "Flenser: Password";
@ -1227,7 +1224,7 @@ const char *a_UIcmd_get_passwd(const char *user)
/*
* Save link URL
*/
void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd::a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url)
{
UIcmd_save(bw, url, "Flenser: Save Link as File");
}
@ -1235,7 +1232,7 @@ void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url)
/*
* Request the bookmarks page
*/
void a_UIcmd_book(void *vbw)
void a_UIcmd::a_UIcmd_book(void *vbw)
{
auto url = a_Url_new("dpi:/bm/", NULL);
a_UIcmd_open_url((BrowserWindow*)vbw, url.get());
@ -1244,7 +1241,7 @@ void a_UIcmd_book(void *vbw)
/*
* Add a bookmark for a certain URL
*/
void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd::a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
{
a_Bookmarks_add(bw, url);
}
@ -1253,7 +1250,7 @@ void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
/*
* Popup the page menu
*/
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
void a_UIcmd::a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
{
BrowserWindow *bw = (BrowserWindow*)vbw;
const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
@ -1263,7 +1260,7 @@ void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr
/*
* Popup the link menu
*/
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url)
void a_UIcmd::a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url)
{
a_Menu_link_popup((BrowserWindow*)vbw, url, page_url);
}
@ -1271,7 +1268,7 @@ void a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url
/*
* Pop up the image menu
*/
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
void a_UIcmd::a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
DilloUrl *page_url, DilloUrl *link_url)
{
a_Menu_image_popup((BrowserWindow*)vbw, url, loaded_img, page_url,link_url);
@ -1280,7 +1277,7 @@ void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
/*
* Pop up the form menu
*/
void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
void a_UIcmd::a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
bool_t showing_hiddens)
{
a_Menu_form_popup((BrowserWindow*)vbw, url, vform, showing_hiddens);
@ -1289,7 +1286,7 @@ void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
/*
* Pop up the file menu
*/
void a_UIcmd_file_popup(void *vbw, void *v_wid)
void a_UIcmd::a_UIcmd_file_popup(void *vbw, void *v_wid)
{
a_Menu_file_popup((BrowserWindow*)vbw, v_wid);
}
@ -1297,7 +1294,7 @@ void a_UIcmd_file_popup(void *vbw, void *v_wid)
/*
* Copy url string to paste buffer
*/
void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr)
void a_UIcmd::a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr)
{
Layout *layout = (Layout*)bw->render_layout;
layout->copySelection(urlstr);
@ -1306,7 +1303,7 @@ void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr)
/*
* Ask the vsource dpi to show this URL's source
*/
void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd::a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
{
char *buf, *major;
int buf_size;
@ -1339,10 +1336,8 @@ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
/*
* Show the browser window's HTML errors in a text window
*/
void a_UIcmd_view_page_bugs(void *vbw)
void a_UIcmd::a_UIcmd_view_page_bugs(BrowserWindow *bw)
{
BrowserWindow *bw = (BrowserWindow*)vbw;
if (bw->num_page_bugs > 0) {
a_Dialog_text_window("Flenser: Detected HTML errors", bw->page_bugs.c_str());
} else {
@ -1353,10 +1348,8 @@ void a_UIcmd_view_page_bugs(void *vbw)
/*
* Popup the bug meter menu
*/
void a_UIcmd_bugmeter_popup(void *vbw)
void a_UIcmd::a_UIcmd_bugmeter_popup(BrowserWindow *bw)
{
BrowserWindow *bw = (BrowserWindow*)vbw;
a_Menu_bugmeter_popup(bw, a_History_get_url(NAV_TOP_UIDX(bw)));
}
@ -1364,7 +1357,7 @@ void a_UIcmd_bugmeter_popup(void *vbw)
* Make a list of URL indexes for the history popup
* based on direction (-1 = back, 1 = forward)
*/
int *a_UIcmd_get_history(BrowserWindow *bw, int direction)
int *a_UIcmd::a_UIcmd_get_history(BrowserWindow *bw, int direction)
{
int i, j, n;
int *hlist;
@ -1388,7 +1381,7 @@ int *a_UIcmd_get_history(BrowserWindow *bw, int direction)
/*
* Jump to a certain URL in the navigation stack.
*/
void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw)
void a_UIcmd::a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw)
{
a_Nav_jump(bw, offset, new_bw);
}
@ -1398,7 +1391,7 @@ void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw)
/*
* Return browser window width and height
*/
void a_UIcmd_get_wh(BrowserWindow *bw, int *w, int *h)
void a_UIcmd::a_UIcmd_get_wh(BrowserWindow *bw, int *w, int *h)
{
*w = BW2UI(bw)->w();
*h = BW2UI(bw)->h();
@ -1408,7 +1401,7 @@ void a_UIcmd_get_wh(BrowserWindow *bw, int *w, int *h)
/*
* Get the scroll position (x, y offset pair)
*/
void a_UIcmd_get_scroll_xy(BrowserWindow *bw, int *x, int *y)
void a_UIcmd::a_UIcmd_get_scroll_xy(BrowserWindow *bw, int *x, int *y)
{
Layout *layout = (Layout*)bw->render_layout;
@ -1421,7 +1414,7 @@ void a_UIcmd_get_scroll_xy(BrowserWindow *bw, int *x, int *y)
/*
* Set the scroll position ({x, y} offset pair)
*/
void a_UIcmd_set_scroll_xy(BrowserWindow *bw, int x, int y)
void a_UIcmd::a_UIcmd_set_scroll_xy(BrowserWindow *bw, int x, int y)
{
Layout *layout = (Layout*)bw->render_layout;
@ -1433,7 +1426,7 @@ void a_UIcmd_set_scroll_xy(BrowserWindow *bw, int x, int y)
/*
* Set the scroll position by fragment (from URL)
*/
void a_UIcmd_set_scroll_by_fragment(BrowserWindow *bw, const char *f)
void a_UIcmd::a_UIcmd_set_scroll_by_fragment(BrowserWindow *bw, const char *f)
{
Layout *layout = (Layout*)bw->render_layout;
@ -1445,7 +1438,7 @@ void a_UIcmd_set_scroll_by_fragment(BrowserWindow *bw, const char *f)
/*
* Pass scrolling command to dw.
*/
void a_UIcmd_scroll(BrowserWindow *bw, int icmd)
void a_UIcmd::a_UIcmd_scroll(BrowserWindow *bw, int icmd)
{
Layout *layout = (Layout*)bw->render_layout;
@ -1481,7 +1474,7 @@ void a_UIcmd_scroll(BrowserWindow *bw, int icmd)
/*
* Get location's text
*/
char *a_UIcmd_get_location_text(BrowserWindow *bw)
char *a_UIcmd::a_UIcmd_get_location_text(BrowserWindow *bw)
{
return dStrdup(BW2UI(bw)->get_location());
}
@ -1489,7 +1482,7 @@ char *a_UIcmd_get_location_text(BrowserWindow *bw)
/*
* Set location's text
*/
void a_UIcmd_set_location_text(void *vbw, const char *text)
void a_UIcmd::a_UIcmd_set_location_text(void *vbw, const char *text)
{
BrowserWindow *bw = (BrowserWindow*)vbw;
BW2UI(bw)->set_location(text);
@ -1499,7 +1492,7 @@ void a_UIcmd_set_location_text(void *vbw, const char *text)
* Set the page progress bar
* cmd: 0 Deactivate, 1 Update, 2 Clear
*/
void a_UIcmd_set_page_prog(BrowserWindow *bw, size_t nbytes, int cmd)
void a_UIcmd::a_UIcmd_set_page_prog(BrowserWindow *bw, size_t nbytes, int cmd)
{
BW2UI(bw)->set_page_prog(nbytes, cmd);
}
@ -1508,7 +1501,7 @@ void a_UIcmd_set_page_prog(BrowserWindow *bw, size_t nbytes, int cmd)
* Set the images progress bar
* cmd: 0 Deactivate, 1 Update, 2 Clear
*/
void a_UIcmd_set_img_prog(BrowserWindow *bw, int n_img, int t_img, int cmd)
void a_UIcmd::a_UIcmd_set_img_prog(BrowserWindow *bw, int n_img, int t_img, int cmd)
{
BW2UI(bw)->set_img_prog(n_img, t_img, cmd);
#if 0
@ -1520,7 +1513,7 @@ void a_UIcmd_set_img_prog(BrowserWindow *bw, int n_img, int t_img, int cmd)
/*
* Set the bug meter progress label
*/
void a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug)
void a_UIcmd::a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug)
{
BW2UI(bw)->set_bug_prog(n_bug);
}
@ -1529,7 +1522,7 @@ void a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug)
* Set the page title in the tab label and window titlebar.
* (Update window titlebar for the current tab only)
*/
void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
void a_UIcmd::a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
{
const int size = 128;
char title[size];
@ -1552,7 +1545,7 @@ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
* Beware: The safe way to set an arbitrary string is
* a_UIcmd_set_msg(bw, "%s", str)
*/
void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...)
void a_UIcmd::a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...)
{
va_list argp;
Dstr *ds = dStr_sized_new(128);
@ -1566,7 +1559,7 @@ void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...)
/*
* Set the sensitivity of back/forw/stop buttons.
*/
void a_UIcmd_set_buttons_sens(BrowserWindow *bw)
void a_UIcmd::a_UIcmd_set_buttons_sens(BrowserWindow *bw)
{
int sens;
@ -1585,7 +1578,7 @@ void a_UIcmd_set_buttons_sens(BrowserWindow *bw)
/*
* Toggle control panel
*/
void a_UIcmd_panels_toggle(BrowserWindow *bw)
void a_UIcmd::a_UIcmd_panels_toggle(BrowserWindow *bw)
{
BW2UI(bw)->panels_toggle();
}
@ -1593,7 +1586,7 @@ void a_UIcmd_panels_toggle(BrowserWindow *bw)
/*
* Search for next/previous occurrence of key.
*/
void a_UIcmd_findtext_search(BrowserWindow *bw, const char *key,
void a_UIcmd::a_UIcmd_findtext_search(BrowserWindow *bw, const char *key,
int case_sens, int backward)
{
Layout *l = (Layout *)bw->render_layout;
@ -1615,7 +1608,7 @@ void a_UIcmd_findtext_search(BrowserWindow *bw, const char *key,
/*
* Reset text search state.
*/
void a_UIcmd_findtext_reset(BrowserWindow *bw)
void a_UIcmd::a_UIcmd_findtext_reset(BrowserWindow *bw)
{
Layout *l = (Layout *)bw->render_layout;
l->resetSearch();
@ -1626,7 +1619,7 @@ void a_UIcmd_findtext_reset(BrowserWindow *bw)
/*
* Tell the UI to hide/show the findbar
*/
void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on)
void a_UIcmd::a_UIcmd_findbar_toggle(BrowserWindow *bw, int on)
{
BW2UI(bw)->findbar_toggle(on);
}
@ -1634,7 +1627,7 @@ void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on)
/*
* Focus the rendered area.
*/
void a_UIcmd_focus_main_area(BrowserWindow *bw)
void a_UIcmd::a_UIcmd_focus_main_area(BrowserWindow *bw)
{
BW2UI(bw)->focus_main();
}
@ -1642,7 +1635,7 @@ void a_UIcmd_focus_main_area(BrowserWindow *bw)
/*
* Focus the location bar.
*/
void a_UIcmd_focus_location(void *vbw)
void a_UIcmd::a_UIcmd_focus_location(void *vbw)
{
BrowserWindow *bw = (BrowserWindow*)vbw;
BW2UI(bw)->focus_location();

View File

@ -15,19 +15,17 @@
#include "bw.hh"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
inline namespace a_UIcmd
{
BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh,
uint32_t xid, const void *v_bw);
BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid);
void a_UIcmd_send_event_to_tabs_by_wid(int e, void *v_wid);
void a_UIcmd_open_urlstr(void *vbw, const char *urlstr);
void a_UIcmd_open_urlstr(BrowserWindow *bw, const char *urlstr);
void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url);
void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url);
void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus);
void a_UIcmd_open_url_nt(BrowserWindow *bw, const DilloUrl *url, int focus);
void a_UIcmd_back(void *vbw);
void a_UIcmd_back_popup(void *vbw, int x, int y);
void a_UIcmd_forw(void *vbw);
@ -46,7 +44,7 @@ void a_UIcmd_tools(void *vbw, int x, int y);
void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url);
void a_UIcmd_open_file(void *vbw);
const char *a_UIcmd_select_file(void);
void a_UIcmd_search_dialog(void *vbw);
void a_UIcmd_search_dialog(BrowserWindow *vbw);
const char *a_UIcmd_get_passwd(const char *user);
void a_UIcmd_book(void *vbw);
void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url);
@ -67,12 +65,12 @@ void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
void a_UIcmd_file_popup(void *vbw, void *v_wid);
void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr);
void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url);
void a_UIcmd_view_page_bugs(void *vbw);
void a_UIcmd_bugmeter_popup(void *vbw);
void a_UIcmd_view_page_bugs(BrowserWindow *bw);
void a_UIcmd_bugmeter_popup(BrowserWindow *bw);
int *a_UIcmd_get_history(BrowserWindow *bw, int direction);
void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw);
void a_UIcmd_close_bw(void *vbw);
void a_UIcmd_close_bw(BrowserWindow *bw);
void a_UIcmd_close_all_bw(void *p);
void a_UIcmd_init(void);
@ -94,8 +92,6 @@ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label);
void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...);
void a_UIcmd_set_buttons_sens(BrowserWindow *bw);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // __UICMD_HH__