[beast: 19/49] BEAST: BstSuperShell: leave reference counting to Bse::SuperH



commit 2503e3f43bdbe1ed9d8cfaaa82a68d6cc2683189
Author: Tim Janik <timj gnu org>
Date:   Mon Jun 22 16:09:11 2015 +0200

    BEAST: BstSuperShell: leave reference counting to Bse::SuperH

 beast-gtk/bstapp.cc        |   12 ++++--------
 beast-gtk/bstsupershell.cc |   39 +++++++++++++++++----------------------
 beast-gtk/bstsupershell.hh |    5 ++---
 3 files changed, 23 insertions(+), 33 deletions(-)
---
diff --git a/beast-gtk/bstapp.cc b/beast-gtk/bstapp.cc
index 9147278..98bab6e 100644
--- a/beast-gtk/bstapp.cc
+++ b/beast-gtk/bstapp.cc
@@ -435,7 +435,7 @@ bst_app_get_current_super (BstApp *app)
       if (BST_IS_SUPER_SHELL (shell))
         {
           BstSuperShell *super_shell = BST_SUPER_SHELL (shell);
-          return super_shell->super;
+          return super_shell->super.proxy_id();
         }
     }
   return 0;
@@ -645,15 +645,11 @@ bst_app_handle_delete_event (GtkWidget   *widget,
 static void
 rebuild_super_shell (BstSuperShell *super_shell)
 {
-  SfiProxy proxy;
-
   g_return_if_fail (BST_IS_SUPER_SHELL (super_shell));
 
-  proxy = super_shell->super;
-  bse_item_use (proxy);
-  bst_super_shell_set_super (super_shell, 0);
-  bst_super_shell_set_super (super_shell, proxy);
-  bse_item_unuse (proxy);
+  Bse::SuperH super = super_shell->super;
+  bst_super_shell_set_super (super_shell, Bse::SuperH());
+  bst_super_shell_set_super (super_shell, super);
 }
 
 typedef struct {
diff --git a/beast-gtk/bstsupershell.cc b/beast-gtk/bstsupershell.cc
index 58842bb..583e9a4 100644
--- a/beast-gtk/bstsupershell.cc
+++ b/beast-gtk/bstsupershell.cc
@@ -60,7 +60,7 @@ bst_super_shell_class_init (BstSuperShellClass *klass)
 static void
 bst_super_shell_init (BstSuperShell *self)
 {
-  self->super = 0;
+  new (&self->super) Bse::SuperH();
   gtk_widget_set (GTK_WIDGET (self),
                   "visible", TRUE,
                  "homogeneous", FALSE,
@@ -76,11 +76,13 @@ bst_super_shell_set_property (GObject         *object,
                              GParamSpec      *pspec)
 {
   BstSuperShell *self = BST_SUPER_SHELL (object);
+  Bse::SuperH super;
 
   switch (prop_id)
     {
     case PROP_SUPER:
-      bst_super_shell_set_super (self, sfi_value_get_proxy (value));
+      super = Bse::SuperH::down_cast (bse_server.from_proxy (sfi_value_get_proxy (value)));
+      bst_super_shell_set_super (self, super);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -99,7 +101,7 @@ bst_super_shell_get_property (GObject         *object,
   switch (prop_id)
     {
     case PROP_SUPER:
-      sfi_value_set_proxy (value, self->super);
+      sfi_value_set_proxy (value, self->super.proxy_id());
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -113,7 +115,7 @@ bst_super_shell_destroy (GtkObject *object)
   BstSuperShell *self = BST_SUPER_SHELL (object);
 
   if (self->super)
-    bst_super_shell_set_super (self, 0);
+    bst_super_shell_set_super (self, Bse::SuperH());
 
   GTK_OBJECT_CLASS (bst_super_shell_parent_class)->destroy (object);
 }
@@ -121,32 +123,25 @@ bst_super_shell_destroy (GtkObject *object)
 static void
 bst_super_shell_finalize (GObject *object)
 {
-  // BstSuperShell *self = BST_SUPER_SHELL (object);
+  BstSuperShell *self = BST_SUPER_SHELL (object);
 
   G_OBJECT_CLASS (bst_super_shell_parent_class)->finalize (object);
+  using namespace Bse;
+  self->super.~SuperH();
 }
 
 void
-bst_super_shell_set_super (BstSuperShell *self,
-                          SfiProxy       super)
+bst_super_shell_set_super (BstSuperShell *self, Bse::SuperH super)
 {
   g_return_if_fail (BST_IS_SUPER_SHELL (self));
-  if (super)
-    g_return_if_fail (BSE_IS_SUPER (super));
 
   if (super != self->super)
     {
       if (self->super)
-       {
-          gtk_container_foreach (GTK_CONTAINER (self), (GtkCallback) gtk_widget_destroy, NULL);
-         bse_item_unuse (self->super);
-       }
+        gtk_container_foreach (GTK_CONTAINER (self), (GtkCallback) gtk_widget_destroy, NULL);
       self->super = super;
       if (self->super)
-       {
-         bse_item_use (self->super);
-          super_shell_add_views (self);
-       }
+        super_shell_add_views (self);
     }
 }
 
@@ -160,7 +155,7 @@ static void
 super_shell_build_song (BstSuperShell *self,
                         GtkNotebook   *notebook)
 {
-  SfiProxy song = self->super;
+  SfiProxy song = self->super.proxy_id();
 
   gtk_notebook_append_page (notebook,
                             bst_track_view_new (song),
@@ -189,7 +184,7 @@ static void
 super_shell_build_snet (BstSuperShell *self,
                         GtkNotebook   *notebook)
 {
-  Bse::SNetH snet = Bse::SNetH::down_cast (bse_server.from_proxy (self->super));
+  Bse::SNetH snet = Bse::SNetH::down_cast (self->super);
   GtkWidget *param_view;
 
   if (BST_DBG_EXT && snet.supports_user_synths())
@@ -211,7 +206,7 @@ static void
 super_shell_build_wave_repo (BstSuperShell *self,
                              GtkNotebook   *notebook)
 {
-  SfiProxy wrepo = self->super;
+  SfiProxy wrepo = self->super.proxy_id();
 
   gtk_notebook_append_page (notebook,
                             bst_wave_view_new (wrepo),
@@ -241,9 +236,9 @@ create_notebook (BstSuperShell *self)
 static void
 super_shell_add_views (BstSuperShell *self)
 {
-  if (BSE_IS_SONG (self->super))
+  if (BSE_IS_SONG (self->super.proxy_id()))
     super_shell_build_song (self, create_notebook (self));
-  else if (BSE_IS_WAVE_REPO (self->super))
+  else if (BSE_IS_WAVE_REPO (self->super.proxy_id()))
     super_shell_build_wave_repo (self, create_notebook (self));
   else /* BSE_IS_SNET (self->super) */
     super_shell_build_snet (self, create_notebook (self));
diff --git a/beast-gtk/bstsupershell.hh b/beast-gtk/bstsupershell.hh
index 741f57c..bd0a194 100644
--- a/beast-gtk/bstsupershell.hh
+++ b/beast-gtk/bstsupershell.hh
@@ -21,7 +21,7 @@ typedef       struct  _BstSuperShellClass     BstSuperShellClass;
 struct _BstSuperShell
 {
   GtkVBox       parent_object;
-  SfiProxy      super;
+  Bse::SuperH   super;
   guint                 name_set_id;
 };
 struct _BstSuperShellClass
@@ -32,8 +32,7 @@ struct _BstSuperShellClass
 
 /* --- prototypes --- */
 GType          bst_super_shell_get_type        (void);
-void           bst_super_shell_set_super       (BstSuperShell  *super_shell,
-                                                SfiProxy        super);
+void           bst_super_shell_set_super       (BstSuperShell *super_shell, Bse::SuperH super);
 GtkWidget*      bst_super_shell_create_label    (BstSuperShell  *super_shell);
 
 G_END_DECLS


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