summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaybin Rutkin <taybin@taybin.com>2006-07-26 19:22:06 +0000
committerTaybin Rutkin <taybin@taybin.com>2006-07-26 19:22:06 +0000
commitf8f84973309fd44de4b693f3fe85551395024c10 (patch)
treea5bdb0b0f0eedac6537eaf60b2aab1c6b949d1a8
parent3a5a338f80e04676a80c5148064f1e48220e494c (diff)
Added PathList widget to Gtkmm2ext. It is for adding and removing directory
paths to a list. It'll be used for sfdb_paths and raid_paths in the OptionEditor. git-svn-id: svn://localhost/ardour2/trunk@693 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/option_editor.cc10
-rw-r--r--gtk2_ardour/option_editor.h17
-rw-r--r--libs/gtkmm2ext/SConscript5
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/pathlist.h63
-rw-r--r--libs/gtkmm2ext/pathlist.cc124
5 files changed, 197 insertions, 22 deletions
diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc
index 09aacdab15..fc4a412f9b 100644
--- a/gtk2_ardour/option_editor.cc
+++ b/gtk2_ardour/option_editor.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2001 Paul Davis
+ Copyright (C) 2001-2006 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -59,9 +59,7 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
/* Paths */
path_table (11, 2),
- sfdb_path_columns(),
- sfdb_paths(ListStore::create(sfdb_path_columns)),
- sfdb_path_view(sfdb_paths),
+ sfdb_path_view(),
/* Fades */
@@ -251,10 +249,6 @@ OptionEditor::setup_path_options()
path_table.attach(*label, 0, 1, 2, 3, FILL|EXPAND, FILL);
path_table.attach(sfdb_path_view, 1, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
- sfdb_path_view.append_column(_("Paths"), sfdb_path_columns.paths);
- sfdb_path_view.set_size_request(-1, 100);
- sfdb_path_view.set_headers_visible (false);
-
path_table.show_all();
}
diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h
index b9690b02e2..68407246e0 100644
--- a/gtk2_ardour/option_editor.h
+++ b/gtk2_ardour/option_editor.h
@@ -33,6 +33,8 @@
#include <gtkmm/radiobutton.h>
#include <gtkmm/comboboxtext.h>
+#include <gtkmm2ext/pathlist.h>
+
#include <ardour/session.h>
#include "ardour_dialog.h"
@@ -70,19 +72,10 @@ class OptionEditor : public Gtk::Dialog
/* paths */
- Gtk::Table path_table;
- Gtk::Entry session_raid_entry;
-
- struct SoundFilePathColumns : public Gtk::TreeModel::ColumnRecord {
- public:
- SoundFilePathColumns() { add (paths); }
- Gtk::TreeModelColumn<std::string> paths;
-
- };
+ Gtk::Table path_table;
+ Gtk::Entry session_raid_entry;
- SoundFilePathColumns sfdb_path_columns;
- Glib::RefPtr<Gtk::ListStore> sfdb_paths;
- Gtk::TreeView sfdb_path_view;
+ Gtkmm2ext::PathList sfdb_path_view;
void setup_path_options();
void add_session_paths ();
diff --git a/libs/gtkmm2ext/SConscript b/libs/gtkmm2ext/SConscript
index bb28945641..cf513eb5a1 100644
--- a/libs/gtkmm2ext/SConscript
+++ b/libs/gtkmm2ext/SConscript
@@ -24,10 +24,10 @@ gtkmm2ext.Merge ([
domain = 'libgtkmm2ext'
-gtkmm2ext.Append(DOMAIN=domain,MAJOR=0,MINOR=8,MICRO=2)
+gtkmm2ext.Append(DOMAIN=domain,MAJOR=0,MINOR=8,MICRO=3)
gtkmm2ext.Append(CXXFLAGS="-DPACKAGE=\\\"" + domain + "\\\"")
gtkmm2ext.Append(CXXFLAGS="-DLIBSIGC_DISABLE_DEPRECATED")
-gtkmm2ext.Append(CPPPATH='#libs/surfaces/control_protocol')
+#gtkmm2ext.Append(CPPPATH='#libs/surfaces/control_protocol')
gtkmm2ext.Append(PACKAGE=domain)
gtkmm2ext.Append(POTFILE=domain + '.pot')
@@ -42,6 +42,7 @@ fastmeter.cc
gtk_ui.cc
hexentry.cc
idle_adjustment.cc
+pathlist.cc
pixscroller.cc
popup.cc
prompter.cc
diff --git a/libs/gtkmm2ext/gtkmm2ext/pathlist.h b/libs/gtkmm2ext/gtkmm2ext/pathlist.h
new file mode 100644
index 0000000000..7b86e016f7
--- /dev/null
+++ b/libs/gtkmm2ext/gtkmm2ext/pathlist.h
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2006 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __gtkmm2ext_pathlist_h__
+#define __gtkmm2ext_pathlist_h__
+
+#include <vector>
+#include <string>
+
+#include <gtkmm.h>
+
+namespace Gtkmm2ext {
+
+class PathList : public Gtk::VBox
+{
+ public:
+ PathList ();
+ ~PathList () {};
+
+ std::vector<std::string> get_paths ();
+ void set_paths (std::vector<std::string> paths);
+
+ sigc::signal<void> paths_updated;
+
+ protected:
+ Gtk::Button add_btn;
+ Gtk::Button subtract_btn;
+
+ void add_btn_clicked ();
+ void subtract_btn_clicked ();
+
+ private:
+ struct PathColumns : public Gtk::TreeModel::ColumnRecord {
+ PathColumns() { add (paths); }
+ Gtk::TreeModelColumn<std::string> paths;
+ };
+ PathColumns path_columns;
+
+ Glib::RefPtr<Gtk::ListStore> _store;
+ Gtk::TreeView _view;
+
+ void selection_changed ();
+};
+
+} // namespace Gtkmm2ext
+
+#endif // __gtkmm2ext_pathlist_h__
diff --git a/libs/gtkmm2ext/pathlist.cc b/libs/gtkmm2ext/pathlist.cc
new file mode 100644
index 0000000000..500cb8c23e
--- /dev/null
+++ b/libs/gtkmm2ext/pathlist.cc
@@ -0,0 +1,124 @@
+/*
+ Copyright (C) 2006 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <gtkmm2ext/pathlist.h>
+
+#include "i18n.h"
+
+using namespace std;
+using namespace Gtkmm2ext;
+
+PathList::PathList ()
+ :
+ add_btn(_("+")),
+ subtract_btn(_("-")),
+ path_columns(),
+ _store(Gtk::ListStore::create(path_columns)),
+ _view(_store)
+{
+ _view.append_column(_("Paths"), path_columns.paths);
+ _view.set_size_request(-1, 100);
+ _view.set_headers_visible (false);
+
+ Gtk::ScrolledWindow* scroll = manage(new Gtk::ScrolledWindow);
+ scroll->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ scroll->add(_view);
+
+ add (*scroll);
+
+ Gtk::HBox* btn_box = manage(new Gtk::HBox);
+ btn_box->add(add_btn);
+ btn_box->add(subtract_btn);
+
+ add (*btn_box);
+
+ add_btn.signal_clicked().connect (mem_fun(*this, &PathList::add_btn_clicked));
+ subtract_btn.signal_clicked().connect (mem_fun(*this, &PathList::subtract_btn_clicked));
+ _view.get_selection()->signal_changed().connect (mem_fun(*this, &PathList::selection_changed));
+}
+
+vector<string>
+PathList::get_paths ()
+{
+ vector<string> paths;
+
+ Gtk::TreeModel::Children children(_store->children());
+
+ for (Gtk::TreeIter iter = children.begin(); iter != children.end(); ++iter) {
+ Gtk::ListStore::Row row = *iter;
+
+ paths.push_back(row[path_columns.paths]);
+ }
+
+ return paths;
+}
+
+void
+PathList::set_paths (vector<string> paths)
+{
+ _store.clear();
+
+ for (vector<string>::iterator i = paths.begin(); i != paths.end(); ++i) {
+ Gtk::ListStore::iterator iter = _store->append();
+ Gtk::ListStore::Row row = *iter;
+ row[path_columns.paths] = *i;
+ }
+}
+
+void
+PathList::add_btn_clicked ()
+{
+ Gtk::FileChooserDialog path_chooser (_("Path Chooser"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+ path_chooser.add_button (Gtk::Stock::ADD, Gtk::RESPONSE_OK);
+ path_chooser.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+
+ int result = path_chooser.run ();
+
+ if (result == Gtk::RESPONSE_OK) {
+ string pathname = path_chooser.get_filename();
+
+ if (pathname.length ()) {
+ Gtk::ListStore::iterator iter = _store->append ();
+ Gtk::ListStore::Row row = *iter;
+ row[path_columns.paths] = pathname;
+
+ paths_updated (); // EMIT_SIGNAL
+ }
+ }
+}
+
+void
+PathList::subtract_btn_clicked ()
+{
+ Gtk::ListStore::iterator iter = _view.get_selection()->get_selected();
+ _store->erase (iter);
+
+ paths_updated (); // EMIT_SIGNAL
+}
+
+void
+PathList::selection_changed ()
+{
+ if (_view.get_selection()->count_selected_rows ()) {
+ subtract_btn.set_sensitive (true);
+ } else {
+ subtract_btn.set_sensitive (false);
+ }
+}