[beast: 3/12] BSE: move Item.get_project and undo grouping into bseapi.idl



commit dc75f1bd1079e66d4b16212a3e2e2cb394a16e9b
Author: Tim Janik <timj gnu org>
Date:   Thu Sep 7 03:52:15 2017 +0200

    BSE: move Item.get_project and undo grouping into bseapi.idl
    
    Along with moving Item.get_project, Item.group_undo, Item.ungroup_undo,
    we remove the Item.clear_undo, Item.undo, Item.redo procedures which
    just replicate existing Project API (and avoid method ambiguities).
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bseapi.idl   |   12 ++--
 bse/bseitem.cc   |   26 ++++++++++
 bse/bseitem.hh   |    3 +
 bse/bseitem.proc |  139 ------------------------------------------------------
 4 files changed, 35 insertions(+), 145 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index db556f1..8155761 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -626,6 +626,7 @@ record PartLink;
 sequence PartLinkSeq;
 record TrackPart;
 sequence TrackPartSeq;
+interface Project;
 
 /// Fundamental base type for all BSE objects.
 interface Object {
@@ -640,12 +641,15 @@ interface Item : Object {
   Icon icon = Record ("Icon", "State dependent icon representation of this item", "rw:G");
   Item   common_ancestor   (Item other);       ///< Find a common container (parent or grand-parent) of two 
items if any.
   bool   check_is_a        (String type_name); ///< Check whether an item has a certain type.
-  // void   clear_undo        (); ///< Call the clear-undo function of the project corresponding to this 
item if any.
+  /// Request multiple modifying actions on an item to be grouped together as single undo operation.
+  /// @param name       Name for the undo group to be created
+  void   group_undo   (String name);
+  void   ungroup_undo ();               ///< Ends the undo grouping opened up by a previous group-undo() 
call.
+  Project   get_project       ();       ///< Retrieve an item's project.
   // bool   editable_property (String property_name); ///< Test whether a property is editable according to 
object state and property options.
   // String get_name          (); ///< Retrieve an item's name.
   // String get_name_or_type  (); ///< Retrieve an item's name or type if it has no name.
   // Item   get_parent        (); ///< Retrieve an item's parent.
-  // Item   get_project       (); ///< Retrieve an item's project.
   // PropertyCandidates get_property_candidates (String property_name); ///< Retrieve tentative values for 
an item or item sequence property.
   // int32  get_seqid        (); ///< Retrieve an item's sequential ID. The sequential ID depends on the 
item's type an it's position inbetween siblings of the same type within it's immediate container.
   // String get_type         (); ///< Retrieve an item's type name.
@@ -654,12 +658,8 @@ interface Item : Object {
   // String get_type_license (); ///< Retrieve the license for an item's type implementation.
   // String get_type_name    (); ///< Retrieve an item's type name.
   // String get_uname_path   (); ///< Retrieve the project relative uname path for this item.
-  // void   group_undo   (String name); ///< Request multiple modifying actions on an item to be grouped 
together as single undo operation.
   // bool   internal     (); ///< Check whether an item is internal, i.e. owned by another non-internal item.
-  // void   redo         (); ///< Call the redo function of the project corresponding to this item if any.
   // void   set_name     (String name); ///< Set an item's name.
-  // void   undo         (); ///< Call the undo function of the project corresponding to this item if any.
-  // void   ungroup_undo (); ///< Ends the undo grouping opened up by a previous group-undo() call.
   // void   unuse        (); ///< Decrement use count for when an item is not needed anymore.
   // Item   use          (); ///< Increment use count to keep an item alive.
   // int32 seqid = Range ("Sequential ID", "", ":readwrite", 0, MAXINT31, 1);
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 27587ab..0e8e436 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -1349,6 +1349,14 @@ ItemImpl::push_property_undo (const String &property_name)
     }
 }
 
+ProjectIfaceP
+ItemImpl::get_project  ()
+{
+  BseItem *self = as<BseItem*>();
+  BseProject *project = bse_item_get_project (self);
+  return project ? project->as<Bse::ProjectIfaceP>() : NULL;
+}
+
 ItemIfaceP
 ItemImpl::common_ancestor (ItemIface &other)
 {
@@ -1367,6 +1375,24 @@ ItemImpl::check_is_a (const String &type_name)
   return is_a;
 }
 
+void
+ItemImpl::group_undo (const std::string &name)
+{
+  BseItem *self = as<BseItem*>();
+  BseUndoStack *ustack = bse_item_undo_open (self, "item-group-undo");
+  bse_undo_stack_add_merger (ustack, name.c_str());
+  bse_item_undo_close (ustack);
+}
+
+void
+ItemImpl::ungroup_undo ()
+{
+  BseItem *self = as<BseItem*>();
+  BseUndoStack *ustack = bse_item_undo_open (self, "item-ungroup-undo");
+  bse_undo_stack_remove_merger (ustack);
+  bse_item_undo_close (ustack);
+}
+
 class CustomIconKey : public DataKey<Icon*> {
   virtual void destroy (Icon *icon) override    { delete icon; }
 };
diff --git a/bse/bseitem.hh b/bse/bseitem.hh
index 95c901e..d737432 100644
--- a/bse/bseitem.hh
+++ b/bse/bseitem.hh
@@ -163,6 +163,9 @@ public:
   ContainerImpl*     parent          ();
   virtual ItemIfaceP common_ancestor (ItemIface &other) override;
   virtual bool       check_is_a      (const String &type_name) override;
+  virtual void       group_undo      (const std::string &name) override;
+  virtual void       ungroup_undo    () override;
+  virtual ProjectIfaceP get_project  () override;
   virtual Icon       icon            () const override;
   virtual void       icon            (const Icon&) override;
   /// Save the value of @a property_name onto the undo stack.
diff --git a/bse/bseitem.proc b/bse/bseitem.proc
index 4c347fb..b99f1b6 100644
--- a/bse/bseitem.proc
+++ b/bse/bseitem.proc
@@ -3,7 +3,6 @@
 #include <bse/bseprocedure.hh>
 #include <bse/bseitem.hh>
 #include <bse/bsecontainer.hh>
-#include <bse/bseundostack.hh>
 #include <bse/bseproject.hh>
 #include "bsecxxplugin.hh"
 #include "bsebuiltin_externs.cc"
@@ -155,29 +154,6 @@ METHOD (BseItem, get-parent) {
   return Bse::Error::NONE;
 }
 
-METHOD (BseItem, get-project) {
-  HELP = "Retrieve an item's project.";
-  IN   = bse_param_spec_object ("item", "Item", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  OUT  = bse_param_spec_object ("project", "Project", NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *item = (BseItem*) bse_value_get_object (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (item))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  bse_value_set_object (out_values++, bse_item_get_project (item));
-
-  return Bse::Error::NONE;
-}
-
 METHOD (BseItem, get-uname-path) {
   HELP = "Retrieve the project relative uname path for this item.";
   IN   = bse_param_spec_object ("item", NULL, NULL,
@@ -435,118 +411,3 @@ METHOD (BseItem, editable-property) {
 
   return Bse::Error::NONE;
 }
-
-METHOD (BseItem, group-undo) {
-  HELP = "Request multiple modifying actions on an item to be grouped together as single undo operation.";
-  IN   = bse_param_spec_object ("item", NULL, NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-  IN   = sfi_pspec_string ("name", NULL, "A name for the undo group to be created",
-                            NULL, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *self = (BseItem*) bse_value_get_object (in_values++);
-  const char *name       = sfi_value_get_string (in_values++);
-  BseUndoStack *ustack;
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (self) || !name)
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  ustack = bse_item_undo_open (self, "item-group-undo");
-  bse_undo_stack_add_merger (ustack, name);
-  bse_item_undo_close (ustack);
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, ungroup-undo) {
-  HELP = "Ends the undo grouping opened up by a previous group-undo() call.";
-  IN   = bse_param_spec_object ("item", NULL, NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *self = (BseItem*) bse_value_get_object (in_values++);
-  BseUndoStack *ustack;
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (self))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  ustack = bse_item_undo_open (self, "item-ungroup-undo");
-  bse_undo_stack_remove_merger (ustack);
-  bse_item_undo_close (ustack);
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, undo) {
-  HELP = "Call the undo function of the project corresponding to this item if any.";
-  IN   = bse_param_spec_object ("item", NULL, NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *self = (BseItem*) bse_value_get_object (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (self))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  Bse::ProjectIface *project = bse_item_get_project (self)->as<Bse::ProjectIface*>();
-  if (project)
-    project->undo();
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, redo) {
-  HELP = "Call the redo function of the project corresponding to this item if any.";
-  IN   = bse_param_spec_object ("item", NULL, NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *self = (BseItem*) bse_value_get_object (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (self))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  Bse::ProjectIface *project = bse_item_get_project (self)->as<Bse::ProjectIface*>();
-  if (project)
-    project->redo();
-
-  return Bse::Error::NONE;
-}
-
-METHOD (BseItem, clear-undo) {
-  HELP = "Call the clear-undo function of the project corresponding to this item if any.";
-  IN   = bse_param_spec_object ("item", NULL, NULL,
-                                BSE_TYPE_ITEM, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
-       const GValue      *in_values,
-       GValue            *out_values)
-{
-  /* extract parameter values */
-  BseItem *self = (BseItem*) bse_value_get_object (in_values++);
-
-  /* check parameters */
-  if (!BSE_IS_ITEM (self))
-    return Bse::Error::PROC_PARAM_INVAL;
-
-  Bse::ProjectIface *project = bse_item_get_project (self)->as<Bse::ProjectIface*>();
-  if (project)
-    project->clear_undo();
-
-  return Bse::Error::NONE;
-}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]