2014-05-19 20:05:28 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Ole Loots <ole@monochrom.net>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2014-05-09 13:15:42 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
#include <stdlib.h>
|
2013-11-25 01:04:03 +04:00
|
|
|
#include <cflib.h>
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
#include "utils/log.h"
|
2016-04-20 12:43:58 +03:00
|
|
|
#include "utils/nsurl.h"
|
2014-02-03 22:31:53 +04:00
|
|
|
#include "utils/messages.h"
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2016-05-30 19:32:57 +03:00
|
|
|
#include "netsurf/browser_window.h"
|
2014-02-03 22:31:53 +04:00
|
|
|
#include "desktop/save_complete.h"
|
2016-04-20 12:43:58 +03:00
|
|
|
#include "desktop/textinput.h"
|
2014-10-17 13:48:50 +04:00
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "atari/res/netsurf.rsh"
|
|
|
|
#include "atari/gemtk/gemtk.h"
|
|
|
|
#include "atari/deskmenu.h"
|
|
|
|
#include "atari/hotlist.h"
|
|
|
|
#include "atari/history.h"
|
2013-09-21 07:29:04 +04:00
|
|
|
#include "atari/cookies.h"
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "atari/toolbar.h"
|
|
|
|
#include "atari/settings.h"
|
|
|
|
#include "atari/misc.h"
|
|
|
|
#include "atari/gui.h"
|
2012-12-06 04:38:49 +04:00
|
|
|
#include "atari/findfile.h"
|
2013-09-26 03:24:49 +04:00
|
|
|
#include "atari/about.h"
|
2013-12-04 04:36:20 +04:00
|
|
|
#include "atari/plot/plot.h"
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "atari/rootwin.h"
|
|
|
|
|
|
|
|
typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
struct s_accelerator
|
|
|
|
{
|
|
|
|
char ascii; /* either ascii or */
|
|
|
|
long keycode; /* normalised keycode is valid */
|
|
|
|
short mod; /* shift / ctrl etc */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct s_menu_item_evnt {
|
|
|
|
short title; /* to which menu this item belongs */
|
|
|
|
short rid; /* resource ID */
|
|
|
|
menu_evnt_func menu_func; /* click handler */
|
|
|
|
struct s_accelerator accel; /* accelerator info */
|
|
|
|
char * menustr;
|
2012-11-19 02:22:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void register_menu_str(struct s_menu_item_evnt * mi);
|
2013-01-07 23:04:44 +04:00
|
|
|
//static void __CDECL evnt_menu(WINDOW * win, short buff[8]);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
extern void *h_gem_rsrc;
|
|
|
|
extern bool html_redraw_debug;
|
|
|
|
extern struct gui_window * input_window;
|
|
|
|
extern char options[PATH_MAX];
|
|
|
|
extern const char * option_homepage_url;
|
2014-05-19 20:05:28 +04:00
|
|
|
extern int option_window_width;
|
2012-11-19 02:22:43 +04:00
|
|
|
extern int option_window_height;
|
|
|
|
extern int option_window_x;
|
|
|
|
extern int option_window_y;
|
|
|
|
|
|
|
|
static OBJECT * h_gem_menu;
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
|
|
|
|
/* Zero based resource tree ids: */
|
|
|
|
#define T_ABOUT 0
|
|
|
|
#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
|
|
|
|
#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
|
|
|
|
#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
|
|
|
|
#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
|
|
|
|
#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
|
|
|
|
#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
|
|
|
|
/* Count of the above defines: */
|
2012-11-19 02:22:43 +04:00
|
|
|
#define NUM_MENU_TITLES 7
|
|
|
|
|
|
|
|
|
|
|
|
static void __CDECL menu_about(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_new_win(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_open_url(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_open_file(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_close_win(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_save_page(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_quit(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_cut(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_copy(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_paste(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_find(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_choices(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_stop(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_reload(short item, short title, void *data);
|
2013-12-04 04:36:20 +04:00
|
|
|
static void __CDECL menu_dec_scale(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_inc_scale(short item, short title, void *data);
|
2012-11-19 02:22:43 +04:00
|
|
|
static void __CDECL menu_toolbars(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_savewin(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_debug_render(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_fg_images(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_bg_images(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_back(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_forward(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_home(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_lhistory(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_ghistory(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_add_bookmark(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_bookmarks(short item, short title, void *data);
|
2013-09-21 07:29:04 +04:00
|
|
|
static void __CDECL menu_cookies(short item, short title, void *data);
|
2012-11-19 02:22:43 +04:00
|
|
|
static void __CDECL menu_vlog(short item, short title, void *data);
|
|
|
|
static void __CDECL menu_help_content(short item, short title, void *data);
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
struct s_menu_item_evnt menu_evnt_tbl[] =
|
|
|
|
{
|
|
|
|
{T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
|
|
|
|
{T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
|
|
|
|
{T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
|
|
|
|
{T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
|
|
|
|
{T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
|
|
|
|
{T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
|
|
|
|
{T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
|
|
|
|
{T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
|
|
|
|
{T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
|
|
|
|
{T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
|
|
|
|
{T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
|
2013-12-04 04:36:20 +04:00
|
|
|
{T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
|
2013-12-13 03:26:00 +04:00
|
|
|
{T_VIEW, MAINMENU_INC_SCALE, menu_inc_scale, {'+',0,K_CTRL}, NULL},
|
2015-05-28 11:11:32 +03:00
|
|
|
{T_VIEW, MAINMENU_DEC_SCALE, menu_dec_scale, {'-',0,K_CTRL}, NULL},
|
2014-05-19 20:05:28 +04:00
|
|
|
{T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
|
|
|
|
{T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
|
2012-11-19 02:22:43 +04:00
|
|
|
{T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
|
|
|
|
{T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
|
2014-05-19 20:05:28 +04:00
|
|
|
{T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
|
|
|
|
{T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
|
|
|
|
{T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
|
|
|
|
{T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
|
|
|
|
{T_NAV, MAINMENU_M_HOME, menu_home, {0,0,0}, NULL},
|
|
|
|
{T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
|
|
|
|
{T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
|
|
|
|
{T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
|
2013-09-21 07:29:04 +04:00
|
|
|
{T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
|
2014-05-19 20:05:28 +04:00
|
|
|
{T_UTIL, MAINMENU_M_COOKIES, menu_cookies, {0,0,0}, NULL},
|
|
|
|
{T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
|
|
|
|
{T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
|
|
|
|
{T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
|
|
|
|
{-1, -1, NULL,{0,0,0}, NULL }
|
2012-11-19 02:22:43 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-07 23:04:44 +04:00
|
|
|
/*
|
2015-05-28 11:11:32 +03:00
|
|
|
static void __CDECL evnt_menu(WINDOW * win, short buff[8])
|
|
|
|
{
|
|
|
|
int title = buff[3];
|
|
|
|
INT16 x,y;
|
|
|
|
char *str;
|
|
|
|
struct gui_window * gw = window_list;
|
|
|
|
int i=0;
|
|
|
|
|
|
|
|
deskmenu_dispatch_item(buff[3], buff[4]);
|
|
|
|
}
|
2013-01-07 23:04:44 +04:00
|
|
|
*/
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
/*
|
2015-05-28 11:11:32 +03:00
|
|
|
Menu item event handlers:
|
2012-11-19 02:22:43 +04:00
|
|
|
*/
|
2014-05-19 20:05:28 +04:00
|
|
|
|
|
|
|
static void __CDECL menu_about(short item, short title, void *data)
|
2013-09-26 03:24:49 +04:00
|
|
|
{
|
2014-05-19 20:05:28 +04:00
|
|
|
/*
|
2015-05-28 11:11:32 +03:00
|
|
|
nsurl *url;
|
|
|
|
nserror error;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2015-05-28 11:11:32 +03:00
|
|
|
strcpy((char*)&buf, "file://");
|
|
|
|
strncat((char*)&buf, (char*)"./doc/README.TXT",
|
|
|
|
PATH_MAX - (strlen("file://")+1) );
|
|
|
|
|
|
|
|
error = nsurl_create(buf, &url);
|
|
|
|
if (error == NSERROR_OK) {
|
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
2016-04-30 13:34:45 +03:00
|
|
|
atari_warn_user(messages_get_errorcode(error), 0);
|
2015-05-28 11:11:32 +03:00
|
|
|
}
|
2013-09-26 03:24:49 +04:00
|
|
|
*/
|
|
|
|
atari_about_show();
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_new_win(short item, short title, void *data)
|
|
|
|
{
|
2013-02-14 22:21:11 +04:00
|
|
|
nsurl *url;
|
|
|
|
nserror error;
|
|
|
|
const char *addr;
|
|
|
|
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2013-04-13 17:34:08 +04:00
|
|
|
|
2013-02-14 22:21:11 +04:00
|
|
|
if (nsoption_charp(homepage_url) != NULL) {
|
|
|
|
addr = nsoption_charp(homepage_url);
|
|
|
|
} else {
|
|
|
|
addr = NETSURF_HOMEPAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create an initial browser window */
|
|
|
|
error = nsurl_create(addr, &url);
|
|
|
|
if (error == NSERROR_OK) {
|
2014-02-10 18:08:45 +04:00
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
2016-04-30 13:34:45 +03:00
|
|
|
atari_warn_user(messages_get_errorcode(error), 0);
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_open_url(short item, short title, void *data)
|
|
|
|
{
|
|
|
|
struct gui_window * gw;
|
|
|
|
struct browser_window * bw ;
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
|
|
|
|
gw = input_window;
|
|
|
|
if( gw == NULL ) {
|
2014-02-10 18:08:45 +04:00
|
|
|
browser_window_create(BW_CREATE_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&bw);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_open_file(short item, short title, void *data)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2014-05-19 20:05:28 +04:00
|
|
|
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
const char * filename = file_select(messages_get("OpenFile"), "");
|
2012-11-19 02:22:43 +04:00
|
|
|
if( filename != NULL ){
|
2013-02-14 22:21:11 +04:00
|
|
|
char * urltxt = local_file_to_url( filename );
|
|
|
|
if( urltxt ){
|
|
|
|
nsurl *url;
|
|
|
|
nserror error;
|
|
|
|
|
|
|
|
error = nsurl_create(urltxt, &url);
|
|
|
|
if (error == NSERROR_OK) {
|
2014-02-10 18:08:45 +04:00
|
|
|
error = browser_window_create(BW_CREATE_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
2013-04-13 17:34:08 +04:00
|
|
|
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
|
|
|
if (error != NSERROR_OK) {
|
2016-04-30 13:34:45 +03:00
|
|
|
atari_warn_user(messages_get_errorcode(error), 0);
|
2013-02-14 22:21:11 +04:00
|
|
|
}
|
|
|
|
free( urltxt );
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
}
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_close_win(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window == NULL )
|
|
|
|
return;
|
|
|
|
gui_window_destroy( input_window );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_save_page(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2012-11-19 02:22:43 +04:00
|
|
|
static bool init = true;
|
|
|
|
bool is_folder=false;
|
|
|
|
const char * path;
|
|
|
|
|
|
|
|
if( !input_window )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( init ){
|
|
|
|
init = false;
|
|
|
|
save_complete_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
// TODO: localize string
|
|
|
|
path = file_select("Select folder", "");
|
|
|
|
if (path)
|
|
|
|
is_folder = is_dir(path);
|
2013-12-21 04:57:16 +04:00
|
|
|
} while ((is_folder == false) && (path != NULL));
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
if( path != NULL ){
|
2014-10-25 18:58:39 +04:00
|
|
|
save_complete(browser_window_get_content(
|
2015-05-28 11:11:32 +03:00
|
|
|
input_window->browser->bw), path, NULL);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2014-05-19 20:05:28 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_quit(short item, short title, void *data)
|
|
|
|
{
|
|
|
|
short buff[8];
|
|
|
|
memset( &buff, 0, sizeof(short)*8 );
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
gemtk_wm_send_msg(NULL, AP_TERM, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_cut(short item, short title, void *data)
|
|
|
|
{
|
|
|
|
if( input_window != NULL )
|
2015-03-27 12:36:19 +03:00
|
|
|
browser_window_key_press( input_window->browser->bw, NS_KEY_CUT_SELECTION);
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_copy(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window != NULL )
|
2015-03-27 12:36:19 +03:00
|
|
|
browser_window_key_press( input_window->browser->bw, NS_KEY_COPY_SELECTION);
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_paste(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window != NULL )
|
2015-03-27 12:36:19 +03:00
|
|
|
browser_window_key_press( input_window->browser->bw, NS_KEY_PASTE);
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_find(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2013-01-31 22:22:35 +04:00
|
|
|
if (input_window != NULL) {
|
|
|
|
if (input_window->search) {
|
|
|
|
window_close_search(input_window->root);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window_open_search(input_window->root, true);
|
|
|
|
}
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_choices(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
open_settings();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_stop(short item, short title, void *data)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window == NULL )
|
2012-11-27 05:12:09 +04:00
|
|
|
return;
|
|
|
|
|
2015-05-28 11:11:32 +03:00
|
|
|
assert(input_window && input_window->root);
|
2014-05-19 20:05:28 +04:00
|
|
|
toolbar_stop_click(input_window->root->toolbar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_reload(short item, short title, void *data)
|
|
|
|
{
|
|
|
|
if(input_window == NULL)
|
|
|
|
return;
|
|
|
|
toolbar_reload_click(input_window->root->toolbar);
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2013-12-04 04:36:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
static void __CDECL menu_inc_scale(short item, short title, void *data)
|
2013-12-13 03:26:00 +04:00
|
|
|
{
|
2014-05-19 20:05:28 +04:00
|
|
|
if(input_window == NULL)
|
|
|
|
return;
|
2013-12-13 03:26:00 +04:00
|
|
|
|
2014-07-06 14:01:39 +04:00
|
|
|
browser_window_set_scale(input_window->browser->bw,
|
2015-05-28 11:11:32 +03:00
|
|
|
browser_window_get_scale(input_window->browser->bw) + 0.25,
|
|
|
|
true);
|
2013-12-04 04:36:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
static void __CDECL menu_dec_scale(short item, short title, void *data)
|
2013-12-13 03:26:00 +04:00
|
|
|
{
|
2014-05-19 20:05:28 +04:00
|
|
|
if(input_window == NULL)
|
2013-12-22 07:52:18 +04:00
|
|
|
return;
|
|
|
|
|
2014-07-06 14:01:39 +04:00
|
|
|
browser_window_set_scale(input_window->browser->bw,
|
2015-05-28 11:11:32 +03:00
|
|
|
browser_window_get_scale(input_window->browser->bw) - 0.25,
|
|
|
|
true);
|
2013-12-04 04:36:20 +04:00
|
|
|
}
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
static void __CDECL menu_toolbars(short item, short title, void *data)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
2014-05-19 20:05:28 +04:00
|
|
|
static int state = 0;
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2012-11-19 02:22:43 +04:00
|
|
|
if( input_window != null && input_window->root->toolbar != null ){
|
|
|
|
state = !state;
|
2012-11-27 05:12:09 +04:00
|
|
|
// TODO: implement toolbar hide
|
|
|
|
//toolbar_hide(input_window->root->toolbar, state );
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_savewin(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2012-11-19 02:22:43 +04:00
|
|
|
if (input_window && input_window->browser) {
|
|
|
|
GRECT rect;
|
2013-01-22 05:33:27 +04:00
|
|
|
wind_get_grect(gemtk_wm_get_handle(input_window->root->win), WF_CURRXYWH,
|
2015-05-28 11:11:32 +03:00
|
|
|
&rect);
|
2012-11-19 02:22:43 +04:00
|
|
|
option_window_width = rect.g_w;
|
|
|
|
option_window_height = rect.g_h;
|
|
|
|
option_window_x = rect.g_x;
|
|
|
|
option_window_y = rect.g_y;
|
|
|
|
nsoption_set_int(window_width, rect.g_w);
|
|
|
|
nsoption_set_int(window_height, rect.g_h);
|
|
|
|
nsoption_set_int(window_x, rect.g_x);
|
|
|
|
nsoption_set_int(window_y, rect.g_y);
|
2013-05-28 19:44:46 +04:00
|
|
|
nsoption_write((const char*)&options, NULL, NULL);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
2014-05-19 20:05:28 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_debug_render(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
html_redraw_debug = !html_redraw_debug;
|
|
|
|
if( input_window != NULL ) {
|
2012-11-19 02:22:43 +04:00
|
|
|
if ( input_window->browser != NULL
|
2015-05-28 11:11:32 +03:00
|
|
|
&& input_window->browser->bw != NULL) {
|
2013-01-03 04:22:38 +04:00
|
|
|
GRECT rect;
|
2014-05-19 20:05:28 +04:00
|
|
|
window_get_grect(input_window->root, BROWSER_AREA_CONTENT, &rect);
|
2012-11-19 02:22:43 +04:00
|
|
|
browser_window_reformat(input_window->browser->bw, false,
|
2015-05-28 11:11:32 +03:00
|
|
|
rect.g_w, rect.g_h );
|
2012-12-03 03:03:29 +04:00
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_DEBUG_RENDER,
|
2015-05-28 11:11:32 +03:00
|
|
|
(html_redraw_debug) ? 1 : 0);
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
static void __CDECL menu_fg_images(short item, short title, void *data)
|
|
|
|
{
|
2012-11-19 02:22:43 +04:00
|
|
|
nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
|
2012-12-03 03:03:29 +04:00
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_FG_IMAGES,
|
2015-05-28 11:11:32 +03:00
|
|
|
(nsoption_bool(foreground_images)) ? 1 : 0);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
static void __CDECL menu_bg_images(short item, short title, void *data)
|
|
|
|
{
|
2012-11-19 02:22:43 +04:00
|
|
|
nsoption_set_bool(background_images, !nsoption_bool(background_images));
|
2012-12-03 03:03:29 +04:00
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_BG_IMAGES,
|
2015-05-28 11:11:32 +03:00
|
|
|
(nsoption_bool(background_images)) ? 1 : 0);
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_back(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window == NULL )
|
|
|
|
return;
|
|
|
|
toolbar_back_click(input_window->root->toolbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_forward(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window == NULL )
|
|
|
|
return;
|
|
|
|
toolbar_forward_click(input_window->root->toolbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_home(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window == NULL )
|
|
|
|
return;
|
|
|
|
toolbar_home_click(input_window->root->toolbar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_lhistory(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if( input_window == NULL )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_ghistory(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
atari_global_history_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_add_bookmark(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
if (input_window) {
|
2014-10-25 18:58:39 +04:00
|
|
|
if( browser_window_has_content(input_window->browser->bw) ){
|
2014-05-19 20:05:28 +04:00
|
|
|
atari_hotlist_add_page(
|
2014-10-25 18:58:39 +04:00
|
|
|
nsurl_access(browser_window_get_url(input_window->browser->bw)),
|
2014-05-19 20:05:28 +04:00
|
|
|
NULL
|
2015-05-28 11:11:32 +03:00
|
|
|
);
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_bookmarks(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
atari_hotlist_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_cookies(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2014-05-19 20:05:28 +04:00
|
|
|
atari_cookie_manager_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_vlog(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2012-12-03 03:00:13 +04:00
|
|
|
verbose_log = !verbose_log;
|
2014-05-19 20:05:28 +04:00
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __CDECL menu_help_content(short item, short title, void *data)
|
|
|
|
{
|
2015-05-28 19:06:18 +03:00
|
|
|
LOG("%s", __FUNCTION__);
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-05-28 11:11:32 +03:00
|
|
|
Public deskmenu interface:
|
2012-11-19 02:22:43 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-01-15 04:54:18 +04:00
|
|
|
/*
|
2015-05-28 11:11:32 +03:00
|
|
|
Parse encoded menu key shortcut
|
|
|
|
|
|
|
|
The format is:
|
|
|
|
|
|
|
|
"[" - marks start of the shortcut
|
|
|
|
"@,^,<" - If the keyshortcut is only valid
|
|
|
|
with modifier keys, one of these characters must directly
|
|
|
|
follow the start mark.
|
|
|
|
Meaning:
|
|
|
|
@ -> Alternate
|
|
|
|
^ -> Control
|
|
|
|
"#" - keycode or ascii character.
|
|
|
|
The value is handled as keycode if the character value
|
|
|
|
is <= 28 ( Atari chracter table )
|
|
|
|
or if it is interpreted as function key string.
|
|
|
|
(strings: F1 - F10)
|
2013-01-15 04:54:18 +04:00
|
|
|
|
|
|
|
*/
|
|
|
|
static void register_menu_str( struct s_menu_item_evnt * mi )
|
|
|
|
{
|
|
|
|
assert(h_gem_menu != NULL);
|
|
|
|
|
|
|
|
struct s_accelerator * accel = &mi->accel;
|
|
|
|
int i, l=0, x=-1;
|
|
|
|
char str[255];
|
2013-11-25 01:04:03 +04:00
|
|
|
bool is_std_shortcut = false;
|
2013-01-15 04:54:18 +04:00
|
|
|
|
2013-01-17 04:18:27 +04:00
|
|
|
get_string(h_gem_menu, mi->rid, str);
|
2013-01-15 04:54:18 +04:00
|
|
|
|
|
|
|
i = l = strlen(str);
|
|
|
|
while (i > 2) {
|
2015-05-28 11:11:32 +03:00
|
|
|
if ((strncmp(" ", &str[i], 2) == 0) && (strlen(&str[i]) > 2)) {
|
|
|
|
// "Standard" Keyboard Shortcut Element found:
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Standard Keyboard Shortcut: \"%s\"\n", &str[i]);
|
2015-05-28 11:11:32 +03:00
|
|
|
x = i+2;
|
|
|
|
is_std_shortcut = true;
|
|
|
|
break;
|
|
|
|
}
|
2013-11-25 01:04:03 +04:00
|
|
|
|
2013-01-15 04:54:18 +04:00
|
|
|
if( str[i] == '['){
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Keyboard Shortcut: \"%s\"\n", &str[i]);
|
2015-05-28 11:11:32 +03:00
|
|
|
// "Custom" Keyboard Shortcut Element found (identified by [):
|
2013-01-15 04:54:18 +04:00
|
|
|
x = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i--;
|
|
|
|
}
|
2013-11-25 01:04:03 +04:00
|
|
|
|
|
|
|
// Parse keyboard shortcut value:
|
2013-01-15 04:54:18 +04:00
|
|
|
if( x > -1 ){
|
2013-11-25 01:04:03 +04:00
|
|
|
|
2015-05-28 11:11:32 +03:00
|
|
|
if (is_std_shortcut == false) {
|
|
|
|
// create a new menu string to hide the "[" mark:
|
|
|
|
mi->menustr = malloc( l+1 );
|
|
|
|
strcpy(mi->menustr, str);
|
|
|
|
mi->menustr[x]=' ';
|
|
|
|
x++;
|
|
|
|
}
|
2013-11-25 01:04:03 +04:00
|
|
|
|
2015-05-28 11:11:32 +03:00
|
|
|
// find & register modifiers:
|
2013-11-25 01:04:03 +04:00
|
|
|
if (str[x] == '@') {
|
2013-01-15 04:54:18 +04:00
|
|
|
accel->mod = K_ALT;
|
2013-11-25 01:04:03 +04:00
|
|
|
if (is_std_shortcut == false) {
|
2015-05-28 11:11:32 +03:00
|
|
|
// only modify menu items when it is malloc'd:
|
|
|
|
mi->menustr[x] = 0x07;
|
2013-11-25 01:04:03 +04:00
|
|
|
}
|
2013-01-15 04:54:18 +04:00
|
|
|
x++;
|
|
|
|
}
|
2013-11-25 01:04:03 +04:00
|
|
|
else if (str[x] == '^') {
|
2013-01-15 04:54:18 +04:00
|
|
|
accel->mod = K_CTRL;
|
|
|
|
x++;
|
|
|
|
}
|
2013-11-25 01:04:03 +04:00
|
|
|
else if (str[x] == 0x01) { // the arrow up chracter (atari-st encoding)
|
2015-05-28 11:11:32 +03:00
|
|
|
accel->mod = K_LSHIFT;
|
|
|
|
x++;
|
2013-11-25 01:04:03 +04:00
|
|
|
}
|
|
|
|
|
2015-05-28 11:11:32 +03:00
|
|
|
// find keycodes / chracters:
|
2013-01-15 04:54:18 +04:00
|
|
|
if( str[x] <= 28 ){
|
|
|
|
// parse symbol
|
|
|
|
switch( str[x] ){
|
2015-05-28 11:11:32 +03:00
|
|
|
case 0x03:
|
|
|
|
accel->keycode = NK_RIGHT;
|
2013-01-15 04:54:18 +04:00
|
|
|
break;
|
2015-05-28 11:11:32 +03:00
|
|
|
case 0x04:
|
|
|
|
accel->keycode = NK_LEFT;
|
2013-01-15 04:54:18 +04:00
|
|
|
break;
|
2015-05-28 11:11:32 +03:00
|
|
|
case 0x1B:
|
|
|
|
accel->keycode = NK_ESC;
|
2013-01-15 04:54:18 +04:00
|
|
|
break;
|
2015-05-28 11:11:32 +03:00
|
|
|
default:
|
2013-01-15 04:54:18 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
|
|
|
|
// parse function key
|
|
|
|
short fkey = atoi( &str[x+1] );
|
|
|
|
if( (fkey >= 0) && (fkey <= 10) ){
|
|
|
|
accel->keycode = NK_F1 - 1 + fkey;
|
|
|
|
}
|
2013-11-25 01:04:03 +04:00
|
|
|
}
|
|
|
|
else if (strncmp(&str[x], "Home", 4) == 0) {
|
2015-05-28 11:11:32 +03:00
|
|
|
accel->keycode = NK_CLRHOME;
|
2013-11-25 01:04:03 +04:00
|
|
|
}
|
|
|
|
else if (strncmp(&str[x], "Undo", 4) == 0) {
|
2015-05-28 11:11:32 +03:00
|
|
|
accel->keycode = NK_UNDO;
|
2013-11-25 01:04:03 +04:00
|
|
|
}
|
|
|
|
else if (strncmp(&str[x], "Help", 4) == 0) {
|
2015-05-28 11:11:32 +03:00
|
|
|
accel->keycode = NK_HELP;
|
2013-11-25 01:04:03 +04:00
|
|
|
}
|
|
|
|
else {
|
2013-01-15 04:54:18 +04:00
|
|
|
accel->ascii = str[x];
|
|
|
|
}
|
|
|
|
}
|
2013-11-25 01:04:03 +04:00
|
|
|
|
2016-04-20 12:43:58 +03:00
|
|
|
LOG("Registered keyboard shortcut for \"%s\" => mod: %d, ""keycode: %ld, ascii: %c\n",
|
|
|
|
str, accel->mod, accel->keycode, accel->ascii);
|
2013-01-15 04:54:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-19 02:22:43 +04:00
|
|
|
/**
|
2015-05-28 11:11:32 +03:00
|
|
|
* Setup & display an desktop menu.
|
|
|
|
*/
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
void deskmenu_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
h_gem_menu = gemtk_obj_get_tree(MAINMENU);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2013-01-15 04:54:18 +04:00
|
|
|
|
|
|
|
/* Install menu: */
|
|
|
|
menu_bar(h_gem_menu, MENU_INSTALL);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
/* parse and update menu items: */
|
|
|
|
i = 0;
|
2013-12-04 04:36:20 +04:00
|
|
|
while (menu_evnt_tbl[i].rid != -1) {
|
2015-05-28 11:11:32 +03:00
|
|
|
if(menu_evnt_tbl[i].rid > 0 && menu_evnt_tbl[i].title > 0){
|
|
|
|
register_menu_str( &menu_evnt_tbl[i] );
|
|
|
|
/* Update menu string if not null: */
|
|
|
|
if( menu_evnt_tbl[i].menustr != NULL ){
|
|
|
|
menu_text(h_gem_menu, menu_evnt_tbl[i].rid,
|
|
|
|
menu_evnt_tbl[i].menustr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
deskmenu_update();
|
|
|
|
/* Redraw menu: */
|
|
|
|
menu_bar(h_gem_menu, MENU_UPDATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-28 11:11:32 +03:00
|
|
|
* Uninstall the desktop menu
|
|
|
|
*/
|
2012-11-19 02:22:43 +04:00
|
|
|
void deskmenu_destroy(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Remove menu from desktop: */
|
2014-05-19 20:05:28 +04:00
|
|
|
menu_bar(h_gem_menu, MENU_REMOVE);
|
2012-11-19 02:22:43 +04:00
|
|
|
|
|
|
|
/* Free modified menu titles: */
|
2014-05-19 20:05:28 +04:00
|
|
|
i=0;
|
|
|
|
while(menu_evnt_tbl[i].rid != -1) {
|
|
|
|
if( menu_evnt_tbl[i].menustr != NULL )
|
|
|
|
free(menu_evnt_tbl[i].menustr);
|
|
|
|
i++;
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-28 11:11:32 +03:00
|
|
|
* Return the deskmenu AES OBJECT tree
|
|
|
|
*/
|
2012-11-19 02:22:43 +04:00
|
|
|
OBJECT * deskmenu_get_obj_tree(void)
|
|
|
|
{
|
|
|
|
return(h_gem_menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-28 11:11:32 +03:00
|
|
|
* Handle an menu item event
|
|
|
|
*/
|
2012-11-19 02:22:43 +04:00
|
|
|
int deskmenu_dispatch_item(short title, short item)
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
int retval = 0;
|
|
|
|
OBJECT * menu_root = deskmenu_get_obj_tree();
|
|
|
|
|
2015-05-28 11:11:32 +03:00
|
|
|
menu_tnormal(menu_root, item, 1);
|
2012-11-19 02:22:43 +04:00
|
|
|
menu_tnormal(menu_root, title, 1);
|
|
|
|
menu_bar(menu_root, 1);
|
|
|
|
|
|
|
|
// legacy code, is this sensible?:
|
|
|
|
/*
|
2015-05-28 11:11:32 +03:00
|
|
|
while( gw ) {
|
|
|
|
window_set_focus( gw, WIDGET_NONE, NULL );
|
|
|
|
gw = gw->next;
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
while (menu_evnt_tbl[i].rid != -1) {
|
2015-05-28 11:11:32 +03:00
|
|
|
if (menu_evnt_tbl[i].rid == item) {
|
2014-05-19 20:05:28 +04:00
|
|
|
if (menu_evnt_tbl[i].menu_func != NULL) {
|
2012-11-19 02:22:43 +04:00
|
|
|
menu_evnt_tbl[i].menu_func(item, title, NULL);
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return(retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-28 11:11:32 +03:00
|
|
|
* Handle an keypress (check for accelerator)
|
|
|
|
*/
|
2012-11-19 02:22:43 +04:00
|
|
|
int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
|
2015-05-28 11:11:32 +03:00
|
|
|
unsigned short nkc)
|
2012-11-19 02:22:43 +04:00
|
|
|
{
|
|
|
|
char sascii;
|
|
|
|
bool done = 0;
|
|
|
|
int i = 0;
|
|
|
|
|
2015-05-28 11:11:32 +03:00
|
|
|
sascii = gemtk_keybd2ascii(kcode, 0);
|
|
|
|
if(sascii >= 'a' && sascii <= 'z'){
|
|
|
|
sascii = gemtk_keybd2ascii(kcode, K_LSHIFT);
|
|
|
|
}
|
2012-11-19 02:22:43 +04:00
|
|
|
|
2014-05-19 20:05:28 +04:00
|
|
|
/* Iterate through the menu function table: */
|
|
|
|
while( menu_evnt_tbl[i].rid != -1 && done == false) {
|
2012-11-19 02:22:43 +04:00
|
|
|
if( kstate == menu_evnt_tbl[i].accel.mod
|
2015-05-28 11:11:32 +03:00
|
|
|
&& menu_evnt_tbl[i].accel.ascii != 0) {
|
2012-11-19 02:22:43 +04:00
|
|
|
if( menu_evnt_tbl[i].accel.ascii == sascii) {
|
2015-05-28 11:11:32 +03:00
|
|
|
if (menu_evnt_tbl[i].title > 0 && menu_evnt_tbl[i].rid > 0) {
|
|
|
|
deskmenu_dispatch_item(menu_evnt_tbl[i].title,
|
|
|
|
menu_evnt_tbl[i].rid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Keyboard shortcut not displayed within menu: */
|
|
|
|
menu_evnt_tbl[i].menu_func(0, 0, NULL);
|
|
|
|
}
|
2014-05-19 20:05:28 +04:00
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* the accel code hides in the keycode: */
|
|
|
|
if( menu_evnt_tbl[i].accel.keycode != 0) {
|
|
|
|
if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
|
2015-05-28 11:11:32 +03:00
|
|
|
kstate == menu_evnt_tbl[i].accel.mod) {
|
|
|
|
if (menu_evnt_tbl[i].title > 0 && menu_evnt_tbl[i].rid > 0) {
|
|
|
|
deskmenu_dispatch_item(menu_evnt_tbl[i].title,
|
|
|
|
menu_evnt_tbl[i].rid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Keyboard shortcut not displayed within menu: */
|
|
|
|
menu_evnt_tbl[i].menu_func(0, 0, NULL);
|
|
|
|
}
|
|
|
|
done = true;
|
|
|
|
break;
|
2014-05-19 20:05:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|
|
|
|
return((done==true) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-28 11:11:32 +03:00
|
|
|
* Refresh the desk menu, reflecting netsurf current state.
|
|
|
|
*/
|
2012-11-19 02:22:43 +04:00
|
|
|
void deskmenu_update(void)
|
|
|
|
{
|
2012-12-03 03:03:29 +04:00
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
|
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_FG_IMAGES,
|
2015-05-28 11:11:32 +03:00
|
|
|
(nsoption_bool(foreground_images)) ? 1 : 0);
|
2012-12-03 03:03:29 +04:00
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_BG_IMAGES,
|
2015-05-28 11:11:32 +03:00
|
|
|
(nsoption_bool(background_images)) ? 1 : 0);
|
|
|
|
menu_icheck(h_gem_menu, MAINMENU_M_VLOG, ((verbose_log == true) ? 1 : 0));
|
2012-11-19 02:22:43 +04:00
|
|
|
}
|