mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-16 17:22:44 +03:00
Make window counting a generic function
This commit is contained in:
parent
b751513d6f
commit
0c77d85f89
@ -537,29 +537,14 @@ STATIC VOID rx_reload(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((u
|
||||
STATIC VOID rx_windows(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
||||
{
|
||||
int windows = 0, tabs = 0;
|
||||
int window = 0;
|
||||
struct nsObject *node, *nnode;
|
||||
struct gui_window_2 *gwin;
|
||||
|
||||
if(cmd->ac_ArgList[0]) window = *(ULONG *)cmd->ac_ArgList[0];
|
||||
cmd->ac_RC = 0;
|
||||
|
||||
if(!IsMinListEmpty(window_list))
|
||||
{
|
||||
node = (struct nsObject *)GetHead((struct List *)window_list);
|
||||
|
||||
do
|
||||
{
|
||||
nnode=(struct nsObject *)GetSucc((struct Node *)node);
|
||||
|
||||
gwin = node->objstruct;
|
||||
|
||||
if(node->Type == AMINS_WINDOW)
|
||||
{
|
||||
windows++;
|
||||
if((cmd->ac_ArgList[0]) && (*(ULONG *)cmd->ac_ArgList[0] == windows))
|
||||
tabs = gwin->tabs;
|
||||
}
|
||||
} while(node = nnode);
|
||||
}
|
||||
windows = ami_gui_count_windows(window, &tabs);
|
||||
|
||||
if(cmd->ac_ArgList[0]) sprintf(result, "%d", tabs);
|
||||
else sprintf(result, "%d", windows);
|
||||
|
32
amiga/gui.c
32
amiga/gui.c
@ -3229,6 +3229,38 @@ static void ami_gui_search_ico_refresh(void *p)
|
||||
search_web_select_provider(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count windows, and optionally tabs.
|
||||
*
|
||||
* \param window window to count tabs of
|
||||
* \param tabs if window > 0, contains the number of tabs in that window,
|
||||
* unchanged otherwise
|
||||
* \return number of windows currently open
|
||||
*/
|
||||
int ami_gui_count_windows(int window, int *tabs)
|
||||
{
|
||||
int windows = 0;
|
||||
struct nsObject *node, *nnode;
|
||||
struct gui_window_2 *gwin;
|
||||
|
||||
if(!IsMinListEmpty(window_list)) {
|
||||
node = (struct nsObject *)GetHead((struct List *)window_list);
|
||||
do {
|
||||
nnode=(struct nsObject *)GetSucc((struct Node *)node);
|
||||
|
||||
gwin = node->objstruct;
|
||||
|
||||
if(node->Type == AMINS_WINDOW) {
|
||||
windows++;
|
||||
if(window == windows) *tabs = gwin->tabs;
|
||||
}
|
||||
} while((node = nnode));
|
||||
}
|
||||
return windows;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin)
|
||||
{
|
||||
nsurl *url;
|
||||
|
@ -168,6 +168,7 @@ bool ami_locate_resource(char *fullpath, const char *file);
|
||||
void ami_gui_update_hotlist_button(struct gui_window_2 *gwin);
|
||||
nserror ami_gui_new_blank_tab(struct gui_window_2 *gwin);
|
||||
char *ami_gui_get_cache_favicon_name(nsurl *url, bool only_if_avail);
|
||||
int ami_gui_count_windows(int window, int *tabs);
|
||||
|
||||
struct TextFont *origrpfont;
|
||||
struct MinList *window_list;
|
||||
|
Loading…
Reference in New Issue
Block a user