2008-08-02 18:31:32 +04:00
/*
2016-12-31 17:43:06 +03:00
* Copyright 2008 - 2016 Chris Young < chris @ unsatisfactorysoftware . co . uk >
2008-08-02 18:31:32 +04:00
*
* This file is part of NetSurf , http : //www.netsurf-browser.org/
*
2015-01-30 21:20:07 +03:00
* NetSurf is free software ; you can redistribute it and / or modify
2008-08-02 18:31:32 +04:00
* 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/>.
*/
2010-02-14 15:26:12 +03:00
2008-08-11 21:53:45 +04:00
2010-02-14 15:26:12 +03:00
/* Custom StringView class */
2009-07-23 15:23:34 +04:00
# include "amiga/stringview/stringview.h"
# include "amiga/stringview/urlhistory.h"
2010-02-14 15:26:12 +03:00
/* AmigaOS libraries */
2011-01-07 02:17:17 +03:00
# ifdef __amigaos4__
2010-02-14 15:26:12 +03:00
# include <proto/application.h>
2011-01-07 02:17:17 +03:00
# endif
2010-02-14 15:26:12 +03:00
# include <proto/asl.h>
# include <proto/datatypes.h>
2016-06-25 19:52:32 +03:00
# include <proto/diskfont.h>
2010-02-14 15:26:12 +03:00
# include <proto/dos.h>
# include <proto/exec.h>
# include <proto/graphics.h>
2015-11-22 03:06:10 +03:00
# include <proto/icon.h>
2010-02-14 15:26:12 +03:00
# include <proto/intuition.h>
# include <proto/keymap.h>
# include <proto/locale.h>
# include <proto/utility.h>
# include <proto/wb.h>
2008-08-15 21:19:57 +04:00
2010-02-14 15:26:12 +03:00
/* Other OS includes */
2010-04-02 20:25:55 +04:00
# include <datatypes/textclass.h>
2010-02-14 15:26:12 +03:00
# include <devices/inputevent.h>
2015-01-31 15:59:49 +03:00
# include <graphics/gfxbase.h>
2015-01-17 20:06:48 +03:00
# include <graphics/rpattr.h>
2011-01-07 02:50:50 +03:00
# ifdef __amigaos4__
2016-06-25 19:52:32 +03:00
# include <diskfont/diskfonttag.h>
2010-03-24 01:27:33 +03:00
# include <graphics/blitattr.h>
2015-01-17 20:06:48 +03:00
# include <intuition/gui.h>
2010-02-14 15:26:12 +03:00
# include <libraries/application.h>
# include <libraries/keymap.h>
2011-01-07 02:50:50 +03:00
# endif
2010-02-14 15:26:12 +03:00
# include <intuition/icclass.h>
2013-05-28 20:34:29 +04:00
# include <intuition/screens.h>
2015-01-17 20:06:48 +03:00
# include <libraries/gadtools.h>
# include <workbench/workbench.h>
2010-02-14 15:26:12 +03:00
/* ReAction libraries */
# include <proto/bevel.h>
2008-08-09 02:38:13 +04:00
# include <proto/bitmap.h>
2008-08-09 19:19:04 +04:00
# include <proto/button.h>
2014-06-15 18:39:49 +04:00
# include <proto/chooser.h>
2008-09-28 00:55:11 +04:00
# include <proto/clicktab.h>
2015-11-17 00:05:01 +03:00
# include <proto/label.h>
2010-02-14 15:26:12 +03:00
# include <proto/layout.h>
2014-10-25 16:17:49 +04:00
# include <proto/scroller.h>
2010-02-14 15:26:12 +03:00
# include <proto/space.h>
2012-11-28 23:29:43 +04:00
# include <proto/speedbar.h>
2010-02-14 15:26:12 +03:00
# include <proto/string.h>
# include <proto/window.h>
2008-08-09 02:38:13 +04:00
# include <classes/window.h>
2010-02-14 15:26:12 +03:00
# include <gadgets/button.h>
2014-06-15 18:39:49 +04:00
# include <gadgets/chooser.h>
2010-02-14 15:26:12 +03:00
# include <gadgets/clicktab.h>
2008-08-09 02:38:13 +04:00
# include <gadgets/layout.h>
2008-08-09 19:19:04 +04:00
# include <gadgets/scroller.h>
2008-08-11 21:53:45 +04:00
# include <gadgets/space.h>
2012-11-28 23:29:43 +04:00
# include <gadgets/speedbar.h>
2010-02-14 15:26:12 +03:00
# include <gadgets/string.h>
# include <images/bevel.h>
# include <images/bitmap.h>
2015-11-17 00:05:01 +03:00
# include <images/label.h>
2010-02-14 15:26:12 +03:00
2008-08-09 02:38:13 +04:00
# include <reaction/reaction_macros.h>
2010-02-14 15:26:12 +03:00
/* newlib includes */
# include <math.h>
# include <string.h>
2016-06-06 10:59:23 +03:00
# include <stdlib.h>
2010-02-14 15:26:12 +03:00
2014-10-16 12:55:01 +04:00
/* NetSurf core includes */
# include "utils/log.h"
# include "utils/messages.h"
# include "utils/nsoption.h"
# include "utils/utf8.h"
# include "utils/utils.h"
# include "utils/nsurl.h"
# include "utils/file.h"
2016-06-06 10:59:23 +03:00
# include "netsurf/window.h"
# include "netsurf/fetch.h"
# include "netsurf/misc.h"
# include "netsurf/mouse.h"
# include "netsurf/netsurf.h"
# include "netsurf/content.h"
# include "netsurf/browser_window.h"
2016-06-14 01:34:45 +03:00
# include "netsurf/cookie_db.h"
# include "netsurf/url_db.h"
2016-07-01 16:27:04 +03:00
# include "netsurf/keypress.h"
2016-01-21 23:13:49 +03:00
# include "content/backing_store.h"
2016-06-27 23:09:39 +03:00
# include "content/fetch.h"
2014-10-16 12:55:01 +04:00
# include "desktop/browser_history.h"
# include "desktop/hotlist.h"
# include "desktop/version.h"
# include "desktop/save_complete.h"
# include "desktop/scrollbar.h"
# include "desktop/searchweb.h"
/* NetSurf Amiga platform includes */
# include "amiga/gui.h"
# include "amiga/arexx.h"
# include "amiga/bitmap.h"
# include "amiga/clipboard.h"
# include "amiga/cookies.h"
2015-09-03 02:24:04 +03:00
# include "amiga/ctxmenu.h"
2014-10-16 12:55:01 +04:00
# include "amiga/datatypes.h"
# include "amiga/download.h"
# include "amiga/drag.h"
# include "amiga/file.h"
# include "amiga/filetype.h"
# include "amiga/font.h"
# include "amiga/gui_options.h"
# include "amiga/help.h"
# include "amiga/history.h"
# include "amiga/history_local.h"
# include "amiga/hotlist.h"
# include "amiga/icon.h"
# include "amiga/launch.h"
2014-11-08 22:25:53 +03:00
# include "amiga/libs.h"
2014-10-16 12:55:01 +04:00
# include "amiga/login.h"
2016-11-20 00:52:46 +03:00
# include "amiga/memory.h"
2014-10-16 12:55:01 +04:00
# include "amiga/menu.h"
# include "amiga/misc.h"
2016-07-09 16:35:39 +03:00
# include "amiga/nsoption.h"
2014-10-16 12:55:01 +04:00
# include "amiga/plotters.h"
# include "amiga/plugin_hack.h"
# include "amiga/print.h"
# include "amiga/schedule.h"
# include "amiga/search.h"
2015-09-05 17:09:00 +03:00
# include "amiga/selectmenu.h"
2014-10-16 12:55:01 +04:00
# include "amiga/theme.h"
# include "amiga/utf8.h"
# include "amiga/sslcert.h"
2013-05-28 20:00:55 +04:00
# define AMINS_SCROLLERPEN NUMDRIPENS
2011-09-25 14:08:23 +04:00
# define NSA_KBD_SCROLL_PX 10
2016-02-14 17:45:28 +03:00
# define NSA_MAX_HOTLIST_BUTTON_LEN 20
2011-09-25 14:08:23 +04:00
2011-06-03 22:08:17 +04:00
/* Extra mouse button defines to match those in intuition/intuition.h */
2011-06-03 22:11:19 +04:00
# define SIDEDOWN (IECODE_4TH_BUTTON)
# define SIDEUP (IECODE_4TH_BUTTON | IECODE_UP_PREFIX)
# define EXTRADOWN (IECODE_5TH_BUTTON)
# define EXTRAUP (IECODE_5TH_BUTTON | IECODE_UP_PREFIX)
2011-06-03 22:08:17 +04:00
2016-08-12 22:32:09 +03:00
/* Left OR Right Shift/Alt keys */
# define NSA_QUAL_SHIFT (IEQUALIFIER_RSHIFT | IEQUALIFIER_LSHIFT)
# define NSA_QUAL_ALT (IEQUALIFIER_RALT | IEQUALIFIER_LALT)
2016-01-11 22:10:59 +03:00
# ifdef __amigaos4__
# define NSA_STATUS_TEXT GA_Text
# else
# define NSA_STATUS_TEXT STRINGA_TextVal
# endif
2016-03-01 02:06:10 +03:00
# ifdef __amigaos4__
# define BOOL_MISMATCH(a,b) ((a == FALSE) && (b != FALSE)) || ((a != FALSE) && (b == FALSE))
# else
# define BOOL_MISMATCH(a,b) (1)
# endif
2014-02-02 02:44:43 +04:00
extern struct gui_utf8_table * amiga_utf8_table ;
2013-09-12 15:29:47 +04:00
struct ami_gui_tb_userdata {
struct List * sblist ;
struct gui_window_2 * gw ;
int items ;
} ;
2016-06-02 02:03:45 +03:00
struct MinList * window_list = NULL ;
struct Screen * scrn = NULL ;
struct MsgPort * sport = NULL ;
struct gui_window * cur_gw = NULL ;
static bool ami_quit = false ;
2014-11-22 19:24:26 +03:00
static struct MsgPort * schedulermsgport = NULL ;
2014-11-16 19:31:35 +03:00
static struct MsgPort * appport ;
static Class * urlStringClass ;
static BOOL locked_screen = FALSE ;
static int screen_signal = - 1 ;
static bool win_destroyed ;
2014-11-16 19:40:41 +03:00
static STRPTR nsscreentitle ;
2017-02-13 20:46:20 +03:00
static struct gui_globals * browserglob = NULL ;
2014-11-16 19:31:35 +03:00
static struct MsgPort * applibport = NULL ;
static uint32 ami_appid = 0 ;
2016-06-02 02:14:10 +03:00
static ULONG applibsig = 0 ;
static ULONG rxsig = 0 ;
2014-11-16 19:31:35 +03:00
static struct Hook newprefs_hook ;
static STRPTR temp_homepage_url = NULL ;
static bool cli_force = false ;
2014-01-19 02:10:18 +04:00
2015-11-22 03:06:10 +03:00
# define USERS_DIR "PROGDIR:Users"
static char * users_dir = NULL ;
2012-03-29 02:17:27 +04:00
static char * current_user_dir ;
2014-06-30 01:35:52 +04:00
static char * current_user_faviconcache ;
2012-03-29 02:17:27 +04:00
2016-01-03 02:59:45 +03:00
static const __attribute__ ( ( used ) ) char * stack_cookie = " \0 $STACK:196608 \0 " ;
2009-03-27 23:04:34 +03:00
2011-09-07 22:38:08 +04:00
const char * const versvn ;
const char * const verdate ;
2016-07-03 20:48:46 +03:00
void ami_switch_tab ( struct gui_window_2 * gwin , bool redraw ) ;
2009-12-13 14:52:58 +03:00
void ami_change_tab ( struct gui_window_2 * gwin , int direction ) ;
2009-08-29 03:12:18 +04:00
void ami_get_hscroll_pos ( struct gui_window_2 * gwin , ULONG * xs ) ;
2009-08-31 01:43:14 +04:00
void ami_get_vscroll_pos ( struct gui_window_2 * gwin , ULONG * ys ) ;
2012-12-08 22:08:00 +04:00
void ami_quit_netsurf_delayed ( void ) ;
2011-05-08 02:21:41 +04:00
Object * ami_gui_splash_open ( void ) ;
void ami_gui_splash_close ( Object * win_obj ) ;
2015-02-24 01:58:57 +03:00
HOOKF ( uint32 , ami_set_favicon_render_hook , APTR , space , struct gpRender * ) ;
HOOKF ( uint32 , ami_set_throbber_render_hook , APTR , space , struct gpRender * ) ;
2016-07-03 20:48:46 +03:00
bool ami_gui_map_filename ( char * * remapped , const char * restrict path , const char * restrict file ,
const char * restrict map ) ;
2013-02-14 00:23:17 +04:00
static void ami_gui_window_update_box_deferred ( struct gui_window * g , bool draw ) ;
2013-04-04 22:46:33 +04:00
static void ami_do_redraw ( struct gui_window_2 * g ) ;
2013-04-12 00:32:05 +04:00
static void ami_schedule_redraw_remove ( struct gui_window_2 * gwin ) ;
2008-08-10 00:27:36 +04:00
2016-07-03 20:48:46 +03:00
static bool gui_window_get_scroll ( struct gui_window * g , int * restrict sx , int * restrict sy ) ;
2014-01-13 05:08:15 +04:00
static void gui_window_set_scroll ( struct gui_window * g , int sx , int sy ) ;
2014-01-16 18:43:48 +04:00
static void gui_window_remove_caret ( struct gui_window * g ) ;
static void gui_window_place_caret ( struct gui_window * g , int x , int y , int height , const struct rect * clip ) ;
2017-01-09 02:10:27 +03:00
static void gui_window_update_box ( struct gui_window * g , const struct rect * restrict rect ) ;
2014-01-16 18:43:48 +04:00
2014-01-13 05:08:15 +04:00
2013-06-01 19:05:51 +04:00
/* accessors for default options - user option is updated if it is set as per default */
# define nsoption_default_set_int(OPTION, VALUE) \
if ( nsoptions_default [ NSOPTION_ # # OPTION ] . value . i = = nsoptions [ NSOPTION_ # # OPTION ] . value . i ) \
nsoptions [ NSOPTION_ # # OPTION ] . value . i = VALUE ; \
nsoptions_default [ NSOPTION_ # # OPTION ] . value . i = VALUE
2014-05-07 19:14:18 +04:00
2016-06-25 19:52:32 +03:00
STRPTR ami_locale_langs ( int * codeset )
2009-06-22 02:12:52 +04:00
{
struct Locale * locale ;
2014-04-05 22:29:27 +04:00
STRPTR acceptlangs = NULL ;
2016-06-15 23:04:51 +03:00
char * remapped = NULL ;
2009-06-22 02:12:52 +04:00
2014-10-18 02:18:58 +04:00
if ( ( locale = OpenLocale ( NULL ) ) )
2009-06-22 02:12:52 +04:00
{
2016-06-25 19:52:32 +03:00
if ( codeset ! = NULL ) * codeset = locale - > loc_CodeSet ;
2014-04-05 22:29:27 +04:00
for ( int i = 0 ; i < 10 ; i + + )
2009-06-22 02:12:52 +04:00
{
if ( locale - > loc_PrefLanguages [ i ] )
{
2011-10-29 18:14:13 +04:00
if ( ami_gui_map_filename ( & remapped , " PROGDIR:Resources " ,
locale - > loc_PrefLanguages [ i ] , " LangNames " ) )
2009-06-22 02:12:52 +04:00
{
if ( acceptlangs )
{
2014-04-05 22:29:27 +04:00
STRPTR acceptlangs2 = acceptlangs ;
2011-10-29 18:14:13 +04:00
acceptlangs = ASPrintf ( " %s, %s " , acceptlangs2 , remapped ) ;
2009-06-22 02:12:52 +04:00
FreeVec ( acceptlangs2 ) ;
acceptlangs2 = NULL ;
}
else
{
2011-10-29 18:14:13 +04:00
acceptlangs = ASPrintf ( " %s " , remapped ) ;
2009-06-22 02:12:52 +04:00
}
}
2016-12-07 02:34:24 +03:00
if ( remapped ! = NULL ) free ( remapped ) ;
2009-06-22 02:12:52 +04:00
}
else
{
continue ;
}
}
CloseLocale ( locale ) ;
}
return acceptlangs ;
}
2016-07-03 20:48:46 +03:00
bool ami_gui_map_filename ( char * * remapped , const char * restrict path ,
const char * restrict file , const char * restrict map )
2011-10-29 17:32:53 +04:00
{
BPTR fh = 0 ;
2014-05-10 18:22:38 +04:00
char * mapfile = NULL ;
size_t mapfile_size = 0 ;
2011-10-29 17:32:53 +04:00
char buffer [ 1024 ] ;
2016-07-03 20:48:46 +03:00
char * restrict realfname ;
2011-10-29 17:32:53 +04:00
bool found = false ;
2014-05-11 19:54:36 +04:00
netsurf_mkpath ( & mapfile , & mapfile_size , 2 , path , map ) ;
2011-10-29 17:32:53 +04:00
2014-05-10 18:22:38 +04:00
if ( mapfile = = NULL ) return false ;
2014-10-18 02:18:58 +04:00
fh = FOpen ( mapfile , MODE_OLDFILE , 0 ) ;
if ( fh )
2011-10-29 17:32:53 +04:00
{
while ( FGets ( fh , buffer , 1024 ) ! = 0 )
{
if ( ( buffer [ 0 ] = = ' # ' ) | |
( buffer [ 0 ] = = ' \n ' ) | |
( buffer [ 0 ] = = ' \0 ' ) ) continue ;
2014-10-18 02:18:58 +04:00
realfname = strchr ( buffer , ' : ' ) ;
if ( realfname )
2011-10-29 17:32:53 +04:00
{
2011-10-29 18:14:13 +04:00
if ( strncmp ( buffer , file , strlen ( file ) ) = = 0 )
2011-10-29 17:32:53 +04:00
{
if ( realfname [ strlen ( realfname ) - 1 ] = = ' \n ' )
realfname [ strlen ( realfname ) - 1 ] = ' \0 ' ;
* remapped = strdup ( realfname + 1 ) ;
found = true ;
break ;
}
}
}
FClose ( fh ) ;
}
if ( found = = false ) * remapped = strdup ( file ) ;
2015-05-28 18:08:46 +03:00
else LOG ( " Remapped %s to %s in path %s using %s " , file , * remapped , path , map ) ;
2011-10-29 17:32:53 +04:00
2014-05-10 18:22:38 +04:00
free ( mapfile ) ;
2011-10-29 17:32:53 +04:00
return found ;
}
2014-10-16 12:55:01 +04:00
static bool ami_gui_check_resource ( char * fullpath , const char * file )
2011-10-29 17:32:53 +04:00
{
bool found = false ;
char * remapped ;
BPTR lock = 0 ;
2014-05-07 19:14:18 +04:00
size_t fullpath_len = 1024 ;
2011-10-29 17:32:53 +04:00
2016-12-06 02:32:55 +03:00
ami_gui_map_filename ( & remapped , fullpath , file , " Resource.map " ) ;
netsurf_mkpath ( & fullpath , & fullpath_len , 2 , fullpath , remapped ) ;
2011-10-29 17:32:53 +04:00
2016-12-06 02:32:55 +03:00
lock = Lock ( fullpath , ACCESS_READ ) ;
if ( lock ) {
UnLock ( lock ) ;
found = true ;
2016-12-05 23:30:28 +03:00
}
2011-10-29 17:32:53 +04:00
2016-12-06 02:32:55 +03:00
if ( found ) LOG ( " Found %s " , fullpath ) ;
free ( remapped ) ;
2011-10-29 17:32:53 +04:00
return found ;
}
2011-10-29 15:24:29 +04:00
bool ami_locate_resource ( char * fullpath , const char * file )
2008-08-02 18:31:32 +04:00
{
2008-08-10 00:27:36 +04:00
struct Locale * locale ;
int i ;
2011-03-13 21:33:57 +03:00
bool found = false ;
2016-12-05 23:30:28 +03:00
char * remapped = NULL ;
2014-05-07 19:14:18 +04:00
size_t fullpath_len = 1024 ;
2008-08-23 20:17:51 +04:00
2012-03-30 23:28:37 +04:00
/* Check NetSurf user data area first */
2015-08-24 20:00:24 +03:00
if ( current_user_dir ! = NULL ) {
strcpy ( fullpath , current_user_dir ) ;
found = ami_gui_check_resource ( fullpath , file ) ;
if ( found ) return true ;
}
2012-03-30 23:28:37 +04:00
2013-08-15 21:21:12 +04:00
/* Check current theme directory */
2015-08-24 20:00:24 +03:00
if ( nsoption_charp ( theme ) ) {
2012-03-22 13:34:34 +04:00
strcpy ( fullpath , nsoption_charp ( theme ) ) ;
2011-10-29 17:32:53 +04:00
found = ami_gui_check_resource ( fullpath , file ) ;
if ( found ) return true ;
2011-10-29 15:24:29 +04:00
}
/* If not found, start on the user's preferred languages */
2008-08-10 00:27:36 +04:00
locale = OpenLocale ( NULL ) ;
2015-08-24 20:00:24 +03:00
for ( i = 0 ; i < 10 ; i + + ) {
2016-07-03 20:48:46 +03:00
strcpy ( fullpath , " PROGDIR:Resources/ " ) ;
2011-10-29 17:32:53 +04:00
2015-08-24 20:00:24 +03:00
if ( locale - > loc_PrefLanguages [ i ] ) {
2016-12-05 23:30:28 +03:00
if ( ami_gui_map_filename ( & remapped , " PROGDIR:Resources " ,
locale - > loc_PrefLanguages [ i ] , " LangNames " ) = = true ) {
netsurf_mkpath ( & fullpath , & fullpath_len , 2 , fullpath , remapped ) ;
found = ami_gui_check_resource ( fullpath , file ) ;
free ( remapped ) ;
}
2015-08-24 20:00:24 +03:00
} else {
2008-08-10 00:27:36 +04:00
continue ;
}
2011-03-13 21:33:57 +03:00
2011-10-29 17:32:53 +04:00
if ( found ) break ;
2008-08-10 00:27:36 +04:00
}
2015-08-24 20:00:24 +03:00
if ( ! found ) {
2011-03-13 21:33:57 +03:00
/* If not found yet, check in PROGDIR:Resources/en,
* might not be in user ' s preferred languages */
2011-10-29 15:24:29 +04:00
strcpy ( fullpath , " PROGDIR:Resources/en/ " ) ;
2011-10-29 17:32:53 +04:00
found = ami_gui_check_resource ( fullpath , file ) ;
2008-08-09 19:19:04 +04:00
}
2008-08-10 00:27:36 +04:00
CloseLocale ( locale ) ;
2011-03-13 21:33:57 +03:00
2015-08-24 20:00:24 +03:00
if ( ! found ) {
2011-03-13 21:33:57 +03:00
/* Lastly check directly in PROGDIR:Resources */
2011-10-29 15:24:29 +04:00
strcpy ( fullpath , " PROGDIR:Resources/ " ) ;
2011-10-29 17:32:53 +04:00
found = ami_gui_check_resource ( fullpath , file ) ;
2011-03-13 21:33:57 +03:00
}
return found ;
2010-03-24 01:55:56 +03:00
}
2008-08-10 00:27:36 +04:00
2016-12-11 19:16:11 +03:00
static void ami_gui_resources_free ( void )
2010-03-24 01:55:56 +03:00
{
2016-12-11 19:16:11 +03:00
ami_schedule_free ( ) ;
ami_object_fini ( ) ;
2016-12-11 19:04:16 +03:00
2016-12-11 19:16:11 +03:00
FreeSysObject ( ASOT_PORT , appport ) ;
FreeSysObject ( ASOT_PORT , sport ) ;
FreeSysObject ( ASOT_PORT , schedulermsgport ) ;
}
static bool ami_gui_resources_open ( void )
{
2010-03-24 01:55:56 +03:00
urlStringClass = MakeStringClass ( ) ;
if ( ! ( appport = AllocSysObjectTags ( ASOT_PORT ,
2014-11-10 21:56:09 +03:00
ASO_NoTrack , FALSE ,
TAG_DONE ) ) ) return false ;
2010-03-24 01:55:56 +03:00
if ( ! ( sport = AllocSysObjectTags ( ASOT_PORT ,
2014-11-10 21:56:09 +03:00
ASO_NoTrack , FALSE ,
TAG_DONE ) ) ) return false ;
2010-03-24 01:55:56 +03:00
2014-11-22 19:24:26 +03:00
if ( ! ( schedulermsgport = AllocSysObjectTags ( ASOT_PORT ,
ASO_NoTrack , FALSE ,
TAG_DONE ) ) ) return false ;
2014-11-10 21:56:09 +03:00
2016-12-11 19:04:16 +03:00
if ( ami_schedule_create ( schedulermsgport ) ! = NSERROR_OK ) {
ami_misc_fatal_error ( " Failed to initialise scheduler " ) ;
return false ;
}
2016-12-11 19:16:11 +03:00
ami_object_init ( ) ;
2014-11-10 21:56:09 +03:00
return true ;
2010-03-24 01:55:56 +03:00
}
2013-05-28 20:22:07 +04:00
static UWORD ami_system_colour_scrollbar_fgpen ( struct DrawInfo * drinfo )
{
LONG scrollerfillpen = FALSE ;
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2013-05-28 20:22:07 +04:00
GetGUIAttrs ( NULL , drinfo , GUIA_PropKnobColor , & scrollerfillpen , TAG_DONE ) ;
if ( scrollerfillpen ) return FILLPEN ;
else return FOREGROUNDPEN ;
2015-01-17 20:06:48 +03:00
# else
return FILLPEN ;
# endif
2013-05-28 20:22:07 +04:00
}
2013-05-27 18:01:47 +04:00
/**
* set option from pen
*/
static nserror
2013-06-01 18:27:29 +04:00
colour_option_from_pen ( UWORD pen ,
2013-05-27 18:01:47 +04:00
enum nsoption_e option ,
2013-06-01 21:56:53 +04:00
struct Screen * screen ,
2013-05-27 18:01:47 +04:00
colour def_colour )
{
2014-04-05 22:32:30 +04:00
ULONG colr [ 3 ] ;
2013-05-27 18:01:47 +04:00
struct DrawInfo * drinfo ;
if ( ( option < NSOPTION_SYS_COLOUR_START ) | |
( option > NSOPTION_SYS_COLOUR_END ) | |
2013-06-01 18:27:29 +04:00
( nsoptions [ option ] . type ! = OPTION_COLOUR ) ) {
2013-05-27 18:01:47 +04:00
return NSERROR_BAD_PARAMETER ;
}
2013-06-01 21:56:53 +04:00
if ( screen ! = NULL ) {
drinfo = GetScreenDrawInfo ( screen ) ;
2013-05-27 18:01:47 +04:00
if ( drinfo ! = NULL ) {
if ( pen = = AMINS_SCROLLERPEN ) pen = ami_system_colour_scrollbar_fgpen ( drinfo ) ;
/* Get the colour of the pen being used for "pen" */
2014-04-05 22:32:30 +04:00
GetRGB32 ( screen - > ViewPort . ColorMap , drinfo - > dri_Pens [ pen ] , 1 , ( ULONG * ) & colr ) ;
2013-05-27 18:01:47 +04:00
/* convert it to a color */
2014-04-05 22:32:30 +04:00
def_colour = ( ( colr [ 0 ] & 0xff000000 ) > > 24 ) |
( ( colr [ 1 ] & 0xff000000 ) > > 16 ) |
( ( colr [ 2 ] & 0xff000000 ) > > 8 ) ;
2013-05-27 18:01:47 +04:00
2013-06-01 21:56:53 +04:00
FreeScreenDrawInfo ( screen , drinfo ) ;
2013-05-27 18:01:47 +04:00
}
}
2013-06-01 18:11:26 +04:00
if ( nsoptions_default [ option ] . value . c = = nsoptions [ option ] . value . c )
nsoptions [ option ] . value . c = def_colour ;
nsoptions_default [ option ] . value . c = def_colour ;
2013-05-27 18:01:47 +04:00
return NSERROR_OK ;
}
2014-11-16 19:40:41 +03:00
/* exported interface documented in amiga/gui.h */
STRPTR ami_gui_get_screen_title ( void )
{
2014-11-16 19:44:19 +03:00
if ( nsscreentitle = = NULL ) {
2014-11-16 19:40:41 +03:00
nsscreentitle = ASPrintf ( " NetSurf %s " , netsurf_version ) ;
2014-11-16 19:44:19 +03:00
/* If this fails it will be NULL, which means we'll get the screen's
* default titlebar text instead - so no need to check for error . */
}
2014-11-16 19:40:41 +03:00
return nsscreentitle ;
}
2013-06-01 21:56:53 +04:00
static void ami_set_screen_defaults ( struct Screen * screen )
2013-05-31 22:34:22 +04:00
{
2017-01-03 03:26:00 +03:00
/* various window size/position defaults */
int width = screen - > Width / 2 ;
int height = screen - > Height / 2 ;
int top = ( screen - > Height / 2 ) - ( height / 2 ) ;
int left = ( screen - > Width / 2 ) - ( width / 2 ) ;
nsoption_default_set_int ( cookies_window_ypos , top ) ;
nsoption_default_set_int ( cookies_window_xpos , left ) ;
nsoption_default_set_int ( cookies_window_xsize , width ) ;
nsoption_default_set_int ( cookies_window_ysize , height ) ;
2017-01-06 21:27:09 +03:00
nsoption_default_set_int ( history_window_ypos , top ) ;
nsoption_default_set_int ( history_window_xpos , left ) ;
nsoption_default_set_int ( history_window_xsize , width ) ;
nsoption_default_set_int ( history_window_ysize , height ) ;
2017-01-07 02:56:52 +03:00
nsoption_default_set_int ( hotlist_window_ypos , top ) ;
nsoption_default_set_int ( hotlist_window_xpos , left ) ;
nsoption_default_set_int ( hotlist_window_xsize , width ) ;
nsoption_default_set_int ( hotlist_window_ysize , height ) ;
2013-06-01 17:58:51 +04:00
nsoption_default_set_int ( window_x , 0 ) ;
2013-06-01 21:56:53 +04:00
nsoption_default_set_int ( window_y , screen - > BarHeight + 1 ) ;
nsoption_default_set_int ( window_width , screen - > Width ) ;
nsoption_default_set_int ( window_height , screen - > Height - screen - > BarHeight - 1 ) ;
2013-06-01 18:37:26 +04:00
2016-01-10 15:07:46 +03:00
# ifdef __amigaos4__
2013-06-01 21:56:53 +04:00
nsoption_default_set_int ( redraw_tile_size_x , screen - > Width ) ;
nsoption_default_set_int ( redraw_tile_size_y , screen - > Height ) ;
2016-01-10 15:07:46 +03:00
2013-06-01 18:11:26 +04:00
/* set system colours for amiga ui */
2013-06-01 21:56:53 +04:00
colour_option_from_pen ( FILLPEN , NSOPTION_sys_colour_ActiveBorder , screen , 0x00000000 ) ;
colour_option_from_pen ( FILLPEN , NSOPTION_sys_colour_ActiveCaption , screen , 0x00dddddd ) ;
colour_option_from_pen ( BACKGROUNDPEN , NSOPTION_sys_colour_AppWorkspace , screen , 0x00eeeeee ) ;
colour_option_from_pen ( BACKGROUNDPEN , NSOPTION_sys_colour_Background , screen , 0x00aa0000 ) ;
colour_option_from_pen ( FOREGROUNDPEN , NSOPTION_sys_colour_ButtonFace , screen , 0x00aaaaaa ) ;
colour_option_from_pen ( FORESHINEPEN , NSOPTION_sys_colour_ButtonHighlight , screen , 0x00cccccc ) ;
colour_option_from_pen ( FORESHADOWPEN , NSOPTION_sys_colour_ButtonShadow , screen , 0x00bbbbbb ) ;
colour_option_from_pen ( TEXTPEN , NSOPTION_sys_colour_ButtonText , screen , 0x00000000 ) ;
colour_option_from_pen ( FILLTEXTPEN , NSOPTION_sys_colour_CaptionText , screen , 0x00000000 ) ;
colour_option_from_pen ( DISABLEDTEXTPEN , NSOPTION_sys_colour_GrayText , screen , 0x00777777 ) ;
colour_option_from_pen ( SELECTPEN , NSOPTION_sys_colour_Highlight , screen , 0x00ee0000 ) ;
colour_option_from_pen ( SELECTTEXTPEN , NSOPTION_sys_colour_HighlightText , screen , 0x00000000 ) ;
colour_option_from_pen ( INACTIVEFILLPEN , NSOPTION_sys_colour_InactiveBorder , screen , 0x00000000 ) ;
colour_option_from_pen ( INACTIVEFILLPEN , NSOPTION_sys_colour_InactiveCaption , screen , 0x00ffffff ) ;
colour_option_from_pen ( INACTIVEFILLTEXTPEN , NSOPTION_sys_colour_InactiveCaptionText , screen , 0x00cccccc ) ;
colour_option_from_pen ( BACKGROUNDPEN , NSOPTION_sys_colour_InfoBackground , screen , 0x00aaaaaa ) ; /* This is wrong, HelpHint backgrounds are pale yellow but doesn't seem to be a DrawInfo pen defined for it. */
colour_option_from_pen ( TEXTPEN , NSOPTION_sys_colour_InfoText , screen , 0x00000000 ) ;
colour_option_from_pen ( MENUBACKGROUNDPEN , NSOPTION_sys_colour_Menu , screen , 0x00aaaaaa ) ;
colour_option_from_pen ( MENUTEXTPEN , NSOPTION_sys_colour_MenuText , screen , 0x00000000 ) ;
colour_option_from_pen ( AMINS_SCROLLERPEN , NSOPTION_sys_colour_Scrollbar , screen , 0x00aaaaaa ) ;
colour_option_from_pen ( FORESHADOWPEN , NSOPTION_sys_colour_ThreeDDarkShadow , screen , 0x00555555 ) ;
colour_option_from_pen ( FOREGROUNDPEN , NSOPTION_sys_colour_ThreeDFace , screen , 0x00dddddd ) ;
colour_option_from_pen ( FORESHINEPEN , NSOPTION_sys_colour_ThreeDHighlight , screen , 0x00aaaaaa ) ;
colour_option_from_pen ( HALFSHINEPEN , NSOPTION_sys_colour_ThreeDLightShadow , screen , 0x00999999 ) ;
colour_option_from_pen ( HALFSHADOWPEN , NSOPTION_sys_colour_ThreeDShadow , screen , 0x00777777 ) ;
colour_option_from_pen ( BACKGROUNDPEN , NSOPTION_sys_colour_Window , screen , 0x00aaaaaa ) ;
colour_option_from_pen ( INACTIVEFILLPEN , NSOPTION_sys_colour_WindowFrame , screen , 0x00000000 ) ;
colour_option_from_pen ( TEXTPEN , NSOPTION_sys_colour_WindowText , screen , 0x00000000 ) ;
2016-01-10 15:07:46 +03:00
# else
nsoption_default_set_int ( redraw_tile_size_x , 100 ) ;
nsoption_default_set_int ( redraw_tile_size_y , 100 ) ;
2015-01-17 20:06:48 +03:00
# endif
2013-05-31 22:34:22 +04:00
}
2013-05-27 18:01:47 +04:00
/**
* Set option defaults for amiga frontend
*
* @ param defaults The option table to update .
* @ return error status .
*/
static nserror ami_set_options ( struct nsoption_s * defaults )
2010-03-24 01:55:56 +03:00
{
STRPTR tempacceptlangs ;
2012-03-29 02:17:27 +04:00
char temp [ 1024 ] ;
2016-06-25 19:52:32 +03:00
int codeset = 0 ;
2009-08-14 21:53:28 +04:00
2015-09-05 17:09:00 +03:00
/* The following line disables the popupmenu.class select menu.
* * It ' s not recommended to use it !
2009-08-14 21:53:28 +04:00
*/
2012-03-22 13:34:34 +04:00
nsoption_set_bool ( core_select_menu , true ) ;
2008-12-14 02:25:42 +03:00
2016-01-31 20:10:47 +03:00
/* ClickTab < 53 doesn't work with the auto show/hide tab-bar (for reasons forgotten) */
if ( ClickTabBase - > lib_Version < 53 )
nsoption_set_bool ( tab_always_show , true ) ;
2012-03-22 13:34:34 +04:00
if ( ( ! nsoption_charp ( accept_language ) ) | |
( nsoption_charp ( accept_language ) [ 0 ] = = ' \0 ' ) | |
( nsoption_bool ( accept_lang_locale ) = = true ) )
2009-06-22 02:12:52 +04:00
{
2016-06-25 19:52:32 +03:00
if ( ( tempacceptlangs = ami_locale_langs ( & codeset ) ) )
2009-06-22 02:12:52 +04:00
{
2012-03-22 13:34:34 +04:00
nsoption_set_charp ( accept_language ,
( char * ) strdup ( tempacceptlangs ) ) ;
2009-06-22 02:12:52 +04:00
FreeVec ( tempacceptlangs ) ;
}
}
2009-05-09 22:56:12 +04:00
2016-06-25 19:52:32 +03:00
/* Some OS-specific overrides */
# ifdef __amigaos4__
2016-12-31 17:43:06 +03:00
if ( ! LIB_IS_AT_LEAST ( ( struct Library * ) SysBase , 53 , 89 ) ) {
/* Disable ExtMem usage pre-OS4.1FEU1 */
nsoption_set_bool ( use_extmem , false ) ;
}
2016-06-25 19:52:32 +03:00
if ( codeset = = 0 ) codeset = 4 ; /* ISO-8859-1 */
const char * encname = ( const char * ) ObtainCharsetInfo ( DFCS_NUMBER , codeset ,
DFCS_MIMENAME ) ;
nsoption_set_charp ( local_charset , strdup ( encname ) ) ;
# else
nsoption_set_bool ( download_notify , false ) ;
nsoption_set_bool ( font_antialiasing , false ) ;
nsoption_set_bool ( truecolour_mouse_pointers , false ) ;
nsoption_set_bool ( use_openurl_lib , true ) ;
nsoption_set_bool ( bitmap_fonts , true ) ;
# endif
2012-03-29 02:17:27 +04:00
sprintf ( temp , " %s/Cookies " , current_user_dir ) ;
2012-03-22 13:34:34 +04:00
nsoption_setnull_charp ( cookie_file ,
2012-03-29 02:17:27 +04:00
( char * ) strdup ( temp ) ) ;
2008-08-10 00:27:36 +04:00
2012-03-29 02:17:27 +04:00
sprintf ( temp , " %s/Hotlist " , current_user_dir ) ;
2012-03-22 13:34:34 +04:00
nsoption_setnull_charp ( hotlist_file ,
2012-03-29 02:17:27 +04:00
( char * ) strdup ( temp ) ) ;
2012-03-22 13:34:34 +04:00
2012-03-29 02:17:27 +04:00
sprintf ( temp , " %s/URLdb " , current_user_dir ) ;
2012-03-22 13:34:34 +04:00
nsoption_setnull_charp ( url_file ,
2012-03-29 02:17:27 +04:00
( char * ) strdup ( temp ) ) ;
2008-08-10 00:27:36 +04:00
2012-05-10 02:23:10 +04:00
sprintf ( temp , " %s/FontGlyphCache " , current_user_dir ) ;
2012-05-05 19:58:17 +04:00
nsoption_setnull_charp ( font_unicode_file ,
( char * ) strdup ( temp ) ) ;
2015-02-21 15:21:14 +03:00
nsoption_setnull_charp ( ca_bundle ,
( char * ) strdup ( " PROGDIR:Resources/ca-bundle " ) ) ;
2012-03-22 13:34:34 +04:00
/* font defaults */
2015-01-30 03:05:40 +03:00
# ifdef __amigaos4__
2012-03-22 13:34:34 +04:00
nsoption_setnull_charp ( font_sans , ( char * ) strdup ( " DejaVu Sans " ) ) ;
nsoption_setnull_charp ( font_serif , ( char * ) strdup ( " DejaVu Serif " ) ) ;
nsoption_setnull_charp ( font_mono , ( char * ) strdup ( " DejaVu Sans Mono " ) ) ;
nsoption_setnull_charp ( font_cursive , ( char * ) strdup ( " DejaVu Sans " ) ) ;
nsoption_setnull_charp ( font_fantasy , ( char * ) strdup ( " DejaVu Serif " ) ) ;
2015-01-30 03:05:40 +03:00
# else
2016-01-10 15:07:46 +03:00
nsoption_setnull_charp ( font_sans , ( char * ) strdup ( " helvetica " ) ) ;
nsoption_setnull_charp ( font_serif , ( char * ) strdup ( " times " ) ) ;
nsoption_setnull_charp ( font_mono , ( char * ) strdup ( " topaz " ) ) ;
nsoption_setnull_charp ( font_cursive , ( char * ) strdup ( " garnet " ) ) ;
nsoption_setnull_charp ( font_fantasy , ( char * ) strdup ( " emerald " ) ) ;
/* Default CG fonts for OS3 - these work with use_diskfont both on and off,
however they are slow in both cases . The bitmap fonts don ' t work when
use_diskfont is off . The bitmap fonts performance on 68 k is far superior ,
so default to those for now whilst testing .
\ todo maybe add some buttons to the prefs GUI to toggle ?
nsoption_setnull_charp ( font_sans , ( char * ) strdup ( " CGTriumvirate " ) ) ;
nsoption_setnull_charp ( font_serif , ( char * ) strdup ( " CGTimes " ) ) ;
nsoption_setnull_charp ( font_mono , ( char * ) strdup ( " LetterGothic " ) ) ;
nsoption_setnull_charp ( font_cursive , ( char * ) strdup ( " CGTriumvirate " ) ) ;
nsoption_setnull_charp ( font_fantasy , ( char * ) strdup ( " CGTimes " ) ) ;
*/
2015-01-30 03:05:40 +03:00
# endif
2008-08-10 00:27:36 +04:00
2012-03-22 13:34:34 +04:00
if ( nsoption_charp ( font_unicode ) = = NULL )
2010-05-06 14:02:58 +04:00
{
2014-04-05 22:46:36 +04:00
BPTR lock = 0 ;
2010-05-06 14:02:58 +04:00
/* Search for some likely candidates */
2016-01-10 15:28:49 +03:00
if ( ( lock = Lock ( " FONTS:Code2000.otag " , ACCESS_READ ) ) )
{
2010-05-06 14:02:58 +04:00
UnLock ( lock ) ;
2012-03-22 13:34:34 +04:00
nsoption_set_charp ( font_unicode ,
( char * ) strdup ( " Code2000 " ) ) ;
}
2016-01-10 15:28:49 +03:00
else if ( ( lock = Lock ( " FONTS:Bitstream Cyberbit.otag " , ACCESS_READ ) ) )
{
2016-01-10 15:22:43 +03:00
UnLock ( lock ) ;
nsoption_set_charp ( font_unicode ,
2016-01-10 15:28:49 +03:00
( char * ) strdup ( " Bitstream Cyberbit " ) ) ;
2016-01-10 15:22:43 +03:00
}
2010-05-06 14:02:58 +04:00
}
2015-07-06 21:29:16 +03:00
if ( nsoption_charp ( font_surrogate ) = = NULL ) {
BPTR lock = 0 ;
/* Search for some likely candidates -
* Ideally we should pick a font during the scan process which announces it
* contains UCR_SURROGATES , but nothing appears to have the tag .
*/
if ( ( lock = Lock ( " FONTS:Symbola.otag " , ACCESS_READ ) ) ) {
UnLock ( lock ) ;
nsoption_set_charp ( font_surrogate ,
( char * ) strdup ( " Symbola " ) ) ;
}
}
2013-05-27 18:01:47 +04:00
return NSERROR_OK ;
2010-03-24 01:55:56 +03:00
}
2008-08-18 23:07:12 +04:00
2014-10-16 12:55:01 +04:00
static void ami_amiupdate ( void )
2010-03-24 01:55:56 +03:00
{
2011-04-22 17:55:25 +04:00
/* Create AppPath location for AmiUpdate use */
2014-04-05 22:46:36 +04:00
BPTR lock = 0 ;
2011-04-22 17:55:25 +04:00
2008-10-13 22:01:25 +04:00
if ( ( ( lock = Lock ( " ENVARC:AppPaths " , SHARED_LOCK ) ) = = 0 ) )
{
lock = CreateDir ( " ENVARC:AppPaths " ) ;
}
UnLock ( lock ) ;
2014-10-25 19:22:08 +04:00
if ( ( lock = Lock ( " PROGDIR: " , ACCESS_READ ) ) )
2008-10-13 22:01:25 +04:00
{
char filename [ 1024 ] ;
2014-04-05 22:46:36 +04:00
BPTR amiupdatefh ;
2008-10-13 22:01:25 +04:00
2015-11-15 04:27:29 +03:00
DevNameFromLock ( lock , ( STRPTR ) & filename , 1024L , DN_FULLPATH ) ;
2015-11-15 16:52:55 +03:00
if ( ( amiupdatefh = FOpen ( " ENVARC:AppPaths/NetSurf " , MODE_NEWFILE , 0 ) ) ) {
2015-11-15 04:27:29 +03:00
FPuts ( amiupdatefh , ( CONST_STRPTR ) & filename ) ;
FClose ( amiupdatefh ) ;
}
2008-10-13 22:01:25 +04:00
2011-04-22 17:55:25 +04:00
UnLock ( lock ) ;
2008-10-13 22:01:25 +04:00
}
2010-03-24 01:55:56 +03:00
}
2014-01-15 03:31:54 +04:00
static nsurl * gui_get_resource_url ( const char * path )
2011-02-24 01:27:55 +03:00
{
2011-10-05 12:32:52 +04:00
char buf [ 1024 ] ;
char path2 [ 1024 ] ;
nsurl * url = NULL ;
2011-02-24 02:29:24 +03:00
2011-10-05 12:32:52 +04:00
if ( ami_locate_resource ( buf , path ) = = false )
2011-03-13 21:33:57 +03:00
{
2011-10-05 12:32:52 +04:00
if ( ( strncmp ( path + strlen ( path ) - SLEN ( " .htm " ) , " .htm " , SLEN ( " .htm " ) ) = = 0 ) | |
( strncmp ( path + strlen ( path ) - SLEN ( " .html " ) , " .html " , SLEN ( " .html " ) ) = = 0 ) )
2011-03-13 21:33:57 +03:00
{
2011-03-14 21:53:13 +03:00
/* Try with RISC OS HTML filetype, might work */
2011-10-05 12:32:52 +04:00
strcpy ( path2 , path ) ;
strcat ( path2 , " ,faf " ) ;
2011-03-14 21:53:13 +03:00
2011-10-05 12:32:52 +04:00
if ( ami_locate_resource ( buf , path2 ) = = false )
2011-03-14 21:53:13 +03:00
{
return NULL ;
}
2011-03-13 21:33:57 +03:00
}
2011-03-14 21:53:13 +03:00
else return NULL ;
2011-03-13 21:33:57 +03:00
}
2011-02-24 02:29:24 +03:00
2014-05-27 02:43:36 +04:00
netsurf_path_to_nsurl ( buf , & url ) ;
2011-10-05 12:32:52 +04:00
return url ;
2011-02-24 01:27:55 +03:00
}
2015-02-24 01:58:57 +03:00
HOOKF ( void , ami_gui_newprefs_hook , APTR , window , APTR )
2012-04-07 21:16:32 +04:00
{
2013-06-01 18:18:09 +04:00
ami_set_screen_defaults ( scrn ) ;
2012-04-07 21:16:32 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_openscreen ( void )
2009-07-04 20:12:27 +04:00
{
ULONG id = 0 ;
2012-02-25 00:00:51 +04:00
ULONG compositing ;
2012-03-22 13:34:34 +04:00
if ( nsoption_int ( screen_compositing ) = = - 1 )
2012-02-25 00:00:51 +04:00
compositing = ~ 0UL ;
2012-03-22 13:34:34 +04:00
else compositing = nsoption_int ( screen_compositing ) ;
2012-02-25 00:00:51 +04:00
2013-06-01 02:25:05 +04:00
if ( nsoption_charp ( pubscreen_name ) = = NULL )
2009-07-04 20:12:27 +04:00
{
2013-05-28 19:44:46 +04:00
if ( ( nsoption_charp ( screen_modeid ) ) & &
( strncmp ( nsoption_charp ( screen_modeid ) , " 0x " , 2 ) = = 0 ) )
2009-07-04 20:12:27 +04:00
{
2013-05-28 19:44:46 +04:00
id = strtoul ( nsoption_charp ( screen_modeid ) , NULL , 0 ) ;
2009-07-04 20:12:27 +04:00
}
else
{
struct ScreenModeRequester * screenmodereq = NULL ;
2014-10-25 19:22:08 +04:00
if ( ( screenmodereq = AllocAslRequest ( ASL_ScreenModeRequest , NULL ) ) ) {
2010-03-24 01:55:56 +03:00
if ( AslRequestTags ( screenmodereq ,
2012-08-08 02:09:40 +04:00
ASLSM_MinDepth , 0 ,
ASLSM_MaxDepth , 32 ,
2010-03-24 01:55:56 +03:00
TAG_DONE ) )
{
2012-03-22 13:34:34 +04:00
char * modeid = malloc ( 20 ) ;
2010-03-24 01:55:56 +03:00
id = screenmodereq - > sm_DisplayID ;
2012-03-22 13:34:34 +04:00
sprintf ( modeid , " 0x%lx " , id ) ;
2013-05-28 19:44:46 +04:00
nsoption_set_charp ( screen_modeid , modeid ) ;
2016-07-09 03:07:18 +03:00
ami_nsoption_write ( ) ;
2010-03-24 01:55:56 +03:00
}
2009-07-04 20:12:27 +04:00
FreeAslRequest ( screenmodereq ) ;
}
}
2014-04-06 18:24:24 +04:00
if ( screen_signal = = - 1 ) screen_signal = AllocSignal ( - 1 ) ;
2015-05-28 18:08:46 +03:00
LOG ( " Screen signal %d " , screen_signal ) ;
2009-07-04 20:12:27 +04:00
scrn = OpenScreenTags ( NULL ,
2015-08-14 21:13:19 +03:00
/**\todo specify screen depth */
2011-06-18 21:58:36 +04:00
SA_DisplayID , id ,
2014-11-16 19:40:41 +03:00
SA_Title , ami_gui_get_screen_title ( ) ,
2011-06-18 21:58:36 +04:00
SA_Type , PUBLICSCREEN ,
SA_PubName , " NetSurf " ,
2014-02-10 22:13:28 +04:00
SA_PubSig , screen_signal ,
SA_PubTask , FindTask ( 0 ) ,
2011-06-18 21:58:36 +04:00
SA_LikeWorkbench , TRUE ,
2012-02-25 00:00:51 +04:00
SA_Compositing , compositing ,
2009-07-04 20:12:27 +04:00
TAG_DONE ) ;
if ( scrn )
{
PubScreenStatus ( scrn , 0 ) ;
}
else
{
2014-04-06 18:22:18 +04:00
FreeSignal ( screen_signal ) ;
2014-04-06 18:24:24 +04:00
screen_signal = - 1 ;
2014-04-06 18:22:18 +04:00
2014-10-25 19:22:08 +04:00
if ( ( scrn = LockPubScreen ( " NetSurf " ) ) )
2009-07-04 20:12:27 +04:00
{
locked_screen = TRUE ;
}
else
{
2013-06-01 02:25:05 +04:00
nsoption_set_charp ( pubscreen_name ,
2012-03-22 13:34:34 +04:00
strdup ( " Workbench " ) ) ;
2009-07-04 20:12:27 +04:00
}
}
}
2013-06-01 02:25:05 +04:00
if ( nsoption_charp ( pubscreen_name ) ! = NULL )
2009-07-04 20:12:27 +04:00
{
2013-06-01 02:25:05 +04:00
scrn = LockPubScreen ( nsoption_charp ( pubscreen_name ) ) ;
2011-06-19 15:16:48 +04:00
if ( scrn = = NULL )
2009-07-04 20:12:27 +04:00
{
scrn = LockPubScreen ( " Workbench " ) ;
}
2011-06-19 15:16:48 +04:00
locked_screen = TRUE ;
2009-07-04 20:12:27 +04:00
}
2011-01-30 20:30:32 +03:00
2013-08-20 22:43:13 +04:00
ami_font_setdevicedpi ( id ) ;
2013-05-31 22:34:22 +04:00
ami_set_screen_defaults ( scrn ) ;
2014-01-11 00:03:22 +04:00
ami_help_new_screen ( scrn ) ;
2009-07-04 20:12:27 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_openscreenfirst ( void )
2009-09-29 02:17:09 +04:00
{
ami_openscreen ( ) ;
2017-02-13 21:09:43 +03:00
if ( browserglob = = NULL ) browserglob = ami_plot_ra_alloc ( 0 , 0 , false , false ) ;
2012-08-11 01:59:38 +04:00
ami_theme_throbber_setup ( ) ;
2009-09-29 02:17:09 +04:00
}
2016-07-03 20:48:46 +03:00
static struct RDArgs * ami_gui_commandline ( int * restrict argc , char * * argv ,
int * restrict nargc , char * * nargv )
2008-08-02 18:31:32 +04:00
{
2008-09-29 02:50:13 +04:00
struct RDArgs * args ;
2015-11-27 15:36:40 +03:00
CONST_STRPTR template = " -v/S,NSOPTS/M,URL/K,USERSDIR/K,FORCE/S " ;
2015-12-20 19:36:59 +03:00
long rarray [ ] = { 0 , 0 , 0 , 0 , 0 } ;
2008-09-29 02:50:13 +04:00
enum
{
2015-11-27 15:36:40 +03:00
A_VERBOSE , /* ignored */
2011-05-30 22:17:09 +04:00
A_NSOPTS , /* ignored */
2010-03-28 20:42:33 +04:00
A_URL ,
2015-11-25 03:11:24 +03:00
A_USERSDIR ,
2010-03-28 20:42:33 +04:00
A_FORCE
2008-09-29 02:50:13 +04:00
} ;
2008-08-02 18:31:32 +04:00
2015-11-25 02:58:54 +03:00
if ( * argc = = 0 ) return NULL ; // argc==0 is started from wb
2014-01-19 02:10:18 +04:00
2014-10-25 19:22:08 +04:00
if ( ( args = ReadArgs ( template , rarray , NULL ) ) ) {
2014-01-19 02:10:18 +04:00
if ( rarray [ A_URL ] ) {
2016-06-06 10:59:23 +03:00
LOG ( " URL %s specified on command line " ,
( char * ) rarray [ A_URL ] ) ;
2016-07-03 21:10:57 +03:00
temp_homepage_url = strdup ( ( char * ) rarray [ A_URL ] ) ; /**\todo allow IDNs */
2014-01-19 02:10:18 +04:00
}
2015-11-25 03:11:24 +03:00
if ( rarray [ A_USERSDIR ] ) {
2016-06-06 10:59:23 +03:00
LOG ( " USERSDIR %s specified on command line " ,
( char * ) rarray [ A_USERSDIR ] ) ;
2015-11-25 03:11:24 +03:00
users_dir = ASPrintf ( " %s " , rarray [ A_USERSDIR ] ) ;
}
2014-01-19 02:10:18 +04:00
if ( rarray [ A_FORCE ] ) {
2015-05-28 18:08:46 +03:00
LOG ( " FORCE specified on command line " ) ;
2014-01-19 02:10:18 +04:00
cli_force = true ;
}
if ( rarray [ A_NSOPTS ] ) {
/* The NSOPTS/M parameter specified in the ReadArgs template is
* special . The / M means it collects all arguments that can ' t
* be assigned to any other parameter , and stores them in an
* array . We collect these and pass them as a fake argc / argv
* to nsoption_commandline ( ) .
* This trickery is necessary because if ReadArgs ( ) is called
* first , nsoption_commandline ( ) can no longer parse ( fetch ? )
* the arguments . If nsoption_commandline ( ) is called first ,
* then ReadArgs cannot fetch the arguments .
2016-09-10 20:37:18 +03:00
* \ todo this was totally broken so to stop startup crashing
* has been temporarily removed ( core cli not called when func
* returns NULL ) .
2014-01-19 02:10:18 +04:00
*/
}
} else {
2015-05-28 18:08:46 +03:00
LOG ( " ReadArgs failed to parse command line " ) ;
2014-01-19 02:10:18 +04:00
}
2016-09-10 20:37:18 +03:00
FreeArgs ( args ) ;
return NULL ;
2014-01-19 02:10:18 +04:00
}
2016-12-11 19:04:16 +03:00
static char * ami_gui_read_tooltypes ( struct WBArg * wbarg )
2015-11-22 03:06:10 +03:00
{
struct DiskObject * dobj ;
STRPTR * toolarray ;
char * s ;
2016-12-11 19:04:16 +03:00
char * current_user = NULL ;
2015-11-22 03:06:10 +03:00
if ( ( * wbarg - > wa_Name ) & & ( dobj = GetDiskObject ( wbarg - > wa_Name ) ) ) {
toolarray = ( STRPTR * ) dobj - > do_ToolTypes ;
if ( ( s = ( char * ) FindToolType ( toolarray , " USERSDIR " ) ) ) users_dir = ASPrintf ( " %s " , s ) ;
if ( ( s = ( char * ) FindToolType ( toolarray , " USER " ) ) ) current_user = ASPrintf ( " %s " , s ) ;
FreeDiskObject ( dobj ) ;
}
2016-12-11 19:04:16 +03:00
return current_user ;
2015-11-22 03:06:10 +03:00
}
2016-12-11 19:04:16 +03:00
static STRPTR ami_gui_read_all_tooltypes ( int argc , char * * argv )
2015-11-22 03:06:10 +03:00
{
struct WBStartup * WBenchMsg ;
struct WBArg * wbarg ;
2016-07-10 01:43:17 +03:00
char i = 0 ;
2016-12-11 19:04:16 +03:00
char * current_user = NULL ;
char * cur_user = NULL ;
2015-11-22 03:06:10 +03:00
if ( argc = = 0 ) { /* Started from WB */
WBenchMsg = ( struct WBStartup * ) argv ;
for ( i = 0 , wbarg = WBenchMsg - > sm_ArgList ; i < WBenchMsg - > sm_NumArgs ; i + + , wbarg + + ) {
2016-07-10 01:43:17 +03:00
LONG olddir = - 1 ;
2015-11-22 03:06:10 +03:00
if ( ( wbarg - > wa_Lock ) & & ( * wbarg - > wa_Name ) )
olddir = SetCurrentDir ( wbarg - > wa_Lock ) ;
2016-12-11 19:04:16 +03:00
cur_user = ami_gui_read_tooltypes ( wbarg ) ;
if ( cur_user ! = NULL ) {
if ( current_user ! = NULL ) FreeVec ( current_user ) ;
current_user = cur_user ;
}
2015-11-22 03:06:10 +03:00
if ( olddir ! = - 1 ) SetCurrentDir ( olddir ) ;
}
}
2016-12-11 19:04:16 +03:00
return current_user ;
2015-11-22 03:06:10 +03:00
}
2014-01-19 02:10:18 +04:00
static void gui_init2 ( int argc , char * * argv )
{
struct Screen * screen ;
BOOL notalreadyrunning ;
nsurl * url ;
nserror error ;
struct browser_window * bw = NULL ;
2016-06-02 02:14:10 +03:00
notalreadyrunning = ami_arexx_init ( & rxsig ) ;
2008-11-15 18:28:17 +03:00
2013-06-01 21:56:53 +04:00
/* ...and this ensures the treeview at least gets the WB colour palette to work with */
if ( scrn = = NULL ) {
2014-10-25 19:22:08 +04:00
if ( ( screen = LockPubScreen ( " Workbench " ) ) ) {
2013-06-01 21:56:53 +04:00
ami_set_screen_defaults ( screen ) ;
UnlockPubScreen ( NULL , screen ) ;
}
} else {
ami_set_screen_defaults ( scrn ) ;
}
2010-10-05 23:14:46 +04:00
/**/
2017-01-07 02:56:52 +03:00
hotlist_init ( nsoption_charp ( hotlist_file ) ) ;
2014-05-25 03:57:48 +04:00
search_web_select_provider ( nsoption_int ( search_provider ) ) ;
2009-12-22 02:25:35 +03:00
2014-01-19 02:10:18 +04:00
if ( notalreadyrunning & &
( nsoption_bool ( startup_no_window ) = = false ) )
ami_openscreenfirst ( ) ;
2010-03-28 20:42:33 +04:00
2014-01-19 02:10:18 +04:00
if ( temp_homepage_url & & notalreadyrunning ) {
error = nsurl_create ( temp_homepage_url , & url ) ;
if ( error = = NSERROR_OK ) {
2014-02-10 18:08:45 +04:00
error = browser_window_create ( BW_CREATE_HISTORY ,
2014-01-19 02:10:18 +04:00
url ,
NULL ,
NULL ,
& bw ) ;
nsurl_unref ( url ) ;
2008-11-16 17:42:40 +03:00
}
2014-01-19 02:10:18 +04:00
if ( error ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( messages_get_errorcode ( error ) , 0 ) ;
2014-01-19 02:10:18 +04:00
}
free ( temp_homepage_url ) ;
2008-11-09 02:08:55 +03:00
}
2014-01-19 02:10:18 +04:00
if ( cli_force = = true ) {
notalreadyrunning = TRUE ;
}
if ( argc = = 0 ) { // WB
2008-11-16 17:42:40 +03:00
struct WBStartup * WBenchMsg = ( struct WBStartup * ) argv ;
struct WBArg * wbarg ;
int first = 0 , i = 0 ;
char fullpath [ 1024 ] ;
for ( i = 0 , wbarg = WBenchMsg - > sm_ArgList ; i < WBenchMsg - > sm_NumArgs ; i + + , wbarg + + )
{
if ( i = = 0 ) continue ;
if ( ( wbarg - > wa_Lock ) & & ( * wbarg - > wa_Name ) )
{
2009-03-15 14:21:46 +03:00
DevNameFromLock ( wbarg - > wa_Lock , fullpath , 1024 , DN_FULLPATH ) ;
AddPart ( fullpath , wbarg - > wa_Name , 1024 ) ;
2008-11-16 17:42:40 +03:00
2014-05-27 02:43:36 +04:00
if ( ! temp_homepage_url ) {
2014-05-27 03:08:04 +04:00
nsurl * temp_url ;
2014-05-27 02:43:36 +04:00
if ( netsurf_path_to_nsurl ( fullpath , & temp_url ) = = NSERROR_OK ) {
2014-05-27 03:15:34 +04:00
temp_homepage_url = strdup ( nsurl_access ( temp_url ) ) ;
2014-05-27 02:43:36 +04:00
nsurl_unref ( temp_url ) ;
}
}
2008-11-16 17:42:40 +03:00
if ( notalreadyrunning )
{
2013-02-14 22:21:11 +04:00
error = nsurl_create ( temp_homepage_url , & url ) ;
if ( error = = NSERROR_OK ) {
if ( ! first )
{
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 ,
& bw ) ;
first = 1 ;
}
else
{
2014-02-10 18:08:45 +04:00
error = browser_window_create ( BW_CREATE_CLONE | BW_CREATE_HISTORY ,
2013-02-14 22:21:11 +04:00
url ,
NULL ,
bw ,
& bw ) ;
}
nsurl_unref ( url ) ;
2008-11-16 17:42:40 +03:00
}
2013-02-14 22:21:11 +04:00
if ( error ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( messages_get_errorcode ( error ) , 0 ) ;
2008-11-16 17:42:40 +03:00
}
free ( temp_homepage_url ) ;
temp_homepage_url = NULL ;
}
}
2015-11-22 03:06:10 +03:00
/* this should be where we read tooltypes, but it's too late for that now */
2008-11-16 17:42:40 +03:00
}
}
2013-06-02 19:26:25 +04:00
nsoption_setnull_charp ( homepage_url , ( char * ) strdup ( NETSURF_HOMEPAGE ) ) ;
2008-11-16 17:42:40 +03:00
if ( ! notalreadyrunning )
{
STRPTR sendcmd = NULL ;
2016-09-10 22:41:07 +03:00
char newtab [ 11 ] = " \0 " ;
2016-08-15 19:51:01 +03:00
if ( nsoption_bool ( tab_new_session ) = = true ) {
2016-09-10 22:41:07 +03:00
strcpy ( newtab , " TAB ACTIVE " ) ;
2016-08-15 19:51:01 +03:00
}
2008-11-16 17:42:40 +03:00
2016-06-02 02:09:30 +03:00
if ( temp_homepage_url ) {
2016-08-15 19:51:01 +03:00
sendcmd = ASPrintf ( " OPEN \" %s \" NEW%s " , temp_homepage_url , newtab ) ;
2008-11-16 17:42:40 +03:00
free ( temp_homepage_url ) ;
2016-06-02 02:09:30 +03:00
} else {
2016-08-15 19:51:01 +03:00
sendcmd = ASPrintf ( " OPEN \" %s \" NEW%s " , nsoption_charp ( homepage_url ) , newtab ) ;
2008-11-16 17:42:40 +03:00
}
2016-07-04 00:08:29 +03:00
ami_arexx_self ( sendcmd ) ;
2008-11-16 17:42:40 +03:00
FreeVec ( sendcmd ) ;
2011-06-19 15:16:48 +04:00
2016-09-10 22:41:07 +03:00
/* Bring the screen to the front. Intuition may have already done this, but it doesn't hurt. */
ami_arexx_self ( " TOFRONT " ) ;
2016-09-04 19:10:59 +03:00
2014-10-12 12:58:54 +04:00
ami_quit = true ;
2008-11-16 17:42:40 +03:00
return ;
2008-11-09 02:08:55 +03:00
}
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2009-09-28 22:00:40 +04:00
if ( IApplication )
{
2009-09-29 02:17:09 +04:00
if ( argc = = 0 )
{
2010-02-22 00:24:58 +03:00
ULONG noicon = TAG_IGNORE ;
2012-03-22 13:34:34 +04:00
if ( nsoption_bool ( hide_docky_icon ) )
noicon = REGAPP_NoIcon ;
2009-12-13 15:14:43 +03:00
2009-09-29 02:17:09 +04:00
ami_appid = RegisterApplication ( messages_get ( " NetSurf " ) ,
REGAPP_URLIdentifier , " netsurf-browser.org " ,
REGAPP_WBStartup , ( struct WBStartup * ) argv ,
2009-12-13 15:14:43 +03:00
noicon , TRUE ,
2009-09-29 02:17:09 +04:00
REGAPP_HasPrefsWindow , TRUE ,
REGAPP_CanCreateNewDocs , TRUE ,
REGAPP_UniqueApplication , TRUE ,
2013-10-12 13:26:28 +04:00
REGAPP_Description , messages_get ( " NetSurfDesc " ) ,
2009-09-29 02:17:09 +04:00
TAG_DONE ) ;
}
else
{
/* TODO: Specify icon when run from Shell */
ami_appid = RegisterApplication ( messages_get ( " NetSurf " ) ,
REGAPP_URLIdentifier , " netsurf-browser.org " ,
REGAPP_FileName , argv [ 0 ] ,
REGAPP_NoIcon , TRUE ,
REGAPP_HasPrefsWindow , TRUE ,
REGAPP_CanCreateNewDocs , TRUE ,
REGAPP_UniqueApplication , TRUE ,
2013-10-12 13:26:28 +04:00
REGAPP_Description , messages_get ( " NetSurfDesc " ) ,
2009-09-29 02:17:09 +04:00
TAG_DONE ) ;
}
2009-09-28 22:00:40 +04:00
GetApplicationAttrs ( ami_appid , APPATTR_Port , ( ULONG ) & applibport , TAG_DONE ) ;
2010-03-28 20:42:33 +04:00
if ( applibport ) applibsig = ( 1L < < applibport - > mp_SigBit ) ;
2009-09-28 22:00:40 +04:00
}
2015-01-17 20:06:48 +03:00
# endif
2013-02-14 22:21:11 +04:00
if ( ! bw & & ( nsoption_bool ( startup_no_window ) = = false ) ) {
error = nsurl_create ( nsoption_charp ( homepage_url ) , & 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-26 01:11:55 +03:00
amiga_warn_user ( messages_get_errorcode ( error ) , 0 ) ;
2013-02-14 22:21:11 +04:00
}
}
2008-08-02 18:31:32 +04:00
}
2014-10-26 16:11:05 +03:00
static void ami_update_buttons ( struct gui_window_2 * gwin )
{
2016-03-01 02:06:10 +03:00
long back = FALSE , forward = FALSE , tabclose = FALSE , stop = FALSE , reload = FALSE ;
long s_back , s_forward , s_tabclose , s_stop , s_reload ;
2014-10-26 16:11:05 +03:00
2014-11-16 17:44:40 +03:00
if ( ! browser_window_back_available ( gwin - > gw - > bw ) )
2014-10-26 16:11:05 +03:00
back = TRUE ;
2016-03-01 02:06:10 +03:00
if ( ! browser_window_forward_available ( gwin - > gw - > bw ) )
forward = TRUE ;
2014-10-26 16:11:05 +03:00
2014-11-16 17:44:40 +03:00
if ( ! browser_window_stop_available ( gwin - > gw - > bw ) )
2014-10-26 16:11:05 +03:00
stop = TRUE ;
2014-11-16 17:44:40 +03:00
if ( ! browser_window_reload_available ( gwin - > gw - > bw ) )
2014-10-26 16:11:05 +03:00
reload = TRUE ;
2017-01-14 23:51:51 +03:00
if ( nsoption_bool ( kiosk_mode ) = = false ) {
if ( gwin - > tabs < = 1 ) {
2014-10-26 16:11:05 +03:00
tabclose = TRUE ;
2017-01-15 19:05:07 +03:00
ami_gui_menu_set_disabled ( gwin - > win , gwin - > imenu , M_CLOSETAB , true ) ;
2017-01-14 23:51:51 +03:00
} else {
2017-01-15 19:05:07 +03:00
ami_gui_menu_set_disabled ( gwin - > win , gwin - > imenu , M_CLOSETAB , false ) ;
2014-10-26 16:11:05 +03:00
}
}
2016-03-01 02:06:10 +03:00
# ifdef __amigaos4__
2016-03-03 02:35:06 +03:00
GetAttr ( GA_Disabled , gwin - > objects [ GID_BACK ] , ( uint32 * ) & s_back ) ;
GetAttr ( GA_Disabled , gwin - > objects [ GID_FORWARD ] , ( uint32 * ) & s_forward ) ;
GetAttr ( GA_Disabled , gwin - > objects [ GID_RELOAD ] , ( uint32 * ) & s_reload ) ;
GetAttr ( GA_Disabled , gwin - > objects [ GID_STOP ] , ( uint32 * ) & s_stop ) ;
2016-03-01 02:06:10 +03:00
# endif
2016-03-03 02:35:06 +03:00
if ( BOOL_MISMATCH ( s_back , back ) )
2014-10-26 16:11:05 +03:00
SetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_BACK ] ,
gwin - > win , NULL , GA_Disabled , back , TAG_DONE ) ;
2016-03-03 02:35:06 +03:00
if ( BOOL_MISMATCH ( s_forward , forward ) )
2014-10-26 16:11:05 +03:00
SetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_FORWARD ] ,
gwin - > win , NULL , GA_Disabled , forward , TAG_DONE ) ;
2016-03-03 02:35:06 +03:00
if ( BOOL_MISMATCH ( s_reload , reload ) )
2014-10-26 16:11:05 +03:00
SetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_RELOAD ] ,
gwin - > win , NULL , GA_Disabled , reload , TAG_DONE ) ;
2016-03-03 02:35:06 +03:00
if ( BOOL_MISMATCH ( s_stop , stop ) )
2014-10-26 16:11:05 +03:00
SetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_STOP ] ,
gwin - > win , NULL , GA_Disabled , stop , TAG_DONE ) ;
2016-01-31 20:18:49 +03:00
if ( ClickTabBase - > lib_Version < 53 ) {
if ( gwin - > tabs < = 1 ) tabclose = TRUE ;
2016-03-01 02:06:10 +03:00
# ifdef __amigaos4__
2016-03-03 02:35:06 +03:00
GetAttr ( GA_Disabled , gwin - > objects [ GID_CLOSETAB ] , ( uint32 * ) & s_tabclose ) ;
2016-03-01 02:06:10 +03:00
# endif
2016-03-03 02:35:06 +03:00
if ( BOOL_MISMATCH ( s_tabclose , tabclose ) )
2014-10-26 16:11:05 +03:00
SetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_CLOSETAB ] ,
gwin - > win , NULL , GA_Disabled , tabclose , TAG_DONE ) ;
}
2015-09-04 02:26:52 +03:00
/* Update the back/forward buttons history context menu */
ami_ctxmenu_history_create ( AMI_CTXMENU_HISTORY_BACK , gwin ) ;
ami_ctxmenu_history_create ( AMI_CTXMENU_HISTORY_FORWARD , gwin ) ;
2014-10-26 16:11:05 +03:00
}
2010-03-29 20:59:30 +04:00
2011-06-03 22:08:17 +04:00
void ami_gui_history ( struct gui_window_2 * gwin , bool back )
{
if ( back = = true )
{
2014-11-16 17:44:40 +03:00
if ( browser_window_back_available ( gwin - > gw - > bw ) )
browser_window_history_back ( gwin - > gw - > bw , false ) ;
2011-06-03 22:08:17 +04:00
}
else
{
2014-11-16 17:44:40 +03:00
if ( browser_window_forward_available ( gwin - > gw - > bw ) )
browser_window_history_forward ( gwin - > gw - > bw , false ) ;
2011-06-03 22:08:17 +04:00
}
ami_update_buttons ( gwin ) ;
}
2009-11-03 02:02:53 +03:00
int ami_key_to_nskey ( ULONG keycode , struct InputEvent * ie )
{
int nskey = 0 , chars ;
2014-10-25 19:22:08 +04:00
char buffer [ 20 ] ;
2011-09-13 01:56:15 +04:00
char * utf8 = NULL ;
2009-11-03 02:02:53 +03:00
if ( keycode > = IECODE_UP_PREFIX ) return 0 ;
switch ( keycode )
{
case RAWKEY_CRSRUP :
2016-08-12 22:32:09 +03:00
if ( ie - > ie_Qualifier & NSA_QUAL_SHIFT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_PAGE_UP ;
2016-08-12 22:32:09 +03:00
} else if ( ie - > ie_Qualifier & NSA_QUAL_ALT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_TEXT_START ;
2009-11-03 02:02:53 +03:00
}
2015-03-27 12:36:19 +03:00
else nskey = NS_KEY_UP ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_CRSRDOWN :
2016-08-12 22:32:09 +03:00
if ( ie - > ie_Qualifier & NSA_QUAL_SHIFT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_PAGE_DOWN ;
2016-08-12 22:32:09 +03:00
} else if ( ie - > ie_Qualifier & NSA_QUAL_ALT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_TEXT_END ;
2009-11-03 02:02:53 +03:00
}
2015-03-27 12:36:19 +03:00
else nskey = NS_KEY_DOWN ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_CRSRLEFT :
2016-08-12 22:32:09 +03:00
if ( ie - > ie_Qualifier & NSA_QUAL_SHIFT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_LINE_START ;
2016-08-12 22:32:09 +03:00
} else if ( ie - > ie_Qualifier & NSA_QUAL_ALT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_WORD_LEFT ;
2009-11-03 02:02:53 +03:00
}
2015-03-27 12:36:19 +03:00
else nskey = NS_KEY_LEFT ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_CRSRRIGHT :
2016-08-12 22:32:09 +03:00
if ( ie - > ie_Qualifier & NSA_QUAL_SHIFT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_LINE_END ;
2016-08-12 22:32:09 +03:00
} else if ( ie - > ie_Qualifier & NSA_QUAL_ALT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_WORD_RIGHT ;
2009-11-03 02:02:53 +03:00
}
2015-03-27 12:36:19 +03:00
else nskey = NS_KEY_RIGHT ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_ESC :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_ESCAPE ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_PAGEUP :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_PAGE_UP ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_PAGEDOWN :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_PAGE_DOWN ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_HOME :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_TEXT_START ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_END :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_TEXT_END ;
2009-11-03 02:02:53 +03:00
break ;
case RAWKEY_BACKSPACE :
2016-08-12 22:32:09 +03:00
if ( ie - > ie_Qualifier & NSA_QUAL_SHIFT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_DELETE_LINE_START ;
2016-08-12 22:32:09 +03:00
} else {
nskey = NS_KEY_DELETE_LEFT ;
2009-11-03 02:02:53 +03:00
}
break ;
case RAWKEY_DEL :
2016-08-12 22:32:09 +03:00
if ( ie - > ie_Qualifier & NSA_QUAL_SHIFT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_DELETE_LINE_END ;
2016-08-12 22:32:09 +03:00
} else {
nskey = NS_KEY_DELETE_RIGHT ;
2009-11-03 02:02:53 +03:00
}
break ;
case RAWKEY_TAB :
2016-08-12 22:32:09 +03:00
if ( ie - > ie_Qualifier & NSA_QUAL_SHIFT ) {
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_SHIFT_TAB ;
2016-08-12 22:32:09 +03:00
} else {
nskey = NS_KEY_TAB ;
2009-11-03 02:02:53 +03:00
}
break ;
2009-11-04 11:06:52 +03:00
case RAWKEY_F5 :
2015-11-16 03:16:52 +03:00
case RAWKEY_F8 :
case RAWKEY_F9 :
case RAWKEY_F10 :
2013-01-25 00:00:09 +04:00
case RAWKEY_HELP :
2009-11-04 11:06:52 +03:00
// don't translate
nskey = keycode ;
break ;
2009-11-03 02:02:53 +03:00
default :
2015-01-03 17:20:47 +03:00
if ( ( chars = MapRawKey ( ie , buffer , 20 , NULL ) ) > 0 ) {
2016-12-12 02:04:13 +03:00
if ( utf8_from_local_encoding ( buffer , chars , & utf8 ) ! = NSERROR_OK ) return 0 ;
2011-09-13 01:56:15 +04:00
nskey = utf8_to_ucs4 ( utf8 , utf8_char_byte_length ( utf8 ) ) ;
2016-12-12 02:04:13 +03:00
free ( utf8 ) ;
2015-01-03 17:20:47 +03:00
if ( ie - > ie_Qualifier & IEQUALIFIER_RCOMMAND ) {
switch ( nskey ) {
case ' a ' :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_SELECT_ALL ;
2015-01-03 17:20:47 +03:00
break ;
case ' c ' :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_COPY_SELECTION ;
2015-01-03 17:20:47 +03:00
break ;
case ' v ' :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_PASTE ;
2015-01-03 17:20:47 +03:00
break ;
case ' x ' :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_CUT_SELECTION ;
2015-01-03 17:20:47 +03:00
break ;
case ' y ' :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_REDO ;
2015-01-03 17:20:47 +03:00
break ;
case ' z ' :
2015-03-27 12:36:19 +03:00
nskey = NS_KEY_UNDO ;
2015-01-03 17:20:47 +03:00
break ;
}
}
2009-11-03 02:02:53 +03:00
}
break ;
}
2015-01-03 17:20:47 +03:00
2009-11-03 02:02:53 +03:00
return nskey ;
}
2017-01-01 19:45:27 +03:00
int ami_gui_get_quals ( Object * win_obj )
2009-01-11 00:31:21 +03:00
{
2009-01-11 02:10:54 +03:00
uint32 quals = 0 ;
2017-01-01 19:45:27 +03:00
int key_state = 0 ;
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2017-01-01 19:45:27 +03:00
GetAttr ( WINDOW_Qualifier , win_obj , ( uint32 * ) & quals ) ;
2015-01-17 20:06:48 +03:00
# else
# warning qualifier needs fixing for OS3
# endif
2009-01-11 00:31:21 +03:00
2016-08-12 22:32:09 +03:00
if ( quals & NSA_QUAL_SHIFT ) {
2017-01-01 19:45:27 +03:00
key_state | = BROWSER_MOUSE_MOD_1 ;
2009-01-11 00:31:21 +03:00
}
2016-08-12 22:32:09 +03:00
if ( quals & IEQUALIFIER_CONTROL ) {
2017-01-01 19:45:27 +03:00
key_state | = BROWSER_MOUSE_MOD_2 ;
2009-01-11 00:31:21 +03:00
}
2009-09-01 01:48:57 +04:00
2016-08-12 22:32:09 +03:00
if ( quals & NSA_QUAL_ALT ) {
2017-01-01 19:45:27 +03:00
key_state | = BROWSER_MOUSE_MOD_3 ;
2009-09-01 01:48:57 +04:00
}
2017-01-01 19:45:27 +03:00
return key_state ;
}
static void ami_update_quals ( struct gui_window_2 * gwin )
{
gwin - > key_state = ami_gui_get_quals ( gwin - > objects [ OID_MAIN ] ) ;
2009-01-11 00:31:21 +03:00
}
2014-11-15 16:52:06 +03:00
/* exported interface documented in amiga/gui.h */
nserror ami_gui_get_space_box ( Object * obj , struct IBox * * bbox )
2014-11-15 16:46:23 +03:00
{
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2016-03-03 02:53:25 +03:00
if ( LIB_IS_AT_LEAST ( ( struct Library * ) SpaceBase , 53 , 6 ) ) {
2016-11-20 00:02:42 +03:00
* bbox = malloc ( sizeof ( struct IBox ) ) ;
2014-11-15 16:46:23 +03:00
if ( * bbox = = NULL ) return NSERROR_NOMEM ;
GetAttr ( SPACE_RenderBox , obj , ( ULONG * ) * bbox ) ;
2016-03-03 02:53:25 +03:00
} else
2015-01-17 20:06:48 +03:00
# endif
2016-03-03 02:53:25 +03:00
{
2014-11-15 16:46:23 +03:00
GetAttr ( SPACE_AreaBox , obj , ( ULONG * ) bbox ) ;
}
return NSERROR_OK ;
}
2014-11-15 16:52:06 +03:00
/* exported interface documented in amiga/gui.h */
void ami_gui_free_space_box ( struct IBox * bbox )
2014-11-15 16:46:23 +03:00
{
2016-03-03 02:53:25 +03:00
# ifdef __amigaos4__
2014-11-15 16:46:23 +03:00
if ( LIB_IS_AT_LEAST ( ( struct Library * ) SpaceBase , 53 , 6 ) ) {
2016-11-20 00:02:42 +03:00
free ( bbox ) ;
2014-11-15 16:46:23 +03:00
}
2016-03-03 02:53:25 +03:00
# endif
2014-11-15 16:46:23 +03:00
}
2016-07-03 20:48:46 +03:00
static bool ami_spacebox_to_ns_coords ( struct gui_window_2 * gwin ,
int * restrict x , int * restrict y , int space_x , int space_y )
2013-02-03 22:50:16 +04:00
{
int ns_x = space_x ;
int ns_y = space_y ;
2014-12-04 14:42:12 +03:00
ns_x / = gwin - > gw - > scale ;
ns_y / = gwin - > gw - > scale ;
2013-02-03 22:50:16 +04:00
2014-11-16 17:44:40 +03:00
ns_x + = gwin - > gw - > scrollx ;
ns_y + = gwin - > gw - > scrolly ;
2013-02-03 22:50:16 +04:00
* x = ns_x ;
* y = ns_y ;
return true ;
}
2016-07-03 20:48:46 +03:00
bool ami_mouse_to_ns_coords ( struct gui_window_2 * gwin , int * restrict x , int * restrict y ,
2011-12-02 16:47:11 +04:00
int mouse_x , int mouse_y )
2011-11-30 00:58:57 +04:00
{
int ns_x , ns_y ;
struct IBox * bbox ;
2011-12-02 16:47:11 +04:00
if ( mouse_x = = - 1 ) mouse_x = gwin - > win - > MouseX ;
if ( mouse_y = = - 1 ) mouse_y = gwin - > win - > MouseY ;
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) = = NSERROR_OK ) {
ns_x = ( ULONG ) ( mouse_x - bbox - > Left ) ;
ns_y = ( ULONG ) ( mouse_y - bbox - > Top ) ;
2011-11-30 00:58:57 +04:00
2014-11-15 16:46:23 +03:00
if ( ( ns_x < 0 ) | | ( ns_x > bbox - > Width ) | | ( ns_y < 0 ) | | ( ns_y > bbox - > Height ) )
return false ;
2011-11-30 00:58:57 +04:00
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
} else {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2011-11-30 00:58:57 +04:00
return false ;
2014-11-15 16:46:23 +03:00
}
2011-11-30 00:58:57 +04:00
2013-02-03 22:50:16 +04:00
return ami_spacebox_to_ns_coords ( gwin , x , y , ns_x , ns_y ) ;
2011-11-30 00:58:57 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_gui_scroll_internal ( struct gui_window_2 * gwin , int xs , int ys )
2011-12-24 02:14:00 +04:00
{
struct IBox * bbox ;
int x , y ;
if ( ami_mouse_to_ns_coords ( gwin , & x , & y , - 1 , - 1 ) = = true )
{
2014-11-16 17:44:40 +03:00
if ( browser_window_scroll_at_point ( gwin - > gw - > bw , x , y ,
2011-12-24 02:14:00 +04:00
xs , ys ) = = false )
{
2014-12-04 15:14:16 +03:00
int width , height ;
2014-11-16 17:44:40 +03:00
gui_window_get_scroll ( gwin - > gw ,
& gwin - > gw - > scrollx ,
& gwin - > gw - > scrolly ) ;
2011-12-24 02:14:00 +04:00
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2014-12-04 15:14:16 +03:00
browser_window_get_extents ( gwin - > gw - > bw , false , & width , & height ) ;
2011-12-24 02:14:00 +04:00
switch ( xs )
{
case SCROLL_PAGE_UP :
2014-11-16 17:44:40 +03:00
xs = gwin - > gw - > scrollx - bbox - > Width ;
2011-12-24 02:14:00 +04:00
break ;
case SCROLL_PAGE_DOWN :
2014-11-16 17:44:40 +03:00
xs = gwin - > gw - > scrollx + bbox - > Width ;
2011-12-24 02:14:00 +04:00
break ;
case SCROLL_TOP :
xs = 0 ;
break ;
case SCROLL_BOTTOM :
2014-12-04 15:14:16 +03:00
xs = width ;
2011-12-24 02:14:00 +04:00
break ;
default :
2014-11-16 17:44:40 +03:00
xs + = gwin - > gw - > scrollx ;
2011-12-24 02:14:00 +04:00
break ;
}
switch ( ys )
{
case SCROLL_PAGE_UP :
2014-11-16 17:44:40 +03:00
ys = gwin - > gw - > scrolly - bbox - > Height ;
2011-12-24 02:14:00 +04:00
break ;
case SCROLL_PAGE_DOWN :
2014-11-16 17:44:40 +03:00
ys = gwin - > gw - > scrolly + bbox - > Height ;
2011-12-24 02:14:00 +04:00
break ;
case SCROLL_TOP :
ys = 0 ;
break ;
case SCROLL_BOTTOM :
2014-12-04 15:14:16 +03:00
ys = height ;
2011-12-24 02:14:00 +04:00
break ;
default :
2014-11-16 17:44:40 +03:00
ys + = gwin - > gw - > scrolly ;
2011-12-24 02:14:00 +04:00
break ;
}
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2014-11-16 17:44:40 +03:00
gui_window_set_scroll ( gwin - > gw , xs , ys ) ;
2011-12-24 02:14:00 +04:00
}
}
}
2014-10-16 12:55:01 +04:00
static struct IBox * ami_ns_rect_to_ibox ( struct gui_window_2 * gwin , const struct rect * rect )
2012-01-12 01:41:55 +04:00
{
struct IBox * bbox , * ibox ;
2016-11-20 00:02:42 +03:00
ibox = malloc ( sizeof ( struct IBox ) ) ;
2012-01-12 01:41:55 +04:00
if ( ibox = = NULL ) return NULL ;
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return NULL ;
}
2012-01-12 01:41:55 +04:00
2014-12-04 14:42:12 +03:00
ibox - > Left = gwin - > win - > MouseX + ( rect - > x0 * gwin - > gw - > scale ) ;
ibox - > Top = gwin - > win - > MouseY + ( rect - > y0 * gwin - > gw - > scale ) ;
2012-01-12 01:41:55 +04:00
2014-12-04 14:42:12 +03:00
ibox - > Width = ( rect - > x1 - rect - > x0 ) * gwin - > gw - > scale ;
ibox - > Height = ( rect - > y1 - rect - > y0 ) * gwin - > gw - > scale ;
2012-01-12 01:41:55 +04:00
if ( ibox - > Left < bbox - > Left ) ibox - > Left = bbox - > Left ;
if ( ibox - > Top < bbox - > Top ) ibox - > Top = bbox - > Top ;
if ( ( ibox - > Left > ( bbox - > Left + bbox - > Width ) ) | |
( ibox - > Top > ( bbox - > Top + bbox - > Height ) ) | |
( ibox - > Width < 0 ) | | ( ibox - > Height < 0 ) )
{
2016-11-20 00:02:42 +03:00
free ( ibox ) ;
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2012-01-12 01:41:55 +04:00
return NULL ;
}
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
return ibox ;
2012-01-12 01:41:55 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_gui_trap_mouse ( struct gui_window_2 * gwin )
2012-01-12 01:41:55 +04:00
{
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2012-01-12 01:41:55 +04:00
switch ( gwin - > drag_op )
{
case GDRAGGING_NONE :
case GDRAGGING_SCROLLBAR :
case GDRAGGING_OTHER :
break ;
default :
if ( gwin - > ptr_lock )
{
SetWindowAttrs ( gwin - > win , WA_GrabFocus , 10 ,
WA_MouseLimits , gwin - > ptr_lock , TAG_DONE ) ;
}
break ;
}
2015-01-17 20:06:48 +03:00
# endif
2012-01-12 01:41:55 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_gui_menu_update_all ( void )
2012-12-15 19:39:09 +04:00
{
struct nsObject * node ;
struct nsObject * nnode ;
struct gui_window_2 * gwin ;
if ( IsMinListEmpty ( window_list ) ) return ;
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
do {
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
gwin = node - > objstruct ;
if ( node - > Type = = AMINS_WINDOW )
{
2017-01-15 19:05:07 +03:00
ami_gui_menu_update_checked ( gwin ) ;
2012-12-15 19:39:09 +04:00
}
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2012-12-15 19:39:09 +04:00
}
2016-07-03 20:48:46 +03:00
static void gui_window_get_dimensions ( struct gui_window * g ,
int * restrict width , int * restrict height , bool scaled )
2014-10-25 23:03:14 +04:00
{
struct IBox * bbox ;
if ( ! g ) return ;
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) g - > shared - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2014-10-25 23:03:14 +04:00
* width = bbox - > Width ;
* height = bbox - > Height ;
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2014-10-25 23:03:14 +04:00
if ( scaled )
{
2014-12-04 14:42:12 +03:00
* width / = g - > scale ;
* height / = g - > scale ;
2014-10-25 23:03:14 +04:00
}
}
2014-10-26 19:35:05 +03:00
/* Add a horizontal scroller, if not already present
* Returns true if changed , false otherwise */
static bool ami_gui_hscroll_add ( struct gui_window_2 * gwin )
{
struct TagItem attrs [ 2 ] ;
if ( gwin - > objects [ GID_HSCROLL ] ! = NULL ) return false ;
attrs [ 0 ] . ti_Tag = CHILD_MinWidth ;
attrs [ 0 ] . ti_Data = 0 ;
attrs [ 1 ] . ti_Tag = TAG_DONE ;
attrs [ 1 ] . ti_Data = 0 ;
2015-01-25 15:45:20 +03:00
gwin - > objects [ GID_HSCROLL ] = ScrollerObj ,
2014-10-26 19:35:05 +03:00
GA_ID , GID_HSCROLL ,
GA_RelVerify , TRUE ,
SCROLLER_Orientation , SORIENT_HORIZ ,
ICA_TARGET , ICTARGET_IDCMP ,
ScrollerEnd ;
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2014-10-26 19:35:05 +03:00
IDoMethod ( gwin - > objects [ GID_HSCROLLLAYOUT ] , LM_ADDCHILD ,
gwin - > win , gwin - > objects [ GID_HSCROLL ] , attrs ) ;
2015-01-17 20:06:48 +03:00
# else
2015-01-31 14:59:31 +03:00
SetAttrs ( gwin - > objects [ GID_HSCROLLLAYOUT ] ,
LAYOUT_AddChild , gwin - > objects [ GID_HSCROLL ] , TAG_MORE , & attrs ) ;
2015-01-17 20:06:48 +03:00
# endif
2014-10-26 19:35:05 +03:00
return true ;
}
/* Remove the horizontal scroller, if present */
static bool ami_gui_hscroll_remove ( struct gui_window_2 * gwin )
{
if ( gwin - > objects [ GID_HSCROLL ] = = NULL ) return false ;
2015-01-29 22:18:49 +03:00
# ifdef __amigaos4__
2014-10-26 19:35:05 +03:00
IDoMethod ( gwin - > objects [ GID_HSCROLLLAYOUT ] , LM_REMOVECHILD ,
gwin - > win , gwin - > objects [ GID_HSCROLL ] ) ;
2015-01-29 22:18:49 +03:00
# else
2017-01-02 21:41:40 +03:00
SetAttrs ( gwin - > objects [ GID_HSCROLLLAYOUT ] , LAYOUT_RemoveChild , gwin - > objects [ GID_HSCROLL ] , TAG_DONE ) ;
2015-01-29 22:18:49 +03:00
# endif
2014-10-26 19:35:05 +03:00
gwin - > objects [ GID_HSCROLL ] = NULL ;
2015-01-29 22:18:49 +03:00
2014-10-26 19:35:05 +03:00
return true ;
}
2014-10-25 23:03:14 +04:00
/* Add a vertical scroller, if not already present
* Returns true if changed , false otherwise */
static bool ami_gui_vscroll_add ( struct gui_window_2 * gwin )
{
struct TagItem attrs [ 2 ] ;
if ( gwin - > objects [ GID_VSCROLL ] ! = NULL ) return false ;
attrs [ 0 ] . ti_Tag = CHILD_MinWidth ;
attrs [ 0 ] . ti_Data = 0 ;
attrs [ 1 ] . ti_Tag = TAG_DONE ;
attrs [ 1 ] . ti_Data = 0 ;
2015-01-25 15:45:20 +03:00
gwin - > objects [ GID_VSCROLL ] = ScrollerObj ,
2014-10-25 23:03:14 +04:00
GA_ID , GID_VSCROLL ,
GA_RelVerify , TRUE ,
ICA_TARGET , ICTARGET_IDCMP ,
ScrollerEnd ;
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2014-10-25 23:03:14 +04:00
IDoMethod ( gwin - > objects [ GID_VSCROLLLAYOUT ] , LM_ADDCHILD ,
gwin - > win , gwin - > objects [ GID_VSCROLL ] , attrs ) ;
2015-01-20 23:46:36 +03:00
# else
2015-01-31 14:59:31 +03:00
SetAttrs ( gwin - > objects [ GID_VSCROLLLAYOUT ] ,
LAYOUT_AddChild , gwin - > objects [ GID_VSCROLL ] , TAG_MORE , & attrs ) ;
2015-01-17 20:06:48 +03:00
# endif
2014-10-25 23:03:14 +04:00
return true ;
}
/* Remove the vertical scroller, if present */
static bool ami_gui_vscroll_remove ( struct gui_window_2 * gwin )
{
if ( gwin - > objects [ GID_VSCROLL ] = = NULL ) return false ;
2015-01-29 22:18:49 +03:00
# ifdef __amigaos4__
2014-10-25 23:03:14 +04:00
IDoMethod ( gwin - > objects [ GID_VSCROLLLAYOUT ] , LM_REMOVECHILD ,
gwin - > win , gwin - > objects [ GID_VSCROLL ] ) ;
2015-01-29 22:18:49 +03:00
# else
2017-01-02 21:41:40 +03:00
SetAttrs ( gwin - > objects [ GID_VSCROLLLAYOUT ] , LAYOUT_RemoveChild , gwin - > objects [ GID_VSCROLL ] , TAG_DONE ) ;
2015-01-29 22:18:49 +03:00
# endif
2014-10-25 23:03:14 +04:00
gwin - > objects [ GID_VSCROLL ] = NULL ;
2015-01-29 22:18:49 +03:00
2014-10-25 23:03:14 +04:00
return true ;
}
/**
* Check the scroll bar requirements for a browser window , and add / remove
* the vertical scroller as appropriate . This should be the main entry
* point used to perform this task .
*
* \ param gwin " Shared " GUI window to check the state of
*/
2014-10-27 00:30:19 +03:00
static void ami_gui_scroller_update ( struct gui_window_2 * gwin )
2014-10-25 23:03:14 +04:00
{
2014-10-26 19:35:05 +03:00
int h = 1 , w = 1 , wh = 0 , ww = 0 ;
bool rethinkv = false ;
bool rethinkh = false ;
2014-10-25 23:03:14 +04:00
browser_scrolling hscroll = BW_SCROLLING_YES ;
browser_scrolling vscroll = BW_SCROLLING_YES ;
2014-11-16 17:44:40 +03:00
browser_window_get_scrollbar_type ( gwin - > gw - > bw , & hscroll , & vscroll ) ;
2014-10-25 23:03:14 +04:00
2014-11-16 17:44:40 +03:00
if ( browser_window_is_frameset ( gwin - > gw - > bw ) = = true ) {
2014-10-26 19:35:05 +03:00
rethinkv = ami_gui_vscroll_remove ( gwin ) ;
rethinkh = ami_gui_hscroll_remove ( gwin ) ;
2014-10-25 23:03:14 +04:00
} else {
2014-11-16 17:44:40 +03:00
if ( ( browser_window_get_extents ( gwin - > gw - > bw , false , & w , & h ) = = NSERROR_OK ) ) {
gui_window_get_dimensions ( gwin - > gw , & ww , & wh , false ) ;
2014-10-26 19:35:05 +03:00
}
if ( vscroll = = BW_SCROLLING_NO ) {
rethinkv = ami_gui_vscroll_remove ( gwin ) ;
} else {
if ( h > wh ) rethinkv = ami_gui_vscroll_add ( gwin ) ;
else rethinkv = ami_gui_vscroll_remove ( gwin ) ;
}
if ( hscroll = = BW_SCROLLING_NO ) {
rethinkh = ami_gui_hscroll_remove ( gwin ) ;
2014-10-25 23:03:14 +04:00
} else {
2014-10-26 19:35:05 +03:00
if ( w > ww ) rethinkh = ami_gui_hscroll_add ( gwin ) ;
else rethinkh = ami_gui_hscroll_remove ( gwin ) ;
2014-10-25 23:03:14 +04:00
}
}
2014-10-26 19:35:05 +03:00
if ( rethinkv | | rethinkh ) {
2014-10-25 23:03:14 +04:00
FlushLayoutDomainCache ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ) ;
RethinkLayout ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ,
gwin - > win , NULL , TRUE ) ;
2014-11-16 17:44:40 +03:00
browser_window_schedule_reformat ( gwin - > gw - > bw ) ;
2014-10-25 23:03:14 +04:00
}
}
2014-01-12 21:07:34 +04:00
/**
* function to add retrieved favicon to gui
*/
2016-06-06 10:59:23 +03:00
static void gui_window_set_icon ( struct gui_window * g , struct hlcache_handle * icon )
2014-01-12 21:07:34 +04:00
{
struct BitMap * bm = NULL ;
struct IBox * bbox ;
2014-10-25 19:22:08 +04:00
struct bitmap * icon_bitmap = NULL ;
2014-01-12 21:07:34 +04:00
if ( nsoption_bool ( kiosk_mode ) = = true ) return ;
if ( ! g ) return ;
if ( ( icon ! = NULL ) & & ( ( icon_bitmap = content_get_bitmap ( icon ) ) ! = NULL ) )
{
2017-02-13 21:41:38 +03:00
bm = ami_bitmap_get_native ( icon_bitmap , 16 , 16 , ami_plot_screen_is_palettemapped ( ) ,
2014-01-12 21:07:34 +04:00
g - > shared - > win - > RPort - > BitMap ) ;
}
2015-01-03 02:14:49 +03:00
if ( g = = g - > shared - > gw ) {
2014-01-12 21:07:34 +04:00
RefreshGList ( ( struct Gadget * ) g - > shared - > objects [ GID_ICON ] ,
g - > shared - > win , NULL , 1 ) ;
if ( bm )
{
ULONG tag , tag_data , minterm ;
if ( ami_plot_screen_is_palettemapped ( ) = = false ) {
tag = BLITA_UseSrcAlpha ;
2016-03-22 22:26:36 +03:00
tag_data = ! amiga_bitmap_get_opaque ( icon_bitmap ) ;
2014-01-12 21:07:34 +04:00
minterm = 0xc0 ;
} else {
tag = BLITA_MaskPlane ;
tag_data = ( ULONG ) ami_bitmap_get_mask ( icon_bitmap , 16 , 16 , bm ) ;
2015-09-01 20:02:32 +03:00
minterm = MINTERM_SRCMASK ;
2014-01-12 21:07:34 +04:00
}
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) g - > shared - > objects [ GID_ICON ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2015-01-31 15:41:34 +03:00
EraseRect ( g - > shared - > win - > RPort , bbox - > Left , bbox - > Top ,
bbox - > Left + 16 , bbox - > Top + 16 ) ;
2015-01-18 21:50:01 +03:00
# ifdef __amigaos4__
2014-01-12 21:07:34 +04:00
BltBitMapTags ( BLITA_SrcX , 0 ,
BLITA_SrcY , 0 ,
BLITA_DestX , bbox - > Left ,
BLITA_DestY , bbox - > Top ,
BLITA_Width , 16 ,
BLITA_Height , 16 ,
BLITA_Source , bm ,
BLITA_Dest , g - > shared - > win - > RPort ,
BLITA_SrcType , BLITT_BITMAP ,
BLITA_DestType , BLITT_RASTPORT ,
BLITA_Minterm , minterm ,
tag , tag_data ,
TAG_DONE ) ;
2015-01-18 21:50:01 +03:00
# else
2015-02-01 13:58:40 +03:00
if ( tag_data ) {
BltMaskBitMapRastPort ( bm , 0 , 0 , g - > shared - > win - > RPort ,
bbox - > Left , bbox - > Top , 16 , 16 , minterm , tag_data ) ;
} else {
BltBitMapRastPort ( bm , 0 , 0 , g - > shared - > win - > RPort ,
bbox - > Left , bbox - > Top , 16 , 16 , 0xc0 ) ;
}
2015-01-18 21:50:01 +03:00
# endif
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2014-01-12 21:07:34 +04:00
}
}
g - > favicon = icon ;
}
2014-07-05 22:00:21 +04:00
static void ami_gui_refresh_favicon ( void * p )
{
struct gui_window_2 * gwin = ( struct gui_window_2 * ) p ;
2014-11-16 17:44:40 +03:00
gui_window_set_icon ( gwin - > gw , gwin - > gw - > favicon ) ;
2014-07-05 22:00:21 +04:00
}
2014-10-26 20:00:18 +03:00
/* Gets the size that border gadget 1 (status) needs to be.
2014-10-26 20:08:23 +03:00
* Returns the width of the size gadget as a convenience .
2014-10-26 20:00:18 +03:00
*/
2016-01-11 22:10:59 +03:00
# ifdef __amigaos4__
2016-07-03 20:48:46 +03:00
static ULONG ami_get_border_gadget_size ( struct gui_window_2 * gwin ,
ULONG * restrict width , ULONG * restrict height )
2014-10-26 20:00:18 +03:00
{
2016-01-11 22:10:59 +03:00
static ULONG sz_gad_width = 0 ;
static ULONG sz_gad_height = 0 ;
2014-10-26 20:00:18 +03:00
ULONG available_width ;
2016-01-11 22:10:59 +03:00
2014-10-26 20:00:18 +03:00
if ( ( sz_gad_width = = 0 ) | | ( sz_gad_height = = 0 ) ) {
struct DrawInfo * dri = GetScreenDrawInfo ( scrn ) ;
GetGUIAttrs ( NULL , dri ,
GUIA_SizeGadgetWidth , & sz_gad_width ,
GUIA_SizeGadgetHeight , & sz_gad_height ,
TAG_DONE ) ;
FreeScreenDrawInfo ( scrn , dri ) ;
}
available_width = gwin - > win - > Width - scrn - > WBorLeft - sz_gad_width ;
* width = available_width ;
* height = sz_gad_height ;
return sz_gad_width ;
}
2016-01-11 22:10:59 +03:00
# endif
2014-10-26 20:00:18 +03:00
static void ami_set_border_gadget_size ( struct gui_window_2 * gwin )
{
2016-01-11 22:10:59 +03:00
# ifdef __amigaos4__
2014-10-26 20:00:18 +03:00
/* Reset gadget widths according to new calculation */
2016-01-15 22:58:24 +03:00
ULONG size1 , size2 ;
2014-10-26 20:00:18 +03:00
2016-01-15 22:58:24 +03:00
ami_get_border_gadget_size ( gwin , & size1 , & size2 ) ;
2014-10-26 20:00:18 +03:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) ( APTR ) gwin - > objects [ GID_STATUS ] ,
gwin - > win , NULL ,
GA_Width , size1 ,
TAG_DONE ) ;
RefreshWindowFrame ( gwin - > win ) ;
2016-01-11 22:10:59 +03:00
# endif
2014-10-26 20:00:18 +03:00
}
2016-12-31 03:51:05 +03:00
static BOOL ami_handle_msg ( void )
2008-08-02 18:31:32 +04:00
{
2016-12-30 03:59:12 +03:00
struct ami_generic_window * w = NULL ;
2008-08-09 19:19:04 +04:00
struct nsObject * node ;
struct nsObject * nnode ;
2016-12-31 03:51:05 +03:00
BOOL win_closed = FALSE ;
2008-08-02 18:31:32 +04:00
2016-12-31 03:51:05 +03:00
if ( IsMinListEmpty ( window_list ) ) {
2008-12-06 13:43:25 +03:00
/* no windows in list, so NetSurf should not be running */
2009-10-03 15:00:10 +04:00
ami_try_quit ( ) ;
2016-12-31 03:51:05 +03:00
return FALSE ;
2008-12-06 13:43:25 +03:00
}
2008-10-06 22:20:16 +04:00
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
2008-08-02 18:31:32 +04:00
2016-12-30 03:59:12 +03:00
do {
2008-10-06 22:20:16 +04:00
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
2016-12-30 03:59:12 +03:00
w = node - > objstruct ;
2016-12-31 03:51:05 +03:00
if ( w = = NULL ) continue ;
2008-08-09 19:19:04 +04:00
2016-12-31 03:51:05 +03:00
if ( w - > tbl - > event ! = NULL ) {
if ( ( win_closed = w - > tbl - > event ( w ) ) ) {
if ( ( node - > Type ! = AMINS_GUIOPTSWINDOW ) | |
( ( node - > Type = = AMINS_GUIOPTSWINDOW ) & & ( scrn ! = NULL ) ) ) {
ami_try_quit ( ) ;
break ;
}
2014-02-11 00:46:24 +04:00
} else {
2010-04-10 02:38:51 +04:00
node = nnode ;
continue ;
}
}
2016-12-30 03:59:12 +03:00
} while ( ( node = nnode ) ) ;
2017-01-15 19:05:07 +03:00
if ( ami_gui_menu_quit_selected ( ) = = true ) {
2016-12-30 03:59:12 +03:00
ami_quit_netsurf ( ) ;
}
2017-01-15 19:05:07 +03:00
if ( ami_gui_menu_get_check_toggled ( ) = = true ) {
2016-12-30 03:59:12 +03:00
ami_gui_menu_update_all ( ) ;
}
2016-12-31 03:51:05 +03:00
return win_closed ;
2016-12-30 03:59:12 +03:00
}
static BOOL ami_gui_event ( void * w )
{
struct gui_window_2 * gwin = ( struct gui_window_2 * ) w ;
ULONG result , storage = 0 , x , y , xs , ys , width = 800 , height = 600 ;
uint16 code ;
struct IBox * bbox ;
struct InputEvent * ie ;
struct Node * tabnode ;
int nskey ;
struct timeval curtime ;
static int drag_x_move = 0 , drag_y_move = 0 ;
char * utf8 = NULL ;
nsurl * url ;
BOOL win_closed = FALSE ;
2015-01-31 14:30:37 +03:00
2016-12-30 03:59:12 +03:00
while ( ( result = RA_HandleInput ( gwin - > objects [ OID_MAIN ] , & code ) ) ! = WMHI_LASTMSG ) {
switch ( result & WMHI_CLASSMASK ) // class
{
case WMHI_MOUSEMOVE :
ami_gui_trap_mouse ( gwin ) ; /* re-assert mouse area */
2012-01-12 01:41:55 +04:00
2016-12-30 03:59:12 +03:00
drag_x_move = 0 ;
drag_y_move = 0 ;
2010-12-19 02:34:56 +03:00
2016-12-30 03:59:12 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
amiga_warn_user ( " NoMemory " , " " ) ;
break ;
}
2008-08-11 21:53:45 +04:00
2016-12-30 03:59:12 +03:00
x = ( ULONG ) ( ( gwin - > win - > MouseX - bbox - > Left ) / gwin - > gw - > scale ) ;
y = ( ULONG ) ( ( gwin - > win - > MouseY - bbox - > Top ) / gwin - > gw - > scale ) ;
2009-01-25 03:36:30 +03:00
2016-12-30 03:59:12 +03:00
ami_get_hscroll_pos ( gwin , ( ULONG * ) & xs ) ;
ami_get_vscroll_pos ( gwin , ( ULONG * ) & ys ) ;
2009-08-31 01:43:14 +04:00
2016-12-30 03:59:12 +03:00
x + = xs ;
y + = ys ;
2009-08-31 01:43:14 +04:00
2016-12-30 03:59:12 +03:00
width = bbox - > Width ;
height = bbox - > Height ;
2008-08-18 23:07:12 +04:00
2016-12-30 03:59:12 +03:00
if ( gwin - > mouse_state & BROWSER_MOUSE_DRAG_ON )
{
if ( ami_drag_icon_move ( ) = = TRUE ) {
if ( ( gwin - > win - > MouseX < bbox - > Left ) & &
( ( gwin - > win - > MouseX - bbox - > Left ) > - AMI_DRAG_THRESHOLD ) )
drag_x_move = gwin - > win - > MouseX - bbox - > Left ;
if ( ( gwin - > win - > MouseX > ( bbox - > Left + bbox - > Width ) ) & &
( ( gwin - > win - > MouseX - ( bbox - > Left + bbox - > Width ) ) < AMI_DRAG_THRESHOLD ) )
drag_x_move = gwin - > win - > MouseX - ( bbox - > Left + bbox - > Width ) ;
if ( ( gwin - > win - > MouseY < bbox - > Top ) & &
( ( gwin - > win - > MouseY - bbox - > Top ) > - AMI_DRAG_THRESHOLD ) )
drag_y_move = gwin - > win - > MouseY - bbox - > Top ;
if ( ( gwin - > win - > MouseY > ( bbox - > Top + bbox - > Height ) ) & &
( ( gwin - > win - > MouseY - ( bbox - > Top + bbox - > Height ) ) < AMI_DRAG_THRESHOLD ) )
drag_y_move = gwin - > win - > MouseY - ( bbox - > Top + bbox - > Height ) ;
2010-10-20 02:22:03 +04:00
}
2016-12-30 03:59:12 +03:00
}
2010-10-20 02:22:03 +04:00
2016-12-30 03:59:12 +03:00
ami_gui_free_space_box ( bbox ) ;
2014-11-15 16:46:23 +03:00
2016-12-30 03:59:12 +03:00
if ( ( x > = xs ) & & ( y > = ys ) & & ( x < width + xs ) & & ( y < height + ys ) )
{
ami_update_quals ( gwin ) ;
2008-10-20 22:06:46 +04:00
2016-12-30 03:59:12 +03:00
if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_1 )
{
browser_window_mouse_track ( gwin - > gw - > bw , BROWSER_MOUSE_DRAG_1 | gwin - > key_state , x , y ) ;
gwin - > mouse_state = BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_DRAG_ON ;
2008-09-04 02:02:41 +04:00
}
2016-12-30 03:59:12 +03:00
else if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_2 )
{
browser_window_mouse_track ( gwin - > gw - > bw , BROWSER_MOUSE_DRAG_2 | gwin - > key_state , x , y ) ;
gwin - > mouse_state = BROWSER_MOUSE_HOLDING_2 | BROWSER_MOUSE_DRAG_ON ;
2014-11-15 16:46:23 +03:00
}
2016-12-30 03:59:12 +03:00
else
{
browser_window_mouse_track ( gwin - > gw - > bw , gwin - > mouse_state | gwin - > key_state , x , y ) ;
}
} else {
if ( ! gwin - > mouse_state ) ami_set_pointer ( gwin , GUI_POINTER_DEFAULT , true ) ;
}
break ;
2009-08-31 01:43:14 +04:00
2016-12-30 03:59:12 +03:00
case WMHI_MOUSEBUTTONS :
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
amiga_warn_user ( " NoMemory " , " " ) ;
return FALSE ;
}
2009-01-25 03:36:30 +03:00
2016-12-30 03:59:12 +03:00
x = ( ULONG ) ( ( gwin - > win - > MouseX - bbox - > Left ) / gwin - > gw - > scale ) ;
y = ( ULONG ) ( ( gwin - > win - > MouseY - bbox - > Top ) / gwin - > gw - > scale ) ;
2009-08-31 01:43:14 +04:00
2016-12-30 03:59:12 +03:00
ami_get_hscroll_pos ( gwin , ( ULONG * ) & xs ) ;
ami_get_vscroll_pos ( gwin , ( ULONG * ) & ys ) ;
2009-08-31 01:43:14 +04:00
2016-12-30 03:59:12 +03:00
x + = xs ;
y + = ys ;
2008-08-11 21:53:45 +04:00
2016-12-30 03:59:12 +03:00
width = bbox - > Width ;
height = bbox - > Height ;
2014-11-15 16:46:23 +03:00
2016-12-30 03:59:12 +03:00
ami_gui_free_space_box ( bbox ) ;
ami_update_quals ( gwin ) ;
2009-01-11 00:31:21 +03:00
2016-12-30 03:59:12 +03:00
if ( ( x > = xs ) & & ( y > = ys ) & & ( x < width + xs ) & & ( y < height + ys ) )
{
//code = code>>16;
switch ( code )
2008-08-09 19:19:04 +04:00
{
2016-12-30 03:59:12 +03:00
case SELECTDOWN :
browser_window_mouse_click ( gwin - > gw - > bw , BROWSER_MOUSE_PRESS_1 | gwin - > key_state , x , y ) ;
gwin - > mouse_state = BROWSER_MOUSE_PRESS_1 ;
break ;
case MIDDLEDOWN :
browser_window_mouse_click ( gwin - > gw - > bw , BROWSER_MOUSE_PRESS_2 | gwin - > key_state , x , y ) ;
gwin - > mouse_state = BROWSER_MOUSE_PRESS_2 ;
break ;
2008-08-09 19:19:04 +04:00
}
2016-12-30 03:59:12 +03:00
}
2008-09-04 02:02:41 +04:00
2016-12-30 03:59:12 +03:00
if ( x < xs ) x = xs ;
if ( y < ys ) y = ys ;
if ( x > = width + xs ) x = width + xs - 1 ;
if ( y > = height + ys ) y = height + ys - 1 ;
2008-09-04 02:02:41 +04:00
2016-12-30 03:59:12 +03:00
switch ( code )
{
case SELECTUP :
if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_1 )
{
CurrentTime ( ( ULONG * ) & curtime . tv_sec , ( ULONG * ) & curtime . tv_usec ) ;
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
gwin - > mouse_state = BROWSER_MOUSE_CLICK_1 ;
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
if ( gwin - > lastclick . tv_sec )
{
if ( DoubleClick ( gwin - > lastclick . tv_sec ,
gwin - > lastclick . tv_usec ,
curtime . tv_sec , curtime . tv_usec ) ) {
if ( gwin - > prev_mouse_state & BROWSER_MOUSE_DOUBLE_CLICK ) {
gwin - > mouse_state | = BROWSER_MOUSE_TRIPLE_CLICK ;
} else {
gwin - > mouse_state | = BROWSER_MOUSE_DOUBLE_CLICK ;
2013-02-12 23:12:14 +04:00
}
2010-12-17 02:28:33 +03:00
}
2016-12-30 03:59:12 +03:00
}
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
browser_window_mouse_click ( gwin - > gw - > bw ,
gwin - > mouse_state | gwin - > key_state , x , y ) ;
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
if ( gwin - > mouse_state & BROWSER_MOUSE_TRIPLE_CLICK )
{
gwin - > lastclick . tv_sec = 0 ;
gwin - > lastclick . tv_usec = 0 ;
2008-09-04 02:02:41 +04:00
}
else
{
2016-12-30 03:59:12 +03:00
gwin - > lastclick . tv_sec = curtime . tv_sec ;
gwin - > lastclick . tv_usec = curtime . tv_usec ;
2008-09-04 02:02:41 +04:00
}
2016-12-30 03:59:12 +03:00
}
else
{
browser_window_mouse_track ( gwin - > gw - > bw , 0 , x , y ) ;
}
gwin - > prev_mouse_state = gwin - > mouse_state ;
gwin - > mouse_state = 0 ;
break ;
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
case MIDDLEUP :
if ( gwin - > mouse_state & BROWSER_MOUSE_PRESS_2 )
{
CurrentTime ( ( ULONG * ) & curtime . tv_sec , ( ULONG * ) & curtime . tv_usec ) ;
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
gwin - > mouse_state = BROWSER_MOUSE_CLICK_2 ;
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
if ( gwin - > lastclick . tv_sec )
{
if ( DoubleClick ( gwin - > lastclick . tv_sec ,
gwin - > lastclick . tv_usec ,
curtime . tv_sec , curtime . tv_usec ) ) {
if ( gwin - > prev_mouse_state & BROWSER_MOUSE_DOUBLE_CLICK ) {
gwin - > mouse_state | = BROWSER_MOUSE_TRIPLE_CLICK ;
} else {
gwin - > mouse_state | = BROWSER_MOUSE_DOUBLE_CLICK ;
2013-02-12 23:12:14 +04:00
}
2010-12-17 02:28:33 +03:00
}
2016-12-30 03:59:12 +03:00
}
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
browser_window_mouse_click ( gwin - > gw - > bw ,
gwin - > mouse_state | gwin - > key_state , x , y ) ;
2010-12-17 02:28:33 +03:00
2016-12-30 03:59:12 +03:00
if ( gwin - > mouse_state & BROWSER_MOUSE_TRIPLE_CLICK )
{
gwin - > lastclick . tv_sec = 0 ;
gwin - > lastclick . tv_usec = 0 ;
2008-09-04 02:02:41 +04:00
}
else
{
2016-12-30 03:59:12 +03:00
gwin - > lastclick . tv_sec = curtime . tv_sec ;
gwin - > lastclick . tv_usec = curtime . tv_usec ;
2008-09-04 02:02:41 +04:00
}
2016-12-30 03:59:12 +03:00
}
else
{
browser_window_mouse_track ( gwin - > gw - > bw , 0 , x , y ) ;
}
gwin - > prev_mouse_state = gwin - > mouse_state ;
gwin - > mouse_state = 0 ;
break ;
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2016-12-30 03:59:12 +03:00
case SIDEUP :
ami_gui_history ( gwin , true ) ;
break ;
2011-06-03 22:08:17 +04:00
2016-12-30 03:59:12 +03:00
case EXTRAUP :
ami_gui_history ( gwin , false ) ;
break ;
2015-01-17 20:06:48 +03:00
# endif
2016-12-30 03:59:12 +03:00
}
if ( ami_drag_has_data ( ) & & ! gwin - > mouse_state )
ami_drag_save ( gwin - > win ) ;
break ;
case WMHI_GADGETUP :
switch ( result & WMHI_GADGETMASK )
{
case GID_TABS :
if ( gwin - > objects [ GID_TABS ] = = NULL ) break ;
if ( ClickTabBase - > lib_Version > = 53 ) {
GetAttrs ( gwin - > objects [ GID_TABS ] ,
CLICKTAB_NodeClosed , & tabnode , TAG_DONE ) ;
} else {
tabnode = NULL ;
}
if ( tabnode ) {
struct gui_window * closedgw ;
GetClickTabNodeAttrs ( tabnode ,
TNA_UserData , & closedgw ,
TAG_DONE ) ;
browser_window_destroy ( closedgw - > bw ) ;
} else {
ami_switch_tab ( gwin , true ) ;
}
break ;
case GID_CLOSETAB :
browser_window_destroy ( gwin - > gw - > bw ) ;
break ;
case GID_ADDTAB :
ami_gui_new_blank_tab ( gwin ) ;
break ;
case GID_URL :
{
nserror ret ;
nsurl * url ;
GetAttr ( STRINGA_TextVal ,
( Object * ) gwin - > objects [ GID_URL ] ,
( ULONG * ) & storage ) ;
utf8 = ami_to_utf8_easy ( ( const char * ) storage ) ;
ret = search_web_omni ( utf8 , SEARCH_WEB_OMNI_NONE , & url ) ;
ami_utf8_free ( utf8 ) ;
if ( ret = = NSERROR_OK ) {
browser_window_navigate ( gwin - > gw - > bw ,
url ,
NULL ,
BW_NAVIGATE_HISTORY ,
NULL ,
NULL ,
NULL ) ;
nsurl_unref ( url ) ;
}
if ( ret ! = NSERROR_OK ) {
amiga_warn_user ( messages_get_errorcode ( ret ) , 0 ) ;
}
2008-09-04 02:02:41 +04:00
}
2016-12-30 03:59:12 +03:00
break ;
2009-03-25 03:03:43 +03:00
2016-12-30 03:59:12 +03:00
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 ) ;
break ;
2008-08-09 19:19:04 +04:00
2016-12-30 03:59:12 +03:00
case GID_SEARCHSTRING :
2008-08-09 19:19:04 +04:00
{
2016-12-30 03:59:12 +03:00
nserror ret ;
nsurl * url ;
GetAttr ( STRINGA_TextVal ,
( Object * ) gwin - > objects [ GID_SEARCHSTRING ] ,
( ULONG * ) & storage ) ;
2016-01-31 20:02:24 +03:00
2016-12-30 03:59:12 +03:00
utf8 = ami_to_utf8_easy ( ( const char * ) storage ) ;
2014-11-16 17:24:18 +03:00
2016-12-30 03:59:12 +03:00
ret = search_web_omni ( utf8 , SEARCH_WEB_OMNI_SEARCHONLY , & url ) ;
ami_utf8_free ( utf8 ) ;
if ( ret = = NSERROR_OK ) {
browser_window_navigate ( gwin - > gw - > bw ,
url ,
NULL ,
BW_NAVIGATE_HISTORY ,
NULL ,
NULL ,
NULL ) ;
nsurl_unref ( url ) ;
}
if ( ret ! = NSERROR_OK ) {
amiga_warn_user ( messages_get_errorcode ( ret ) , 0 ) ;
}
2010-02-14 03:46:53 +03:00
2016-12-30 03:59:12 +03:00
}
break ;
case GID_HOME :
{
if ( nsurl_create ( nsoption_charp ( homepage_url ) , & url ) ! = NSERROR_OK ) {
amiga_warn_user ( " NoMemory " , 0 ) ;
2014-11-16 17:24:18 +03:00
} else {
2016-12-30 03:59:12 +03:00
browser_window_navigate ( gwin - > gw - > bw ,
url ,
NULL ,
BW_NAVIGATE_HISTORY ,
NULL ,
NULL ,
NULL ) ;
nsurl_unref ( url ) ;
2010-02-14 03:46:53 +03:00
}
2016-12-30 03:59:12 +03:00
}
break ;
2008-10-05 03:29:17 +04:00
2016-12-30 03:59:12 +03:00
case GID_STOP :
if ( browser_window_stop_available ( gwin - > gw - > bw ) )
browser_window_stop ( gwin - > gw - > bw ) ;
break ;
2008-10-05 03:29:17 +04:00
2016-12-30 03:59:12 +03:00
case GID_RELOAD :
ami_update_quals ( gwin ) ;
2010-02-14 17:00:33 +03:00
2016-12-30 03:59:12 +03:00
if ( browser_window_reload_available ( gwin - > gw - > bw ) )
2014-05-25 03:57:48 +04:00
{
2016-12-30 03:59:12 +03:00
if ( gwin - > key_state & BROWSER_MOUSE_MOD_1 )
{
browser_window_reload ( gwin - > gw - > bw , true ) ;
2013-02-14 19:09:28 +04:00
}
2016-12-30 03:59:12 +03:00
else
{
browser_window_reload ( gwin - > gw - > bw , false ) ;
2014-05-25 03:57:48 +04:00
}
}
2016-12-30 03:59:12 +03:00
break ;
2008-08-09 19:19:04 +04:00
2016-12-30 03:59:12 +03:00
case GID_BACK :
ami_gui_history ( gwin , true ) ;
break ;
2009-12-23 02:04:59 +03:00
2016-12-30 03:59:12 +03:00
case GID_FORWARD :
ami_gui_history ( gwin , false ) ;
break ;
2014-06-15 18:48:55 +04:00
2016-12-30 03:59:12 +03:00
case GID_FAVE :
GetAttr ( STRINGA_TextVal ,
( Object * ) gwin - > objects [ GID_URL ] ,
( ULONG * ) & storage ) ;
if ( nsurl_create ( ( const char * ) storage , & url ) = = NSERROR_OK ) {
if ( hotlist_has_url ( url ) ) {
hotlist_remove_url ( url ) ;
} else {
hotlist_add_url ( url ) ;
}
nsurl_unref ( url ) ;
}
ami_gui_update_hotlist_button ( gwin ) ;
break ;
2014-05-25 03:57:48 +04:00
2016-12-30 03:59:12 +03:00
case GID_HOTLIST :
default :
// printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
break ;
}
break ;
2014-03-13 23:37:01 +04:00
2016-12-30 03:59:12 +03:00
case WMHI_RAWKEY :
ami_update_quals ( gwin ) ;
storage = result & WMHI_GADGETMASK ;
if ( storage > = IECODE_UP_PREFIX ) break ;
2014-05-25 03:57:48 +04:00
2016-12-30 03:59:12 +03:00
GetAttr ( WINDOW_InputEvent , gwin - > objects [ OID_MAIN ] , ( ULONG * ) & ie ) ;
2014-05-25 03:57:48 +04:00
2016-12-30 03:59:12 +03:00
nskey = ami_key_to_nskey ( storage , ie ) ;
2009-12-23 02:04:59 +03:00
2016-12-30 03:59:12 +03:00
if ( ( ie - > ie_Qualifier & IEQUALIFIER_RCOMMAND ) & &
( ( 31 < nskey ) & & ( nskey < 127 ) ) ) {
/* NB: Some keypresses are converted to generic keypresses above
* rather than being " menu-emulated " here . */
switch ( nskey )
{
/* The following aren't available from the menu at the moment */
case ' r ' : // reload
if ( browser_window_reload_available ( gwin - > gw - > bw ) )
browser_window_reload ( gwin - > gw - > bw , false ) ;
2008-08-09 19:19:04 +04:00
break ;
2016-12-30 03:59:12 +03:00
case ' u ' : // open url
if ( ( nsoption_bool ( kiosk_mode ) = = false ) )
ActivateLayoutGadget ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ,
gwin - > win , NULL , ( uint32 ) gwin - > objects [ GID_URL ] ) ;
2008-08-09 19:19:04 +04:00
break ;
2016-12-30 03:59:12 +03:00
}
}
else
{
if ( ! browser_window_key_press ( gwin - > gw - > bw , nskey ) )
{
switch ( nskey )
{
case NS_KEY_UP :
ami_gui_scroll_internal ( gwin , 0 , - NSA_KBD_SCROLL_PX ) ;
break ;
2008-08-09 19:19:04 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_DOWN :
ami_gui_scroll_internal ( gwin , 0 , + NSA_KBD_SCROLL_PX ) ;
break ;
2009-01-11 00:31:21 +03:00
2016-12-30 03:59:12 +03:00
case NS_KEY_LEFT :
ami_gui_scroll_internal ( gwin , - NSA_KBD_SCROLL_PX , 0 ) ;
break ;
2008-08-10 00:27:36 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_RIGHT :
ami_gui_scroll_internal ( gwin , + NSA_KBD_SCROLL_PX , 0 ) ;
break ;
2008-08-10 00:27:36 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_PAGE_UP :
ami_gui_scroll_internal ( gwin , 0 , SCROLL_PAGE_UP ) ;
break ;
2008-08-10 13:57:41 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_PAGE_DOWN :
case ' ' :
ami_gui_scroll_internal ( gwin , 0 , SCROLL_PAGE_DOWN ) ;
break ;
2013-11-23 16:34:00 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_LINE_START : // page left
ami_gui_scroll_internal ( gwin , SCROLL_PAGE_UP , 0 ) ;
break ;
2008-08-09 19:19:04 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_LINE_END : // page right
ami_gui_scroll_internal ( gwin , SCROLL_PAGE_DOWN , 0 ) ;
break ;
2009-07-18 15:36:41 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_TEXT_START : // home
ami_gui_scroll_internal ( gwin , SCROLL_TOP , SCROLL_TOP ) ;
break ;
2008-10-26 15:25:26 +03:00
2016-12-30 03:59:12 +03:00
case NS_KEY_TEXT_END : // end
ami_gui_scroll_internal ( gwin , SCROLL_BOTTOM , SCROLL_BOTTOM ) ;
break ;
2009-11-03 02:02:53 +03:00
2016-12-30 03:59:12 +03:00
case NS_KEY_WORD_RIGHT : // alt+right
ami_change_tab ( gwin , 1 ) ;
break ;
2009-11-04 02:17:57 +03:00
2016-12-30 03:59:12 +03:00
case NS_KEY_WORD_LEFT : // alt+left
ami_change_tab ( gwin , - 1 ) ;
2009-11-04 02:17:57 +03:00
break ;
2014-01-11 00:35:49 +04:00
2016-12-30 03:59:12 +03:00
case NS_KEY_DELETE_LEFT : // backspace
ami_gui_history ( gwin , true ) ;
2009-11-04 02:17:57 +03:00
break ;
2008-08-25 17:32:26 +04:00
2016-12-30 03:59:12 +03:00
/* RawKeys. NB: These are passthrus in ami_key_to_nskey() */
case RAWKEY_F5 : // reload
if ( browser_window_reload_available ( gwin - > gw - > bw ) )
browser_window_reload ( gwin - > gw - > bw , false ) ;
break ;
2008-08-11 21:53:45 +04:00
2016-12-30 03:59:12 +03:00
case RAWKEY_F8 : // scale 100%
ami_gui_set_scale ( gwin - > gw , 1.0 ) ;
break ;
2010-03-15 22:00:21 +03:00
2016-12-30 03:59:12 +03:00
case RAWKEY_F9 : // decrease scale
ami_gui_set_scale ( gwin - > gw , gwin - > gw - > scale - 0.1 ) ;
break ;
2008-10-26 02:22:34 +03:00
2016-12-30 03:59:12 +03:00
case RAWKEY_F10 : // increase scale
ami_gui_set_scale ( gwin - > gw , gwin - > gw - > scale + 0.1 ) ;
break ;
case RAWKEY_HELP : // help
ami_help_open ( AMI_HELP_GUI , scrn ) ;
break ;
}
} else if ( nskey = = NS_KEY_COPY_SELECTION ) {
/* if we've copied a selection we need to clear it - style guide rules */
browser_window_key_press ( gwin - > gw - > bw , NS_KEY_CLEAR_SELECTION ) ;
}
}
break ;
2008-08-09 19:19:04 +04:00
2016-12-30 03:59:12 +03:00
case WMHI_NEWSIZE :
ami_set_border_gadget_size ( gwin ) ;
ami_throbber_redraw_schedule ( 0 , gwin - > gw ) ;
ami_schedule ( 0 , ami_gui_refresh_favicon , gwin ) ;
browser_window_schedule_reformat ( gwin - > gw - > bw ) ;
break ;
2008-08-10 13:57:41 +04:00
2016-12-30 03:59:12 +03:00
case WMHI_CLOSEWINDOW :
ami_gui_close_window ( gwin ) ;
win_closed = TRUE ;
break ;
# ifdef __amigaos4__
case WMHI_ICONIFY :
2008-08-22 01:41:42 +04:00
{
2016-12-30 03:59:12 +03:00
struct bitmap * bm ;
bm = urldb_get_thumbnail ( browser_window_get_url ( gwin - > gw - > bw ) ) ;
if ( ! bm ) bm = content_get_bitmap ( browser_window_get_content ( gwin - > gw - > bw ) ) ;
gwin - > dobj = amiga_icon_from_bitmap ( bm ) ;
amiga_icon_superimpose_favicon_internal ( gwin - > gw - > favicon ,
gwin - > dobj ) ;
HideWindow ( gwin - > win ) ;
gwin - > appicon = AddAppIcon ( ( ULONG ) gwin - > objects [ OID_MAIN ] ,
( ULONG ) gwin , gwin - > win - > Title , appport ,
0 , gwin - > dobj , NULL ) ;
cur_gw = NULL ;
2008-08-22 01:41:42 +04:00
}
2016-12-30 03:59:12 +03:00
break ;
# endif
case WMHI_INACTIVE :
gwin - > gw - > c_h_temp = gwin - > gw - > c_h ;
gui_window_remove_caret ( gwin - > gw ) ;
break ;
2008-08-10 13:57:41 +04:00
2016-12-30 03:59:12 +03:00
case WMHI_ACTIVE :
if ( gwin - > gw - > bw ) cur_gw = gwin - > gw ;
if ( gwin - > gw - > c_h_temp )
gwin - > gw - > c_h = gwin - > gw - > c_h_temp ;
break ;
2010-12-19 02:34:56 +03:00
2016-12-30 03:59:12 +03:00
case WMHI_INTUITICK :
break ;
2010-12-19 02:34:56 +03:00
2016-12-30 03:59:12 +03:00
default :
//printf("class: %ld\n",(result & WMHI_CLASSMASK));
break ;
2008-08-02 18:31:32 +04:00
}
2008-08-10 13:57:41 +04:00
2016-12-30 03:59:12 +03:00
if ( win_destroyed )
{
/* we can't be sure what state our window_list is in, so let's
jump out of the function and start again */
win_destroyed = false ;
return TRUE ;
2016-07-03 19:09:11 +03:00
}
2016-12-30 03:59:12 +03:00
if ( drag_x_move | | drag_y_move )
{
gui_window_get_scroll ( gwin - > gw ,
& gwin - > gw - > scrollx , & gwin - > gw - > scrolly ) ;
2011-09-13 02:38:51 +04:00
2016-12-30 03:59:12 +03:00
gui_window_set_scroll ( gwin - > gw ,
gwin - > gw - > scrollx + drag_x_move ,
gwin - > gw - > scrolly + drag_y_move ) ;
}
// ReplyMsg((struct Message *)message);
2012-11-01 00:50:22 +04:00
}
2016-12-30 03:59:12 +03:00
if ( gwin - > closed = = true ) {
win_closed = TRUE ;
ami_gui_close_window ( gwin ) ;
2012-12-15 19:39:09 +04:00
}
2016-12-30 03:59:12 +03:00
return win_closed ;
2008-09-05 02:41:26 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_gui_appicon_remove ( struct gui_window_2 * gwin )
2011-07-03 15:05:18 +04:00
{
if ( gwin - > appicon )
{
RemoveAppIcon ( gwin - > appicon ) ;
amiga_icon_free ( gwin - > dobj ) ;
gwin - > appicon = NULL ;
}
}
2014-10-16 12:55:01 +04:00
static void ami_handle_appmsg ( void )
2008-09-05 02:41:26 +04:00
{
struct AppMessage * appmsg ;
2008-10-05 03:29:17 +04:00
struct gui_window_2 * gwin ;
2011-12-02 16:47:11 +04:00
int x , y ;
2008-09-07 19:58:11 +04:00
struct WBArg * appwinargs ;
STRPTR filename ;
2011-12-02 16:47:11 +04:00
int i = 0 ;
2008-09-04 02:02:41 +04:00
2014-10-25 19:22:08 +04:00
while ( ( appmsg = ( struct AppMessage * ) GetMsg ( appport ) ) )
2008-09-04 02:02:41 +04:00
{
2012-04-28 23:43:46 +04:00
gwin = ( struct gui_window_2 * ) appmsg - > am_UserData ;
2008-09-07 19:58:11 +04:00
2009-07-04 20:12:27 +04:00
if ( appmsg - > am_Type = = AMTYPE_APPICON )
{
2011-07-03 15:05:18 +04:00
ami_gui_appicon_remove ( gwin ) ;
ShowWindow ( gwin - > win , WINDOW_FRONTMOST ) ;
2011-07-03 15:20:00 +04:00
ActivateWindow ( gwin - > win ) ;
2009-07-04 20:12:27 +04:00
}
2011-07-03 15:05:18 +04:00
else if ( appmsg - > am_Type = = AMTYPE_APPWINDOW )
2008-09-07 19:58:11 +04:00
{
2011-12-02 16:47:11 +04:00
for ( i = 0 ; i < appmsg - > am_NumArgs ; + + i )
2008-09-05 02:41:26 +04:00
{
2014-10-25 19:22:08 +04:00
if ( ( appwinargs = & appmsg - > am_ArgList [ i ] ) )
2008-09-07 19:58:11 +04:00
{
2016-11-20 00:02:42 +03:00
if ( ( filename = malloc ( 1024 ) ) )
2008-09-07 19:58:11 +04:00
{
2011-12-02 16:47:11 +04:00
if ( appwinargs - > wa_Lock )
2008-09-07 19:58:11 +04:00
{
2011-12-02 16:47:11 +04:00
NameFromLock ( appwinargs - > wa_Lock , filename , 1024 ) ;
2008-09-07 19:58:11 +04:00
}
2011-12-02 16:47:11 +04:00
AddPart ( filename , appwinargs - > wa_Name , 1024 ) ;
2008-09-07 19:58:11 +04:00
2011-12-02 16:47:11 +04:00
if ( ami_mouse_to_ns_coords ( gwin , & x , & y ,
appmsg - > am_MouseX , appmsg - > am_MouseY ) = = false )
2008-09-07 19:58:11 +04:00
{
2013-02-14 19:09:28 +04:00
nsurl * url ;
2008-09-07 19:58:11 +04:00
2014-05-27 02:43:36 +04:00
if ( netsurf_path_to_nsurl ( filename , & url ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , 0 ) ;
2011-12-02 16:47:11 +04:00
}
else
{
2013-02-14 19:09:28 +04:00
if ( i = = 0 )
{
2014-11-16 17:44:40 +03:00
browser_window_navigate ( gwin - > gw - > bw ,
2013-02-14 19:09:28 +04:00
url ,
NULL ,
2014-02-11 02:40:04 +04:00
BW_NAVIGATE_HISTORY ,
2013-02-14 19:09:28 +04:00
NULL ,
NULL ,
NULL ) ;
ActivateWindow ( gwin - > win ) ;
}
else
{
2014-02-10 18:08:45 +04:00
browser_window_create ( BW_CREATE_CLONE | BW_CREATE_HISTORY |
BW_CREATE_TAB ,
2013-02-14 22:21:11 +04:00
url ,
NULL ,
2014-11-16 17:44:40 +03:00
gwin - > gw - > bw ,
2013-02-14 22:21:11 +04:00
NULL ) ;
2013-02-14 19:09:28 +04:00
}
nsurl_unref ( url ) ;
2008-09-07 19:58:11 +04:00
}
}
else
{
2014-11-16 17:44:40 +03:00
if ( browser_window_drop_file_at_point ( gwin - > gw - > bw , x , y , filename ) = = false )
2008-09-07 19:58:11 +04:00
{
2013-02-14 19:09:28 +04:00
nsurl * url ;
2011-12-02 16:47:11 +04:00
2014-05-27 02:43:36 +04:00
if ( netsurf_path_to_nsurl ( filename , & url ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , 0 ) ;
2011-12-02 16:47:11 +04:00
}
else
2008-09-07 19:58:11 +04:00
{
2013-02-14 19:09:28 +04:00
if ( i = = 0 )
{
2014-11-16 17:44:40 +03:00
browser_window_navigate ( gwin - > gw - > bw ,
2013-02-14 19:09:28 +04:00
url ,
NULL ,
2014-02-11 02:53:22 +04:00
BW_NAVIGATE_HISTORY ,
2013-02-14 19:09:28 +04:00
NULL ,
NULL ,
NULL ) ;
ActivateWindow ( gwin - > win ) ;
}
else
{
2014-02-10 18:08:45 +04:00
browser_window_create ( BW_CREATE_CLONE | BW_CREATE_HISTORY |
BW_CREATE_TAB ,
2013-02-14 22:21:11 +04:00
url ,
NULL ,
2014-11-16 17:44:40 +03:00
gwin - > gw - > bw ,
2013-02-14 22:21:11 +04:00
NULL ) ;
2013-02-14 19:09:28 +04:00
}
nsurl_unref ( url ) ;
2008-09-07 19:58:11 +04:00
}
}
}
2016-11-20 00:02:42 +03:00
free ( filename ) ;
2008-09-07 19:58:11 +04:00
}
}
2008-09-05 02:41:26 +04:00
}
}
2008-09-04 02:02:41 +04:00
ReplyMsg ( ( struct Message * ) appmsg ) ;
}
2008-08-02 18:31:32 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_handle_applib ( void )
2009-09-28 22:00:40 +04:00
{
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2009-09-28 22:00:40 +04:00
struct ApplicationMsg * applibmsg ;
2009-09-29 02:17:09 +04:00
struct browser_window * bw ;
2013-02-14 22:21:11 +04:00
nsurl * url ;
nserror error ;
2009-09-28 22:00:40 +04:00
2010-03-28 20:42:33 +04:00
if ( ! applibport ) return ;
2009-09-28 22:00:40 +04:00
while ( ( applibmsg = ( struct ApplicationMsg * ) GetMsg ( applibport ) ) )
{
switch ( applibmsg - > type )
{
2009-09-29 02:17:09 +04:00
case APPLIBMT_NewBlankDoc :
2013-02-14 22:21:11 +04:00
{
error = nsurl_create ( nsoption_charp ( homepage_url ) , & 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 ,
& bw ) ;
nsurl_unref ( url ) ;
}
if ( error ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( messages_get_errorcode ( error ) , 0 ) ;
2013-02-14 22:21:11 +04:00
}
}
2009-09-29 02:17:09 +04:00
break ;
case APPLIBMT_OpenDoc :
{
2011-07-23 18:06:13 +04:00
struct ApplicationOpenPrintDocMsg * applibopdmsg =
( struct ApplicationOpenPrintDocMsg * ) applibmsg ;
2013-02-14 22:21:11 +04:00
2014-05-27 02:43:36 +04:00
error = netsurf_path_to_nsurl ( applibopdmsg - > fileName , & url ) ;
2013-02-14 22:21:11 +04:00
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 ,
& bw ) ;
nsurl_unref ( url ) ;
}
if ( error ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( messages_get_errorcode ( error ) , 0 ) ;
2013-02-14 22:21:11 +04:00
}
2009-09-29 02:17:09 +04:00
}
break ;
2009-09-28 22:00:40 +04:00
case APPLIBMT_ToFront :
2014-11-16 19:01:59 +03:00
if ( cur_gw )
2009-09-29 02:17:09 +04:00
{
ScreenToFront ( scrn ) ;
2014-11-16 19:01:59 +03:00
WindowToFront ( cur_gw - > shared - > win ) ;
ActivateWindow ( cur_gw - > shared - > win ) ;
2009-09-29 02:17:09 +04:00
}
2009-09-28 22:00:40 +04:00
break ;
case APPLIBMT_OpenPrefs :
ScreenToFront ( scrn ) ;
ami_gui_opts_open ( ) ;
break ;
case APPLIBMT_Quit :
case APPLIBMT_ForceQuit :
ami_quit_netsurf ( ) ;
break ;
2010-02-13 20:31:10 +03:00
case APPLIBMT_CustomMsg :
{
2011-07-23 18:06:13 +04:00
struct ApplicationCustomMsg * applibcustmsg =
( struct ApplicationCustomMsg * ) applibmsg ;
2015-05-28 18:08:46 +03:00
LOG ( " Ringhio BackMsg received: %s " , applibcustmsg - > customMsg ) ;
2013-10-29 01:21:07 +04:00
OpenWorkbenchObjectA ( applibcustmsg - > customMsg , NULL ) ;
2010-02-13 20:31:10 +03:00
}
break ;
2009-09-28 22:00:40 +04:00
}
ReplyMsg ( ( struct Message * ) applibmsg ) ;
}
2015-01-17 20:06:48 +03:00
# endif
2009-09-28 22:00:40 +04:00
}
2008-09-05 02:41:26 +04:00
void ami_get_msg ( void )
2008-08-02 18:31:32 +04:00
{
2008-09-05 02:41:26 +04:00
ULONG winsignal = 1L < < sport - > mp_SigBit ;
ULONG appsig = 1L < < appport - > mp_SigBit ;
2014-11-22 19:24:26 +03:00
ULONG schedulesig = 1L < < schedulermsgport - > mp_SigBit ;
2012-12-08 03:35:57 +04:00
ULONG ctrlcsig = SIGBREAKF_CTRL_C ;
2014-07-03 23:53:28 +04:00
uint32 signal = 0 ;
fd_set read_fd_set , write_fd_set , except_fd_set ;
int max_fd = - 1 ;
2009-08-29 18:00:57 +04:00
struct MsgPort * printmsgport = ami_print_get_msgport ( ) ;
2014-02-07 21:45:00 +04:00
ULONG printsig = 0 ;
2014-02-10 22:42:50 +04:00
ULONG helpsignal = ami_help_signal ( ) ;
2014-02-07 21:45:00 +04:00
if ( printmsgport ) printsig = 1L < < printmsgport - > mp_SigBit ;
2014-07-03 23:53:28 +04:00
uint32 signalmask = winsignal | appsig | schedulesig | rxsig |
2014-07-05 12:36:43 +04:00
printsig | applibsig | helpsignal ;
2014-07-03 23:53:28 +04:00
2016-06-27 23:09:39 +03:00
if ( ( fetch_fdset ( & read_fd_set , & write_fd_set , & except_fd_set , & max_fd ) = = NSERROR_OK ) & &
2014-07-03 23:53:28 +04:00
( max_fd ! = - 1 ) ) {
/* max_fd is the highest fd in use, but waitselect() needs to know how many
* are in use , so we add 1. */
2016-03-03 02:47:37 +03:00
2014-07-05 12:36:43 +04:00
if ( waitselect ( max_fd + 1 , & read_fd_set , & write_fd_set , & except_fd_set ,
NULL , ( unsigned int * ) & signalmask ) ! = - 1 ) {
signal = signalmask ;
} else {
2015-05-28 18:08:46 +03:00
LOG ( " waitselect() returned error " ) ;
2014-07-05 12:36:43 +04:00
/* \todo Fix Ctrl-C handling.
* WaitSelect ( ) from bsdsocket . library returns - 1 if the task was
* signalled with a Ctrl - C . waitselect ( ) from newlib . library does not .
* Adding the Ctrl - C signal to our user signal mask causes a Ctrl - C to
* occur sporadically . Otherwise we never get a - 1 except on error .
* NetSurf still terminates at the Wait ( ) when network activity is over .
*/
}
2014-07-03 23:53:28 +04:00
} else {
/* If fetcher_fdset fails or no network activity, do it the old fashioned way. */
signalmask | = ctrlcsig ;
signal = Wait ( signalmask ) ;
}
2008-08-02 18:31:32 +04:00
2008-09-05 02:41:26 +04:00
if ( signal & winsignal )
2016-12-31 03:51:05 +03:00
while ( ami_handle_msg ( ) ) ;
2011-02-10 00:52:28 +03:00
if ( signal & appsig )
2008-09-05 02:41:26 +04:00
ami_handle_appmsg ( ) ;
2011-02-10 00:52:28 +03:00
if ( signal & rxsig )
2008-09-29 23:35:30 +04:00
ami_arexx_handle ( ) ;
2011-02-10 00:52:28 +03:00
if ( signal & applibsig )
2009-09-28 22:00:40 +04:00
ami_handle_applib ( ) ;
2011-02-10 00:52:28 +03:00
2014-02-10 22:42:50 +04:00
if ( signal & printsig ) {
2009-08-29 18:00:57 +04:00
while ( GetMsg ( printmsgport ) ) ; //ReplyMsg
ami_print_cont ( ) ;
}
2011-02-10 00:52:28 +03:00
2014-11-22 19:24:26 +03:00
if ( signal & schedulesig ) {
ami_schedule_handle ( schedulermsgport ) ;
2008-09-08 22:14:14 +04:00
}
2012-12-08 03:35:57 +04:00
2014-02-10 22:42:50 +04:00
if ( signal & helpsignal )
ami_help_process ( ) ;
2012-12-08 03:35:57 +04:00
if ( signal & ctrlcsig )
2012-12-08 22:08:00 +04:00
ami_quit_netsurf_delayed ( ) ;
2008-09-05 02:41:26 +04:00
}
2008-08-02 18:31:32 +04:00
2009-12-13 14:52:58 +03:00
void ami_change_tab ( struct gui_window_2 * gwin , int direction )
{
2014-11-16 17:44:40 +03:00
struct Node * tab_node = gwin - > gw - > tab_node ;
2015-01-16 02:50:35 +03:00
struct Node * ptab = NULL ;
2009-12-13 14:52:58 +03:00
if ( gwin - > tabs < = 1 ) return ;
2015-01-16 02:48:56 +03:00
if ( direction > 0 ) {
2009-12-13 14:52:58 +03:00
ptab = GetSucc ( tab_node ) ;
2015-01-16 02:48:56 +03:00
} else {
2009-12-13 14:52:58 +03:00
ptab = GetPred ( tab_node ) ;
}
if ( ! ptab ) return ;
2010-02-13 21:03:05 +03:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_TABS ] , gwin - > win , NULL ,
2015-01-16 02:48:56 +03:00
CLICKTAB_CurrentNode , ptab ,
2009-12-13 14:52:58 +03:00
TAG_DONE ) ;
ami_switch_tab ( gwin , true ) ;
}
2014-11-16 17:44:40 +03:00
void ami_switch_tab ( struct gui_window_2 * gwin , bool redraw )
2008-10-05 17:17:18 +04:00
{
struct Node * tabnode ;
2009-09-09 02:59:47 +04:00
struct IBox * bbox ;
2008-10-05 17:17:18 +04:00
2011-07-03 02:40:45 +04:00
/* Clear the last new tab list */
2016-09-04 19:35:32 +03:00
gwin - > last_new_tab = NULL ;
2011-07-03 02:40:45 +04:00
2008-10-05 17:17:18 +04:00
if ( gwin - > tabs = = 0 ) return ;
2014-11-16 17:44:40 +03:00
gui_window_get_scroll ( gwin - > gw ,
& gwin - > gw - > scrollx , & gwin - > gw - > scrolly ) ;
2008-11-09 02:08:55 +03:00
2010-02-13 21:03:05 +03:00
GetAttr ( CLICKTAB_CurrentNode , ( Object * ) gwin - > objects [ GID_TABS ] ,
( ULONG * ) & tabnode ) ;
2008-10-05 17:17:18 +04:00
GetClickTabNodeAttrs ( tabnode ,
2014-11-16 17:24:18 +03:00
TNA_UserData , & gwin - > gw ,
2014-07-05 22:00:21 +04:00
TAG_DONE ) ;
2014-11-16 19:01:59 +03:00
cur_gw = gwin - > gw ;
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2009-09-09 02:59:47 +04:00
2015-01-13 22:09:48 +03:00
if ( ( gwin - > gw - > bw = = NULL ) | | ( browser_window_has_content ( gwin - > gw - > bw ) ) = = false ) {
2010-02-14 15:51:30 +03:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_URL ] ,
gwin - > win , NULL , STRINGA_TextVal , " " , TAG_DONE ) ;
2015-02-02 21:10:43 +03:00
ami_plot_clear_bbox ( gwin - > win - > RPort , bbox ) ;
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2009-09-09 02:59:47 +04:00
return ;
}
2008-10-05 17:17:18 +04:00
2016-01-25 03:01:55 +03:00
ami_plot_release_pens ( gwin - > shared_pens ) ;
2008-10-05 17:17:18 +04:00
ami_update_buttons ( gwin ) ;
2017-01-15 19:05:07 +03:00
ami_gui_menu_update_disabled ( gwin - > gw , browser_window_get_content ( gwin - > gw - > bw ) ) ;
2008-10-05 17:17:18 +04:00
if ( redraw )
{
2015-02-02 21:10:43 +03:00
ami_plot_clear_bbox ( gwin - > win - > RPort , bbox ) ;
2014-11-16 17:44:40 +03:00
browser_window_update ( gwin - > gw - > bw , false ) ;
2008-10-05 17:17:18 +04:00
2014-11-16 17:44:40 +03:00
gui_window_set_scroll ( gwin - > gw ,
gwin - > gw - > scrollx , gwin - > gw - > scrolly ) ;
2009-05-31 19:17:35 +04:00
gwin - > redraw_scroll = false ;
2008-11-09 17:02:04 +03:00
2014-11-16 17:44:40 +03:00
browser_window_refresh_url_bar ( gwin - > gw - > bw ) ;
2013-11-23 17:46:57 +04:00
ami_gui_update_hotlist_button ( gwin ) ;
2014-10-27 00:30:19 +03:00
ami_gui_scroller_update ( gwin ) ;
2014-11-16 17:44:40 +03:00
ami_throbber_redraw_schedule ( 0 , gwin - > gw ) ;
2015-01-31 15:28:14 +03:00
gui_window_set_icon ( gwin - > gw , gwin - > gw - > favicon ) ;
2008-10-05 17:17:18 +04:00
}
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2008-10-05 17:17:18 +04:00
}
2008-10-06 21:47:31 +04:00
void ami_quit_netsurf ( void )
{
struct nsObject * node ;
struct nsObject * nnode ;
2016-12-30 16:06:42 +03:00
struct ami_generic_window * w ;
2008-10-06 21:47:31 +04:00
2016-12-15 21:23:52 +03:00
/* Disable the multiple tabs open warning */
nsoption_set_bool ( tab_close_warn , false ) ;
2014-02-11 01:08:36 +04:00
if ( ! IsMinListEmpty ( window_list ) ) {
2009-09-29 02:17:09 +04:00
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
2008-10-06 21:47:31 +04:00
2014-02-11 01:08:36 +04:00
do {
2009-09-29 02:17:09 +04:00
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
2016-12-30 16:06:42 +03:00
w = node - > objstruct ;
2008-10-06 21:47:31 +04:00
2016-12-31 03:14:44 +03:00
if ( w - > tbl - > close ! = NULL ) {
if ( node - > Type = = AMINS_WINDOW ) {
struct gui_window_2 * gwin = ( struct gui_window_2 * ) w ;
2016-12-31 03:02:21 +03:00
ShowWindow ( gwin - > win , WINDOW_BACKMOST ) ; // do we need this??
2016-12-31 03:14:44 +03:00
}
w - > tbl - > close ( w ) ;
2014-02-11 01:08:36 +04:00
}
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2012-11-01 00:50:22 +04:00
win_destroyed = true ;
2009-09-29 02:17:09 +04:00
}
2008-10-06 21:47:31 +04:00
2014-02-11 01:08:36 +04:00
if ( IsMinListEmpty ( window_list ) ) {
2008-10-06 21:47:31 +04:00
/* last window closed, so exit */
2014-10-12 12:58:54 +04:00
ami_quit = true ;
2008-10-06 21:47:31 +04:00
}
}
2012-12-08 22:08:00 +04:00
void ami_quit_netsurf_delayed ( void )
{
2012-12-09 23:39:48 +04:00
int res = - 1 ;
# ifdef __amigaos4__
2012-12-08 22:08:00 +04:00
char * utf8text = ami_utf8_easy ( messages_get ( " TCPIPShutdown " ) ) ;
char * utf8gadgets = ami_utf8_easy ( messages_get ( " AbortShutdown " ) ) ;
DisplayBeep ( NULL ) ;
2012-12-10 00:00:11 +04:00
res = TimedDosRequesterTags ( TDR_ImageType , TDRIMAGE_INFO ,
2012-12-08 22:08:00 +04:00
TDR_TitleString , messages_get ( " NetSurf " ) ,
TDR_FormatString , utf8text ,
TDR_GadgetString , utf8gadgets ,
TDR_Timeout , 5 ,
TDR_Inactive , TRUE ,
TAG_DONE ) ;
free ( utf8text ) ;
free ( utf8gadgets ) ;
2012-12-09 23:39:48 +04:00
# endif
2012-12-08 22:08:00 +04:00
if ( res = = - 1 ) { /* Requester timed out */
ami_quit_netsurf ( ) ;
}
}
2014-10-16 12:55:01 +04:00
static void ami_gui_close_screen ( struct Screen * scrn , BOOL locked_screen , BOOL donotwait )
2011-06-16 22:46:43 +04:00
{
2011-09-11 03:25:49 +04:00
if ( scrn = = NULL ) return ;
2016-02-19 21:41:04 +03:00
if ( locked_screen ) {
UnlockPubScreen ( NULL , scrn ) ;
locked_screen = FALSE ;
}
2016-08-12 00:34:46 +03:00
/* If this is our own screen, wait for visitor windows to close */
if ( screen_signal = = - 1 ) return ;
2014-02-10 22:13:28 +04:00
if ( CloseScreen ( scrn ) = = TRUE ) {
2016-02-19 21:41:04 +03:00
if ( screen_signal ! = - 1 ) {
2014-02-10 23:21:47 +04:00
FreeSignal ( screen_signal ) ;
2014-02-11 00:31:06 +04:00
screen_signal = - 1 ;
2014-02-10 23:21:47 +04:00
scrn = NULL ;
}
2014-02-10 22:13:28 +04:00
return ;
}
2014-02-11 00:18:18 +04:00
if ( donotwait = = TRUE ) return ;
2011-06-16 22:46:43 +04:00
2016-02-19 21:41:04 +03:00
ULONG scrnsig = 1 < < screen_signal ;
LOG ( " Waiting for visitor windows to close... (signal) " ) ;
Wait ( scrnsig ) ;
2014-01-25 00:35:31 +04:00
while ( CloseScreen ( scrn ) = = FALSE ) {
2015-05-28 18:08:46 +03:00
LOG ( " Waiting for visitor windows to close... (polling) " ) ;
2014-01-25 00:35:31 +04:00
Delay ( 50 ) ;
}
2014-02-07 01:23:24 +04:00
FreeSignal ( screen_signal ) ;
2014-02-10 22:42:50 +04:00
screen_signal = - 1 ;
2014-02-10 22:13:28 +04:00
scrn = NULL ;
}
void ami_try_quit ( void )
{
2014-02-11 00:40:08 +04:00
if ( ! IsMinListEmpty ( window_list ) ) return ;
2014-02-10 22:13:28 +04:00
if ( nsoption_bool ( close_no_quit ) = = false )
{
2014-10-12 12:58:54 +04:00
ami_quit = true ;
2014-02-10 22:13:28 +04:00
return ;
}
else
{
2014-02-11 00:18:18 +04:00
ami_gui_close_screen ( scrn , locked_screen , TRUE ) ;
2014-02-10 22:13:28 +04:00
}
2011-06-16 22:46:43 +04:00
}
2014-01-11 18:20:30 +04:00
static void gui_quit ( void )
2008-08-02 18:31:32 +04:00
{
2010-03-24 01:27:33 +03:00
ami_theme_throbber_free ( ) ;
2008-09-11 23:33:40 +04:00
2012-03-22 13:34:34 +04:00
urldb_save ( nsoption_charp ( url_file ) ) ;
urldb_save_cookies ( nsoption_charp ( cookie_file ) ) ;
2017-01-07 02:56:52 +03:00
hotlist_fini ( nsoption_charp ( hotlist_file ) ) ;
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2009-09-28 22:00:40 +04:00
if ( IApplication & & ami_appid )
UnregisterApplication ( ami_appid , NULL ) ;
2015-01-17 20:06:48 +03:00
# endif
2008-12-08 00:50:04 +03:00
ami_arexx_cleanup ( ) ;
2017-02-13 20:46:20 +03:00
ami_plot_ra_free ( browserglob ) ;
2008-12-26 22:04:57 +03:00
2016-01-15 22:36:12 +03:00
ami_font_fini ( ) ;
2014-02-11 00:23:09 +04:00
ami_help_free ( ) ;
2013-09-28 17:58:03 +04:00
2015-05-28 18:08:46 +03:00
LOG ( " Freeing menu items " ) ;
2015-09-03 02:24:04 +03:00
ami_ctxmenu_free ( ) ;
2013-08-20 22:39:18 +04:00
ami_menu_free_glyphs ( ) ;
2010-10-05 23:14:46 +04:00
2015-05-28 18:08:46 +03:00
LOG ( " Freeing mouse pointers " ) ;
2010-03-24 01:27:33 +03:00
ami_mouse_pointers_free ( ) ;
2008-09-04 02:02:41 +04:00
2011-10-15 18:09:35 +04:00
ami_file_req_free ( ) ;
2009-01-11 00:31:21 +03:00
ami_openurl_close ( ) ;
2016-01-21 23:42:49 +03:00
FreeStringClass ( urlStringClass ) ;
2008-08-09 02:38:13 +04:00
2008-08-10 00:27:36 +04:00
FreeObjList ( window_list ) ;
2016-12-11 18:17:42 +03:00
ami_clipboard_free ( ) ;
2016-12-11 19:16:11 +03:00
ami_gui_resources_free ( ) ;
2016-12-11 18:17:42 +03:00
LOG ( " Closing screen " ) ;
ami_gui_close_screen ( scrn , locked_screen , FALSE ) ;
if ( nsscreentitle ) FreeVec ( nsscreentitle ) ;
2008-08-10 00:27:36 +04:00
}
2014-06-30 01:35:52 +04:00
char * ami_gui_get_cache_favicon_name ( nsurl * url , bool only_if_avail )
{
STRPTR filename = NULL ;
2014-10-25 19:22:08 +04:00
if ( ( filename = ASPrintf ( " %s/%x " , current_user_faviconcache , nsurl_hash ( url ) ) ) ) {
2015-05-28 18:08:46 +03:00
LOG ( " favicon cache location: %s " , filename ) ;
2014-06-30 01:35:52 +04:00
if ( only_if_avail = = true ) {
2016-07-10 01:43:17 +03:00
BPTR lock = 0 ;
2014-10-25 19:22:08 +04:00
if ( ( lock = Lock ( filename , ACCESS_READ ) ) ) {
2014-06-30 01:35:52 +04:00
UnLock ( lock ) ;
return filename ;
}
} else {
return filename ;
}
}
return NULL ;
}
static void ami_gui_cache_favicon ( nsurl * url , struct bitmap * favicon )
{
STRPTR filename = NULL ;
2014-10-25 19:22:08 +04:00
if ( ( filename = ami_gui_get_cache_favicon_name ( url , false ) ) ) {
2015-06-22 21:12:57 +03:00
if ( favicon ) amiga_bitmap_save ( favicon , filename , AMI_BITMAP_SCALE_ICON ) ;
2014-06-30 01:35:52 +04:00
FreeVec ( filename ) ;
}
}
2013-11-23 16:23:56 +04:00
void ami_gui_update_hotlist_button ( struct gui_window_2 * gwin )
{
char * url ;
nsurl * nsurl ;
GetAttr ( STRINGA_TextVal ,
( Object * ) gwin - > objects [ GID_URL ] ,
( ULONG * ) & url ) ;
if ( nsurl_create ( url , & nsurl ) = = NSERROR_OK ) {
if ( hotlist_has_url ( nsurl ) ) {
2013-11-23 17:11:30 +04:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_FAVE ] , gwin - > win , NULL ,
BUTTON_RenderImage , gwin - > objects [ GID_FAVE_RMV ] , TAG_DONE ) ;
2014-06-30 01:35:52 +04:00
2014-11-16 17:44:40 +03:00
if ( gwin - > gw - > favicon )
ami_gui_cache_favicon ( nsurl , content_get_bitmap ( gwin - > gw - > favicon ) ) ;
2013-11-23 16:23:56 +04:00
} else {
2013-11-23 17:11:30 +04:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_FAVE ] , gwin - > win , NULL ,
BUTTON_RenderImage , gwin - > objects [ GID_FAVE_ADD ] , TAG_DONE ) ;
2013-11-23 16:23:56 +04:00
}
nsurl_unref ( nsurl ) ;
}
}
2016-07-03 20:48:46 +03:00
static bool ami_gui_hotlist_add ( void * userdata , int level , int item ,
const char * title , nsurl * url , bool is_folder )
2012-11-28 23:29:43 +04:00
{
2013-09-12 15:29:47 +04:00
struct ami_gui_tb_userdata * tb_userdata = ( struct ami_gui_tb_userdata * ) userdata ;
2012-11-28 23:29:43 +04:00
struct Node * speed_button_node ;
2015-11-17 00:05:01 +03:00
char menu_icon [ 1024 ] ;
2016-02-14 17:45:28 +03:00
char * utf8title = NULL ;
2012-11-28 23:29:43 +04:00
2013-09-12 15:29:47 +04:00
if ( level ! = 1 ) return false ;
if ( item > AMI_GUI_TOOLBAR_MAX ) return false ;
if ( is_folder = = true ) return false ;
2015-01-31 14:21:14 +03:00
2016-02-14 17:45:28 +03:00
if ( utf8_from_local_encoding ( title ,
( strlen ( title ) < NSA_MAX_HOTLIST_BUTTON_LEN ) ? strlen ( title ) : NSA_MAX_HOTLIST_BUTTON_LEN ,
& utf8title ) ! = NSERROR_OK )
return false ;
2015-11-17 00:05:01 +03:00
char * iconname = ami_gui_get_cache_favicon_name ( url , true ) ;
if ( iconname = = NULL ) iconname = ASPrintf ( " icons/content.png " ) ;
ami_locate_resource ( menu_icon , iconname ) ;
tb_userdata - > gw - > hotlist_toolbar_lab [ item ] = BitMapObj ,
IA_Scalable , TRUE ,
BITMAP_Screen , scrn ,
BITMAP_SourceFile , menu_icon ,
BITMAP_Masking , TRUE ,
BitMapEnd ;
/* \todo make this scale the bitmap to these dimensions */
SetAttrs ( tb_userdata - > gw - > hotlist_toolbar_lab [ item ] ,
BITMAP_Width , 16 ,
BITMAP_Height , 16 ,
TAG_DONE ) ;
Object * lab_item = LabelObj ,
// LABEL_DrawInfo, dri,
LABEL_DisposeImage , TRUE ,
LABEL_Image , tb_userdata - > gw - > hotlist_toolbar_lab [ item ] ,
LABEL_Text , " " ,
LABEL_Text , utf8title ,
LabelEnd ;
free ( utf8title ) ;
2015-01-31 16:58:35 +03:00
2013-09-12 15:29:47 +04:00
speed_button_node = AllocSpeedButtonNode ( item ,
2015-11-17 00:05:01 +03:00
SBNA_Image , lab_item ,
2016-02-14 17:48:41 +03:00
SBNA_HintInfo , nsurl_access ( url ) ,
2013-09-12 15:29:47 +04:00
SBNA_UserData , ( void * ) url ,
2012-11-28 23:29:43 +04:00
TAG_DONE ) ;
2013-09-12 15:29:47 +04:00
AddTail ( tb_userdata - > sblist , speed_button_node ) ;
2012-11-28 23:29:43 +04:00
2013-09-12 15:29:47 +04:00
tb_userdata - > items + + ;
return true ;
2012-11-28 23:29:43 +04:00
}
2017-01-07 02:56:52 +03:00
static int ami_gui_hotlist_scan ( struct List * speed_button_list , struct gui_window_2 * gwin )
2012-11-28 23:29:43 +04:00
{
2013-09-12 15:29:47 +04:00
struct ami_gui_tb_userdata userdata ;
userdata . gw = gwin ;
userdata . sblist = speed_button_list ;
userdata . items = 0 ;
2012-11-28 23:29:43 +04:00
2013-09-12 15:29:47 +04:00
ami_hotlist_scan ( ( void * ) & userdata , 0 , messages_get ( " HotlistToolbar " ) , ami_gui_hotlist_add ) ;
return userdata . items ;
2012-11-28 23:29:43 +04:00
}
2014-10-16 12:55:01 +04:00
static void ami_gui_hotlist_toolbar_add ( struct gui_window_2 * gwin )
2012-11-28 23:29:43 +04:00
{
2012-12-15 17:39:40 +04:00
struct TagItem attrs [ 2 ] ;
attrs [ 0 ] . ti_Tag = CHILD_MinWidth ;
attrs [ 0 ] . ti_Data = 0 ;
attrs [ 1 ] . ti_Tag = TAG_DONE ;
attrs [ 1 ] . ti_Data = 0 ;
2012-11-28 23:29:43 +04:00
NewList ( & gwin - > hotlist_toolbar_list ) ;
2017-01-07 02:56:52 +03:00
if ( ami_gui_hotlist_scan ( & gwin - > hotlist_toolbar_list , gwin ) > 0 ) {
2012-11-28 23:29:43 +04:00
gwin - > objects [ GID_HOTLIST ] =
2015-01-25 15:45:20 +03:00
SpeedBarObj ,
2012-11-28 23:29:43 +04:00
GA_ID , GID_HOTLIST ,
GA_RelVerify , TRUE ,
2012-12-01 04:27:46 +04:00
ICA_TARGET , ICTARGET_IDCMP ,
2012-11-29 02:42:23 +04:00
SPEEDBAR_BevelStyle , BVS_NONE ,
2012-11-28 23:29:43 +04:00
SPEEDBAR_Buttons , & gwin - > hotlist_toolbar_list ,
SpeedBarEnd ;
2012-11-29 02:42:23 +04:00
gwin - > objects [ GID_HOTLISTSEPBAR ] =
2015-01-25 15:45:20 +03:00
BevelObj ,
2012-11-29 02:42:23 +04:00
BEVEL_Style , BVS_SBAR_VERT ,
BevelEnd ;
2015-01-31 14:59:31 +03:00
# ifdef __amigaos4__
2012-11-28 23:29:43 +04:00
IDoMethod ( gwin - > objects [ GID_HOTLISTLAYOUT ] , LM_ADDCHILD ,
2012-12-15 17:39:40 +04:00
gwin - > win , gwin - > objects [ GID_HOTLIST ] , attrs ) ;
2012-11-29 02:42:23 +04:00
IDoMethod ( gwin - > objects [ GID_HOTLISTLAYOUT ] , LM_ADDIMAGE ,
gwin - > win , gwin - > objects [ GID_HOTLISTSEPBAR ] , NULL ) ;
2012-11-30 02:13:42 +04:00
2015-01-31 14:59:31 +03:00
# else
SetAttrs ( gwin - > objects [ GID_HOTLISTLAYOUT ] ,
LAYOUT_AddChild , gwin - > objects [ GID_HOTLIST ] , TAG_MORE , & attrs ) ;
SetAttrs ( gwin - > objects [ GID_HOTLISTLAYOUT ] ,
LAYOUT_AddChild , gwin - > objects [ GID_HOTLISTSEPBAR ] , TAG_DONE ) ;
# endif
2012-11-30 02:13:42 +04:00
FlushLayoutDomainCache ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ) ;
RethinkLayout ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ,
gwin - > win , NULL , TRUE ) ;
2012-12-01 19:15:12 +04:00
2014-12-10 20:44:38 +03:00
ami_schedule_redraw ( gwin , true ) ;
2012-11-28 23:29:43 +04:00
}
2012-11-30 02:13:42 +04:00
}
2014-10-25 19:22:08 +04:00
static void ami_gui_hotlist_toolbar_free ( struct gui_window_2 * gwin , struct List * speed_button_list )
2012-11-30 02:13:42 +04:00
{
int i ;
struct Node * node ;
struct Node * nnode ;
2014-10-26 20:08:23 +03:00
if ( nsoption_bool ( kiosk_mode ) = = true ) return ;
2012-11-30 02:13:42 +04:00
if ( IsListEmpty ( speed_button_list ) ) return ;
node = GetHead ( speed_button_list ) ;
do {
nnode = GetSucc ( node ) ;
Remove ( node ) ;
FreeSpeedButtonNode ( node ) ;
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2012-11-30 02:13:42 +04:00
for ( i = 0 ; i < AMI_GUI_TOOLBAR_MAX ; i + + ) {
if ( gwin - > hotlist_toolbar_lab [ i ] ) {
2015-11-17 00:05:01 +03:00
DisposeObject ( gwin - > hotlist_toolbar_lab [ i ] ) ;
2012-11-30 02:13:42 +04:00
gwin - > hotlist_toolbar_lab [ i ] = NULL ;
}
}
}
2014-10-25 19:22:08 +04:00
static void ami_gui_hotlist_toolbar_remove ( struct gui_window_2 * gwin )
2012-11-30 02:13:42 +04:00
{
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2012-11-30 02:13:42 +04:00
IDoMethod ( gwin - > objects [ GID_HOTLISTLAYOUT ] , LM_REMOVECHILD ,
gwin - > win , gwin - > objects [ GID_HOTLIST ] ) ;
IDoMethod ( gwin - > objects [ GID_HOTLISTLAYOUT ] , LM_REMOVECHILD ,
gwin - > win , gwin - > objects [ GID_HOTLISTSEPBAR ] ) ;
2015-01-31 14:59:31 +03:00
# else
2017-01-02 21:41:40 +03:00
SetAttrs ( gwin - > objects [ GID_HOTLISTLAYOUT ] ,
LAYOUT_RemoveChild , gwin - > objects [ GID_HOTLIST ] , TAG_DONE ) ;
SetAttrs ( gwin - > objects [ GID_HOTLISTLAYOUT ] ,
LAYOUT_RemoveChild , gwin - > objects [ GID_HOTLISTSEPBAR ] , TAG_DONE ) ;
2015-01-31 14:59:31 +03:00
# endif
2012-11-28 23:41:18 +04:00
FlushLayoutDomainCache ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ) ;
RethinkLayout ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ,
gwin - > win , NULL , TRUE ) ;
2012-11-30 02:13:42 +04:00
2013-04-04 22:31:42 +04:00
ami_schedule_redraw ( gwin , true ) ;
2012-11-30 02:13:42 +04:00
}
2014-10-25 19:22:08 +04:00
static void ami_gui_hotlist_toolbar_update ( struct gui_window_2 * gwin )
2012-11-30 02:13:42 +04:00
{
if ( IsListEmpty ( & gwin - > hotlist_toolbar_list ) ) {
ami_gui_hotlist_toolbar_add ( gwin ) ;
return ;
}
/* Below should be SetAttr according to Autodocs */
SetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_HOTLIST ] ,
gwin - > win , NULL ,
SPEEDBAR_Buttons , ~ 0 ,
TAG_DONE ) ;
ami_gui_hotlist_toolbar_free ( gwin , & gwin - > hotlist_toolbar_list ) ;
2017-01-07 02:56:52 +03:00
if ( ami_gui_hotlist_scan ( & gwin - > hotlist_toolbar_list , gwin ) > 0 ) {
2012-11-30 02:13:42 +04:00
SetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_HOTLIST ] ,
gwin - > win , NULL ,
SPEEDBAR_Buttons , & gwin - > hotlist_toolbar_list ,
TAG_DONE ) ;
} else {
ami_gui_hotlist_toolbar_remove ( gwin ) ;
}
}
2014-07-01 01:37:05 +04:00
/**
* Update hotlist toolbar and recreate the menu for all windows
*/
void ami_gui_hotlist_update_all ( void )
2012-11-30 02:13:42 +04:00
{
struct nsObject * node ;
struct nsObject * nnode ;
struct gui_window_2 * gwin ;
if ( IsMinListEmpty ( window_list ) ) return ;
2017-01-17 01:24:05 +03:00
ami_gui_menu_refresh_hotlist ( ) ;
2017-01-15 20:51:55 +03:00
2012-11-30 02:13:42 +04:00
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
do {
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
gwin = node - > objstruct ;
2017-01-15 23:01:49 +03:00
if ( node - > Type = = AMINS_WINDOW ) {
2012-11-30 02:13:42 +04:00
ami_gui_hotlist_toolbar_update ( gwin ) ;
}
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2012-11-28 23:29:43 +04:00
}
2014-10-25 19:22:08 +04:00
static void ami_toggletabbar ( struct gui_window_2 * gwin , bool show )
2010-02-14 03:46:53 +03:00
{
if ( ClickTabBase - > lib_Version < 53 ) return ;
2015-01-31 14:59:31 +03:00
if ( show ) {
2010-02-14 18:32:54 +03:00
struct TagItem attrs [ 3 ] ;
attrs [ 0 ] . ti_Tag = CHILD_WeightedWidth ;
attrs [ 0 ] . ti_Data = 0 ;
attrs [ 1 ] . ti_Tag = CHILD_WeightedHeight ;
attrs [ 1 ] . ti_Data = 0 ;
attrs [ 2 ] . ti_Tag = TAG_DONE ;
attrs [ 2 ] . ti_Data = 0 ;
2010-02-14 17:00:33 +03:00
2015-01-25 15:45:20 +03:00
gwin - > objects [ GID_TABS ] = ClickTabObj ,
2010-02-14 03:46:53 +03:00
GA_ID , GID_TABS ,
GA_RelVerify , TRUE ,
GA_Underscore , 13 , // disable kb shortcuts
2015-09-05 03:41:56 +03:00
GA_ContextMenu , ami_ctxmenu_clicktab_create ( gwin ) ,
2010-02-14 03:46:53 +03:00
CLICKTAB_Labels , & gwin - > tab_list ,
CLICKTAB_LabelTruncate , TRUE ,
CLICKTAB_CloseImage , gwin - > objects [ GID_CLOSETAB_BM ] ,
CLICKTAB_FlagImage , gwin - > objects [ GID_TABS_FLAG ] ,
ClickTabEnd ;
2015-01-25 15:45:20 +03:00
gwin - > objects [ GID_ADDTAB ] = ButtonObj ,
2010-02-14 17:00:33 +03:00
GA_ID , GID_ADDTAB ,
GA_RelVerify , TRUE ,
2010-03-18 00:43:23 +03:00
GA_HintInfo , gwin - > helphints [ GID_ADDTAB ] ,
2010-02-14 17:00:33 +03:00
GA_Text , " + " ,
BUTTON_RenderImage , gwin - > objects [ GID_ADDTAB_BM ] ,
ButtonEnd ;
2015-01-31 14:59:31 +03:00
# ifdef __amigaos4__
2010-02-14 03:46:53 +03:00
IDoMethod ( gwin - > objects [ GID_TABLAYOUT ] , LM_ADDCHILD ,
gwin - > win , gwin - > objects [ GID_TABS ] , NULL ) ;
2010-02-14 17:00:33 +03:00
2010-02-14 18:32:54 +03:00
IDoMethod ( gwin - > objects [ GID_TABLAYOUT ] , LM_ADDCHILD ,
gwin - > win , gwin - > objects [ GID_ADDTAB ] , attrs ) ;
2015-01-31 14:59:31 +03:00
# else
SetAttrs ( gwin - > objects [ GID_TABLAYOUT ] ,
LAYOUT_AddChild , gwin - > objects [ GID_TABS ] , TAG_DONE ) ;
SetAttrs ( gwin - > objects [ GID_TABLAYOUT ] ,
LAYOUT_AddChild , gwin - > objects [ GID_ADDTAB ] , TAG_MORE , & attrs ) ;
# endif
} else {
# ifdef __amigaos4__
2010-02-14 03:46:53 +03:00
IDoMethod ( gwin - > objects [ GID_TABLAYOUT ] , LM_REMOVECHILD ,
gwin - > win , gwin - > objects [ GID_TABS ] ) ;
2010-02-14 17:00:33 +03:00
2010-02-14 18:32:54 +03:00
IDoMethod ( gwin - > objects [ GID_TABLAYOUT ] , LM_REMOVECHILD ,
2010-02-14 17:00:33 +03:00
gwin - > win , gwin - > objects [ GID_ADDTAB ] ) ;
2015-01-31 14:59:31 +03:00
# else
SetAttrs ( gwin - > objects [ GID_TABLAYOUT ] ,
LAYOUT_RemoveChild , gwin - > objects [ GID_TABS ] , TAG_DONE ) ;
SetAttrs ( gwin - > objects [ GID_TABLAYOUT ] ,
LAYOUT_RemoveChild , gwin - > objects [ GID_ADDTAB ] , TAG_DONE ) ;
# endif
2014-02-06 23:35:52 +04:00
gwin - > objects [ GID_TABS ] = NULL ;
gwin - > objects [ GID_ADDTAB ] = NULL ;
2010-02-14 03:46:53 +03:00
}
FlushLayoutDomainCache ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ) ;
RethinkLayout ( ( struct Gadget * ) gwin - > objects [ GID_MAIN ] ,
gwin - > win , NULL , TRUE ) ;
2014-12-19 14:57:32 +03:00
if ( gwin - > gw & & gwin - > gw - > bw ) browser_window_update ( gwin - > gw - > bw , false ) ;
2010-02-14 03:46:53 +03:00
}
2012-12-10 00:39:10 +04:00
void ami_gui_tabs_toggle_all ( void )
{
struct nsObject * node ;
struct nsObject * nnode ;
struct gui_window_2 * gwin ;
if ( IsMinListEmpty ( window_list ) ) return ;
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
do {
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
gwin = node - > objstruct ;
if ( node - > Type = = AMINS_WINDOW )
{
if ( gwin - > tabs = = 1 ) {
if ( nsoption_bool ( tab_always_show ) = = true ) {
ami_toggletabbar ( gwin , true ) ;
} else {
ami_toggletabbar ( gwin , false ) ;
}
}
}
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2012-12-10 00:39:10 +04:00
}
2014-10-25 19:22:08 +04:00
static void ami_gui_search_ico_refresh ( void * p )
2014-07-05 21:44:44 +04:00
{
search_web_select_provider ( - 1 ) ;
}
2014-10-26 18:41:44 +03:00
/**
* Count windows , and optionally tabs .
*
* \ param window window to count tabs of
2014-10-26 19:12:34 +03:00
* \ param tabs if window > 0 , will be updated to contain the number of tabs
* in that window , unchanged otherwise
2014-10-26 18:41:44 +03:00
* \ return number of windows currently open
*/
int ami_gui_count_windows ( int window , int * tabs )
{
int windows = 0 ;
struct nsObject * node , * nnode ;
struct gui_window_2 * gwin ;
if ( ! IsMinListEmpty ( window_list ) ) {
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
do {
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
gwin = node - > objstruct ;
if ( node - > Type = = AMINS_WINDOW ) {
windows + + ;
if ( window = = windows ) * tabs = gwin - > tabs ;
}
} while ( ( node = nnode ) ) ;
}
return windows ;
}
2014-12-04 14:42:12 +03:00
/**
* Set the scale of a gui window
*
* \ param gw gui_window to set scale for
* \ param scale scale to set
*/
void ami_gui_set_scale ( struct gui_window * gw , float scale )
{
2015-11-15 17:07:25 +03:00
if ( scale < = 0.0 ) return ;
2014-12-04 14:42:12 +03:00
gw - > scale = scale ;
browser_window_set_scale ( gw - > bw , scale , true ) ;
}
2016-09-10 22:36:11 +03:00
void ami_gui_switch_to_new_tab ( struct gui_window_2 * gwin )
{
if ( nsoption_bool ( new_tab_is_active ) = = true ) return ;
/* Switch to the just-opened tab (if new_tab_is_active, we already did!) */
RefreshSetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_TABS ] ,
gwin - > win , NULL ,
CLICKTAB_CurrentNode , gwin - > last_new_tab ,
TAG_DONE ) ;
ami_switch_tab ( gwin , false ) ;
}
2014-01-03 22:17:25 +04:00
nserror ami_gui_new_blank_tab ( struct gui_window_2 * gwin )
{
nsurl * url ;
nserror error ;
struct browser_window * bw = NULL ;
error = nsurl_create ( nsoption_charp ( homepage_url ) , & url ) ;
if ( error = = NSERROR_OK ) {
2014-02-10 18:08:45 +04:00
error = browser_window_create ( BW_CREATE_HISTORY |
BW_CREATE_TAB ,
2014-01-03 22:17:25 +04:00
url ,
NULL ,
2014-11-16 17:44:40 +03:00
gwin - > gw - > bw ,
2014-01-03 22:17:25 +04:00
& bw ) ;
nsurl_unref ( url ) ;
}
if ( error ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( messages_get_errorcode ( error ) , 0 ) ;
2014-01-03 22:17:25 +04:00
return error ;
}
2014-02-09 03:06:24 +04:00
2016-09-10 22:36:11 +03:00
ami_gui_switch_to_new_tab ( gwin ) ;
2016-09-04 19:35:32 +03:00
2014-01-03 22:17:25 +04:00
return NSERROR_OK ;
}
2015-02-23 23:34:24 +03:00
static void ami_do_redraw_tiled ( struct gui_window_2 * gwin , bool busy ,
int left , int top , int width , int height ,
int sx , int sy , struct IBox * bbox , struct redraw_context * ctx )
{
2017-02-13 03:18:32 +03:00
struct gui_globals * glob = ( struct gui_globals * ) ctx - > priv ;
2015-02-23 23:34:24 +03:00
int x , y ;
struct rect clip ;
2017-02-13 21:16:22 +03:00
int tile_size_x ;
int tile_size_y ;
ami_plot_ra_get_size ( glob , & tile_size_x , & tile_size_y ) ;
2015-04-25 14:02:08 +03:00
int tile_x_scale = ( int ) ( tile_size_x / gwin - > gw - > scale ) ;
int tile_y_scale = ( int ) ( tile_size_y / gwin - > gw - > scale ) ;
2017-02-13 21:09:43 +03:00
ami_plot_ra_set_pen_list ( glob , gwin - > shared_pens ) ;
2015-02-23 23:34:24 +03:00
if ( top < 0 ) {
height + = top ;
top = 0 ;
}
if ( left < 0 ) {
width + = left ;
left = 0 ;
}
if ( top < sy ) {
height + = ( top - sy ) ;
top = sy ;
}
if ( left < sx ) {
width + = ( left - sx ) ;
left = sx ;
}
if ( ( ( top - sy ) + height ) > bbox - > Height )
height = bbox - > Height - ( top - sy ) ;
if ( ( ( left - sx ) + width ) > bbox - > Width )
width = bbox - > Width - ( left - sx ) ;
if ( width < = 0 ) return ;
if ( height < = 0 ) return ;
if ( busy ) ami_set_pointer ( gwin , GUI_POINTER_WAIT , false ) ;
for ( y = top ; y < ( top + height ) ; y + = tile_y_scale ) {
clip . y0 = 0 ;
2015-04-25 14:02:08 +03:00
clip . y1 = tile_size_y ;
2015-02-23 23:34:24 +03:00
if ( clip . y1 > height ) clip . y1 = height ;
if ( ( ( ( y - sy ) * gwin - > gw - > scale ) + clip . y1 ) > bbox - > Height )
clip . y1 = bbox - > Height - ( ( y - sy ) * gwin - > gw - > scale ) ;
for ( x = left ; x < ( left + width ) ; x + = tile_x_scale ) {
clip . x0 = 0 ;
2015-04-25 14:02:08 +03:00
clip . x1 = tile_size_x ;
2015-02-23 23:34:24 +03:00
if ( clip . x1 > width ) clip . x1 = width ;
if ( ( ( ( x - sx ) * gwin - > gw - > scale ) + clip . x1 ) > bbox - > Width )
clip . x1 = bbox - > Width - ( ( x - sx ) * gwin - > gw - > scale ) ;
if ( browser_window_redraw ( gwin - > gw - > bw ,
clip . x0 - ( int ) x ,
clip . y0 - ( int ) y ,
& clip , ctx ) )
{
2017-02-13 20:46:20 +03:00
ami_clearclipreg ( glob ) ;
2015-02-23 23:34:24 +03:00
# ifdef __amigaos4__
BltBitMapTags ( BLITA_SrcType , BLITT_BITMAP ,
2017-02-13 20:46:20 +03:00
BLITA_Source , ami_plot_ra_get_bitmap ( glob ) ,
2015-02-23 23:34:24 +03:00
BLITA_SrcX , 0 ,
BLITA_SrcY , 0 ,
BLITA_DestType , BLITT_RASTPORT ,
BLITA_Dest , gwin - > win - > RPort ,
BLITA_DestX , bbox - > Left + ( int ) ( ( x - sx ) * gwin - > gw - > scale ) ,
BLITA_DestY , bbox - > Top + ( int ) ( ( y - sy ) * gwin - > gw - > scale ) ,
BLITA_Width , ( int ) ( clip . x1 ) ,
BLITA_Height , ( int ) ( clip . y1 ) ,
TAG_DONE ) ;
# else
2017-02-13 20:46:20 +03:00
BltBitMapRastPort ( ami_plot_ra_get_bitmap ( glob ) , 0 , 0 , gwin - > win - > RPort ,
2015-02-23 23:34:24 +03:00
bbox - > Left + ( int ) ( ( x - sx ) * gwin - > gw - > scale ) ,
bbox - > Top + ( int ) ( ( y - sy ) * gwin - > gw - > scale ) ,
( int ) ( clip . x1 ) , ( int ) ( clip . y1 ) , 0xC0 ) ;
# endif
}
}
}
if ( busy ) ami_reset_pointer ( gwin ) ;
}
/**
* Redraw an area of the browser window - Amiga - specific function
*
* \ param g a struct gui_window
* \ param bw a struct browser_window
* \ param busy busy flag passed to tiled redraw .
* \ param x0 top - left co - ordinate ( in document co - ordinates )
* \ param y0 top - left co - ordinate ( in document co - ordinates )
* \ param x1 bottom - right co - ordinate ( in document co - ordinates )
* \ param y1 bottom - right co - ordinate ( in document co - ordinates )
*/
static void ami_do_redraw_limits ( struct gui_window * g , struct browser_window * bw , bool busy ,
int x0 , int y0 , int x1 , int y1 )
{
struct IBox * bbox ;
ULONG sx , sy ;
struct redraw_context ctx = {
. interactive = true ,
. background_images = true ,
2017-02-13 03:18:32 +03:00
. plot = & amiplot ,
2017-02-13 20:46:20 +03:00
. priv = browserglob
2015-02-23 23:34:24 +03:00
} ;
if ( ! g ) return ;
if ( browser_window_redraw_ready ( bw ) = = false ) return ;
sx = g - > scrollx ;
sy = g - > scrolly ;
if ( g ! = g - > shared - > gw ) return ;
if ( ami_gui_get_space_box ( ( Object * ) g - > shared - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2015-02-23 23:34:24 +03:00
return ;
}
ami_do_redraw_tiled ( g - > shared , busy , x0 , y0 ,
( x1 - x0 ) * g - > scale , ( y1 - y0 ) * g - > scale , sx , sy , bbox , & ctx ) ;
ami_gui_free_space_box ( bbox ) ;
return ;
}
static void ami_refresh_window ( struct gui_window_2 * gwin )
{
/* simplerefresh only */
struct IBox * bbox ;
2017-01-09 02:10:27 +03:00
int sx , sy ;
2015-02-23 23:34:24 +03:00
struct RegionRectangle * regrect ;
2017-01-09 02:10:27 +03:00
struct rect r ;
2015-02-23 23:34:24 +03:00
sx = gwin - > gw - > scrollx ;
sy = gwin - > gw - > scrolly ;
ami_set_pointer ( gwin , GUI_POINTER_WAIT , false ) ;
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2015-02-23 23:34:24 +03:00
return ;
}
BeginRefresh ( gwin - > win ) ;
2017-01-09 02:10:27 +03:00
r . x0 = ( ( gwin - > win - > RPort - > Layer - > DamageList - > bounds . MinX - bbox - > Left ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sx - 1 ;
2017-01-09 02:10:27 +03:00
r . x1 = ( ( gwin - > win - > RPort - > Layer - > DamageList - > bounds . MaxX - bbox - > Left ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sx + 2 ;
2017-01-09 02:10:27 +03:00
r . y0 = ( ( gwin - > win - > RPort - > Layer - > DamageList - > bounds . MinY - bbox - > Top ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sy - 1 ;
2017-01-09 02:10:27 +03:00
r . y1 = ( ( gwin - > win - > RPort - > Layer - > DamageList - > bounds . MaxY - bbox - > Top ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sy + 2 ;
regrect = gwin - > win - > RPort - > Layer - > DamageList - > RegionRectangle ;
2017-01-09 02:10:27 +03:00
gui_window_update_box ( gwin - > gw , & r ) ;
2015-02-23 23:34:24 +03:00
while ( regrect )
{
2017-01-09 02:10:27 +03:00
r . x0 = ( ( regrect - > bounds . MinX - bbox - > Left ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sx - 1 ;
2017-01-09 02:10:27 +03:00
r . x1 = ( ( regrect - > bounds . MaxX - bbox - > Left ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sx + 2 ;
2017-01-09 02:10:27 +03:00
r . y0 = ( ( regrect - > bounds . MinY - bbox - > Top ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sy - 1 ;
2017-01-09 02:10:27 +03:00
r . y1 = ( ( regrect - > bounds . MaxY - bbox - > Top ) /
2015-02-23 23:34:24 +03:00
browser_window_get_scale ( gwin - > gw - > bw ) ) + sy + 2 ;
regrect = regrect - > Next ;
2017-01-09 02:10:27 +03:00
gui_window_update_box ( gwin - > gw , & r ) ;
2015-02-23 23:34:24 +03:00
}
EndRefresh ( gwin - > win , TRUE ) ;
ami_gui_free_space_box ( bbox ) ;
ami_reset_pointer ( gwin ) ;
}
2015-02-24 01:58:57 +03:00
HOOKF ( void , ami_scroller_hook , Object * , object , struct IntuiMessage * )
2015-02-23 23:34:24 +03:00
{
ULONG gid ;
struct gui_window_2 * gwin = hook - > h_Data ;
struct IntuiWheelData * wheel ;
struct Node * node = NULL ;
nsurl * url ;
switch ( msg - > Class )
{
case IDCMP_IDCMPUPDATE :
gid = GetTagData ( GA_ID , 0 , msg - > IAddress ) ;
switch ( gid )
{
case GID_HSCROLL :
case GID_VSCROLL :
if ( nsoption_bool ( faster_scroll ) = = true ) gwin - > redraw_scroll = true ;
else gwin - > redraw_scroll = false ;
ami_schedule_redraw ( gwin , true ) ;
break ;
case GID_HOTLIST :
if ( ( node = ( struct Node * ) GetTagData ( SPEEDBAR_SelectedNode , 0 , msg - > IAddress ) ) ) {
GetSpeedButtonNodeAttrs ( node , SBNA_UserData , ( ULONG * ) & url , TAG_DONE ) ;
if ( gwin - > key_state & BROWSER_MOUSE_MOD_2 ) {
browser_window_create ( BW_CREATE_TAB ,
url ,
NULL ,
gwin - > gw - > bw ,
NULL ) ;
} else {
browser_window_navigate ( gwin - > gw - > bw ,
url ,
NULL ,
BW_NAVIGATE_HISTORY ,
NULL ,
NULL ,
NULL ) ;
}
}
break ;
}
break ;
# ifdef __amigaos4__
case IDCMP_EXTENDEDMOUSE :
if ( msg - > Code = = IMSGCODE_INTUIWHEELDATA )
{
wheel = ( struct IntuiWheelData * ) msg - > IAddress ;
ami_gui_scroll_internal ( gwin , wheel - > WheelX * 50 , wheel - > WheelY * 50 ) ;
}
break ;
# endif
case IDCMP_SIZEVERIFY :
break ;
case IDCMP_REFRESHWINDOW :
ami_refresh_window ( gwin ) ;
break ;
default :
2017-01-08 16:59:51 +03:00
LOG ( " IDCMP hook unhandled event: %ld " , msg - > Class ) ;
2015-02-23 23:34:24 +03:00
break ;
}
// ReplyMsg((struct Message *)msg);
}
2016-12-30 03:59:12 +03:00
/* exported function documented in gui.h */
2016-12-30 16:06:42 +03:00
nserror ami_gui_win_list_add ( void * win , int type , const struct ami_win_event_table * table )
2016-12-30 03:59:12 +03:00
{
struct nsObject * node = AddObject ( window_list , type ) ;
if ( node = = NULL ) return NSERROR_NOMEM ;
node - > objstruct = win ;
struct ami_generic_window * w = ( struct ami_generic_window * ) win ;
w - > tbl = table ;
w - > node = node ;
return NSERROR_OK ;
}
/* exported function documented in gui.h */
void ami_gui_win_list_remove ( void * win )
{
struct ami_generic_window * w = ( struct ami_generic_window * ) win ;
2016-12-30 16:06:42 +03:00
if ( w - > node - > Type = = AMINS_TVWINDOW ) {
DelObjectNoFree ( w - > node ) ;
} else {
DelObject ( w - > node ) ;
}
2016-12-30 03:59:12 +03:00
}
2016-12-30 16:06:42 +03:00
static const struct ami_win_event_table ami_gui_table = {
2016-12-30 03:59:12 +03:00
ami_gui_event ,
ami_gui_close_window ,
} ;
2014-01-12 02:34:12 +04:00
static struct gui_window *
gui_window_create ( struct browser_window * bw ,
2014-02-09 17:07:39 +04:00
struct gui_window * existing ,
gui_window_create_flags flags )
2008-08-02 18:31:32 +04:00
{
2012-04-29 20:13:53 +04:00
struct gui_window * g = NULL ;
2014-10-26 19:12:34 +03:00
ULONG offset = 0 ;
ULONG curx = nsoption_int ( window_x ) , cury = nsoption_int ( window_y ) ;
ULONG curw = nsoption_int ( window_width ) , curh = nsoption_int ( window_height ) ;
Added ability to load toolbar images from a different path.
Default is still TBImages: (ie AISS, http://www.masonicons.de)
All of the following must be present, in any format that bitmap.image will load
(usually this means any picture.datatype subclasses):
home, home_g, home_s - Home button
nav_east, nav_east_g, nav_east_s - History forward
nav_west, nav_west_g, nav_west_s - History back
reload, reload_g, reload_s - Reload
stop, stop_g, stop_s - Stop
The _g and _s files are ghosted and selected versions respectively.
To set the path, use toolbar_images:<path> in Options.
svn path=/trunk/netsurf/; revision=5304
2008-09-12 01:32:55 +04:00
char nav_west [ 100 ] , nav_west_s [ 100 ] , nav_west_g [ 100 ] ;
char nav_east [ 100 ] , nav_east_s [ 100 ] , nav_east_g [ 100 ] ;
char stop [ 100 ] , stop_s [ 100 ] , stop_g [ 100 ] ;
char reload [ 100 ] , reload_s [ 100 ] , reload_g [ 100 ] ;
char home [ 100 ] , home_s [ 100 ] , home_g [ 100 ] ;
2009-02-18 23:04:59 +03:00
char closetab [ 100 ] , closetab_s [ 100 ] , closetab_g [ 100 ] ;
2010-02-14 17:00:33 +03:00
char addtab [ 100 ] , addtab_s [ 100 ] , addtab_g [ 100 ] ;
2013-11-23 17:11:30 +04:00
char fave [ 100 ] , unfave [ 100 ] ;
2009-09-06 15:23:35 +04:00
char tabthrobber [ 100 ] ;
2012-04-29 03:23:29 +04:00
ULONG refresh_mode = WA_SmartRefresh ;
2015-02-23 22:28:32 +03:00
ULONG defer_layout = TRUE ;
2013-04-10 22:36:38 +04:00
ULONG idcmp_sizeverify = IDCMP_SIZEVERIFY ;
2008-09-04 02:02:41 +04:00
2016-03-01 02:06:10 +03:00
LOG ( " Creating window " ) ;
2012-03-22 13:34:34 +04:00
if ( ! scrn ) ami_openscreenfirst ( ) ;
2009-09-29 02:17:09 +04:00
2014-02-09 17:31:48 +04:00
if ( nsoption_bool ( kiosk_mode ) ) flags & = ~ GW_CREATE_TAB ;
2013-04-10 22:36:38 +04:00
if ( nsoption_bool ( resize_with_contents ) ) idcmp_sizeverify = 0 ;
2008-10-05 18:22:02 +04:00
2014-10-26 19:12:34 +03:00
/* Offset the new window by titlebar + 1 as per AmigaOS style guide.
* If we don ' t have a clone window we offset by all windows open . */
offset = scrn - > WBorTop + scrn - > Font - > ta_YSize + 1 ;
if ( existing ) {
curx = existing - > shared - > win - > LeftEdge ;
cury = existing - > shared - > win - > TopEdge + offset ;
curw = existing - > shared - > win - > Width ;
curh = existing - > shared - > win - > Height ;
} else {
if ( nsoption_bool ( kiosk_mode ) = = false ) {
cury + = offset * ami_gui_count_windows ( 0 , NULL ) ;
}
2008-09-04 02:02:41 +04:00
}
2014-10-26 19:12:34 +03:00
if ( curh > ( scrn - > Height - cury ) ) curh = scrn - > Height - cury ;
2016-11-20 00:02:42 +03:00
g = calloc ( 1 , sizeof ( struct gui_window ) ) ;
2008-08-09 02:38:13 +04:00
2012-04-29 20:13:53 +04:00
if ( ! g )
2008-08-02 18:31:32 +04:00
{
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2008-08-31 01:32:05 +04:00
return NULL ;
2008-08-02 18:31:32 +04:00
}
2012-04-29 20:13:53 +04:00
NewList ( & g - > dllist ) ;
2013-02-03 18:01:48 +04:00
g - > deferred_rects = NewObjList ( ) ;
2016-11-20 19:30:33 +03:00
g - > deferred_rects_pool = ami_memory_itempool_create ( sizeof ( struct rect ) ) ;
2014-11-16 17:24:18 +03:00
g - > bw = bw ;
2014-12-04 22:02:59 +03:00
g - > scale = browser_window_get_scale ( bw ) ;
2009-03-28 15:50:19 +03:00
2014-02-09 17:07:39 +04:00
if ( ( flags & GW_CREATE_TAB ) & & existing )
2008-10-05 03:29:17 +04:00
{
2014-02-09 17:07:39 +04:00
g - > shared = existing - > shared ;
2012-04-29 20:13:53 +04:00
g - > tab = g - > shared - > next_tab ;
2014-07-12 18:44:14 +04:00
g - > shared - > tabs + + ; /* do this early so functions know to update the tabs */
2008-08-31 01:32:05 +04:00
2014-07-12 18:44:14 +04:00
if ( ( g - > shared - > tabs = = 2 ) & & ( nsoption_bool ( tab_always_show ) = = false ) ) {
2012-04-29 20:13:53 +04:00
ami_toggletabbar ( g - > shared , true ) ;
2014-07-12 18:44:14 +04:00
}
2010-02-14 03:46:53 +03:00
2012-04-29 20:13:53 +04:00
SetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_TABS ] ,
g - > shared - > win , NULL ,
2010-02-14 03:46:53 +03:00
CLICKTAB_Labels , ~ 0 ,
2008-10-05 03:29:17 +04:00
TAG_DONE ) ;
2014-11-16 17:24:18 +03:00
g - > tab_node = AllocClickTabNode ( TNA_Text , messages_get ( " NetSurf " ) ,
TNA_Number , g - > tab ,
TNA_UserData , g ,
2010-02-14 03:46:53 +03:00
TNA_CloseGadget , TRUE ,
2008-10-05 03:29:17 +04:00
TAG_DONE ) ;
2014-11-16 17:24:18 +03:00
if ( nsoption_bool ( new_tab_last ) ) {
2012-04-29 20:13:53 +04:00
AddTail ( & g - > shared - > tab_list , g - > tab_node ) ;
2014-11-16 17:24:18 +03:00
} else {
2014-02-09 17:19:46 +04:00
struct Node * insert_after = existing - > tab_node ;
2011-07-03 02:40:45 +04:00
2016-09-04 19:35:32 +03:00
if ( g - > shared - > last_new_tab )
insert_after = g - > shared - > last_new_tab ;
2012-04-29 20:13:53 +04:00
Insert ( & g - > shared - > tab_list , g - > tab_node , insert_after ) ;
2011-07-03 02:04:51 +04:00
}
2008-10-05 03:29:17 +04:00
2016-09-04 19:35:32 +03:00
g - > shared - > last_new_tab = g - > tab_node ;
2012-04-29 20:13:53 +04:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_TABS ] ,
g - > shared - > win , NULL ,
CLICKTAB_Labels , & g - > shared - > tab_list ,
2008-10-05 03:29:17 +04:00
TAG_DONE ) ;
2014-11-16 17:24:18 +03:00
if ( nsoption_bool ( new_tab_is_active ) ) {
RefreshSetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_TABS ] ,
g - > shared - > win , NULL ,
CLICKTAB_Current , g - > tab ,
2008-10-05 17:17:18 +04:00
TAG_DONE ) ;
}
2014-11-16 17:24:18 +03:00
if ( ClickTabBase - > lib_Version < 53 ) {
RethinkLayout ( ( struct Gadget * ) g - > shared - > objects [ GID_TABLAYOUT ] ,
g - > shared - > win , NULL , TRUE ) ;
}
2008-10-05 03:29:17 +04:00
2012-04-29 20:13:53 +04:00
g - > shared - > next_tab + + ;
2008-10-05 17:17:18 +04:00
2013-05-28 19:44:46 +04:00
if ( nsoption_bool ( new_tab_is_active ) ) ami_switch_tab ( g - > shared , false ) ;
2008-10-05 03:29:17 +04:00
2012-04-29 20:13:53 +04:00
ami_update_buttons ( g - > shared ) ;
2014-07-05 22:00:21 +04:00
ami_schedule ( 0 , ami_gui_refresh_favicon , g - > shared ) ;
2008-11-09 02:08:55 +03:00
2012-04-29 20:13:53 +04:00
return g ;
2008-10-05 03:29:17 +04:00
}
2016-11-20 00:02:42 +03:00
g - > shared = calloc ( 1 , sizeof ( struct gui_window_2 ) ) ;
2008-10-05 03:29:17 +04:00
2012-04-29 20:13:53 +04:00
if ( ! g - > shared )
2008-10-05 03:29:17 +04:00
{
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2008-10-05 03:29:17 +04:00
return NULL ;
}
2016-01-25 03:01:55 +03:00
g - > shared - > shared_pens = ami_AllocMinList ( ) ;
2015-09-03 02:24:04 +03:00
2012-04-29 20:13:53 +04:00
g - > shared - > scrollerhook . h_Entry = ( void * ) ami_scroller_hook ;
g - > shared - > scrollerhook . h_Data = g - > shared ;
2008-08-25 17:32:26 +04:00
2012-04-29 20:13:53 +04:00
g - > shared - > favicon_hook . h_Entry = ( void * ) ami_set_favicon_render_hook ;
g - > shared - > favicon_hook . h_Data = g - > shared ;
2012-04-29 19:59:37 +04:00
2012-04-29 20:13:53 +04:00
g - > shared - > throbber_hook . h_Entry = ( void * ) ami_set_throbber_render_hook ;
g - > shared - > throbber_hook . h_Data = g - > shared ;
2012-04-29 19:59:37 +04:00
2012-04-07 21:16:32 +04:00
newprefs_hook . h_Entry = ( void * ) ami_gui_newprefs_hook ;
newprefs_hook . h_Data = 0 ;
2015-09-03 21:57:04 +03:00
g - > shared - > ctxmenu_hook = ami_ctxmenu_get_hook ( g - > shared ) ;
2015-09-04 02:26:52 +03:00
g - > shared - > history_ctxmenu [ AMI_CTXMENU_HISTORY_BACK ] = NULL ;
g - > shared - > history_ctxmenu [ AMI_CTXMENU_HISTORY_FORWARD ] = NULL ;
2015-09-05 03:41:56 +03:00
g - > shared - > clicktab_ctxmenu = NULL ;
2012-04-07 21:16:32 +04:00
2012-04-29 03:23:29 +04:00
if ( nsoption_bool ( window_simple_refresh ) = = true ) {
refresh_mode = WA_SimpleRefresh ;
2015-02-23 22:28:32 +03:00
defer_layout = FALSE ; /* testing reveals this does work with SimpleRefresh,
but the docs say it doesn ' t so err on the side of caution . */
2012-04-29 03:23:29 +04:00
} else {
refresh_mode = WA_SmartRefresh ;
2015-02-23 22:28:32 +03:00
defer_layout = TRUE ;
2012-04-29 03:23:29 +04:00
}
2012-03-22 13:34:34 +04:00
if ( ! nsoption_bool ( kiosk_mode ) )
2011-09-04 22:53:54 +04:00
{
ULONG addtabclosegadget = TAG_IGNORE ;
ULONG iconifygadget = FALSE ;
2013-06-01 02:25:05 +04:00
if ( nsoption_charp ( pubscreen_name ) & &
2012-03-22 13:34:34 +04:00
( locked_screen = = TRUE ) & &
2013-06-01 02:25:05 +04:00
( strcmp ( nsoption_charp ( pubscreen_name ) , " Workbench " ) = = 0 ) )
2011-09-04 22:53:54 +04:00
iconifygadget = TRUE ;
2015-09-06 11:06:20 +03:00
2016-04-28 21:18:06 +03:00
LOG ( " Creating menu " ) ;
2017-01-15 19:05:07 +03:00
struct Menu * menu = ami_gui_menu_create ( g - > shared ) ;
2015-09-06 11:06:20 +03:00
2012-04-29 20:13:53 +04:00
NewList ( & g - > shared - > tab_list ) ;
g - > tab_node = AllocClickTabNode ( TNA_Text , messages_get ( " NetSurf " ) ,
2011-09-04 22:53:54 +04:00
TNA_Number , 0 ,
2014-11-16 17:24:18 +03:00
TNA_UserData , g ,
2011-09-04 22:53:54 +04:00
TNA_CloseGadget , TRUE ,
TAG_DONE ) ;
2012-04-29 20:13:53 +04:00
AddTail ( & g - > shared - > tab_list , g - > tab_node ) ;
2011-09-04 22:53:54 +04:00
2014-06-15 18:39:49 +04:00
g - > shared - > web_search_list = ami_gui_opts_websearch ( ) ;
g - > shared - > search_bm = NULL ;
2012-04-29 20:13:53 +04:00
g - > shared - > tabs = 1 ;
g - > shared - > next_tab = 1 ;
2011-09-04 22:53:54 +04:00
2016-11-20 00:02:42 +03:00
g - > shared - > svbuffer = calloc ( 1 , 2000 ) ;
2011-09-04 22:53:54 +04:00
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_BACK ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarBack " ) ) ;
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_FORWARD ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarForward " ) ) ;
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_STOP ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarStop " ) ) ;
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_RELOAD ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarReload " ) ) ;
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_HOME ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarHome " ) ) ;
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_URL ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarURL " ) ) ;
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_SEARCHSTRING ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarWebSearch " ) ) ;
2012-04-29 20:13:53 +04:00
g - > shared - > helphints [ GID_ADDTAB ] =
2012-05-07 19:06:48 +04:00
translate_escape_chars ( messages_get ( " HelpToolbarAddTab " ) ) ;
2011-09-04 22:53:54 +04:00
2013-11-23 16:23:56 +04:00
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 ) ;
ami_get_theme_filename ( nav_east , " theme_nav_east " , false ) ;
ami_get_theme_filename ( nav_east_s , " theme_nav_east_s " , false ) ;
ami_get_theme_filename ( nav_east_g , " theme_nav_east_g " , false ) ;
ami_get_theme_filename ( stop , " theme_stop " , false ) ;
ami_get_theme_filename ( stop_s , " theme_stop_s " , false ) ;
ami_get_theme_filename ( stop_g , " theme_stop_g " , false ) ;
ami_get_theme_filename ( reload , " theme_reload " , false ) ;
ami_get_theme_filename ( reload_s , " theme_reload_s " , false ) ;
ami_get_theme_filename ( reload_g , " theme_reload_g " , false ) ;
ami_get_theme_filename ( home , " theme_home " , false ) ;
ami_get_theme_filename ( home_s , " theme_home_s " , false ) ;
ami_get_theme_filename ( home_g , " theme_home_g " , false ) ;
ami_get_theme_filename ( closetab , " theme_closetab " , false ) ;
ami_get_theme_filename ( closetab_s , " theme_closetab_s " , false ) ;
ami_get_theme_filename ( closetab_g , " theme_closetab_g " , false ) ;
ami_get_theme_filename ( addtab , " theme_addtab " , false ) ;
ami_get_theme_filename ( addtab_s , " theme_addtab_s " , false ) ;
ami_get_theme_filename ( addtab_g , " theme_addtab_g " , false ) ;
ami_get_theme_filename ( tabthrobber , " theme_tab_loading " , false ) ;
ami_get_theme_filename ( fave , " theme_fave " , false ) ;
2013-11-23 17:11:30 +04:00
ami_get_theme_filename ( unfave , " theme_unfave " , false ) ;
2015-01-25 03:27:53 +03:00
g - > shared - > objects [ GID_FAVE_ADD ] = BitMapObj ,
2013-11-23 17:11:30 +04:00
BITMAP_SourceFile , fave ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ;
2015-01-25 03:27:53 +03:00
g - > shared - > objects [ GID_FAVE_RMV ] = BitMapObj ,
2013-11-23 17:11:30 +04:00
BITMAP_SourceFile , unfave ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ;
2011-09-04 22:53:54 +04:00
2015-01-25 03:27:53 +03:00
g - > shared - > objects [ GID_ADDTAB_BM ] = BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , addtab ,
BITMAP_SelectSourceFile , addtab_s ,
BITMAP_DisabledSourceFile , addtab_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ;
2015-01-25 03:27:53 +03:00
g - > shared - > objects [ GID_CLOSETAB_BM ] = BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , closetab ,
BITMAP_SelectSourceFile , closetab_s ,
BITMAP_DisabledSourceFile , closetab_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ;
if ( ClickTabBase - > lib_Version < 53 )
{
addtabclosegadget = LAYOUT_AddChild ;
2015-01-25 15:45:20 +03:00
g - > shared - > objects [ GID_CLOSETAB ] = ButtonObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_CLOSETAB ,
GA_RelVerify , TRUE ,
2012-04-29 20:13:53 +04:00
BUTTON_RenderImage , g - > shared - > objects [ GID_CLOSETAB_BM ] ,
2011-09-04 22:53:54 +04:00
ButtonEnd ;
2015-01-25 15:45:20 +03:00
g - > shared - > objects [ GID_TABS ] = ClickTabObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_TABS ,
GA_RelVerify , TRUE ,
GA_Underscore , 13 , // disable kb shortcuts
2012-04-29 20:13:53 +04:00
CLICKTAB_Labels , & g - > shared - > tab_list ,
2011-09-04 22:53:54 +04:00
CLICKTAB_LabelTruncate , TRUE ,
ClickTabEnd ;
2015-01-25 15:45:20 +03:00
g - > shared - > objects [ GID_ADDTAB ] = ButtonObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_ADDTAB ,
GA_RelVerify , TRUE ,
GA_Text , " + " ,
2012-04-29 20:13:53 +04:00
BUTTON_RenderImage , g - > shared - > objects [ GID_ADDTAB_BM ] ,
2011-09-04 22:53:54 +04:00
ButtonEnd ;
}
else
{
2015-01-25 03:27:53 +03:00
g - > shared - > objects [ GID_TABS_FLAG ] = BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , tabthrobber ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ;
}
2015-05-28 18:08:46 +03:00
LOG ( " Creating window object " ) ;
2015-01-19 23:08:45 +03:00
2015-01-25 03:27:53 +03:00
g - > shared - > objects [ OID_MAIN ] = WindowObj ,
2014-11-16 19:40:41 +03:00
WA_ScreenTitle , ami_gui_get_screen_title ( ) ,
2014-06-15 18:39:49 +04:00
WA_Activate , TRUE ,
WA_DepthGadget , TRUE ,
WA_DragBar , TRUE ,
WA_CloseGadget , TRUE ,
WA_SizeGadget , TRUE ,
2011-09-04 22:53:54 +04:00
WA_Top , cury ,
WA_Left , curx ,
WA_Width , curw ,
WA_Height , curh ,
2013-03-20 12:22:03 +04:00
WA_PubScreen , scrn ,
2011-09-04 22:53:54 +04:00
WA_ReportMouse , TRUE ,
2012-04-29 03:23:29 +04:00
refresh_mode , TRUE ,
2011-09-04 22:53:54 +04:00
WA_SizeBBottom , TRUE ,
2015-09-03 21:57:04 +03:00
WA_ContextMenuHook , g - > shared - > ctxmenu_hook ,
2014-06-15 18:39:49 +04:00
WA_IDCMP , IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
IDCMP_RAWKEY | idcmp_sizeverify |
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_REFRESHWINDOW |
IDCMP_ACTIVEWINDOW | IDCMP_EXTENDEDMOUSE ,
2011-09-04 22:53:54 +04:00
WINDOW_IconifyGadget , iconifygadget ,
2015-01-29 22:18:49 +03:00
WINDOW_MenuStrip , menu ,
2012-04-29 19:59:37 +04:00
WINDOW_MenuUserData , WGUD_HOOK ,
WINDOW_NewPrefsHook , & newprefs_hook ,
2012-04-29 20:13:53 +04:00
WINDOW_IDCMPHook , & g - > shared - > scrollerhook ,
2012-04-29 03:23:29 +04:00
WINDOW_IDCMPHookBits , IDCMP_IDCMPUPDATE | IDCMP_REFRESHWINDOW |
2011-09-04 22:53:54 +04:00
IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY ,
2012-04-29 19:59:37 +04:00
WINDOW_SharedPort , sport ,
WINDOW_BuiltInScroll , TRUE ,
2011-09-04 22:53:54 +04:00
WINDOW_GadgetHelp , TRUE ,
2012-04-29 20:13:53 +04:00
WINDOW_UserData , g - > shared ,
2015-01-25 03:27:53 +03:00
WINDOW_ParentGroup , g - > shared - > objects [ GID_MAIN ] = LayoutVObj ,
2015-02-23 22:28:32 +03:00
LAYOUT_DeferLayout , defer_layout ,
2014-06-15 18:39:49 +04:00
LAYOUT_SpaceOuter , TRUE ,
2015-01-25 03:27:53 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_TOOLBARLAYOUT ] = LayoutHObj ,
2011-09-04 22:53:54 +04:00
LAYOUT_VertAlignment , LALIGN_CENTER ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_BACK ] = ButtonObj ,
2015-09-04 02:26:52 +03:00
GA_ID , GID_BACK ,
GA_RelVerify , TRUE ,
GA_Disabled , TRUE ,
GA_ContextMenu , ami_ctxmenu_history_create ( AMI_CTXMENU_HISTORY_BACK , g - > shared ) ,
2012-04-29 20:13:53 +04:00
GA_HintInfo , g - > shared - > helphints [ GID_BACK ] ,
2015-01-25 03:27:53 +03:00
BUTTON_RenderImage , BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , nav_west ,
BITMAP_SelectSourceFile , nav_west_s ,
BITMAP_DisabledSourceFile , nav_west_g ,
2010-02-14 17:00:33 +03:00
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
2011-09-04 22:53:54 +04:00
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_FORWARD ] = ButtonObj ,
2015-09-04 02:26:52 +03:00
GA_ID , GID_FORWARD ,
GA_RelVerify , TRUE ,
GA_Disabled , TRUE ,
GA_ContextMenu , ami_ctxmenu_history_create ( AMI_CTXMENU_HISTORY_FORWARD , g - > shared ) ,
2012-04-29 20:13:53 +04:00
GA_HintInfo , g - > shared - > helphints [ GID_FORWARD ] ,
2015-01-25 03:27:53 +03:00
BUTTON_RenderImage , BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , nav_east ,
BITMAP_SelectSourceFile , nav_east_s ,
BITMAP_DisabledSourceFile , nav_east_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_STOP ] = ButtonObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_STOP ,
GA_RelVerify , TRUE ,
2012-04-29 20:13:53 +04:00
GA_HintInfo , g - > shared - > helphints [ GID_STOP ] ,
2015-01-25 03:27:53 +03:00
BUTTON_RenderImage , BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , stop ,
BITMAP_SelectSourceFile , stop_s ,
BITMAP_DisabledSourceFile , stop_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_RELOAD ] = ButtonObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_RELOAD ,
GA_RelVerify , TRUE ,
2012-04-29 20:13:53 +04:00
GA_HintInfo , g - > shared - > helphints [ GID_RELOAD ] ,
2015-01-25 03:27:53 +03:00
BUTTON_RenderImage , BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , reload ,
BITMAP_SelectSourceFile , reload_s ,
BITMAP_DisabledSourceFile , reload_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_HOME ] = ButtonObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_HOME ,
GA_RelVerify , TRUE ,
2012-04-29 20:13:53 +04:00
GA_HintInfo , g - > shared - > helphints [ GID_HOME ] ,
2015-01-25 03:27:53 +03:00
BUTTON_RenderImage , BitMapObj ,
2011-09-04 22:53:54 +04:00
BITMAP_SourceFile , home ,
BITMAP_SelectSourceFile , home_s ,
BITMAP_DisabledSourceFile , home_g ,
BITMAP_Screen , scrn ,
BITMAP_Masking , TRUE ,
BitMapEnd ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2015-01-25 03:27:53 +03:00
LAYOUT_AddChild , LayoutHObj , // FavIcon, URL bar and hotlist star
2013-11-24 18:37:44 +04:00
LAYOUT_VertAlignment , LALIGN_CENTER ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_ICON ] = SpaceObj ,
2013-11-24 18:37:44 +04:00
GA_ID , GID_ICON ,
SPACE_MinWidth , 16 ,
SPACE_MinHeight , 16 ,
2015-01-31 15:28:14 +03:00
SPACE_Transparent , TRUE ,
2014-07-01 11:28:07 +04:00
// SPACE_RenderHook, &g->shared->favicon_hook,
2013-11-24 18:37:44 +04:00
SpaceEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LAYOUT_AddChild , g - > shared - > objects [ GID_URL ] =
2015-01-28 02:54:59 +03:00
# ifdef __amigaos4__
2013-11-24 18:37:44 +04:00
NewObject ( urlStringClass , NULL ,
2015-01-28 02:54:59 +03:00
# else
StringObj ,
# endif
2013-11-24 18:37:44 +04:00
STRINGA_MaxChars , 2000 ,
GA_ID , GID_URL ,
GA_RelVerify , TRUE ,
GA_HintInfo , g - > shared - > helphints [ GID_URL ] ,
GA_TabCycle , TRUE ,
STRINGA_Buffer , g - > shared - > svbuffer ,
2015-01-28 02:54:59 +03:00
# ifdef __amigaos4__
2013-11-24 18:37:44 +04:00
STRINGVIEW_Header , URLHistory_GetList ( ) ,
2015-01-28 02:54:59 +03:00
# endif
2014-04-03 22:06:09 +04:00
TAG_DONE ) ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_FAVE ] = ButtonObj ,
2013-11-24 18:37:44 +04:00
GA_ID , GID_FAVE ,
GA_RelVerify , TRUE ,
// GA_HintInfo, g->shared->helphints[GID_FAVE],
BUTTON_RenderImage , g - > shared - > objects [ GID_FAVE_ADD ] ,
ButtonEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LayoutEnd ,
2011-09-04 22:53:54 +04:00
// GA_ID, GID_TOOLBARLAYOUT,
// GA_RelVerify, TRUE,
// LAYOUT_RelVerify, TRUE,
LAYOUT_WeightBar , TRUE ,
2015-01-25 03:27:53 +03:00
LAYOUT_AddChild , LayoutHObj ,
2011-09-04 22:53:54 +04:00
LAYOUT_VertAlignment , LALIGN_CENTER ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_SEARCH_ICON ] = ChooserObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_SEARCH_ICON ,
2014-06-15 18:48:55 +04:00
GA_RelVerify , TRUE ,
2014-06-15 18:39:49 +04:00
CHOOSER_DropDown , TRUE ,
CHOOSER_Labels , g - > shared - > web_search_list ,
CHOOSER_MaxLabels , 40 , /* Same as options GUI */
ChooserEnd ,
2011-09-04 22:53:54 +04:00
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_SEARCHSTRING ] = StringObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_SEARCHSTRING ,
STRINGA_TextVal , NULL ,
GA_RelVerify , TRUE ,
2012-04-29 20:13:53 +04:00
GA_HintInfo , g - > shared - > helphints [ GID_SEARCHSTRING ] ,
2011-09-04 22:53:54 +04:00
StringEnd ,
LayoutEnd ,
2012-12-07 03:40:13 +04:00
CHILD_WeightedWidth , nsoption_int ( web_search_width ) ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_THROBBER ] = SpaceObj ,
2011-09-04 22:53:54 +04:00
GA_ID , GID_THROBBER ,
2016-07-03 19:23:24 +03:00
SPACE_MinWidth , ami_theme_throbber_get_width ( ) ,
SPACE_MinHeight , ami_theme_throbber_get_height ( ) ,
2011-09-04 22:53:54 +04:00
SPACE_Transparent , TRUE ,
2012-04-29 20:13:53 +04:00
// SPACE_RenderHook, &g->shared->throbber_hook,
2011-09-04 22:53:54 +04:00
SpaceEnd ,
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LayoutEnd ,
CHILD_WeightedHeight , 0 ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddImage , BevelObj ,
2011-09-04 22:53:54 +04:00
BEVEL_Style , BVS_SBAR_VERT ,
BevelEnd ,
CHILD_WeightedHeight , 0 ,
2015-01-25 03:27:53 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_HOTLISTLAYOUT ] = LayoutVObj ,
2012-11-28 23:44:40 +04:00
LAYOUT_SpaceInner , FALSE ,
LayoutEnd ,
CHILD_WeightedHeight , 0 ,
2015-01-25 03:27:53 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_TABLAYOUT ] = LayoutHObj ,
2011-09-04 22:53:54 +04:00
LAYOUT_SpaceInner , FALSE ,
2012-04-29 20:13:53 +04:00
addtabclosegadget , g - > shared - > objects [ GID_CLOSETAB ] ,
2011-09-04 22:53:54 +04:00
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
2012-04-29 20:13:53 +04:00
addtabclosegadget , g - > shared - > objects [ GID_TABS ] ,
2011-09-04 22:53:54 +04:00
CHILD_CacheDomain , FALSE ,
2012-04-29 20:13:53 +04:00
addtabclosegadget , g - > shared - > objects [ GID_ADDTAB ] ,
2011-09-04 22:53:54 +04:00
CHILD_WeightedWidth , 0 ,
CHILD_WeightedHeight , 0 ,
LayoutEnd ,
CHILD_WeightedHeight , 0 ,
2016-01-23 18:11:17 +03:00
LAYOUT_AddChild , LayoutVObj ,
LAYOUT_AddChild , g - > shared - > objects [ GID_VSCROLLLAYOUT ] = LayoutHObj ,
LAYOUT_AddChild , LayoutVObj ,
LAYOUT_AddChild , g - > shared - > objects [ GID_HSCROLLLAYOUT ] = LayoutVObj ,
LAYOUT_AddChild , g - > shared - > objects [ GID_BROWSER ] = SpaceObj ,
GA_ID , GID_BROWSER ,
SPACE_Transparent , TRUE ,
SpaceEnd ,
EndGroup ,
2016-01-11 22:10:59 +03:00
EndGroup ,
2016-01-23 18:11:17 +03:00
EndGroup ,
2016-01-11 22:10:59 +03:00
# ifndef __amigaos4__
2016-01-23 18:11:17 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_STATUS ] = StringObj ,
GA_ID , GID_STATUS ,
GA_ReadOnly , TRUE ,
STRINGA_TextVal , NULL ,
GA_RelVerify , TRUE ,
StringEnd ,
2016-01-11 22:10:59 +03:00
# endif
2014-10-25 16:17:49 +04:00
EndGroup ,
2011-09-04 22:53:54 +04:00
EndGroup ,
EndWindow ;
}
else
{
/* borderless kiosk mode window */
2012-04-29 20:13:53 +04:00
g - > tab = 0 ;
g - > shared - > tabs = 0 ;
g - > tab_node = NULL ;
2011-09-04 22:53:54 +04:00
2015-01-25 03:27:53 +03:00
g - > shared - > objects [ OID_MAIN ] = WindowObj ,
2014-11-16 19:40:41 +03:00
WA_ScreenTitle , ami_gui_get_screen_title ( ) ,
2011-09-04 22:53:54 +04:00
WA_Activate , TRUE ,
WA_DepthGadget , FALSE ,
WA_DragBar , FALSE ,
WA_CloseGadget , FALSE ,
WA_Borderless , TRUE ,
WA_RMBTrap , TRUE ,
WA_Top , 0 ,
WA_Left , 0 ,
WA_Width , scrn - > Width ,
WA_Height , scrn - > Height ,
WA_SizeGadget , FALSE ,
2013-03-20 12:22:03 +04:00
WA_PubScreen , scrn ,
2012-04-29 03:23:29 +04:00
WA_ReportMouse , TRUE ,
refresh_mode , TRUE ,
WA_IDCMP , IDCMP_MENUPICK | IDCMP_MOUSEMOVE |
2011-09-04 22:53:54 +04:00
IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
2012-04-29 03:23:29 +04:00
IDCMP_RAWKEY | IDCMP_REFRESHWINDOW |
2011-09-04 22:53:54 +04:00
IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
IDCMP_EXTENDEDMOUSE ,
2012-04-29 20:13:53 +04:00
WINDOW_IDCMPHook , & g - > shared - > scrollerhook ,
2012-04-29 03:23:29 +04:00
WINDOW_IDCMPHookBits , IDCMP_IDCMPUPDATE |
IDCMP_EXTENDEDMOUSE | IDCMP_REFRESHWINDOW ,
2011-09-04 22:53:54 +04:00
WINDOW_SharedPort , sport ,
2012-04-29 20:13:53 +04:00
WINDOW_UserData , g - > shared ,
2011-09-04 22:53:54 +04:00
WINDOW_BuiltInScroll , TRUE ,
2015-01-25 03:27:53 +03:00
WINDOW_ParentGroup , g - > shared - > objects [ GID_MAIN ] = LayoutHObj ,
2015-02-23 22:28:32 +03:00
LAYOUT_DeferLayout , defer_layout ,
2014-10-25 17:41:10 +04:00
LAYOUT_SpaceOuter , TRUE ,
2015-01-25 03:27:53 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_VSCROLLLAYOUT ] = LayoutHObj ,
LAYOUT_AddChild , g - > shared - > objects [ GID_HSCROLLLAYOUT ] = LayoutVObj ,
2015-01-25 15:45:20 +03:00
LAYOUT_AddChild , g - > shared - > objects [ GID_BROWSER ] = SpaceObj ,
2014-10-26 19:35:05 +03:00
GA_ID , GID_BROWSER ,
SPACE_Transparent , TRUE ,
SpaceEnd ,
EndGroup ,
EndGroup ,
2011-09-04 22:53:54 +04:00
EndGroup ,
EndWindow ;
}
2008-08-11 21:53:45 +04:00
2015-05-28 18:08:46 +03:00
LOG ( " Opening window " ) ;
2015-01-19 23:08:45 +03:00
2012-04-29 20:13:53 +04:00
g - > shared - > win = ( struct Window * ) RA_OpenWindow ( g - > shared - > objects [ OID_MAIN ] ) ;
2008-08-10 13:57:41 +04:00
2015-05-28 18:08:46 +03:00
LOG ( " Window opened, adding border gadgets " ) ;
2015-01-19 23:08:45 +03:00
2012-04-29 20:13:53 +04:00
if ( ! g - > shared - > win )
2008-08-31 01:32:05 +04:00
{
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2016-11-20 00:02:42 +03:00
free ( g - > shared ) ;
free ( g ) ;
2008-08-31 01:32:05 +04:00
return NULL ;
}
2012-03-22 13:34:34 +04:00
if ( nsoption_bool ( kiosk_mode ) = = false )
2009-08-29 03:12:18 +04:00
{
2016-01-11 22:10:59 +03:00
# ifdef __amigaos4__
2016-01-15 22:58:24 +03:00
ULONG width , height ;
2013-08-20 22:43:13 +04:00
struct DrawInfo * dri = GetScreenDrawInfo ( scrn ) ;
2016-01-15 22:58:24 +03:00
ami_get_border_gadget_size ( g - > shared ,
2014-10-26 20:00:18 +03:00
( ULONG * ) & width , ( ULONG * ) & height ) ;
2009-08-29 03:12:18 +04:00
2012-04-29 20:13:53 +04:00
g - > shared - > objects [ GID_STATUS ] = NewObject (
2009-08-29 03:12:18 +04:00
NULL ,
2016-01-11 22:10:59 +03:00
" frbuttonclass " ,
2009-08-29 03:12:18 +04:00
GA_ID , GID_STATUS ,
2012-02-12 03:17:47 +04:00
GA_Left , scrn - > WBorLeft + 2 ,
2015-11-15 20:00:01 +03:00
GA_RelBottom , scrn - > WBorBottom - ( height / 2 ) ,
2015-09-06 11:33:00 +03:00
GA_BottomBorder , TRUE ,
2014-10-26 20:00:18 +03:00
GA_Width , width ,
2015-02-05 21:57:24 +03:00
GA_Height , 1 + height - scrn - > WBorBottom ,
2009-08-29 03:12:18 +04:00
GA_DrawInfo , dri ,
2009-09-16 02:49:33 +04:00
GA_ReadOnly , TRUE ,
2015-02-04 03:48:47 +03:00
GA_Disabled , TRUE ,
2009-09-16 02:49:33 +04:00
GA_Image , ( struct Image * ) NewObject (
NULL ,
2012-04-01 01:49:50 +04:00
" gaugeiclass " ,
2015-02-04 03:48:47 +03:00
GAUGEIA_Level , 0 ,
2015-11-16 22:01:13 +03:00
IA_Top , ( int ) ( - ceil ( ( scrn - > WBorBottom + height ) / 2 ) ) ,
2012-04-02 22:05:09 +04:00
IA_Left , - 4 ,
2015-11-16 22:01:13 +03:00
IA_Height , 2 + height - scrn - > WBorBottom ,
2012-04-01 01:49:50 +04:00
IA_Label , NULL ,
2015-02-04 03:48:47 +03:00
IA_InBorder , TRUE ,
2012-04-01 01:49:50 +04:00
IA_Screen , scrn ,
2009-09-16 02:49:33 +04:00
TAG_DONE ) ,
2009-08-29 03:12:18 +04:00
TAG_DONE ) ;
2012-04-29 20:13:53 +04:00
AddGList ( g - > shared - > win , ( struct Gadget * ) g - > shared - > objects [ GID_STATUS ] ,
2009-08-29 03:12:18 +04:00
( UWORD ) ~ 0 , - 1 , NULL ) ;
2014-11-16 17:24:18 +03:00
/* Apparently you can't set GA_Width on creation time for frbuttonclass */
2009-09-16 02:49:33 +04:00
2012-04-29 20:13:53 +04:00
SetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_STATUS ] ,
g - > shared - > win , NULL ,
2014-10-26 20:00:18 +03:00
GA_Width , width ,
2009-09-16 02:49:33 +04:00
TAG_DONE ) ;
2012-04-29 20:13:53 +04:00
RefreshGadgets ( ( APTR ) g - > shared - > objects [ GID_STATUS ] ,
g - > shared - > win , NULL ) ;
2012-11-28 23:29:43 +04:00
2013-08-20 22:43:13 +04:00
FreeScreenDrawInfo ( scrn , dri ) ;
2016-01-11 22:10:59 +03:00
# endif //__amigaos4__
2012-11-28 23:29:43 +04:00
ami_gui_hotlist_toolbar_add ( g - > shared ) ; /* is this the right place for this? */
2012-12-10 00:00:11 +04:00
if ( nsoption_bool ( tab_always_show ) ) ami_toggletabbar ( g - > shared , true ) ;
2009-08-29 03:12:18 +04:00
}
2008-08-10 00:27:36 +04:00
2014-11-16 17:24:18 +03:00
g - > shared - > gw = g ;
2014-11-16 19:01:59 +03:00
cur_gw = g ;
2008-10-26 02:22:34 +03:00
2012-04-29 20:13:53 +04:00
g - > shared - > appwin = AddAppWindowA ( ( ULONG ) g - > shared - > objects [ OID_MAIN ] ,
( ULONG ) g - > shared , g - > shared - > win , appport , NULL ) ;
2012-04-28 23:43:46 +04:00
2016-12-30 03:59:12 +03:00
ami_gui_win_list_add ( g - > shared , AMINS_WINDOW , & ami_gui_table ) ;
2008-08-02 18:31:32 +04:00
2016-02-14 17:13:24 +03:00
if ( locked_screen ) {
UnlockPubScreen ( NULL , scrn ) ;
locked_screen = FALSE ;
}
2014-05-25 03:57:48 +04:00
2014-07-05 21:44:44 +04:00
ami_schedule ( 0 , ami_gui_search_ico_refresh , NULL ) ;
2009-12-22 02:25:35 +03:00
2013-06-02 19:26:25 +04:00
ScreenToFront ( scrn ) ;
2012-04-29 20:13:53 +04:00
return g ;
2008-08-02 18:31:32 +04:00
}
2016-01-31 20:58:27 +03:00
static void ami_gui_close_tabs ( struct gui_window_2 * gwin , bool other_tabs )
2008-10-06 11:07:33 +04:00
{
struct Node * tab ;
struct Node * ntab ;
2016-01-31 20:58:27 +03:00
struct gui_window * gw ;
2012-12-08 21:47:57 +04:00
if ( ( gwin - > tabs > 1 ) & & ( nsoption_bool ( tab_close_warn ) = = true ) ) {
char * req_body = ami_utf8_easy ( messages_get ( " MultiTabClose " ) ) ;
2016-05-01 16:00:47 +03:00
int32 res = amiga_warn_user_multi ( req_body , " Yes " , " No " , gwin - > win ) ;
2012-12-08 21:47:57 +04:00
free ( req_body ) ;
2016-01-31 20:58:27 +03:00
2012-12-10 00:00:59 +04:00
if ( res = = 0 ) return ;
2012-12-08 21:47:57 +04:00
}
2016-01-31 20:58:27 +03:00
if ( gwin - > tabs ) {
2008-10-06 11:07:33 +04:00
tab = GetHead ( & gwin - > tab_list ) ;
2016-01-31 20:58:27 +03:00
do {
2008-10-06 22:20:16 +04:00
ntab = GetSucc ( tab ) ;
2008-10-06 11:07:33 +04:00
GetClickTabNodeAttrs ( tab ,
2016-01-31 20:58:27 +03:00
TNA_UserData , & gw ,
2008-10-06 11:07:33 +04:00
TAG_DONE ) ;
2016-01-31 20:58:27 +03:00
if ( ( other_tabs = = false ) | | ( gwin - > gw ! = gw ) ) {
browser_window_destroy ( gw - > bw ) ;
}
2014-10-25 19:22:08 +04:00
} while ( ( tab = ntab ) ) ;
2016-01-31 20:58:27 +03:00
} else {
if ( other_tabs = = false ) browser_window_destroy ( gwin - > gw - > bw ) ;
2008-10-06 11:07:33 +04:00
}
2016-01-31 20:58:27 +03:00
}
2016-12-30 03:59:12 +03:00
void ami_gui_close_window ( void * w )
2016-01-31 20:58:27 +03:00
{
2016-12-30 03:59:12 +03:00
struct gui_window_2 * gwin = ( struct gui_window_2 * ) w ;
2016-01-31 20:58:27 +03:00
ami_gui_close_tabs ( gwin , false ) ;
}
void ami_gui_close_inactive_tabs ( struct gui_window_2 * gwin )
{
ami_gui_close_tabs ( gwin , true ) ;
2008-10-06 11:07:33 +04:00
}
2014-01-12 02:34:12 +04:00
static void gui_window_destroy ( struct gui_window * g )
2008-08-02 18:31:32 +04:00
{
2015-01-16 02:44:29 +03:00
struct Node * ptab = NULL ;
2010-03-17 02:55:39 +03:00
int gid ;
2008-10-05 17:17:18 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2016-06-01 09:59:19 +03:00
if ( ami_search_get_gwin ( g - > shared - > searchwin ) = = g )
2009-03-15 14:29:33 +03:00
{
ami_search_close ( ) ;
win_destroyed = true ;
}
2009-01-11 01:57:23 +03:00
2009-03-15 14:29:33 +03:00
if ( g - > hw )
{
ami_history_close ( g - > hw ) ;
win_destroyed = true ;
}
2009-03-15 14:21:46 +03:00
2009-03-28 15:50:19 +03:00
ami_free_download_list ( & g - > dllist ) ;
2013-02-03 18:01:48 +04:00
FreeObjList ( g - > deferred_rects ) ;
2016-11-20 19:30:33 +03:00
ami_memory_itempool_delete ( g - > deferred_rects_pool ) ;
2014-10-23 21:48:31 +04:00
gui_window_stop_throbber ( g ) ;
2009-03-28 15:50:19 +03:00
2014-11-16 19:01:59 +03:00
cur_gw = NULL ;
2010-02-14 03:46:53 +03:00
2016-12-06 02:32:55 +03:00
if ( g - > shared - > tabs > 1 ) {
2010-02-13 21:03:05 +03:00
SetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_TABS ] , g - > shared - > win , NULL ,
2008-10-05 17:17:18 +04:00
CLICKTAB_Labels , ~ 0 ,
TAG_DONE ) ;
2015-01-16 02:44:29 +03:00
GetAttr ( CLICKTAB_CurrentNode , g - > shared - > objects [ GID_TABS ] , ( ULONG * ) & ptab ) ;
2010-02-14 18:32:54 +03:00
2015-01-16 02:44:29 +03:00
if ( ptab = = g - > tab_node ) {
2010-02-14 18:32:54 +03:00
ptab = GetSucc ( g - > tab_node ) ;
if ( ! ptab ) ptab = GetPred ( g - > tab_node ) ;
}
2008-10-05 17:17:18 +04:00
Remove ( g - > tab_node ) ;
FreeClickTabNode ( g - > tab_node ) ;
2015-01-16 02:44:29 +03:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_TABS ] , g - > shared - > win , NULL ,
CLICKTAB_Labels , & g - > shared - > tab_list ,
CLICKTAB_CurrentNode , ptab ,
2008-10-05 17:17:18 +04:00
TAG_DONE ) ;
2009-09-01 02:10:05 +04:00
if ( ClickTabBase - > lib_Version < 53 )
2015-01-16 02:44:29 +03:00
RethinkLayout ( ( struct Gadget * ) g - > shared - > objects [ GID_TABLAYOUT ] ,
g - > shared - > win , NULL , TRUE ) ;
2008-10-05 17:17:18 +04:00
2008-10-05 03:29:17 +04:00
g - > shared - > tabs - - ;
2008-10-05 17:17:18 +04:00
ami_switch_tab ( g - > shared , true ) ;
2014-08-25 23:20:16 +04:00
ami_schedule ( 0 , ami_gui_refresh_favicon , g - > shared ) ;
2010-02-14 03:46:53 +03:00
2012-12-10 00:05:22 +04:00
if ( ( g - > shared - > tabs = = 1 ) & & ( nsoption_bool ( tab_always_show ) = = false ) )
2010-02-14 03:46:53 +03:00
ami_toggletabbar ( g - > shared , false ) ;
2016-12-06 02:32:55 +03:00
if ( g - > tabtitle ) free ( g - > tabtitle ) ;
2016-11-20 00:02:42 +03:00
free ( g ) ;
2008-10-05 03:29:17 +04:00
return ;
}
2016-01-25 03:01:55 +03:00
ami_plot_release_pens ( g - > shared - > shared_pens ) ;
2016-11-20 00:02:42 +03:00
free ( g - > shared - > shared_pens ) ;
2013-04-12 00:26:42 +04:00
ami_schedule_redraw_remove ( g - > shared ) ;
2014-11-16 18:06:32 +03:00
ami_schedule ( - 1 , ami_gui_refresh_favicon , g - > shared ) ;
2012-08-05 14:28:48 +04:00
2008-10-05 03:29:17 +04:00
DisposeObject ( g - > shared - > objects [ OID_MAIN ] ) ;
2011-07-03 15:05:18 +04:00
ami_gui_appicon_remove ( g - > shared ) ;
2012-04-28 23:43:46 +04:00
if ( g - > shared - > appwin ) RemoveAppWindow ( g - > shared - > appwin ) ;
2012-11-30 02:13:42 +04:00
ami_gui_hotlist_toolbar_free ( g - > shared , & g - > shared - > hotlist_toolbar_list ) ;
2011-03-01 01:12:34 +03:00
/* These aren't freed by the above.
2012-08-04 18:44:57 +04:00
* TODO : nav_west etc need freeing too ? */
2011-03-01 01:12:34 +03:00
DisposeObject ( g - > shared - > objects [ GID_ADDTAB_BM ] ) ;
DisposeObject ( g - > shared - > objects [ GID_CLOSETAB_BM ] ) ;
DisposeObject ( g - > shared - > objects [ GID_TABS_FLAG ] ) ;
2013-11-23 17:11:30 +04:00
DisposeObject ( g - > shared - > objects [ GID_FAVE_ADD ] ) ;
DisposeObject ( g - > shared - > objects [ GID_FAVE_RMV ] ) ;
2011-03-01 01:12:34 +03:00
2014-06-15 18:39:49 +04:00
ami_gui_opts_websearch_free ( g - > shared - > web_search_list ) ;
if ( g - > shared - > search_bm ) DisposeObject ( g - > shared - > search_bm ) ;
2015-09-05 03:41:56 +03:00
/* This appears to be disposed along with the ClickTab object
if ( g - > shared - > clicktab_ctxmenu ) DisposeObject ( ( Object * ) g - > shared - > clicktab_ctxmenu ) ; */
2015-09-04 02:26:52 +03:00
DisposeObject ( ( Object * ) g - > shared - > history_ctxmenu [ AMI_CTXMENU_HISTORY_BACK ] ) ;
DisposeObject ( ( Object * ) g - > shared - > history_ctxmenu [ AMI_CTXMENU_HISTORY_FORWARD ] ) ;
2015-09-03 21:57:04 +03:00
ami_ctxmenu_release_hook ( g - > shared - > ctxmenu_hook ) ;
2017-01-15 19:05:07 +03:00
ami_gui_menu_free ( g - > shared ) ;
2015-09-06 11:06:20 +03:00
2010-03-18 01:15:03 +03:00
free ( g - > shared - > wintitle ) ;
2009-08-29 14:16:19 +04:00
ami_utf8_free ( g - > shared - > status ) ;
2016-11-20 00:02:42 +03:00
free ( g - > shared - > svbuffer ) ;
2009-07-23 15:23:34 +04:00
2010-03-17 02:55:39 +03:00
for ( gid = 0 ; gid < GID_LAST ; gid + + )
free ( g - > shared - > helphints [ gid ] ) ;
2016-12-30 03:59:12 +03:00
ami_gui_win_list_remove ( g - > shared ) ;
2015-09-05 03:41:56 +03:00
if ( g - > tab_node ) {
2008-10-05 17:17:18 +04:00
Remove ( g - > tab_node ) ;
FreeClickTabNode ( g - > tab_node ) ;
}
2016-12-06 02:32:55 +03:00
if ( g - > tabtitle ) free ( g - > tabtitle ) ;
2016-11-20 00:02:42 +03:00
free ( g ) ; // g->shared should be freed by DelObject()
2008-08-09 19:19:04 +04:00
if ( IsMinListEmpty ( window_list ) )
{
/* last window closed, so exit */
2009-10-03 15:00:10 +04:00
ami_try_quit ( ) ;
2008-08-09 19:19:04 +04:00
}
2008-08-10 13:57:41 +04:00
win_destroyed = true ;
2008-08-02 18:31:32 +04:00
}
2016-07-03 20:48:46 +03:00
static void gui_window_set_title ( struct gui_window * g , const char * restrict title )
2008-08-02 18:31:32 +04:00
{
2008-10-05 03:29:17 +04:00
struct Node * node ;
2016-07-03 20:48:46 +03:00
char * restrict utf8title ;
2008-10-19 15:33:05 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2009-09-16 02:49:33 +04:00
if ( ! title ) return ;
2008-10-05 03:29:17 +04:00
2009-09-18 01:44:07 +04:00
utf8title = ami_utf8_easy ( ( char * ) title ) ;
2016-12-05 23:22:21 +03:00
if ( g - > tab_node ) {
2009-09-18 01:44:07 +04:00
node = g - > tab_node ;
2008-10-19 15:33:05 +04:00
2015-02-23 23:34:24 +03:00
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 ) ;
2013-01-06 15:40:37 +04:00
2016-12-05 23:22:21 +03:00
if ( g - > tabtitle ) free ( g - > tabtitle ) ;
2015-02-23 23:34:24 +03:00
g - > tabtitle = strdup ( utf8title ) ;
2012-02-25 22:42:33 +04:00
2015-02-23 23:34:24 +03:00
SetClickTabNodeAttrs ( node , TNA_Text , g - > tabtitle ,
TNA_HintInfo , g - > tabtitle ,
TAG_DONE ) ;
2012-02-25 22:42:33 +04:00
2015-02-23 23:34:24 +03:00
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 ) ;
2012-02-25 22:42:33 +04:00
}
}
2015-02-23 23:34:24 +03:00
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 ( ) ) ;
}
}
2012-02-25 22:42:33 +04:00
2015-02-23 23:34:24 +03:00
ami_utf8_free ( utf8title ) ;
}
2009-06-03 23:44:43 +04:00
2015-02-23 23:34:24 +03:00
static void ami_redraw_callback ( void * p )
2008-08-02 18:31:32 +04:00
{
2015-02-23 23:34:24 +03:00
struct gui_window_2 * gwin = ( struct gui_window_2 * ) p ;
2009-02-01 02:45:25 +03:00
2015-02-23 23:34:24 +03:00
if ( gwin - > redraw_required ) {
ami_do_redraw ( gwin ) ;
}
2010-06-05 13:59:38 +04:00
2015-02-23 23:34:24 +03:00
ami_gui_window_update_box_deferred ( gwin - > gw , true ) ;
2009-02-01 02:45:25 +03:00
2015-02-23 23:34:24 +03:00
if ( gwin - > gw - > c_h )
{
gui_window_place_caret ( gwin - > gw , gwin - > gw - > c_x ,
gwin - > gw - > c_y , gwin - > gw - > c_h , NULL ) ;
2014-11-15 16:46:23 +03:00
}
2015-02-23 23:34:24 +03:00
}
2009-02-01 02:45:25 +03:00
2015-02-23 23:34:24 +03:00
/**
* Schedule a redraw of the browser window - Amiga - specific function
*
* \ param gwin a struct gui_window_2
* \ param full_redraw set to true to schedule a full redraw ,
should only be set to false when called from gui_window_update_box ( )
*/
void ami_schedule_redraw ( struct gui_window_2 * gwin , bool full_redraw )
{
int ms = 1 ;
2014-11-15 16:46:23 +03:00
2015-02-23 23:34:24 +03:00
if ( full_redraw ) gwin - > redraw_required = true ;
ami_schedule ( ms , ami_redraw_callback , gwin ) ;
}
2014-11-15 16:46:23 +03:00
2015-02-23 23:34:24 +03:00
static void ami_schedule_redraw_remove ( struct gui_window_2 * gwin )
{
ami_schedule ( - 1 , ami_redraw_callback , gwin ) ;
2008-08-02 18:31:32 +04:00
}
2014-01-13 03:50:54 +04:00
static void gui_window_redraw_window ( struct gui_window * g )
2008-08-15 21:19:57 +04:00
{
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2015-01-03 02:14:49 +03:00
if ( g = = g - > shared - > gw )
2013-04-04 22:31:42 +04:00
ami_schedule_redraw ( g - > shared , true ) ;
2008-08-15 21:19:57 +04:00
}
2013-02-14 00:23:17 +04:00
static void ami_gui_window_update_box_deferred ( struct gui_window * g , bool draw )
2008-08-15 21:19:57 +04:00
{
2013-02-03 18:01:48 +04:00
struct nsObject * node ;
struct nsObject * nnode ;
struct rect * rect ;
2009-08-18 17:06:28 +04:00
if ( ! g ) return ;
2013-02-03 18:01:48 +04:00
if ( IsMinListEmpty ( g - > deferred_rects ) ) return ;
2013-02-14 00:23:17 +04:00
if ( draw = = true ) {
2013-02-05 23:44:21 +04:00
ami_set_pointer ( g - > shared , GUI_POINTER_WAIT , false ) ;
} else {
2015-05-28 18:08:46 +03:00
LOG ( " Ignoring deferred box redraw queue " ) ;
2013-02-05 23:44:21 +04:00
}
2013-02-03 18:01:48 +04:00
node = ( struct nsObject * ) GetHead ( ( struct List * ) g - > deferred_rects ) ;
do {
2013-02-14 00:23:17 +04:00
if ( draw = = true ) {
2013-02-03 18:01:48 +04:00
rect = ( struct rect * ) node - > objstruct ;
2014-11-16 17:44:40 +03:00
ami_do_redraw_limits ( g , g - > bw , false ,
2013-02-03 18:01:48 +04:00
rect - > x0 , rect - > y0 , rect - > x1 , rect - > y1 ) ;
2013-02-05 23:44:21 +04:00
}
2013-02-03 18:01:48 +04:00
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
2016-11-20 19:30:33 +03:00
ami_memory_itempool_free ( g - > deferred_rects_pool , node - > objstruct , sizeof ( struct rect ) ) ;
2016-01-21 02:32:19 +03:00
DelObjectNoFree ( node ) ;
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2013-02-03 18:01:48 +04:00
2013-02-14 00:23:17 +04:00
if ( draw = = true ) ami_reset_pointer ( g - > shared ) ;
2013-02-05 23:44:21 +04:00
}
2017-01-02 02:57:35 +03:00
bool ami_gui_window_update_box_deferred_check ( struct MinList * deferred_rects ,
2016-07-03 20:48:46 +03:00
const struct rect * restrict new_rect , APTR mempool )
2013-02-05 23:44:21 +04:00
{
2016-01-21 02:32:19 +03:00
struct nsObject * node ;
struct nsObject * nnode ;
2016-07-03 20:48:46 +03:00
struct rect * restrict rect ;
2013-02-05 23:44:21 +04:00
if ( IsMinListEmpty ( deferred_rects ) ) return true ;
node = ( struct nsObject * ) GetHead ( ( struct List * ) deferred_rects ) ;
do {
2013-02-06 22:44:41 +04:00
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
2013-02-05 23:44:21 +04:00
rect = ( struct rect * ) node - > objstruct ;
2013-02-06 22:44:41 +04:00
if ( ( rect - > x0 < = new_rect - > x0 ) & &
( rect - > y0 < = new_rect - > y0 ) & &
( rect - > x1 > = new_rect - > x1 ) & &
( rect - > y1 > = new_rect - > y1 ) ) {
2013-02-05 23:44:21 +04:00
return false ;
}
2013-02-06 22:44:41 +04:00
if ( ( new_rect - > x0 < = rect - > x0 ) & &
( new_rect - > y0 < = rect - > y0 ) & &
( new_rect - > x1 > = rect - > x1 ) & &
( new_rect - > y1 > = rect - > y1 ) ) {
2015-05-28 18:08:46 +03:00
LOG ( " Removing queued redraw that is a subset of new box redraw " ) ;
2016-11-20 19:30:33 +03:00
ami_memory_itempool_free ( mempool , node - > objstruct , sizeof ( struct rect ) ) ;
2016-01-21 02:32:19 +03:00
DelObjectNoFree ( node ) ;
2013-02-06 22:44:41 +04:00
/* Don't return - we might find more */
}
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2013-02-05 23:44:21 +04:00
return true ;
2013-02-03 18:01:48 +04:00
}
2016-07-03 20:48:46 +03:00
static void gui_window_update_box ( struct gui_window * g , const struct rect * restrict rect )
2013-02-03 18:01:48 +04:00
{
struct nsObject * nsobj ;
2016-07-03 20:48:46 +03:00
struct rect * restrict deferred_rect ;
2013-02-03 18:01:48 +04:00
if ( ! g ) return ;
2016-01-21 02:32:19 +03:00
if ( ami_gui_window_update_box_deferred_check ( g - > deferred_rects , rect ,
g - > deferred_rects_pool ) ) {
2016-11-20 19:30:33 +03:00
deferred_rect = ami_memory_itempool_alloc ( g - > deferred_rects_pool , sizeof ( struct rect ) ) ;
2013-02-05 23:44:21 +04:00
CopyMem ( rect , deferred_rect , sizeof ( struct rect ) ) ;
nsobj = AddObject ( g - > deferred_rects , AMINS_RECT ) ;
nsobj - > objstruct = deferred_rect ;
} else {
2015-05-28 18:08:46 +03:00
LOG ( " Ignoring duplicate or subset of queued box redraw " ) ;
2013-02-05 23:44:21 +04:00
}
2013-04-04 22:31:42 +04:00
ami_schedule_redraw ( g - > shared , false ) ;
2008-08-15 21:19:57 +04:00
}
2014-06-30 19:40:56 +04:00
/**
* callback from core to reformat a window .
*/
static void amiga_window_reformat ( struct gui_window * gw )
{
struct IBox * bbox ;
2016-03-03 02:47:37 +03:00
LOG ( " reformat window %p " , gw ) ;
2014-06-30 19:40:56 +04:00
if ( gw ! = NULL ) {
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gw - > shared - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2014-11-16 17:44:40 +03:00
browser_window_reformat ( gw - > bw , false , bbox - > Width , bbox - > Height ) ;
2014-06-30 19:40:56 +04:00
gw - > shared - > redraw_scroll = false ;
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2014-06-30 19:40:56 +04:00
}
}
2013-04-04 22:46:33 +04:00
static void ami_do_redraw ( struct gui_window_2 * gwin )
2008-08-02 18:31:32 +04:00
{
2014-10-25 19:22:08 +04:00
ULONG hcurrent , vcurrent , xoffset , yoffset , width = 800 , height = 600 ;
2008-08-11 21:53:45 +04:00
struct IBox * bbox ;
2013-01-03 23:32:21 +04:00
ULONG oldh = gwin - > oldh , oldv = gwin - > oldv ;
2008-08-09 19:19:04 +04:00
2014-11-16 17:44:40 +03:00
if ( browser_window_redraw_ready ( gwin - > gw - > bw ) = = false ) return ;
2011-03-04 22:13:23 +03:00
2013-01-03 23:32:21 +04:00
ami_get_hscroll_pos ( gwin , ( ULONG * ) & hcurrent ) ;
ami_get_vscroll_pos ( gwin , ( ULONG * ) & vcurrent ) ;
2008-08-07 22:44:28 +04:00
2014-11-16 17:44:40 +03:00
gwin - > gw - > scrollx = hcurrent ;
gwin - > gw - > scrolly = vcurrent ;
2011-12-24 16:49:55 +04:00
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2008-08-11 21:53:45 +04:00
width = bbox - > Width ;
height = bbox - > Height ;
xoffset = bbox - > Left ;
yoffset = bbox - > Top ;
2008-08-10 00:27:36 +04:00
2013-01-03 23:32:21 +04:00
if ( gwin - > redraw_scroll )
2009-06-01 00:14:15 +04:00
{
if ( ( abs ( vcurrent - oldv ) > height ) | | ( abs ( hcurrent - oldh ) > width ) )
2013-01-03 23:32:21 +04:00
gwin - > redraw_scroll = false ;
2009-06-19 22:32:31 +04:00
2013-01-03 23:32:21 +04:00
if ( gwin - > new_content ) gwin - > redraw_scroll = false ;
2014-12-04 14:42:12 +03:00
// if(gwin->gw->scale != 1.0) gwin->redraw_scroll = false;
2011-02-24 02:11:26 +03:00
}
2008-08-10 00:27:36 +04:00
2013-01-03 23:32:21 +04:00
if ( gwin - > redraw_scroll )
2009-01-11 00:31:21 +03:00
{
2013-02-10 16:13:39 +04:00
struct rect rect ;
2013-02-03 22:50:16 +04:00
2014-11-16 17:44:40 +03:00
gwin - > gw - > c_h_temp = gwin - > gw - > c_h ;
gui_window_remove_caret ( gwin - > gw ) ;
2010-03-15 21:48:14 +03:00
2013-01-03 23:32:21 +04:00
ScrollWindowRaster ( gwin - > win , hcurrent - oldh , vcurrent - oldv ,
xoffset , yoffset , xoffset + width - 1 , yoffset + height - 1 ) ;
2009-02-02 00:28:59 +03:00
2014-11-16 17:44:40 +03:00
gwin - > gw - > c_h = gwin - > gw - > c_h_temp ;
2010-03-15 21:48:14 +03:00
2012-08-04 18:44:57 +04:00
if ( vcurrent > oldv ) /* Going down */
2009-02-05 15:20:23 +03:00
{
2013-02-10 16:13:39 +04:00
ami_spacebox_to_ns_coords ( gwin , & rect . x0 , & rect . y0 , 0 , height - ( vcurrent - oldv ) - 1 ) ;
ami_spacebox_to_ns_coords ( gwin , & rect . x1 , & rect . y1 , width + 1 , height + 1 ) ;
2014-11-16 17:44:40 +03:00
gui_window_update_box ( gwin - > gw , & rect ) ;
2009-02-05 15:20:23 +03:00
}
2012-08-04 18:44:57 +04:00
else if ( vcurrent < oldv ) /* Going up */
2009-02-05 15:20:23 +03:00
{
2013-02-10 16:13:39 +04:00
ami_spacebox_to_ns_coords ( gwin , & rect . x0 , & rect . y0 , 0 , 0 ) ;
ami_spacebox_to_ns_coords ( gwin , & rect . x1 , & rect . y1 , width + 1 , oldv - vcurrent + 1 ) ;
2014-11-16 17:44:40 +03:00
gui_window_update_box ( gwin - > gw , & rect ) ;
2009-02-05 15:20:23 +03:00
}
2009-02-02 00:28:59 +03:00
2012-08-04 18:44:57 +04:00
if ( hcurrent > oldh ) /* Going right */
2009-02-05 15:20:23 +03:00
{
2013-02-10 16:13:39 +04:00
ami_spacebox_to_ns_coords ( gwin , & rect . x0 , & rect . y0 , width - ( hcurrent - oldh ) , 0 ) ;
ami_spacebox_to_ns_coords ( gwin , & rect . x1 , & rect . y1 , width + 1 , height + 1 ) ;
2014-11-16 17:44:40 +03:00
gui_window_update_box ( gwin - > gw , & rect ) ;
2009-02-05 15:20:23 +03:00
}
2012-08-04 18:44:57 +04:00
else if ( hcurrent < oldh ) /* Going left */
2009-02-05 15:20:23 +03:00
{
2013-02-10 16:13:39 +04:00
ami_spacebox_to_ns_coords ( gwin , & rect . x0 , & rect . y0 , 0 , 0 ) ;
ami_spacebox_to_ns_coords ( gwin , & rect . x1 , & rect . y1 , oldh - hcurrent + 1 , height + 1 ) ;
2014-11-16 17:44:40 +03:00
gui_window_update_box ( gwin - > gw , & rect ) ;
2009-02-05 15:20:23 +03:00
}
2008-08-15 21:19:57 +04:00
}
else
{
2011-06-30 19:48:07 +04:00
struct redraw_context ctx = {
. interactive = true ,
2011-12-24 02:39:25 +04:00
. background_images = true ,
2017-02-13 03:18:32 +03:00
. plot = & amiplot ,
2017-02-13 20:46:20 +03:00
. priv = browserglob
2011-06-30 19:48:07 +04:00
} ;
2011-02-12 13:39:21 +03:00
2017-02-13 21:30:30 +03:00
ami_do_redraw_tiled ( gwin , true , hcurrent , vcurrent , width , height , hcurrent , vcurrent , bbox , & ctx ) ;
2013-02-10 16:13:39 +04:00
/* Tell NetSurf not to bother with the next queued box redraw, as we've redrawn everything. */
2014-11-16 17:44:40 +03:00
ami_gui_window_update_box_deferred ( gwin - > gw , false ) ;
2009-01-15 23:03:15 +03:00
}
2008-08-10 00:27:36 +04:00
2013-01-03 23:32:21 +04:00
ami_update_buttons ( gwin ) ;
2008-08-11 21:53:45 +04:00
2013-01-03 23:32:21 +04:00
gwin - > oldh = hcurrent ;
gwin - > oldv = vcurrent ;
2008-08-30 20:57:35 +04:00
2013-01-03 23:32:21 +04:00
gwin - > redraw_scroll = false ;
gwin - > redraw_required = false ;
gwin - > new_content = false ;
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2008-08-02 18:31:32 +04:00
}
2009-08-29 03:12:18 +04:00
void ami_get_hscroll_pos ( struct gui_window_2 * gwin , ULONG * xs )
{
2010-02-13 21:03:05 +03:00
if ( gwin - > objects [ GID_HSCROLL ] )
2009-08-29 03:12:18 +04:00
{
2014-10-26 19:42:00 +03:00
GetAttr ( SCROLLER_Top , ( Object * ) gwin - > objects [ GID_HSCROLL ] , xs ) ;
} else {
* xs = 0 ;
2009-08-29 03:12:18 +04:00
}
2009-08-31 01:43:14 +04:00
2014-12-04 14:42:12 +03:00
* xs / = gwin - > gw - > scale ;
2009-08-31 01:43:14 +04:00
}
void ami_get_vscroll_pos ( struct gui_window_2 * gwin , ULONG * ys )
{
2014-10-25 18:08:04 +04:00
if ( gwin - > objects [ GID_VSCROLL ] ) {
GetAttr ( SCROLLER_Top , gwin - > objects [ GID_VSCROLL ] , ys ) ;
} else {
* ys = 0 ;
}
2014-12-04 14:42:12 +03:00
* ys / = gwin - > gw - > scale ;
2009-08-29 03:12:18 +04:00
}
2016-07-03 20:48:46 +03:00
static bool gui_window_get_scroll ( struct gui_window * g , int * restrict sx , int * restrict sy )
2008-08-02 18:31:32 +04:00
{
2009-08-29 03:12:18 +04:00
ami_get_hscroll_pos ( g - > shared , ( ULONG * ) sx ) ;
2009-08-31 01:43:14 +04:00
ami_get_vscroll_pos ( g - > shared , ( ULONG * ) sy ) ;
2014-10-18 02:18:58 +04:00
return true ;
2008-08-02 18:31:32 +04:00
}
2014-01-13 05:08:15 +04:00
static void gui_window_set_scroll ( struct gui_window * g , int sx , int sy )
2008-08-02 18:31:32 +04:00
{
2010-06-05 14:37:02 +04:00
struct IBox * bbox ;
2014-12-04 15:14:16 +03:00
int width , height ;
2008-10-06 01:20:12 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2014-12-04 15:22:56 +03:00
if ( ! g - > bw | | browser_window_has_content ( g - > bw ) = = false ) return ;
2010-06-05 14:37:02 +04:00
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) g - > shared - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2010-06-05 14:37:02 +04:00
if ( sx < 0 ) sx = 0 ;
if ( sy < 0 ) sy = 0 ;
2014-12-04 15:14:16 +03:00
browser_window_get_extents ( g - > bw , false , & width , & height ) ;
if ( sx > = width - bbox - > Width )
sx = width - bbox - > Width ;
2014-12-04 15:18:36 +03:00
if ( sy > = height - bbox - > Height )
2014-12-04 15:14:16 +03:00
sy = height - bbox - > Height ;
2010-06-05 14:37:02 +04:00
2014-12-04 15:14:16 +03:00
if ( width < = bbox - > Width ) sx = 0 ;
if ( height < = bbox - > Height ) sy = 0 ;
2008-10-06 21:47:31 +04:00
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2015-01-03 02:14:49 +03:00
if ( g = = g - > shared - > gw ) {
2014-10-25 18:08:04 +04:00
if ( g - > shared - > objects [ GID_VSCROLL ] ) {
RefreshSetGadgetAttrs ( ( struct Gadget * ) ( APTR ) g - > shared - > objects [ GID_VSCROLL ] ,
g - > shared - > win , NULL ,
2014-12-04 14:42:12 +03:00
SCROLLER_Top , ( ULONG ) ( sy * g - > scale ) ,
2008-10-06 01:20:12 +04:00
TAG_DONE ) ;
2014-10-25 18:08:04 +04:00
}
2008-08-09 19:19:04 +04:00
2010-02-13 21:03:05 +03:00
if ( g - > shared - > objects [ GID_HSCROLL ] )
2009-08-29 03:12:18 +04:00
{
2010-02-13 21:03:05 +03:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) ( APTR ) g - > shared - > objects [ GID_HSCROLL ] ,
2009-08-29 03:12:18 +04:00
g - > shared - > win , NULL ,
2014-12-04 14:42:12 +03:00
SCROLLER_Top , ( ULONG ) ( sx * g - > scale ) ,
2009-08-29 03:12:18 +04:00
TAG_DONE ) ;
}
2014-10-26 19:42:00 +03:00
2013-04-04 22:31:42 +04:00
ami_schedule_redraw ( g - > shared , true ) ;
2009-05-31 19:19:46 +04:00
2012-03-22 13:34:34 +04:00
if ( nsoption_bool ( faster_scroll ) = = true ) g - > shared - > redraw_scroll = true ;
2009-06-04 22:19:27 +04:00
else g - > shared - > redraw_scroll = false ;
2009-03-09 10:21:19 +03:00
g - > scrollx = sx ;
g - > scrolly = sy ;
2008-10-19 15:33:05 +04:00
}
2008-08-02 18:31:32 +04:00
}
2014-01-13 15:38:35 +04:00
static void gui_window_update_extent ( struct gui_window * g )
2008-08-02 18:31:32 +04:00
{
2014-10-18 02:18:58 +04:00
struct IBox * bbox ;
2008-08-17 20:22:40 +04:00
2014-12-04 15:22:56 +03:00
if ( ! g | | ! g - > bw ) return ;
if ( browser_window_has_content ( g - > bw ) = = false ) return ;
2014-10-18 02:18:58 +04:00
2015-01-03 02:14:49 +03:00
if ( g = = g - > shared - > gw ) {
2014-12-04 15:14:16 +03:00
int width , height ;
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) g - > shared - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2008-08-09 19:19:04 +04:00
2014-10-25 18:08:04 +04:00
if ( g - > shared - > objects [ GID_VSCROLL ] ) {
2014-12-04 15:14:16 +03:00
browser_window_get_extents ( g - > bw , true , & width , & height ) ;
2014-10-25 18:08:04 +04:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) ( APTR ) g - > shared - > objects [ GID_VSCROLL ] , g - > shared - > win , NULL ,
2014-12-04 15:14:16 +03:00
SCROLLER_Total , ( ULONG ) ( height ) ,
2014-10-25 18:08:04 +04:00
SCROLLER_Visible , bbox - > Height ,
2008-10-19 15:33:05 +04:00
TAG_DONE ) ;
2014-10-25 18:08:04 +04:00
}
2008-08-09 19:19:04 +04:00
2010-02-13 21:03:05 +03:00
if ( g - > shared - > objects [ GID_HSCROLL ] )
2009-08-29 03:12:18 +04:00
{
2014-12-04 15:14:16 +03:00
browser_window_get_extents ( g - > bw , true , & width , & height ) ;
2010-02-13 21:03:05 +03:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) ( APTR ) g - > shared - > objects [ GID_HSCROLL ] ,
2009-08-29 03:12:18 +04:00
g - > shared - > win , NULL ,
2014-12-04 15:14:16 +03:00
SCROLLER_Total , ( ULONG ) ( width ) ,
2009-08-29 03:12:18 +04:00
SCROLLER_Visible , bbox - > Width ,
TAG_DONE ) ;
}
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2008-10-19 15:33:05 +04:00
}
2014-10-27 01:22:15 +03:00
ami_gui_scroller_update ( g - > shared ) ;
2009-06-20 13:57:26 +04:00
g - > shared - > new_content = true ;
2008-08-02 18:31:32 +04:00
}
2014-01-13 18:51:27 +04:00
static void gui_window_set_status ( struct gui_window * g , const char * text )
2008-08-02 18:31:32 +04:00
{
2009-08-29 14:16:19 +04:00
char * utf8text ;
2010-02-11 21:49:03 +03:00
ULONG size ;
UWORD chars ;
struct TextExtent textex ;
2008-10-19 15:33:05 +04:00
if ( ! g ) return ;
2009-08-14 21:53:28 +04:00
if ( ! text ) return ;
2010-02-13 21:03:05 +03:00
if ( ! g - > shared - > objects [ GID_STATUS ] ) return ;
2008-10-19 15:33:05 +04:00
2015-01-03 02:14:49 +03:00
if ( g = = g - > shared - > gw ) {
2009-09-04 22:10:15 +04:00
utf8text = ami_utf8_easy ( ( char * ) text ) ;
2009-10-16 01:35:29 +04:00
if ( utf8text = = NULL ) return ;
2009-08-29 14:16:19 +04:00
2010-02-13 21:03:05 +03:00
GetAttr ( GA_Width , g - > shared - > objects [ GID_STATUS ] , ( ULONG * ) & size ) ;
2016-01-15 23:43:12 +03:00
chars = TextFit ( & scrn - > RastPort , utf8text , ( UWORD ) strlen ( utf8text ) ,
2010-04-02 14:49:18 +04:00
& textex , NULL , 1 , size - 4 , scrn - > RastPort . TxHeight ) ;
2010-01-09 02:13:20 +03:00
2010-02-11 21:49:03 +03:00
utf8text [ chars ] = 0 ;
2010-01-09 02:13:20 +03:00
2010-02-13 21:03:05 +03:00
SetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_STATUS ] ,
2010-02-11 21:49:03 +03:00
g - > shared - > win , NULL ,
2016-01-11 22:10:59 +03:00
NSA_STATUS_TEXT , utf8text ,
2010-02-11 21:49:03 +03:00
TAG_DONE ) ;
2009-08-29 03:12:18 +04:00
2010-02-13 21:03:05 +03:00
RefreshGList ( ( struct Gadget * ) g - > shared - > objects [ GID_STATUS ] ,
g - > shared - > win , NULL , 1 ) ;
2009-08-29 14:16:19 +04:00
2010-02-11 21:49:03 +03:00
if ( g - > shared - > status ) ami_utf8_free ( g - > shared - > status ) ;
g - > shared - > status = utf8text ;
2008-10-19 15:33:05 +04:00
}
2008-08-02 18:31:32 +04:00
}
2014-11-03 01:30:45 +03:00
static nserror gui_window_set_url ( struct gui_window * g , nsurl * url )
2008-08-02 18:31:32 +04:00
{
2015-07-23 02:05:22 +03:00
size_t idn_url_l ;
char * idn_url_s = NULL ;
char * url_lc = NULL ;
2014-11-09 04:10:52 +03:00
if ( ! g ) return NSERROR_OK ;
2008-08-31 01:32:05 +04:00
2015-07-26 20:09:25 +03:00
if ( g = = g - > shared - > gw ) {
2015-07-23 02:05:22 +03:00
if ( nsoption_bool ( display_decoded_idn ) = = true ) {
2015-10-25 12:03:20 +03:00
if ( nsurl_get_utf8 ( url , & idn_url_s , & idn_url_l ) = = NSERROR_OK ) {
2015-07-23 02:05:22 +03:00
url_lc = ami_utf8_easy ( idn_url_s ) ;
}
}
RefreshSetGadgetAttrs ( ( struct Gadget * ) g - > shared - > objects [ GID_URL ] ,
g - > shared - > win , NULL ,
STRINGA_TextVal , url_lc ? url_lc : nsurl_access ( url ) ,
TAG_DONE ) ;
if ( url_lc ) {
ami_utf8_free ( url_lc ) ;
if ( idn_url_s ) free ( idn_url_s ) ;
2015-07-17 22:59:49 +03:00
}
2008-10-05 17:17:18 +04:00
}
2011-07-16 17:53:22 +04:00
ami_update_buttons ( g - > shared ) ;
2014-10-29 03:17:11 +03:00
return NSERROR_OK ;
2008-08-02 18:31:32 +04:00
}
2015-02-24 01:58:57 +03:00
HOOKF ( uint32 , ami_set_favicon_render_hook , APTR , space , struct gpRender * )
2012-04-29 19:59:37 +04:00
{
2014-07-05 22:00:21 +04:00
ami_schedule ( 0 , ami_gui_refresh_favicon , hook - > h_Data ) ;
2012-04-29 19:59:37 +04:00
return 0 ;
}
2009-12-18 02:55:02 +03:00
/**
2014-05-25 03:57:48 +04:00
* Gui callback when search provider details are updated .
*
* \ param provider_name The providers name .
* \ param ico_bitmap The icon bitmap representing the provider .
* \ return NSERROR_OK on success else error code .
2009-12-18 02:55:02 +03:00
*/
2014-05-25 04:14:01 +04:00
static nserror gui_search_web_provider_update ( const char * provider_name ,
2014-05-25 03:57:48 +04:00
struct bitmap * ico_bitmap )
2009-12-18 02:55:02 +03:00
{
2009-12-22 02:25:35 +03:00
struct BitMap * bm = NULL ;
struct nsObject * node ;
struct nsObject * nnode ;
struct gui_window_2 * gwin ;
2014-05-25 04:14:01 +04:00
if ( IsMinListEmpty ( window_list ) ) return NSERROR_BAD_PARAMETER ;
if ( nsoption_bool ( kiosk_mode ) = = true ) return NSERROR_BAD_PARAMETER ;
2011-10-08 01:53:35 +04:00
2014-05-25 03:57:48 +04:00
if ( ico_bitmap ! = NULL ) {
2017-02-13 21:41:38 +03:00
bm = ami_bitmap_get_native ( ico_bitmap , 16 , 16 , ami_plot_screen_is_palettemapped ( ) , NULL ) ;
2014-05-25 03:57:48 +04:00
}
2011-07-02 23:38:54 +04:00
2015-01-31 14:59:31 +03:00
if ( bm = = NULL ) return NSERROR_BAD_PARAMETER ;
2009-12-22 02:25:35 +03:00
node = ( struct nsObject * ) GetHead ( ( struct List * ) window_list ) ;
do {
nnode = ( struct nsObject * ) GetSucc ( ( struct Node * ) node ) ;
gwin = node - > objstruct ;
2011-09-05 02:35:11 +04:00
if ( node - > Type = = AMINS_WINDOW )
2009-12-22 02:25:35 +03:00
{
2014-06-15 18:39:49 +04:00
if ( gwin - > search_bm ! = NULL )
DisposeObject ( gwin - > search_bm ) ;
2015-01-31 15:59:49 +03:00
ULONG bm_masking_tag = TAG_IGNORE ;
2015-08-17 19:52:09 +03:00
if ( LIB_IS_AT_LEAST ( ( struct Library * ) ChooserBase , 53 , 21 ) ) {
/* Broken in earlier versions */
2015-01-31 15:59:49 +03:00
bm_masking_tag = BITMAP_Masking ;
}
2015-01-25 03:27:53 +03:00
gwin - > search_bm = BitMapObj ,
2014-06-15 18:48:55 +04:00
BITMAP_Screen , scrn ,
2014-06-15 18:39:49 +04:00
BITMAP_Width , 16 ,
BITMAP_Height , 16 ,
BITMAP_BitMap , bm ,
2015-01-31 15:59:49 +03:00
BITMAP_HasAlpha , TRUE ,
bm_masking_tag , TRUE ,
2014-06-15 18:39:49 +04:00
BitMapEnd ;
2010-03-18 00:43:23 +03:00
RefreshSetGadgetAttrs ( ( struct Gadget * ) gwin - > objects [ GID_SEARCH_ICON ] ,
gwin - > win , NULL ,
2014-05-25 03:57:48 +04:00
GA_HintInfo , provider_name ,
2014-06-15 18:39:49 +04:00
GA_Image , gwin - > search_bm ,
2010-03-18 00:43:23 +03:00
TAG_DONE ) ;
2009-12-22 02:25:35 +03:00
}
2014-10-25 19:22:08 +04:00
} while ( ( node = nnode ) ) ;
2014-05-25 03:57:48 +04:00
return NSERROR_OK ;
2009-12-18 02:55:02 +03:00
}
2015-02-24 01:58:57 +03:00
HOOKF ( uint32 , ami_set_throbber_render_hook , APTR , space , struct gpRender * )
2012-04-29 19:59:37 +04:00
{
2014-07-05 21:44:44 +04:00
struct gui_window_2 * gwin = hook - > h_Data ;
2014-11-16 17:44:40 +03:00
ami_throbber_redraw_schedule ( 0 , gwin - > gw ) ;
2012-04-29 19:59:37 +04:00
return 0 ;
}
2014-01-13 18:51:27 +04:00
static void gui_window_place_caret ( struct gui_window * g , int x , int y , int height ,
2013-03-06 02:53:33 +04:00
const struct rect * clip )
2008-08-02 18:31:32 +04:00
{
2008-08-22 01:41:42 +04:00
struct IBox * bbox ;
2014-10-25 19:22:08 +04:00
int xs , ys ;
2008-08-22 01:41:42 +04:00
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2008-09-28 00:55:11 +04:00
gui_window_remove_caret ( g ) ;
2011-03-20 01:40:02 +03:00
xs = g - > scrollx ;
ys = g - > scrolly ;
2008-08-22 01:41:42 +04:00
2008-10-05 03:29:17 +04:00
SetAPen ( g - > shared - > win - > RPort , 3 ) ;
2008-09-28 01:33:00 +04:00
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) g - > shared - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return ;
}
2009-03-28 18:43:12 +03:00
if ( ( y - ys + height ) > ( bbox - > Height ) ) height = bbox - > Height - y + ys ;
2014-11-15 16:46:23 +03:00
if ( ( ( x - xs ) < = 0 ) | | ( ( x - xs + 2 ) > = ( bbox - > Width ) ) | | ( ( y - ys ) < = 0 ) | | ( ( y - ys ) > = ( bbox - > Height ) ) ) {
ami_gui_free_space_box ( bbox ) ;
return ;
}
2008-09-28 01:33:00 +04:00
2011-03-19 16:00:45 +03:00
g - > c_w = 2 ;
2010-09-19 16:38:23 +04:00
2009-04-29 21:05:40 +04:00
SetDrMd ( g - > shared - > win - > RPort , COMPLEMENT ) ;
2011-03-19 16:00:45 +03:00
RectFill ( g - > shared - > win - > RPort , x + bbox - > Left - xs , y + bbox - > Top - ys ,
x + bbox - > Left + g - > c_w - xs , y + bbox - > Top + height - ys ) ;
2009-04-29 21:05:40 +04:00
SetDrMd ( g - > shared - > win - > RPort , JAM1 ) ;
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2008-10-19 15:33:05 +04:00
g - > c_x = x ;
g - > c_y = y ;
g - > c_h = height ;
2010-07-24 20:39:37 +04:00
2012-03-22 13:34:34 +04:00
if ( ( nsoption_bool ( kiosk_mode ) = = false ) )
2017-01-15 19:05:07 +03:00
ami_gui_menu_set_disabled ( g - > shared - > win , g - > shared - > imenu , M_PASTE , false ) ;
2008-08-02 18:31:32 +04:00
}
2014-01-13 18:51:27 +04:00
static void gui_window_remove_caret ( struct gui_window * g )
2008-08-02 18:31:32 +04:00
{
2008-08-31 01:32:05 +04:00
if ( ! g ) return ;
2010-09-19 16:58:25 +04:00
if ( g - > c_h = = 0 ) return ;
2008-08-31 01:32:05 +04:00
2012-03-22 13:34:34 +04:00
if ( ( nsoption_bool ( kiosk_mode ) = = false ) )
2017-01-15 19:05:07 +03:00
ami_gui_menu_set_disabled ( g - > shared - > win , g - > shared - > imenu , M_PASTE , true ) ;
2010-07-24 20:39:37 +04:00
2014-11-16 17:44:40 +03:00
ami_do_redraw_limits ( g , g - > bw , false , g - > c_x , g - > c_y ,
2011-03-19 16:00:45 +03:00
g - > c_x + g - > c_w + 1 , g - > c_y + g - > c_h + 1 ) ;
2008-09-23 00:41:01 +04:00
2008-10-19 15:33:05 +04:00
g - > c_h = 0 ;
2008-08-02 18:31:32 +04:00
}
2014-01-13 02:55:26 +04:00
static void gui_window_new_content ( struct gui_window * g )
2008-08-02 18:31:32 +04:00
{
2016-06-06 10:59:23 +03:00
struct hlcache_handle * c ;
2009-05-23 23:06:58 +04:00
2014-12-04 15:22:56 +03:00
if ( g & & g - > shared & & g - > bw & & browser_window_has_content ( g - > bw ) )
c = browser_window_get_content ( g - > bw ) ;
2009-05-23 23:06:58 +04:00
else return ;
2009-05-17 14:40:42 +04:00
2017-02-13 20:46:20 +03:00
ami_clearclipreg ( browserglob ) ;
2009-06-03 11:14:24 +04:00
g - > shared - > new_content = true ;
2009-06-14 16:34:53 +04:00
g - > scrollx = 0 ;
g - > scrolly = 0 ;
2009-06-19 22:32:31 +04:00
g - > shared - > oldh = 0 ;
g - > shared - > oldv = 0 ;
2009-12-22 02:25:35 +03:00
g - > favicon = NULL ;
2016-01-25 03:01:55 +03:00
ami_plot_release_pens ( g - > shared - > shared_pens ) ;
2017-01-15 19:05:07 +03:00
ami_gui_menu_update_disabled ( g , c ) ;
2013-11-23 16:23:56 +04:00
ami_gui_update_hotlist_button ( g - > shared ) ;
2014-10-27 00:30:19 +03:00
ami_gui_scroller_update ( g - > shared ) ;
2008-08-02 18:31:32 +04:00
}
2014-01-12 21:07:34 +04:00
static 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 )
2008-08-02 18:31:32 +04:00
{
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2012-01-12 01:41:55 +04:00
g - > shared - > drag_op = type ;
if ( rect ) g - > shared - > ptr_lock = ami_ns_rect_to_ibox ( g - > shared , rect ) ;
if ( type = = GDRAGGING_NONE )
{
2012-01-15 19:57:02 +04:00
SetWindowAttrs ( g - > shared - > win , WA_GrabFocus , 0 ,
2012-01-12 01:41:55 +04:00
WA_MouseLimits , NULL , TAG_DONE ) ;
2012-01-15 19:57:02 +04:00
if ( g - > shared - > ptr_lock )
2012-01-12 01:41:55 +04:00
{
2016-11-20 00:02:42 +03:00
free ( g - > shared - > ptr_lock ) ;
2012-01-15 19:57:02 +04:00
g - > shared - > ptr_lock = NULL ;
2012-01-12 01:41:55 +04:00
}
}
2015-01-17 20:06:48 +03:00
# endif
2009-06-19 22:32:31 +04:00
return true ;
2008-08-02 18:31:32 +04:00
}
2010-07-24 23:57:27 +04:00
/* return the text box at posn x,y in window coordinates
x , y are updated to be document co - ordinates */
2010-07-24 20:39:37 +04:00
2016-07-03 20:48:46 +03:00
bool ami_text_box_at_point ( struct gui_window_2 * gwin , ULONG * restrict x , ULONG * restrict y )
2010-07-24 20:39:37 +04:00
{
struct IBox * bbox ;
2014-11-15 16:46:23 +03:00
ULONG xs , ys ;
2014-11-02 18:46:42 +03:00
struct browser_window_features data ;
2010-09-17 00:55:25 +04:00
2014-11-15 16:46:23 +03:00
if ( ami_gui_get_space_box ( ( Object * ) gwin - > objects [ GID_BROWSER ] , & bbox ) ! = NSERROR_OK ) {
2016-04-26 01:11:55 +03:00
amiga_warn_user ( " NoMemory " , " " ) ;
2014-11-15 16:46:23 +03:00
return false ;
}
2010-07-24 20:39:37 +04:00
2010-07-28 01:41:21 +04:00
ami_get_hscroll_pos ( gwin , ( ULONG * ) & xs ) ;
2010-07-24 23:57:27 +04:00
* x = * x - ( bbox - > Left ) + xs ;
2010-07-24 20:39:37 +04:00
2010-07-28 01:41:21 +04:00
ami_get_vscroll_pos ( gwin , ( ULONG * ) & ys ) ;
2010-07-24 23:57:27 +04:00
* y = * y - ( bbox - > Top ) + ys ;
2010-07-24 20:39:37 +04:00
2014-11-15 16:46:23 +03:00
ami_gui_free_space_box ( bbox ) ;
2010-07-24 20:39:37 +04:00
2014-11-16 17:44:40 +03:00
browser_window_get_features ( gwin - > gw - > bw , * x , * y , & data ) ;
2010-07-24 20:39:37 +04:00
2012-08-21 01:03:59 +04:00
if ( data . form_features = = CTX_FORM_TEXT )
return true ;
2010-07-24 20:39:37 +04:00
2012-08-21 01:03:59 +04:00
return false ;
2010-07-24 20:39:37 +04:00
}
2011-02-28 22:31:35 +03:00
BOOL ami_gadget_hit ( Object * obj , int x , int y )
{
int top , left , width , height ;
GetAttrs ( obj ,
GA_Left , & left ,
GA_Top , & top ,
GA_Width , & width ,
GA_Height , & height ,
TAG_DONE ) ;
if ( ( x > = left ) & & ( x < = ( left + width ) ) & & ( y > = top ) & & ( y < = ( top + height ) ) )
return TRUE ;
else return FALSE ;
}
2011-05-08 02:21:41 +04:00
Object * ami_gui_splash_open ( void )
{
2016-07-03 20:48:46 +03:00
Object * restrict win_obj , * restrict bm_obj ;
2011-05-08 02:21:41 +04:00
struct Window * win ;
struct Screen * wbscreen = LockPubScreen ( " Workbench " ) ;
2011-09-07 22:38:08 +04:00
uint32 top = 0 , left = 0 ;
2011-09-08 03:01:53 +04:00
struct TextAttr tattr ;
struct TextFont * tfont ;
2011-05-08 02:21:41 +04:00
2015-01-25 03:27:53 +03:00
win_obj = WindowObj ,
2015-01-19 23:50:06 +03:00
# ifdef __amigaos4__
2011-05-08 02:21:41 +04:00
WA_ToolBox , TRUE ,
2015-01-19 23:50:06 +03:00
# endif
WA_Borderless , TRUE ,
2011-05-08 02:21:41 +04:00
WA_BusyPointer , TRUE ,
WINDOW_Position , WPOS_CENTERSCREEN ,
WINDOW_LockWidth , TRUE ,
WINDOW_LockHeight , TRUE ,
2015-01-25 03:27:53 +03:00
WINDOW_ParentGroup , LayoutVObj ,
LAYOUT_AddImage , bm_obj = BitMapObj ,
2011-09-07 22:38:08 +04:00
BITMAP_SourceFile , " PROGDIR:Resources/splash.png " ,
2011-05-08 02:21:41 +04:00
BITMAP_Screen , wbscreen ,
2015-01-20 03:39:32 +03:00
BITMAP_Precision , PRECISION_IMAGE ,
2011-05-08 02:21:41 +04:00
BitMapEnd ,
LayoutEnd ,
EndWindow ;
2016-11-28 22:35:15 +03:00
if ( win_obj = = NULL ) {
LOG ( " Splash window object not created " ) ;
return NULL ;
}
2015-05-28 18:08:46 +03:00
LOG ( " Attempting to open splash window... " ) ;
2011-05-08 02:21:41 +04:00
win = RA_OpenWindow ( win_obj ) ;
2016-11-28 22:35:15 +03:00
if ( win = = NULL ) {
LOG ( " Splash window did not open " ) ;
return NULL ;
}
if ( bm_obj = = NULL ) {
LOG ( " BitMap object not created " ) ;
return NULL ;
}
2011-09-07 22:38:08 +04:00
GetAttrs ( bm_obj , IA_Top , & top ,
IA_Left , & left ,
TAG_DONE ) ;
2011-09-08 03:01:53 +04:00
SetDrMd ( win - > RPort , JAM1 ) ;
2015-01-30 03:05:40 +03:00
# ifdef __amigaos4__
SetRPAttrs ( win - > RPort , RPTAG_APenColor , 0xFF3F6DFE , TAG_DONE ) ;
2011-12-24 16:57:42 +04:00
tattr . ta_Name = " DejaVu Serif Italic.font " ;
2015-01-30 03:05:40 +03:00
# else
2015-01-31 14:59:31 +03:00
SetAPen ( win - > RPort , 3 ) ; /* Pen 3 is usually blue */
2015-02-05 21:54:39 +03:00
tattr . ta_Name = " ruby.font " ;
2015-01-30 03:05:40 +03:00
# endif
2011-09-08 03:01:53 +04:00
tattr . ta_YSize = 24 ;
tattr . ta_Style = 0 ;
tattr . ta_Flags = 0 ;
2014-10-25 19:22:08 +04:00
if ( ( tfont = ami_font_open_disk_font ( & tattr ) ) )
2011-12-24 16:57:42 +04:00
{
2011-09-08 03:01:53 +04:00
SetFont ( win - > RPort , tfont ) ;
2011-12-24 16:57:42 +04:00
}
else
{
tattr . ta_Name = " DejaVu Serif Oblique.font " ;
2014-10-25 19:22:08 +04:00
if ( ( tfont = ami_font_open_disk_font ( & tattr ) ) )
2011-12-24 16:57:42 +04:00
SetFont ( win - > RPort , tfont ) ;
}
2011-09-08 03:01:53 +04:00
Move ( win - > RPort , left + 5 , top + 25 ) ;
2011-09-07 22:38:08 +04:00
Text ( win - > RPort , " Initialising... " , strlen ( " Initialising... " ) ) ;
2011-09-08 03:01:53 +04:00
if ( tfont ) ami_font_close_disk_font ( tfont ) ;
2015-01-30 03:05:40 +03:00
# ifdef __amigaos4__
2011-09-08 03:01:53 +04:00
tattr . ta_Name = " DejaVu Sans.font " ;
2015-01-30 03:05:40 +03:00
# else
2015-02-05 21:54:39 +03:00
tattr . ta_Name = " helvetica.font " ;
2015-01-30 03:05:40 +03:00
# endif
2011-09-08 03:01:53 +04:00
tattr . ta_YSize = 16 ;
tattr . ta_Style = 0 ;
tattr . ta_Flags = 0 ;
2014-10-25 19:22:08 +04:00
if ( ( tfont = ami_font_open_disk_font ( & tattr ) ) )
2011-09-08 03:01:53 +04:00
SetFont ( win - > RPort , tfont ) ;
2011-09-07 22:38:08 +04:00
Move ( win - > RPort , left + 185 , top + 220 ) ;
2016-07-29 20:02:56 +03:00
Text ( win - > RPort , netsurf_version , strlen ( netsurf_version ) ) ;
2011-09-07 22:38:08 +04:00
2011-09-08 03:01:53 +04:00
if ( tfont ) ami_font_close_disk_font ( tfont ) ;
2011-09-07 22:38:08 +04:00
2011-05-08 02:21:41 +04:00
UnlockPubScreen ( NULL , wbscreen ) ;
return win_obj ;
}
void ami_gui_splash_close ( Object * win_obj )
{
2014-09-20 16:38:38 +04:00
if ( win_obj = = NULL ) return ;
2015-05-28 18:08:46 +03:00
LOG ( " Closing splash window " ) ;
2014-09-20 16:38:38 +04:00
DisposeObject ( win_obj ) ;
2011-05-08 02:21:41 +04:00
}
2014-01-05 20:01:03 +04:00
2016-06-06 10:59:23 +03:00
static void gui_file_gadget_open ( struct gui_window * g , struct hlcache_handle * hl ,
2014-01-05 20:01:03 +04:00
struct form_control * gadget )
{
2015-05-28 18:08:46 +03:00
LOG ( " File open dialog request for %p/%p " , g , gadget ) ;
2014-01-06 03:04:28 +04:00
if ( AslRequestTags ( filereq ,
ASLFR_Window , g - > shared - > win ,
ASLFR_SleepWindow , TRUE ,
ASLFR_TitleText , messages_get ( " NetSurf " ) ,
ASLFR_Screen , scrn ,
ASLFR_DoSaveMode , FALSE ,
TAG_DONE ) ) {
char fname [ 1024 ] ;
strlcpy ( fname , filereq - > fr_Drawer , 1024 ) ;
AddPart ( fname , filereq - > fr_File , 1024 ) ;
2014-11-16 17:44:40 +03:00
browser_window_set_gadget_filename ( g - > bw , gadget , fname ) ;
2014-01-06 03:04:28 +04:00
}
2014-01-05 20:01:03 +04:00
}
2014-11-16 17:06:12 +03:00
/* exported function documented in amiga/gui.h */
uint32 ami_gui_get_app_id ( void )
{
return ami_appid ;
}
2016-12-11 19:04:16 +03:00
/* Get current user directory for user-specific NetSurf data
* Returns NULL on error
*/
static char * ami_gui_get_user_dir ( STRPTR current_user )
{
BPTR lock = 0 ;
char temp [ 1024 ] ;
int32 user = 0 ;
if ( current_user = = NULL ) {
user = GetVar ( " user " , temp , 1024 , GVF_GLOBAL_ONLY ) ;
current_user = ASPrintf ( " %s " , ( user = = - 1 ) ? " Default " : temp ) ;
}
LOG ( " User: %s " , current_user ) ;
if ( users_dir = = NULL ) {
users_dir = ASPrintf ( " %s " , USERS_DIR ) ;
if ( users_dir = = NULL ) {
ami_misc_fatal_error ( " Failed to allocate memory " ) ;
FreeVec ( current_user ) ;
return NULL ;
}
}
if ( LIB_IS_AT_LEAST ( ( struct Library * ) DOSBase , 51 , 96 ) ) {
# ifdef __amigaos4__
struct InfoData * infodata = AllocDosObject ( DOS_INFODATA , 0 ) ;
if ( infodata = = NULL ) {
ami_misc_fatal_error ( " Failed to allocate memory " ) ;
FreeVec ( current_user ) ;
return NULL ;
}
GetDiskInfoTags ( GDI_StringNameInput , users_dir ,
GDI_InfoData , infodata ,
TAG_DONE ) ;
if ( infodata - > id_DiskState = = ID_DISKSTATE_WRITE_PROTECTED ) {
FreeDosObject ( DOS_INFODATA , infodata ) ;
ami_misc_fatal_error ( " User directory MUST be on a writeable volume " ) ;
FreeVec ( current_user ) ;
return NULL ;
}
FreeDosObject ( DOS_INFODATA , infodata ) ;
# else
# warning FIXME for OS3 and older OS4
# endif
} else {
//TODO: check volume write status using old API
}
int len = strlen ( current_user ) ;
len + = strlen ( users_dir ) ;
len + = 2 ; /* for poss path sep and NULL term */
current_user_dir = malloc ( len ) ;
if ( current_user_dir = = NULL ) {
ami_misc_fatal_error ( " Failed to allocate memory " ) ;
2016-12-11 19:16:11 +03:00
FreeVec ( current_user ) ;
2016-12-11 19:04:16 +03:00
return NULL ;
}
strlcpy ( current_user_dir , users_dir , len ) ;
AddPart ( current_user_dir , current_user , len ) ;
FreeVec ( users_dir ) ;
2016-12-11 19:16:11 +03:00
FreeVec ( current_user ) ;
2016-12-11 19:04:16 +03:00
LOG ( " User dir: %s " , current_user_dir ) ;
if ( ( lock = CreateDirTree ( current_user_dir ) ) )
UnLock ( lock ) ;
ami_nsoption_set_location ( current_user_dir ) ;
current_user_faviconcache = ASPrintf ( " %s/IconCache " , current_user_dir ) ;
if ( ( lock = CreateDirTree ( current_user_faviconcache ) ) ) UnLock ( lock ) ;
return current_user_dir ;
}
2014-01-15 23:37:05 +04:00
static struct gui_window_table amiga_window_table = {
2014-01-12 21:07:34 +04:00
. create = gui_window_create ,
. destroy = gui_window_destroy ,
2014-01-13 03:50:54 +04:00
. redraw = gui_window_redraw_window ,
. update = gui_window_update_box ,
2014-01-13 05:08:15 +04:00
. get_scroll = gui_window_get_scroll ,
. set_scroll = gui_window_set_scroll ,
2014-01-13 15:38:35 +04:00
. get_dimensions = gui_window_get_dimensions ,
. update_extent = gui_window_update_extent ,
2014-06-30 19:40:56 +04:00
. reformat = amiga_window_reformat ,
2014-01-12 21:07:34 +04:00
. set_icon = gui_window_set_icon ,
. set_title = gui_window_set_title ,
. set_url = gui_window_set_url ,
2014-01-13 18:51:27 +04:00
. set_status = gui_window_set_status ,
. place_caret = gui_window_place_caret ,
. remove_caret = gui_window_remove_caret ,
2014-01-12 21:07:34 +04:00
. drag_start = gui_window_drag_start ,
2014-01-13 02:55:26 +04:00
. new_content = gui_window_new_content ,
2014-10-24 23:45:21 +04:00
. create_form_select_menu = gui_create_form_select_menu ,
2014-01-14 02:54:19 +04:00
. file_gadget_open = gui_file_gadget_open ,
. drag_save_object = gui_drag_save_object ,
. drag_save_selection = gui_drag_save_selection ,
. start_selection = gui_start_selection ,
2014-01-13 18:51:27 +04:00
/* from theme */
. set_pointer = gui_window_set_pointer ,
2014-01-12 21:07:34 +04:00
. start_throbber = gui_window_start_throbber ,
. stop_throbber = gui_window_stop_throbber ,
/* from download */
. save_link = gui_window_save_link ,
} ;
2014-05-07 19:14:18 +04:00
2014-01-23 03:19:57 +04:00
static struct gui_fetch_table amiga_fetch_table = {
. filetype = fetch_filetype ,
. get_resource_url = gui_get_resource_url ,
} ;
2014-01-12 21:07:34 +04:00
2014-05-25 03:57:48 +04:00
static struct gui_search_web_table amiga_search_web_table = {
. provider_update = gui_search_web_provider_update ,
} ;
2016-04-16 00:50:28 +03:00
static struct gui_misc_table amiga_misc_table = {
2014-03-08 18:13:27 +04:00
. schedule = ami_schedule ,
2016-04-26 01:11:55 +03:00
. warning = amiga_warn_user ,
2014-01-23 03:19:57 +04:00
2014-01-12 02:34:12 +04:00
. quit = gui_quit ,
2014-01-15 03:31:54 +04:00
. launch_url = gui_launch_url ,
2017-01-02 15:57:07 +03:00
. cert_verify = ami_cert_verify ,
2014-01-16 04:52:17 +04:00
. login = gui_401login_open ,
2014-01-11 18:20:30 +04:00
} ;
/** Normal entry point from OS */
int main ( int argc , char * * argv )
{
setbuf ( stderr , NULL ) ;
char messages [ 100 ] ;
char script [ 1024 ] ;
char temp [ 1024 ] ;
2014-05-16 12:55:38 +04:00
STRPTR current_user_cache = NULL ;
2016-12-11 19:04:16 +03:00
STRPTR current_user = NULL ;
2014-01-11 18:20:30 +04:00
BPTR lock = 0 ;
nserror ret ;
2015-11-25 03:11:24 +03:00
int nargc = 0 ;
char * nargv = NULL ;
2014-09-20 16:38:38 +04:00
2014-05-10 13:22:10 +04:00
struct netsurf_table amiga_table = {
2016-04-16 00:50:28 +03:00
. misc = & amiga_misc_table ,
2014-01-15 23:37:05 +04:00
. window = & amiga_window_table ,
2014-01-16 18:43:48 +04:00
. clipboard = amiga_clipboard_table ,
2014-01-15 23:37:05 +04:00
. download = amiga_download_table ,
2014-01-23 03:19:57 +04:00
. fetch = & amiga_fetch_table ,
2014-05-27 02:43:36 +04:00
. file = amiga_file_table ,
2014-02-02 02:17:36 +04:00
. utf8 = amiga_utf8_table ,
2014-03-19 02:32:52 +04:00
. search = amiga_search_table ,
2014-05-25 03:57:48 +04:00
. search_web = & amiga_search_web_table ,
2015-04-01 00:48:27 +03:00
. llcache = filesystem_llcache_table ,
2015-04-17 00:36:29 +03:00
. bitmap = amiga_bitmap_table ,
2016-04-25 02:09:31 +03:00
. layout = ami_layout_table ,
2014-01-15 23:37:05 +04:00
} ;
2014-01-11 18:20:30 +04:00
2015-01-17 20:06:48 +03:00
# ifdef __amigaos4__
2014-07-05 12:36:43 +04:00
signal ( SIGINT , SIG_IGN ) ;
2015-01-17 20:06:48 +03:00
# endif
2014-05-10 13:22:10 +04:00
ret = netsurf_register ( & amiga_table ) ;
if ( ret ! = NSERROR_OK ) {
2014-11-11 00:59:51 +03:00
ami_misc_fatal_error ( " NetSurf operation table failed registration " ) ;
2014-11-10 21:56:09 +03:00
return RETURN_FAIL ;
2014-05-10 13:22:10 +04:00
}
2014-09-20 16:38:38 +04:00
/* initialise logging. Not fatal if it fails but not much we
* can do about it either .
*/
nslog_init ( NULL , & argc , argv ) ;
2014-11-09 02:48:48 +03:00
/* Need to do this before opening any splash windows etc... */
2014-11-09 03:05:44 +03:00
if ( ( ami_libs_open ( ) = = false ) ) {
2014-11-10 21:56:09 +03:00
return RETURN_FAIL ;
2014-11-09 03:05:44 +03:00
}
2014-11-09 02:48:48 +03:00
2014-09-20 16:38:38 +04:00
/* Open splash window */
Object * splash_window = ami_gui_splash_open ( ) ;
2016-11-27 18:31:18 +03:00
# ifndef __amigaos4__
/* OS3 low memory handler */
struct Interupt * memhandler = ami_memory_init ( ) ;
# endif
2016-12-11 19:16:11 +03:00
if ( ami_gui_resources_open ( ) = = false ) { /* alloc msgports, objects and other miscelleny */
2014-11-22 19:24:26 +03:00
ami_misc_fatal_error ( " Unable to allocate resources " ) ;
2015-11-25 02:22:15 +03:00
ami_gui_splash_close ( splash_window ) ;
ami_libs_close ( ) ;
2014-11-22 19:24:26 +03:00
return RETURN_FAIL ;
}
2016-12-11 19:04:16 +03:00
current_user = ami_gui_read_all_tooltypes ( argc , argv ) ;
2015-11-25 02:58:54 +03:00
struct RDArgs * args = ami_gui_commandline ( & argc , argv , & nargc , & nargv ) ;
2015-11-22 03:06:10 +03:00
2016-12-11 19:04:16 +03:00
current_user_dir = ami_gui_get_user_dir ( current_user ) ;
2015-11-22 03:06:10 +03:00
if ( current_user_dir = = NULL ) {
2016-12-11 19:16:11 +03:00
ami_gui_resources_free ( ) ;
2015-11-25 02:22:15 +03:00
ami_gui_splash_close ( splash_window ) ;
ami_libs_close ( ) ;
2015-11-22 03:06:10 +03:00
return RETURN_FAIL ;
}
2014-01-11 18:20:30 +04:00
ami_mime_init ( " PROGDIR:Resources/mimetypes " ) ;
sprintf ( temp , " %s/mimetypes.user " , current_user_dir ) ;
ami_mime_init ( temp ) ;
2015-01-19 23:08:45 +03:00
# ifdef __amigaos4__
2014-01-11 18:20:30 +04:00
amiga_plugin_hack_init ( ) ;
2016-01-18 03:02:52 +03:00
/* DataTypes loader needs datatypes.library v45,
* but for some reason that ' s not in OS3 .9 .
* Skip it to ensure it isn ' t causing other problems . */
2014-04-06 02:12:07 +04:00
ret = amiga_datatypes_init ( ) ;
2016-01-18 03:02:52 +03:00
# endif
2014-01-11 18:20:30 +04:00
/* user options setup */
ret = nsoption_init ( ami_set_options , & nsoptions , & nsoptions_default ) ;
if ( ret ! = NSERROR_OK ) {
2014-11-11 00:59:51 +03:00
ami_misc_fatal_error ( " Options failed to initialise " ) ;
2016-12-11 19:16:11 +03:00
ami_gui_resources_free ( ) ;
2015-11-25 02:22:15 +03:00
ami_gui_splash_close ( splash_window ) ;
ami_libs_close ( ) ;
2014-11-10 21:56:09 +03:00
return RETURN_FAIL ;
2014-01-11 18:20:30 +04:00
}
2016-07-09 03:07:18 +03:00
ami_nsoption_read ( ) ;
2015-11-25 02:58:54 +03:00
if ( args ! = NULL ) {
nsoption_commandline ( & nargc , & nargv , NULL ) ;
FreeArgs ( args ) ;
}
2014-01-11 18:20:30 +04:00
2014-11-10 21:56:09 +03:00
if ( ami_locate_resource ( messages , " Messages " ) = = false ) {
2014-11-11 00:59:51 +03:00
ami_misc_fatal_error ( " Cannot open Messages file " ) ;
2016-12-11 19:16:11 +03:00
ami_nsoption_free ( ) ;
2016-12-06 02:08:17 +03:00
nsoption_finalise ( nsoptions , nsoptions_default ) ;
2016-12-11 19:16:11 +03:00
ami_gui_resources_free ( ) ;
2015-11-25 02:22:15 +03:00
ami_gui_splash_close ( splash_window ) ;
ami_libs_close ( ) ;
2014-11-10 21:56:09 +03:00
return RETURN_FAIL ;
}
2015-06-19 18:29:42 +03:00
ret = messages_add_from_file ( messages ) ;
2016-12-11 19:04:16 +03:00
current_user_cache = ASPrintf ( " %s/Cache " , current_user_dir ) ;
if ( ( lock = CreateDirTree ( current_user_cache ) ) ) UnLock ( lock ) ;
2015-06-19 18:29:42 +03:00
ret = netsurf_init ( current_user_cache ) ;
2016-12-11 19:04:16 +03:00
if ( current_user_cache ! = NULL ) FreeVec ( current_user_cache ) ;
2014-01-11 18:20:30 +04:00
if ( ret ! = NSERROR_OK ) {
2014-11-11 00:59:51 +03:00
ami_misc_fatal_error ( " NetSurf failed to initialise " ) ;
2016-12-11 19:16:11 +03:00
ami_nsoption_free ( ) ;
2016-12-06 02:08:17 +03:00
nsoption_finalise ( nsoptions , nsoptions_default ) ;
2016-12-11 19:16:11 +03:00
ami_gui_resources_free ( ) ;
2015-11-25 02:22:15 +03:00
ami_gui_splash_close ( splash_window ) ;
ami_libs_close ( ) ;
2014-11-10 21:56:09 +03:00
return RETURN_FAIL ;
2014-01-11 18:20:30 +04:00
}
2014-04-06 02:12:07 +04:00
ret = amiga_icon_init ( ) ;
2014-01-11 18:20:30 +04:00
2014-05-25 13:26:34 +04:00
search_web_init ( nsoption_charp ( search_engines_file ) ) ;
2014-11-10 21:57:38 +03:00
ami_clipboard_init ( ) ;
ami_openurl_open ( ) ;
2014-11-10 22:01:30 +03:00
ami_amiupdate ( ) ; /* set env-vars for AmiUpdate */
2016-01-15 22:36:12 +03:00
ami_font_init ( ) ;
2014-11-10 22:01:30 +03:00
save_complete_init ( ) ;
ami_theme_init ( ) ;
ami_init_mouse_pointers ( ) ;
2014-11-22 19:24:26 +03:00
ami_file_req_init ( ) ;
2014-11-10 21:57:38 +03:00
win_destroyed = false ;
ami_font_setdevicedpi ( 0 ) ; /* for early font requests, eg treeview init */
window_list = NewObjList ( ) ;
urldb_load ( nsoption_charp ( url_file ) ) ;
urldb_load_cookies ( nsoption_charp ( cookie_file ) ) ;
2014-01-11 18:20:30 +04:00
gui_init2 ( argc , argv ) ;
2015-09-03 21:57:04 +03:00
ami_ctxmenu_init ( ) ; /* Requires screen pointer */
2014-01-11 18:20:30 +04:00
ami_gui_splash_close ( splash_window ) ;
strlcpy ( script , nsoption_charp ( arexx_dir ) , 1024 ) ;
AddPart ( script , nsoption_charp ( arexx_startup ) , 1024 ) ;
ami_arexx_execute ( script ) ;
2016-03-03 02:47:37 +03:00
LOG ( " Entering main loop " ) ;
2014-10-12 12:58:54 +04:00
while ( ! ami_quit ) {
ami_get_msg ( ) ;
}
2014-01-11 18:20:30 +04:00
strlcpy ( script , nsoption_charp ( arexx_dir ) , 1024 ) ;
AddPart ( script , nsoption_charp ( arexx_shutdown ) , 1024 ) ;
ami_arexx_execute ( script ) ;
ami_mime_free ( ) ;
2014-11-10 21:58:58 +03:00
netsurf_exit ( ) ;
2016-01-29 03:24:15 +03:00
2016-12-06 02:08:17 +03:00
nsoption_finalise ( nsoptions , nsoptions_default ) ;
2016-12-06 02:32:55 +03:00
ami_nsoption_free ( ) ;
2016-11-20 00:02:42 +03:00
free ( current_user_dir ) ;
2016-01-29 03:24:15 +03:00
FreeVec ( current_user_faviconcache ) ;
2016-11-27 18:31:18 +03:00
# ifndef __amigaos4__
/* OS3 low memory handler */
ami_memory_fini ( memhandler ) ;
# endif
2016-12-11 18:24:56 +03:00
ami_bitmap_fini ( ) ;
2016-01-29 03:24:15 +03:00
ami_libs_close ( ) ;
2014-11-10 21:58:58 +03:00
return RETURN_OK ;
2014-01-11 18:20:30 +04:00
}
2014-11-10 21:58:58 +03:00