[beast: 4/9] BSE: Item: add push_property_undo()
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 4/9] BSE: Item: add push_property_undo()
- Date: Fri, 20 Nov 2015 22:08:51 +0000 (UTC)
commit 8c510228c4e34a3f17cb319d5b4f5ec7cca19e2b
Author: Tim Janik <timj gnu org>
Date: Thu Nov 19 13:22:49 2015 +0100
BSE: Item: add push_property_undo()
Signed-off-by: Tim Janik <timj gnu org>
bse/bseitem.cc | 19 +++++++++++++++++++
bse/bseitem.hh | 2 ++
2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 2a17de5..70ec79d 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -1330,6 +1330,25 @@ ItemImpl::push_item_undo (const String &blurb, const UndoLambda &lambda)
bse_item_undo_close (ustack);
}
+void
+ItemImpl::push_property_undo (const String &property_name)
+{
+ assert_return (property_name.empty() == false);
+ Any saved_value = __aida_get__ (property_name);
+ if (saved_value.empty())
+ critical ("%s: invalid property name: %s", __func__, property_name);
+ else
+ {
+ auto lambda = [property_name, saved_value] (ItemImpl &self, BseUndoStack *ustack) -> ErrorType {
+ const bool success = self.__aida_set__ (property_name, saved_value);
+ if (!success)
+ critical ("%s: failed to undo property change for '%s': %s", __func__, property_name,
saved_value.repr());
+ return ERROR_NONE;
+ };
+ push_undo (__func__, *this, lambda);
+ }
+}
+
ItemIfaceP
ItemImpl::common_ancestor (ItemIface &other)
{
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index 98c934b..65414da 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -168,6 +168,8 @@ public:
virtual ItemIfaceP common_ancestor (ItemIface &other) override;
virtual Icon icon () const override;
virtual void icon (const Icon&) override;
+ /// Save the value of @a property_name onto the undo stack.
+ void push_property_undo (const String &property_name);
/// Push an undo @a function onto the undo stack, the @a self argument to @a function must match @a this.
template<typename ItemT, typename... FuncArgs, typename... CallArgs> void
push_undo (const String &blurb, ItemT &self, ErrorType (ItemT::*function) (FuncArgs...), CallArgs... args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]