home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * File : CassLabel.c *
- * Purpose : The MUI based Multimedia Cover-Editor *
- * Last Revised : 05.06.1994 *
- * Created by : Dirk Nehring *
- * Current revision: V2.1 *
- **********************************************************************/
-
- /***** History (* = New) *****
- Version 1.0 (21.09.93)
- - First official release
-
- Version 1.1 (04.10.93)
- * Now CassLabel uses its own Icon as Diskobject when iconified
- - Improved GUI (the window was too big)
- - File format changed (Sorry ;-( )
- - Better ARexx-Script
- * Included tape type and tape length
- * Disabled <CTRL-C> Checking
- - From now on no back text
- - LaTeX output: back side changed (tape type and tape length)
- * New ISO-Latin 1 to LaTeX Source-Converter
- * Error text when CassLabel can't open the Main Window
- * New LaTex output formats
- * LaTeX output: if you have not enough songs, the second page will not
- be printed
- - Catalogs changed
- - Divide source in some parts
-
- Version 1.2 (20.10.93)
- - Action buttons moved into the Window Menu (=> smaller Window)
- - 'rexx/Start_LateX.rexx' changed (now handles PasTeX and AmigaTeX
- correctly)
- * Now handles <CTRL-C> as <ESC>
- * Listview-Stringgadgets are now disabled at Startup
- * Online Help can be invoked by pressing <HELP>
- * ARexx-Script will now be called with System() instead of Execute()
-
- Version 2.0 (26.03.94)
- - Recompiled with SAS/C 6.51
- - Nederlands catalog added (Thanks to Ivo Kroone)
- * Now there is a safety Requester
- * selectable Device Driver (i.e. PasTeX, MuchMore, PostView, etc.)
- * selectable Format (i.e. LaTeX, ASCII, PostScript, etc.)
- * every song have a now group and an extension
- - New File format, but the old format is still supported
- - Improved GUI
- * Filename now in the window border
-
- Version 2.1 (05.06.94)
- * CON-Window opens, when CassLabel is started from the WB and the driver
- makes some output
- * Errorshandler now uses EasyRequest()
- * Help on Format-Button in the Preferences
- - some bugs in the format files removed
-
- ***** End of History *****/
-
- /**********************************************************************
- * Includes *
- **********************************************************************/
- #include "global.h"
-
- /* Locale support */
- #define CATCOMP_NUMBERS
- #define CATCOMP_BLOCK
- #include "CassLabel_strings.h"
-
-
- /**********************************************************************
- * Defines *
- **********************************************************************/
- #define REVISION "2.1"
- #define REVDATE __DATE__
- #define REVTIME __TIME__
-
- /* Online Help */
- #define GUIDEFILE "CassLabel.guide"
- #define NODE_MAIN "MainWindow"
- #define NODE_PREFS "MENU_Preferences"
-
-
- /**********************************************************************
- * Turning off CTRL-C checking *
- **********************************************************************/
- void __regargs __chkabort(void) {}
-
-
- /**********************************************************************
- * Global variables, structures, enums *
- **********************************************************************/
- struct Library *MUIMasterBase;
-
- long __oslibversion = 37;
- long __stack = 8192;
-
- static char *programname;
- static char programpath[256];
- static char pathname[256];
- static struct DiskObject *diskobj;
-
- char dirbuf_load[256];
- char filebuf_load[256];
- char dirbuf_save[256];
- char filebuf_save[256];
- char dirbuf_generate[256] = "RAM:";
- char filebuf_generate[256];
-
- static struct NewMenu Menu[] =
- {
- {NM_TITLE, "", NULL, 0, 0, NULL},
- {NM_ITEM, "", NULL, 0, 0, (APTR) ID_NEW},
- {NM_ITEM, "", "", 0, 0, (APTR) ID_LOAD},
- {NM_ITEM, "", NULL, 0, 0, (APTR) ID_LOAD_OLD},
- {NM_ITEM, "", NULL, 0, 0, (APTR) ID_APPEND},
- {NM_ITEM, "", "", 0, 0, (APTR) ID_SAVE},
- {NM_ITEM, "", NULL, 0, 0, (APTR) ID_SAVE_AS},
- {NM_ITEM, NM_BARLABEL, NULL, 0, 0, NULL},
- {NM_ITEM, "", NULL, 0, 0, (APTR) ID_PREFS},
- {NM_ITEM, NM_BARLABEL, NULL, 0, 0, NULL},
- {NM_ITEM, "", "", 0, 0, (APTR) ID_GENERATE},
- {NM_ITEM, "", "", 0, 0, (APTR) ID_PRINT},
- {NM_ITEM, NM_BARLABEL, NULL, 0, 0, NULL},
- {NM_ITEM, "", "", 0, 0, (APTR) ID_ABOUT},
- {NM_ITEM, "", "", 0, 0, (APTR) ID_QUIT},
- {NM_END, NULL, NULL, 0, 0, NULL},
- };
-
- const char *CYA_Source[] = {"CD", "MC", "Vinyl", "Live", "Radio", "Video", "TV", NULL};
- const char *CYA_NoiseR[] = {"-", "Dolby B", "Dolby C", "Dolby S", "DBX", NULL};
- const char *CYA_Position[] = {"Normal", "Chrome", "Metal", NULL};
- const char *CYA_Length[] = {"30", "60", "90", "100", "110", "120", NULL};
- const char *Pages[] = {"", "", "", NULL};
-
- APTR App;
- APTR MainWindow;
- APTR PrefsWindow;
-
- APTR LV_SideA;
- APTR ST_ElementTitleA;
- APTR ST_ElementGroupA;
- APTR ST_ElementExtensionA;
- APTR BT_AddA;
- APTR BT_RemoveA;
- APTR BT_UpA;
- APTR BT_DownA;
- APTR ST_DateA;
- APTR ST_GroupA;
- APTR ST_TitleA;
- APTR CY_SourceA;
- APTR CY_NoiseRA;
-
- APTR LV_SideB;
- APTR ST_ElementTitleB;
- APTR ST_ElementGroupB;
- APTR ST_ElementExtensionB;
- APTR BT_AddB;
- APTR BT_RemoveB;
- APTR BT_UpB;
- APTR BT_DownB;
- APTR ST_DateB;
- APTR ST_GroupB;
- APTR ST_TitleB;
- APTR CY_SourceB;
- APTR CY_NoiseRB;
-
- APTR BT_New;
- APTR BT_Load;
- APTR BT_Save;
- APTR BT_Print;
- APTR BT_Create;
-
- APTR GA_GaugeA;
- APTR GA_GaugeB;
- APTR ST_Number;
- APTR CY_Position;
- APTR CY_Length;
-
- APTR BT_PrefsSave;
- APTR BT_PrefsOK;
- APTR BT_PrefsCancel;
- APTR PS_PopFormat;
- APTR PS_PopFormat_String;
- APTR PS_PopDriver;
- APTR PS_PopDriver_String;
- APTR CM_Translate;
- APTR BT_PrefsHelp;
-
-
- /**********************************************************************
- * Support Functions *
- **********************************************************************/
- char *GetStr(APTR obj)
- {
- char *str;
-
- if (!get(obj, MUIA_String_Contents, &str))
- get(obj, MUIA_Text_Contents, &str);
-
- return (str);
- }
-
- long GetBool(APTR obj)
- {
- long x;
- get(obj, MUIA_Selected, &x);
- return (x);
- }
-
- long GetRadio(APTR obj)
- {
- long x;
- get(obj, MUIA_Radio_Active, &x);
- return (x);
- }
-
- long GetCycle(APTR obj)
- {
- long x;
- get(obj, MUIA_Cycle_Active, &x);
- return (x);
- }
-
-
- /**********************************************************************
- * Locale Support *
- **********************************************************************/
- struct LocaleInfo CassLabelLocaleInfo = {NULL, NULL};
- struct Library *LocaleBase;
- APTR CassLabelCatalog;
-
- STRPTR GetLocaleString(long stringNum)
- {
- long *l;
- unsigned short *w;
- STRPTR builtIn;
-
- l = (long *) CatCompBlock;
-
- while (*l != stringNum)
- {
- w = (unsigned short *) ((unsigned long) l + 4);
- l = (long *) ((unsigned long) l + (unsigned long) * w + 6);
- }
- builtIn = (STRPTR) ((unsigned long) l + 6);
-
- if (LocaleBase)
- return (GetCatalogStr(CassLabelCatalog, stringNum, builtIn));
-
- return (builtIn);
- }
-
-
- /**********************************************************************
- * Fail Functions *
- **********************************************************************/
- static void fail(APTR app, char *str)
- {
- struct EasyStruct es = {sizeof (struct EasyStruct), 0, NULL, NULL, "OK"};
-
- if (diskobj)
- FreeDiskObject(diskobj);
-
- if (app)
- MUI_DisposeObject(app);
-
- if (MUIMasterBase)
- CloseLibrary(MUIMasterBase);
-
- if (CassLabelCatalog)
- CloseCatalog(CassLabelCatalog);
-
- if (LocaleBase)
- CloseLibrary(LocaleBase);
-
- if (str)
- {
- es.es_TextFormat = str;
- EasyRequestArgs(NULL, &es, NULL, NULL);
- exit(EXIT_FAILURE);
- }
-
- exit(EXIT_SUCCESS);
- }
-
-
- /**********************************************************************
- * Functions for changing Listview entries *
- **********************************************************************/
- static void ga_update(APTR lv, APTR ga)
- {
- long last;
-
- get(lv, MUIA_List_Entries, &last);
- set(ga, MUIA_Gauge_Current, last);
- }
-
- static void lv_add(APTR lv, APTR st1, APTR st2, APTR st3, APTR bt1, APTR bt2, APTR bt3, APTR bt4, APTR ga)
- {
- struct NodeEntry entry = {"", ""}, *entrypointer = &entry;
-
- long pos, last;
-
- /* Insert at Cursor-Position */
- get(lv, MUIA_List_Active, &pos);
- get(lv, MUIA_List_Entries, &last);
- if (pos == -1)
- {
- /* Enable the String Gadget */
- set(st1, MUIA_Disabled, FALSE);
- set(st2, MUIA_Disabled, FALSE);
- set(st3, MUIA_Disabled, FALSE);
- set(bt2, MUIA_Disabled, FALSE);
- set(bt3, MUIA_Disabled, FALSE);
- set(bt4, MUIA_Disabled, FALSE);
- pos = last;
- }
- if (last < MAX_ENTRIES)
- {
- pos++;
- DoMethod(lv, MUIM_List_Insert, &entrypointer, 1, pos);
- set(lv, MUIA_List_Active, pos);
- ga_update(lv, ga);
- /* Activate String Gadget */
- set(MainWindow, MUIA_Window_ActiveObject, st1);
- }
- if (last + 1 == MAX_ENTRIES)
- set(bt1, MUIA_Disabled, TRUE);
- }
-
- static void lv_remove(APTR lv, APTR st1, APTR st2, APTR st3, APTR bt1, APTR bt2, APTR bt3, APTR bt4, APTR ga)
- {
- long pos, last;
-
- get(lv, MUIA_List_Active, &pos);
- DoMethod(lv, MUIM_List_Remove, pos);
- get(lv, MUIA_List_Entries, &last);
- /* If there is no more entry, disable the Stringgadget */
- if (!last)
- {
- set(st1, MUIA_Disabled, TRUE);
- set(st2, MUIA_Disabled, TRUE);
- set(st3, MUIA_Disabled, TRUE);
- set(bt2, MUIA_Disabled, TRUE);
- set(bt3, MUIA_Disabled, TRUE);
- set(bt4, MUIA_Disabled, TRUE);
- }
- set(bt1, MUIA_Disabled, FALSE);
- ga_update(lv, ga);
- }
-
- static void lv_up(APTR lv)
- {
- long pos;
-
- get(lv, MUIA_List_Active, &pos);
- if (pos > 0)
- {
- DoMethod(lv, MUIM_List_Exchange, pos, pos - 1);
- set(lv, MUIA_List_Active, pos - 1);
- }
- }
-
- static void lv_down(APTR lv)
- {
- long pos, last;
-
- get(lv, MUIA_List_Entries, &last);
- get(lv, MUIA_List_Active, &pos);
-
- last--;
- if (pos < last && last > 0)
- {
- DoMethod(lv, MUIM_List_Exchange, pos, pos + 1);
- set(lv, MUIA_List_Active, pos + 1);
- }
- }
-
- static void lv_edit(APTR lv, APTR st1, APTR st2, APTR st3)
- {
- long pos;
- char *title;
- char *group;
- char *extension;
- struct NodeEntry entry, *entrypointer = &entry;
-
- set(lv, MUIA_List_Quiet, TRUE);
- get(lv, MUIA_List_Active, &pos);
- DoMethod(lv, MUIM_List_Remove, pos);
- get(st1, MUIA_String_Contents, &title);
- get(st2, MUIA_String_Contents, &group);
- get(st3, MUIA_String_Contents, &extension);
- strncpy(entry.title, title, MAXLENGTH_ENTRY);
- strncpy(entry.group, group, MAXLENGTH_ENTRY);
- strncpy(entry.extension, extension, MAXLENGTH_ENTRY);
- DoMethod(lv, MUIM_List_Insert, &entrypointer, 1, pos);
- set(lv, MUIA_List_Quiet, FALSE);
- set(lv, MUIA_List_Active, pos);
- }
-
- static void lv_copy(APTR lv, APTR st1, APTR st2, APTR st3)
- {
- struct NodeEntry *entry;
-
- DoMethod(lv, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &entry);
- set(st1, MUIA_String_Contents, entry->title);
- set(st2, MUIA_String_Contents, entry->group);
- set(st3, MUIA_String_Contents, entry->extension);
- set(MainWindow, MUIA_Window_ActiveObject, st1);
- }
-
-
- /**********************************************************************
- * Constructing and Destructing Hooks for Listviews *
- **********************************************************************/
- static __saveds __asm APTR DisplayFunc(register __a0 struct Hook *hook,
- register __a2 char **array,
- register __a1 struct NodeEntry *entry)
- {
- *array++ = entry->title;
- *array++ = entry->group;
- *array = entry->extension;
- return NULL;
- }
-
- static struct Hook DisplayHook =
- {
- {NULL, NULL},
- (HOOKFUNC) DisplayFunc,
- NULL, NULL
- };
-
- static __saveds __asm APTR ConstructFunc(register __a0 struct Hook *hook,
- register __a2 APTR mempool,
- register __a1 struct NodeEntry *data)
- {
- struct NodeEntry *new;
-
- if (new = (struct NodeEntry*) AllocMem(sizeof(struct NodeEntry), MEMF_ANY))
- *new = *data;
- return new;
- }
-
- static struct Hook ConstructHook =
- {
- {NULL, NULL},
- (HOOKFUNC) ConstructFunc,
- NULL, NULL
- };
-
- static __saveds __asm APTR DestructFunc(register __a0 struct Hook *hook,
- register __a2 APTR mempool,
- register __a1 struct NodeEntry *data)
- {
- FreeMem(data, sizeof(struct NodeEntry));
- return NULL;
- }
-
- static struct Hook DestructHook =
- {
- {NULL, NULL},
- (HOOKFUNC) DestructFunc,
- NULL, NULL
- };
-
-
- /**********************************************************************
- * Clear all *
- **********************************************************************/
- static void Clear_Cass(void)
- {
- setstring(ST_TitleA, "");
- setstring(ST_GroupA, "");
- setstring(ST_DateA, "");
- setcycle(CY_SourceA, 0);
- setcycle(CY_NoiseRA, 0);
- setstring(ST_TitleB, "");
- setstring(ST_GroupB, "");
- setstring(ST_DateB, "");
- setcycle(CY_SourceB, 0);
- setcycle(CY_NoiseRB, 0);
- setstring(ST_Number, "");
- setcycle(CY_Position, 1);
- setcycle(CY_Length, 2);
-
- DoMethod(LV_SideA, MUIM_List_Clear);
- ga_update(LV_SideA, GA_GaugeA);
- setstring(ST_ElementTitleA, "");
- setstring(ST_ElementGroupA, "");
- setstring(ST_ElementExtensionA, "");
- set(ST_ElementTitleA, MUIA_Disabled, TRUE);
- set(ST_ElementGroupA, MUIA_Disabled, TRUE);
- set(ST_ElementExtensionA, MUIA_Disabled, TRUE);
- set(BT_AddA, MUIA_Disabled, FALSE);
- set(BT_RemoveA, MUIA_Disabled, TRUE);
- set(BT_UpA, MUIA_Disabled, TRUE);
- set(BT_DownA, MUIA_Disabled, TRUE);
-
- DoMethod(LV_SideB, MUIM_List_Clear);
- ga_update(LV_SideB, GA_GaugeB);
- setstring(ST_ElementTitleB, "");
- setstring(ST_ElementGroupB, "");
- setstring(ST_ElementExtensionB, "");
- set(ST_ElementTitleB, MUIA_Disabled, TRUE);
- set(ST_ElementGroupB, MUIA_Disabled, TRUE);
- set(ST_ElementExtensionB, MUIA_Disabled, TRUE);
- set(BT_AddB, MUIA_Disabled, FALSE);
- set(BT_RemoveB, MUIA_Disabled, TRUE);
- set(BT_UpB, MUIA_Disabled, TRUE);
- set(BT_DownB, MUIA_Disabled, TRUE);
-
- filebuf_save[0] = '\0';
- settitle(NULL);
- }
-
-
- /**********************************************************************
- * File Handling *
- **********************************************************************/
- static void File_Cass(enum files filemode)
- {
- char *dirbuf;
- char *filebuf;
-
- struct Window *window;
- char pathbuf[256], linebuf[256];
- char *title;
- char *suffix = NULL;
- FILE *fh;
- struct FileRequester *frq;
- long i, end, end2;
- char *temp;
- struct NodeEntry entry = {"", ""}, *entrypointer = &entry;
- int saveflag = 0; /* Flag for saving without requester */
- int sourceside, destside;
-
- /* Put our Application to sleep while displaying the Requester */
- set(App, MUIA_Application_Sleep, TRUE);
-
- switch (filemode)
- {
- case ID_LOAD:
- title = GetLocaleString(MSG_LOAD_FILE);
- dirbuf = dirbuf_load;
- filebuf = filebuf_load;
- suffix = "#?.cas";
- break;
-
- case ID_LOAD_OLD:
- title = GetLocaleString(MSG_LOAD_OLD_FILE);
- dirbuf = dirbuf_load;
- filebuf = filebuf_load;
- suffix = "#?.cas";
- break;
-
- case ID_APPEND:
- title = GetLocaleString(MSG_APPEND_FILE);
- dirbuf = dirbuf_load;
- filebuf = filebuf_load;
- suffix = "#?.cas";
- break;
-
- case ID_SAVE:
- dirbuf = dirbuf_save;
- filebuf = filebuf_save;
- saveflag = 1;
- suffix = "#?.cas";
- break;
-
- case ID_SAVE_AS:
- title = GetLocaleString(MSG_SAVE_FILE);
- dirbuf = dirbuf_save;
- filebuf = filebuf_save;
- suffix = "#?.cas";
- break;
-
- case ID_GENERATE:
- title = GetLocaleString(MSG_GENERATE_FILE);
- dirbuf = dirbuf_generate;
- filebuf = filebuf_generate;
- suffix = "#?";
- break;
- }
-
- /* Get the Calling Objects Window */
- get(MainWindow, MUIA_Window_Window, &window);
-
- if (frq = MUI_AllocAslRequestTags(ASL_FileRequest, TAG_DONE))
- {
- if (!saveflag)
- {
- saveflag = MUI_AslRequestTags(frq,
- ASLFO_Window, window,
- ASLFO_PrivateIDCMP, TRUE,
- ASLFO_TitleText, title,
- ASLFO_InitialLeftEdge, window->LeftEdge + window->Width / 4,
- ASLFO_InitialTopEdge, window->TopEdge + window->Height / 8,
- ASLFO_InitialWidth, window->Width / 2,
- ASLFO_InitialHeight, window->Height * 6 / 8,
- ASLFR_DoPatterns, TRUE,
- ASLFR_InitialPattern, suffix,
- ASLFR_InitialFile, filebuf,
- ASLFR_InitialDrawer, dirbuf,
- ASLFR_RejectIcons, TRUE,
- TAG_DONE);
- /* Save directory and filename */
- stccpy(dirbuf, frq->fr_Drawer, 256);
- stccpy(filebuf, frq->fr_File, 64);
- }
- stccpy(pathbuf, dirbuf, 256);
- AddPart(pathbuf, filebuf, 256);
-
- if (saveflag)
- {
- switch (filemode)
- {
- case ID_LOAD:
- /*************
- * Load File *
- *************/
- if (fh = fopen(pathbuf, "r"))
- {
- /* Disable list refresh */
- set(LV_SideA, MUIA_List_Quiet, TRUE);
- set(LV_SideB, MUIA_List_Quiet, TRUE);
-
- /* Clear all entries */
- Clear_Cass();
- stccpy(dirbuf_save, dirbuf, 256);
- stccpy(filebuf_save, filebuf, 64);
- settitle(filebuf_save);
-
- fgets(linebuf, 256, fh);
- end = atoi(linebuf);
- if (end)
- {
- set(ST_ElementTitleA, MUIA_Disabled, FALSE);
- set(ST_ElementGroupA, MUIA_Disabled, FALSE);
- set(ST_ElementExtensionA, MUIA_Disabled, FALSE);
- set(BT_RemoveA, MUIA_Disabled, FALSE);
- set(BT_UpA, MUIA_Disabled, FALSE);
- set(BT_DownA, MUIA_Disabled, FALSE);
- }
- if (end == MAX_ENTRIES)
- set(BT_AddA, MUIA_Disabled, TRUE);
-
- for (i = 0; i < end; i++)
- {
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.title, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.group, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.extension, temp, 30);
- DoMethod(LV_SideA, MUIM_List_Insert, &entrypointer, 1,
- MUIV_List_Insert_Bottom);
- }
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_DateA, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_GroupA, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_TitleA, temp);
-
- fgets(linebuf, 256, fh);
- setcycle(CY_SourceA, atoi(linebuf));
- fgets(linebuf, 256, fh);
- setcycle(CY_NoiseRA, atoi(linebuf));
-
- fgets(linebuf, 256, fh);
- end = atoi(linebuf);
- if (end)
- {
- set(ST_ElementTitleB, MUIA_Disabled, FALSE);
- set(ST_ElementGroupB, MUIA_Disabled, FALSE);
- set(ST_ElementExtensionB, MUIA_Disabled, FALSE);
- set(BT_RemoveB, MUIA_Disabled, FALSE);
- set(BT_UpB, MUIA_Disabled, FALSE);
- set(BT_DownB, MUIA_Disabled, FALSE);
- }
- if (end == MAX_ENTRIES)
- set(BT_AddB, MUIA_Disabled, TRUE);
-
- for (i = 0; i < end; i++)
- {
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.title, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.group, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.extension, temp, 30);
- DoMethod(LV_SideB, MUIM_List_Insert, &entrypointer, 1,
- MUIV_List_Insert_Bottom);
- }
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_DateB, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_GroupB, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_TitleB, temp);
-
- fgets(linebuf, 256, fh);
- setcycle(CY_SourceB, atoi(linebuf));
- fgets(linebuf, 256, fh);
- setcycle(CY_NoiseRB, atoi(linebuf));
-
- fgets(linebuf, 256, fh);
- setcycle(CY_Position, atoi(linebuf));
- fgets(linebuf, 256, fh);
- setcycle(CY_Length, atoi(linebuf));
-
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_Number, temp);
-
- /* Refresh lists */
- set(LV_SideA, MUIA_List_Quiet, FALSE);
- set(LV_SideB, MUIA_List_Quiet, FALSE);
- set(LV_SideA, MUIA_List_Active, 0);
- set(LV_SideB, MUIA_List_Active, 0);
- DoMethod(LV_SideA, MUIM_List_Redraw, MUIV_List_Redraw_All);
- DoMethod(LV_SideB, MUIM_List_Redraw, MUIV_List_Redraw_All);
- ga_update(LV_SideA, GA_GaugeA);
- ga_update(LV_SideB, GA_GaugeB);
- fclose(fh);
- }
- break;
-
- case ID_LOAD_OLD:
- /*****************
- * Load old File *
- *****************/
- if (fh = fopen(pathbuf, "r"))
- {
- /* Disable list refresh */
- set(LV_SideA, MUIA_List_Quiet, TRUE);
- set(LV_SideB, MUIA_List_Quiet, TRUE);
-
- /* Clear all entries */
- Clear_Cass();
- stccpy(dirbuf_save, dirbuf, 256);
-
- fgets(linebuf, 256, fh);
- end = atoi(linebuf);
- if (end)
- {
- set(ST_ElementTitleA, MUIA_Disabled, FALSE);
- set(ST_ElementGroupA, MUIA_Disabled, FALSE);
- set(ST_ElementExtensionA, MUIA_Disabled, FALSE);
- set(BT_RemoveA, MUIA_Disabled, FALSE);
- set(BT_UpA, MUIA_Disabled, FALSE);
- set(BT_DownA, MUIA_Disabled, FALSE);
- }
- if (end == MAX_ENTRIES)
- set(BT_AddA, MUIA_Disabled, TRUE);
-
- for (i = 0; i < end; i++)
- {
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.title, temp, 30);
- DoMethod(LV_SideA, MUIM_List_Insert, &entrypointer, 1,
- MUIV_List_Insert_Bottom);
- }
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_DateA, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_GroupA, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_TitleA, temp);
-
- fgets(linebuf, 256, fh);
- setcycle(CY_SourceA, atoi(linebuf));
- fgets(linebuf, 256, fh);
- setcycle(CY_NoiseRA, atoi(linebuf));
-
- fgets(linebuf, 256, fh);
- end = atoi(linebuf);
- if (end)
- {
- set(ST_ElementTitleB, MUIA_Disabled, FALSE);
- set(ST_ElementGroupB, MUIA_Disabled, FALSE);
- set(ST_ElementExtensionB, MUIA_Disabled, FALSE);
- set(BT_RemoveB, MUIA_Disabled, FALSE);
- set(BT_UpB, MUIA_Disabled, FALSE);
- set(BT_DownB, MUIA_Disabled, FALSE);
- }
- if (end == MAX_ENTRIES)
- set(BT_AddB, MUIA_Disabled, TRUE);
-
- for (i = 0; i < end; i++)
- {
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.title, temp, 30);
- DoMethod(LV_SideB, MUIM_List_Insert, &entrypointer, 1,
- MUIV_List_Insert_Bottom);
- }
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_DateB, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_GroupB, temp);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_TitleB, temp);
-
- fgets(linebuf, 256, fh);
- setcycle(CY_SourceB, atoi(linebuf));
- fgets(linebuf, 256, fh);
- setcycle(CY_NoiseRB, atoi(linebuf));
-
- fgets(linebuf, 256, fh);
- setcycle(CY_Position, atoi(linebuf));
- fgets(linebuf, 256, fh);
- setcycle(CY_Length, atoi(linebuf));
-
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- setstring(ST_Number, temp);
-
- /* Refresh lists */
- set(LV_SideA, MUIA_List_Quiet, FALSE);
- set(LV_SideB, MUIA_List_Quiet, FALSE);
- set(LV_SideA, MUIA_List_Active, 0);
- set(LV_SideB, MUIA_List_Active, 0);
- DoMethod(LV_SideA, MUIM_List_Redraw, MUIV_List_Redraw_All);
- DoMethod(LV_SideB, MUIM_List_Redraw, MUIV_List_Redraw_All);
- ga_update(LV_SideA, GA_GaugeA);
- ga_update(LV_SideB, GA_GaugeB);
- fclose(fh);
- }
- break;
-
- case ID_APPEND:
- /***************
- * Append Side *
- ***************/
- sourceside = MUI_Request(App, MainWindow, 0,
- GetLocaleString(MSG_TITLE_SOURCE_SIDE),
- GetLocaleString(MSG_QUESTION_SIDE_BUTTONS),
- GetLocaleString(MSG_QUESTION_SOURCE_SIDE_TEXT));
- destside = MUI_Request(App, MainWindow, 0,
- GetLocaleString(MSG_TITLE_DEST_SIDE),
- GetLocaleString(MSG_QUESTION_SIDE_BUTTONS),
- GetLocaleString(MSG_QUESTION_DEST_SIDE_TEXT));
- /* Side A:=1, Side B:=0 */
-
- if (fh = fopen(pathbuf, "r"))
- {
- /* Disable list refresh */
- set(LV_SideA, MUIA_List_Quiet, TRUE);
- set(LV_SideB, MUIA_List_Quiet, TRUE);
-
- fgets(linebuf, 256, fh);
- end = atoi(linebuf);
- if (end)
- {
- set(destside ? ST_ElementTitleA : ST_ElementTitleB, MUIA_Disabled, FALSE);
- set(destside ? ST_ElementGroupA : ST_ElementGroupB, MUIA_Disabled, FALSE);
- set(destside ? ST_ElementExtensionA : ST_ElementExtensionB, MUIA_Disabled, FALSE);
- set(destside ? BT_RemoveA : BT_RemoveB, MUIA_Disabled, FALSE);
- set(destside ? BT_UpA : BT_UpB, MUIA_Disabled, FALSE);
- set(destside ? BT_DownA : BT_DownB, MUIA_Disabled, FALSE);
- }
- get(destside ? LV_SideA : LV_SideB, MUIA_List_Entries, &end2);
- for (i = 0; i < end; i++, end2++)
- {
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.title, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.group, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.extension, temp, 30);
- if (sourceside && end2 < MAX_ENTRIES)
- DoMethod(destside ? LV_SideA : LV_SideB,
- MUIM_List_Insert, &entrypointer, 1,
- MUIV_List_Insert_Bottom);
- }
- if (end2 >= MAX_ENTRIES)
- set(destside ? BT_AddA : BT_AddB, MUIA_Disabled, TRUE);
- fgets(linebuf, 256, fh);
- fgets(linebuf, 256, fh);
- fgets(linebuf, 256, fh);
-
- fgets(linebuf, 256, fh);
- fgets(linebuf, 256, fh);
-
- fgets(linebuf, 256, fh);
- end = atoi(linebuf);
- if (end)
- {
- set(destside ? ST_ElementTitleA : ST_ElementTitleB, MUIA_Disabled, FALSE);
- set(destside ? ST_ElementGroupA : ST_ElementGroupB, MUIA_Disabled, FALSE);
- set(destside ? ST_ElementExtensionA : ST_ElementExtensionB, MUIA_Disabled, FALSE);
- }
- get(destside ? LV_SideA : LV_SideB, MUIA_List_Entries, &end2);
- for (i = 0; i < end; i++, end2++)
- {
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.title, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.group, temp, 30);
- temp = fgets(linebuf, 256, fh);
- temp[strlen(temp) - 1] = '\0';
- stccpy(entry.extension, temp, 30);
- if (!sourceside && end2 < MAX_ENTRIES)
- DoMethod(destside ? LV_SideA : LV_SideB,
- MUIM_List_Insert, &entrypointer, 1,
- MUIV_List_Insert_Bottom);
- }
- if (end2 >= MAX_ENTRIES)
- set(destside ? BT_AddA : BT_AddB, MUIA_Disabled, TRUE);
- fclose(fh);
-
- /* Refresh lists */
- set(LV_SideA, MUIA_List_Quiet, FALSE);
- set(LV_SideB, MUIA_List_Quiet, FALSE);
- set(LV_SideA, MUIA_List_Active, 0);
- set(LV_SideB, MUIA_List_Active, 0);
- DoMethod(LV_SideA, MUIM_List_Redraw, MUIV_List_Redraw_All);
- DoMethod(LV_SideB, MUIM_List_Redraw, MUIV_List_Redraw_All);
- ga_update(LV_SideA, GA_GaugeA);
- ga_update(LV_SideB, GA_GaugeB);
- /* Activate String Gadget */
- set(MainWindow, MUIA_Window_ActiveObject, destside ? ST_ElementTitleA : ST_ElementTitleB);
- }
- break;
-
- case ID_SAVE:
- case ID_SAVE_AS:
- /*************
- * Save File *
- *************/
- settitle(filebuf_save);
- if (fh = fopen(pathbuf, "w"))
- {
- /* Get number of all entries of SideA */
- get(LV_SideA, MUIA_List_Entries, &end);
- fprintf(fh, "%ld\n", end);
-
- for (i = 0; i < end; i++)
- {
- DoMethod(LV_SideA, MUIM_List_GetEntry, i, &entrypointer);
- fprintf(fh, "%s\n%s\n%s\n", entrypointer->title, entrypointer->group, entrypointer->extension);
- }
-
- fprintf(fh, "%s\n", GetStr(ST_DateA));
- fprintf(fh, "%s\n", GetStr(ST_GroupA));
- fprintf(fh, "%s\n", GetStr(ST_TitleA));
- fprintf(fh, "%ld\n", GetCycle(CY_SourceA));
- fprintf(fh, "%ld\n", GetCycle(CY_NoiseRA));
-
- /* Get number of all entries of SideB */
- get(LV_SideB, MUIA_List_Entries, &end);
- fprintf(fh, "%ld\n", end);
-
- for (i = 0; i < end; i++)
- {
- DoMethod(LV_SideB, MUIM_List_GetEntry, i, &entrypointer);
- fprintf(fh, "%s\n%s\n%s\n", entrypointer->title, entrypointer->group, entrypointer->extension);
- }
-
- fprintf(fh, "%s\n", GetStr(ST_DateB));
- fprintf(fh, "%s\n", GetStr(ST_GroupB));
- fprintf(fh, "%s\n", GetStr(ST_TitleB));
- fprintf(fh, "%ld\n", GetCycle(CY_SourceB));
- fprintf(fh, "%ld\n", GetCycle(CY_NoiseRB));
-
- fprintf(fh, "%ld\n", GetCycle(CY_Position));
- fprintf(fh, "%ld\n", GetCycle(CY_Length));
- fprintf(fh, "%s\n", GetStr(ST_Number));
-
- fclose(fh);
- }
- break;
-
- case ID_GENERATE:
- /*****************
- * Generate File *
- *****************/
- stccpy(dirbuf_generate, dirbuf, 256);
- stccpy(filebuf_generate, filebuf, 64);
- generate_file(pathbuf);
- break;
- }
- }
- MUI_FreeAslRequest(frq);
- }
-
- /* Wake up our Application again */
- set(App, MUIA_Application_Sleep, FALSE);
- }
-
- /**********************************************************************
- * Set the Window title *
- **********************************************************************/
- void settitle(char *filename)
- {
- static char titlebuffer[256];
-
- strcpy(titlebuffer, "CassLabel " REVISION " - ");
- if (filename)
- strcat(titlebuffer, filename);
- else
- strcat(titlebuffer, "Unnamed");
- set(MainWindow, MUIA_Window_Title, titlebuffer);
- }
-
-
- /**********************************************************************
- * Main Program *
- **********************************************************************/
- int main(int argc, char *argv[])
- {
- BOOL running = TRUE;
- unsigned long signal, open;
- char keychar[20]; /* Enough place for key shortcuts */
-
- if (argc)
- {
- /* Shell startup */
- char *temp;
- int length;
-
- GetProgramName(programpath, 256);
- temp = PathPart(programpath);
- length = temp - programpath;
- if (length > 1)
- {
- strncpy(pathname, programpath, length);
- pathname[length] = '/';
- pathname[length + 1] = '\0';
- }
- else
- pathname[0] = '\0';
- }
- else
- {
- /* Workbench startup */
- struct WBStartup *WBenchMsg = (struct WBStartup *) argv;
- BPTR tmplock;
-
- programname = WBenchMsg->sm_ArgList->wa_Name;
- tmplock = Lock(programname, ACCESS_READ);
- NameFromLock(tmplock, programpath, 256);
- UnLock(tmplock);
- pathname[0] = '\0';
- }
-
- /* Get real program name */
- programname = FilePart(programpath);
-
- /* Correct the path for the cassettes-files */
- strcpy(dirbuf_load, pathname);
- strcat(dirbuf_load, "Cassettes");
- strcpy(dirbuf_save, dirbuf_load);
-
- /* Get disk object */
- diskobj = GetDiskObject(programpath);
-
- /* Try to open locale - if no success, english texts are used! */
- if (LocaleBase = OpenLibrary("locale.library", 38))
- CassLabelCatalog = OpenCatalogA(NULL, "CassLabel.catalog", NULL);
-
- if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, 7)))
- fail(NULL, "Failed to open " MUIMASTER_NAME ".");
-
- /* Fill the localized strings into the menu structure */
- Menu[0].nm_Label = GetLocaleString(MSG_MENU_PROJECT);
- Menu[1].nm_Label = GetLocaleString(MSG_MENU_NEW);
- Menu[2].nm_Label = GetLocaleString(MSG_MENU_LOAD);
- Menu[2].nm_CommKey = GetLocaleString(MSG_MENU_LOAD_SHORTCUT);
- Menu[3].nm_Label = GetLocaleString(MSG_MENU_LOAD_OLD_FORMAT);
- Menu[4].nm_Label = GetLocaleString(MSG_MENU_APPEND);
- Menu[5].nm_Label = GetLocaleString(MSG_MENU_SAVE);
- Menu[5].nm_CommKey = GetLocaleString(MSG_MENU_SAVE_SHORTCUT);
- Menu[6].nm_Label = GetLocaleString(MSG_MENU_SAVE_AS);
- Menu[8].nm_Label = GetLocaleString(MSG_MENU_PREFERENCES);
- Menu[10].nm_Label = GetLocaleString(MSG_MENU_GENERATE);
- Menu[10].nm_CommKey = GetLocaleString(MSG_MENU_GENERATE_SHORTCUT);
- Menu[11].nm_Label = GetLocaleString(MSG_MENU_PRINT);
- Menu[11].nm_CommKey = GetLocaleString(MSG_MENU_PRINT_SHORTCUT);
- Menu[13].nm_Label = GetLocaleString(MSG_MENU_ABOUT);
- Menu[13].nm_CommKey = GetLocaleString(MSG_MENU_ABOUT_SHORTCUT);
- Menu[14].nm_Label = GetLocaleString(MSG_MENU_QUIT);
- Menu[14].nm_CommKey = GetLocaleString(MSG_MENU_QUIT_SHORTCUT);
-
- /* The Register titles */
- Pages[0] = GetLocaleString(MSG_LABEL_GLOBAL);
- Pages[1] = GetLocaleString(MSG_LABEL_SIDEA);
- Pages[2] = GetLocaleString(MSG_LABEL_SIDEB);
-
- /* Trouble with pointer conversion, so going this way */
- keychar[0] = *GetLocaleString(MSG_LABEL_POSITION_SHORTCUT);
- keychar[1] = *GetLocaleString(MSG_LABEL_LENGTH_SHORTCUT);
- keychar[2] = *GetLocaleString(MSG_LABEL_NUMBER_SHORTCUT);
- keychar[3] = *GetLocaleString(MSG_LABEL_ADD_SHORTCUT);
- keychar[4] = *GetLocaleString(MSG_LABEL_REMOVE_SHORTCUT);
- keychar[5] = *GetLocaleString(MSG_LABEL_UP_SHORTCUT);
- keychar[6] = *GetLocaleString(MSG_LABEL_DOWN_SHORTCUT);
- keychar[7] = *GetLocaleString(MSG_LABEL_PREFS_SAVE_SHORTCUT);
- keychar[8] = *GetLocaleString(MSG_LABEL_PREFS_OK_SHORTCUT);
- keychar[9] = *GetLocaleString(MSG_LABEL_PREFS_CANCEL_SHORTCUT);
- keychar[10] = *GetLocaleString(MSG_LABEL_PREFS_FORMAT_SHORTCUT);
- keychar[11] = *GetLocaleString(MSG_LABEL_PREFS_DRIVER_SHORTCUT);
- keychar[12] = *GetLocaleString(MSG_LABEL_PREFS_TR_SHORTCUT);
- keychar[13] = *GetLocaleString(MSG_LABEL_PREFS_HELP_SHORTCUT);
-
- App = ApplicationObject,
- MUIA_Application_Title, "CassLabel",
- MUIA_Application_Version, "$VER: CassLabel " REVISION " " __AMIGADATE__,
- MUIA_Application_Copyright, GetLocaleString(MSG_ABOUT_COPYRIGHT),
- MUIA_Application_Author, "Dirk Nehring",
- MUIA_Application_Description, GetLocaleString(MSG_ABOUT_PROGRAM),
- MUIA_Application_Base, "CassLabel",
- MUIA_Application_SingleTask, TRUE,
- MUIA_Application_Menu, Menu,
- MUIA_Application_DiskObject, diskobj,
- MUIA_HelpFile, GUIDEFILE,
-
- SubWindow, MainWindow = WindowObject,
- MUIA_Window_ID, MAKE_ID('M', 'A', 'I', 'N'),
- MUIA_HelpNode, NODE_MAIN,
- WindowContents, VGroup,
- Child, TextObject,
- TextFrame,
- MUIA_Background, MUII_FILLBACK,
- MUIA_Text_Contents, GetLocaleString(MSG_WINDOW_TITLE),
- End,
- Child, VSpace(2),
- Child, RegisterGroup(Pages),
- Child, VGroup,
- Child, ColGroup(2), GroupFrameT(GetLocaleString(MSG_LABEL_SIDEA)),
- Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
- Child, ST_TitleA = StringObject,
- StringFrame,
- MUIA_String_MaxLen, MAXLENGTH_ENTRY,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
- Child, ST_GroupA = StringObject,
- StringFrame,
- MUIA_String_MaxLen, MAXLENGTH_ENTRY,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_DATE)),
- Child, HGroup,
- Child, ST_DateA = StringObject,
- MUIA_String_Accept, "1234567890.",
- MUIA_String_MaxLen, 11,
- MUIA_FixWidthTxt, "00.00.00000",
- StringFrame,
- End,
- Child, HSpace(0),
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_SOURCE)),
- Child, HGroup,
- Child, CY_SourceA = KeyCycle(CYA_Source, 0),
- Child, Label2(GetLocaleString(MSG_LABEL_NOISER)),
- Child, CY_NoiseRA = KeyCycle(CYA_NoiseR, 0),
- End,
- End,
- Child, VSpace(0),
- Child, ColGroup(2), GroupFrameT(GetLocaleString(MSG_LABEL_SIDEB)),
- Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
- Child, ST_TitleB = StringObject,
- StringFrame,
- MUIA_String_MaxLen, MAXLENGTH_ENTRY,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
- Child, ST_GroupB = StringObject,
- StringFrame,
- MUIA_String_MaxLen, MAXLENGTH_ENTRY,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_DATE)),
- Child, HGroup,
- Child, ST_DateB = StringObject,
- MUIA_String_Accept, "1234567890.",
- MUIA_String_MaxLen, 11,
- MUIA_FixWidthTxt, "00.00.00000",
- StringFrame,
- End,
- Child, HSpace(0),
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_SOURCE)),
- Child, HGroup,
- Child, CY_SourceB = KeyCycle(CYA_Source, 0),
- Child, Label2(GetLocaleString(MSG_LABEL_NOISER)),
- Child, CY_NoiseRB = KeyCycle(CYA_NoiseR, 0),
- End,
- End,
- Child, VSpace(0),
- Child, VSpace(0),
- Child, HGroup, GroupFrame,
- Child, KeyLabel2(GetLocaleString(MSG_LABEL_POSITION), keychar[0]),
- Child, CY_Position = KeyCycle(CYA_Position, keychar[0]),
- Child, KeyLabel2(GetLocaleString(MSG_LABEL_LENGTH), keychar[1]),
- Child, CY_Length = KeyCycle(CYA_Length, keychar[1]),
- Child, KeyLabel2(GetLocaleString(MSG_LABEL_NUMBER), keychar[2]),
- Child, ST_Number = StringObject,
- MUIA_ControlChar, keychar[2],
- MUIA_String_Accept, "1234567890",
- MUIA_String_MaxLen, 4,
- MUIA_FixWidthTxt, "0000",
- StringFrame,
- End,
- End,
- End,
- Child, VGroup,
- Child, HGroup,
- Child, GA_GaugeA = GaugeObject,
- GaugeFrame,
- MUIA_FixWidth, 8,
- MUIA_Gauge_Max, MAX_ENTRIES,
- End,
- Child, LV_SideA = ListviewObject,
- MUIA_Listview_Input, TRUE,
- MUIA_Listview_List, ListObject,
- InputListFrame,
- MUIA_List_ConstructHook, &ConstructHook,
- MUIA_List_DestructHook, &DestructHook,
- MUIA_List_DisplayHook, &DisplayHook,
- MUIA_List_Format, "MAW=100,P=\033r D=8, P=\033r\0338",
- End,
- End,
- End,
- Child, HGroup, GroupSpacing(0), MUIA_Group_SameSize, TRUE,
- Child, BT_AddA = KeyButton(GetLocaleString(MSG_LABEL_ADD), keychar[3]),
- Child, BT_RemoveA = KeyButton(GetLocaleString(MSG_LABEL_REMOVE), keychar[4]),
- Child, BT_UpA = KeyButton(GetLocaleString(MSG_LABEL_UP), keychar[5]),
- Child, BT_DownA = KeyButton(GetLocaleString(MSG_LABEL_DOWN), keychar[6]),
- End,
- Child, ColGroup(2),
- Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
- Child, ST_ElementTitleA = StringObject,
- StringFrame,
- MUIA_String_MaxLen, MAXLENGTH_ENTRY,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
- Child, ST_ElementGroupA = StringObject,
- StringFrame,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_EXTENSION)),
- Child, ST_ElementExtensionA = StringObject,
- StringFrame,
- End,
- End,
- End,
- Child, VGroup,
- Child, HGroup,
- Child, GA_GaugeB = GaugeObject,
- GaugeFrame,
- MUIA_FixWidth, 8,
- MUIA_Gauge_Max, MAX_ENTRIES,
- End,
- Child, LV_SideB = ListviewObject,
- MUIA_Listview_Input, TRUE,
- MUIA_Listview_List, ListObject,
- InputListFrame,
- MUIA_List_ConstructHook, &ConstructHook,
- MUIA_List_DestructHook, &DestructHook,
- MUIA_List_DisplayHook, &DisplayHook,
- MUIA_List_Format, "MAW=100,P=\033r D=8,P=\033r\0338",
- End,
- End,
- End,
- Child, HGroup, GroupSpacing(0), MUIA_Group_SameSize, TRUE,
- Child, BT_AddB = KeyButton(GetLocaleString(MSG_LABEL_ADD), keychar[3]),
- Child, BT_RemoveB = KeyButton(GetLocaleString(MSG_LABEL_REMOVE), keychar[4]),
- Child, BT_UpB = KeyButton(GetLocaleString(MSG_LABEL_UP), keychar[5]),
- Child, BT_DownB = KeyButton(GetLocaleString(MSG_LABEL_DOWN), keychar[6]),
- End,
- Child, ColGroup(2),
- Child, Label2(GetLocaleString(MSG_LABEL_TITLE)),
- Child, ST_ElementTitleB = StringObject,
- StringFrame,
- MUIA_String_MaxLen, MAXLENGTH_ENTRY,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_GROUP)),
- Child, ST_ElementGroupB = StringObject,
- StringFrame,
- End,
- Child, Label2(GetLocaleString(MSG_LABEL_EXTENSION)),
- Child, ST_ElementExtensionB = StringObject,
- StringFrame,
- End,
- End,
- End,
- End,
- End,
- End,
- SubWindow, PrefsWindow = WindowObject,
- MUIA_Window_Title, GetLocaleString(MSG_LABEL_PREFS_TITLE),
- MUIA_Window_ID, MAKE_ID('P', 'R', 'E', 'F'),
- MUIA_Window_NoMenus, TRUE,
- MUIA_HelpNode, NODE_PREFS,
- WindowContents, VGroup,
- Child, VGroup,
- Child, ColGroup(2), GroupFrame,
- Child, KeyLabel2(GetLocaleString(MSG_LABEL_PREFS_FORMAT), keychar[10]),
- Child, PS_PopFormat = PopaslObject,
- MUIA_Popstring_String, PS_PopFormat_String = StringObject,
- StringFrame,
- MUIA_ControlChar, keychar[10],
- MUIA_String_MaxLen, 256,
- MUIA_ExportID, 1,
- End,
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText, GetLocaleString(MSG_LABEL_PREFS_FORMAT),
- ASLFR_DoPatterns, TRUE,
- ASLFR_InitialPattern, "#?.form",
- End,
- Child, KeyLabel2(GetLocaleString(MSG_LABEL_PREFS_DRIVER), keychar[11]),
- Child, PS_PopDriver = PopaslObject,
- MUIA_Popstring_String, PS_PopDriver_String = StringObject,
- StringFrame,
- MUIA_ControlChar, keychar[11],
- MUIA_String_MaxLen, 256,
- MUIA_ExportID, 2,
- End,
- MUIA_Popstring_Button, PopButton(MUII_PopFile),
- ASLFR_TitleText, GetLocaleString(MSG_LABEL_PREFS_DRIVER),
- ASLFR_DoPatterns, TRUE,
- ASLFR_InitialPattern, "#?.drv",
- End,
- Child, KeyLabel1(GetLocaleString(MSG_LABEL_PREFS_TR), keychar[12]),
- Child, HGroup,
- Child, CM_Translate = ImageObject,
- ImageButtonFrame,
- MUIA_InputMode, MUIV_InputMode_Toggle,
- MUIA_Image_Spec, MUII_CheckMark,
- MUIA_Background, MUII_ButtonBack,
- MUIA_ShowSelState, FALSE,
- MUIA_ControlChar, keychar[12],
- MUIA_ExportID, 3,
- End,
- Child, HSpace(0),
- Child, BT_PrefsHelp = KeyButton(GetLocaleString(MSG_LABEL_PREFS_HELP), keychar[13]),
- End,
- End,
- Child, HGroup, GroupFrame, MUIA_Group_SameSize, TRUE,
- Child, BT_PrefsSave = KeyButton(GetLocaleString(MSG_LABEL_PREFS_SAVE), keychar[7]),
- Child, BT_PrefsOK = KeyButton(GetLocaleString(MSG_LABEL_PREFS_OK), keychar[8]),
- Child, BT_PrefsCancel = KeyButton(GetLocaleString(MSG_LABEL_PREFS_CANCEL), keychar[9]),
- End,
- End,
- End,
- End,
- End;
-
- /* Error when we declare the Application? */
- if (!App)
- fail(App, GetLocaleString(MSG_ERROR_APP));
-
- /**************
- * MainWindow *
- **************/
- /* Close Connection */
- DoMethod(MainWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
- MUIM_Application_ReturnID, ID_QUIT);
- DoMethod(MainWindow, MUIM_Notify, MUIA_Window_InputEvent, "control c",
- App, 2, MUIM_Application_ReturnID, ID_QUIT);
-
- /* Control the list manipulation buttons */
- DoMethod(LV_SideA, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, App, 2,
- MUIM_Application_ReturnID, ID_LISTA);
- DoMethod(ST_ElementTitleA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- App, 2, MUIM_Application_ReturnID, ID_ELEMENTTITLEA);
- DoMethod(ST_ElementGroupA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- App, 2, MUIM_Application_ReturnID, ID_ELEMENTGROUPA);
- DoMethod(ST_ElementExtensionA, MUIM_Notify, MUIA_String_Acknowledge,
- MUIV_EveryTime, App, 2, MUIM_Application_ReturnID, ID_ELEMENTEXTENSIONA);
- DoMethod(BT_AddA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_ADDA);
- DoMethod(BT_RemoveA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_REMOVEA);
- DoMethod(BT_UpA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_UPA);
- DoMethod(BT_DownA, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_DOWNA);
-
- DoMethod(LV_SideB, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, App, 2,
- MUIM_Application_ReturnID, ID_LISTB);
- DoMethod(ST_ElementTitleB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- App, 2, MUIM_Application_ReturnID, ID_ELEMENTTITLEB);
- DoMethod(ST_ElementGroupB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- App, 2, MUIM_Application_ReturnID, ID_ELEMENTGROUPB);
- DoMethod(ST_ElementExtensionB, MUIM_Notify, MUIA_String_Acknowledge,
- MUIV_EveryTime, App, 2, MUIM_Application_ReturnID, ID_ELEMENTEXTENSIONB);
- DoMethod(BT_AddB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_ADDB);
- DoMethod(BT_RemoveB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_REMOVEB);
- DoMethod(BT_UpB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_UPB);
- DoMethod(BT_DownB, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_DOWNB);
-
- /* Cycle chain for keyboard control */
- DoMethod(MainWindow, MUIM_Window_SetCycleChain, ST_TitleA, ST_GroupA,
- ST_DateA, CY_SourceA, CY_NoiseRA, ST_TitleB, ST_GroupB,
- ST_DateB, CY_SourceB, CY_NoiseRB, CY_Position, CY_Length,
- ST_Number, ST_ElementTitleA, ST_ElementGroupA,ST_ElementExtensionA,
- BT_AddA, BT_RemoveA, BT_UpA, BT_DownA, ST_ElementTitleB,
- ST_ElementGroupB, ST_ElementExtensionB, BT_AddB, BT_RemoveB, BT_UpB,
- BT_DownB, NULL);
-
- DoMethod(PrefsWindow, MUIM_Window_SetCycleChain, PS_PopFormat,
- PS_PopDriver, CM_Translate, BT_PrefsSave, BT_PrefsOK, BT_PrefsCancel,
- NULL);
-
- /* Concatenate strings, <return> will activate the next one */
- DoMethod(ST_TitleA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_GroupA);
- DoMethod(ST_GroupA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_DateA);
- DoMethod(ST_DateA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_TitleB);
- DoMethod(ST_TitleB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_GroupB);
- DoMethod(ST_GroupB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_DateB);
- DoMethod(ST_DateB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_Number);
- DoMethod(ST_Number, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_TitleA);
-
- DoMethod(ST_ElementTitleA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementGroupA);
- DoMethod(ST_ElementGroupA, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementExtensionA);
- DoMethod(ST_ElementTitleB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementGroupB);
- DoMethod(ST_ElementGroupB, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, ST_ElementExtensionB);
-
- DoMethod(PS_PopFormat, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, PS_PopDriver);
- DoMethod(PS_PopDriver, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
- MainWindow, 3, MUIM_Set, MUIA_Window_ActiveObject, PS_PopFormat);
-
- /* Load the settings */
- DoMethod(App, MUIM_Application_Load, MUIV_Application_Load_ENV);
-
- /***************
- * PrefsWindow *
- ***************/
- /* Close Request */
- DoMethod(PrefsWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
- MUIM_Application_ReturnID, ID_PREFS_QUIT);
-
- /* On OK, first save the prefs to ENV: */
- DoMethod(BT_PrefsOK, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_Save, MUIV_Application_Save_ENV);
-
- /* Then quit the preferences */
- DoMethod(BT_PrefsOK, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_PREFS_QUIT);
-
- /* On SAVE, save both to ENV: and ENVARC: */
- DoMethod(BT_PrefsSave, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_Save, MUIV_Application_Save_ENV);
- DoMethod(BT_PrefsSave, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_Save, MUIV_Application_Save_ENVARC);
-
- /* Then quit the preferences */
- DoMethod(BT_PrefsSave, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_PREFS_QUIT);
-
- /* On Cancel, simply close the window */
- DoMethod(BT_PrefsCancel, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_PREFS_QUIT);
-
- /* Help on Format */
- DoMethod(BT_PrefsHelp, MUIM_Notify, MUIA_Pressed, FALSE, App, 2,
- MUIM_Application_ReturnID, ID_PREFS_HELP);
-
- /********************
- * Startup Settings *
- ********************/
- set(LV_SideA, MUIA_List_Active, 0);
- set(LV_SideB, MUIA_List_Active, 0);
- set(ST_ElementTitleA, MUIA_String_AttachedList, LV_SideA);
- set(ST_ElementGroupA, MUIA_String_AttachedList, LV_SideA);
- set(ST_ElementExtensionA, MUIA_String_AttachedList, LV_SideA);
- set(ST_ElementTitleB, MUIA_String_AttachedList, LV_SideB);
- set(ST_ElementGroupB, MUIA_String_AttachedList, LV_SideB);
- set(ST_ElementExtensionB, MUIA_String_AttachedList, LV_SideB);
- set(ST_ElementTitleA, MUIA_Disabled, TRUE);
- set(ST_ElementGroupA, MUIA_Disabled, TRUE);
- set(ST_ElementExtensionA, MUIA_Disabled, TRUE);
- set(BT_RemoveA, MUIA_Disabled, TRUE);
- set(BT_UpA, MUIA_Disabled, TRUE);
- set(BT_DownA, MUIA_Disabled, TRUE);
- set(ST_ElementTitleB, MUIA_Disabled, TRUE);
- set(ST_ElementGroupB, MUIA_Disabled, TRUE);
- set(ST_ElementExtensionB, MUIA_Disabled, TRUE);
- set(BT_RemoveB, MUIA_Disabled, TRUE);
- set(BT_UpB, MUIA_Disabled, TRUE);
- set(BT_DownB, MUIA_Disabled, TRUE);
- setcycle(CY_Position, 1);
- setcycle(CY_Length, 2);
- set(MainWindow, MUIA_Window_Open, TRUE);
- settitle(NULL);
-
- /* Is the Main Window opened? */
- get(MainWindow, MUIA_Window_Open, &open);
- if (!open)
- fail(App, GetLocaleString(MSG_ERROR_WINDOW));
-
- /*****************
- * IDMCP-Handler *
- *****************/
- while (running)
- {
- switch (DoMethod(App, MUIM_Application_Input, &signal))
- {
- case ID_QUIT:
- case MUIV_Application_ReturnID_Quit:
- if (MUI_Request(App, MainWindow, 0, NULL,
- GetLocaleString(MSG_QUESTION_QUIT_BUTTONS),
- GetLocaleString(MSG_QUESTION_QUIT_TEXT)))
- running = FALSE;
- break;
-
- case ID_NEW:
- Clear_Cass();
- break;
-
- case ID_LOAD:
- File_Cass(ID_LOAD);
- break;
-
- case ID_LOAD_OLD:
- File_Cass(ID_LOAD_OLD);
- break;
-
- case ID_APPEND:
- File_Cass(ID_APPEND);
- break;
-
- case ID_SAVE:
- if (filebuf_save[0] != '\0')
- File_Cass(ID_SAVE);
- else
- File_Cass(ID_SAVE_AS);
- break;
-
- case ID_SAVE_AS:
- File_Cass(ID_SAVE_AS);
- break;
-
- case ID_GENERATE:
- File_Cass(ID_GENERATE);
- break;
-
- case ID_PRINT:
- print();
- break;
-
- case ID_ABOUT:
- MUI_Request(App, MainWindow, 0, GetLocaleString(MSG_MENU_ABOUT), "*OK",
- "\033c\0338CassLabel\0332\n\n"
- "\0332CassLabel V" REVISION " (" REVDATE ", " REVTIME " )"
- "\n%s%s%s%s%s%s%s%s",
- GetLocaleString(MSG_ABOUT_COPYRIGHT),
- "\n\nDirk Nehring\n",
- "Hörster Bruch 57\n",
- "D-32791 Lage\n",
- "GERMANY\n",
- "Phone: +49-5232-89130\n",
- "E-Mail: dnehring@TechFak.Uni-Bielefeld.DE\n\n",
- GetLocaleString(MSG_ABOUT_MUIAPPLICATION),
- GetLocaleString(MSG_ABOUT_MUICOPYRIGHT));
- break;
-
- case ID_LISTA:
- {
- long end;
- get(LV_SideA, MUIA_List_Entries, &end);
- if (end)
- lv_copy(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA);
- else
- {
- setstring(ST_ElementTitleA, "");
- setstring(ST_ElementGroupA, "");
- setstring(ST_ElementExtensionA, "");
- }
- }
- break;
-
- case ID_ELEMENTTITLEA:
- case ID_ELEMENTGROUPA:
- case ID_ELEMENTEXTENSIONA:
- lv_edit(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA);
- break;
-
- case ID_REMOVEA:
- lv_remove(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA, BT_AddA, BT_RemoveA, BT_UpA, BT_DownA, GA_GaugeA);
- break;
-
- case ID_ADDA:
- lv_add(LV_SideA, ST_ElementTitleA, ST_ElementGroupA, ST_ElementExtensionA, BT_AddA, BT_RemoveA, BT_UpA, BT_DownA, GA_GaugeA);
- break;
-
- case ID_UPA:
- lv_up(LV_SideA);
- break;
-
- case ID_DOWNA:
- lv_down(LV_SideA);
- break;
-
- case ID_LISTB:
- {
- long end;
- get(LV_SideB, MUIA_List_Entries, &end);
- if (end)
- lv_copy(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB);
- else
- {
- setstring(ST_ElementTitleB, "");
- setstring(ST_ElementGroupB, "");
- setstring(ST_ElementExtensionB, "");
- }
- }
- break;
-
- case ID_ELEMENTTITLEB:
- case ID_ELEMENTGROUPB:
- case ID_ELEMENTEXTENSIONB:
- lv_edit(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB);
- break;
-
- case ID_REMOVEB:
- lv_remove(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB, BT_AddB, BT_RemoveB, BT_UpB, BT_DownB, GA_GaugeB);
- break;
-
- case ID_ADDB:
- lv_add(LV_SideB, ST_ElementTitleB, ST_ElementGroupB, ST_ElementExtensionB, BT_AddB, BT_RemoveB, BT_UpB, BT_DownB, GA_GaugeB);
- break;
-
- case ID_UPB:
- lv_up(LV_SideB);
- break;
-
- case ID_DOWNB:
- lv_down(LV_SideB);
- break;
-
- case ID_PREFS:
- set(PrefsWindow, MUIA_Window_Open, TRUE);
- break;
-
- case ID_PREFS_QUIT:
- set(PrefsWindow, MUIA_Window_Open, FALSE);
- DoMethod(App, MUIM_Application_Load, MUIV_Application_Load_ENV);
- set(MainWindow, MUIA_Window_Activate, TRUE);
- break;
-
- case ID_PREFS_HELP:
- MUI_Request(App, MainWindow, 0, GetLocaleString(MSG_LABEL_PREFS_HELP), "*OK",
- "\033c\0338CassLabel Format Documentation\0332\n\n"
- "\033l\033bASCII:\033n Very naiv output\n"
- "\033bStandard:\033n Date/NR/Src on the same page as the songs\n"
- "\033bEnhanced:\033n Date/NR/Src on the back side\n"
- "\033bRotated:\033n Cover is rotated by 180 degrees, but like Enhanced\n\n"
- "\033c\0338The format filename\0332\n"
- "\033l_{1|2|T|G|E} means\n"
- "1: One group/title\n"
- "2: Two groups/titles\n"
- "T: songs\n"
- "G: groups\n"
- "E: extensions\n\n"
- "\033c\0338Examples\0332\n"
- "\033l\033bLaTeX-Standard_2+T+G\033n means 2 titles on top side and\n"
- "every song has a group separatly\n"
- "\033bASCII_1+T+E\033n means 1 group/title on the top side and\n"
- "every song has an extension, but no group\n");
- break;
- }
- if (running && signal)
- Wait(signal);
- }
- fail(App, NULL);
- }
-