diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2014-10-26 15:41:44 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2014-10-26 15:41:44 +0000 |
commit | 0c77d85f8976046b0c5cf2915f0618e1522099ac (patch) | |
tree | 5ea4da05ae8c4b57e306d3f61867c5670e3d7130 | |
parent | b751513d6f1515976238adf68598729b9021160f (diff) | |
download | netsurf-0c77d85f8976046b0c5cf2915f0618e1522099ac.tar.gz netsurf-0c77d85f8976046b0c5cf2915f0618e1522099ac.tar.bz2 |
Make window counting a generic function
-rw-r--r-- | amiga/arexx.c | 21 | ||||
-rw-r--r-- | amiga/gui.c | 32 | ||||
-rwxr-xr-x | amiga/gui.h | 1 |
3 files changed, 36 insertions, 18 deletions
diff --git a/amiga/arexx.c b/amiga/arexx.c index 7a367e893..120656f69 100644 --- a/amiga/arexx.c +++ b/amiga/arexx.c @@ -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); diff --git a/amiga/gui.c b/amiga/gui.c index c63833ad8..76e484933 100644 --- a/amiga/gui.c +++ b/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; diff --git a/amiga/gui.h b/amiga/gui.h index 1de31aebd..91dc2e7d4 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -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; |