From 6a002558551b5dd57c062268079aef7a63f444e7 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 5 Sep 2015 15:37:34 +0100 Subject: Enable control of core/popupmenu select menus in the prefs GUI. This at least gives the option for people who prefer the popupmenu-based selection menus to easily switch back to the core ones when the options don't all fit on the screen (as popupmenu can't scroll). --- amiga/gui.h | 1 - amiga/gui_options.c | 21 ++++++++++++++++++++- amiga/os3support.h | 2 ++ amiga/selectmenu.c | 23 ++++++++++++++++++----- amiga/selectmenu.h | 9 +++++++++ resources/FatMessages | 5 +++++ 6 files changed, 54 insertions(+), 7 deletions(-) diff --git a/amiga/gui.h b/amiga/gui.h index 536071c77..6348884ce 100644 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -226,6 +226,5 @@ struct MsgPort *sport; struct gui_window *cur_gw; struct gui_globals browserglob; BOOL ami_autoscroll; -BOOL popupmenu_lib_ok; #endif diff --git a/amiga/gui_options.c b/amiga/gui_options.c index 2f16b9001..c2aaeb1f2 100755 --- a/amiga/gui_options.c +++ b/amiga/gui_options.c @@ -71,6 +71,7 @@ #include "amiga/libs.h" #include "amiga/misc.h" #include "amiga/object.h" +#include "amiga/selectmenu.h" #include "amiga/theme.h" #include "amiga/utf8.h" @@ -132,6 +133,7 @@ enum GID_OPTS_TAB_CLOSE, GID_OPTS_SEARCH_PROV, GID_OPTS_CLIPBOARD, + GID_OPTS_SELECTMENU, GID_OPTS_STARTUP_NO_WIN, GID_OPTS_CLOSE_NO_QUIT, GID_OPTS_DOCKY, @@ -327,6 +329,7 @@ static void ami_gui_opts_setup(struct ami_gui_opts_window *gow) gadlab[GID_OPTS_TAB_CLOSE] = (char *)ami_utf8_easy((char *)messages_get("TabClose")); gadlab[GID_OPTS_SEARCH_PROV] = (char *)ami_utf8_easy((char *)messages_get("SearchProvider")); gadlab[GID_OPTS_CLIPBOARD] = (char *)ami_utf8_easy((char *)messages_get("ClipboardUTF8")); + gadlab[GID_OPTS_SELECTMENU] = (char *)ami_utf8_easy((char *)messages_get("PopupMenu")); gadlab[GID_OPTS_STARTUP_NO_WIN] = (char *)ami_utf8_easy((char *)messages_get("OptionNoWindow")); gadlab[GID_OPTS_CLOSE_NO_QUIT] = (char *)ami_utf8_easy((char *)messages_get("OptionNoQuit")); gadlab[GID_OPTS_DOCKY] = (char *)ami_utf8_easy((char *)messages_get("OptionDocky")); @@ -1364,7 +1367,16 @@ void ami_gui_opts_open(void) GA_Text, gadlab[GID_OPTS_FASTSCROLL], GA_Selected, nsoption_bool(faster_scroll), CheckBoxEnd, - LayoutEnd, // context menus +#ifdef __amigaos4__ + LAYOUT_AddChild, gow->objects[GID_OPTS_SELECTMENU] = CheckBoxObj, + GA_ID, GID_OPTS_SELECTMENU, + GA_RelVerify, TRUE, + GA_Text, gadlab[GID_OPTS_SELECTMENU], + GA_Selected, nsoption_bool(core_select_menu), + GA_Disabled, !ami_selectmenu_is_safe(), + CheckBoxEnd, +#endif + LayoutEnd, // misc CHILD_WeightedHeight, 0, LayoutEnd, // page vgroup @@ -1844,6 +1856,13 @@ static void ami_gui_opts_use(bool save) nsoption_set_bool(clipboard_write_utf8, false); } + GetAttr(GA_Selected,gow->objects[GID_OPTS_SELECTMENU],(ULONG *)&data); + if (data) { + nsoption_set_bool(core_select_menu, true); + } else { + nsoption_set_bool(core_select_menu, false); + } + GetAttr(GA_Selected,gow->objects[GID_OPTS_STARTUP_NO_WIN],(ULONG *)&data); if (data) { nsoption_set_bool(startup_no_window, true); diff --git a/amiga/os3support.h b/amiga/os3support.h index ac7f31590..45a917a46 100644 --- a/amiga/os3support.h +++ b/amiga/os3support.h @@ -73,6 +73,7 @@ #define GETFONT_ScalableOnly TAG_IGNORE #define PDTA_PromoteMask TAG_IGNORE #define RPTAG_APenColor TAG_IGNORE +#define GA_ContextMenu TAG_IGNORE #define GA_HintInfo TAG_IGNORE #define GAUGEIA_Level TAG_IGNORE #define IA_InBorder TAG_IGNORE @@ -81,6 +82,7 @@ #define SBNA_Text TAG_IGNORE #define TNA_CloseGadget TAG_IGNORE #define TNA_HintInfo TAG_IGNORE +#define WA_ContextMenuHook TAG_IGNORE #define WA_ToolBox TAG_IGNORE #define WINDOW_BuiltInScroll TAG_IGNORE #define WINDOW_NewMenu TAG_IGNORE diff --git a/amiga/selectmenu.c b/amiga/selectmenu.c index 642362b4d..0af0e1739 100644 --- a/amiga/selectmenu.c +++ b/amiga/selectmenu.c @@ -25,6 +25,7 @@ #include #include "utils/errors.h" +#include "utils/log.h" #include "render/form.h" #include "desktop/mouse.h" @@ -33,7 +34,21 @@ #include "amiga/theme.h" #include "amiga/utf8.h" +/** Exported interface documented in selectmenu.h **/ +BOOL ami_selectmenu_is_safe(void) +{ + struct Library *PopupMenuBase; + BOOL popupmenu_lib_ok = FALSE; + + if((PopupMenuBase = OpenLibrary("popupmenu.library", 53))) { + LOG("popupmenu.library v%d.%d", PopupMenuBase->lib_Version, PopupMenuBase->lib_Revision); + if(LIB_IS_AT_LEAST((struct Library *)PopupMenuBase, 53, 11)) + popupmenu_lib_ok = TRUE; + CloseLibrary(PopupMenuBase); + } + return popupmenu_lib_ok; +} HOOKF(uint32, ami_popup_hook, Object *, item, APTR) { @@ -57,8 +72,8 @@ void gui_create_form_select_menu(struct gui_window *g, struct form_option *opt = form_select_get_option(control, 0); ULONG i = 0; - /**\todo Open popupmenu.library to check the version. - * Versions older than 53.11 are dangerous! */ + if(ami_selectmenu_is_safe() == FALSE) return; + if((PopupMenuBase = OpenLibrary("popupmenu.class", 0))) { IPopupMenu = (struct PopupMenuIFace *)GetInterface(PopupMenuBase, "main", 1, NULL); } @@ -72,8 +87,6 @@ void gui_create_form_select_menu(struct gui_window *g, g->shared->control = control; /**\todo PMIA_Title memory leaks as we don't free the strings. - * We use the core menu anyway, but in future when popupmenu.class - * improves we will probably start using this again. */ selectmenuobj = PMMENU(ami_utf8_easy(form_control_get_name(control))), @@ -97,7 +110,7 @@ void gui_create_form_select_menu(struct gui_window *g, IDoMethod(selectmenuobj, PM_OPEN, g->shared->win); - /* I believe PM_OPEN is blocking, so dispose menu immediately... */ + /* PM_OPEN is blocking, so dispose menu immediately... */ if(selectmenuobj) DisposeObject(selectmenuobj); /* ...and get rid of popupmenu.class ASAP */ diff --git a/amiga/selectmenu.h b/amiga/selectmenu.h index 97f288add..760f58997 100755 --- a/amiga/selectmenu.h +++ b/amiga/selectmenu.h @@ -22,7 +22,16 @@ struct gui_window; struct form_control; +BOOL popupmenu_lib_ok; + void gui_create_form_select_menu(struct gui_window *g, struct form_control *control); +/** + * Opens popupmenu.library to check the version. + * Versions older than 53.11 are dangerous! + * + * \returns TRUE if popupmenu is safe, FALSE otherwise. + */ +BOOL ami_selectmenu_is_safe(void); #endif diff --git a/resources/FatMessages b/resources/FatMessages index fa661255a..765f037c2 100644 --- a/resources/FatMessages +++ b/resources/FatMessages @@ -6159,6 +6159,11 @@ de.ami.OptionDocky:In AmiDock zeigen fr.ami.OptionDocky:Afficher dans AmiDock it.ami.OptionDocky:Mostra icona di NetSurf su AmiDock nl.ami.OptionDocky:Show in AmiDock +en.ami.PopupMenu:Use popupmenu for forms +de.ami.PopupMenu:Use popupmenu for forms +fr.ami.PopupMenu:Use popupmenu for forms +it.ami.PopupMenu:Use popupmenu for forms +nl.ami.PopupMenu:Use popupmenu for forms en.all.Clipboard:Clipboard de.all.Clipboard:Clipboard fr.all.Clipboard:Presse-papiers -- cgit v1.2.3