Guitarix
gx_portmap.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  * --------------------------------------------------------------------------
19  */
20 
21 /* ------- This is the GUI namespace ------- */
22 
23 
24 #pragma once
25 
26 #ifndef SRC_HEADERS_GX_PORTMAP_H_
27 #define SRC_HEADERS_GX_PORTMAP_H_
28 
29 #include <gtk/gtk.h>
30 #include <gtkmm.h>
31 #include <jack/jack.h>
32 
33 #include <list>
34 #include <string>
35 
36 namespace gx_portmap {
37 
38 /****************************************************************
39  ** PortMapWindow
40  */
41 
42 struct PortAttr {
43  const int client_num;
44  const bool is_insert;
45  const char *port_name;
46  bool is_input;
47  const char *port_type;
48 };
49 
50 struct PortSection {
51  Glib::RefPtr<Gtk::TreeStore> treestore;
52  Gtk::ScrolledWindow *scrolled_window;
53  Gtk::Expander *expander;
54  Gtk::Label *label;
56 };
57 
58 class PortMapWindow: public sigc::trackable {
59 private:
60  enum {
61  number_of_ports = 7
62  };
63  struct ModelColumns : public Gtk::TreeModelColumnRecord {
64  Gtk::TreeModelColumn<Glib::ustring> port;
65  Gtk::TreeModelColumn<bool> connected;
66  Gtk::TreeModelColumn<bool> is_port;
67  ModelColumns() { add(port); add(connected); add(is_port); }
68  };
71  list<string> excluded_clients;
74  void on_expander(Gtk::Expander& expander);
76  void on_cell_toggle(Glib::ustring path, PortSection& p);
77  void update_summary(PortSection& p, string *port = 0, bool connect = false);
78  void redraw_expander(Gtk::Expander* expander);
79  list<string> walk(Glib::RefPtr<Gtk::TreeStore> ts, string *port, int connect);
80  bool walk_remove(Glib::RefPtr<Gtk::TreeStore> ts, bool (*compare)(const string&, const char*), string data);
81  void walk_insert(Glib::RefPtr<Gtk::TreeStore> ts, string data);
82  void load(int sect, jack_port_t*);
83  void load_all();
84  int sort_func(const Gtk::TreeIter& a, const Gtk::TreeIter& b);
85  explicit PortMapWindow(Glib::RefPtr<gx_gui::GxBuilder> bld, gx_jack::GxJack& jack, Glib::RefPtr<Gtk::AccelGroup> ag);
86  Gtk::Dialog *window;
87  void client_removed(string name);
88  void port_changed(string name, const char *tp, int flags, bool reg);
89 public:
91  static PortMapWindow* create(gx_engine::GxMachineBase& machine, Glib::RefPtr<Gtk::AccelGroup> ag);
92  void refresh();
93  void connection_changed(string port1, string port2, bool conn);
94  Glib::SignalProxy1<void,int> signal_response() { return window->signal_response(); }
95 };
96 
97 } // end namespace gx_portmap
98 #endif // SRC_HEADERS_GX_PORTMAP_H_
gx_portmap::PortMapWindow::walk_remove
bool walk_remove(Glib::RefPtr< Gtk::TreeStore > ts, bool(*compare)(const string &, const char *), string data)
gx_portmap::PortMapWindow::port_changed
void port_changed(string name, const char *tp, int flags, bool reg)
gx_portmap::PortMapWindow::~PortMapWindow
~PortMapWindow()
gx_portmap::PortAttr::client_num
const int client_num
Definition: gx_portmap.h:45
gx_portmap::PortSection::treestore
Glib::RefPtr< Gtk::TreeStore > treestore
Definition: gx_portmap.h:51
gx_portmap::PortAttr::port_name
const char * port_name
Definition: gx_portmap.h:47
gx_portmap::PortAttr::is_input
bool is_input
Definition: gx_portmap.h:48
gx_engine::GxMachineBase
Definition: machine.h:55
gx_portmap::PortMapWindow::portsection
PortSection portsection[number_of_ports]
Definition: gx_portmap.h:70
gx_portmap::PortMapWindow::ModelColumns::is_port
Gtk::TreeModelColumn< bool > is_port
Definition: gx_portmap.h:66
gx_portmap::PortMapWindow::on_check_resize
void on_check_resize()
gx_portmap::PortMapWindow::excluded_clients
list< string > excluded_clients
Definition: gx_portmap.h:71
gx_portmap::PortMapWindow::number_of_ports
@ number_of_ports
Definition: gx_portmap.h:61
gx_portmap::PortSection
Definition: gx_portmap.h:50
gx_portmap::PortMapWindow::ModelColumns::port
Gtk::TreeModelColumn< Glib::ustring > port
Definition: gx_portmap.h:64
gx_portmap::PortAttr::port_type
const char * port_type
Definition: gx_portmap.h:49
gx_portmap::PortMapWindow::ModelColumns::connected
Gtk::TreeModelColumn< bool > connected
Definition: gx_portmap.h:65
gx_portmap::PortMapWindow::redraw_expander
void redraw_expander(Gtk::Expander *expander)
gx_portmap::PortMapWindow::walk
list< string > walk(Glib::RefPtr< Gtk::TreeStore > ts, string *port, int connect)
gx_portmap::PortSection::expander
Gtk::Expander * expander
Definition: gx_portmap.h:53
gx_portmap::PortSection::label
Gtk::Label * label
Definition: gx_portmap.h:54
gx_jack::GxJack
Definition: gx_jack.h:145
gx_portmap::PortMapWindow
Definition: gx_portmap.h:58
gx_portmap::PortMapWindow::PortMapWindow
PortMapWindow(Glib::RefPtr< gx_gui::GxBuilder > bld, gx_jack::GxJack &jack, Glib::RefPtr< Gtk::AccelGroup > ag)
gx_portmap::PortMapWindow::load_all
void load_all()
gx_portmap::PortMapWindow::on_expander
void on_expander(Gtk::Expander &expander)
gx_portmap::PortAttr
Definition: gx_portmap.h:42
gx_portmap::PortMapWindow::load
void load(int sect, jack_port_t *)
gx_portmap::PortMapWindow::refresh
void refresh()
gx_portmap::PortMapWindow::client_removed
void client_removed(string name)
gx_portmap::PortMapWindow::connection_changed
void connection_changed(string port1, string port2, bool conn)
gx_portmap::PortMapWindow::jack
gx_jack::GxJack & jack
Definition: gx_portmap.h:72
gx_portmap::PortMapWindow::ModelColumns
Definition: gx_portmap.h:63
gx_portmap::PortMapWindow::on_cell_toggle
void on_cell_toggle(Glib::ustring path, PortSection &p)
gx_portmap::PortMapWindow::sort_func
int sort_func(const Gtk::TreeIter &a, const Gtk::TreeIter &b)
gx_portmap::PortMapWindow::walk_insert
void walk_insert(Glib::RefPtr< Gtk::TreeStore > ts, string data)
gx_portmap::PortMapWindow::monitored_expander_child
Gtk::Widget * monitored_expander_child
Definition: gx_portmap.h:73
gx_portmap::PortMapWindow::window
Gtk::Dialog * window
Definition: gx_portmap.h:86
gx_portmap::PortMapWindow::ModelColumns::ModelColumns
ModelColumns()
Definition: gx_portmap.h:67
gx_portmap::PortMapWindow::columns
const ModelColumns columns
Definition: gx_portmap.h:69
gx_portmap::PortMapWindow::update_summary
void update_summary(PortSection &p, string *port=0, bool connect=false)
gx_portmap::PortMapWindow::signal_response
Glib::SignalProxy1< void, int > signal_response()
Definition: gx_portmap.h:94
gx_portmap::PortSection::scrolled_window
Gtk::ScrolledWindow * scrolled_window
Definition: gx_portmap.h:52
gx_portmap::PortAttr::is_insert
const bool is_insert
Definition: gx_portmap.h:46
gx_portmap
Definition: gx_portmap.h:36
gx_portmap::PortMapWindow::create
static PortMapWindow * create(gx_engine::GxMachineBase &machine, Glib::RefPtr< Gtk::AccelGroup > ag)
gx_portmap::PortSection::port_attr
PortAttr * port_attr
Definition: gx_portmap.h:55