Make foldback bus match foldback sends namewise
[ardour.git] / gtk2_ardour / session_import_dialog.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sakari Bergen
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __session_import_dialog_h__
22 #define __session_import_dialog_h__
23
24 #include <string>
25 #include <list>
26 #include <utility>
27
28 #include <boost/shared_ptr.hpp>
29
30 #include <gtkmm/box.h>
31 #include <gtkmm/button.h>
32 #include <gtkmm/entry.h>
33 #include <gtkmm/filechooserdialog.h>
34 #include <gtkmm/frame.h>
35 #include <gtkmm/scrolledwindow.h>
36 #include <gtkmm/treemodel.h>
37 #include <gtkmm/treestore.h>
38 #include <gtkmm/treeview.h>
39
40 #include "pbd/xml++.h"
41
42 #include "ardour_dialog.h"
43 namespace ARDOUR {
44         class ElementImportHandler;
45         class ElementImporter;
46         class Session;
47 }
48
49 class SessionImportDialog : public ArdourDialog
50 {
51 private:
52         typedef boost::shared_ptr<ARDOUR::ElementImportHandler> HandlerPtr;
53         typedef std::list<HandlerPtr> HandlerList;
54
55         typedef boost::shared_ptr<ARDOUR::ElementImporter> ElementPtr;
56         typedef std::list<ElementPtr> ElementList;
57
58 public:
59         SessionImportDialog (ARDOUR::Session* target);
60
61         virtual Gtk::FileChooserAction browse_action() const { return Gtk::FILE_CHOOSER_ACTION_OPEN; }
62
63 private:
64
65         void load_session (const std::string& filename);
66         void fill_list ();
67         void browse ();
68         void do_merge ();
69         void end_dialog ();
70         void update (std::string path);
71         void show_info(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
72
73         std::pair<bool, std::string> open_rename_dialog (std::string text, std::string name);
74         bool open_prompt_dialog (std::string text);
75
76         // Data
77         HandlerList        handlers;
78         XMLTree            tree;
79
80         // GUI
81         Gtk::Frame                    file_frame;
82         Gtk::HBox                     file_hbox;
83         Gtk::Entry                    file_entry;
84         Gtk::Button                   file_browse_button;
85
86         struct SessionBrowserColumns : public Gtk::TreeModel::ColumnRecord
87         {
88         public:
89                 Gtk::TreeModelColumn<std::string>    name;
90                 Gtk::TreeModelColumn<bool>           queued;
91                 Gtk::TreeModelColumn<ElementPtr>     element;
92                 Gtk::TreeModelColumn<std::string>    info;
93
94                 SessionBrowserColumns() { add (name); add (queued); add (element); add (info); }
95         };
96
97         SessionBrowserColumns         sb_cols;
98         Glib::RefPtr<Gtk::TreeStore>  session_tree;
99         Gtk::TreeView                 session_browser;
100         Gtk::ScrolledWindow           session_scroll;
101
102         Gtk::Button*                  ok_button;
103         Gtk::Button*                  cancel_button;
104
105         PBD::ScopedConnectionList connections;
106 };
107
108 #endif