add system build to autoconf/automake
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindow.C
index 890aaac6b46261ef70b4ced6b4905490c5e7b653..dcca2ca75d6470512a18bc2ff26fd1ccf1555b46 100644 (file)
@@ -369,7 +369,7 @@ void MWindow::create_defaults_path(char *string, const char *config_file)
 // set the .bcast path
        FileSystem fs;
 
-       sprintf(string, "%s", BCASTDIR);
+       sprintf(string, "%s/", File::get_config_path());
        fs.complete_path(string);
        if(!fs.is_dir(string))
                fs.create_dir(string);
@@ -379,43 +379,46 @@ void MWindow::create_defaults_path(char *string, const char *config_file)
 }
 const char *MWindow::default_std()
 {
-       int fd, i, l = 0;
-       char buf[BCTEXTLEN];
-        char *p;
+       char buf[BCTEXTLEN], *p = 0;
 
-       if((fd = open(TIMEZONE_NAME, O_RDONLY)) >= 0)
-       {
-               l = read(fd, buf, BCTEXTLEN);
+       int fd = open(TIMEZONE_NAME, O_RDONLY);
+       if( fd >= 0 ) {
+               int l = read(fd, buf, sizeof(buf)-1);
                close(fd);
-               if(l > 0)
-               {
+               if( l > 0 ) {
+                       if( buf[l-1] == '\n' ) --l;
                        buf[l] = 0;
-                       if(buf[l - 1] == '\n')
-                               buf[--l] = 0;
+                       p = buf;
                }
-               p = buf;
        }
-       if(l < 1)
-       {
-               if((l = readlink(LOCALTIME_LINK, buf, BCTEXTLEN)) > 0)
-               {
+       if( !p ) {
+               int l = readlink(LOCALTIME_LINK, buf, sizeof(buf)-1);
+               if( l > 0 ) {
                        buf[l] = 0;
-                       if( (p=strstr(buf, ZONEINFO_STR)) != 0 )
-                       {
-                               p += strlen(ZONEINFO_STR);
-                               l = strlen(p);
-                       }
-                       else
-                               l = 0;
+                       if( !(p=strstr(buf, ZONEINFO_STR)) != 0 ) return "PAL";
+                       p += strlen(ZONEINFO_STR);
                }
        }
-       if(l)
-       {
-               for(i = 0; ntsc_zones[i]; i++)
-               if(strcmp(ntsc_zones[i], p) == 0)
-                       return "NTSC";
+
+       if( p ) {
+               for( int i=0; ntsc_zones[i]; ++i ) {
+                       if( !strcmp(ntsc_zones[i], p) )
+                               return "NTSC";
+               }
+       }
+
+       p = getenv("TZ");
+       if( p ) {
+               for( int i=0; ntsc_zones[i]; ++i ) {
+                       if( !strcmp(ntsc_zones[i], p) )
+                               return "NTSC";
+               }
        }
-       return "PAL";
+
+//__timezone: Seconds west of UTC.  240sec/deg
+       double tz_deg = -__timezone / 240.;
+// from Honolulu = -10, to New York = -5, 15deg/hr   lat -150..-75
+       return tz_deg >= -10*15 && tz_deg <= -5*15 ? "NTSC" : "PAL";
 }
 
 void MWindow::fill_preset_defaults(const char *preset, EDLSession *session)
@@ -424,7 +427,7 @@ void MWindow::fill_preset_defaults(const char *preset, EDLSession *session)
 
        for(fpr = &format_presets[0]; fpr->name; fpr++)
        {
-               if(strcmp(fpr->name, preset) == 0)
+               if(strcmp(_(fpr->name), preset) == 0)
                {
                        session->audio_channels = fpr->audio_channels;
                        session->audio_tracks = fpr->audio_tracks;
@@ -447,7 +450,7 @@ const char *MWindow::get_preset_name(int index)
 {
        if(index < 0 || index >= (int)MAX_NUM_PRESETS)
                return "Error";
-       return format_presets[index].name;
+       return _(format_presets[index].name);
 }
 
 
@@ -594,8 +597,7 @@ int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
        char *path = getenv("LADSPA_PATH");
        char ladspa_path[BCTEXTLEN];
        if( !path ) {
-               get_exe_path(ladspa_path);
-               strcat(ladspa_path, "/ladspa");
+               strncpy(ladspa_path, File::get_ladspa_path(), sizeof(ladspa_path));
                path = ladspa_path;
        }
        for( int len=0; *path; path+=len ) {
@@ -2873,17 +2875,19 @@ void MWindow::save_backup()
        FileXML file;
        edl->optimize();
        edl->set_path(session->filename);
-       edl->save_xml(&file, BACKUP_PATH, 0, 0);
+       char backup_path[BCTEXTLEN];
+       snprintf(backup_path, sizeof(backup_path), "%s/%s",
+               File::get_config_path(), BACKUP_FILE);
+       edl->save_xml(&file, backup_path, 0, 0);
        file.terminate_string();
        char path[BCTEXTLEN];
        FileSystem fs;
-       strcpy(path, BACKUP_PATH);
-       fs.complete_path(path);
+       fs.complete_path(backup_path);
 
-       if(file.write_to_file(path))
+       if(file.write_to_file(backup_path))
        {
                char string2[256];
-               sprintf(string2, _("Couldn't open %s for writing."), BACKUP_PATH);
+               sprintf(string2, _("Couldn't open %s for writing."), backup_path);
                gui->show_message(string2);
        }
 }
@@ -2893,13 +2897,14 @@ void MWindow::load_backup()
        ArrayList<char*> path_list;
        path_list.set_array_delete();
        char *out_path;
-       char string[BCTEXTLEN];
-       strcpy(string, BACKUP_PATH);
+       char backup_path[BCTEXTLEN];
+       snprintf(backup_path, sizeof(backup_path), "%s/%s",
+               File::get_config_path(), BACKUP_FILE);
        FileSystem fs;
-       fs.complete_path(string);
+       fs.complete_path(backup_path);
 
-       path_list.append(out_path = new char[strlen(string) + 1]);
-       strcpy(out_path, string);
+       path_list.append(out_path = new char[strlen(backup_path) + 1]);
+       strcpy(out_path, backup_path);
 
        load_filenames(&path_list, LOADMODE_REPLACE, 0);
        edl->local_session->clip_title[0] = 0;
@@ -2922,6 +2927,9 @@ int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
 {
        w = 1;  h = 1;
        if(!width || !height) return 1;
+       if( width == 720 && (height == 480 || height == 576) ) {
+               w = 4;  h = 3;  return 0; // for NTSC and PAL
+       }
        double ar = (double)width / height;
 // square-ish pixels
        if( EQUIV(ar, 1.0000) ) return 0;