[beast: 5/26] BSE: move WaveRepoImpl.list_children() and remove_wave() into bseapi.idl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 5/26] BSE: move WaveRepoImpl.list_children() and remove_wave() into bseapi.idl
- Date: Fri, 14 Oct 2016 15:48:24 +0000 (UTC)
commit 2778741f89b6bae543961e815dea37ba618f699a
Author: Tim Janik <timj gnu org>
Date: Fri May 27 15:16:56 2016 +0200
BSE: move WaveRepoImpl.list_children() and remove_wave() into bseapi.idl
Signed-off-by: Tim Janik <timj gnu org>
bse/Makefile.am | 2 +-
bse/bseapi.idl | 2 +
bse/bsewaverepo.cc | 65 ++++++++++++++++++++++++++-
bse/bsewaverepo.hh | 4 +-
bse/bsewaverepo.proc | 117 --------------------------------------------------
5 files changed, 68 insertions(+), 122 deletions(-)
---
diff --git a/bse/Makefile.am b/bse/Makefile.am
index 9d114bb..45a6afc 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -118,7 +118,7 @@ bse_proc_sources = $(strip \
bsecategories.proc bseeditablesample.proc \
bsejanitor.proc bseproject.proc \
bsesong.proc bsesource.proc \
- bseitem.proc bsewave.proc bsewaveosc.proc
bsewaverepo.proc \
+ bseitem.proc bsewave.proc bsewaveosc.proc \
)
bse_proc_gen_sources = $(bse_proc_sources:.proc=.genprc.cc)
# non-compile and non-install sources required
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 3236686..6b5d211 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -798,6 +798,8 @@ interface Wave : Source {
/// Interface serving as container for Wave objects.
interface WaveRepo : Super {
+ Error load_file (String file_name); ///< Load wave from file.
+ void remove_wave (Wave wave); ///< Remove a wave from repository.
};
/// Interface for MIDI event notification.
diff --git a/bse/bsewaverepo.cc b/bse/bsewaverepo.cc
index 8071586..a27d74a 100644
--- a/bse/bsewaverepo.cc
+++ b/bse/bsewaverepo.cc
@@ -1,6 +1,5 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsewaverepo.hh"
-
#include "bsewave.hh"
@@ -199,7 +198,67 @@ WaveRepoImpl::WaveRepoImpl (BseObject *bobj) :
WaveRepoImpl::~WaveRepoImpl ()
{}
-// BseWaveRepo *self = as<BseWaveRepo*>();
-// other->as<WaveRepoIfaceP>();
+static Error
+repo_load_file (BseWaveRepo *wrepo, const String &file_name, BseWave **wave_p)
+{
+ String fname = Path::basename (file_name);
+ BseWave *wave = (BseWave*) bse_object_new (BSE_TYPE_WAVE, "uname", fname.c_str(), NULL);
+ Error error = bse_wave_load_wave_file (wave, file_name.c_str(), NULL, NULL, NULL, TRUE);
+ if (wave->n_wchunks)
+ {
+ bse_container_add_item (BSE_CONTAINER (wrepo), BSE_ITEM (wave));
+ *wave_p = wave;
+ error = Error::NONE;
+ }
+ else
+ {
+ if (error == 0)
+ error = Error::WAVE_NOT_FOUND;
+ *wave_p = NULL;
+ }
+ g_object_unref (wave);
+ return error;
+}
+
+Error
+WaveRepoImpl::load_file (const String &file_name)
+{
+ BseWaveRepo *self = as<BseWaveRepo*>();
+ BseWave *wave = NULL;
+ Bse::Error error = repo_load_file (self, file_name, &wave);
+ if (wave)
+ {
+ UndoDescriptor<WaveImpl> wave_descriptor = undo_descriptor (*wave->as<WaveImpl*>());
+ auto remove_wave_lambda = [wave_descriptor] (WaveRepoImpl &self, BseUndoStack *ustack) -> Error {
+ WaveImpl &wave = self.undo_resolve (wave_descriptor);
+ self.remove_wave (wave);
+ return Error::NONE;
+ };
+ push_undo (__func__, *this, remove_wave_lambda);
+ }
+ return error;
+}
+
+void
+WaveRepoImpl::remove_wave (WaveIface &wave_iface)
+{
+ BseWaveRepo *self = as<BseWaveRepo*>();
+ BseWave *wave = wave_iface.as<BseWave*>();
+ assert_return (wave->parent == self);
+ BseUndoStack *ustack = bse_item_undo_open (self, __func__);
+ bse_container_uncross_undoable (self, wave); // removes object references
+ if (wave) // push undo for 'remove_backedup'
+ {
+ UndoDescriptor<WaveImpl> wave_descriptor = undo_descriptor (*wave->as<WaveImpl*>());
+ auto remove_wave_lambda = [wave_descriptor] (WaveRepoImpl &self, BseUndoStack *ustack) -> Error {
+ WaveImpl &wave = self.undo_resolve (wave_descriptor);
+ self.remove_wave (wave);
+ return Error::NONE;
+ };
+ push_undo_to_redo (__func__, *this, remove_wave_lambda);
+ }
+ bse_container_remove_backedup (self, wave, ustack); // removes without undo
+ bse_item_undo_close (ustack);
+}
} // Bse
diff --git a/bse/bsewaverepo.hh b/bse/bsewaverepo.hh
index 6bbf878..a0d42b7 100644
--- a/bse/bsewaverepo.hh
+++ b/bse/bsewaverepo.hh
@@ -30,7 +30,9 @@ class WaveRepoImpl : public SuperImpl, public virtual WaveRepoIface {
protected:
virtual ~WaveRepoImpl ();
public:
- explicit WaveRepoImpl (BseObject*);
+ explicit WaveRepoImpl (BseObject*);
+ virtual Error load_file (const String &file_name) override;
+ virtual void remove_wave (WaveIface &wave) override;
};
} // Bse
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]