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
34 #define LocaleInfo LocaleInfoTmp /* Avoid redefinition :-( */
35 #include "../../tools/Edit/strings.h"
37 /* Shared libraires we'll need to open */
38 struct IntuitionBase
*IntuitionBase
= NULL
;
39 struct GfxBase
*GfxBase
= NULL
;
40 struct Library
*GadToolsBase
= NULL
;
41 struct Library
*AslBase
= NULL
;
42 struct Library
*LocaleBase
= NULL
;
43 struct Library
*DiskfontBase
= NULL
;
44 struct Library
*LayersBase
= NULL
;
46 struct IntuiMessage
*msg
, msgbuf
;
47 struct NewWindow NewPrefWin
=
49 0,0,0,0, 1,1, /* LE,TE,Wid,Hei, Pens */
50 IDCMP_MENUPICK
| IDCMP_CLOSEWINDOW
| IDCMP_GADGETUP
| IDCMP_NEWSIZE
| IDCMP_VANILLAKEY
,
51 WFLG_CLOSEGADGET
| WFLG_NEWLOOKMENUS
| WFLG_DEPTHGADGET
| WFLG_ACTIVATE
| WFLG_SMART_REFRESH
|
53 NULL
, /* FirstGadget */
58 100, 50, 0xffff, 0xffff, /* Min & Max size */
62 /** Standard GUI ressource **/
63 struct Screen
*Scr
= NULL
; /* Screen where window opens */
64 struct Window
*Wnd
= NULL
; /* Pointer to the opened window */
65 void *Vi
= NULL
; /* Visual Info for gadget */
66 struct Menu
*Menu
= NULL
; /* Menu of interface */
67 struct TextFont
*font
; /* Font used for gadgets */
68 struct RastPort RPT
; /* Font measurement */
73 /* Tag list for various gadget */
74 struct TagItem IntTags
[] = { /*{GTIN_Number, 0},*/ {GTST_MaxChars
,2}, {TAG_DONE
}};
75 struct TagItem SepTags
[] = {{GTST_MaxChars
, MAX_SPLIT
}, {TAG_DONE
}};
76 struct TagItem TextFontTags
[] = {{GTCY_Labels
, (IPTR
)FTCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
77 struct TagItem ScrFontTags
[] = {{GTCY_Labels
, (IPTR
)FSCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
78 struct TagItem ScrMdTags
[] = {{GTCY_Labels
, (IPTR
)ScrCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
79 struct TagItem ColorTags
[] = {{GTCY_Labels
, (IPTR
)ColCycTxt
}, {GTCY_Active
,0}, {TAG_DONE
}};
80 struct TagItem MenuTags
[] = {{GTMN_FrontPen
, 1L}, {TAG_DONE
}};
82 struct TagItem
*GadTags
[] = {IntTags
, SepTags
, TextFontTags
, ScrFontTags
, ScrMdTags
};
84 /* Tag list for opening the main window */
86 struct TagItem PrefTags
[] = {
88 {WA_NewLookMenus
,TRUE
},
92 struct NewGadget NG
; /* To create the gadgets */
93 struct Gadget
*pgads
=NULL
; /* Gadtool's gadgets */
94 struct Gadget
*gads
[CBS
+CGS
];
95 extern PREFS prefs
; /* Preference buffer */
96 extern UBYTE Modif
[]; /* Buffer for string's gadget */
97 ULONG prefsigbit
, msgport
; /* Signal bits for asynchronous messages collect */
98 ULONG extended
; /* Extended cycle gadgets */
99 UBYTE ConfigFile
= TRUE
; /* TRUE is a config file is edited */
100 UBYTE ColorIndex
= 0; /* Color index to change */
101 UBYTE StrInfo
[60]; /* Screen/font description */
102 WORD wid
[5]; /* Width of various strings */
104 /*** Display an error message in the window's title ***/
105 static UBYTE
*Title
= NULL
;
106 static ULONG err_time
;
107 void ThrowError(struct Window
*W
, UBYTE
*Msg
)
112 Title
= (W
->Flags
& WFLG_BACKDROP
? W
->WScreen
->Title
: W
->Title
);
113 /* If window is backdrop'ed, change screen's title instead of window */
114 if(W
->Flags
& WFLG_BACKDROP
) SetWindowTitles(W
,(STRPTR
)-1,Msg
);
115 else SetWindowTitles(W
,Msg
,(STRPTR
)-1);
117 DisplayBeep(W
->WScreen
);
119 /* To be sure that mesage will be disappear one day */
120 ModifyIDCMP(W
,W
->IDCMPFlags
| IDCMP_INTUITICKS
);
124 /*** Show messages associated with IoErr() number ***/
125 void ThrowDOSError(struct Window
*W
, STRPTR Prefix
, UBYTE err
)
127 static UBYTE Message
[100];
129 /* Get standard DOS error message */
130 Fault(err
, Prefix
, Message
, sizeof(Message
));
132 ThrowError(W
, Message
);
135 /*** Reset the old title ***/
136 void StopError(struct Window
*W
)
138 if(W
->Flags
& WFLG_BACKDROP
) SetWindowTitles(W
,(STRPTR
)-1,Title
);
139 else SetWindowTitles(W
,Title
,(STRPTR
)-1);
141 /* INTUITICKS aren't required anymore */
142 ModifyIDCMP(W
,W
->IDCMPFlags
& ~IDCMP_INTUITICKS
);
145 /*** Try to open configuration window, return 1 if all's ok ***/
146 BYTE
setup_guipref( void )
151 /** Look if window isn't already open, thus just activate it **/
155 /* Uniconified it, if it is */
156 if(Wnd
->Height
<=Wnd
->BorderTop
) ZipWindow(Wnd
);
161 /** Visual info pointer **/
162 if(Vi
== NULL
&& !(Vi
= (void *) GetVisualInfoA(Scr
,NULL
))) return 0;
164 /** Init missing strings **/
165 CopyMem(FTCycTxt
,FSCycTxt
,sizeof(FSCycTxt
));
166 CopyMem(FTCycTxt
+1,ScrCycTxt
+2,sizeof(UBYTE
*)*2);
168 FSCycTxt
[0]=StrInfo
+20;
169 ScrCycTxt
[0]=StrInfo
+40;
170 /** Init temporary rastport, for font measurement **/
172 SetFont(&RPT
, font
= Scr
->RastPort
.Font
);
174 /** Compute window width and height **/
175 wid
[0] = meas_table(MiscTxt
);
176 wid
[1] = meas_table(ChkTxt
);
177 wid
[2] = meas_table(OkCanSav
)+20;
178 wid
[3] = meas_table(FSCycTxt
);
179 wid
[4] = meas_table(ColCycTxt
);
180 width
= meas_table(ScrCycTxt
);
181 if(wid
[3] < width
) wid
[3] = width
;
183 NewPrefWin
.Width
= wid
[0] + wid
[3] + wid
[1] + 130;
184 NewPrefWin
.Height
= Scr
->BarHeight
+ font
->tf_YSize
* 8 + (54 + SAMPLE_HEI
);
185 NewPrefWin
.LeftEdge
= 50;
186 NewPrefWin
.TopEdge
= 50;
187 NewPrefWin
.Screen
= Scr
;
188 NewPrefWin
.Title
= (ConfigFile
? Path
: PrefMsg
[0]);
190 /** Does it fit in the screen ? **/
191 fit_in_screen(&NewPrefWin
, Scr
);
193 /** Compute the iconified window dimensions: **/
194 PrefZoom
[2] = TextLength(&RPT
,NewPrefWin
.Title
,strlen(NewPrefWin
.Title
))+100;
195 if(prefs
.use_pub
) PrefZoom
[0] = Scr
->Width
-PrefZoom
[2]-15, PrefZoom
[1] = 0;
196 else PrefZoom
[0] = PrefZoom
[1] = 50;
197 PrefZoom
[3] = Scr
->WBorTop
+ Scr
->Font
->ta_YSize
+ 1;
199 /** Setup inital tags: **/
200 ScrFontTags
[1].ti_Data
= 0;
201 ScrMdTags
[1].ti_Data
= 0;
202 TextFontTags
[1].ti_Data
= 0;
205 if( prefs
.use_txtfont
)
206 font_info(StrInfo
, prefs
.txtfont
),
207 TextFontTags
[0].ti_Data
= (IPTR
) FTCycTxt
, extended
|= 1;
209 TextFontTags
[0].ti_Data
= (IPTR
) (FTCycTxt
+1);
211 if( prefs
.use_scrfont
)
212 font_info(StrInfo
+20, prefs
.scrfont
),
213 ScrFontTags
[0].ti_Data
= (IPTR
) FSCycTxt
, extended
|= 2;
215 ScrFontTags
[0].ti_Data
= (IPTR
) (FSCycTxt
+1);
217 if( prefs
.use_pub
==1 )
218 scr_info(StrInfo
+40,Scr
->Width
, Scr
->Height
, Scr
->RastPort
.BitMap
->Depth
),
219 ScrMdTags
[0].ti_Data
= (IPTR
) ScrCycTxt
, extended
|= 4;
221 ScrMdTags
[0].ti_Data
= (IPTR
) (ScrCycTxt
+1);
222 if(prefs
.use_pub
!=2) ScrMdTags
[1].ti_Data
= 1; /* Clone */
224 /* Checkbox states */
225 CopyMem(&prefs
.backdrop
, CB_state
, CBS
);
227 /* If it isn't the frontmost screen */
228 if(Scr
!= IntuitionBase
->ActiveScreen
) ScreenToFront(Scr
);
231 if(NULL
== (Menu
= (void *) CreateMenusA(newmenu
, MenuTags
)) ||
232 0 == LayoutMenus(Menu
, Vi
, GTMN_TextAttr
, Scr
->Font
, TAG_DONE
)) return FALSE
;
234 /** Try to open the window **/
235 if(( Wnd
= (struct Window
*) OpenWindowTagList(&NewPrefWin
,PrefTags
) ))
237 struct Gadget
**pg
= gads
, *gad
;
239 gad
= (struct Gadget
*) CreateContext(&pgads
);
240 NG
.ng_TopEdge
= Wnd
->BorderTop
+5;
241 NG
.ng_Width
= wid
[3]+40;
242 NG
.ng_LeftEdge
= wid
[0]+20;
243 NG
.ng_Height
= font
->tf_YSize
+6;
244 NG
.ng_Flags
= PLACETEXT_LEFT
| NG_HIGHLABEL
;
245 NG
.ng_TextAttr
= Scr
->Font
;
246 NG
.ng_VisualInfo
= Vi
;
248 /* Create left column of gadgets */
249 for(i
=0; i
<CGS
; i
++, NG
.ng_TopEdge
+=NG
.ng_Height
, *pg
++ = gad
)
253 NG
.ng_GadgetText
= MiscTxt
[i
];
268 gad
= (void *) CreateGadgetA(kind
, gad
, &NG
, GadTags
[i
]);
269 if(i
==0) AddNum (prefs
.tabsize
, GetSI(gad
)->Buffer
);
270 if(i
==1) CopyMem(prefs
.wordssep
, GetSI(gad
)->Buffer
, MAX_SPLIT
);
273 /* Create right column of gads */
274 NG
.ng_TopEdge
= Wnd
->BorderTop
+5;
275 NG
.ng_LeftEdge
+= NG
.ng_Width
+20;
276 NG
.ng_Width
= (NG
.ng_Height
-= 2);
277 NG
.ng_Flags
= PLACETEXT_RIGHT
;
278 for(; i
<CGS
+CBS
; i
++, NG
.ng_TopEdge
+=NG
.ng_Height
, *pg
++ = gad
)
280 NG
.ng_GadgetText
= ChkTxt
[i
-CGS
];
282 gad
= (void *) CreateGadget(CHECKBOX_KIND
, gad
, &NG
, GTCB_Checked
, CB_state
[i
-CGS
], TAG_DONE
);
283 if(i
== CGS
&& prefs
.use_pub
== 0)
284 gad
->Flags
|= GFLG_DISABLED
;
287 /* Create bottom row of gadgets */
288 NG
.ng_TopEdge
= Wnd
->Height
-NG
.ng_Height
-5;
290 NG
.ng_Width
= wid
[2];
291 NG
.ng_Flags
= PLACETEXT_IN
;
292 width
= (Wnd
->Width
-20-wid
[2]) >> 1;
293 for(; i
<UCS
+3; i
++, NG
.ng_LeftEdge
+=width
)
295 NG
.ng_GadgetText
= OkCanSav
[i
-UCS
];
297 gad
= (void *) CreateGadgetA(BUTTON_KIND
, gad
, &NG
, NULL
);
300 /* Initiate sample editor to see colors adjustement */
301 init_sample(Wnd
, &prefs
, NG
.ng_TopEdge
-= 5 + SAMPLE_HEI
);
303 /* Cycle color chooser */
304 NG
.ng_TopEdge
-= NG
.ng_Height
+3;
305 NG
.ng_Width
= wid
[4]+40;
306 NG
.ng_GadgetText
= NULL
;
309 gad
= (void *) CreateGadgetA(CYCLE_KIND
, gad
, &NG
, ColorTags
);
311 /* Palette chooser */
312 NG
.ng_Width
= Wnd
->Width
- 10 - (
313 NG
.ng_LeftEdge
+= NG
.ng_Width
+10);
314 NG
.ng_GadgetID
= i
+1;
315 CreateGadget(PALETTE_KIND
, gad
, &NG
,
316 GTPA_Depth
, ((Scr
->RastPort
.BitMap
->Depth
> 5) ? 5 : Scr
->RastPort
.BitMap
->Depth
),
319 /* Add gadgets to window: */
320 CopyMem(Wnd
->RPort
, &RPT
, sizeof(RPT
));
321 SetFont(&RPT
, prefs
.scrfont
);
322 render_sample(Wnd
, EDIT_ALL
);
323 AddGList( Wnd
, pgads
, -1, -1, NULL
);
324 RefreshGList(pgads
, Wnd
, NULL
, -1);
325 SetMenuStrip( Wnd
, Menu
);
326 GT_RefreshWindow(Wnd
, NULL
);
328 /* Add window's signal bit: */
329 prefsigbit
= 1 << Wnd
->UserPort
->mp_SigBit
;
335 /*** Close the preference window ***/
336 void close_prefwnd( BYTE cmd
)
340 if( Menu
) ClearMenuStrip(Wnd
);
342 prefsigbit
=0; Wnd
=NULL
;
345 /* Flush content of some gadget that may not be confirmed */
346 prefs
.tabsize
= atoi(GetSI(gads
[0])->Buffer
);
347 CopyMem(GetSI(gads
[1])->Buffer
, prefs
.wordssep
, MAX_SPLIT
);
349 FreeGadgets(pgads
); pgads
=NULL
;
352 if(Menu
) FreeMenus(Menu
),Menu
=NULL
;
354 /* Do we need to send modifications to JANO? */
355 if( cmd
&& !ConfigFile
) send_jano(&prefs
, cmd
);
358 /*** Handle messages coming from gadgets ***/
359 BYTE
handle_pref_gadget(struct Gadget
*G
)
361 struct TextFont
*newfont
;
362 static UBYTE useit
[]={1,2,0,1};
365 switch( G
->GadgetID
)
367 case 0: /* Check tabulation: */
370 case 2: /* Changing default text font: */
372 Code
= msgbuf
.Code
; if(extended
& 1) Code
--;
375 if( !(prefs
.use_txtfont
= (Code
==-1)) )
376 /* User want to use the default text font: */
377 text_to_attr(prefs
.txtfont
=GfxBase
->DefaultFont
, &prefs
.attrtxt
);
379 if((newfont
= get_old_font(FTCycTxt
[0])))
380 text_to_attr(prefs
.txtfont
=newfont
, &prefs
.attrtxt
);
381 else { ThrowError(Wnd
, ErrMsg(ERR_LOADFONT
)); break; }
382 render_sample(Wnd
, EDIT_AREA
);
385 /* User want to change the text font: */
386 if((newfont
= change_fonts(&prefs
.attrtxt
, Wnd
, TRUE
)))
388 if( prefs
.txtfont
) CloseFont(prefs
.txtfont
);
389 font_info(StrInfo
, prefs
.txtfont
= newfont
);
390 TextFontTags
[0].ti_Data
= (IPTR
) FTCycTxt
; extended
|= 1;
391 prefs
.use_txtfont
= TRUE
;
392 TextFontTags
[1].ti_Data
= 0;
393 } /* else we must reset the original cycle gadget entry */
394 GT_SetGadgetAttrsA(G
, Wnd
, NULL
, TextFontTags
);
395 render_sample(Wnd
, EDIT_AREA
);
397 case 3: /* Changing default screen font */
399 Code
= msgbuf
.Code
; if(extended
& 2) Code
--;
402 if( !(prefs
.use_scrfont
= (Code
==-1)) )
403 /* User want to use default screen font */
404 text_to_attr(prefs
.scrfont
=prefs
.parent
->RastPort
.Font
, &prefs
.attrscr
);
406 if((newfont
= get_old_font(FSCycTxt
[0])))
407 text_to_attr(prefs
.scrfont
=newfont
, &prefs
.attrscr
);
408 else { ThrowError(Wnd
, ErrMsg(ERR_LOADFONT
)); break; }
410 render_sample(Wnd
, EDIT_ALL
);
413 /* User want to change the screen font */
414 if((newfont
= change_fonts(&prefs
.attrscr
, Wnd
, FALSE
)))
416 if( prefs
.scrfont
) CloseFont(prefs
.scrfont
);
417 font_info(StrInfo
+20, prefs
.scrfont
= newfont
);
418 ScrFontTags
[0].ti_Data
= (IPTR
) FSCycTxt
; extended
|= 2;
419 prefs
.use_scrfont
= TRUE
;
420 ScrFontTags
[1].ti_Data
= 0;
422 GT_SetGadgetAttrsA(G
, Wnd
, NULL
, ScrFontTags
);
423 render_sample(Wnd
, EDIT_ALL
);
425 case 4: /* Change screen mode/type */
427 Code
= msgbuf
.Code
; if(extended
& 4) Code
--;
429 prefs
.use_pub
= useit
[Code
+1];
432 /* User want to use a pubscreen instead of workbench screen: */
433 if((Code
= change_screen_mode(wid
, prefs
.modeid
)) != INVALID_ID
)
435 prefs
.depth
= wid
[2];
437 ScrMdTags
[0].ti_Data
= (IPTR
) ScrCycTxt
;
438 ScrMdTags
[1].ti_Data
= 0;
439 scr_info(StrInfo
+40, wid
[0], wid
[1], wid
[2]);
440 prefs
.use_pub
= TRUE
; extended
|= 4;
441 } else ScrMdTags
[1].ti_Data
= useit
[ prefs
.use_pub
+1 ];
442 GT_SetGadgetAttrsA(G
, Wnd
, NULL
, ScrMdTags
);
444 /* If user want to use a pubscreen, then disable backdrop checkbox **
445 ** It is not recommended to use a backdrop'ed window on a such scr */
447 OnGadget (gads
[CGS
], Wnd
, NULL
);
449 OffGadget (gads
[CGS
], Wnd
, NULL
);
451 case CGS
: case CGS
+1: /* Checkbuttons */
452 case CGS
+2: case CGS
+3:
453 (&prefs
.backdrop
)[G
->GadgetID
-CGS
] = ((G
->Flags
& GFLG_SELECTED
) == GFLG_SELECTED
);
456 close_prefwnd(CMD_SAVPREF
);
457 if(ConfigFile
) save_prefs(&prefs
);
459 case UCS
+1: /* Use */
460 close_prefwnd(CMD_NEWPREF
); return TRUE
;
461 case UCS
+2: /* Cancel */
462 close_prefwnd(0); return TRUE
;
463 case UCS
+3: /* Cycle color */
464 ColorIndex
= msgbuf
.Code
; break;
465 case UCS
+4: /* Palette */
466 if((&pen
.bg
)[ ColorIndex
] != msgbuf
.Code
)
467 (&pen
.bg
)[ ColorIndex
] = msgbuf
.Code
,
468 (&prefs
.pen
.bg
)[ ColorIndex
] = -msgbuf
.Code
-1,
469 render_sample(Wnd
, Modif
[ ColorIndex
] );
471 /* Returns TRUE if window is closed */
475 /*** Keyboard shorcut ***/
476 BYTE
handle_pref_kbd( UBYTE Key
)
483 GetSI(gads
[0])->BufferPos
= GetSI(gads
[0])->MaxChars
;
484 ActivateGadget(gads
[0], Wnd
, NULL
); break;
485 case 27: close_prefwnd(0); return TRUE
;
488 case 'U': close_prefwnd(CMD_NEWPREF
); return TRUE
;
491 close_prefwnd(CMD_SAVPREF
);
492 if(ConfigFile
) save_prefs(&prefs
);
495 if(Wnd
->Height
> Wnd
->BorderTop
)
501 /*** Handle newmenu events ***/
502 BYTE
handle_pref_menu( ULONG MenuID
)
506 case 101: load_pref(&prefs
); break; /* Load */
507 case 102: save_pref_as(&prefs
); break; /* Save as */
508 case 103: close_prefwnd(0); return TRUE
;
509 case 201: default_prefs(&prefs
); break; /* Default prefs */
510 case 202: restore_config(&prefs
); break; /* Last saved */
515 /*** Handle events coming from pref window ***/
516 void handle_pref( void )
518 /* Collect messages posted to the window port: */
519 while(( msg
=GT_GetIMsg(Wnd
->UserPort
) ))
521 /* Copy the entire message into the buffer: */
522 CopyMem(msg
, &msgbuf
, sizeof(msgbuf
));
525 switch( msgbuf
.Class
)
527 case IDCMP_CLOSEWINDOW
: close_prefwnd(CMD_NEWPREF
); return;
528 case IDCMP_INTUITICKS
:
529 /* An error message which needs to be removed? */
530 if(err_time
== 0) err_time
= msgbuf
.Seconds
;
531 if(err_time
&& msgbuf
.Seconds
-err_time
>4) StopError(Wnd
);
533 case IDCMP_VANILLAKEY
:
534 if( handle_pref_kbd( msgbuf
.Code
) ) return;
538 struct MenuItem
*item
= ItemAddress(Menu
,msgbuf
.Code
);
542 if( handle_pref_menu((ULONG
)GTMENUITEM_USERDATA(item
))) return;
547 if( handle_pref_gadget( (struct Gadget
*) msgbuf
.IAddress
) ) return;
550 if( Wnd
->Height
> SAMPLE_HEI
) render_sample(Wnd
, EDIT_ALL
);
559 void free_locale(void);
561 /*** Handle events coming from main window: ***/
562 void cleanup(UBYTE
*msg
, int errcode
)
569 if(Vi
) FreeVisualInfo(Vi
);
570 if(DiskfontBase
) CloseLibrary(DiskfontBase
);
571 if(LocaleBase
) CloseLibrary(LocaleBase
);
572 if(AslBase
) CloseLibrary(AslBase
);
573 if(GadToolsBase
) CloseLibrary(GadToolsBase
);
574 if(GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
575 if(IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
579 /* Here can be compared good programs with the others :-) */
580 amem
= AvailMem( MEMF_PUBLIC
);
581 if(amem
< bmem
) printf("Possible memory lost of %d bytes\n", bmem
-amem
);
586 void prefs_local(void);
589 int main(int argc
, char *argv
[])
591 ULONG sigwait
, sigrcvd
;
593 bmem
= AvailMem( MEMF_PUBLIC
);
595 memset(&prefs
,0,sizeof(prefs
));
597 /* If preference tool is already running, just quits */
598 if( find_prefs() ) cleanup(0,0);
600 /* Optionnal libraries */
601 AslBase
= (struct Library
*) OpenLibrary("asl.library", 36);
602 LocaleBase
= (struct Library
*) OpenLibrary("locale.library", 38);
603 DiskfontBase
= (struct Library
*) OpenLibrary("diskfont.library", 0);
605 if(LocaleBase
) prefs_local(); /* Localize the prog */
607 /* Open the required ROM libraries: */
608 if( (IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 36)) &&
609 (GfxBase
= (struct GfxBase
*) OpenLibrary("graphics.library", 36)) &&
610 (GadToolsBase
= (struct Library
*) OpenLibrary("gadtools.library", 36)) &&
611 (LayersBase
= (struct Library
*) OpenLibrary("layers.library", 36)) )
613 if( !(msgport
= create_port()) ) cleanup(0, RETURN_FAIL
);
615 /* User may want to "edit" a particular file */
617 if( load_prefs(&prefs
, argv
[1]) ) cleanup(ErrMsg(ERR_LOADFILE
), RETURN_FAIL
);
619 if( find_jano(&prefs
) ) ConfigFile
= FALSE
;
620 else load_prefs(&prefs
, NULL
);
622 save_config( ConfigFile
);
623 if(ConfigFile
) Scr
= prefs
.parent
;
626 if( setup_guipref() )
628 sigwait
= msgport
| prefsigbit
| SIGBREAKF_CTRL_C
;
631 sigrcvd
= Wait( sigwait
);
632 /* From where does the signal comes from? */
633 if(sigrcvd
& SIGBREAKF_CTRL_C
) break;
635 else if(sigrcvd
& msgport
) handle_port();
638 if(Wnd
== NULL
) break;
640 } else ThrowError(Wnd
, ErrMsg(ERR_NOGUI
));
641 } else ThrowError(Wnd
, ErrMsg(ERR_BADOS
));