Fix crash when X11 is not available for VST UIs
[ardour.git] / gtk2_ardour / playlist_selector.h
1 /*
2  * Copyright (C) 2005-2009 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
4  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #ifndef __ardour_playlist_selector_h__
22 #define __ardour_playlist_selector_h__
23
24 #include <boost/shared_ptr.hpp>
25
26 #include <gtkmm/box.h>
27 #include <gtkmm/scrolledwindow.h>
28 #include <gtkmm/button.h>
29 #include <gtkmm/treeview.h>
30 #include <gtkmm/treestore.h>
31
32 #include "ardour_dialog.h"
33 #include "ardour/session_handle.h"
34
35 namespace ARDOUR {
36         class Session;
37         class PluginManager;
38         class Plugin;
39 }
40
41 class RouteUI;
42
43 class PlaylistSelector : public ArdourDialog
44 {
45 public:
46         PlaylistSelector ();
47         ~PlaylistSelector ();
48
49         void show_for (RouteUI*);
50
51 protected:
52         bool on_unmap_event (GdkEventAny*);
53
54 private:
55         typedef std::map<PBD::ID,std::list<boost::shared_ptr<ARDOUR::Playlist> >*> TrackPlaylistMap;
56
57         Gtk::ScrolledWindow scroller;
58         TrackPlaylistMap trpl_map;
59         RouteUI* rui;
60
61         sigc::connection select_connection;
62
63         void add_playlist_to_map (boost::shared_ptr<ARDOUR::Playlist>);
64         void clear_map ();
65         void close_button_click ();
66         void selection_changed ();
67
68         struct ModelColumns : public Gtk::TreeModel::ColumnRecord
69         {
70                 ModelColumns () {
71                         add (text);
72                         add (playlist);
73                 }
74                 Gtk::TreeModelColumn<std::string> text;
75                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Playlist> >   playlist;
76         };
77
78         ModelColumns columns;
79         Glib::RefPtr<Gtk::TreeStore> model;
80         Gtk::TreeView tree;
81 };
82
83 #endif // __ardour_playlist_selector_h__