From d0df3fa4b340071fbe54f9e7966f62b873b52b81 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Wed, 8 May 2019 01:44:44 +0100 Subject: more accessor for gui_window_2 --- frontends/amiga/arexx.c | 10 +++--- frontends/amiga/clipboard.c | 8 ++--- frontends/amiga/ctxmenu.c | 34 +++++++++++++-------- frontends/amiga/gui.c | 74 ++++++++++++++++++++++++++++++++++++++++++--- frontends/amiga/gui.h | 59 ++++++++++++++++++++++++++++++++++-- frontends/amiga/gui_menu.c | 4 +-- frontends/amiga/theme.c | 14 ++++----- 7 files changed, 166 insertions(+), 37 deletions(-) diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c index 5b5f0ea09..24da3e7e5 100644 --- a/frontends/amiga/arexx.c +++ b/frontends/amiga/arexx.c @@ -191,9 +191,9 @@ static struct gui_window *ami_find_tab_gwin(struct gui_window_2 *gwin, int tab) struct Node *ntab; struct gui_window *gw; - if((tab == 0) || (gwin->tabs == 0)) return ami_gui2_get_gui_window(gwin); + if((tab == 0) || (ami_gui2_get_tabs(gwin) == 0)) return ami_gui2_get_gui_window(gwin); - ctab = GetHead(&gwin->tab_list); + ctab = GetHead(ami_gui2_get_tab_list(gwin)); do { @@ -215,9 +215,9 @@ static int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw) struct Node *ntab; struct gui_window *tgw = NULL; - if((bw == NULL) || (gwin->tabs == 0)) return 1; + if((bw == NULL) || (ami_gui2_get_tabs(gwin) == 0)) return 1; - ctab = GetHead(&gwin->tab_list); + ctab = GetHead(ami_gui2_get_tab_list(gwin)); do { @@ -418,7 +418,7 @@ RXHOOKF(rx_gettitle) if(gw) { - if(ami_gui_get_gui_window_2(gw)->tabs > 1) + if(ami_gui2_get_tabs(ami_gui_get_gui_window_2(gw)) > 1) strcpy(result, ami_gui_get_tab_title(gw)); else strcpy(result, ami_gui_get_win_title(gw)); diff --git a/frontends/amiga/clipboard.c b/frontends/amiga/clipboard.c index 7a5c5f4d9..731492bb3 100644 --- a/frontends/amiga/clipboard.c +++ b/frontends/amiga/clipboard.c @@ -299,23 +299,23 @@ void ami_drag_selection(struct gui_window *g) x = ami_gui2_get_window(gwin)->MouseX; y = ami_gui2_get_window(gwin)->MouseY; - if(ami_gadget_hit(gwin->objects[GID_URL], x, y)) + if(ami_gadget_hit(ami_gui2_get_object(gwin, AMI_GAD_URL), x, y)) { if((sel = browser_window_get_selection(ami_gui_get_browser_window(g)))) { utf8text = ami_utf8_easy(sel); - RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL], + RefreshSetGadgetAttrs((struct Gadget *)ami_gui2_get_object(gwin, AMI_GAD_URL), ami_gui2_get_window(gwin), NULL, STRINGA_TextVal, utf8text, TAG_DONE); free(sel); ami_utf8_free(utf8text); } } - else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y)) + else if(ami_gadget_hit(ami_gui2_get_object(gwin, AMI_GAD_SEARCH), x, y)) { if((sel = browser_window_get_selection(ami_gui_get_browser_window(g)))) { utf8text = ami_utf8_easy(sel); - RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING], + RefreshSetGadgetAttrs((struct Gadget *)ami_gui2_get_object(gwin, AMI_GAD_SEARCH), ami_gui2_get_window(gwin), NULL, STRINGA_TextVal, utf8text, TAG_DONE); free(sel); ami_utf8_free(utf8text); diff --git a/frontends/amiga/ctxmenu.c b/frontends/amiga/ctxmenu.c index b245324cd..e9ab0e6b4 100644 --- a/frontends/amiga/ctxmenu.c +++ b/frontends/amiga/ctxmenu.c @@ -499,15 +499,15 @@ void ami_ctxmenu_init(void) static bool ami_ctxmenu_history(int direction, struct gui_window_2 *gwin, const struct history_entry *entry) { Object *history_root; - int id = AMI_CTX_ID_HISTORY0 + gwin->temp; + int id = AMI_CTX_ID_HISTORY0 + ami_gui2_get_ctxmenu_history_tmp(gwin); if(direction == AMI_CTXMENU_HISTORY_FORWARD) id += 10; - if(gwin->temp >= 10) return false; + if(ami_gui2_get_ctxmenu_history_tmp(gwin) >= 10) return false; ctxmenu_item_hook[id].h_Entry = (HOOKFUNC)ami_ctxmenu_item_history; ctxmenu_item_hook[id].h_Data = (APTR)entry; - history_root = (Object *)IDoMethod(gwin->history_ctxmenu[direction], MM_FINDID, 0, AMI_CTX_ID_HISTORY); + history_root = (Object *)IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), MM_FINDID, 0, AMI_CTX_ID_HISTORY); IDoMethod(history_root, OM_ADDMEMBER, MStrip, MA_Type, T_ITEM, @@ -518,7 +518,7 @@ static bool ami_ctxmenu_history(int direction, struct gui_window_2 *gwin, const MA_UserData, &ctxmenu_item_hook[id], MEnd); - gwin->temp++; + ami_gui2_set_ctxmenu_history_tmp(gwin, ami_gui2_get_ctxmenu_history_tmp(gwin) + 1); return true; } @@ -544,11 +544,11 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin { Object *obj; - if(gwin->history_ctxmenu[direction] == NULL) { + if(ami_gui2_get_ctxmenu_history(gwin, direction) == NULL) { if(ctxmenu_item_label[AMI_CTX_ID_HISTORY] == NULL) ctxmenu_item_label[AMI_CTX_ID_HISTORY] = ami_utf8_easy(messages_get("History")); - gwin->history_ctxmenu[direction] = MStrip, + obj = MStrip, MA_Type, T_ROOT, MA_AddChild, MStrip, MA_Type, T_MENU, @@ -558,14 +558,17 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin //MA_FreeImage, FALSE, MEnd, MEnd; + + ami_gui2_set_ctxmenu_history(gwin, direction, obj); + } else { for (int i = 0; i < 20; i++) { - obj = (Object *)IDoMethod(gwin->history_ctxmenu[direction], + obj = (Object *)IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), MM_FINDID, 0, AMI_CTX_ID_HISTORY0 + i); - if(obj != NULL) IDoMethod(gwin->history_ctxmenu[direction], OM_REMMEMBER, obj); + if(obj != NULL) IDoMethod(ami_gui2_get_ctxmenu_history(gwin, direction), OM_REMMEMBER, obj); } - gwin->temp = 0; + ami_gui2_set_ctxmenu_history_tmp(gwin, 0); if(direction == AMI_CTXMENU_HISTORY_BACK) { browser_window_history_enumerate_back(ami_gui2_get_browser_window(gwin), ami_ctxmenu_history_back, gwin); @@ -574,7 +577,7 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin } } - return (struct Menu *)gwin->history_ctxmenu[direction]; + return (struct Menu *)ami_gui2_get_ctxmenu_history(gwin, direction); } @@ -586,10 +589,13 @@ struct Menu *ami_ctxmenu_history_create(int direction, struct gui_window_2 *gwin struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin) { Object *root_menu; + Object *clicktab; - if(gwin->clicktab_ctxmenu != NULL) return (struct Menu *)gwin->clicktab_ctxmenu; + if(ami_gui2_get_ctxmenu_clicktab(gwin) != NULL) { + return (struct Menu *)ami_gui2_get_ctxmenu_clicktab(gwin); + } - gwin->clicktab_ctxmenu = MStrip, + clicktab = MStrip, MA_Type, T_ROOT, MA_AddChild, root_menu = MStrip, MA_Type, T_MENU, @@ -598,10 +604,12 @@ struct Menu *ami_ctxmenu_clicktab_create(struct gui_window_2 *gwin) MEnd, MEnd; + ami_gui2_set_ctxmenu_clicktab(gwin, clicktab); + ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABNEW, gwin); ami_ctxmenu_add_item(root_menu, AMI_CTX_ID_TABCLOSE_OTHER, gwin); - return (struct Menu *)gwin->clicktab_ctxmenu; + return (struct Menu *)clicktab; } diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index 64e152478..9832b1d26 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -339,6 +339,18 @@ struct Node *ami_gui_get_tab_node(struct gui_window *gw) return gw->tab_node; } +ULONG ami_gui2_get_tabs(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->tabs; +} + +struct List *ami_gui2_get_tab_list(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return &gwin->tab_list; +} + struct hlcache_handle *ami_gui_get_favicon(struct gui_window *gw) { assert(gw != NULL); @@ -393,12 +405,11 @@ void ami_gui_set_throbber_frame(struct gui_window *gw, int frame) gw->shared->throbber_frame = frame; } -Object *ami_gui_get_object(struct gui_window *gw, int object_type) +Object *ami_gui2_get_object(struct gui_window_2 *gwin, int object_type) { ULONG obj = 0; - assert(gw != NULL); - assert(gw->shared != NULL); + assert(gwin != NULL); switch(object_type) { case AMI_GAD_THROBBER: @@ -409,12 +420,20 @@ Object *ami_gui_get_object(struct gui_window *gw, int object_type) obj = GID_TABS; break; + case AMI_GAD_URL: + obj = GID_URL; + break; + + case AMI_GAD_SEARCH: + obj = GID_SEARCHSTRING; + break; + default: return NULL; break; } - return gw->shared->objects[obj]; + return gwin->objects[obj]; } @@ -458,6 +477,53 @@ void ami_gui_set_control(struct gui_window *gw, struct form_control *control) gw->control = control; } +void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp) +{ + assert(gwin != NULL); + gwin->temp = temp; +} + +int ami_gui2_get_ctxmenu_history_tmp(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->temp; +} + +Object *ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction) +{ + assert(gwin != NULL); + return gwin->history_ctxmenu[direction]; +} + +void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist) +{ + assert(gwin != NULL); + gwin->history_ctxmenu[direction] = ctx_hist; +} + +Object *ami_gui2_get_ctxmenu_clicktab(struct gui_window_2 *gwin) +{ + assert(gwin != NULL); + return gwin->clicktab_ctxmenu; +} + +void ami_gui2_set_ctxmenu_clicktab(struct gui_window_2 *gwin, Object *ctx_tab) +{ + assert(gwin != NULL); + gwin->clicktab_ctxmenu = ctx_tab; +} + +void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed) +{ + assert(gwin != NULL); + gwin->closed = closed; +} + +void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content) +{ + assert(gwin != NULL); + gwin->new_content = new_content; +} /** undocumented, or internal, or documented elsewhere **/ diff --git a/frontends/amiga/gui.h b/frontends/amiga/gui.h index 3b9298a38..f45d22e22 100644 --- a/frontends/amiga/gui.h +++ b/frontends/amiga/gui.h @@ -41,7 +41,9 @@ /* valid options for ami_gui_get_object */ enum { AMI_GAD_THROBBER = 0, - AMI_GAD_TABS + AMI_GAD_TABS, + AMI_GAD_URL, + AMI_GAD_SEARCH }; enum @@ -86,6 +88,9 @@ enum struct find_window; struct ami_history_local_window; struct ami_menu_data; +struct gui_window; +struct gui_window_2; +struct IBox; #define AMI_GUI_TOOLBAR_MAX 20 @@ -304,6 +309,16 @@ const char *ami_gui_get_win_title(struct gui_window *gw); */ struct Node *ami_gui_get_tab_node(struct gui_window *gw); +/** + * Get tabs from gui_window_2 + */ +ULONG ami_gui2_get_tabs(struct gui_window_2 *gwin); + +/** + * Get tab list from gui_window_2 + */ +struct List *ami_gui2_get_tab_list(struct gui_window_2 *gwin); + /** * Get favicon from gui_window */ @@ -347,7 +362,7 @@ void ami_gui_set_throbbing(struct gui_window *gw, bool throbbing); /** * Get object from gui_window */ -Object *ami_gui_get_object(struct gui_window *gw, int object_type); +Object *ami_gui2_get_object(struct gui_window_2 *gwin, int object_type); /** * Get window from gui_window @@ -379,5 +394,45 @@ struct form_control *ami_gui_get_control(struct gui_window *gw); */ void ami_gui_set_control(struct gui_window *gw, struct form_control *control); +/** + * Set ctxmenu history tmp in gui_window_2 + */ +void ami_gui2_set_ctxmenu_history_tmp(struct gui_window_2 *gwin, int temp); + +/** + * Get ctxmenu history tmp from gui_window_2 + */ +int ami_gui2_get_ctxmenu_history_tmp(struct gui_window_2 *gwin); + +/** + * Get ctxmenu history from gui_window_2 + */ +Object *ami_gui2_get_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction); + +/** + * Set ctxmenu history in gui_window_2 + */ +void ami_gui2_set_ctxmenu_history(struct gui_window_2 *gwin, ULONG direction, Object *ctx_hist); + +/** + * Get ctxmenu clicktab from gui_window_2 + */ +Object *ami_gui2_get_ctxmenu_clicktab(struct gui_window_2 *gwin); + +/** + * Set ctxmenu clicktab in gui_window_2 + */ +void ami_gui2_set_ctxmenu_clicktab(struct gui_window_2 *gwin, Object *ctx_tab); + +/** + * Set closed in gui_window_2 + */ +void ami_gui2_set_closed(struct gui_window_2 *gwin, bool closed); + +/** + * Set new_content in gui_window_2 + */ +void ami_gui2_set_new_content(struct gui_window_2 *gwin, bool new_content); + #endif diff --git a/frontends/amiga/gui_menu.c b/frontends/amiga/gui_menu.c index 425643284..08891f381 100644 --- a/frontends/amiga/gui_menu.c +++ b/frontends/amiga/gui_menu.c @@ -157,7 +157,7 @@ HOOKF(void, ami_menu_item_project_closewin, APTR, window, struct IntuiMessage *) struct gui_window_2 *gwin; GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); - gwin->closed = true; + ami_gui2_set_closed(gwin, true); } HOOKF(void, ami_menu_item_project_print, APTR, window, struct IntuiMessage *) @@ -405,7 +405,7 @@ HOOKF(void, ami_menu_item_browser_redraw, APTR, window, struct IntuiMessage *) GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin); ami_schedule_redraw(gwin, true); - gwin->new_content = true; + ami_gui2_set_new_content(gwin, true); } HOOKF(void, ami_menu_item_hotlist_add, APTR, window, struct IntuiMessage *) diff --git a/frontends/amiga/theme.c b/frontends/amiga/theme.c index 275e19fc8..3e6ed8647 100644 --- a/frontends/amiga/theme.c +++ b/frontends/amiga/theme.c @@ -416,10 +416,10 @@ void gui_window_start_throbber(struct gui_window *g) if(nsoption_bool(kiosk_mode)) return; #ifdef __amigaos4__ - if(ami_gui_get_tab_node(g) && (ami_gui_get_gui_window_2(g)->tabs > 1)) + if(ami_gui_get_tab_node(g) && (ami_gui2_get_tabs(ami_gui_get_gui_window_2(g)) > 1)) { SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, TRUE, TAG_DONE); - RefreshGadgets((APTR)ami_gui_get_object(g, AMI_GAD_TABS), + RefreshGadgets((APTR)ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_TABS), ami_gui_get_window(g), NULL); } #endif @@ -437,16 +437,16 @@ void gui_window_stop_throbber(struct gui_window *g) if(nsoption_bool(kiosk_mode)) return; #ifdef __amigaos4__ - if(ami_gui_get_tab_node(g) && (ami_gui_get_gui_window_2(g)->tabs > 1)) + if(ami_gui_get_tab_node(g) && (ami_gui2_get_tabs(ami_gui_get_gui_window_2(g)) > 1)) { SetClickTabNodeAttrs(ami_gui_get_tab_node(g), TNA_Flagged, FALSE, TAG_DONE); - RefreshGadgets((APTR)ami_gui_get_object(g, AMI_GAD_TABS), + RefreshGadgets((APTR)ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_TABS), ami_gui_get_window(g), NULL); } #endif if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g), g)) { - if(ami_gui_get_space_box(ami_gui_get_object(g, AMI_GAD_THROBBER), &bbox) != NSERROR_OK) { + if(ami_gui_get_space_box(ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_THROBBER), &bbox) != NSERROR_OK) { amiga_warn_user("NoMemory", ""); return; } @@ -471,7 +471,7 @@ static void ami_throbber_update(void *p) int frame = 0; if(!g) return; - if(!ami_gui_get_object(g, AMI_GAD_THROBBER)) return; + if(!ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_THROBBER)) return; if(ami_gui_get_throbbing(g) == true) { frame = ami_gui_get_throbber_frame(g); @@ -481,7 +481,7 @@ static void ami_throbber_update(void *p) } if(IS_CURRENT_GW(ami_gui_get_gui_window_2(g),g)) { - if(ami_gui_get_space_box(ami_gui_get_object(g, AMI_GAD_THROBBER), &bbox) != NSERROR_OK) { + if(ami_gui_get_space_box(ami_gui2_get_object(ami_gui_get_gui_window_2(g), AMI_GAD_THROBBER), &bbox) != NSERROR_OK) { amiga_warn_user("NoMemory", ""); return; } -- cgit v1.2.3