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  };
69  const ModelColumns columns;
70  PortSection portsection[number_of_ports];
71  list<string> excluded_clients;
72  gx_jack::GxJack& jack;
73  Gtk::Widget *monitored_expander_child;
74  void on_expander(Gtk::Expander& expander);
75  void on_check_resize();
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::~PortMapWindow
~PortMapWindow()
Definition: gx_portmap.cpp:667
gx_portmap::PortAttr::client_num
const int client_num
Definition: gx_portmap.h:43
gx_portmap::PortSection::treestore
Glib::RefPtr< Gtk::TreeStore > treestore
Definition: gx_portmap.h:50
gx_portmap::PortAttr::port_name
const char * port_name
Definition: gx_portmap.h:45
gx_portmap::PortAttr::is_input
bool is_input
Definition: gx_portmap.h:46
gx_engine::GxMachineBase
Definition: machine.h:53
gx_portmap::PortSection
Definition: gx_portmap.h:49
gx_portmap::PortAttr::port_type
const char * port_type
Definition: gx_portmap.h:47
gx_portmap::PortSection::expander
Gtk::Expander * expander
Definition: gx_portmap.h:52
gx_portmap::PortSection::label
Gtk::Label * label
Definition: gx_portmap.h:53
gx_jack::GxJack
Definition: gx_jack.h:109
gx_portmap::PortMapWindow
Definition: gx_portmap.h:57
gx_portmap::PortAttr
Definition: gx_portmap.h:41
gx_portmap::PortMapWindow::create
static PortMapWindow * create(gx_engine::GxMachineBase &machine, Glib::RefPtr< Gtk::AccelGroup > ag)
Definition: gx_portmap.cpp:554
gx_portmap::PortMapWindow::refresh
void refresh()
Definition: gx_portmap.cpp:651
gx_portmap::PortMapWindow::connection_changed
void connection_changed(string port1, string port2, bool conn)
Definition: gx_portmap.cpp:321
gx_portmap::PortMapWindow::signal_response
Glib::SignalProxy1< void, int > signal_response()
Definition: gx_portmap.h:93
gx_portmap::PortSection::scrolled_window
Gtk::ScrolledWindow * scrolled_window
Definition: gx_portmap.h:51
gx_portmap::PortAttr::is_insert
const bool is_insert
Definition: gx_portmap.h:44
gx_portmap
Definition: gx_portmap.h:36
gx_portmap::PortSection::port_attr
PortAttr * port_attr
Definition: gx_portmap.h:54