1 /***************************************************************
2 **** JanoPrefs.c: Configuration window for JanoEditor ****
3 **** Free software under GNU license, started on 11/11/2000 ****
4 **** © T.Pierron, C.Guillaume. ****
5 ***************************************************************/
7 #define ASL_V38_NAMES_ONLY
8 #include <intuition/intuition.h>
9 #include <intuition/intuitionbase.h>
10 #include <libraries/gadtools.h>
11 #include <libraries/asl.h>
12 #include <libraries/dos.h>
13 #include <graphics/gfxbase.h>
14 #include <graphics/modeid.h>
16 #include <proto/exec.h>
17 #include <proto/dos.h>
18 #include <proto/graphics.h>
19 #include <proto/intuition.h>
20 #include <proto/gadtools.h>
21 #include <proto/asl.h>
28 #include "JanoPrefs.h"
29 #include "IPC_Prefs.h"
32 #define CATCOMP_NUMBERS
37 #define LocaleInfo LocaleInfoTmp /* Avoid redefinition :-( */
38 #include "../../tools/Edit/strings.h"
40 /* Shared libraires we'll need to open */
41 struct IntuitionBase
*IntuitionBase
= NULL
;
42 struct GfxBase
*GfxBase
= NULL
;
43 struct Library
*GadToolsBase
= NULL
;
44 struct Library
*AslBase
= NULL
;
45 struct Library
*LocaleBase
= NULL
;
46 struct Library
*DiskfontBase
= NULL
;
47 struct Library
*LayersBase
= NULL
;
49 struct IntuiMessage
*msg
, msgbuf
;
50 struct NewWindow NewPrefWin
=
52 0,0,0,0, 1,1, /* LE,TE,Wid,Hei, Pens */
53 IDCMP_MENUPICK
| IDCMP_CLOSEWINDOW
| IDCMP_GADGETUP
| IDCMP_NEWSIZE
| IDCMP_VANILLAKEY
,
54 WFLG_CLOSEGADGET
| WFLG_NEWLOOKMENUS
| WFLG_DEPTHGADGET
| WFLG_ACTIVATE
| WFLG_SMART_REFRESH
|
56 NULL
, /* FirstGadget */
61 100, 50, 0xffff, 0xffff, /* Min & Max size */
65 /** Standard GUI ressource **/
66 struct Screen
*Scr
= NULL
; /* Screen where window opens */
67 struct Window
*Wnd
= NULL
; /* Pointer to the opened window */
68 void *Vi
= NULL
; /* Visual Info for gadget */
69 struct Menu
*Menu
= NULL
; /* Menu of interface */
70 struct TextFont
*font
; /* Font used for gadgets */
71 struct RastPort RPT
; /* Font measurement */
76 /* Tag list for various gadget */
77 struct TagItem IntTags
[] = { /*{GTIN_Number, 0},*/ {GTST_MaxChars
,2}, {TAG_DONE
}};
78 struct TagItem SepTags
[] = {{GTST_MaxChars
, MAX_SPLIT
}, {TAG_DONE
}};
79 struct TagItem TextFontTags
[] = {{GTCY_Labels
, (IPTR
)FTCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
80 struct TagItem ScrFontTags
[] = {{GTCY_Labels
, (IPTR
)FSCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
81 struct TagItem ScrMdTags
[] = {{GTCY_Labels
, (IPTR
)ScrCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
82 struct TagItem ColorTags
[] = {{GTCY_Labels
, (IPTR
)ColCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
83 struct TagItem MenuTags
[] = {{GTMN_FrontPen
, 1L}, {TAG_DONE
}};
85 struct TagItem
*GadTags
[] = {IntTags
, SepTags
, TextFontTags
, ScrFontTags
, ScrMdTags
};
87 /* Tag list for opening the main window */
89 struct TagItem PrefTags
[] = {
90 {WA_Zoom
,(IPTR
)PrefZoom
},
91 {WA_NewLookMenus
,TRUE
},
95 struct NewGadget NG
; /* To create the gadgets */
96 struct Gadget
*pgads
=NULL
; /* Gadtool's gadgets */
97 struct Gadget
*gads
[CBS
+CGS
];
98 extern PREFS prefs
; /* Preference buffer */
99 extern UBYTE Modif
[]; /* Buffer for string's gadget */
100 ULONG prefsigbit
, msgport
; /* Signal bits for asynchronous messages collect */
101 ULONG extended
; /* Extended cycle gadgets */
102 UBYTE ConfigFile
= TRUE
; /* TRUE is a config file is edited */
103 UBYTE ColorIndex
= 0; /* Color index to change */
104 UBYTE StrInfo
[60]; /* Screen/font description */
105 WORD wid
[5]; /* Width of various strings */
107 /*** Display an error message in the window's title ***/
108 static UBYTE
*Title
= NULL
;
109 static ULONG err_time
;
110 void ThrowError(struct Window
*W
, UBYTE
*Msg
)
115 Title
= (W
->Flags
& WFLG_BACKDROP
? W
->WScreen
->Title
: W
->Title
);
116 /* If window is backdrop'ed, change screen's title instead of window */
117 if(W
->Flags
& WFLG_BACKDROP
) SetWindowTitles(W
,(STRPTR
)-1,Msg
);
118 else SetWindowTitles(W
,Msg
,(STRPTR
)-1);
120 DisplayBeep(W
->WScreen
);
122 /* To be sure that mesage will be disappear one day */
123 ModifyIDCMP(W
,W
->IDCMPFlags
| IDCMP_INTUITICKS
);
127 /*** Show messages associated with IoErr() number ***/
128 void ThrowDOSError(struct Window
*W
, STRPTR Prefix
, UBYTE err
)
130 static UBYTE Message
[100];
132 /* Get standard DOS error message */
133 Fault(err
, Prefix
, Message
, sizeof(Message
));
135 ThrowError(W
, Message
);
138 /*** Reset the old title ***/
139 void StopError(struct Window
*W
)
141 if(W
->Flags
& WFLG_BACKDROP
) SetWindowTitles(W
,(STRPTR
)-1,Title
);
142 else SetWindowTitles(W
,Title
,(STRPTR
)-1);
144 /* INTUITICKS aren't required anymore */
145 ModifyIDCMP(W
,W
->IDCMPFlags
& ~IDCMP_INTUITICKS
);
148 /*** Try to open configuration window, return 1 if all's ok ***/
149 BYTE
setup_guipref( void )
154 /** Look if window isn't already open, thus just activate it **/
158 /* Uniconified it, if it is */
159 if(Wnd
->Height
<=Wnd
->BorderTop
) ZipWindow(Wnd
);
164 /** Visual info pointer **/
165 if(Vi
== NULL
&& !(Vi
= (void *) GetVisualInfoA(Scr
,NULL
))) return 0;
167 /** Init missing strings **/
168 CopyMem(FTCycTxt
,FSCycTxt
,sizeof(FSCycTxt
));
169 CopyMem(FTCycTxt
+1,ScrCycTxt
+2,sizeof(UBYTE
*)*2);
171 FSCycTxt
[0]=StrInfo
+20;
172 ScrCycTxt
[0]=StrInfo
+40;
173 /** Init temporary rastport, for font measurement **/
175 SetFont(&RPT
, font
= Scr
->RastPort
.Font
);
177 /** Compute window width and height **/
178 wid
[0] = meas_table(MiscTxt
);
179 wid
[1] = meas_table(ChkTxt
);
180 wid
[2] = meas_table(OkCanSav
)+20;
181 wid
[3] = meas_table(FSCycTxt
);
182 wid
[4] = meas_table(ColCycTxt
);
183 width
= meas_table(ScrCycTxt
);
184 if(wid
[3] < width
) wid
[3] = width
;
186 NewPrefWin
.Width
= wid
[0] + wid
[3] + wid
[1] + 130;
187 NewPrefWin
.Height
= Scr
->BarHeight
+ font
->tf_YSize
* 8 + (59 + SAMPLE_HEI
);
188 NewPrefWin
.LeftEdge
= 50;
189 NewPrefWin
.TopEdge
= 50;
190 NewPrefWin
.Screen
= Scr
;
191 NewPrefWin
.Title
= (ConfigFile
? Path
: PrefMsg
[0]);
193 /** Does it fit in the screen ? **/
194 fit_in_screen(&NewPrefWin
, Scr
);
196 /** Compute the iconified window dimensions: **/
197 PrefZoom
[2] = TextLength(&RPT
,NewPrefWin
.Title
,strlen(NewPrefWin
.Title
))+100;
198 if(prefs
.use_pub
) PrefZoom
[0] = Scr
->Width
-PrefZoom
[2]-15, PrefZoom
[1] = 0;
199 else PrefZoom
[0] = PrefZoom
[1] = 50;
200 PrefZoom
[3] = Scr
->WBorTop
+ Scr
->Font
->ta_YSize
+ 1;
202 /** Setup inital tags: **/
203 ScrFontTags
[1].ti_Data
= 0;
204 ScrMdTags
[1].ti_Data
= 0;
205 TextFontTags
[1].ti_Data
= 0;
208 if( prefs
.use_txtfont
)
209 font_info(StrInfo
, prefs
.txtfont
),
210 TextFontTags
[0].ti_Data
= (IPTR
) FTCycTxt
, extended
|= 1;
212 TextFontTags
[0].ti_Data
= (IPTR
) (FTCycTxt
+1);
214 if( prefs
.use_scrfont
)
215 font_info(StrInfo
+20, prefs
.scrfont
),
216 ScrFontTags
[0].ti_Data
= (IPTR
) FSCycTxt
, extended
|= 2;
218 ScrFontTags
[0].ti_Data
= (IPTR
) (FSCycTxt
+1);
220 if( prefs
.use_pub
==1 )
221 scr_info(StrInfo
+40,Scr
->Width
, Scr
->Height
, Scr
->RastPort
.BitMap
->Depth
),
222 ScrMdTags
[0].ti_Data
= (IPTR
) ScrCycTxt
, extended
|= 4;
224 ScrMdTags
[0].ti_Data
= (IPTR
) (ScrCycTxt
+1);
225 if(prefs
.use_pub
!=2) ScrMdTags
[1].ti_Data
= 1; /* Clone */
227 /* Checkbox states */
228 CopyMem(&prefs
.backdrop
, CB_state
, CBS
);
230 /* If it isn't the frontmost screen */
231 if(Scr
!= IntuitionBase
->ActiveScreen
) ScreenToFront(Scr
);
234 if(NULL
== (Menu
= (void *) CreateMenusA(newmenu
, MenuTags
)) ||
235 0 == LayoutMenus(Menu
, Vi
, GTMN_TextAttr
, Scr
->Font
, TAG_DONE
)) return FALSE
;
237 /** Try to open the window **/
238 if(( Wnd
= (struct Window
*) OpenWindowTagList(&NewPrefWin
,PrefTags
) ))
240 struct Gadget
**pg
= gads
, *gad
;
242 gad
= (struct Gadget
*) CreateContext(&pgads
);
243 NG
.ng_TopEdge
= Wnd
->BorderTop
+5;
244 NG
.ng_Width
= wid
[3]+40;
245 NG
.ng_LeftEdge
= wid
[0]+20;
246 NG
.ng_Height
= font
->tf_YSize
+6;
247 NG
.ng_Flags
= PLACETEXT_LEFT
| NG_HIGHLABEL
;
248 NG
.ng_TextAttr
= Scr
->Font
;
249 NG
.ng_VisualInfo
= Vi
;
251 /* Create left column of gadgets */
252 for(i
=0; i
<CGS
; i
++, NG
.ng_TopEdge
+=NG
.ng_Height
, *pg
++ = gad
)
256 NG
.ng_GadgetText
= MiscTxt
[i
];
271 gad
= (void *) CreateGadgetA(kind
, gad
, &NG
, GadTags
[i
]);
272 if(i
==0) AddNum (prefs
.tabsize
, GetSI(gad
)->Buffer
);
273 if(i
==1) CopyMem(prefs
.wordssep
, GetSI(gad
)->Buffer
, MAX_SPLIT
);
276 /* Create right column of gads */
277 NG
.ng_TopEdge
= Wnd
->BorderTop
+5;
278 NG
.ng_LeftEdge
+= NG
.ng_Width
+20;
279 NG
.ng_Width
= (NG
.ng_Height
-= 2);
280 NG
.ng_Flags
= PLACETEXT_RIGHT
;
281 for(; i
<CGS
+CBS
; i
++, NG
.ng_TopEdge
+=NG
.ng_Height
, *pg
++ = gad
)
283 NG
.ng_GadgetText
= ChkTxt
[i
-CGS
];
285 gad
= (void *) CreateGadget(CHECKBOX_KIND
, gad
, &NG
, GTCB_Checked
, CB_state
[i
-CGS
], TAG_DONE
);
286 if(i
== CGS
&& prefs
.use_pub
== 0)
287 gad
->Flags
|= GFLG_DISABLED
;
290 /* Create bottom row of gadgets */
291 NG
.ng_TopEdge
= Wnd
->Height
-NG
.ng_Height
-10;
293 NG
.ng_Width
= wid
[2];
294 NG
.ng_Flags
= PLACETEXT_IN
;
295 width
= (Wnd
->Width
-20-wid
[2]) >> 1;
296 for(; i
<UCS
+3; i
++, NG
.ng_LeftEdge
+=width
)
298 NG
.ng_GadgetText
= OkCanSav
[i
-UCS
];
300 gad
= (void *) CreateGadgetA(BUTTON_KIND
, gad
, &NG
, NULL
);
303 /* Initiate sample editor to see colors adjustement */
304 init_sample(Wnd
, &prefs
, NG
.ng_TopEdge
-= 5 + SAMPLE_HEI
);
306 /* Cycle color chooser */
307 NG
.ng_TopEdge
-= NG
.ng_Height
+3;
308 NG
.ng_Width
= wid
[4]+40;
309 NG
.ng_GadgetText
= NULL
;
312 gad
= (void *) CreateGadgetA(CYCLE_KIND
, gad
, &NG
, ColorTags
);
314 /* Palette chooser */
315 NG
.ng_Width
= Wnd
->Width
- 10 - (
316 NG
.ng_LeftEdge
+= NG
.ng_Width
+10);
317 NG
.ng_GadgetID
= i
+1;
318 CreateGadget(PALETTE_KIND
,
321 GTPA_Depth
, ((Scr
->RastPort
.BitMap
->Depth
> 5) ? 5 : Scr
->RastPort
.BitMap
->Depth
),
324 /* Add gadgets to window: */
325 CopyMem(Wnd
->RPort
, &RPT
, sizeof(RPT
));
326 SetFont(&RPT
, prefs
.scrfont
);
327 render_sample(Wnd
, EDIT_ALL
);
328 AddGList( Wnd
, pgads
, -1, -1, NULL
);
329 RefreshGList(pgads
, Wnd
, NULL
, -1);
330 SetMenuStrip( Wnd
, Menu
);
331 GT_RefreshWindow(Wnd
, NULL
);
333 /* Add window's signal bit: */
334 prefsigbit
= 1 << Wnd
->UserPort
->mp_SigBit
;
340 /*** Close the preference window ***/
341 void close_prefwnd( BYTE cmd
)
345 if( Menu
) ClearMenuStrip(Wnd
);
347 prefsigbit
=0; Wnd
=NULL
;
350 /* Flush content of some gadget that may not be confirmed */
351 prefs
.tabsize
= atoi(GetSI(gads
[0])->Buffer
);
352 CopyMem(GetSI(gads
[1])->Buffer
, prefs
.wordssep
, MAX_SPLIT
);
354 FreeGadgets(pgads
); pgads
=NULL
;
357 if(Menu
) FreeMenus(Menu
),Menu
=NULL
;
359 /* Do we need to send modifications to JANO? */
360 if( cmd
&& !ConfigFile
) send_jano(&prefs
, cmd
);
363 /*** Handle messages coming from gadgets ***/
364 BYTE
handle_pref_gadget(struct Gadget
*G
)
366 struct TextFont
*newfont
;
367 static UBYTE useit
[]={1,2,0,1};
370 switch( G
->GadgetID
)
372 case 0: /* Check tabulation: */
375 case 2: /* Changing default text font: */
377 Code
= msgbuf
.Code
; if(extended
& 1) Code
--;
380 if( !(prefs
.use_txtfont
= (Code
==-1)) )
381 /* User want to use the default text font: */
382 text_to_attr(prefs
.txtfont
=GfxBase
->DefaultFont
, &prefs
.attrtxt
);
384 if((newfont
= get_old_font(FTCycTxt
[0])))
385 text_to_attr(prefs
.txtfont
=newfont
, &prefs
.attrtxt
);
386 else { ThrowError(Wnd
, ErrMsg(ERR_LOADFONT
)); break; }
387 render_sample(Wnd
, EDIT_AREA
);
390 /* User want to change the text font: */
391 if((newfont
= change_fonts(&prefs
.attrtxt
, Wnd
, TRUE
)))
393 if( prefs
.txtfont
) CloseFont(prefs
.txtfont
);
394 font_info(StrInfo
, prefs
.txtfont
= newfont
);
395 TextFontTags
[0].ti_Data
= (IPTR
) FTCycTxt
; extended
|= 1;
396 prefs
.use_txtfont
= TRUE
;
397 TextFontTags
[1].ti_Data
= 0;
398 } /* else we must reset the original cycle gadget entry */
399 GT_SetGadgetAttrsA(G
, Wnd
, NULL
, TextFontTags
);
400 render_sample(Wnd
, EDIT_AREA
);
402 case 3: /* Changing default screen font */
404 Code
= msgbuf
.Code
; if(extended
& 2) Code
--;
407 if( !(prefs
.use_scrfont
= (Code
==-1)) )
408 /* User want to use default screen font */
409 text_to_attr(prefs
.scrfont
=prefs
.parent
->RastPort
.Font
, &prefs
.attrscr
);
411 if((newfont
= get_old_font(FSCycTxt
[0])))
412 text_to_attr(prefs
.scrfont
=newfont
, &prefs
.attrscr
);
413 else { ThrowError(Wnd
, ErrMsg(ERR_LOADFONT
)); break; }
415 render_sample(Wnd
, EDIT_ALL
);
418 /* User want to change the screen font */
419 if((newfont
= change_fonts(&prefs
.attrscr
, Wnd
, FALSE
)))
421 if( prefs
.scrfont
) CloseFont(prefs
.scrfont
);
422 font_info(StrInfo
+20, prefs
.scrfont
= newfont
);
423 ScrFontTags
[0].ti_Data
= (IPTR
) FSCycTxt
; extended
|= 2;
424 prefs
.use_scrfont
= TRUE
;
425 ScrFontTags
[1].ti_Data
= 0;
427 GT_SetGadgetAttrsA(G
, Wnd
, NULL
, ScrFontTags
);
428 render_sample(Wnd
, EDIT_ALL
);
430 case 4: /* Change screen mode/type */
432 Code
= msgbuf
.Code
; if(extended
& 4) Code
--;
434 prefs
.use_pub
= useit
[Code
+1];
437 /* User want to use a pubscreen instead of workbench screen: */
438 if((Code
= change_screen_mode(wid
, prefs
.modeid
)) != INVALID_ID
)
440 prefs
.depth
= wid
[2];
442 ScrMdTags
[0].ti_Data
= (IPTR
) ScrCycTxt
;
443 ScrMdTags
[1].ti_Data
= 0;
444 scr_info(StrInfo
+40, wid
[0], wid
[1], wid
[2]);
445 prefs
.use_pub
= TRUE
; extended
|= 4;
446 } else ScrMdTags
[1].ti_Data
= useit
[ prefs
.use_pub
+1 ];
447 GT_SetGadgetAttrsA(G
, Wnd
, NULL
, ScrMdTags
);
449 /* If user want to use a pubscreen, then disable backdrop checkbox **
450 ** It is not recommended to use a backdrop'ed window on a such scr */
452 OnGadget (gads
[CGS
], Wnd
, NULL
);
454 OffGadget (gads
[CGS
], Wnd
, NULL
);
456 case CGS
: case CGS
+1: /* Checkbuttons */
457 case CGS
+2: case CGS
+3:
458 (&prefs
.backdrop
)[G
->GadgetID
-CGS
] = ((G
->Flags
& GFLG_SELECTED
) == GFLG_SELECTED
);
461 close_prefwnd(CMD_SAVPREF
);
462 if(ConfigFile
) save_prefs(&prefs
);
464 case UCS
+1: /* Use */
465 close_prefwnd(CMD_NEWPREF
); return TRUE
;
466 case UCS
+2: /* Cancel */
467 close_prefwnd(0); return TRUE
;
468 case UCS
+3: /* Cycle color */
469 ColorIndex
= msgbuf
.Code
; break;
470 case UCS
+4: /* Palette */
471 if((&pen
.bg
)[ ColorIndex
] != msgbuf
.Code
)
473 (&pen
.bg
)[ColorIndex
] = msgbuf
.Code
;
474 (&prefs
.pen
.bg
)[ColorIndex
] = -msgbuf
.Code
- 1;
476 render_sample(Wnd
, Modif
[ColorIndex
] );
479 /* Returns TRUE if window is closed */
483 /*** Keyboard shorcut ***/
484 BYTE
handle_pref_kbd( UBYTE Key
)
491 GetSI(gads
[0])->BufferPos
= GetSI(gads
[0])->MaxChars
;
492 ActivateGadget(gads
[0], Wnd
, NULL
); break;
493 case 27: close_prefwnd(0); return TRUE
;
496 case 'U': close_prefwnd(CMD_NEWPREF
); return TRUE
;
499 close_prefwnd(CMD_SAVPREF
);
500 if(ConfigFile
) save_prefs(&prefs
);
503 if(Wnd
->Height
> Wnd
->BorderTop
)
509 /*** Handle newmenu events ***/
510 BYTE
handle_pref_menu( ULONG MenuID
)
514 case 101: load_pref(&prefs
); break; /* Load */
515 case 102: save_pref_as(&prefs
); break; /* Save as */
516 case 103: close_prefwnd(0); return TRUE
;
517 case 201: default_prefs(&prefs
); break; /* Default prefs */
518 case 202: restore_config(&prefs
); break; /* Last saved */
523 /*** Handle events coming from pref window ***/
524 void handle_pref( void )
526 /* Collect messages posted to the window port: */
527 while(( msg
=GT_GetIMsg(Wnd
->UserPort
) ))
529 /* Copy the entire message into the buffer: */
530 CopyMem(msg
, &msgbuf
, sizeof(msgbuf
));
533 switch( msgbuf
.Class
)
535 case IDCMP_CLOSEWINDOW
: close_prefwnd(CMD_NEWPREF
); return;
536 case IDCMP_INTUITICKS
:
537 /* An error message which needs to be removed? */
538 if(err_time
== 0) err_time
= msgbuf
.Seconds
;
539 if(err_time
&& msgbuf
.Seconds
-err_time
>4) StopError(Wnd
);
541 case IDCMP_VANILLAKEY
:
542 if( handle_pref_kbd( msgbuf
.Code
) ) return;
546 struct MenuItem
*item
= ItemAddress(Menu
,msgbuf
.Code
);
550 if( handle_pref_menu((IPTR
)GTMENUITEM_USERDATA(item
))) return;
555 if( handle_pref_gadget( (struct Gadget
*) msgbuf
.IAddress
) ) return;
558 if( Wnd
->Height
> SAMPLE_HEI
) render_sample(Wnd
, EDIT_ALL
);
567 void free_locale(void);
569 /*** Handle events coming from main window: ***/
570 void cleanup(UBYTE
*msg
, int errcode
)
577 if(Vi
) FreeVisualInfo(Vi
);
578 if(DiskfontBase
) CloseLibrary(DiskfontBase
);
579 if(LocaleBase
) CloseLibrary(LocaleBase
);
580 if(AslBase
) CloseLibrary(AslBase
);
581 if(GadToolsBase
) CloseLibrary(GadToolsBase
);
582 if(GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
583 if(IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
587 /* Here can be compared good programs with the others :-) */
588 amem
= AvailMem( MEMF_PUBLIC
);
589 if(amem
< bmem
) printf("Possible memory lost of %d bytes\n", bmem
-amem
);
594 void prefs_local(void);
597 int main(int argc
, char *argv
[])
599 ULONG sigwait
, sigrcvd
;
601 bmem
= AvailMem( MEMF_PUBLIC
);
603 memset(&prefs
,0,sizeof(prefs
));
605 /* If preference tool is already running, just quits */
606 if( find_prefs() ) cleanup(0,0);
608 /* Optionnal libraries */
609 AslBase
= (struct Library
*) OpenLibrary("asl.library", 36);
610 LocaleBase
= (struct Library
*) OpenLibrary("locale.library", 38);
611 DiskfontBase
= (struct Library
*) OpenLibrary("diskfont.library", 0);
613 if(LocaleBase
) prefs_local(); /* Localize the prog */
615 /* Open the required ROM libraries: */
616 if( (IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 36)) &&
617 (GfxBase
= (struct GfxBase
*) OpenLibrary("graphics.library", 36)) &&
618 (GadToolsBase
= (struct Library
*) OpenLibrary("gadtools.library", 36)) &&
619 (LayersBase
= (struct Library
*) OpenLibrary("layers.library", 36)) )
621 if( !(msgport
= create_port()) ) cleanup(0, RETURN_FAIL
);
623 /* User may want to "edit" a particular file */
625 if( load_prefs(&prefs
, argv
[1]) ) cleanup(ErrMsg(ERR_LOADFILE
), RETURN_FAIL
);
627 if( find_jano(&prefs
) ) ConfigFile
= FALSE
;
628 else load_prefs(&prefs
, NULL
);
630 save_config( ConfigFile
);
631 if(ConfigFile
) Scr
= prefs
.parent
;
634 if( setup_guipref() )
636 sigwait
= msgport
| prefsigbit
| SIGBREAKF_CTRL_C
;
639 sigrcvd
= Wait( sigwait
);
640 /* From where does the signal comes from? */
641 if(sigrcvd
& SIGBREAKF_CTRL_C
) break;
643 else if(sigrcvd
& msgport
) handle_port();
646 if(Wnd
== NULL
) break;
648 } else ThrowError(Wnd
, ErrMsg(ERR_NOGUI
));
649 } else ThrowError(Wnd
, ErrMsg(ERR_BADOS
));