Gui progress
git-svn-id: file:///home/vcs/svn/jsweeper/trunk@6 6611ac79-6612-48ef-a1e9-b906f853523emaster
parent
52d27c7796
commit
01c06da832
|
@ -22,6 +22,7 @@ void Config::Read()
|
|||
CellPadding = group->GetValue("cellpadding", 3);
|
||||
FontSize = group->GetValue("fontsize", 10);
|
||||
FontFace = group->GetValue("fontface", "Sans");
|
||||
SeparateByPortType = group->GetValue("separatebyporttype", false);
|
||||
ExpandClients = group->GetValue("expandclients", true);
|
||||
ExpandGroups = group->GetValue("expandgroups", false);
|
||||
|
||||
|
@ -54,7 +55,7 @@ void Config::Write()
|
|||
group->SetValue("cellpadding", CellPadding);
|
||||
group->SetValue("fontsize", FontSize);
|
||||
group->SetValue("fontface", FontFace);
|
||||
|
||||
group->SetValue("separatebyporttype", SeparateByPortType);
|
||||
group->SetValue("expandclients", ExpandClients);
|
||||
group->SetValue("expandgroups", ExpandGroups);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
int FontSize;
|
||||
std::string FontFace;
|
||||
|
||||
bool SeparateByPortType;
|
||||
bool ExpandClients;
|
||||
bool ExpandGroups;
|
||||
|
||||
|
|
181
src/gui.cpp
181
src/gui.cpp
|
@ -10,21 +10,14 @@ Glib::RefPtr<Gtk::Builder> g_builder;
|
|||
|
||||
Gui::Gui(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder)
|
||||
: Gtk::Window(cobject),
|
||||
m_scrolledwindow_audio(NULL),
|
||||
m_scrolledwindow_midi(NULL)
|
||||
m_vbox(NULL),
|
||||
m_matrix_audio(NULL),
|
||||
m_matrix_midi(NULL),
|
||||
m_closing(false)
|
||||
{
|
||||
builder->get_widget("scrolledwindow_audio", m_scrolledwindow_audio);
|
||||
builder->get_widget("scrolledwindow_midi", m_scrolledwindow_midi);
|
||||
|
||||
if (m_scrolledwindow_audio != NULL) {
|
||||
m_scrolledwindow_audio->add(m_matrix);
|
||||
}
|
||||
if (m_scrolledwindow_midi != NULL) {
|
||||
m_scrolledwindow_midi->add(m_matrix);
|
||||
}
|
||||
|
||||
m_matrix.parent = this;
|
||||
builder->get_widget("vbox1", m_vbox);
|
||||
|
||||
SetPortTypeSeparation();
|
||||
Refresh();
|
||||
|
||||
Glib::signal_idle().connect(sigc::mem_fun(*this, &Gui::on_idle));
|
||||
|
@ -35,6 +28,76 @@ Gui::Gui(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder)
|
|||
|
||||
Gui::~Gui()
|
||||
{
|
||||
m_closing = true;
|
||||
delete m_matrix_audio;
|
||||
delete m_matrix_midi;
|
||||
}
|
||||
|
||||
void Gui::SetPortTypeSeparation()
|
||||
{
|
||||
if (cfg.SeparateByPortType) {
|
||||
if (m_matrix_audio && m_matrix_midi) return;
|
||||
|
||||
m_scrolledwindow_audio.remove();
|
||||
m_scrolledwindow_midi.remove();
|
||||
|
||||
if (m_notebook.pages().size() > 0) {
|
||||
m_notebook.remove(m_scrolledwindow_audio);
|
||||
m_notebook.remove(m_scrolledwindow_midi);
|
||||
}
|
||||
|
||||
if (m_vbox->children().size() == 3) {
|
||||
m_vbox->remove(m_scrolledwindow_audio);
|
||||
}
|
||||
|
||||
delete m_matrix_audio;
|
||||
delete m_matrix_midi;
|
||||
|
||||
m_matrix_audio = new Matrix(PT_AUDIO);
|
||||
m_matrix_midi = new Matrix(PT_MIDI);
|
||||
|
||||
m_notebook.pages().clear();
|
||||
|
||||
m_notebook.pages().push_back(
|
||||
Gtk::Notebook_Helpers::TabElem(m_scrolledwindow_audio, "Audio"));
|
||||
m_scrolledwindow_audio.add(*m_matrix_audio);
|
||||
m_scrolledwindow_audio.show();
|
||||
|
||||
m_notebook.pages().push_back(
|
||||
Gtk::Notebook_Helpers::TabElem(m_scrolledwindow_midi, "MIDI"));
|
||||
m_scrolledwindow_midi.add(*m_matrix_midi);
|
||||
m_scrolledwindow_midi.show();
|
||||
|
||||
m_notebook.show();
|
||||
m_notebook.signal_switch_page().connect(sigc::mem_fun(*this, &Gui::on_notebook_switch_page));
|
||||
|
||||
m_vbox->pack_start(m_notebook);
|
||||
} else {
|
||||
if (m_matrix_audio && !m_matrix_midi) return;
|
||||
|
||||
m_scrolledwindow_audio.remove();
|
||||
m_scrolledwindow_midi.remove();
|
||||
|
||||
if (m_notebook.pages().size() > 0) {
|
||||
m_notebook.remove(m_scrolledwindow_audio);
|
||||
m_notebook.remove(m_scrolledwindow_midi);
|
||||
}
|
||||
|
||||
if (m_vbox->children().size() == 3) {
|
||||
m_vbox->remove(m_notebook);
|
||||
}
|
||||
|
||||
delete m_matrix_audio;
|
||||
delete m_matrix_midi;
|
||||
|
||||
m_matrix_audio = new Matrix(PT_ALL);
|
||||
m_matrix_midi = NULL;
|
||||
|
||||
m_scrolledwindow_audio.add(*m_matrix_audio);
|
||||
m_scrolledwindow_audio.show();
|
||||
|
||||
m_vbox->pack_start(m_scrolledwindow_audio);
|
||||
}
|
||||
}
|
||||
|
||||
Gui *Gui::Open()
|
||||
|
@ -50,11 +113,22 @@ Gui *Gui::Open()
|
|||
|
||||
void Gui::Refresh()
|
||||
{
|
||||
m_matrix.Refresh();
|
||||
if (m_closing) return;
|
||||
|
||||
if (cfg.SeparateByPortType) {
|
||||
int page = m_notebook.get_current_page();
|
||||
|
||||
if (page == 0 && m_matrix_audio != NULL) m_matrix_audio->Refresh();
|
||||
if (page == 1 && m_matrix_midi != NULL) m_matrix_midi->Refresh();
|
||||
} else {
|
||||
if (m_matrix_audio != NULL) m_matrix_audio->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
bool Gui::on_idle()
|
||||
{
|
||||
if (m_closing) return false;
|
||||
|
||||
if (jack.ProcessEvents()) {
|
||||
Refresh();
|
||||
queue_draw();
|
||||
|
@ -65,9 +139,66 @@ bool Gui::on_idle()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Gui::on_notebook_switch_page(GtkNotebookPage * /* page */, guint /* page_num */)
|
||||
{
|
||||
if (m_closing) return;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
Preferences::Preferences(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder)
|
||||
: Gtk::Dialog(cobject)
|
||||
{
|
||||
builder->get_widget("button_preferences_close", button_preferences_close);
|
||||
|
||||
builder->get_widget("check_separate_port_type", check_separate_port_type);
|
||||
builder->get_widget("check_expand_clients", check_expand_clients);
|
||||
builder->get_widget("check_expand_groups", check_expand_groups);
|
||||
|
||||
builder->get_widget("check_default_location", check_default_location);
|
||||
builder->get_widget("filechooser_custom_location", filechooser_custom_location);
|
||||
|
||||
builder->get_widget("check_activate_connections", check_activate_connections);
|
||||
builder->get_widget("treeview_connections", treeview_connections);
|
||||
builder->get_widget("button_connections_add", button_connections_add);
|
||||
builder->get_widget("button_connections_remove", button_connections_remove);
|
||||
builder->get_widget("button_connections_edit", button_connections_edit);
|
||||
builder->get_widget("button_connections_up", button_connections_up);
|
||||
builder->get_widget("button_connections_down", button_connections_down);
|
||||
|
||||
builder->get_widget("check_activate_aliases", check_activate_aliases);
|
||||
builder->get_widget("treeview_aliases", treeview_aliases);
|
||||
builder->get_widget("button_aliases_add", button_aliases_add);
|
||||
builder->get_widget("button_aliases_remove", button_aliases_remove);
|
||||
builder->get_widget("button_aliases_edit", button_aliases_edit);
|
||||
builder->get_widget("button_aliases_up", button_aliases_up);
|
||||
builder->get_widget("button_aliases_down", button_aliases_down);
|
||||
|
||||
builder->get_widget("fontbutton_font", fontbutton_font);
|
||||
builder->get_widget("spin_cell_padding", spin_cell_padding);
|
||||
|
||||
builder->get_widget("colorbutton_background", colour_background);
|
||||
builder->get_widget("colorbutton_clients", colour_clients);
|
||||
builder->get_widget("colorbutton_port_groups", colour_port_groups);
|
||||
builder->get_widget("colorbutton_ports_audio", colour_ports_audio);
|
||||
builder->get_widget("colorbutton_ports_midi", colour_ports_midi);
|
||||
builder->get_widget("colorbutton_text", colour_text);
|
||||
builder->get_widget("colorbutton_grid_client", colour_grid_client);
|
||||
builder->get_widget("colorbutton_grid_group", colour_grid_group);
|
||||
builder->get_widget("colorbutton_grid_port", colour_grid_port);
|
||||
|
||||
check_separate_port_type->set_active(cfg.SeparateByPortType);
|
||||
check_expand_clients->set_active(cfg.ExpandClients);
|
||||
check_expand_groups->set_active(cfg.ExpandGroups);
|
||||
|
||||
fontbutton_font->set_font_name(cfg.FontFace);
|
||||
spin_cell_padding->set_value(cfg.CellPadding);
|
||||
|
||||
button_preferences_close->signal_clicked().connect(sigc::mem_fun(*this, &Preferences::on_preferences_close_click));
|
||||
|
||||
check_separate_port_type->signal_clicked().connect(sigc::mem_fun(*this, &Preferences::on_check_separate_port_type_click));
|
||||
check_expand_clients->signal_clicked().connect(sigc::mem_fun(*this, &Preferences::on_check_expand_clients_click));
|
||||
check_expand_groups->signal_clicked().connect(sigc::mem_fun(*this, &Preferences::on_check_expand_groups_click));
|
||||
}
|
||||
|
||||
Preferences *Preferences::Open()
|
||||
|
@ -76,3 +207,25 @@ Preferences *Preferences::Open()
|
|||
g_builder->get_widget_derived("dialog_preferences", window);
|
||||
return window;
|
||||
}
|
||||
|
||||
void Preferences::on_preferences_close_click()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
void Preferences::on_check_separate_port_type_click()
|
||||
{
|
||||
cfg.SeparateByPortType = check_separate_port_type->get_active();
|
||||
g->SetPortTypeSeparation();
|
||||
g->Refresh();
|
||||
}
|
||||
|
||||
void Preferences::on_check_expand_clients_click()
|
||||
{
|
||||
cfg.ExpandClients = check_expand_clients->get_active();
|
||||
}
|
||||
|
||||
void Preferences::on_check_expand_groups_click()
|
||||
{
|
||||
cfg.ExpandGroups = check_expand_groups->get_active();
|
||||
}
|
||||
|
|
68
src/gui.h
68
src/gui.h
|
@ -9,9 +9,15 @@ extern Glib::RefPtr<Gtk::Builder> g_builder;
|
|||
class Gui : public Gtk::Window
|
||||
{
|
||||
private:
|
||||
Gtk::ScrolledWindow *m_scrolledwindow_audio;
|
||||
Gtk::ScrolledWindow *m_scrolledwindow_midi;
|
||||
Matrix m_matrix;
|
||||
Gtk::Notebook m_notebook;
|
||||
Gtk::ScrolledWindow m_scrolledwindow_audio;
|
||||
Gtk::ScrolledWindow m_scrolledwindow_midi;
|
||||
|
||||
Gtk::VBox *m_vbox;
|
||||
Matrix *m_matrix_audio;
|
||||
Matrix *m_matrix_midi;
|
||||
|
||||
bool m_closing;
|
||||
|
||||
public:
|
||||
Gui(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder);
|
||||
|
@ -19,17 +25,73 @@ public:
|
|||
static Gui *Open();
|
||||
virtual ~Gui();
|
||||
|
||||
void SetPortTypeSeparation();
|
||||
void Refresh();
|
||||
|
||||
protected:
|
||||
bool on_idle();
|
||||
void on_notebook_switch_page(GtkNotebookPage * /* page */, guint /* page_num */);
|
||||
};
|
||||
|
||||
class Preferences : public Gtk::Dialog
|
||||
{
|
||||
private:
|
||||
Gtk::Button *button_preferences_close;
|
||||
|
||||
// Grid behaviour
|
||||
Gtk::CheckButton *check_separate_port_type;
|
||||
Gtk::CheckButton *check_expand_clients;
|
||||
Gtk::CheckButton *check_expand_groups;
|
||||
|
||||
// Session
|
||||
Gtk::CheckButton *check_default_location;
|
||||
Gtk::FileChooserButton *filechooser_custom_location;
|
||||
|
||||
// Connections
|
||||
Gtk::CheckButton *check_activate_connections;
|
||||
Gtk::TreeView *treeview_connections;
|
||||
Gtk::Button *button_connections_add;
|
||||
Gtk::Button *button_connections_remove;
|
||||
Gtk::Button *button_connections_edit;
|
||||
Gtk::Button *button_connections_up;
|
||||
Gtk::Button *button_connections_down;
|
||||
|
||||
// Aliases
|
||||
Gtk::CheckButton *check_activate_aliases;
|
||||
Gtk::TreeView *treeview_aliases;
|
||||
Gtk::Button *button_aliases_add;
|
||||
Gtk::Button *button_aliases_remove;
|
||||
Gtk::Button *button_aliases_edit;
|
||||
Gtk::Button *button_aliases_up;
|
||||
Gtk::Button *button_aliases_down;
|
||||
|
||||
// Grid layout
|
||||
Gtk::FontButton *fontbutton_font;
|
||||
Gtk::SpinButton *spin_cell_padding;
|
||||
|
||||
// Colours
|
||||
Gtk::ColorButton *colour_background;
|
||||
Gtk::ColorButton *colour_clients;
|
||||
Gtk::ColorButton *colour_port_groups;
|
||||
Gtk::ColorButton *colour_ports_audio;
|
||||
Gtk::ColorButton *colour_ports_midi;
|
||||
Gtk::ColorButton *colour_text;
|
||||
Gtk::ColorButton *colour_grid_client;
|
||||
Gtk::ColorButton *colour_grid_group;
|
||||
Gtk::ColorButton *colour_grid_port;
|
||||
|
||||
public:
|
||||
Preferences(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder);
|
||||
static Preferences *Open();
|
||||
|
||||
protected:
|
||||
void on_preferences_close_click();
|
||||
|
||||
void on_check_separate_port_type_click();
|
||||
void on_check_expand_clients_click();
|
||||
void on_check_expand_groups_click();
|
||||
};
|
||||
|
||||
extern Gui *g;
|
||||
|
||||
#endif // GUI_H
|
||||
|
|
21
src/jack.cpp
21
src/jack.cpp
|
@ -39,25 +39,7 @@ void JackDriver::Connect()
|
|||
|
||||
jack_activate(m_client);
|
||||
|
||||
const char **ports = jack_get_ports(m_client, NULL, NULL, 0);
|
||||
|
||||
for (int i = 0; ports[i] != NULL; ++i) {
|
||||
pm.Add(jack_port_by_name(m_client, ports[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; ports[i] != NULL; ++i) {
|
||||
jack_port_t *port = jack_port_by_name(m_client, ports[i]);
|
||||
if (jack_port_flags(port) & JackPortIsInput) {
|
||||
const char **connections = jack_port_get_all_connections(m_client, port);
|
||||
if (connections != NULL) {
|
||||
for (int j = 0; connections[j] != NULL; ++j) {
|
||||
pm.Connect(port, jack_port_by_name(m_client, connections[j]));
|
||||
}
|
||||
free(connections);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(ports);
|
||||
pm.Refresh();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -150,4 +132,3 @@ void JackDriver::Disconnect(jack_port_t *a, jack_port_t *b)
|
|||
{
|
||||
jack_disconnect(m_client, jack_port_name(a), jack_port_name(b));
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
|
||||
void Connect(jack_port_t *a, jack_port_t *b);
|
||||
void Disconnect(jack_port_t *a, jack_port_t *b);
|
||||
|
||||
jack_client_t *GetClient() { return m_client; }
|
||||
};
|
||||
|
||||
extern JackDriver jack;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
PortManager pm;
|
||||
JackDriver jack;
|
||||
Config cfg;
|
||||
Gui *g;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
@ -17,7 +18,7 @@ int main(int argc, char **argv)
|
|||
|
||||
jack.Connect();
|
||||
|
||||
Gui *g = Gui::Open();
|
||||
g = Gui::Open();
|
||||
kit.run(*g);
|
||||
delete g;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.4.5 on Thu Nov 26 09:25:38 2009 -->
|
||||
<!--Generated with glade3 3.4.5 on Thu Nov 26 16:17:28 2009 -->
|
||||
<glade-interface>
|
||||
<widget class="GtkWindow" id="window1">
|
||||
<property name="title" translatable="yes">JACK Sweeper</property>
|
||||
|
@ -153,64 +153,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkNotebook" id="notebook2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow_audio">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label13">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Audio</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
<property name="tab_fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow_midi">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label14">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">MIDI</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
<property name="position">1</property>
|
||||
<property name="tab_fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkStatusbar" id="statusbar1">
|
||||
|
@ -219,6 +162,7 @@
|
|||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
@ -277,7 +221,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="check_separate_midi">
|
||||
<widget class="GtkCheckButton" id="check_separate_port_type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Use separate pane for MIDI ports</property>
|
||||
|
@ -898,8 +842,8 @@
|
|||
<child>
|
||||
<widget class="GtkTable" id="table2">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="n_rows">5</property>
|
||||
<property name="n_columns">4</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<child>
|
||||
|
@ -940,7 +884,7 @@
|
|||
<widget class="GtkLabel" id="label11">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Port tabs:</property>
|
||||
<property name="label" translatable="yes">Audio port tabs:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">3</property>
|
||||
|
@ -995,7 +939,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorbutton_ports">
|
||||
<widget class="GtkColorButton" id="colorbutton_ports_audio">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
|
@ -1010,6 +954,174 @@
|
|||
<property name="x_options">GTK_EXPAND</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label13">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">MIDI port tabs:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorbutton_ports_midi">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_EXPAND</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label14">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Foreground:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorbutton_text">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="right_attach">4</property>
|
||||
<property name="x_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorbutton_grid_client">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="right_attach">4</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorbutton_grid_group">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="right_attach">4</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorbutton_grid_port">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<property name="color">#000000000000</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="right_attach">4</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label30">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="right_attach">4</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label31">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Grid lines (clients):</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label32">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Grid lines (groups):</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label33">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Grid lines (ports):</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label34">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="right_attach">3</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
const Rect Rect::None = Rect(0, 0, -1, -1);
|
||||
|
||||
Matrix::Matrix() :
|
||||
m_client_width(0), m_client_height(0), m_port_width(0), m_port_height(0), m_separation(0)
|
||||
Matrix::Matrix(PortType port_type) :
|
||||
m_client_width(0), m_client_height(0), m_port_width(0), m_port_height(0), m_separation(0), m_port_type(port_type)
|
||||
{
|
||||
set_size_request(0, 0);
|
||||
show();
|
||||
|
@ -45,6 +45,9 @@ void Matrix::Refresh()
|
|||
PortList::iterator plit;
|
||||
for (plit = pm.m_ports.begin(); plit != pm.m_ports.end(); ++plit) {
|
||||
Port *p = *plit;
|
||||
|
||||
if (m_port_type != PT_ALL && m_port_type != (p->m_is_midi ? PT_MIDI : PT_AUDIO)) continue;
|
||||
|
||||
p->rect = Rect::None;
|
||||
}
|
||||
|
||||
|
@ -52,6 +55,8 @@ void Matrix::Refresh()
|
|||
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||
Client *c = *clit;
|
||||
|
||||
if (m_port_type != PT_ALL && m_port_type != (c->m_is_midi ? PT_MIDI : PT_AUDIO)) continue;
|
||||
|
||||
cr->get_text_extents(c->m_name, c->extents);
|
||||
|
||||
int width = c->extents.width + cfg.CellPadding * 2;
|
||||
|
@ -149,6 +154,8 @@ void Matrix::Refresh()
|
|||
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||
Client *c = *clit;
|
||||
|
||||
if (m_port_type != PT_ALL && m_port_type != (c->m_is_midi ? PT_MIDI : PT_AUDIO)) continue;
|
||||
|
||||
if (c->m_is_input) {
|
||||
r.left = x;
|
||||
r.top = cfg.CellPadding;
|
||||
|
@ -282,7 +289,6 @@ void Matrix::Refresh()
|
|||
m_height = h;
|
||||
|
||||
set_size_request(w, h);
|
||||
// parent->set_size_request(w + 20, h + 20);
|
||||
}
|
||||
|
||||
static void SetColour(Cairo::RefPtr<Cairo::Context> cr, Colour &c)
|
||||
|
@ -337,6 +343,9 @@ bool Matrix::on_expose_event(GdkEventExpose *event)
|
|||
ClientList::iterator clit;
|
||||
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||
Client *c = *clit;
|
||||
|
||||
if (m_port_type != PT_ALL && m_port_type != (c->m_is_midi ? PT_MIDI : PT_AUDIO)) continue;
|
||||
|
||||
r = c->rect;
|
||||
|
||||
if (c->m_is_input) {
|
||||
|
|
12
src/matrix.h
12
src/matrix.h
|
@ -8,6 +8,12 @@
|
|||
|
||||
typedef std::list<Base *> BaseList;
|
||||
|
||||
enum PortType {
|
||||
PT_ALL,
|
||||
PT_AUDIO,
|
||||
PT_MIDI
|
||||
};
|
||||
|
||||
class Matrix : public Gtk::DrawingArea
|
||||
{
|
||||
private:
|
||||
|
@ -19,17 +25,17 @@ private:
|
|||
int m_width;
|
||||
int m_height;
|
||||
|
||||
PortType m_port_type;
|
||||
|
||||
BaseList across;
|
||||
BaseList down;
|
||||
|
||||
public:
|
||||
Matrix();
|
||||
Matrix(PortType port_type);
|
||||
virtual ~Matrix();
|
||||
|
||||
void Refresh();
|
||||
|
||||
Gtk::Window *parent;
|
||||
|
||||
protected:
|
||||
void Box(Cairo::RefPtr<Cairo::Context> cr, Colour &c, Rect &rect);
|
||||
virtual bool on_expose_event(GdkEventExpose *event);
|
||||
|
|
|
@ -5,6 +5,36 @@
|
|||
#include "portmanager.h"
|
||||
#include "config.h"
|
||||
|
||||
void PortManager::Refresh()
|
||||
{
|
||||
// Clear all information
|
||||
m_clients.clear();
|
||||
m_ports.clear();
|
||||
|
||||
jack_client_t *client = jack.GetClient();
|
||||
|
||||
const char **ports = jack_get_ports(client, NULL, NULL, 0);
|
||||
|
||||
for (int i = 0; ports[i] != NULL; ++i) {
|
||||
Add(jack_port_by_name(client, ports[i]));
|
||||
}
|
||||
|
||||
for (int i = 0; ports[i] != NULL; ++i) {
|
||||
jack_port_t *port = jack_port_by_name(client, ports[i]);
|
||||
if (jack_port_flags(port) & JackPortIsInput) {
|
||||
const char **connections = jack_port_get_all_connections(client, port);
|
||||
if (connections != NULL) {
|
||||
for (int j = 0; connections[j] != NULL; ++j) {
|
||||
pm.Connect(port, jack_port_by_name(client, connections[j]));
|
||||
}
|
||||
free(connections);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(ports);
|
||||
}
|
||||
|
||||
void PortManager::Add(jack_port_t *port)
|
||||
{
|
||||
std::string jack_name = jack_port_name(port);
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
AliasList m_aliases;
|
||||
|
||||
public:
|
||||
void Refresh();
|
||||
void Add(jack_port_t *port);
|
||||
void Delete(jack_port_t *port);
|
||||
|
||||
|
|
Loading…
Reference in New Issue