2008-09-17 08:56:00 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2008 Paul Davis
|
2008-09-17 08:56:00 -04:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __session_metadata_dialog_h__
|
|
|
|
#define __session_metadata_dialog_h__
|
|
|
|
|
|
|
|
#include "ardour_dialog.h"
|
|
|
|
|
2013-07-11 15:29:28 -04:00
|
|
|
#ifdef interface
|
|
|
|
#undef interface
|
|
|
|
#endif
|
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <list>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/session_metadata.h"
|
2008-09-17 08:56:00 -04:00
|
|
|
|
|
|
|
class MetadataField;
|
2009-10-14 12:10:01 -04:00
|
|
|
typedef boost::shared_ptr<MetadataField> MetadataPtr;
|
2008-09-17 08:56:00 -04:00
|
|
|
|
|
|
|
/// Wraps a metadata field to be used in a GUI
|
|
|
|
class MetadataField {
|
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
MetadataField (std::string const & field_name);
|
2008-09-17 08:56:00 -04:00
|
|
|
virtual ~MetadataField();
|
|
|
|
virtual MetadataPtr copy () = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
virtual void save_data (ARDOUR::SessionMetadata & data) const = 0;
|
|
|
|
virtual void load_data (ARDOUR::SessionMetadata const & data) = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-14 11:45:21 -04:00
|
|
|
virtual std::string name() { return _name; }
|
|
|
|
virtual std::string value() { return _value; }
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/// Get widget containing name of field
|
|
|
|
virtual Gtk::Widget & name_widget () = 0;
|
|
|
|
/// Get label containing value of field
|
|
|
|
virtual Gtk::Widget & value_widget () = 0;
|
|
|
|
/// Get widget for editing value
|
|
|
|
virtual Gtk::Widget & edit_widget () = 0;
|
|
|
|
protected:
|
2010-09-14 11:45:21 -04:00
|
|
|
std::string _name;
|
|
|
|
std::string _value;
|
2008-09-17 08:56:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/// MetadataField that contains text
|
|
|
|
class TextMetadataField : public MetadataField {
|
|
|
|
private:
|
2010-09-14 11:45:21 -04:00
|
|
|
typedef std::string (ARDOUR::SessionMetadata::*Getter) () const;
|
|
|
|
typedef void (ARDOUR::SessionMetadata::*Setter) (std::string const &);
|
2008-09-17 08:56:00 -04:00
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
TextMetadataField (Getter getter, Setter setter, std::string const & field_name, guint width = 50);
|
2008-09-17 08:56:00 -04:00
|
|
|
MetadataPtr copy ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
void save_data (ARDOUR::SessionMetadata & data) const;
|
|
|
|
void load_data (ARDOUR::SessionMetadata const & data);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Widget & name_widget ();
|
|
|
|
Gtk::Widget & value_widget ();
|
|
|
|
Gtk::Widget & edit_widget ();
|
|
|
|
private:
|
|
|
|
void update_value ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Getter getter;
|
|
|
|
Setter setter;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Label* label;
|
|
|
|
Gtk::Label* value_label;
|
|
|
|
Gtk::Entry* entry;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-07-11 12:05:37 -04:00
|
|
|
guint width;
|
2008-09-17 08:56:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/// MetadataField that accepts only numbers
|
|
|
|
class NumberMetadataField : public MetadataField {
|
|
|
|
private:
|
|
|
|
typedef uint32_t (ARDOUR::SessionMetadata::*Getter) () const;
|
|
|
|
typedef void (ARDOUR::SessionMetadata::*Setter) (uint32_t);
|
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
NumberMetadataField (Getter getter, Setter setter, std::string const & field_name, guint numbers, guint width = 50);
|
2008-09-17 08:56:00 -04:00
|
|
|
MetadataPtr copy ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
void save_data (ARDOUR::SessionMetadata & data) const;
|
|
|
|
void load_data (ARDOUR::SessionMetadata const & data);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Widget & name_widget ();
|
|
|
|
Gtk::Widget & value_widget ();
|
|
|
|
Gtk::Widget & edit_widget ();
|
|
|
|
private:
|
|
|
|
void update_value ();
|
2010-09-14 11:45:21 -04:00
|
|
|
std::string uint_to_str (uint32_t i) const;
|
|
|
|
uint32_t str_to_uint (std::string const & str) const;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Getter getter;
|
|
|
|
Setter setter;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Label* label;
|
|
|
|
Gtk::Label* value_label;
|
|
|
|
Gtk::Entry* entry;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
guint numbers;
|
|
|
|
guint width;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Interface for MetadataFields
|
2009-12-17 13:24:23 -05:00
|
|
|
class SessionMetadataSet : public ARDOUR::SessionHandlePtr {
|
2008-09-17 08:56:00 -04:00
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
SessionMetadataSet (std::string const & name);
|
2008-09-17 08:56:00 -04:00
|
|
|
virtual ~SessionMetadataSet () {};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
void add_data_field (MetadataPtr field);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/// allows loading extra data into data sets (for importing etc.)
|
2009-07-21 11:55:17 -04:00
|
|
|
virtual void load_extra_data (ARDOUR::SessionMetadata const & /*data*/) { }
|
2008-09-17 08:56:00 -04:00
|
|
|
/// Saves data to session
|
|
|
|
virtual void save_data () = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
virtual Gtk::Widget & get_widget () = 0;
|
|
|
|
virtual Gtk::Widget & get_tab_widget () = 0;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
protected:
|
|
|
|
typedef std::list<MetadataPtr> DataList;
|
|
|
|
DataList list;
|
2010-09-14 11:45:21 -04:00
|
|
|
std::string name;
|
2008-09-17 08:56:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Contains MetadataFields for editing
|
|
|
|
class SessionMetadataSetEditable : public SessionMetadataSet {
|
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
SessionMetadataSetEditable (std::string const & name);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-24 14:49:27 -04:00
|
|
|
Gtk::Widget & get_widget () { return vbox; }
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Widget & get_tab_widget ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/// Sets session and loads data
|
|
|
|
void set_session (ARDOUR::Session * s);
|
|
|
|
/// Saves from MetadataFields into data
|
|
|
|
void save_data ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
private:
|
2009-08-24 14:49:27 -04:00
|
|
|
Gtk::VBox vbox;
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Table table;
|
|
|
|
Gtk::Label tab_widget;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Contains MetadataFields for importing
|
|
|
|
class SessionMetadataSetImportable : public SessionMetadataSet {
|
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
SessionMetadataSetImportable (std::string const & name);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Widget & get_widget () { return tree_view; }
|
|
|
|
Gtk::Widget & get_tab_widget ();
|
|
|
|
Gtk::Widget & get_select_all_widget ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/// Loads importable data from data
|
|
|
|
void load_extra_data (ARDOUR::SessionMetadata const & data);
|
|
|
|
/// Saves from importable data (see load_data) to session_data
|
|
|
|
void save_data ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
private:
|
|
|
|
DataList & session_list; // References MetadataSet::list
|
|
|
|
DataList import_list;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
struct Columns : public Gtk::TreeModel::ColumnRecord
|
|
|
|
{
|
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
Gtk::TreeModelColumn<std::string> field;
|
|
|
|
Gtk::TreeModelColumn<std::string> values;
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::TreeModelColumn<bool> import;
|
|
|
|
Gtk::TreeModelColumn<MetadataPtr> data;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Columns() { add (field); add (values); add (import); add (data); }
|
|
|
|
};
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Glib::RefPtr<Gtk::ListStore> tree;
|
|
|
|
Columns tree_cols;
|
|
|
|
Gtk::TreeView tree_view;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
|
|
|
Gtk::Label tab_widget;
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::CheckButton select_all_check;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
void select_all ();
|
2010-09-14 11:45:21 -04:00
|
|
|
void selection_changed (std::string const & path);
|
2008-09-17 08:56:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Metadata dialog interface
|
|
|
|
/**
|
|
|
|
* The DataSets are initalized in this class so that all
|
|
|
|
* Dialogs have the same sets of data in the same order.
|
|
|
|
*/
|
|
|
|
template <typename DataSet>
|
|
|
|
class SessionMetadataDialog : public ArdourDialog
|
|
|
|
{
|
|
|
|
public:
|
2010-09-14 11:45:21 -04:00
|
|
|
SessionMetadataDialog (std::string const & name);
|
2008-09-17 08:56:00 -04:00
|
|
|
|
|
|
|
protected:
|
2012-04-18 13:46:29 -04:00
|
|
|
void init_data ( bool skip_user = false );
|
2008-09-17 08:56:00 -04:00
|
|
|
void load_extra_data (ARDOUR::SessionMetadata const & data);
|
|
|
|
void save_data ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
virtual void init_gui () = 0;
|
|
|
|
virtual void save_and_close ();
|
|
|
|
virtual void end_dialog ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-14 11:45:21 -04:00
|
|
|
void warn_user (std::string const & string);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
typedef std::list<Gtk::Widget *> WidgetList;
|
|
|
|
typedef boost::shared_ptr<WidgetList> WidgetListPtr;
|
|
|
|
typedef Gtk::Widget & (DataSet::*WidgetFunc) ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/// Returns list of widgets gathered by calling f for each data set
|
|
|
|
WidgetListPtr get_custom_widgets (WidgetFunc f);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/// Adds a widget to the table (vertical stacking) with automatic spacing
|
|
|
|
void add_widget (Gtk::Widget & widget);
|
|
|
|
|
|
|
|
Gtk::Notebook notebook;
|
|
|
|
|
|
|
|
private:
|
2012-04-18 13:46:29 -04:00
|
|
|
void init_user_data ();
|
2008-09-17 08:56:00 -04:00
|
|
|
void init_track_data ();
|
|
|
|
void init_album_data ();
|
|
|
|
void init_people_data ();
|
2012-04-18 13:46:29 -04:00
|
|
|
void init_school_data ();
|
2008-09-17 08:56:00 -04:00
|
|
|
|
|
|
|
typedef boost::shared_ptr<SessionMetadataSet> DataSetPtr;
|
|
|
|
typedef std::list<DataSetPtr> DataSetList;
|
|
|
|
DataSetList data_list;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::Button * save_button;
|
|
|
|
Gtk::Button * cancel_button;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SessionMetadataEditor : public SessionMetadataDialog<SessionMetadataSetEditable> {
|
|
|
|
public:
|
|
|
|
SessionMetadataEditor ();
|
|
|
|
~SessionMetadataEditor ();
|
|
|
|
void run ();
|
|
|
|
private:
|
|
|
|
void init_gui ();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SessionMetadataImporter : public SessionMetadataDialog<SessionMetadataSetImportable> {
|
|
|
|
public:
|
|
|
|
SessionMetadataImporter ();
|
|
|
|
~SessionMetadataImporter ();
|
|
|
|
void run ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void init_gui ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
// Select all from -widget
|
|
|
|
Gtk::HBox selection_hbox;
|
|
|
|
Gtk::Label selection_label;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|