Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Added an option to disable write of label, cat# and barcode (closes #24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dremora committed Jun 1, 2011
1 parent 45a157a commit 637507a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
30 changes: 16 additions & 14 deletions FileTagMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,24 @@ Tag::Tag(Release &release, Medium &medium, Track &track) {
}
}

// Barcode
set("BARCODE", release.get_barcode());

// Label info
TagValues labels, catalog_numbers;
for (auto i = 0; i < release.label_info_count(); i++) {
// TODO: possibly remove duplicates?
if (auto label = release.get_label_info(i)->get_name()) {
labels.add_item(label);
}
if (auto catalog_number = release.get_label_info(i)->get_catalog_number()) {
catalog_numbers.add_item(catalog_number);
if (Preferences::write_label_info) {
// Barcode
set("BARCODE", release.get_barcode());

// Label info
TagValues labels, catalog_numbers;
for (auto i = 0; i < release.label_info_count(); i++) {
// TODO: possibly remove duplicates?
if (auto label = release.get_label_info(i)->get_name()) {
labels.add_item(label);
}
if (auto catalog_number = release.get_label_info(i)->get_catalog_number()) {
catalog_numbers.add_item(catalog_number);
}
}
base_class::set("LABEL", labels);
base_class::set("CATALOGNUMBER", catalog_numbers);
}
base_class::set("LABEL", labels);
base_class::set("CATALOGNUMBER", catalog_numbers);
}

void Tag::set(pfc::string8 key, pfc::string8 value) {
Expand Down
4 changes: 4 additions & 0 deletions Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ namespace foo_musicbrainz {
extern const GUID guid_ascii_punctuation;
extern const bool default_ascii_punctuation;
extern cfg_bool ascii_punctuation;

extern const GUID guid_write_label_info;
extern const bool default_write_label_info;
extern cfg_bool write_label_info;
}
}
2 changes: 2 additions & 0 deletions foo_musicbrainz.rc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ BEGIN
EDITTEXT IDC_ALBUMTYPE_DATA,122,65,133,14,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
CONTROL "Write Album Status, use field:",IDC_ALBUMSTATUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,83,111,10
EDITTEXT IDC_ALBUMSTATUS_DATA,122,81,133,14,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
CONTROL "Write label, catalog number and barcode",IDC_WRITE_LABEL_INFO,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,99,146,10
END


Expand Down
16 changes: 14 additions & 2 deletions preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ namespace foo_musicbrainz {
const GUID guid_albumstatus_data = { 0x77182aac, 0x1caa, 0x4793, { 0xb7, 0x15, 0xcc, 0xf8, 0x97, 0xba, 0x11, 0x1a } };
cfg_string albumstatus_data(guid_albumstatus_data, "MUSICBRAINZ_ALBUMSTATUS");

const GUID guid_ascii_punctuation =
const GUID guid_ascii_punctuation =
{ 0xd08b1b7c, 0x38fd, 0x4689, { 0x9e, 0x91, 0x8c, 0xdc, 0xbe, 0xc4, 0x26, 0x98 } };
const bool default_ascii_punctuation = false;
cfg_bool ascii_punctuation(guid_ascii_punctuation, default_ascii_punctuation);

const GUID guid_write_label_info =
{ 0x9b3c94e3, 0x278, 0x4eb0, { 0xa2, 0xed, 0x5, 0xad, 0xf8, 0xce, 0xa3, 0x9d } };
const bool default_write_label_info = true;
cfg_bool write_label_info(guid_write_label_info, default_write_label_info);
}

class PreferencesPageInstance : public CDialogImpl<PreferencesPageInstance>, public preferences_page_instance {
Expand All @@ -37,6 +42,7 @@ namespace foo_musicbrainz {
CButton write_ids_checkbox;
CButton write_albumtype_checkbox;
CButton write_albumstatus_checkbox;
CButton write_label_info_checkbox;
CEdit albumtype;
CEdit albumstatus;
preferences_page_callback::ptr on_change_callback;
Expand All @@ -54,6 +60,7 @@ namespace foo_musicbrainz {
COMMAND_HANDLER_EX(IDC_WRITE_IDS, BN_CLICKED, OnChanged)
COMMAND_HANDLER_EX(IDC_ALBUMTYPE, BN_CLICKED, OnAlbumType)
COMMAND_HANDLER_EX(IDC_ALBUMSTATUS, BN_CLICKED, OnAlbumStatus)
COMMAND_HANDLER_EX(IDC_WRITE_LABEL_INFO, BN_CLICKED, OnChanged)
COMMAND_HANDLER_EX(IDC_ALBUMTYPE_DATA, EN_UPDATE, OnChanged)
COMMAND_HANDLER_EX(IDC_ALBUMSTATUS_DATA, EN_UPDATE, OnChanged)
END_MSG_MAP()
Expand All @@ -65,6 +72,7 @@ namespace foo_musicbrainz {
write_ids_checkbox = GetDlgItem(IDC_WRITE_IDS);
write_albumtype_checkbox = GetDlgItem(IDC_ALBUMTYPE);
write_albumstatus_checkbox = GetDlgItem(IDC_ALBUMSTATUS);
write_label_info_checkbox = GetDlgItem(IDC_WRITE_LABEL_INFO);
albumtype = GetDlgItem(IDC_ALBUMTYPE_DATA);
albumstatus = GetDlgItem(IDC_ALBUMSTATUS_DATA);

Expand All @@ -74,6 +82,7 @@ namespace foo_musicbrainz {
write_ids_checkbox.SetCheck(Preferences::write_ids.get_value());
write_albumtype_checkbox.SetCheck(Preferences::albumtype.get_value());
write_albumstatus_checkbox.SetCheck(Preferences::albumstatus.get_value());
write_label_info_checkbox.SetCheck(Preferences::write_label_info.get_value());
uSetWindowText(albumtype, Preferences::albumtype_data);
uSetWindowText(albumstatus, Preferences::albumstatus_data);
if (Preferences::albumtype.get_value()) albumtype.EnableWindow(true);
Expand All @@ -89,6 +98,7 @@ namespace foo_musicbrainz {
if ((bool)write_ids_checkbox.GetCheck() != Preferences::write_ids.get_value()) return true;
if ((bool)write_albumtype_checkbox.GetCheck() != Preferences::albumtype.get_value()) return true;
if ((bool)write_albumstatus_checkbox.GetCheck() != Preferences::albumstatus.get_value()) return true;
if ((bool)write_label_info_checkbox.GetCheck() != Preferences::write_label_info.get_value()) return true;

pfc::string8 temp;
uGetWindowText(albumtype, temp);
Expand All @@ -112,6 +122,7 @@ namespace foo_musicbrainz {
Preferences::write_ids = (bool)write_ids_checkbox.GetCheck();
Preferences::albumtype = (bool)write_albumtype_checkbox.GetCheck();
Preferences::albumstatus = (bool)write_albumstatus_checkbox.GetCheck();
Preferences::write_label_info = (bool)write_label_info_checkbox.GetCheck();
uGetWindowText(albumtype, Preferences::albumtype_data);
uGetWindowText(albumstatus, Preferences::albumstatus_data);
}
Expand All @@ -123,10 +134,11 @@ namespace foo_musicbrainz {
void reset() {
short_date_checkbox.SetCheck(false);
no_feat_checkbox.SetCheck(false);
ascii_punctuation_checkbox.SetCheck(false);
ascii_punctuation_checkbox.SetCheck(Preferences::default_ascii_punctuation);
write_ids_checkbox.SetCheck(true);
write_albumtype_checkbox.SetCheck(true);
write_albumstatus_checkbox.SetCheck(true);
write_label_info_checkbox.SetCheck(Preferences::default_write_label_info);
uSetWindowText(albumtype, "MUSICBRAINZ_ALBUMTYPE");
uSetWindowText(albumstatus, "MUSICBRAINZ_ALBUMSTATUS");
on_change();
Expand Down
1 change: 1 addition & 0 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define IDC_ALBUMSTATUS 1033
#define IDC_ALBUMSTATUS_DATA 1034
#define IDC_ASCII_PUNCTUATION 1035
#define IDC_WRITE_LABEL_INFO 1036
#define IDC_MEDIUM_LIST 1039
#define IDC_LABEL_INFO_LIST 1041
#define IDC_BARCODE 1042
Expand Down

0 comments on commit 637507a

Please sign in to comment.