Make all the buttons on the first two options tabs work.

May need to improve theme selection so it at least checks it is a valid theme and/or
provide a list of themes instead of a file requester.
Language selection could benefit from also having a drop-down chooser gadget too.

svn path=/trunk/netsurf/; revision=7910
This commit is contained in:
Chris Young 2009-06-21 22:12:52 +00:00
parent fa976f3aed
commit ec2dba8579
3 changed files with 109 additions and 22 deletions

View File

@ -181,10 +181,48 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw);
static void *myrealloc(void *ptr, size_t len, void *pw);
void ami_init_layers(struct RastPort *rp);
STRPTR ami_locale_langs(void)
{
struct Locale *locale;
STRPTR acceptlangs = NULL, acceptlangs2 = NULL;
int i;
if(locale = OpenLocale(NULL))
{
for(i=0;i<10;i++)
{
if(locale->loc_PrefLanguages[i])
{
if(messages_get(locale->loc_PrefLanguages[i]) != locale->loc_PrefLanguages[i])
{
if(acceptlangs)
{
acceptlangs2 = acceptlangs;
acceptlangs = ASPrintf("%s, %s",acceptlangs2,messages_get(locale->loc_PrefLanguages[i]));
FreeVec(acceptlangs2);
acceptlangs2 = NULL;
}
else
{
acceptlangs = ASPrintf("%s",messages_get(locale->loc_PrefLanguages[i]));
}
}
}
else
{
continue;
}
}
CloseLocale(locale);
}
return acceptlangs;
}
void gui_init(int argc, char** argv)
{
struct Locale *locale;
char lang[100],throbberfile[100],tempacceptlangs[100] = "\0";
char lang[100],throbberfile[100];
STRPTR tempacceptlangs;
bool found=FALSE;
int i;
BPTR lock=0,amiupdatefh;
@ -274,25 +312,6 @@ void gui_init(int argc, char** argv)
strcpy(lang,"PROGDIR:Resources/en/Messages");
}
for(i=0;i<10;i++)
{
if(locale->loc_PrefLanguages[i])
{
if(messages_get(locale->loc_PrefLanguages[i]) != locale->loc_PrefLanguages[i])
{
if(tempacceptlangs[0] != '\0')
{
strcat(tempacceptlangs,", ");
}
strcat(tempacceptlangs,messages_get(locale->loc_PrefLanguages[i]));
}
}
else
{
continue;
}
}
CloseLocale(locale);
messages_load(lang);
@ -311,7 +330,13 @@ void gui_init(int argc, char** argv)
css_scrollbar_arrow_colour = 0x00d6d6d6;
if((!option_accept_language) || (option_accept_language[0] == '\0'))
{
if(tempacceptlangs = ami_locale_langs())
{
option_accept_language = (char *)strdup(tempacceptlangs);
FreeVec(tempacceptlangs);
}
}
if((!option_cookie_file) || (option_cookie_file[0] == '\0'))
option_cookie_file = (char *)strdup("PROGDIR:Resources/Cookies");

View File

@ -136,6 +136,7 @@ void ami_quit_netsurf(void);
void ami_get_theme_filename(char *filename,char *themestring);
void ami_clearclipreg(struct RastPort *rp);
void ami_do_redraw(struct gui_window_2 *g);
STRPTR ami_locale_langs(void);
struct RastPort *currp;
struct TextFont *origrpfont;

View File

@ -274,6 +274,7 @@ void ami_gui_opts_open(void)
GETFILE_Drawer, option_theme,
GETFILE_DrawersOnly, TRUE,
GETFILE_ReadOnly, TRUE,
GETFILE_FullFileExpand, FALSE,
GetFileEnd,
LayoutEnd, // theme
CHILD_WeightedHeight, 0,
@ -443,8 +444,9 @@ void ami_gui_opts_close(void)
BOOL ami_gui_opts_event(void)
{
/* return TRUE if window destroyed */
ULONG result;
ULONG result,data;
uint16 code;
STRPTR text;
while((result = RA_HandleInput(gow->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
{
@ -468,9 +470,68 @@ BOOL ami_gui_opts_event(void)
ami_gui_opts_close();
return TRUE;
break;
case GID_OPTS_HOMEPAGE_DEFAULT:
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_HOMEPAGE],
gow->win,NULL,STRINGA_TextVal,NETSURF_HOMEPAGE,
TAG_DONE);
break;
case GID_OPTS_HOMEPAGE_CURRENT:
if(curbw) RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_HOMEPAGE],
gow->win,NULL,STRINGA_TextVal,
curbw->current_content->url,TAG_DONE);
break;
case GID_OPTS_FROMLOCALE:
if(text = ami_locale_langs())
{
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_CONTENTLANG],
gow->win,NULL,STRINGA_TextVal, text, TAG_DONE);
FreeVec(text);
}
break;
case GID_OPTS_SCREEN:
GetAttr(RADIOBUTTON_Selected,gow->gadgets[GID_OPTS_SCREEN],(ULONG *)&data);
switch(data)
{
case 0:
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_SCREENMODE],
gow->win,NULL, GA_Disabled, FALSE, TAG_DONE);
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_SCREENNAME],
gow->win,NULL, GA_Disabled, TRUE, TAG_DONE);
break;
case 1:
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_SCREENMODE],
gow->win,NULL, GA_Disabled, TRUE, TAG_DONE);
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_SCREENNAME],
gow->win,NULL, GA_Disabled, TRUE, TAG_DONE);
break;
case 2:
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_SCREENMODE],
gow->win,NULL, GA_Disabled, TRUE, TAG_DONE);
RefreshSetGadgetAttrs(gow->gadgets[GID_OPTS_SCREENNAME],
gow->win,NULL, GA_Disabled, FALSE, TAG_DONE);
break;
}
break;
case GID_OPTS_SCREENMODE:
IDoMethod((Object *)gow->gadgets[GID_OPTS_SCREENMODE],
GSM_REQUEST,gow->win);
break;
case GID_OPTS_THEME:
IDoMethod((Object *)gow->gadgets[GID_OPTS_THEME],
GFILE_REQUEST,gow->win);
break;
}
break;
}
}
return FALSE;
}