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
This commit is contained in:
Taybin Rutkin 2006-07-26 19:22:06 +00:00
parent 3a5a338f80
commit f8f8497330
5 changed files with 197 additions and 22 deletions

View File

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

View File

@ -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;
Gtk::Table path_table;
Gtk::Entry session_raid_entry;
struct SoundFilePathColumns : public Gtk::TreeModel::ColumnRecord {
public:
SoundFilePathColumns() { add (paths); }
Gtk::TreeModelColumn<std::string> paths;
};
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 ();

View File

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

View File

@ -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__

124
libs/gtkmm2ext/pathlist.cc Normal file
View File

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