diff --git a/CMakeLists.txt b/CMakeLists.txt index f7fd238..47d03b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ INCLUDE( ${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake ) pkg_check_modules(JACK jack>=0.118) pkg_check_modules(GTKMM gtkmm-2.4>=2.4) pkg_check_modules(CAIROMM cairomm-1.0>=1.0) +pkg_check_modules(DBUS dbus-glib-1) SET(SOURCES src/config.cpp @@ -27,18 +28,22 @@ SET(SOURCES src/port.h src/portmanager.cpp src/portmanager.h + src/session.cpp + src/session.h ) LINK_DIRECTORIES( ${JACK_LIBRARY_DIRS} ${GTKMM_LIBRARY_DIRS} ${CAIROMM_LIBRARY_DIRS} + ${DBUS_LIBRARY_DIRS} ) INCLUDE_DIRECTORIES( ${JACK_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS} ${CAIROMM_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} ) ADD_DEFINITIONS(-g -Wall -Wextra -ansi -pedantic) @@ -48,4 +53,5 @@ TARGET_LINK_LIBRARIES(jsweeper ${JACK_LIBRARIES} ${GTKMM_LIBRARIES} ${CAIROMM_LIBRARIES} + ${DBUS_LIBRARIES} ) diff --git a/src/gui.cpp b/src/gui.cpp index 3d120a4..478b5f2 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -5,6 +5,7 @@ #include "portmanager.h" #include "gui.h" #include "config.h" +#include "session.h" Glib::RefPtr g_builder; @@ -158,33 +159,43 @@ void Gui::on_quit() { hide(); } + void Gui::on_session_open() { + SessionOpenGui *sgui = SessionOpenGui::Open(); + sgui->show(); } + void Gui::on_session_save() { } + void Gui::on_session_save_as() { } + void Gui::on_session_close() { } + void Gui::on_preferences() { Preferences *p = Preferences::Open(); p->show(); } + void Gui::on_connect() { jack.Connect(); Refresh(); } + void Gui::on_disconnect() { jack.Disconnect(); Refresh(); } + void Gui::on_about() { Gtk::AboutDialog *about; g_builder->get_widget("aboutdialog1", about); diff --git a/src/jsweeper.glade b/src/jsweeper.glade index e26e446..cac7504 100644 --- a/src/jsweeper.glade +++ b/src/jsweeper.glade @@ -1,6 +1,6 @@ - + JACK Sweeper @@ -750,12 +750,27 @@ 6 6 - + True - 0 - Font: + True + 0 0 100 1 10 10 + 1 + 2 + 1 + 2 + + + + + True + 0 + Cell padding: + + + 1 + 2 GTK_FILL @@ -772,30 +787,15 @@ - + True 0 - Cell padding: + Font: - 1 - 2 GTK_FILL - - - True - True - 0 0 100 1 10 10 - - - 1 - 2 - 1 - 2 - - 1 @@ -847,169 +847,73 @@ 6 6 - + True - 0 - Background: - - - GTK_FILL - - - - - True - 0 - Client tabs: - - - 1 - 2 - GTK_FILL - - - - - True - 0 - Port group tabs: - - - 2 - 3 - GTK_FILL - - - - - True - 0 - Audio port tabs: - - - 3 - 4 - GTK_FILL - - - - - True - True - True - 0 - #000000000000 - - - 1 - 2 - - - - - - True - True - True - 0 - #000000000000 - - - 1 - 2 - 1 - 2 - GTK_EXPAND - - - - - True - True - True - 0 - #000000000000 - - - 1 - 2 - 2 - 3 - GTK_EXPAND - - - - - True - True - True - 0 - #000000000000 - - - 1 - 2 - 3 - 4 - GTK_EXPAND - - - - - True - 0 - MIDI port tabs: - - - 4 - 5 - GTK_FILL - - - - - True - True - True - 0 - #000000000000 - - - 1 - 2 - 4 - 5 - GTK_EXPAND - - - - - True - 0 - Foreground: 2 3 + 4 + 5 GTK_FILL - + True - True - True - 0 - #000000000000 + 0 + Grid lines (ports): - 3 - 4 - + 2 + 3 + 3 + 4 + GTK_FILL - + + True + 0 + Grid lines (groups): + + + 2 + 3 + 2 + 3 + GTK_FILL + + + + + True + 0 + Grid lines (clients): + + + 2 + 3 + 1 + 2 + GTK_FILL + + + + + True + + + 3 + 4 + 4 + 5 + GTK_FILL + + + + True True True @@ -1019,8 +923,8 @@ 3 4 - 1 - 2 + 3 + 4 @@ -1041,7 +945,7 @@ - + True True True @@ -1051,74 +955,170 @@ 3 4 - 3 - 4 + 1 + 2 - + True + True + True + 0 + #000000000000 3 4 + + + + + + True + 0 + Foreground: + + + 2 + 3 + GTK_FILL + + + + + True + True + True + 0 + #000000000000 + + + 1 + 2 + 4 + 5 + GTK_EXPAND + + + + + True + 0 + MIDI port tabs: + + 4 5 GTK_FILL - + True - 0 - Grid lines (clients): + True + True + 0 + #000000000000 - 2 - 3 + 1 + 2 + 3 + 4 + GTK_EXPAND + + + + + True + True + True + 0 + #000000000000 + + + 1 + 2 + 2 + 3 + GTK_EXPAND + + + + + True + True + True + 0 + #000000000000 + + + 1 + 2 1 2 + GTK_EXPAND + + + + + True + True + True + 0 + #000000000000 + + + 1 + 2 + + + + + + True + 0 + Audio port tabs: + + + 3 + 4 GTK_FILL - + True 0 - Grid lines (groups): + Port group tabs: - 2 - 3 2 3 GTK_FILL - + True 0 - Grid lines (ports): + Client tabs: - 2 - 3 - 3 - 4 + 1 + 2 GTK_FILL - + True + 0 + Background: - 2 - 3 - 4 - 5 GTK_FILL @@ -1236,25 +1236,29 @@ 6 6 - + True True + Stop after matching rule + 0 + True - 1 2 - 1 - 2 + 2 + 3 - + True - True + 0 + _Source match rule: + True + True - 1 - 2 + GTK_FILL @@ -1272,29 +1276,25 @@ - + True - 0 - _Source match rule: - True - True + True - GTK_FILL + 1 + 2 - + True True - Stop after matching rule - 0 - True + 1 2 - 2 - 3 + 1 + 2 @@ -1359,25 +1359,29 @@ 6 6 - + True True + Stop after matching rule + 0 + True - 1 2 - 1 - 2 + 2 + 3 - + True - True + 0 + _Match rule: + True + True - 1 - 2 + GTK_FILL @@ -1395,29 +1399,25 @@ - + True - 0 - _Match rule: - True - True + True - GTK_FILL + 1 + 2 - + True True - Stop after matching rule - 0 - True + 1 2 - 2 - 3 + 1 + 2 @@ -1462,4 +1462,102 @@ + + 5 + Open Session + False + GTK_WIN_POS_CENTER_ON_PARENT + GDK_WINDOW_TYPE_HINT_DIALOG + False + + + True + 2 + + + True + 5 + 6 + + + True + 0 + <b>Open session</b> + True + + + False + False + + + + + True + + + True + + + + + False + False + + + + + True + + + 1 + + + + + 1 + + + + + False + False + 1 + + + + + True + GTK_BUTTONBOX_END + + + True + True + True + gtk-cancel + True + 0 + + + + + True + True + True + gtk-ok + True + 0 + + + 1 + + + + + False + GTK_PACK_END + + + + + diff --git a/src/matrix.h b/src/matrix.h index 2fd9d5e..875080b 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -6,6 +6,7 @@ #include "rect.h" #include "colour.h" +struct Base; typedef std::list BaseList; enum PortType { diff --git a/src/session.cpp b/src/session.cpp new file mode 100644 index 0000000..f5390da --- /dev/null +++ b/src/session.cpp @@ -0,0 +1,129 @@ +#include +#include +#include "session.h" +#include "gui.h" + +DBusGConnection *connection; +DBusGProxy *proxy; + +Session::Session() +{ + GError *error = NULL; + + g_type_init(); + + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + + if (connection == NULL) return; + + proxy = dbus_g_proxy_new_for_name( + connection, "org.jackaudio.sessionmanager", + "/org/jackaudio/sessionmanager", "org.jackaudio.sessionmanager"); +} + +Session::~Session() +{ + g_object_unref(proxy); +} + +int Session::SaveAs(std::string name) +{ + GError *error = NULL; + int ret; + + if (proxy == NULL) return -1; + + dbus_g_proxy_call(proxy, "save_as", &error, + G_TYPE_STRING, name.c_str(), + G_TYPE_INVALID, + G_TYPE_INT, &ret, + G_TYPE_INVALID); + + return ret; +} + +int Session::Load(std::string name) +{ + GError *error = NULL; + int ret; + + if (proxy == NULL) return -1; + + dbus_g_proxy_call(proxy, "load", &error, + G_TYPE_STRING, name.c_str(), + G_TYPE_INVALID, + G_TYPE_INT, &ret, + G_TYPE_INVALID); + + return ret; +} + +std::list Session::List() +{ + GError *error = NULL; + char **session_list; + char **session_list_ptr; + std::list list; + + if (proxy == NULL) return list; + + dbus_g_proxy_call(proxy, "list", &error, + G_TYPE_INVALID, + G_TYPE_STRV, &session_list, + G_TYPE_INVALID); + + if (session_list == NULL) return list; + + for (session_list_ptr = session_list; *session_list_ptr; session_list_ptr++) { + list.push_back(*session_list_ptr); + } + + g_strfreev(session_list); + + return list; +} + +Session s; + +// Session Open window + +SessionOpenGui *SessionOpenGui::Open() +{ + SessionOpenGui *window = NULL; + g_builder->get_widget_derived("dialog_session_open", window); + return window; +} + +SessionOpenGui::SessionOpenGui(BaseObjectType *cobject, const Glib::RefPtr &builder) + : Gtk::Dialog(cobject) +{ + builder->get_widget("combobox_session_open", combobox_session_open); + builder->get_widget("button_session_open_cancel", button_session_open_cancel); + builder->get_widget("button_session_open_okay", button_session_open_okay); + + m_tree_model = Gtk::ListStore::create(m_columns); + combobox_session_open->set_model(m_tree_model); + + Gtk::TreeModel::Row row; + std::list sessions = s.List(); + std::list::iterator it; + for (it = sessions.begin(); it != sessions.end(); ++it) { + row = *(m_tree_model->append()); + row[m_columns.m_name] = *it; + } + + combobox_session_open->pack_start(m_columns.m_name); + + button_session_open_cancel->signal_clicked().connect(sigc::mem_fun(*this, &SessionOpenGui::on_cancel)); + button_session_open_okay->signal_clicked().connect(sigc::mem_fun(*this, &SessionOpenGui::on_okay)); +} + +void SessionOpenGui::on_cancel() +{ + hide(); +} + +void SessionOpenGui::on_okay() +{ + hide(); +} diff --git a/src/session.h b/src/session.h new file mode 100644 index 0000000..8266d8f --- /dev/null +++ b/src/session.h @@ -0,0 +1,51 @@ +#ifndef SESSION_H +#define SESSION_H + +#include +#include +#include +#include "glib.h" + +class Session +{ +public: + Session(); + ~Session(); + + int SaveAs(std::string name); + int Load(std::string name); + std::list List(); +}; + +class SessionOpenGui : public Gtk::Dialog +{ +private: + Gtk::ComboBox *combobox_session_open; + Gtk::Button *button_session_open_cancel; + Gtk::Button *button_session_open_okay; + +public: + SessionOpenGui(BaseObjectType *cobject, const Glib::RefPtr &builder); + + static SessionOpenGui *Open(); + +protected: + void on_cancel(); + void on_okay(); + + class ModelColumns : public Gtk::TreeModel::ColumnRecord + { + public: + ModelColumns() + { + add(m_name); + } + + Gtk::TreeModelColumn m_name; + }; + + ModelColumns m_columns; + Glib::RefPtr m_tree_model; +}; + +#endif // SESSION_H