mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
Made the chapter parser for simple/OGM style chapters honour the default values for language and country.
This commit is contained in:
parent
d7672f8566
commit
046d7dd61e
@ -32,6 +32,9 @@
|
||||
using namespace std;
|
||||
using namespace libmatroska;
|
||||
|
||||
string default_chapter_language;
|
||||
string default_chapter_country;
|
||||
|
||||
// {{{ defines for chapter line recognition
|
||||
|
||||
#define isequal(s) (*(s) == '=')
|
||||
@ -152,8 +155,12 @@ KaxChapters *parse_simple_chapters(mm_text_io_c *in, int64_t min_tc,
|
||||
} else
|
||||
do_convert = false;
|
||||
|
||||
if (language == NULL)
|
||||
language = "eng";
|
||||
if (language == NULL) {
|
||||
if (default_chapter_language.length() > 0)
|
||||
language = default_chapter_language.c_str();
|
||||
else
|
||||
language = "eng";
|
||||
}
|
||||
|
||||
try {
|
||||
while (in->getline2(line)) {
|
||||
@ -212,6 +219,11 @@ KaxChapters *parse_simple_chapters(mm_text_io_c *in, int64_t min_tc,
|
||||
*static_cast<EbmlString *>(&GetChild<KaxChapterLanguage>(*display)) =
|
||||
language;
|
||||
|
||||
if (default_chapter_country.length() > 0)
|
||||
*static_cast<EbmlString *>
|
||||
(&GetChild<KaxChapterCountry>(*display)) =
|
||||
default_chapter_country;
|
||||
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
@ -65,5 +65,7 @@ KaxChapters *select_chapters_in_timeframe(KaxChapters *chapters,
|
||||
int64_t min_tc, int64_t max_tc,
|
||||
int64_t offset, bool validate);
|
||||
|
||||
extern string default_chapter_language, default_chapter_country;
|
||||
|
||||
#endif // __CHAPTERS_H
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "wx/statline.h"
|
||||
|
||||
#include "mmg.h"
|
||||
#include "chapters.h"
|
||||
#include "common.h"
|
||||
#ifdef SYS_UNIX
|
||||
#include "matroskalogo_big.xpm"
|
||||
@ -1114,9 +1115,9 @@ bool mmg_app::OnInit() {
|
||||
}
|
||||
cfg->SetPath("/chapter_editor");
|
||||
if (cfg->Read("default_language", &k))
|
||||
tab_chapters::default_language = k;
|
||||
default_chapter_language = k.c_str();
|
||||
if (cfg->Read("default_country", &k))
|
||||
tab_chapters::default_country = k;
|
||||
default_chapter_country = k.c_str();
|
||||
|
||||
app = this;
|
||||
mdlg = new mmg_dialog();
|
||||
@ -1133,8 +1134,8 @@ int mmg_app::OnExit() {
|
||||
cfg->SetPath("/GUI");
|
||||
cfg->Write("last_directory", last_open_dir);
|
||||
cfg->SetPath("/chapter_editor");
|
||||
cfg->Write("default_language", tab_chapters::default_language);
|
||||
cfg->Write("default_country", tab_chapters::default_country);
|
||||
cfg->Write("default_language", default_chapter_language.c_str());
|
||||
cfg->Write("default_country", default_chapter_country.c_str());
|
||||
cfg->Flush();
|
||||
|
||||
delete cfg;
|
||||
|
@ -395,8 +395,6 @@ public:
|
||||
|
||||
kax_analyzer_c *analyzer;
|
||||
|
||||
static wxString default_language, default_country;
|
||||
|
||||
public:
|
||||
tab_chapters(wxWindow *parent, wxMenu *nm_chapters);
|
||||
~tab_chapters();
|
||||
|
@ -41,9 +41,6 @@ using namespace std;
|
||||
using namespace libebml;
|
||||
using namespace libmatroska;
|
||||
|
||||
wxString tab_chapters::default_language = "";
|
||||
wxString tab_chapters::default_country = "";
|
||||
|
||||
class chapter_node_data_c: public wxTreeItemData {
|
||||
public:
|
||||
bool is_atom;
|
||||
@ -781,14 +778,15 @@ void tab_chapters::on_add_chapter(wxCommandEvent &evt) {
|
||||
delete (*chapter)[0];
|
||||
chapter->Remove(0);
|
||||
}
|
||||
if ((default_language.Length() > 0) || (default_country.Length() > 0)) {
|
||||
if ((default_chapter_language.length() > 0) ||
|
||||
(default_chapter_country.length() > 0)) {
|
||||
KaxChapterDisplay &display = GetEmptyChild<KaxChapterDisplay>(*chapter);
|
||||
if (default_language.Length() > 0)
|
||||
if (default_chapter_language.length() > 0)
|
||||
*static_cast<EbmlString *>(&GetChild<KaxChapterLanguage>(display)) =
|
||||
default_language.c_str();
|
||||
if (default_country.Length() > 0)
|
||||
default_chapter_language.c_str();
|
||||
if (default_chapter_country.length() > 0)
|
||||
*static_cast<EbmlString *>(&GetChild<KaxChapterCountry>(display)) =
|
||||
default_country.c_str();
|
||||
default_chapter_country.c_str();
|
||||
}
|
||||
s = create_chapter_label(*chapter);
|
||||
|
||||
@ -858,14 +856,15 @@ void tab_chapters::on_add_subchapter(wxCommandEvent &evt) {
|
||||
delete (*chapter)[0];
|
||||
chapter->Remove(0);
|
||||
}
|
||||
if ((default_language.Length() > 0) || (default_country.Length() > 0)) {
|
||||
if ((default_chapter_language.length() > 0) ||
|
||||
(default_chapter_country.length() > 0)) {
|
||||
KaxChapterDisplay &display = GetEmptyChild<KaxChapterDisplay>(*chapter);
|
||||
if (default_language.Length() > 0)
|
||||
if (default_chapter_language.length() > 0)
|
||||
*static_cast<EbmlString *>(&GetChild<KaxChapterLanguage>(display)) =
|
||||
default_language.c_str();
|
||||
if (default_country.Length() > 0)
|
||||
default_chapter_language.c_str();
|
||||
if (default_chapter_country.length() > 0)
|
||||
*static_cast<EbmlString *>(&GetChild<KaxChapterCountry>(display)) =
|
||||
default_country.c_str();
|
||||
default_chapter_country.c_str();
|
||||
}
|
||||
m->PushElement(*chapter);
|
||||
s = create_chapter_label(*chapter);
|
||||
@ -1063,16 +1062,17 @@ void tab_chapters::verify_country_codes(string s, vector<string> &parts) {
|
||||
|
||||
void tab_chapters::on_set_default_values(wxCommandEvent &evt) {
|
||||
vector<string> parts;
|
||||
chapter_values_dlg dlg(this, true, default_language, default_country);
|
||||
chapter_values_dlg dlg(this, true, default_chapter_language.c_str(),
|
||||
default_chapter_country.c_str());
|
||||
|
||||
if (dlg.ShowModal() != wxID_OK)
|
||||
return;
|
||||
|
||||
verify_language_codes(dlg.tc_language->GetValue().c_str(), parts);
|
||||
default_language = join(" ", parts).c_str();
|
||||
default_chapter_language = join(" ", parts);
|
||||
|
||||
verify_country_codes(dlg.tc_country->GetValue().c_str(), parts);
|
||||
default_country = join(" ", parts).c_str();
|
||||
default_chapter_country = join(" ", parts);
|
||||
}
|
||||
|
||||
void tab_chapters::set_values_recursively(wxTreeItemId id, string &s,
|
||||
|
Loading…
Reference in New Issue
Block a user