/*
- Copyright (C) 2008 Paul Davis
- Author: Sakari Bergen
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "session_metadata_dialog.h"
+ * Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2015-2016 Colin Fletcher <colin.m.fletcher@googlemail.com>
+ * Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
#include <sstream>
-
-#include <gtkmm2ext/utils.h>
+#include <gtkmm/filechooserdialog.h>
+#include <gtkmm/messagedialog.h>
+#include <gtkmm/stock.h>
#include "pbd/xml++.h"
#include "pbd/error.h"
#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;
TextMetadataField::name_widget ()
{
label = Gtk::manage (new Gtk::Label(_name + ':'));
- label->set_alignment (1, 0.5);
+ label->set_alignment (1, 0);
return *label;
}
_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<Gtk::TextBuffer> 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) :
NumberMetadataField::name_widget ()
{
label = Gtk::manage (new Gtk::Label(_name + ':'));
- label->set_alignment (1, 0.5);
+ label->set_alignment (1, 0);
return *label;
}
// 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(
"<span color=\"green\">%1: %2</span>",
EAN13MetadataField::name_widget ()
{
label = Gtk::manage (new Gtk::Label(_name + ':'));
- label->set_alignment (1, 0.5);
+ label->set_alignment (1, 0);
return *label;
}
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);
}
+template <typename DataSet>
+void
+SessionMetadataDialog<DataSet>::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 <typename DataSet>
void
SessionMetadataDialog<DataSet>::init_track_data ()
/* 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);
return;
}
- //create a temporary
+ //create a temporary
ARDOUR::SessionMetadata data;
data.set_state (*node, version);
init_data ( true ); //skip user data here