2011-01-06 00:02:22 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2010 <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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
This File provides all the mandatory functions prefixed with gui_
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <windom.h>
|
|
|
|
#include <hubbub/hubbub.h>
|
|
|
|
|
|
|
|
#include "content/urldb.h"
|
|
|
|
#include "content/fetch.h"
|
2011-02-24 01:27:55 +03:00
|
|
|
#include "content/fetchers/resource.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "css/utils.h"
|
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/history_core.h"
|
|
|
|
#include "desktop/plotters.h"
|
|
|
|
#include "desktop/netsurf.h"
|
|
|
|
#include "desktop/401login.h"
|
|
|
|
|
|
|
|
#include "desktop/options.h"
|
|
|
|
#include "desktop/save_complete.h"
|
|
|
|
#include "desktop/selection.h"
|
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/mouse.h"
|
|
|
|
#include "render/html.h"
|
|
|
|
#include "render/font.h"
|
2011-03-21 01:41:29 +03:00
|
|
|
#include "utils/schedule.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "utils/url.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
|
|
|
|
#include "atari/gui.h"
|
|
|
|
#include "atari/misc.h"
|
|
|
|
#include "atari/findfile.h"
|
|
|
|
#include "atari/schedule.h"
|
|
|
|
#include "atari/browser_win.h"
|
|
|
|
#include "atari/browser.h"
|
|
|
|
#include "atari/statusbar.h"
|
|
|
|
#include "atari/toolbar.h"
|
|
|
|
#include "atari/verify_ssl.h"
|
|
|
|
#include "atari/hotlist.h"
|
|
|
|
#include "atari/login.h"
|
|
|
|
#include "atari/global_evnt.h"
|
2011-11-29 03:23:28 +04:00
|
|
|
#include "atari/encoding.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "atari/res/netsurf.rsh"
|
|
|
|
#include "atari/plot.h"
|
|
|
|
#include "atari/clipboard.h"
|
2011-01-31 01:03:19 +03:00
|
|
|
#include "atari/osspec.h"
|
2011-02-12 22:48:58 +03:00
|
|
|
#include "atari/search.h"
|
2011-06-26 00:03:28 +04:00
|
|
|
#include "cflib.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
|
2011-01-22 19:42:32 +03:00
|
|
|
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
|
2011-01-06 00:02:22 +03:00
|
|
|
|
|
|
|
char *tmp_clipboard;
|
|
|
|
struct gui_window *input_window = NULL;
|
|
|
|
struct gui_window *window_list = NULL;
|
|
|
|
void * h_gem_rsrc;
|
2012-01-02 04:02:40 +04:00
|
|
|
OBJECT * h_gem_menu;
|
2011-01-06 00:02:22 +03:00
|
|
|
OBJECT **rsc_trindex;
|
|
|
|
short vdih;
|
|
|
|
short rsc_ntree;
|
2012-01-11 20:45:17 +04:00
|
|
|
long next_poll;
|
2011-12-04 21:18:59 +04:00
|
|
|
bool rendering = false;
|
2012-01-11 20:45:17 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
|
|
|
|
/* Comandline / Options: */
|
|
|
|
int cfg_width;
|
|
|
|
int cfg_height;
|
2012-01-11 20:45:17 +04:00
|
|
|
|
2012-01-02 04:02:40 +04:00
|
|
|
/* Defaults to option_homepage_url, commandline options overwrites that value */
|
2011-01-06 00:02:22 +03:00
|
|
|
const char * cfg_homepage_url;
|
2012-01-11 20:45:17 +04:00
|
|
|
|
|
|
|
/* path to choices file: */
|
2011-12-22 02:51:17 +04:00
|
|
|
char options[PATH_MAX];
|
2011-01-31 01:20:55 +03:00
|
|
|
|
2011-04-11 01:52:07 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
void gui_poll(bool active)
|
|
|
|
{
|
|
|
|
short winloc[4];
|
2011-04-11 01:52:07 +04:00
|
|
|
// int timeout; /* timeout in milliseconds */
|
2011-01-06 00:02:22 +03:00
|
|
|
int flags = MU_MESAG | MU_KEYBD | MU_BUTTON ;
|
2011-04-11 01:52:07 +04:00
|
|
|
short mx, my, dummy;
|
|
|
|
short aestop;
|
2012-01-11 20:45:17 +04:00
|
|
|
|
|
|
|
evnt.timer = schedule_run();
|
2011-04-11 01:52:07 +04:00
|
|
|
|
2011-12-04 21:18:59 +04:00
|
|
|
if( active || rendering ) {
|
2012-01-11 20:45:17 +04:00
|
|
|
if( clock() >= next_poll ) {
|
2011-05-25 01:44:20 +04:00
|
|
|
evnt.timer = 0;
|
|
|
|
flags |= MU_TIMER;
|
|
|
|
EvntWindom( flags );
|
2011-12-10 05:06:23 +04:00
|
|
|
next_poll = clock() + (CLOCKS_PER_SEC>>2);
|
2011-05-25 01:44:20 +04:00
|
|
|
}
|
2012-01-11 20:45:17 +04:00
|
|
|
} else {
|
|
|
|
if( input_window != NULL ){
|
2011-12-04 17:05:00 +04:00
|
|
|
wind_get( 0, WF_TOP, &aestop, &winloc[1], &winloc[2], &winloc[3]);
|
2012-01-11 20:45:17 +04:00
|
|
|
if( winloc[1] == _AESapid ){
|
|
|
|
/* only check for mouse move when netsurf is on top: */
|
|
|
|
// move that into m1 event handler
|
|
|
|
graf_mkstate( &mx, &my, &dummy, &dummy );
|
|
|
|
flags |= MU_M1;
|
|
|
|
evnt.m1_flag = MO_LEAVE;
|
|
|
|
evnt.m1_w = evnt.m1_h = 1;
|
|
|
|
evnt.m1_x = mx;
|
|
|
|
evnt.m1_y = my;
|
2011-12-04 17:05:00 +04:00
|
|
|
}
|
2012-01-11 20:45:17 +04:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
flags |= MU_TIMER;
|
2012-01-11 20:45:17 +04:00
|
|
|
EvntWindom( flags );
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
2011-05-25 01:44:20 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
struct gui_window * g;
|
2011-01-22 19:42:32 +03:00
|
|
|
for( g = window_list; g != NULL; g=g->next ) {
|
2011-02-02 00:21:16 +03:00
|
|
|
if( browser_redraw_required( g ) ){
|
2011-01-06 00:02:22 +03:00
|
|
|
browser_redraw( g );
|
2012-01-11 20:45:17 +04:00
|
|
|
}
|
|
|
|
if( g->root->toolbar ){
|
|
|
|
if(g->root->toolbar->url.redraw ){
|
|
|
|
tb_url_redraw( g );
|
|
|
|
}
|
2011-02-02 00:21:16 +03:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
2011-04-24 00:09:24 +04:00
|
|
|
if( evnt.timer != 0 && !active ){
|
2012-01-11 20:45:17 +04:00
|
|
|
/* this suits for stuff with lower priority */
|
2011-11-29 03:23:28 +04:00
|
|
|
/* TBD: really be spare on redraws??? */
|
2011-09-21 00:09:42 +04:00
|
|
|
atari_treeview_redraw( hl.tv );
|
2011-04-24 00:09:24 +04:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct gui_window *
|
|
|
|
gui_create_browser_window(struct browser_window *bw,
|
|
|
|
struct browser_window *clone,
|
|
|
|
bool new_tab)
|
|
|
|
{
|
|
|
|
struct gui_window *gw=NULL;
|
2011-09-19 22:38:48 +04:00
|
|
|
LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
|
2011-09-05 16:27:06 +04:00
|
|
|
(int)new_tab
|
2011-01-06 00:02:22 +03:00
|
|
|
));
|
|
|
|
|
|
|
|
gw = malloc( sizeof(struct gui_window) );
|
|
|
|
if (gw == NULL)
|
|
|
|
return NULL;
|
|
|
|
memset( gw, 0, sizeof(struct gui_window) );
|
|
|
|
|
2011-09-05 16:27:06 +04:00
|
|
|
LOG(("new window: %p, bw: %p\n", gw, bw));
|
2011-11-05 19:18:19 +04:00
|
|
|
window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
|
2012-01-11 20:45:17 +04:00
|
|
|
if( gw->root->handle ) {
|
|
|
|
GRECT pos = {
|
|
|
|
app.w/2-(cfg_width/2), (app.h/2)-(cfg_height/2)+16,
|
|
|
|
cfg_width, cfg_height
|
2011-12-01 03:08:21 +04:00
|
|
|
};
|
|
|
|
window_open( gw , pos );
|
2011-09-05 16:27:06 +04:00
|
|
|
/* Recalculate windows browser area now */
|
|
|
|
browser_update_rects( gw );
|
|
|
|
tb_update_buttons( gw );
|
|
|
|
input_window = gw;
|
|
|
|
/* TODO:... this line: placeholder to create a local history widget ... */
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add the window to the window list: */
|
|
|
|
if( window_list == NULL ) {
|
|
|
|
window_list = gw;
|
|
|
|
gw->next = NULL;
|
|
|
|
gw->prev = NULL;
|
|
|
|
} else {
|
|
|
|
struct gui_window * tmp = window_list;
|
|
|
|
while( tmp->next != NULL ) {
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
tmp->next = gw;
|
|
|
|
gw->prev = tmp;
|
|
|
|
gw->next = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return( gw );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_destroy(struct gui_window *w)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
LOG(("%s\n", __FUNCTION__ ));
|
|
|
|
|
|
|
|
input_window = NULL;
|
|
|
|
|
2011-09-05 16:27:06 +04:00
|
|
|
window_destroy( w );
|
2011-07-01 00:20:27 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
/* unlink the window: */
|
|
|
|
if(w->prev != NULL ) {
|
|
|
|
w->prev->next = w->next;
|
|
|
|
} else {
|
|
|
|
window_list = w->next;
|
|
|
|
}
|
|
|
|
if( w->next != NULL ) {
|
|
|
|
w->next->prev = w->prev;
|
2011-10-15 00:56:52 +04:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
free(w);
|
2011-10-15 00:56:52 +04:00
|
|
|
w = NULL;
|
|
|
|
|
|
|
|
w = window_list;
|
2011-09-21 00:09:42 +04:00
|
|
|
while( w != NULL ) {
|
2011-10-15 00:56:52 +04:00
|
|
|
if( w->root ) {
|
2011-09-21 00:09:42 +04:00
|
|
|
input_window = w;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
w = w->next;
|
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
|
|
|
|
bool scaled)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
LGRECT rect;
|
|
|
|
browser_get_rect( w, BR_CONTENT, &rect );
|
|
|
|
*width = rect.g_w;
|
|
|
|
*height = rect.g_h;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_set_title(struct gui_window *gw, const char *title)
|
|
|
|
{
|
2011-08-05 15:02:33 +04:00
|
|
|
int l;
|
|
|
|
char * conv;
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
if (gw == NULL)
|
|
|
|
return;
|
2011-07-01 00:20:27 +04:00
|
|
|
if( gw->root ){
|
2011-08-05 15:02:33 +04:00
|
|
|
l = strlen(title);
|
|
|
|
if( utf8_to_local_encoding(title, l, &conv) == UTF8_CONVERT_OK ){
|
|
|
|
strncpy(gw->root->title, conv, atari_sysinfo.aes_max_win_title_len);
|
|
|
|
free( conv );
|
|
|
|
} else {
|
|
|
|
strncpy(gw->root->title, title, atari_sysinfo.aes_max_win_title_len);
|
|
|
|
}
|
2011-03-21 01:41:29 +03:00
|
|
|
gw->root->title[atari_sysinfo.aes_max_win_title_len] = 0;
|
|
|
|
WindSetStr( gw->root->handle, WF_NAME, gw->root->title );
|
2011-02-26 02:19:06 +03:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set the status bar message
|
|
|
|
*/
|
|
|
|
void gui_window_set_status(struct gui_window *w, const char *text)
|
2012-01-26 02:44:00 +04:00
|
|
|
{
|
|
|
|
static char * msg_loading = NULL;
|
|
|
|
static char * msg_fetch = NULL;
|
|
|
|
|
|
|
|
if( msg_loading == NULL ){
|
|
|
|
msg_loading = messages_get("Loading");
|
|
|
|
msg_fetch = messages_get("Fetch");
|
2012-01-11 20:45:17 +04:00
|
|
|
}
|
2012-01-26 02:44:00 +04:00
|
|
|
|
|
|
|
if( (strncmp(msg_loading, text, 4) == 0)
|
|
|
|
||
|
|
|
|
(strncmp(msg_fetch, text, 4)) == 0 ) {
|
|
|
|
rendering = true;
|
|
|
|
} else {
|
|
|
|
rendering = false;
|
|
|
|
}
|
2012-01-11 20:45:17 +04:00
|
|
|
|
2012-01-02 04:02:40 +04:00
|
|
|
if (w == NULL || text == NULL )
|
|
|
|
return;
|
2012-01-11 20:45:17 +04:00
|
|
|
window_set_stauts( w , (char*)text );
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_redraw_window(struct gui_window *gw)
|
|
|
|
{
|
|
|
|
CMP_BROWSER b;
|
|
|
|
LGRECT rect;
|
|
|
|
if (gw == NULL)
|
|
|
|
return;
|
|
|
|
b = gw->browser;
|
2012-01-11 20:45:17 +04:00
|
|
|
browser_get_rect( gw, BR_CONTENT, &rect );
|
2011-01-06 00:02:22 +03:00
|
|
|
browser_schedule_redraw( gw, 0, 0, rect.g_w, rect.g_h );
|
|
|
|
}
|
|
|
|
|
2011-07-06 16:42:45 +04:00
|
|
|
void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
|
2011-01-06 00:02:22 +03:00
|
|
|
{
|
2011-02-12 22:48:58 +03:00
|
|
|
CMP_BROWSER b;
|
2011-01-06 00:02:22 +03:00
|
|
|
if (gw == NULL)
|
|
|
|
return;
|
|
|
|
b = gw->browser;
|
|
|
|
/* the box values are actually floats */
|
2011-07-06 16:42:45 +04:00
|
|
|
int x0 = rect->x0 - b->scroll.current.x;
|
|
|
|
int y0 = rect->y0 - b->scroll.current.y;
|
2011-02-12 22:48:58 +03:00
|
|
|
int w,h;
|
2011-07-06 16:42:45 +04:00
|
|
|
w = rect->x1 - rect->x0;
|
2012-01-11 20:45:17 +04:00
|
|
|
h = rect->y1 - rect->y0;
|
2011-02-12 22:48:58 +03:00
|
|
|
browser_schedule_redraw_rect( gw, x0, y0, w,h);
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return false;
|
|
|
|
*sx = w->browser->scroll.current.x;
|
|
|
|
*sy = w->browser->scroll.current.y;
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
|
|
|
|
{
|
|
|
|
if ((w == NULL) ||
|
|
|
|
(w->browser->bw == NULL) ||
|
|
|
|
(w->browser->bw->current_content == NULL))
|
|
|
|
return;
|
|
|
|
if( sx != 0 ) {
|
|
|
|
if( sx < 0 ) {
|
|
|
|
browser_scroll(w, WA_LFLINE, abs(sx), true );
|
|
|
|
} else {
|
|
|
|
browser_scroll(w, WA_RTLINE, abs(sx), true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( sy != 0 ) {
|
|
|
|
if( sy < 0) {
|
|
|
|
browser_scroll(w, WA_UPLINE, abs(sy), true );
|
|
|
|
} else {
|
|
|
|
browser_scroll(w, WA_DNLINE, abs(sy), true );
|
|
|
|
}
|
|
|
|
}
|
2011-09-19 22:38:48 +04:00
|
|
|
return;
|
2011-01-06 00:02:22 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
|
|
|
|
{
|
|
|
|
LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
|
2012-01-11 20:45:17 +04:00
|
|
|
gui_window_set_scroll(w,x0,y0);
|
2011-02-12 22:48:58 +03:00
|
|
|
browser_schedule_redraw_rect( w, 0, 0, x1-x0,y1-y0);
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* It seems this method is called when content size got adjusted,
|
|
|
|
so that we can adjust scroll info. We also have to call it when tab
|
|
|
|
change occurs.
|
|
|
|
*/
|
|
|
|
void gui_window_update_extent(struct gui_window *gw)
|
|
|
|
{
|
|
|
|
int oldx, oldy;
|
|
|
|
oldx = gw->browser->scroll.current.x;
|
|
|
|
oldy = gw->browser->scroll.current.y;
|
|
|
|
if( gw->browser->bw->current_content != NULL ) {
|
2011-09-19 22:38:48 +04:00
|
|
|
browser_set_content_size( gw,
|
2011-03-21 01:41:29 +03:00
|
|
|
content_get_width(gw->browser->bw->current_content),
|
|
|
|
content_get_height(gw->browser->bw->current_content)
|
2011-01-06 00:02:22 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gui_clear_selection(struct gui_window *g)
|
|
|
|
{
|
2011-09-19 22:38:48 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set the pointer shape
|
|
|
|
*/
|
|
|
|
void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
switch (shape) {
|
|
|
|
case GUI_POINTER_POINT: /* link */
|
|
|
|
gem_set_cursor(&gem_cursors.hand);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_MENU:
|
|
|
|
gem_set_cursor(&gem_cursors.menu);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_CARET: /* input */
|
|
|
|
gem_set_cursor(&gem_cursors.ibeam);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_CROSS:
|
|
|
|
gem_set_cursor(&gem_cursors.cross);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_MOVE:
|
|
|
|
gem_set_cursor(&gem_cursors.sizeall);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_RIGHT:
|
|
|
|
case GUI_POINTER_LEFT:
|
|
|
|
gem_set_cursor(&gem_cursors.sizewe);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_UP:
|
|
|
|
case GUI_POINTER_DOWN:
|
|
|
|
gem_set_cursor(&gem_cursors.sizens);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_RU:
|
|
|
|
case GUI_POINTER_LD:
|
|
|
|
gem_set_cursor(&gem_cursors.sizenesw);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_RD:
|
|
|
|
case GUI_POINTER_LU:
|
|
|
|
gem_set_cursor(&gem_cursors.sizenwse);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_WAIT:
|
|
|
|
gem_set_cursor(&gem_cursors.wait);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_PROGRESS:
|
|
|
|
gem_set_cursor(&gem_cursors.appstarting);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_NO_DROP:
|
|
|
|
gem_set_cursor(&gem_cursors.nodrop);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_NOT_ALLOWED:
|
|
|
|
gem_set_cursor(&gem_cursors.deny);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GUI_POINTER_HELP:
|
|
|
|
gem_set_cursor(&gem_cursors.help);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gem_set_cursor(&gem_cursors.arrow);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_hide_pointer(struct gui_window *w)
|
|
|
|
{
|
|
|
|
TODO();
|
|
|
|
}
|
|
|
|
|
2011-02-12 22:48:58 +03:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
void gui_window_set_url(struct gui_window *w, const char *url)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
|
|
|
tb_url_set(w, (char*)url );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void throbber_advance( void * data )
|
|
|
|
{
|
|
|
|
LGRECT work;
|
|
|
|
struct gui_window * gw = (struct gui_window *)data;
|
2011-02-02 00:21:16 +03:00
|
|
|
if( gw->root == NULL )
|
|
|
|
return;
|
2011-01-22 19:42:32 +03:00
|
|
|
if( gw->root->toolbar == NULL )
|
|
|
|
return;
|
2011-01-06 00:02:22 +03:00
|
|
|
if( gw->root->toolbar->throbber.running == false )
|
|
|
|
return;
|
|
|
|
mt_CompGetLGrect(&app, gw->root->toolbar->throbber.comp,
|
|
|
|
WF_WORKXYWH, &work);
|
|
|
|
gw->root->toolbar->throbber.index++;
|
|
|
|
if( gw->root->toolbar->throbber.index > gw->root->toolbar->throbber.max_index )
|
2011-02-02 00:21:16 +03:00
|
|
|
gw->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
|
2011-01-06 00:02:22 +03:00
|
|
|
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
|
|
|
|
work.g_x, work.g_y, work.g_w, work.g_h );
|
2011-12-10 05:06:23 +04:00
|
|
|
schedule(100, throbber_advance, gw );
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_start_throbber(struct gui_window *w)
|
|
|
|
{
|
|
|
|
LGRECT work;
|
|
|
|
if (w == NULL)
|
2012-01-11 20:45:17 +04:00
|
|
|
return;
|
|
|
|
if( w->root->toolbar->throbber.running == true )
|
2011-01-06 00:02:22 +03:00
|
|
|
return;
|
|
|
|
mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
|
|
|
|
WF_WORKXYWH, &work);
|
|
|
|
w->root->toolbar->throbber.running = true;
|
2011-02-02 00:21:16 +03:00
|
|
|
w->root->toolbar->throbber.index = THROBBER_MIN_INDEX;
|
2011-12-15 01:23:30 +04:00
|
|
|
schedule(100, throbber_advance, w );
|
2011-01-06 00:02:22 +03:00
|
|
|
ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
|
|
|
|
work.g_x, work.g_y, work.g_w, work.g_h );
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_stop_throbber(struct gui_window *w)
|
|
|
|
{
|
|
|
|
LGRECT work;
|
|
|
|
if (w == NULL)
|
2012-01-11 20:45:17 +04:00
|
|
|
return;
|
|
|
|
if( w->root->toolbar->throbber.running == false )
|
|
|
|
return;
|
|
|
|
|
|
|
|
schedule_remove(throbber_advance, w);
|
2011-12-15 01:23:30 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
mt_CompGetLGrect(&app, w->root->toolbar->throbber.comp,
|
|
|
|
WF_WORKXYWH, &work);
|
|
|
|
w->root->toolbar->throbber.running = false;
|
|
|
|
ApplWrite( _AESapid, WM_REDRAW, w->root->handle->handle,
|
|
|
|
work.g_x, work.g_y, work.g_w, work.g_h );
|
|
|
|
}
|
|
|
|
|
2012-01-11 20:45:17 +04:00
|
|
|
/* Place caret in window */
|
2011-01-06 00:02:22 +03:00
|
|
|
void gui_window_place_caret(struct gui_window *w, int x, int y, int height)
|
|
|
|
{
|
|
|
|
if (w == NULL)
|
|
|
|
return;
|
2011-09-19 22:38:48 +04:00
|
|
|
if( w->browser->caret.current.g_w > 0 )
|
2011-01-06 00:02:22 +03:00
|
|
|
gui_window_remove_caret( w );
|
|
|
|
w->browser->caret.requested.g_x = x;
|
2012-01-11 20:45:17 +04:00
|
|
|
w->browser->caret.requested.g_y = y;
|
2011-11-29 03:23:28 +04:00
|
|
|
w->browser->caret.requested.g_w = 1;
|
2011-01-06 00:02:22 +03:00
|
|
|
w->browser->caret.requested.g_h = height;
|
|
|
|
w->browser->caret.redraw = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clear window caret
|
2012-01-11 20:45:17 +04:00
|
|
|
*/
|
2011-01-06 00:02:22 +03:00
|
|
|
void
|
|
|
|
gui_window_remove_caret(struct gui_window *w)
|
2012-01-11 20:45:17 +04:00
|
|
|
{
|
2011-01-06 00:02:22 +03:00
|
|
|
if (w == NULL)
|
|
|
|
return;
|
2012-01-11 20:45:17 +04:00
|
|
|
|
|
|
|
if( w->browser->caret.background.fd_addr != NULL ){
|
|
|
|
browser_restore_caret_background( w, NULL );
|
|
|
|
w->browser->caret.requested.g_w = 0;
|
|
|
|
w->browser->caret.current.g_w = 0;
|
|
|
|
}
|
|
|
|
return;
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
|
2011-10-15 00:56:52 +04:00
|
|
|
{
|
2011-11-05 05:49:55 +04:00
|
|
|
g->icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gui_window_set_search_ico(hlcache_handle *ico)
|
|
|
|
{
|
|
|
|
TODO();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_new_content(struct gui_window *w)
|
|
|
|
{
|
2011-02-12 22:48:58 +03:00
|
|
|
w->browser->scroll.current.x = 0;
|
|
|
|
w->browser->scroll.current.y = 0;
|
|
|
|
w->browser->scroll.requested.x = 0;
|
|
|
|
w->browser->scroll.requested.y = 0;
|
|
|
|
w->browser->scroll.required = true;
|
|
|
|
gui_window_redraw_window( w );
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_window_scroll_start(struct gui_window *w)
|
|
|
|
{
|
|
|
|
TODO();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-11 18:20:26 +04:00
|
|
|
bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
|
2012-01-11 20:45:17 +04:00
|
|
|
const struct rect *rect)
|
2011-01-06 00:02:22 +03:00
|
|
|
{
|
|
|
|
TODO();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_window_save_link(struct gui_window *g, const char *url,
|
|
|
|
const char *title)
|
|
|
|
{
|
2011-02-02 00:21:16 +03:00
|
|
|
LOG(("%s -> %s", title, url ));
|
2011-01-06 00:02:22 +03:00
|
|
|
TODO();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
|
|
|
|
struct gui_window *w)
|
|
|
|
{
|
2011-02-02 00:21:16 +03:00
|
|
|
LOG((""));
|
2011-01-06 00:02:22 +03:00
|
|
|
TODO();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_drag_save_selection(struct selection *s, struct gui_window *w)
|
|
|
|
{
|
2011-02-02 00:21:16 +03:00
|
|
|
LOG((""));
|
2011-01-06 00:02:22 +03:00
|
|
|
TODO();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_start_selection(struct gui_window *w)
|
|
|
|
{
|
|
|
|
gui_empty_clipboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_paste_from_clipboard(struct gui_window *w, int x, int y)
|
|
|
|
{
|
|
|
|
char * clip = scrap_txt_read( &app );
|
|
|
|
if( clip == NULL )
|
|
|
|
return;
|
|
|
|
int clip_length = strlen( clip );
|
|
|
|
if (clip_length > 0) {
|
|
|
|
char *utf8;
|
|
|
|
utf8_convert_ret ret;
|
|
|
|
/* Clipboard is in local encoding so
|
|
|
|
* convert to UTF8 */
|
2011-12-04 21:18:59 +04:00
|
|
|
ret = utf8_from_local_encoding(clip,
|
2011-01-06 00:02:22 +03:00
|
|
|
clip_length, &utf8);
|
|
|
|
if (ret == UTF8_CONVERT_OK) {
|
|
|
|
browser_window_paste_text(w->browser->bw, utf8,
|
|
|
|
strlen(utf8), true);
|
|
|
|
free(utf8);
|
|
|
|
}
|
|
|
|
free( clip );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_empty_clipboard(void)
|
|
|
|
{
|
|
|
|
if( tmp_clipboard != NULL ){
|
|
|
|
free( tmp_clipboard );
|
|
|
|
tmp_clipboard = NULL;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_add_to_clipboard(const char *text_utf8, size_t length_utf8, bool space)
|
|
|
|
{
|
|
|
|
LOG(("(%s): %s (%d)\n", (space)?"space":"", (char*)text_utf8, (int)length_utf8));
|
|
|
|
char * oldptr = tmp_clipboard;
|
|
|
|
size_t oldlen = 0;
|
|
|
|
size_t newlen = 0;
|
|
|
|
char * text = NULL;
|
|
|
|
char * text2 = NULL;
|
2011-09-19 22:38:48 +04:00
|
|
|
bool retval;
|
2011-01-06 00:02:22 +03:00
|
|
|
int length = 0;
|
|
|
|
if( length_utf8 > 0 && text_utf8 != NULL ) {
|
|
|
|
utf8_to_local_encoding(text_utf8,length_utf8,&text);
|
|
|
|
if( text == NULL ) {
|
|
|
|
LOG(("Conversion failed (%s)", text_utf8));
|
|
|
|
goto error;
|
|
|
|
} else {
|
|
|
|
text2 = text;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if( space == false ) {
|
|
|
|
goto success;
|
|
|
|
}
|
|
|
|
text = malloc(length + 2);
|
|
|
|
if( text == NULL ) {
|
|
|
|
goto error;
|
2011-09-19 22:38:48 +04:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
text2 = text;
|
|
|
|
text[length+1] = 0;
|
|
|
|
memset(text, ' ', length+1);
|
|
|
|
}
|
|
|
|
length = strlen(text);
|
|
|
|
if( tmp_clipboard != NULL ) {
|
|
|
|
oldlen = strlen( tmp_clipboard );
|
2011-09-19 22:38:48 +04:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
newlen = oldlen + length + 1;
|
|
|
|
if( tmp_clipboard == NULL){
|
|
|
|
tmp_clipboard = malloc(newlen);
|
|
|
|
if( tmp_clipboard == NULL ) {
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
strncpy(tmp_clipboard, text, newlen);
|
|
|
|
} else {
|
|
|
|
tmp_clipboard = realloc( tmp_clipboard, newlen);
|
|
|
|
if( tmp_clipboard == NULL ) {
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
strncpy(tmp_clipboard, oldptr, newlen);
|
|
|
|
strncat(tmp_clipboard, text, newlen-oldlen);
|
|
|
|
}
|
|
|
|
goto success;
|
|
|
|
|
|
|
|
error:
|
|
|
|
retval = false;
|
|
|
|
goto fin;
|
|
|
|
|
|
|
|
success:
|
|
|
|
retval = true;
|
|
|
|
|
|
|
|
fin:
|
2011-09-19 22:38:48 +04:00
|
|
|
if( text2 != NULL )
|
2011-01-06 00:02:22 +03:00
|
|
|
free( text2 );
|
|
|
|
return(retval);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_commit_clipboard(void)
|
|
|
|
{
|
|
|
|
int r = scrap_txt_write(&app, tmp_clipboard);
|
2011-09-19 22:38:48 +04:00
|
|
|
return( (r>0)?true:false );
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
gui_selection_traverse_handler(const char *text,
|
|
|
|
size_t length,
|
|
|
|
struct box *box,
|
|
|
|
void *handle,
|
|
|
|
const char *space_text,
|
|
|
|
size_t space_length)
|
|
|
|
{
|
2011-03-06 21:04:13 +03:00
|
|
|
bool add_space = box != NULL ? box->space != 0 : false;
|
2011-01-06 00:02:22 +03:00
|
|
|
|
2011-02-09 23:31:34 +03:00
|
|
|
if (space_text != NULL && space_length > 0) {
|
2011-01-06 00:02:22 +03:00
|
|
|
if (!gui_add_to_clipboard(space_text, space_length, false)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-09 23:31:34 +03:00
|
|
|
if (!gui_add_to_clipboard(text, length, add_space))
|
2011-01-06 00:02:22 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gui_copy_to_clipboard(struct selection *s)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
2011-08-05 05:11:03 +04:00
|
|
|
if( s->defined ) {
|
2011-01-06 00:02:22 +03:00
|
|
|
gui_empty_clipboard();
|
|
|
|
if(selection_traverse(s, gui_selection_traverse_handler, NULL)){
|
|
|
|
ret = gui_commit_clipboard();
|
|
|
|
}
|
2011-09-19 22:38:48 +04:00
|
|
|
}
|
|
|
|
gui_empty_clipboard();
|
2011-01-06 00:02:22 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gui_create_form_select_menu(struct browser_window *bw,
|
|
|
|
struct form_control *control)
|
|
|
|
{
|
|
|
|
TODO();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Broadcast an URL that we can't handle.
|
|
|
|
*/
|
|
|
|
void gui_launch_url(const char *url)
|
|
|
|
{
|
|
|
|
TODO();
|
|
|
|
LOG(("launch file: %s\n", url));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_401login_open(const char *url, const char *realm,
|
|
|
|
nserror (*cb)(bool proceed, void *pw), void *cbpw)
|
|
|
|
{
|
|
|
|
bool bres;
|
|
|
|
char * out = NULL;
|
|
|
|
bres = login_form_do( (char*)url, (char*)realm, &out );
|
|
|
|
if( bres ) {
|
|
|
|
LOG(("url: %s, realm: %s, auth: %s\n", url, realm, out ));
|
|
|
|
urldb_set_auth_details(url, realm, out );
|
|
|
|
}
|
|
|
|
if( out != NULL ){
|
|
|
|
free( out );
|
|
|
|
}
|
|
|
|
if( cb != NULL )
|
|
|
|
cb(bres, cbpw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_cert_verify(const char *url, const struct ssl_cert_info *certs,
|
|
|
|
unsigned long num,
|
|
|
|
nserror (*cb)(bool proceed, void *pw), void *cbpw)
|
|
|
|
{
|
|
|
|
LOG((""));
|
2011-09-19 22:38:48 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
bool bres;
|
|
|
|
/*bres = verify_ssl_form_do(url, certs, num);
|
|
|
|
if( bres )
|
|
|
|
urldb_set_cert_permissions(url, true);
|
2012-01-11 20:45:17 +04:00
|
|
|
*/
|
2011-12-07 01:06:41 +04:00
|
|
|
// TODO: localize string
|
2011-01-06 00:02:22 +03:00
|
|
|
int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort]");
|
|
|
|
bres = (b==1)? true : false;
|
|
|
|
LOG(("Trust: %d", bres ));
|
|
|
|
urldb_set_cert_permissions(url, bres);
|
|
|
|
cb(bres, cbpw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_quit(void)
|
|
|
|
{
|
|
|
|
LOG((""));
|
|
|
|
|
|
|
|
struct gui_window * gw = window_list;
|
|
|
|
struct gui_window * tmp = window_list;
|
2011-02-12 22:48:58 +03:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
while( gw ) {
|
|
|
|
tmp = gw->next;
|
2011-07-01 00:20:27 +04:00
|
|
|
browser_window_destroy(gw->browser->bw);
|
2011-01-06 00:02:22 +03:00
|
|
|
gw = tmp;
|
|
|
|
}
|
2011-04-11 01:52:07 +04:00
|
|
|
|
|
|
|
hotlist_destroy();
|
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
urldb_save_cookies(nsoption_charp(cookie_file));
|
|
|
|
urldb_save(nsoption_charp(url_file));
|
2011-02-12 22:48:58 +03:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
RsrcXtype( 0, rsc_trindex, rsc_ntree);
|
|
|
|
unbind_global_events();
|
|
|
|
MenuBar( h_gem_menu , 0 );
|
2011-12-16 01:59:55 +04:00
|
|
|
if( h_gem_rsrc != NULL ) {
|
2011-01-06 00:02:22 +03:00
|
|
|
RsrcXfree(h_gem_rsrc );
|
|
|
|
}
|
|
|
|
LOG(("Shutting down plotter"));
|
|
|
|
atari_plotter_finalise();
|
|
|
|
if( tmp_clipboard != NULL ){
|
|
|
|
free( tmp_clipboard );
|
|
|
|
tmp_clipboard = NULL;
|
|
|
|
}
|
|
|
|
LOG(("done"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool
|
|
|
|
process_cmdline(int argc, char** argv)
|
|
|
|
{
|
|
|
|
int opt;
|
|
|
|
|
|
|
|
LOG(("argc %d, argv %p", argc, argv));
|
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) {
|
|
|
|
cfg_width = nsoption_int(window_width);
|
|
|
|
cfg_height = nsoption_int(window_height);
|
2012-01-11 20:45:17 +04:00
|
|
|
} else {
|
|
|
|
if( sys_type() == SYS_TOS ){
|
|
|
|
/* on single tasking OS, start as fulled window: */
|
2012-01-02 04:02:40 +04:00
|
|
|
cfg_width = app.w;
|
2012-01-11 20:45:17 +04:00
|
|
|
cfg_height = app.h;
|
2012-01-02 04:02:40 +04:00
|
|
|
} else {
|
|
|
|
cfg_width = 600;
|
2012-01-11 20:45:17 +04:00
|
|
|
cfg_height = 360;
|
2012-01-02 04:02:40 +04:00
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if (nsoption_charp(homepage_url) != NULL)
|
|
|
|
cfg_homepage_url = nsoption_charp(homepage_url);
|
2011-01-06 00:02:22 +03:00
|
|
|
else
|
|
|
|
cfg_homepage_url = NETSURF_HOMEPAGE;
|
|
|
|
|
|
|
|
while((opt = getopt(argc, argv, "w:h:")) != -1) {
|
|
|
|
switch (opt) {
|
|
|
|
case 'w':
|
|
|
|
cfg_width = atoi(optarg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'h':
|
|
|
|
cfg_height = atoi(optarg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
fprintf(stderr,
|
|
|
|
"Usage: %s [w,h,v] url\n",
|
|
|
|
argv[0]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optind < argc) {
|
|
|
|
cfg_homepage_url = argv[optind];
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void create_cursor(int flags, short mode, void * form, MFORM_EX * m)
|
|
|
|
{
|
|
|
|
m->flags = flags;
|
|
|
|
m->number = mode;
|
|
|
|
if( flags & MFORM_EX_FLAG_USERFORM ) {
|
|
|
|
m->number = mode;
|
|
|
|
m->tree = (OBJECT*)form;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
nsurl *gui_get_resource_url(const char *path)
|
2011-02-24 01:27:55 +03:00
|
|
|
{
|
2011-03-21 01:41:29 +03:00
|
|
|
char buf[PATH_MAX];
|
2011-10-05 12:32:52 +04:00
|
|
|
char *raw;
|
2011-10-15 00:56:52 +04:00
|
|
|
nsurl *url = NULL;
|
|
|
|
|
2011-10-05 12:32:52 +04:00
|
|
|
atari_find_resource((char*)&buf, path, path);
|
|
|
|
raw = path_to_url((char*)&buf);
|
2011-10-15 00:56:52 +04:00
|
|
|
if (raw != NULL) {
|
|
|
|
nsurl_create(raw, &url);
|
|
|
|
free(raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
return url;
|
2011-02-24 01:27:55 +03:00
|
|
|
}
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
static void gui_init(int argc, char** argv)
|
|
|
|
{
|
2011-12-04 17:05:00 +04:00
|
|
|
char buf[PATH_MAX];
|
2011-01-06 00:02:22 +03:00
|
|
|
OBJECT * cursors;
|
|
|
|
|
|
|
|
atari_find_resource(buf, "netsurf.rsc", "./res/netsurf.rsc");
|
2011-01-22 19:42:32 +03:00
|
|
|
LOG(("%s ", (char*)&buf));
|
2011-01-06 00:02:22 +03:00
|
|
|
h_gem_rsrc = RsrcXload( (char*) &buf );
|
2011-01-22 19:42:32 +03:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
if( !h_gem_rsrc )
|
|
|
|
die("Uable to open GEM Resource file!");
|
|
|
|
rsc_trindex = RsrcGhdr(h_gem_rsrc)->trindex;
|
|
|
|
rsc_ntree = RsrcGhdr(h_gem_rsrc)->ntree;
|
|
|
|
|
|
|
|
RsrcGaddr( h_gem_rsrc, R_TREE, MAINMENU , &h_gem_menu );
|
2011-12-12 23:38:58 +04:00
|
|
|
RsrcXtype( RSRC_XTYPE, rsc_trindex, rsc_ntree);
|
2011-01-06 00:02:22 +03:00
|
|
|
|
|
|
|
create_cursor(0, POINT_HAND, NULL, &gem_cursors.hand );
|
|
|
|
create_cursor(0, TEXT_CRSR, NULL, &gem_cursors.ibeam );
|
|
|
|
create_cursor(0, THIN_CROSS, NULL, &gem_cursors.cross);
|
|
|
|
create_cursor(0, BUSY_BEE, NULL, &gem_cursors.wait);
|
|
|
|
create_cursor(0, ARROW, NULL, &gem_cursors.arrow);
|
|
|
|
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizeall);
|
|
|
|
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenesw);
|
|
|
|
create_cursor(0, OUTLN_CROSS, NULL, &gem_cursors.sizenwse);
|
|
|
|
RsrcGaddr( h_gem_rsrc, R_TREE, CURSOR , &cursors );
|
|
|
|
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_APPSTART,
|
|
|
|
cursors, &gem_cursors.appstarting);
|
|
|
|
gem_set_cursor( &gem_cursors.appstarting );
|
|
|
|
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZEWE,
|
|
|
|
cursors, &gem_cursors.sizewe);
|
|
|
|
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_SIZENS,
|
|
|
|
cursors, &gem_cursors.sizens);
|
|
|
|
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_NODROP,
|
|
|
|
cursors, &gem_cursors.nodrop);
|
|
|
|
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_DENY,
|
|
|
|
cursors, &gem_cursors.deny);
|
|
|
|
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_MENU,
|
|
|
|
cursors, &gem_cursors.menu);
|
|
|
|
create_cursor(MFORM_EX_FLAG_USERFORM, CURSOR_HELP,
|
|
|
|
cursors, &gem_cursors.help);
|
|
|
|
|
|
|
|
LOG(("Enabling core select menu"));
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_bool(core_select_menu, true);
|
2011-01-06 00:02:22 +03:00
|
|
|
|
2012-03-22 13:34:34 +04:00
|
|
|
if( strlen(nsoption_charp(url_file)) ){
|
|
|
|
urldb_load(nsoption_charp(url_file));
|
2011-02-12 22:48:58 +03:00
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
if( strlen(nsoption_charp(cookie_file)) ){
|
|
|
|
urldb_load_cookies(nsoption_charp(cookie_file));
|
|
|
|
LOG(("Loading cookies from: %s", nsoption_charp(cookie_file) ));
|
2011-02-12 22:48:58 +03:00
|
|
|
}
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
if (process_cmdline(argc,argv) != true)
|
|
|
|
die("unable to process command line.\n");
|
|
|
|
|
|
|
|
nkc_init();
|
2012-03-22 13:34:34 +04:00
|
|
|
atari_plotter_init( nsoption_charp(atari_screen_driver), nsoption_charp(atari_font_driver) );
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
2011-08-05 05:11:03 +04:00
|
|
|
static char *theapp = (char*)"NetSurf";
|
2011-01-06 00:02:22 +03:00
|
|
|
static void gui_init2(int argc, char** argv)
|
|
|
|
{
|
|
|
|
MenuBar( h_gem_menu , 1 );
|
|
|
|
bind_global_events();
|
2011-03-21 01:41:29 +03:00
|
|
|
menu_register( -1, theapp);
|
|
|
|
if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
|
2011-01-22 19:42:32 +03:00
|
|
|
menu_register( _AESapid, (char*)" NetSurf ");
|
|
|
|
}
|
2012-03-22 13:34:34 +04:00
|
|
|
tree_set_icon_dir( nsoption_charp(tree_icons_path) );
|
2011-04-11 01:52:07 +04:00
|
|
|
hotlist_init();
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
2011-04-11 01:52:07 +04:00
|
|
|
/* #define WITH_DBG_LOGFILE 1 */
|
2011-01-06 00:02:22 +03:00
|
|
|
/** Entry point from OS.
|
|
|
|
*
|
|
|
|
* /param argc The number of arguments in the string vector.
|
|
|
|
* /param argv The argument string vector.
|
|
|
|
* /return The return code to the OS
|
|
|
|
*/
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
char messages[PATH_MAX];
|
|
|
|
|
|
|
|
setbuf(stderr, NULL);
|
2011-02-02 00:21:16 +03:00
|
|
|
setbuf(stdout, NULL);
|
|
|
|
#ifdef WITH_DBG_LOGFILE
|
|
|
|
freopen("stdout.log", "a+", stdout);
|
|
|
|
freopen("stderr.log", "a+", stderr);
|
|
|
|
#endif
|
2011-01-06 00:02:22 +03:00
|
|
|
ApplInit();
|
|
|
|
graf_mouse(BUSY_BEE, NULL);
|
2011-01-22 19:42:32 +03:00
|
|
|
init_os_info();
|
2011-04-11 01:52:07 +04:00
|
|
|
atari_find_resource((char*)&messages, "messages", "res/messages");
|
|
|
|
atari_find_resource((char*)&options, "Choices", "Choices");
|
2011-01-06 00:02:22 +03:00
|
|
|
netsurf_init(&argc, &argv, options, messages);
|
|
|
|
gui_init(argc, argv);
|
|
|
|
gui_init2(argc, argv);
|
2011-02-02 00:21:16 +03:00
|
|
|
browser_window_create(cfg_homepage_url, 0, 0, true, false);
|
2011-01-06 00:02:22 +03:00
|
|
|
graf_mouse( ARROW , NULL);
|
|
|
|
netsurf_main_loop();
|
2012-01-11 20:45:17 +04:00
|
|
|
netsurf_exit();
|
2011-01-06 00:02:22 +03:00
|
|
|
LOG(("ApplExit"));
|
|
|
|
ApplExit();
|
2011-09-19 22:38:48 +04:00
|
|
|
#ifdef WITH_DBG_LOGFILE
|
2011-02-02 00:21:16 +03:00
|
|
|
fclose(stdout);
|
2011-04-11 01:52:07 +04:00
|
|
|
fclose(stderr);
|
2011-02-02 00:21:16 +03:00
|
|
|
#endif
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|