Rename context_menu.c and strip out all the context menu code, so this file and popupmenu.class is only used (optionally) for HTML form selection.

This commit is contained in:
Chris Young 2015-09-05 15:09:00 +01:00
parent 00aa1e2d35
commit 63227a214b
8 changed files with 124 additions and 1407 deletions

View File

@ -70,12 +70,13 @@ MESSAGES_FILTER=ami
S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \
misc.c bitmap.c font.c filetype.c utf8.c login.c \
plotters.c object.c menu.c save_pdf.c arexx.c version.c \
cookies.c context_menu.c ctxmenu.c clipboard.c help.c font_scan.c \
cookies.c ctxmenu.c clipboard.c help.c font_scan.c \
launch.c search.c history_local.c download.c iff_dr2d.c \
sslcert.c gui_options.c print.c theme.c drag.c icon.c libs.c \
datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \
stringview/stringview.c stringview/urlhistory.c rtg.c \
agclass/amigaguide_class.c os3support.c font_bitmap.c
agclass/amigaguide_class.c os3support.c font_bitmap.c \
selectmenu.c
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
# This is the final source build list

File diff suppressed because it is too large Load Diff

View File

@ -34,9 +34,6 @@
#include <proto/intuition.h>
#include <proto/keymap.h>
#include <proto/locale.h>
#ifdef __amigaos4__
#include <proto/popupmenu.h>
#endif
#include <proto/utility.h>
#include <proto/wb.h>
@ -119,7 +116,6 @@
#include "amiga/arexx.h"
#include "amiga/bitmap.h"
#include "amiga/clipboard.h"
#include "amiga/context_menu.h"
#include "amiga/cookies.h"
#include "amiga/ctxmenu.h"
#include "amiga/datatypes.h"
@ -145,6 +141,7 @@
#include "amiga/print.h"
#include "amiga/schedule.h"
#include "amiga/search.h"
#include "amiga/selectmenu.h"
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
@ -542,9 +539,8 @@ static nserror ami_set_options(struct nsoption_s *defaults)
STRPTR tempacceptlangs;
char temp[1024];
/* The following line disables the popupmenu.class select menu
** This will become a user option when/if popupmenu.class is
** updated to show more items than can fit in one column vertically
/* The following line disables the popupmenu.class select menu.
** It's not recommended to use it!
*/
nsoption_set_bool(core_select_menu, true);
@ -627,9 +623,6 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
if(popupmenu_lib_ok == FALSE)
nsoption_set_bool(context_menu, false);
#ifndef __amigaos4__
nsoption_set_bool(download_notify, false);
nsoption_set_bool(font_antialiasing, false);
@ -1923,7 +1916,6 @@ static void ami_handle_msg(void)
if((x>=xs) && (y>=ys) && (x<width+xs) && (y<height+ys))
{
ami_update_quals(gwin);
ami_context_menu_mouse_trap(gwin, TRUE);
if(gwin->mouse_state & BROWSER_MOUSE_PRESS_1)
{
@ -1939,11 +1931,7 @@ static void ami_handle_msg(void)
{
browser_window_mouse_track(gwin->gw->bw,gwin->mouse_state | gwin->key_state,x,y);
}
}
else
{
ami_context_menu_mouse_trap(gwin, FALSE);
} else {
if(!gwin->mouse_state) ami_set_pointer(gwin, GUI_POINTER_DEFAULT, true);
}
break;
@ -1993,10 +1981,6 @@ static void ami_handle_msg(void)
switch(code)
{
case MENUDOWN:
ami_context_menu_show(gwin,x,y);
break;
case SELECTUP:
if(gwin->mouse_state & BROWSER_MOUSE_PRESS_1)
{
@ -2948,7 +2932,6 @@ static void gui_quit(void)
if(nsscreentitle) FreeVec(nsscreentitle);
LOG("Freeing menu items");
ami_context_menu_free();
ami_ctxmenu_free();
ami_menu_free_glyphs();
@ -5369,19 +5352,6 @@ int main(int argc, char** argv)
/* Open splash window */
Object *splash_window = ami_gui_splash_open();
/* Open popupmenu.library just to check the version.
* Versions older than 53.11 are dangerous, so we
* forcibly disable context menus if these are in use.
*/
popupmenu_lib_ok = FALSE;
#ifdef __amigaos4__
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);
}
#endif
if (ami_open_resources() == false) { /* alloc message ports */
ami_misc_fatal_error("Unable to allocate resources");
return RETURN_FAIL;
@ -5446,7 +5416,6 @@ int main(int argc, char** argv)
ami_openurl_open();
ami_amiupdate(); /* set env-vars for AmiUpdate */
ami_init_fonts();
ami_context_menu_init();
save_complete_init();
ami_theme_init();
ami_init_mouse_pointers();

View File

@ -132,7 +132,6 @@ enum
GID_OPTS_TAB_CLOSE,
GID_OPTS_SEARCH_PROV,
GID_OPTS_CLIPBOARD,
GID_OPTS_CONTEXTMENU,
GID_OPTS_STARTUP_NO_WIN,
GID_OPTS_CLOSE_NO_QUIT,
GID_OPTS_DOCKY,
@ -328,7 +327,6 @@ 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_CONTEXTMENU] = (char *)ami_utf8_easy((char *)messages_get("ContextMenu"));
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"));
@ -1360,15 +1358,6 @@ void ami_gui_opts_open(void)
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, gadlab[GRP_OPTS_MISC],
LAYOUT_SpaceOuter, TRUE,
#ifdef __amigaos4__
LAYOUT_AddChild, gow->objects[GID_OPTS_CONTEXTMENU] = CheckBoxObj,
GA_ID, GID_OPTS_CONTEXTMENU,
GA_RelVerify, TRUE,
GA_Text, gadlab[GID_OPTS_CONTEXTMENU],
GA_Selected, nsoption_bool(context_menu),
GA_Disabled, !popupmenu_lib_ok,
CheckBoxEnd,
#endif
LAYOUT_AddChild, gow->objects[GID_OPTS_FASTSCROLL] = CheckBoxObj,
GA_ID, GID_OPTS_FASTSCROLL,
GA_RelVerify, TRUE,
@ -1855,13 +1844,6 @@ static void ami_gui_opts_use(bool save)
nsoption_set_bool(clipboard_write_utf8, false);
}
GetAttr(GA_Selected,gow->objects[GID_OPTS_CONTEXTMENU],(ULONG *)&data);
if (data) {
nsoption_set_bool(context_menu, true);
} else {
nsoption_set_bool(context_menu, false);
}
GetAttr(GA_Selected,gow->objects[GID_OPTS_STARTUP_NO_WIN],(ULONG *)&data);
if (data) {
nsoption_set_bool(startup_no_window, true);

View File

@ -34,7 +34,6 @@ NSOPTION_INTEGER(screen_ydpi, 85)
NSOPTION_INTEGER(cache_bitmaps, 0)
NSOPTION_STRING(theme, "PROGDIR:Resources/Themes/Default")
NSOPTION_BOOL(clipboard_write_utf8, false)
NSOPTION_BOOL(context_menu, true)
NSOPTION_BOOL(truecolour_mouse_pointers, false)
NSOPTION_BOOL(os_mouse_pointers, true)
NSOPTION_BOOL(use_openurl_lib, false)

114
amiga/selectmenu.c Normal file
View File

@ -0,0 +1,114 @@
/*
* Copyright 2008 - 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef __amigaos4__
#include <stdbool.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/popupmenu.h>
#include <reaction/reaction_macros.h>
#include "utils/errors.h"
#include "render/form.h"
#include "desktop/mouse.h"
#include "amiga/gui.h"
#include "amiga/selectmenu.h"
#include "amiga/theme.h"
#include "amiga/utf8.h"
HOOKF(uint32, ami_popup_hook, Object *, item, APTR)
{
uint32 itemid = 0;
struct gui_window *gwin = hook->h_Data;
if(GetAttr(PMIA_ID, item, &itemid)) {
form_select_process_selection(gwin->shared->control, itemid);
}
return itemid;
}
void gui_create_form_select_menu(struct gui_window *g,
struct form_control *control)
{
struct Library *PopupMenuBase = NULL;
struct PopupMenuIFace *IPopupMenu = NULL;
struct Hook ctxmenuhook;
Object *selectmenuobj;
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((PopupMenuBase = OpenLibrary("popupmenu.class", 0))) {
IPopupMenu = (struct PopupMenuIFace *)GetInterface(PopupMenuBase, "main", 1, NULL);
}
if(IPopupMenu == NULL) return;
ctxmenuhook.h_Entry = ami_popup_hook;
ctxmenuhook.h_SubEntry = NULL;
ctxmenuhook.h_Data = 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))),
PMA_MenuHandler, &ctxmenuhook, End;
while(opt) {
IDoMethod(selectmenuobj, PM_INSERT,
NewObject(POPUPMENU_GetItemClass(), NULL,
PMIA_Title, (ULONG)ami_utf8_easy(opt->text),
PMIA_ID, i,
PMIA_CheckIt, TRUE,
PMIA_Checked, opt->selected,
TAG_DONE),
~0);
opt = opt->next;
i++;
}
ami_set_pointer(g->shared, GUI_POINTER_DEFAULT, false); // Clear the menu-style pointer
IDoMethod(selectmenuobj, PM_OPEN, g->shared->win);
/* I believe PM_OPEN is blocking, so dispose menu immediately... */
if(selectmenuobj) DisposeObject(selectmenuobj);
/* ...and get rid of popupmenu.class ASAP */
if(IPopupMenu) DropInterface((struct Interface *)IPopupMenu);
if(PopupMenuBase) CloseLibrary(PopupMenuBase);
}
#else
#include "amiga/selectmenu.h"
void gui_create_form_select_menu(struct gui_window *g, struct form_control *control)
{
}
#endif

View File

@ -16,19 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AMIGA_CONTEXT_MENU_H
#define AMIGA_CONTEXT_MENU_H
#ifndef AMIGA_SELECTMENU_H
#define AMIGA_SELECTMENU_H
struct tree;
struct gui_window;
struct gui_window_2;
struct form_control;
void ami_context_menu_init(void);
void ami_context_menu_free(void);
BOOL ami_context_menu_mouse_trap(struct gui_window_2 *gwin, BOOL trap);
void ami_context_menu_show(struct gui_window_2 *gwin, int x, int y);
void gui_create_form_select_menu(struct gui_window *g, struct form_control *control);
#endif

View File

@ -26,6 +26,7 @@
#define _NETSURF_RENDER_FORM_H_
struct form_control;
struct rect;
/** Option in a select. */
struct form_option {