diff options
Diffstat (limited to 'frontends/amiga/gui.c')
-rw-r--r-- | frontends/amiga/gui.c | 439 |
1 files changed, 298 insertions, 141 deletions
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index 5384ffec4..62df2e2d3 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -1,5 +1,5 @@ /* - * Copyright 2008-2019 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008-2024 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -152,6 +152,7 @@ #include "amiga/menu.h" #include "amiga/misc.h" #include "amiga/nsoption.h" +#include "amiga/pageinfo.h" #include "amiga/plotters.h" #include "amiga/plugin_hack.h" #include "amiga/print.h" @@ -160,7 +161,7 @@ #include "amiga/selectmenu.h" #include "amiga/theme.h" #include "amiga/utf8.h" -#include "amiga/sslcert.h" +#include "amiga/corewindow.h" #define AMINS_SCROLLERPEN NUMDRIPENS #define NSA_KBD_SCROLL_PX 10 @@ -213,6 +214,12 @@ enum GID_FORWARD, GID_THROBBER, GID_SEARCH_ICON, + GID_PAGEINFO, + GID_PAGEINFO_INSECURE_BM, + GID_PAGEINFO_INTERNAL_BM, + GID_PAGEINFO_LOCAL_BM, + GID_PAGEINFO_SECURE_BM, + GID_PAGEINFO_WARNING_BM, GID_FAVE, GID_FAVE_ADD, GID_FAVE_RMV, @@ -1089,6 +1096,7 @@ static nserror ami_set_options(struct nsoption_s *defaults) const char *encname = (const char *)ObtainCharsetInfo(DFCS_NUMBER, codeset, DFCS_MIMENAME); nsoption_set_charp(local_charset, strdup(encname)); + nsoption_set_int(local_codeset, codeset); #else nsoption_set_bool(download_notify, false); nsoption_set_bool(font_antialiasing, false); @@ -1448,7 +1456,7 @@ static void gui_init2(int argc, char** argv) hotlist_init(nsoption_charp(hotlist_file), nsoption_charp(hotlist_file)); - search_web_select_provider(nsoption_int(search_provider)); + search_web_select_provider(nsoption_charp(search_web_provider)); if (notalreadyrunning && (nsoption_bool(startup_no_window) == false)) @@ -2238,6 +2246,7 @@ static void ami_gui_scroller_update(struct gui_window_2 *gwin) } } +/* For future use static void ami_gui_console_log_clear(struct gui_window *g) { if(g->shared->objects[GID_LOG] != NULL) { @@ -2256,6 +2265,7 @@ static void ami_gui_console_log_clear(struct gui_window *g) TAG_DONE); } } +*/ static void ami_gui_console_log_add(struct gui_window *g) { @@ -2907,12 +2917,22 @@ static BOOL ami_gui_event(void *w) case GID_TOOLBARLAYOUT: /* Need fixing: never gets here */ - search_web_select_provider(-1); break; case GID_SEARCH_ICON: - GetAttr(CHOOSER_Selected, gwin->objects[GID_SEARCH_ICON], (ULONG *)&storage); - search_web_select_provider(storage); +#ifdef __amigaos4__ + { + char *prov = NULL; + GetAttr(CHOOSER_SelectedNode, gwin->objects[GID_SEARCH_ICON],(ULONG *)&storage); + if(storage != NULL) { + GetChooserNodeAttrs((struct Node *)storage, CNA_Text, (ULONG *)&prov, TAG_DONE); + nsoption_set_charp(search_web_provider, (char *)strdup(prov)); + } + } +#else + /* TODO: Fix for OS<3.2 */ +#endif + search_web_select_provider(nsoption_charp(search_web_provider)); break; case GID_SEARCHSTRING: @@ -2991,6 +3011,25 @@ static BOOL ami_gui_event(void *w) ami_gui_history(gwin, false); break; + case GID_PAGEINFO: + { + ULONG w_top, w_left; + ULONG g_top, g_left, g_height; + + GetAttr(WA_Top, gwin->objects[OID_MAIN], &w_top); + GetAttr(WA_Left, gwin->objects[OID_MAIN], &w_left); + GetAttr(GA_Top, gwin->objects[GID_PAGEINFO], &g_top); + GetAttr(GA_Left, gwin->objects[GID_PAGEINFO], &g_left); + GetAttr(GA_Height, gwin->objects[GID_PAGEINFO], &g_height); + + if(ami_pageinfo_open(gwin->gw->bw, + w_left + g_left, + w_top + g_top + g_height) != NSERROR_OK) { + NSLOG(netsurf, INFO, "Unable to open page info window"); + } + } + break; + case GID_FAVE: GetAttr(STRINGA_TextVal, (Object *)gwin->objects[GID_URL], @@ -3226,6 +3265,56 @@ static void ami_gui_appicon_remove(struct gui_window_2 *gwin) } } +static nserror gui_page_info_change(struct gui_window *gw) +{ + int bm_idx; + browser_window_page_info_state pistate; + struct gui_window_2 *gwin = ami_gui_get_gui_window_2(gw); + struct browser_window *bw = ami_gui_get_browser_window(gw); + + /* if this isn't the visible tab, don't do anything */ + if((gwin == NULL) || (gwin->gw != gw)) return NSERROR_OK; + + pistate = browser_window_get_page_info_state(bw); + + switch(pistate) { + case PAGE_STATE_INTERNAL: + bm_idx = GID_PAGEINFO_INTERNAL_BM; + break; + + case PAGE_STATE_LOCAL: + bm_idx = GID_PAGEINFO_LOCAL_BM; + break; + + case PAGE_STATE_INSECURE: + bm_idx = GID_PAGEINFO_INSECURE_BM; + break; + + case PAGE_STATE_SECURE_OVERRIDE: + bm_idx = GID_PAGEINFO_WARNING_BM; + break; + + case PAGE_STATE_SECURE_ISSUES: + bm_idx = GID_PAGEINFO_WARNING_BM; + break; + + case PAGE_STATE_SECURE: + bm_idx = GID_PAGEINFO_SECURE_BM; + break; + + default: + bm_idx = GID_PAGEINFO_INTERNAL_BM; + break; + } + + RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_PAGEINFO], gwin->win, NULL, + BUTTON_RenderImage, gwin->objects[bm_idx], + GA_HintInfo, gwin->helphints[bm_idx], + TAG_DONE); + + return NSERROR_OK; +} + static void ami_handle_appmsg(void) { struct AppMessage *appmsg; @@ -3519,6 +3608,135 @@ static void ami_change_tab(struct gui_window_2 *gwin, int direction) ami_switch_tab(gwin, true); } + +static void gui_window_set_title(struct gui_window *g, const char *restrict title) +{ + struct Node *node; + char *restrict utf8title; + + if(!g) return; + if(!title) return; + + utf8title = ami_utf8_easy((char *)title); + + if(g->tab_node) { + node = g->tab_node; + + if((g->tabtitle == NULL) || (strcmp(utf8title, g->tabtitle))) + { + SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], + g->shared->win, NULL, + CLICKTAB_Labels, ~0, + TAG_DONE); + + if(g->tabtitle) free(g->tabtitle); + g->tabtitle = strdup(utf8title); + + SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle, + TNA_HintInfo, g->tabtitle, + TAG_DONE); + + RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], + g->shared->win, NULL, + CLICKTAB_Labels, &g->shared->tab_list, + TAG_DONE); + + if(ClickTabBase->lib_Version < 53) + RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT], + g->shared->win, NULL, TRUE); + } + } + + if(g == g->shared->gw) { + if((g->shared->wintitle == NULL) || (strcmp(utf8title, g->shared->wintitle))) + { + if(g->shared->wintitle) free(g->shared->wintitle); + g->shared->wintitle = strdup(utf8title); + SetWindowTitles(g->shared->win, g->shared->wintitle, ami_gui_get_screen_title()); + } + } + + ami_utf8_free(utf8title); +} + +static void gui_window_update_extent(struct gui_window *g) +{ + struct IBox *bbox; + + if(!g || !g->bw) return; + if(browser_window_has_content(g->bw) == false) return; + + if(g == g->shared->gw) { + int width, height; + if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) { + amiga_warn_user("NoMemory", ""); + return; + } + + if(g->shared->objects[GID_VSCROLL]) { + browser_window_get_extents(g->bw, true, &width, &height); + RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_VSCROLL],g->shared->win,NULL, + SCROLLER_Total, (ULONG)(height), + SCROLLER_Visible, bbox->Height, + TAG_DONE); + } + + if(g->shared->objects[GID_HSCROLL]) + { + browser_window_get_extents(g->bw, true, &width, &height); + RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_HSCROLL], + g->shared->win, NULL, + SCROLLER_Total, (ULONG)(width), + SCROLLER_Visible, bbox->Width, + TAG_DONE); + } + + ami_gui_free_space_box(bbox); + } + + ami_gui_scroller_update(g->shared); + g->shared->new_content = true; +} + + +/** + * Invalidates an area of an amiga browser window + * + * \param g gui_window + * \param rect area to redraw or NULL for the entire window area + * \return NSERROR_OK on success or appropriate error code + */ +static nserror amiga_window_invalidate_area(struct gui_window *g, + const struct rect *restrict rect) +{ + struct nsObject *nsobj; + struct rect *restrict deferred_rect; + + if(!g) return NSERROR_BAD_PARAMETER; + + if (rect == NULL) { + if (g != g->shared->gw) { + return NSERROR_OK; + } + } else { + if (ami_gui_window_update_box_deferred_check(g->deferred_rects, rect, + g->deferred_rects_pool)) { + deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool, + sizeof(struct rect)); + CopyMem(rect, deferred_rect, sizeof(struct rect)); + nsobj = AddObject(g->deferred_rects, AMINS_RECT); + nsobj->objstruct = deferred_rect; + } else { + NSLOG(netsurf, INFO, + "Ignoring duplicate or subset of queued box redraw"); + } + } + ami_schedule_redraw(g->shared, false); + + return NSERROR_OK; +} + + static void ami_switch_tab(struct gui_window_2 *gwin, bool redraw) { struct Node *tabnode; @@ -3564,7 +3782,10 @@ static void ami_switch_tab(struct gui_window_2 *gwin, bool redraw) struct rect rect; ami_plot_clear_bbox(gwin->win->RPort, bbox); - browser_window_update(gwin->gw->bw, false); + gui_window_set_title(gwin->gw, + browser_window_get_title(gwin->gw->bw)); + gui_window_update_extent(gwin->gw); + amiga_window_invalidate_area(gwin->gw, NULL); rect.x0 = rect.x1 = gwin->gw->scrollx; rect.y0 = rect.y1 = gwin->gw->scrolly; @@ -3578,6 +3799,7 @@ static void ami_switch_tab(struct gui_window_2 *gwin, bool redraw) ami_throbber_redraw_schedule(0, gwin->gw); gui_window_set_icon(gwin->gw, gwin->gw->favicon); + gui_page_info_change(gwin->gw); } ami_gui_free_space_box(bbox); @@ -4070,7 +4292,12 @@ static void ami_toggletabbar(struct gui_window_2 *gwin, bool show) RethinkLayout((struct Gadget *)gwin->objects[GID_MAIN], gwin->win, NULL, TRUE); - if(gwin->gw && gwin->gw->bw) browser_window_update(gwin->gw->bw, false); + if (gwin->gw && gwin->gw->bw) { + gui_window_set_title(gwin->gw, + browser_window_get_title(gwin->gw->bw)); + gui_window_update_extent(gwin->gw); + amiga_window_invalidate_area(gwin->gw, NULL); + } } void ami_gui_tabs_toggle_all(void) @@ -4100,10 +4327,6 @@ void ami_gui_tabs_toggle_all(void) } while((node = nnode)); } -static void ami_gui_search_ico_refresh(void *p) -{ - search_web_select_provider(-1); -} /** * Count windows, and optionally tabs. @@ -4328,44 +4551,6 @@ static void ami_do_redraw_limits(struct gui_window *g, struct browser_window *bw } -/** - * Invalidates an area of an amiga browser window - * - * \param g gui_window - * \param rect area to redraw or NULL for the entire window area - * \return NSERROR_OK on success or appropriate error code - */ -static nserror amiga_window_invalidate_area(struct gui_window *g, - const struct rect *restrict rect) -{ - struct nsObject *nsobj; - struct rect *restrict deferred_rect; - - if(!g) return NSERROR_BAD_PARAMETER; - - if (rect == NULL) { - if (g != g->shared->gw) { - return NSERROR_OK; - } - } else { - if (ami_gui_window_update_box_deferred_check(g->deferred_rects, rect, - g->deferred_rects_pool)) { - deferred_rect = ami_memory_itempool_alloc(g->deferred_rects_pool, - sizeof(struct rect)); - CopyMem(rect, deferred_rect, sizeof(struct rect)); - nsobj = AddObject(g->deferred_rects, AMINS_RECT); - nsobj->objstruct = deferred_rect; - } else { - NSLOG(netsurf, INFO, - "Ignoring duplicate or subset of queued box redraw"); - } - } - ami_schedule_redraw(g->shared, false); - - return NSERROR_OK; -} - - static void ami_refresh_window(struct gui_window_2 *gwin) { /* simplerefresh only */ @@ -4534,6 +4719,7 @@ gui_window_create(struct browser_window *bw, char closetab[100],closetab_s[100],closetab_g[100]; char addtab[100],addtab_s[100],addtab_g[100]; char fave[100], unfave[100]; + char pi_insecure[100], pi_internal[100], pi_local[100], pi_secure[100], pi_warning[100]; char tabthrobber[100]; ULONG refresh_mode = WA_SmartRefresh; ULONG defer_layout = TRUE; @@ -4730,7 +4916,7 @@ gui_window_create(struct browser_window *bw, TAG_DONE); AddTail(&g->shared->tab_list,g->tab_node); - g->shared->web_search_list = ami_gui_opts_websearch(); + g->shared->web_search_list = ami_gui_opts_websearch(NULL); g->shared->search_bm = NULL; g->shared->tabs=1; @@ -4755,6 +4941,12 @@ gui_window_create(struct browser_window *bw, g->shared->helphints[GID_ADDTAB] = translate_escape_chars(messages_get("HelpToolbarAddTab")); + g->shared->helphints[GID_PAGEINFO_INSECURE_BM] = ami_utf8_easy(messages_get("PageInfoInsecure")); + g->shared->helphints[GID_PAGEINFO_LOCAL_BM] = ami_utf8_easy(messages_get("PageInfoLocal")); + g->shared->helphints[GID_PAGEINFO_SECURE_BM] = ami_utf8_easy(messages_get("PageInfoSecure")); + g->shared->helphints[GID_PAGEINFO_WARNING_BM] = ami_utf8_easy(messages_get("PageInfoWarning")); + g->shared->helphints[GID_PAGEINFO_INTERNAL_BM] = ami_utf8_easy(messages_get("PageInfoInternal")); + ami_get_theme_filename(nav_west, "theme_nav_west", false); ami_get_theme_filename(nav_west_s, "theme_nav_west_s", false); ami_get_theme_filename(nav_west_g, "theme_nav_west_g", false); @@ -4779,6 +4971,11 @@ gui_window_create(struct browser_window *bw, ami_get_theme_filename(tabthrobber, "theme_tab_loading", false); ami_get_theme_filename(fave, "theme_fave", false); ami_get_theme_filename(unfave, "theme_unfave", false); + ami_get_theme_filename(pi_insecure, "theme_pageinfo_insecure", false); + ami_get_theme_filename(pi_internal, "theme_pageinfo_internal", false); + ami_get_theme_filename(pi_local, "theme_pageinfo_local", false); + ami_get_theme_filename(pi_secure, "theme_pageinfo_secure", false); + ami_get_theme_filename(pi_warning, "theme_pageinfo_warning", false); g->shared->objects[GID_FAVE_ADD] = BitMapObj, BITMAP_SourceFile, fave, @@ -4808,6 +5005,37 @@ gui_window_create(struct browser_window *bw, BITMAP_Masking, TRUE, BitMapEnd; + g->shared->objects[GID_PAGEINFO_INSECURE_BM] = BitMapObj, + BITMAP_SourceFile, pi_insecure, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_INTERNAL_BM] = BitMapObj, + BITMAP_SourceFile, pi_internal, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_LOCAL_BM] = BitMapObj, + BITMAP_SourceFile, pi_local, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_SECURE_BM] = BitMapObj, + BITMAP_SourceFile, pi_secure, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + g->shared->objects[GID_PAGEINFO_WARNING_BM] = BitMapObj, + BITMAP_SourceFile, pi_warning, + BITMAP_Screen, scrn, + BITMAP_Masking, TRUE, + BitMapEnd; + + if(ClickTabBase->lib_Version < 53) { addtabclosegadget = LAYOUT_AddChild; @@ -4966,6 +5194,14 @@ gui_window_create(struct browser_window *bw, SpaceEnd, CHILD_WeightedWidth, 0, CHILD_WeightedHeight, 0, + LAYOUT_AddChild, g->shared->objects[GID_PAGEINFO] = ButtonObj, + GA_ID, GID_PAGEINFO, + GA_RelVerify, TRUE, + GA_ReadOnly, FALSE, + BUTTON_RenderImage, g->shared->objects[GID_PAGEINFO_INTERNAL_BM], + ButtonEnd, + CHILD_WeightedWidth, 0, + CHILD_WeightedHeight, 0, LAYOUT_AddChild, g->shared->objects[GID_URL] = #ifdef __amigaos4__ NewObject(urlStringClass, NULL, @@ -5204,8 +5440,6 @@ gui_window_create(struct browser_window *bw, locked_screen = FALSE; } - ami_schedule(0, ami_gui_search_ico_refresh, NULL); - ScreenToFront(scrn); return g; @@ -5335,6 +5569,11 @@ static void gui_window_destroy(struct gui_window *g) DisposeObject(g->shared->objects[GID_TABS_FLAG]); DisposeObject(g->shared->objects[GID_FAVE_ADD]); DisposeObject(g->shared->objects[GID_FAVE_RMV]); + DisposeObject(g->shared->objects[GID_PAGEINFO_INSECURE_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_INTERNAL_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_LOCAL_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_SECURE_BM]); + DisposeObject(g->shared->objects[GID_PAGEINFO_WARNING_BM]); ami_gui_opts_websearch_free(g->shared->web_search_list); if(g->shared->search_bm) DisposeObject(g->shared->search_bm); @@ -5375,55 +5614,6 @@ static void gui_window_destroy(struct gui_window *g) win_destroyed = true; } -static void gui_window_set_title(struct gui_window *g, const char *restrict title) -{ - struct Node *node; - char *restrict utf8title; - - if(!g) return; - if(!title) return; - - utf8title = ami_utf8_easy((char *)title); - - if(g->tab_node) { - node = g->tab_node; - - if((g->tabtitle == NULL) || (strcmp(utf8title, g->tabtitle))) - { - SetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], - g->shared->win, NULL, - CLICKTAB_Labels, ~0, - TAG_DONE); - - if(g->tabtitle) free(g->tabtitle); - g->tabtitle = strdup(utf8title); - - SetClickTabNodeAttrs(node, TNA_Text, g->tabtitle, - TNA_HintInfo, g->tabtitle, - TAG_DONE); - - RefreshSetGadgetAttrs((struct Gadget *)g->shared->objects[GID_TABS], - g->shared->win, NULL, - CLICKTAB_Labels, &g->shared->tab_list, - TAG_DONE); - - if(ClickTabBase->lib_Version < 53) - RethinkLayout((struct Gadget *)g->shared->objects[GID_TABLAYOUT], - g->shared->win, NULL, TRUE); - } - } - - if(g == g->shared->gw) { - if((g->shared->wintitle == NULL) || (strcmp(utf8title, g->shared->wintitle))) - { - if(g->shared->wintitle) free(g->shared->wintitle); - g->shared->wintitle = strdup(utf8title); - SetWindowTitles(g->shared->win, g->shared->wintitle, ami_gui_get_screen_title()); - } - } - - ami_utf8_free(utf8title); -} static void ami_redraw_callback(void *p) { @@ -5734,45 +5924,6 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect) return NSERROR_OK; } -static void gui_window_update_extent(struct gui_window *g) -{ - struct IBox *bbox; - - if(!g || !g->bw) return; - if(browser_window_has_content(g->bw) == false) return; - - if(g == g->shared->gw) { - int width, height; - if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) { - amiga_warn_user("NoMemory", ""); - return; - } - - if(g->shared->objects[GID_VSCROLL]) { - browser_window_get_extents(g->bw, true, &width, &height); - RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_VSCROLL],g->shared->win,NULL, - SCROLLER_Total, (ULONG)(height), - SCROLLER_Visible, bbox->Height, - TAG_DONE); - } - - if(g->shared->objects[GID_HSCROLL]) - { - browser_window_get_extents(g->bw, true, &width, &height); - RefreshSetGadgetAttrs((struct Gadget *)(APTR)g->shared->objects[GID_HSCROLL], - g->shared->win, NULL, - SCROLLER_Total, (ULONG)(width), - SCROLLER_Visible, bbox->Width, - TAG_DONE); - } - - ami_gui_free_space_box(bbox); - } - - ami_gui_scroller_update(g->shared); - g->shared->new_content = true; -} - static void gui_window_set_status(struct gui_window *g, const char *text) { char *utf8text; @@ -6319,6 +6470,10 @@ gui_window_event(struct gui_window *gw, enum gui_window_event event) gui_window_stop_throbber(gw); break; + case GW_EVENT_PAGE_INFO_CHANGE: + gui_page_info_change(gw); + break; + default: break; } @@ -6371,6 +6526,7 @@ static struct gui_misc_table amiga_misc_table = { .quit = gui_quit, .launch_url = gui_launch_url, + .present_cookies = ami_cookies_present, }; /** Normal entry point from OS */ @@ -6390,6 +6546,7 @@ int main(int argc, char** argv) struct netsurf_table amiga_table = { .misc = &amiga_misc_table, .window = &amiga_window_table, + .corewindow = amiga_core_window_table, .clipboard = amiga_clipboard_table, .download = amiga_download_table, .fetch = &amiga_fetch_table, |