Start of DBus sessionmanager.py support

git-svn-id: file:///home/vcs/svn/jsweeper/trunk@10 6611ac79-6612-48ef-a1e9-b906f853523e
master
petern 2009-11-27 17:19:30 +00:00
parent 242d908852
commit 5c7f2794e0
6 changed files with 531 additions and 235 deletions

View File

@ -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}
)

View File

@ -5,6 +5,7 @@
#include "portmanager.h"
#include "gui.h"
#include "config.h"
#include "session.h"
Glib::RefPtr<Gtk::Builder> 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);

View File

@ -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 16:17:28 2009 -->
<!--Generated with glade3 3.4.5 on Fri Nov 27 15:54:25 2009 -->
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="title" translatable="yes">JACK Sweeper</property>
@ -750,12 +750,27 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkLabel" id="label6">
<widget class="GtkSpinButton" id="spin_cell_padding">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Font:</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Cell padding:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -772,30 +787,15 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label8">
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Cell padding:</property>
<property name="label" translatable="yes">Font:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_cell_padding">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
@ -847,169 +847,73 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkLabel" id="label7">
<widget class="GtkLabel" id="label34">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Background:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Client tabs:</property>
</widget>
<packing>
<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="label10">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Port group tabs:</property>
</widget>
<packing>
<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="label11">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Audio port tabs:</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_background">
<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="x_options"></property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_clients">
<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">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_port_groups">
<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">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_ports_audio">
<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">3</property>
<property name="bottom_attach">4</property>
<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="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_text">
<widget class="GtkLabel" id="label33">
<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>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grid lines (ports):</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="x_options"></property>
<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="GtkColorButton" id="colorbutton_grid_client">
<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="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="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="GtkColorButton" id="colorbutton_grid_port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -1019,8 +923,8 @@
<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="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options"></property>
</packing>
</child>
@ -1041,7 +945,7 @@
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_grid_port">
<widget class="GtkColorButton" id="colorbutton_grid_client">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@ -1051,74 +955,170 @@
<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="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label30">
<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="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_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="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="GtkLabel" id="label31">
<widget class="GtkColorButton" id="colorbutton_ports_audio">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grid lines (clients):</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">2</property>
<property name="right_attach">3</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_port_groups">
<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">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_clients">
<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">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<widget class="GtkColorButton" id="colorbutton_background">
<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="x_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Audio port tabs:</property>
</widget>
<packing>
<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="label32">
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grid lines (groups):</property>
<property name="label" translatable="yes">Port group tabs:</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">
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grid lines (ports):</property>
<property name="label" translatable="yes">Client tabs:</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="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label34">
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Background:</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>
@ -1236,25 +1236,29 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkEntry" id="entry_destination_rule">
<widget class="GtkCheckButton" id="check_connections_stop">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Stop after matching rule</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_source_rule">
<widget class="GtkLabel" id="label29">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Source match rule:</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@ -1272,29 +1276,25 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label29">
<widget class="GtkEntry" id="entry_source_rule">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Source match rule:</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_connections_stop">
<widget class="GtkEntry" id="entry_destination_rule">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Stop after matching rule</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
@ -1359,25 +1359,29 @@
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<child>
<widget class="GtkEntry" id="entry_replace_rule">
<widget class="GtkCheckButton" id="check_aliases_stop">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Stop after matching rule</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_match_rule">
<widget class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Match rule:</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@ -1395,29 +1399,25 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label26">
<widget class="GtkEntry" id="entry_match_rule">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Match rule:</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_aliases_stop">
<widget class="GtkEntry" id="entry_replace_rule">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Stop after matching rule</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
@ -1462,4 +1462,102 @@
</widget>
</child>
</widget>
<widget class="GtkDialog" id="dialog_session_open">
<property name="border_width">5</property>
<property name="title" translatable="yes">Open Session</property>
<property name="resizable">False</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox6">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<widget class="GtkVBox" id="vbox17">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="label36">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Open session&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox11">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="label35">
<property name="visible">True</property>
<property name="label" translatable="yes">
</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="combobox_session_open">
<property name="visible">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area6">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button_session_open_cancel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_session_open_okay">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -6,6 +6,7 @@
#include "rect.h"
#include "colour.h"
struct Base;
typedef std::list<Base *> BaseList;
enum PortType {

129
src/session.cpp 100644
View File

@ -0,0 +1,129 @@
#include <string>
#include <dbus/dbus-glib.h>
#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<std::string> Session::List()
{
GError *error = NULL;
char **session_list;
char **session_list_ptr;
std::list<std::string> 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<Gtk::Builder> &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<std::string> sessions = s.List();
std::list<std::string>::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();
}

51
src/session.h 100644
View File

@ -0,0 +1,51 @@
#ifndef SESSION_H
#define SESSION_H
#include <string>
#include <list>
#include <gtkmm.h>
#include "glib.h"
class Session
{
public:
Session();
~Session();
int SaveAs(std::string name);
int Load(std::string name);
std::list<std::string> 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<Gtk::Builder> &builder);
static SessionOpenGui *Open();
protected:
void on_cancel();
void on_okay();
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{
add(m_name);
}
Gtk::TreeModelColumn<std::string> m_name;
};
ModelColumns m_columns;
Glib::RefPtr<Gtk::ListStore> m_tree_model;
};
#endif // SESSION_H