[beast: 20/49] BEAST: BstSNetRouter: leave reference counting to Bse::SNetH
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 20/49] BEAST: BstSNetRouter: leave reference counting to Bse::SNetH
- Date: Wed, 1 Jul 2015 11:30:47 +0000 (UTC)
commit 2da2eb23143cd2d2320bdcededc31e394e70d917
Author: Tim Janik <timj gnu org>
Date: Mon Jun 22 16:25:09 2015 +0200
BEAST: BstSNetRouter: leave reference counting to Bse::SNetH
beast-gtk/bstsnetrouter.cc | 52 ++++++++++++++++++++-----------------------
beast-gtk/bstsnetrouter.hh | 12 ++++------
beast-gtk/bstsupershell.cc | 7 +++--
3 files changed, 33 insertions(+), 38 deletions(-)
---
diff --git a/beast-gtk/bstsnetrouter.cc b/beast-gtk/bstsnetrouter.cc
index 0f68125..108d76a 100644
--- a/beast-gtk/bstsnetrouter.cc
+++ b/beast-gtk/bstsnetrouter.cc
@@ -112,7 +112,7 @@ bst_snet_router_destroy (GtkObject *object)
bst_snet_router_reset_tool (self);
bst_snet_router_destroy_contents (self);
- bst_snet_router_set_snet (self, 0);
+ bst_snet_router_set_snet (self, Bse::SNetH());
gxk_action_group_dispose (self->canvas_tool);
gxk_action_group_dispose (self->channel_toggle);
@@ -132,6 +132,8 @@ bst_snet_router_finalize (GObject *object)
g_object_unref (self->channel_toggle);
G_OBJECT_CLASS (bst_snet_router_parent_class)->finalize (object);
+ using namespace Bse;
+ self->snet.~SNetH();
}
static void
@@ -249,11 +251,11 @@ bst_snet_router_queue_link_update (BstSNetRouter *self,
}
GtkWidget*
-bst_snet_router_new (SfiProxy snet)
+bst_snet_router_new (Bse::SNetH snet)
{
GtkWidget *router;
- g_return_val_if_fail (BSE_IS_SNET (snet), NULL);
+ g_return_val_if_fail (snet != NULL, NULL);
router = gtk_widget_new (BST_TYPE_SNET_ROUTER,
"aa", BST_SNET_ANTI_ALIASED,
@@ -285,30 +287,24 @@ bst_snet_router_item_added (BstSNetRouter *self,
}
void
-bst_snet_router_set_snet (BstSNetRouter *self,
- SfiProxy snet)
+bst_snet_router_set_snet (BstSNetRouter *self, Bse::SNetH snet)
{
g_return_if_fail (BST_IS_SNET_ROUTER (self));
- if (snet)
- g_return_if_fail (BSE_IS_SNET (snet));
if (self->snet)
{
bst_snet_router_destroy_contents (self);
- bse_proxy_disconnect (self->snet,
+ bse_proxy_disconnect (self->snet.proxy_id(),
"any_signal", bst_snet_router_item_added, self,
NULL);
- bse_item_unuse (self->snet);
- self->snet = 0;
+ self->snet = Bse::SNetH();
}
self->snet = snet;
if (self->snet)
{
- bse_item_use (self->snet); // FIXME: should we hold a use-count on the snet?
- bse_proxy_connect (self->snet,
+ bse_proxy_connect (self->snet.proxy_id(),
"swapped_signal::item_added", bst_snet_router_item_added, self,
NULL);
-
bst_snet_router_update (self);
bst_snet_router_adjust_region (self);
#if 0
@@ -332,15 +328,14 @@ bst_router_run_method (gpointer user_data, size_t action_id)
BstSNetRouter *self = BST_SNET_ROUTER (user_data);
BseCategory *cat = bse_category_from_id (action_id);
bst_procedure_exec_auto (cat->type,
- "synth-net", SFI_TYPE_PROXY, self->snet,
- BSE_IS_CSYNTH (self->snet) ? "custom-synth" : "", SFI_TYPE_PROXY, self->snet,
+ "synth-net", SFI_TYPE_PROXY, self->snet.proxy_id(),
+ BSE_IS_CSYNTH (self->snet.proxy_id()) ? "custom-synth" : "", SFI_TYPE_PROXY,
self->snet.proxy_id(),
NULL);
}
void
bst_snet_router_update (BstSNetRouter *self)
{
- GnomeCanvasItem *csource;
GnomeCanvas *canvas;
BseItemSeq *iseq;
GSList *slist, *csources = NULL;
@@ -353,7 +348,7 @@ bst_snet_router_update (BstSNetRouter *self)
/* destroy all canvas sources */
bst_snet_router_destroy_contents (self);
- if (0)
+#if 0
{
/* add canvas source for the snet itself */
csource = bst_canvas_source_new (GNOME_CANVAS_GROUP (canvas->root), self->snet);
@@ -363,9 +358,10 @@ bst_snet_router_update (BstSNetRouter *self)
NULL);
csources = g_slist_prepend (csources, csource);
}
+#endif
/* walk all child sources */
- iseq = bse_container_list_children (self->snet);
+ iseq = bse_container_list_children (self->snet.proxy_id());
for (i = 0; i < iseq->n_items; i++)
{
SfiProxy item = iseq->items[i];
@@ -621,7 +617,7 @@ bst_snet_router_root_event (BstSNetRouter *self,
gxk_status_set (GXK_STATUS_WAIT, _("Create Link"), _("Select input module"));
handled = TRUE;
}
- else if (csource && csource->source != self->snet)
+ else if (csource && csource->source != (SfiProxy) self->snet.proxy_id())
{
if (bst_mouse_button_activate2 (event))
bst_canvas_source_toggle_info (csource);
@@ -689,7 +685,7 @@ bst_snet_router_root_event (BstSNetRouter *self,
BST_CHOICE (5, _("Show Info"), INFO),
BST_CHOICE_SUBMENU (_("Output Signal Monitor"), choice,
SIGNAL),
BST_CHOICE_SEPERATOR,
- BST_CHOICE_S (1, _("Delete"), DELETE, csource->source !=
self->snet),
+ BST_CHOICE_S (1, _("Delete"), DELETE, csource->source !=
(SfiProxy) self->snet.proxy_id()),
BST_CHOICE_END);
g_free (source_name);
int i = bst_choice_modal (choice, event->button.button, event->button.time);
@@ -713,7 +709,7 @@ bst_snet_router_root_event (BstSNetRouter *self,
bst_canvas_source_popup_info (csource);
break;
case 1:
- error = bse_snet_remove_source (self->snet, csource->source);
+ error = bse_snet_remove_source (self->snet.proxy_id(), csource->source);
bst_status_eprintf (error, _("Remove Module"));
break;
case 0: break;
@@ -785,16 +781,16 @@ bst_snet_router_event (GtkWidget *widget,
event->button.x, event->button.y,
&self->world_x, &self->world_y);
- error = bse_snet_can_create_source (self->snet, cat->type);
+ error = bse_snet_can_create_source (self->snet.proxy_id(), cat->type);
if (!error)
{
SfiProxy module;
- bse_item_group_undo (self->snet, "Create Module");
- module = bse_snet_create_source (self->snet, cat->type);
+ bse_item_group_undo (self->snet.proxy_id(), "Create Module");
+ module = bse_snet_create_source (self->snet.proxy_id(), cat->type);
bse_source_set_pos (module,
self->world_x / BST_CANVAS_SOURCE_PIXEL_SCALE,
self->world_y / -BST_CANVAS_SOURCE_PIXEL_SCALE);
- bse_item_ungroup_undo (self->snet);
+ bse_item_ungroup_undo (self->snet.proxy_id());
}
if (BST_SNET_EDIT_FALLBACK)
gxk_action_group_select (self->canvas_tool, ROUTER_TOOL_EDIT);
@@ -934,7 +930,7 @@ snet_router_action_exec (gpointer user_data,
}
BstSNetRouter*
-bst_snet_router_build_page (SfiProxy snet)
+bst_snet_router_build_page (Bse::SNetH snet)
{
static const char *zoom_xpm[] = {
"12 12 2 1", " c None", "# c #000000",
@@ -957,7 +953,7 @@ bst_snet_router_build_page (SfiProxy snet)
GdkBitmap *mask;
GxkRadget *radget;
- g_return_val_if_fail (BSE_IS_SNET (snet), NULL);
+ g_return_val_if_fail (snet != NULL, NULL);
/* main radget */
radget = gxk_radget_create ("beast", "snet-view", NULL);
@@ -1001,6 +997,7 @@ bst_snet_router_build_page (SfiProxy snet)
static void
bst_snet_router_init (BstSNetRouter *self)
{
+ new (&self->snet) Bse::SNetH();
GnomeCanvas *canvas = GNOME_CANVAS (self);
GxkActionList *al1, *al2, *canvas_modules, *toolbar_modules, *palette_modules;
BseCategorySeq *cseq;
@@ -1008,7 +1005,6 @@ bst_snet_router_init (BstSNetRouter *self)
self->palette = NULL;
self->adjustment = NULL;
- self->snet = 0;
self->world_x = 0;
self->world_y = 0;
self->drag_is_input = FALSE;
diff --git a/beast-gtk/bstsnetrouter.hh b/beast-gtk/bstsnetrouter.hh
index f0da768..f41f856 100644
--- a/beast-gtk/bstsnetrouter.hh
+++ b/beast-gtk/bstsnetrouter.hh
@@ -28,7 +28,7 @@ struct _BstSNetRouter
GtkWidget *palette_text;
GtkAdjustment *adjustment;
- SfiProxy snet;
+ Bse::SNetH snet;
GxkActionGroup *canvas_tool;
GxkActionGroup *channel_toggle;
@@ -51,14 +51,12 @@ struct _BstSNetRouterClass
/* --- prototypes --- */
GType bst_snet_router_get_type (void);
-GtkWidget* bst_snet_router_new (SfiProxy snet);
-void bst_snet_router_set_snet (BstSNetRouter *router,
- SfiProxy snet);
+GtkWidget* bst_snet_router_new (Bse::SNetH snet);
+void bst_snet_router_set_snet (BstSNetRouter *router, Bse::SNetH snet);
void bst_snet_router_update (BstSNetRouter *snet_router);
void bst_snet_router_adjust_region (BstSNetRouter *snet_router);
-BstCanvasSource* bst_snet_router_csource_from_source (BstSNetRouter *snet_router,
- SfiProxy source);
-BstSNetRouter* bst_snet_router_build_page (SfiProxy snet);
+BstCanvasSource* bst_snet_router_csource_from_source (BstSNetRouter *snet_router, SfiProxy source);
+BstSNetRouter* bst_snet_router_build_page (Bse::SNetH snet);
G_END_DECLS
diff --git a/beast-gtk/bstsupershell.cc b/beast-gtk/bstsupershell.cc
index 583e9a4..18479e1 100644
--- a/beast-gtk/bstsupershell.cc
+++ b/beast-gtk/bstsupershell.cc
@@ -155,7 +155,8 @@ static void
super_shell_build_song (BstSuperShell *self,
GtkNotebook *notebook)
{
- SfiProxy song = self->super.proxy_id();
+ Bse::SuperH super = self->super;
+ SfiProxy song = super.proxy_id();
gtk_notebook_append_page (notebook,
bst_track_view_new (song),
@@ -176,7 +177,7 @@ super_shell_build_song (BstSuperShell *self,
gxk_notebook_create_tabulator (_("Busses"), BST_STOCK_BUS, NULL));
if (BST_DBG_EXT)
gtk_notebook_append_page (notebook,
- gtk_widget_get_toplevel (GTK_WIDGET (bst_snet_router_build_page (song))),
+ gtk_widget_get_toplevel (GTK_WIDGET (bst_snet_router_build_page
(Bse::SNetH::down_cast (super)))),
gxk_notebook_create_tabulator (_("Routing"), BST_STOCK_MESH, NULL));
}
@@ -193,7 +194,7 @@ super_shell_build_snet (BstSuperShell *self,
gxk_notebook_create_tabulator (_("Rack"), NULL, NULL));
if (snet.supports_user_synths() || BST_DBG_EXT)
gtk_notebook_append_page (notebook,
- gtk_widget_get_toplevel (GTK_WIDGET (bst_snet_router_build_page
(snet.proxy_id()))),
+ gtk_widget_get_toplevel (GTK_WIDGET (bst_snet_router_build_page (snet))),
gxk_notebook_create_tabulator (_("Routing"), BST_STOCK_MESH, _("Add, edit and
connect synthesizer mesh components")));
param_view = bst_param_view_new (snet.proxy_id());
gtk_notebook_append_page (notebook,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]