Root clients is now a C++ container.
This commit is contained in:
26
src/bw.cc
26
src/bw.cc
@ -64,7 +64,6 @@ BrowserWindow *a_Bw_new(void)
|
||||
bw->meta_refresh_status = 0;
|
||||
bw->meta_refresh_url = NULL;
|
||||
|
||||
bw->RootClients = dList_new(8);
|
||||
bw->ImageClients = dList_new(8);
|
||||
bw->NumImages = 0;
|
||||
bw->NumImagesGot = 0;
|
||||
@ -91,7 +90,6 @@ BrowserWindow::~BrowserWindow()
|
||||
if (bws[i] == this) {
|
||||
a_List_remove(bws, i, num_bws);
|
||||
|
||||
dList_free(this->RootClients);
|
||||
dList_free(this->ImageClients);
|
||||
|
||||
|
||||
@ -114,14 +112,14 @@ void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
|
||||
dReturn_if_fail ( bw != NULL );
|
||||
|
||||
if (Root) {
|
||||
dList_append(bw->RootClients, INT2VOIDP(Key));
|
||||
bw->RootClients.push_back(Key);
|
||||
} else {
|
||||
dList_append(bw->ImageClients, INT2VOIDP(Key));
|
||||
bw->NumImages++;
|
||||
/* --Images progress-bar stuff-- */
|
||||
a_UIcmd_set_img_prog(bw, bw->NumImagesGot, bw->NumImages, 1);
|
||||
}
|
||||
if (dList_length(bw->RootClients) + dList_length(bw->ImageClients) == 1)
|
||||
if (bw->RootClients.size() + dList_length(bw->ImageClients) == 1)
|
||||
a_UIcmd_set_buttons_sens(bw);
|
||||
}
|
||||
|
||||
@ -134,8 +132,10 @@ int a_Bw_remove_client(BrowserWindow *bw, int ClientKey)
|
||||
{
|
||||
void *data;
|
||||
|
||||
if ((data = dList_find(bw->RootClients, INT2VOIDP(ClientKey)))) {
|
||||
dList_remove_fast(bw->RootClients, data);
|
||||
auto where= std::find( begin( bw->RootClients ), end( bw->RootClients ), ClientKey );
|
||||
|
||||
if (where != end( bw->RootClients )) {
|
||||
bw->RootClients.erase( where );
|
||||
} else if ((data = dList_find(bw->ImageClients, INT2VOIDP(ClientKey)))) {
|
||||
dList_remove_fast(bw->ImageClients, data);
|
||||
++bw->NumImagesGot;
|
||||
@ -154,7 +154,7 @@ void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
|
||||
a_UIcmd_set_img_prog(bw, bw->NumImagesGot, bw->NumImages, 1);
|
||||
if (bw->NumImagesGot == bw->NumImages)
|
||||
a_UIcmd_set_img_prog(bw, 0, 0, 0);
|
||||
if (dList_length(bw->RootClients) == 0)
|
||||
if (bw->RootClients.empty())
|
||||
a_UIcmd_set_buttons_sens(bw);
|
||||
}
|
||||
}
|
||||
@ -166,12 +166,13 @@ void a_Bw_close_client(BrowserWindow *bw, int ClientKey)
|
||||
void a_Bw_stop_clients(BrowserWindow *bw, int flags)
|
||||
{
|
||||
void *data;
|
||||
int which;
|
||||
|
||||
if (flags & BW_Root) {
|
||||
/* Remove root clients */
|
||||
while ((data = dList_nth_data(bw->RootClients, 0))) {
|
||||
a_Capi_stop_client(VOIDP2INT(data), (flags & BW_Force));
|
||||
dList_remove_fast(bw->RootClients, data);
|
||||
while (not bw->RootClients.empty() and (which = bw->RootClients.at( 0 ))) {
|
||||
a_Capi_stop_client(which, (flags & BW_Force));
|
||||
bw->RootClients.erase( begin( bw->RootClients ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,9 +267,8 @@ void a_Bw_cleanup(BrowserWindow *bw)
|
||||
void *data;
|
||||
|
||||
/* Remove root clients */
|
||||
while ((data = dList_nth_data(bw->RootClients, 0))) {
|
||||
dList_remove_fast(bw->RootClients, data);
|
||||
}
|
||||
bw->RootClients.clear();
|
||||
|
||||
/* Remove image clients */
|
||||
while ((data = dList_nth_data(bw->ImageClients, 0))) {
|
||||
dList_remove_fast(bw->ImageClients, data);
|
||||
|
@ -55,7 +55,7 @@ struct BrowserWindow {
|
||||
std::vector< DilloHtml * > Docs;
|
||||
|
||||
/** A list of active cache clients in the window (The primary Key) */
|
||||
Dlist *RootClients;
|
||||
std::vector< int > RootClients;
|
||||
/** Image Keys for all active connections in the window */
|
||||
Dlist *ImageClients;
|
||||
/** Number of images in the page */
|
||||
|
@ -1571,7 +1571,7 @@ void a_UIcmd_set_buttons_sens(BrowserWindow *bw)
|
||||
int sens;
|
||||
|
||||
// Stop
|
||||
sens = (dList_length(bw->ImageClients) || dList_length(bw->RootClients));
|
||||
sens = (dList_length(bw->ImageClients) || bw->RootClients.size());
|
||||
BW2UI(bw)->button_set_sens(UI_STOP, sens);
|
||||
// Back
|
||||
sens = (a_Nav_stack_ptr(bw) > 0);
|
||||
|
Reference in New Issue
Block a user