AmigaOS tabs implementation.

Two new strings: NewTab, CloseTab

Two new options:
always_open_tabs indicates to open tabs instead of windows by default
new_tab_is_active makes any new tab the current one (default is to open tabs in
background)

svn path=/trunk/netsurf/; revision=5483
This commit is contained in:
Chris Young 2008-10-05 13:17:18 +00:00
parent bd94b12422
commit ec72e05bdc
9 changed files with 164 additions and 60 deletions

View File

@ -223,6 +223,8 @@ ImgStyle3:Error-Diffusion
#
Project:Project
NewWindowNS:New window
NewTab:New tab
CloseTab:Close tab
CloseWindow:Close window
SaveAs:Save as
Source:Source...

View File

@ -223,6 +223,8 @@ ImgStyle3:Error diffused
#
Project:Project
NewWindowNS:New window
NewTab:New tab
CloseTab:Close tab
CloseWindow:Close window
SaveAs:Save as
Source:Source...

View File

@ -223,6 +223,8 @@ ImgStyle3:Avec diffusion d'erreur
#
Project:Project
NewWindowNS:New window
NewTab:New tab
CloseTab:Close tab
CloseWindow:Close window
SaveAs:Save as
Source:Source...

View File

@ -223,6 +223,8 @@ ImgStyle3:Fout-spreiding
#
Project:Project
NewWindowNS:New window
NewTab:New tab
CloseTab:Close tab
CloseWindow:Close window
SaveAs:Save as
Source:Source...

View File

@ -551,17 +551,10 @@ void ami_handle_msg(void)
switch(result & WMHI_GADGETMASK) //gadaddr->GadgetID) //result & WMHI_GADGETMASK)
{
case GID_TABS:
GetAttr(CLICKTAB_CurrentNode,gwin->gadgets[GID_TABS],(ULONG *)&tabnode);
GetClickTabNodeAttrs(tabnode,
TNA_UserData,&gwin->bw,
TAG_DONE);
ami_switch_tab(gwin,true);
ami_update_buttons(gwin);
browser_window_update(gwin->bw,false);
gwin->redraw_required = true;
gwin->redraw_data = NULL;
// gwin->redraw_required = true;
// gwin->redraw_data = NULL;
break;
case GID_URL:
@ -920,6 +913,29 @@ void gui_poll(bool active)
}
}
void ami_switch_tab(struct gui_window_2 *gwin,bool redraw)
{
struct Node *tabnode;
if(gwin->tabs == 0) return;
GetAttr(CLICKTAB_CurrentNode,gwin->gadgets[GID_TABS],(ULONG *)&tabnode);
GetClickTabNodeAttrs(tabnode,
TNA_UserData,&gwin->bw,
TAG_DONE);
ami_update_buttons(gwin);
if(redraw)
{
browser_window_update(gwin->bw,false);
RefreshSetGadgetAttrs(gwin->gadgets[GID_URL],gwin->win,NULL,
STRINGA_TextVal,gwin->bw->current_content->url,
TAG_DONE);
}
}
void gui_quit(void)
{
int i;
@ -1012,6 +1028,16 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
char reload[100],reload_s[100],reload_g[100];
char home[100],home_s[100],home_g[100];
if(option_force_tabs && (bw->browser_window_type == BROWSER_WINDOW_NORMAL))
{
/* option_force_tabs reverses the new_tab parameter.
* We can still open new windows by setting new_tab to true.
*/
if(new_tab) new_tab = false;
else new_tab = true;
}
if(clone)
{
if(clone->window)
@ -1042,7 +1068,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
return NULL;
}
if(new_tab)
if(new_tab && clone && (bw->browser_window_type == BROWSER_WINDOW_NORMAL))
{
gwin->shared = clone->window->shared;
@ -1051,7 +1077,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
TAG_DONE);
gwin->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
TNA_Number,gwin->shared->tabs,
TNA_Number,gwin->shared->next_tab,
TNA_UserData,bw,
TAG_DONE);
@ -1063,9 +1089,19 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
CLICKTAB_Labels,&gwin->shared->tab_list,
TAG_DONE);
RethinkLayout(gwin->shared->gadgets[GID_MAIN],gwin->shared->win,NULL,TRUE);
if(option_new_tab_active)
{
RefreshSetGadgetAttrs(gwin->shared->gadgets[GID_TABS],gwin->shared->win,NULL,
CLICKTAB_Current,gwin->shared->next_tab,
TAG_DONE);
}
RethinkLayout(gwin->shared->gadgets[GID_TABLAYOUT],gwin->shared->win,NULL,TRUE);
gwin->shared->tabs++;
gwin->shared->next_tab++;
if(option_new_tab_active) ami_switch_tab(gwin->shared,false);
return gwin;
}
@ -1086,7 +1122,12 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
case BROWSER_WINDOW_IFRAME:
case BROWSER_WINDOW_FRAMESET:
case BROWSER_WINDOW_FRAME:
gwin->shared->objects[OID_MAIN] = WindowObject,
gwin->tab = 0;
gwin->shared->tabs = 0;
gwin->tab_node = NULL;
gwin->shared->objects[OID_MAIN] = WindowObject,
WA_ScreenTitle,nsscreentitle,
// WA_Title, messages_get("NetSurf"),
WA_Activate, FALSE,
@ -1103,7 +1144,7 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
WA_IDCMP,IDCMP_MENUPICK | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS |
IDCMP_NEWSIZE | IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE | IDCMP_INTUITICKS,
// WINDOW_IconifyGadget, TRUE,
WINDOW_NewMenu,menu,
// WINDOW_NewMenu,menu,
WINDOW_HorizProp,1,
WINDOW_VertProp,1,
WINDOW_IDCMPHook,&gwin->shared->scrollerhook,
@ -1130,17 +1171,17 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
break;
case BROWSER_WINDOW_NORMAL:
menu = ami_create_menu(bw->browser_window_type);
menu = ami_create_menu(bw->browser_window_type);
NewList(&gwin->shared->tab_list);
gwin->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
TNA_Number,0,
TNA_UserData,bw,
TAG_DONE);
AddTail(&gwin->shared->tab_list,gwin->tab_node);
NewList(&gwin->shared->tab_list);
gwin->tab_node = AllocClickTabNode(TNA_Text,messages_get("NetSurf"),
TNA_Number,0,
TNA_UserData,bw,
TAG_DONE);
AddTail(&gwin->shared->tab_list,gwin->tab_node);
gwin->shared->tabs=1;
gwin->shared->tabs=1;
gwin->shared->next_tab=1;
strcpy(nav_west,option_toolbar_images);
strcpy(nav_west_s,option_toolbar_images);
@ -1290,13 +1331,16 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
CHILD_WeightedHeight,0,
LayoutEnd,
CHILD_WeightedHeight,0,
LAYOUT_AddChild, gwin->shared->gadgets[GID_TABS] = ClickTabObject,
GA_ID,GID_TABS,
GA_RelVerify,TRUE,
CLICKTAB_Labels,&gwin->shared->tab_list,
CLICKTAB_LabelTruncate,TRUE,
ClickTabEnd,
CHILD_CacheDomain,FALSE,
LAYOUT_AddChild, gwin->shared->gadgets[GID_TABLAYOUT] = HGroupObject,
LAYOUT_AddChild, gwin->shared->gadgets[GID_TABS] = ClickTabObject,
GA_ID,GID_TABS,
GA_RelVerify,TRUE,
CLICKTAB_Labels,&gwin->shared->tab_list,
CLICKTAB_LabelTruncate,TRUE,
ClickTabEnd,
CHILD_CacheDomain,FALSE,
LayoutEnd,
CHILD_WeightedHeight,0,
LAYOUT_AddChild, gwin->shared->gadgets[GID_BROWSER] = SpaceObject,
GA_ID,GID_BROWSER,
SpaceEnd,
@ -1392,28 +1436,50 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
void gui_window_destroy(struct gui_window *g)
{
struct Node *ptab;
ULONG ptabnum;
if(!g) return;
if(g->shared->tabs > 1)
{
/* we need to remove the tab in question, but for the moment... */
SetGadgetAttrs(g->shared->gadgets[GID_TABS],g->shared->win,NULL,
CLICKTAB_Labels,~0,
TAG_DONE);
ptab = GetPred(g->tab_node);
if(!ptab) ptab = GetSucc(g->tab_node);
GetClickTabNodeAttrs(ptab,TNA_Number,(ULONG *)&ptabnum,TAG_DONE);
Remove(g->tab_node);
FreeClickTabNode(g->tab_node);
RefreshSetGadgetAttrs(g->shared->gadgets[GID_TABS],g->shared->win,NULL,
CLICKTAB_Labels,&g->shared->tab_list,
CLICKTAB_Current,ptabnum,
TAG_DONE);
RethinkLayout(g->shared->gadgets[GID_TABLAYOUT],g->shared->win,NULL,TRUE);
g->shared->tabs--;
win_destroyed = true;
ami_switch_tab(g->shared,true);
FreeVec(g);
return;
}
// DisposeDTObject(g->gadgets[GID_THROBBER]);
DisposeObject(g->shared->objects[OID_MAIN]);
DeleteLayer(0,g->shared->rp.Layer);
DisposeLayerInfo(g->shared->layerinfo);
// ami_tte_cleanup(&g->rp);
p96FreeBitMap(g->shared->bm);
FreeVec(g->shared->rp.TmpRas);
FreeVec(g->shared->rp.AreaInfo);
FreeVec(g->shared->tmprasbuf);
FreeVec(g->shared->areabuf);
DelObject(g->shared->node);
// FreeVec(g); should be freed by DelObject()
if(g->tab_node)
{
Remove(g->tab_node);
FreeClickTabNode(g->tab_node);
}
FreeVec(g); // g->shared should be freed by DelObject()
if(IsMinListEmpty(window_list))
{
@ -1427,7 +1493,7 @@ void gui_window_destroy(struct gui_window *g)
void gui_window_set_title(struct gui_window *g, const char *title)
{
struct Node *node;
WORD cur_tab;
ULONG cur_tab = 0;
if(!g) return;
if(g->tab_node)
@ -1441,7 +1507,7 @@ void gui_window_set_title(struct gui_window *g, const char *title)
RefreshSetGadgetAttrs(g->shared->gadgets[GID_TABS],g->shared->win,NULL,
CLICKTAB_Labels,&g->shared->tab_list,
TAG_DONE);
RethinkLayout(g->shared->gadgets[GID_MAIN],g->shared->win,NULL,TRUE);
RethinkLayout(g->shared->gadgets[GID_TABLAYOUT],g->shared->win,NULL,TRUE);
GetAttr(CLICKTAB_Current,g->shared->gadgets[GID_TABS],(ULONG *)&cur_tab);
}
@ -1867,9 +1933,16 @@ void ami_init_mouse_pointers(void)
void gui_window_set_url(struct gui_window *g, const char *url)
{
ULONG cur_tab = 0;
if(!g) return;
RefreshSetGadgetAttrs(g->shared->gadgets[GID_URL],g->shared->win,NULL,STRINGA_TextVal,url,TAG_DONE);
if(g->tab_node) GetAttr(CLICKTAB_Current,g->shared->gadgets[GID_TABS],(ULONG *)&cur_tab);
if((cur_tab == g->tab) || (g->shared->tabs == 0))
{
RefreshSetGadgetAttrs(g->shared->gadgets[GID_URL],g->shared->win,NULL,STRINGA_TextVal,url,TAG_DONE);
}
}
void gui_window_start_throbber(struct gui_window *g)

View File

@ -38,6 +38,7 @@
enum
{
GID_MAIN=0,
GID_TABLAYOUT,
GID_BROWSER,
GID_STATUS,
GID_URL,
@ -86,7 +87,8 @@ struct gui_window_2 {
int throbber_frame;
int c_h;
struct List tab_list;
int tabs;
ULONG tabs;
ULONG next_tab;
struct BitMap *bm;
struct RastPort rp;
struct Layer_Info *layerinfo;

View File

@ -22,7 +22,7 @@
#include "amiga/utf8.h"
#include <libraries/gadtools.h>
#include <proto/asl.h>
#include "desktop/options.h"
#include "amiga/options.h"
#include "desktop/gui.h"
#include "amiga/hotlist.h"
#include <proto/dos.h>
@ -54,18 +54,19 @@ void ami_init_menulabs(void)
menulab[6] = ami_utf8_easy((char *)messages_get("TextNS"));
menulab[7] = ami_utf8_easy((char *)messages_get("PDF"));
menulab[8] = NM_BARLABEL;
menulab[9] = ami_utf8_easy((char *)messages_get("CloseWindow"));
menulab[10] = ami_utf8_easy((char *)messages_get("Edit"));
menulab[11] = ami_utf8_easy((char *)messages_get("CopyNS"));
menulab[12] = ami_utf8_easy((char *)messages_get("Paste"));
menulab[13] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
menulab[14] = ami_utf8_easy((char *)messages_get("ClearNS"));
menulab[15] = ami_utf8_easy((char *)messages_get("Hotlist"));
menulab[16] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
menulab[17] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
menulab[18] = ami_utf8_easy((char *)messages_get("Settings"));
menulab[19] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
menulab[20] = ami_utf8_easy((char *)messages_get("SettingsSave"));
menulab[9] = ami_utf8_easy((char *)messages_get("CloseTab"));
menulab[10] = ami_utf8_easy((char *)messages_get("CloseWindow"));
menulab[11] = ami_utf8_easy((char *)messages_get("Edit"));
menulab[12] = ami_utf8_easy((char *)messages_get("CopyNS"));
menulab[13] = ami_utf8_easy((char *)messages_get("Paste"));
menulab[14] = ami_utf8_easy((char *)messages_get("SelectAllNS"));
menulab[15] = ami_utf8_easy((char *)messages_get("ClearNS"));
menulab[16] = ami_utf8_easy((char *)messages_get("Hotlist"));
menulab[17] = ami_utf8_easy((char *)messages_get("HotlistAdd"));
menulab[18] = ami_utf8_easy((char *)messages_get("HotlistShowNS"));
menulab[19] = ami_utf8_easy((char *)messages_get("Settings"));
menulab[20] = ami_utf8_easy((char *)messages_get("SnapshotWindow"));
menulab[21] = ami_utf8_easy((char *)messages_get("SettingsSave"));
}
struct NewMenu *ami_create_menu(ULONG type)
@ -82,7 +83,8 @@ struct NewMenu *ami_create_menu(ULONG type)
{ NM_SUB,0,0,0,0,0,}, // save as text
{ NM_SUB,0,0,0,0,0,}, // save as pdf
{ NM_ITEM,NM_BARLABEL,0,0,0,0,},
{ NM_ITEM,0,"K",0,0,0,}, // close window
{ NM_ITEM,0,"K",0,0,0,}, // close tab
{ NM_ITEM,0,0,0,0,0,}, // close window
{NM_TITLE,0,0,0,0,0,}, // edit
{ NM_ITEM,0,"C",0,0,0,}, // copy
{ NM_ITEM,0,"V",0,0,0,}, // paste
@ -110,6 +112,7 @@ struct NewMenu *ami_create_menu(ULONG type)
menu[1].nm_Flags = menuflags;
menu[2].nm_Flags = menuflags;
menu[9].nm_Flags = menuflags;
menu[10].nm_Flags = menuflags;
#ifndef WITH_PDF_EXPORT
menu[7].nm_Flags = NM_ITEMDISABLED;
@ -120,11 +123,20 @@ struct NewMenu *ami_create_menu(ULONG type)
void ami_menupick(ULONG code,struct gui_window_2 *gwin)
{
struct browser_window *bw;
struct gui_window tgw;
ULONG menunum=0,itemnum=0,subnum=0;
menunum = MENUNUM(code);
itemnum = ITEMNUM(code);
subnum = SUBNUM(code);
bool openwin=false;
bool opentab=true;
if(option_force_tabs)
{
openwin=true;
opentab=false;
}
tgw.tab_node = NULL;
tgw.tab = 0;
@ -135,13 +147,12 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin)
case 0: // project
switch(itemnum)
{
struct browser_window *bw;
case 0: // new window
bw = browser_window_create(gwin->bw->current_content->url,gwin->bw, 0, true, false);
bw = browser_window_create(gwin->bw->current_content->url,gwin->bw, 0, true, openwin);
break;
case 1: // new tab
bw = browser_window_create(gwin->bw->current_content->url,gwin->bw, 0, true, true);
bw = browser_window_create(gwin->bw->current_content->url,gwin->bw, 0, true, opentab);
break;
case 3: // save
@ -210,7 +221,11 @@ void ami_menupick(ULONG code,struct gui_window_2 *gwin)
}
break;
case 5: // close
case 5: // close tab
browser_window_destroy(gwin->bw);
break;
case 6: // close window
browser_window_destroy(gwin->bw);
break;
}

View File

@ -21,7 +21,7 @@
#include <exec/types.h>
#include "amiga/gui.h"
#define AMI_MENU_MAX 20
#define AMI_MENU_MAX 21
char *menulab[AMI_MENU_MAX+1];
struct NewMenu *ami_create_menu(ULONG type);

View File

@ -31,6 +31,8 @@ extern bool option_utf8_clipboard;
extern int option_throbber_frames;
extern bool option_truecolour_mouse_pointers;
extern bool option_use_os_pointers;
extern bool option_force_tabs;
extern bool option_new_tab_active;
#define EXTRA_OPTION_DEFINE \
bool option_verbose_log = false; \
@ -44,6 +46,8 @@ bool option_utf8_clipboard = false; \
int option_throbber_frames = 1; \
bool option_truecolour_mouse_pointers = true; \
bool option_use_os_pointers = false; \
bool option_force_tabs = false; \
bool option_new_tab_active = false; \
#define EXTRA_OPTION_TABLE \
{ "verbose_log", OPTION_BOOL, &option_verbose_log}, \
@ -56,5 +60,7 @@ bool option_use_os_pointers = false; \
{ "clipboard_write_utf8", OPTION_BOOL, &option_utf8_clipboard}, \
{ "throbber_frames", OPTION_INTEGER, &option_throbber_frames}, \
{ "truecolour_mouse_pointers", OPTION_BOOL, &option_truecolour_mouse_pointers}, \
{ "os_mouse_pointers", OPTION_BOOL, &option_use_os_pointers},
{ "os_mouse_pointers", OPTION_BOOL, &option_use_os_pointers}, \
{ "always_open_tabs", OPTION_BOOL, &option_force_tabs}, \
{ "new_tab_is_active", OPTION_BOOL, &option_new_tab_active},
#endif