summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaybin Rutkin <taybin@taybin.com>2006-01-05 05:15:29 +0000
committerTaybin Rutkin <taybin@taybin.com>2006-01-05 05:15:29 +0000
commit18844bac7aa0747453ed4d04c4a462f2044a43bb (patch)
treef4e0ae7ac4dc0110489162f7835dd92f28c6605a
parentec13ef02b050e402d95fdf896a0db21e780442dd (diff)
sfdb displays file info.
git-svn-id: svn://localhost/trunk/ardour2@243 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/.cvsignore1
-rw-r--r--gtk2_ardour/sfdb_ui.cc41
-rw-r--r--gtk2_ardour/sfdb_ui.h6
-rw-r--r--libs/ardour/ardour/sndfile_helpers.h1
-rw-r--r--libs/ardour/sndfile_helpers.cc2
5 files changed, 19 insertions, 32 deletions
diff --git a/gtk2_ardour/.cvsignore b/gtk2_ardour/.cvsignore
index 95bc1a733d..d15bcf4fda 100644
--- a/gtk2_ardour/.cvsignore
+++ b/gtk2_ardour/.cvsignore
@@ -1,3 +1,4 @@
+.gdb_history
ardour
ardourx
ardour.bin
diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc
index 2c7003c6f1..d8e629b176 100644
--- a/gtk2_ardour/sfdb_ui.cc
+++ b/gtk2_ardour/sfdb_ui.cc
@@ -19,6 +19,8 @@
*/
+#include <sndfile.h>
+
#include <gtkmm/box.h>
#include <gtkmm/stock.h>
@@ -51,14 +53,8 @@ SoundFileBox::SoundFileBox ()
pack_start (border_frame);
set_border_width (4);
- path_box.set_spacing (4);
- path_box.pack_start (path, false, false);
- path_box.pack_start (path_entry, true, true);
-
main_box.set_border_width (4);
- main_box.pack_start(label, false, false);
- main_box.pack_start(path_box, false, false);
main_box.pack_start(length, false, false);
main_box.pack_start(format, false, false);
main_box.pack_start(channels, false, false);
@@ -105,31 +101,26 @@ SoundFileBox::set_session(ARDOUR::Session* s)
}
}
-int
+bool
SoundFileBox::setup_labels (string filename)
{
SNDFILE *sf;
+ sf_info.format = 0; // libsndfile says to clear this before sf_open().
+
if ((sf = sf_open ((char *) filename.c_str(), SFM_READ, &sf_info)) < 0) {
- error << string_compose(_("file \"%1\" could not be opened"), filename) << endmsg;
- return -1;
+ return false;
}
+ sf_close (sf);
+
if (sf_info.frames == 0 && sf_info.channels == 0 &&
sf_info.samplerate == 0 && sf_info.format == 0 &&
sf_info.sections == 0) {
/* .. ok, its not a sound file */
- error << string_compose(_("file \"%1\" appears not to be an audio file"), filename) << endmsg;
- return -1;
+ return false;
}
- label.set_alignment (0.0f, 0.0f);
- label.set_text ("Label: " + ARDOUR::Library->get_label(filename));
-
- path.set_text ("Path: ");
- path_entry.set_text (filename);
- path_entry.set_position (-1);
-
length.set_alignment (0.0f, 0.0f);
length.set_text (string_compose("Length: %1", length2string(sf_info.frames, sf_info.samplerate)));
@@ -144,7 +135,7 @@ SoundFileBox::setup_labels (string filename)
samplerate.set_alignment (0.0f, 0.0f);
samplerate.set_text (string_compose("Samplerate: %1", sf_info.samplerate));
- return 0;
+ return true;
}
void
@@ -175,12 +166,6 @@ void
SoundFileBox::field_selected ()
{}
-bool
-SoundFileBox::update (std::string filename)
-{
- return true;
-}
-
SoundFileBrowser::SoundFileBrowser (std::string title)
:
ArdourDialog(title),
@@ -201,7 +186,7 @@ SoundFileBrowser::set_session (ARDOUR::Session* s)
void
SoundFileBrowser::update_preview ()
{
- chooser.set_preview_widget_active(preview.update(chooser.get_filename()));
+ chooser.set_preview_widget_active(preview.setup_labels(chooser.get_filename()));
}
SoundFileChooser::SoundFileChooser (std::string title)
@@ -210,6 +195,8 @@ SoundFileChooser::SoundFileChooser (std::string title)
{
add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+
+ show_all ();
}
SoundFileOmega::SoundFileOmega (std::string title)
@@ -227,6 +214,8 @@ SoundFileOmega::SoundFileOmega (std::string title)
embed_btn.signal_clicked().connect (mem_fun (*this, &SoundFileOmega::embed_clicked));
import_btn.signal_clicked().connect (mem_fun (*this, &SoundFileOmega::import_clicked));
+
+ show_all ();
}
void
diff --git a/gtk2_ardour/sfdb_ui.h b/gtk2_ardour/sfdb_ui.h
index 2c43fb1aa7..279cca3ae4 100644
--- a/gtk2_ardour/sfdb_ui.h
+++ b/gtk2_ardour/sfdb_ui.h
@@ -50,8 +50,8 @@ class SoundFileBox : public Gtk::VBox
SoundFileBox ();
virtual ~SoundFileBox () {};
- bool update (std::string filename);
void set_session (ARDOUR::Session* s);
+ bool setup_labels (std::string filename);
protected:
ARDOUR::Session* _session;
@@ -71,9 +71,6 @@ class SoundFileBox : public Gtk::VBox
pid_t current_pid;
- Gtk::Label label;
- Gtk::Label path;
- Gtk::Entry path_entry;
Gtk::Label length;
Gtk::Label format;
Gtk::Label channels;
@@ -96,7 +93,6 @@ class SoundFileBox : public Gtk::VBox
Gtk::Button remove_field_btn;
// void fields_refiller (Gtk::CList &clist);
- int setup_labels (std::string filename);
void setup_fields ();
void play_btn_clicked ();
diff --git a/libs/ardour/ardour/sndfile_helpers.h b/libs/ardour/ardour/sndfile_helpers.h
index 5bb4937410..4a2c38eac3 100644
--- a/libs/ardour/ardour/sndfile_helpers.h
+++ b/libs/ardour/ardour/sndfile_helpers.h
@@ -2,7 +2,6 @@
#define __sndfile_helpers_h__
#include <string>
-#include <sndfile.h>
using std::string;
diff --git a/libs/ardour/sndfile_helpers.cc b/libs/ardour/sndfile_helpers.cc
index d9e7aa563a..2fd9e63ce2 100644
--- a/libs/ardour/sndfile_helpers.cc
+++ b/libs/ardour/sndfile_helpers.cc
@@ -1,5 +1,7 @@
#include <map>
+#include <sndfile.h>
+
#include <ardour/sndfile_helpers.h>
#include "i18n.h"