X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fsession_metadata_dialog.cc;h=77e299ba69db3e2b5650400d7a25c2074cdd5c88;hb=fb74b9e015f1e071992dbad727745e9defab34ae;hp=90e978903cee303c786ad21b2dc80a37e35ca351;hpb=ced4378d0914bcfb926267772c45d1d23f3bed38;p=ardour.git diff --git a/gtk2_ardour/session_metadata_dialog.cc b/gtk2_ardour/session_metadata_dialog.cc index 90e978903c..77e299ba69 100644 --- a/gtk2_ardour/session_metadata_dialog.cc +++ b/gtk2_ardour/session_metadata_dialog.cc @@ -17,11 +17,10 @@ 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "session_metadata_dialog.h" - #include - -#include +#include +#include +#include #include "pbd/xml++.h" #include "pbd/error.h" @@ -30,7 +29,11 @@ #include "ardour/session.h" #include "ardour/session_utils.h" -#include "i18n.h" +#include "gtkmm2ext/utils.h" + +#include "session_metadata_dialog.h" + +#include "pbd/i18n.h" using namespace std; using namespace Glib; @@ -85,7 +88,7 @@ Gtk::Widget & TextMetadataField::name_widget () { label = Gtk::manage (new Gtk::Label(_name + ':')); - label->set_alignment (1, 0.5); + label->set_alignment (1, 0); return *label; } @@ -114,6 +117,44 @@ TextMetadataField::update_value () _value = entry->get_text (); } +/* LongTextMetadataField */ + +LongTextMetadataField::LongTextMetadataField (Getter getter, Setter setter, string const & field_name, guint width ) : + TextMetadataField (getter, setter, field_name, width) +{ + tview = 0; + label = 0; + value_label = 0; +} + +MetadataPtr +LongTextMetadataField::copy () +{ + return MetadataPtr (new TextMetadataField (getter, setter, _name, width)); +} + +Gtk::Widget & +LongTextMetadataField::edit_widget () +{ + tview = Gtk::manage (new Gtk::TextView()); + + tview->get_buffer()->set_text (_value); + tview->set_wrap_mode (Gtk::WRAP_WORD); + tview->set_size_request (-1, 400); + tview->set_editable (true); + + Glib::RefPtr tb (tview->get_buffer()); + tb->signal_changed().connect (sigc::mem_fun(*this, &LongTextMetadataField::update_value)); + + return *tview; +} + +void +LongTextMetadataField::update_value () +{ + _value = tview->get_buffer()->get_text (); +} + /* NumberMetadataField */ NumberMetadataField::NumberMetadataField (Getter getter, Setter setter, string const & field_name, guint numbers, guint width) : @@ -164,7 +205,7 @@ Gtk::Widget & NumberMetadataField::name_widget () { label = Gtk::manage (new Gtk::Label(_name + ':')); - label->set_alignment (1, 0.5); + label->set_alignment (1, 0); return *label; } @@ -270,15 +311,18 @@ EAN13MetadataField::update_status () // calculate EAN-13 modulo 10 check digit int sum = 0; const char *p = _value.c_str(); - for (int i =0; i < 12; i++) { + for (int i = 0; i < 12; i++) { char c = p[i] - '0'; if (i % 2) { - sum += c; - } else { sum += c * 3; + } else { + sum += c; } } sum %= 10; + if (sum) + sum = 10 - sum; + if (sum == p[12] - '0') { status_label->set_markup (string_compose( "%1: %2", @@ -301,7 +345,7 @@ Gtk::Widget & EAN13MetadataField::name_widget () { label = Gtk::manage (new Gtk::Label(_name + ':')); - label->set_alignment (1, 0.5); + label->set_alignment (1, 0); return *label; } @@ -563,6 +607,7 @@ SessionMetadataDialog::init_data ( bool skip_user ) init_album_data (); init_people_data (); init_school_data (); + init_description_data (); for (DataSetList::iterator it = data_list.begin(); it != data_list.end(); ++it) { (*it)->set_session (_session); @@ -660,6 +705,20 @@ SessionMetadataDialog::init_user_data () } +template +void +SessionMetadataDialog::init_description_data () +{ + DataSetPtr data_set (new DataSet (_("Description"))); + data_list.push_back (data_set); + + MetadataPtr ptr; + + ptr = MetadataPtr (new LongTextMetadataField (&ARDOUR::SessionMetadata::description, &ARDOUR::SessionMetadata::set_description, _("Description"))); + data_set->add_data_field (ptr); +} + + template void SessionMetadataDialog::init_track_data () @@ -849,6 +908,7 @@ SessionMetadataImporter::run () /* Open session file selector */ Gtk::FileChooserDialog session_selector(_("Choose session to import metadata from"), Gtk::FILE_CHOOSER_ACTION_OPEN); + Gtkmm2ext::add_volume_shortcuts (session_selector); session_selector.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); session_selector.add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT); session_selector.set_default_response(Gtk::RESPONSE_ACCEPT); @@ -900,7 +960,7 @@ SessionMetadataImporter::run () return; } - //create a temporary + //create a temporary ARDOUR::SessionMetadata data; data.set_state (*node, version); init_data ( true ); //skip user data here