[beast: 8/9] BST: adjust to use moved Bse.Source accessors



commit 1fbb74340c964bb2bd8afdc8106e70f6d40d77e9
Author: Tim Janik <timj gnu org>
Date:   Sat Jul 29 00:15:18 2017 +0200

    BST: adjust to use moved Bse.Source accessors
    
    Signed-off-by: Tim Janik <timj gnu org>

 beast-gtk/bstcanvaslink.cc       |   21 +++++++-----
 beast-gtk/bstcanvassource.cc     |   62 +++++++++++++++++++------------------
 beast-gtk/bstparam-automation.cc |    3 +-
 beast-gtk/bstplayback.cc         |   36 +++++++++++-----------
 beast-gtk/bstplayback.hh         |    6 ++--
 beast-gtk/bstscrollgraph.cc      |    5 +--
 beast-gtk/bstsnetrouter.cc       |   25 ++++++++-------
 7 files changed, 83 insertions(+), 75 deletions(-)
---
diff --git a/beast-gtk/bstcanvaslink.cc b/beast-gtk/bstcanvaslink.cc
index fbdf384..67bba6a 100644
--- a/beast-gtk/bstcanvaslink.cc
+++ b/beast-gtk/bstcanvaslink.cc
@@ -104,9 +104,12 @@ clink_view_update (BstCanvasLink *clink,
   if (frame)
     {
       GtkWidget *text = GTK_BIN (frame)->child;
-      const gchar *ic_label, *oc_label, *ic_blurb, *oc_blurb, *iname, *oname;
+      const gchar *iname, *oname;
       gchar *string;
 
+      Bse::SourceH icsource = clink->icsource ? Bse::SourceH::down_cast (bse_server.from_proxy 
(clink->icsource->source)) : Bse::SourceH();
+      Bse::SourceH ocsource = clink->ocsource ? Bse::SourceH::down_cast (bse_server.from_proxy 
(clink->ocsource->source)) : Bse::SourceH();
+
       /* figure appropriate window title
        */
       iname = clink->icsource ? bse_item_get_name_or_type (clink->icsource->source) : "<""???"">";
@@ -117,20 +120,20 @@ clink_view_update (BstCanvasLink *clink,
 
       /* construct actuall information
        */
-      oc_label = clink->ocsource ? bse_source_ochannel_label (clink->ocsource->source, clink->ochannel) : 
NULL;
-      oc_blurb = clink->ocsource ? bse_source_ochannel_blurb (clink->ocsource->source, clink->ochannel) : 
NULL;
-      ic_label = clink->icsource ? bse_source_ichannel_label (clink->icsource->source, clink->ichannel) : 
NULL;
-      ic_blurb = clink->icsource ? bse_source_ichannel_blurb (clink->icsource->source, clink->ichannel) : 
NULL;
-      if (!oc_label)
+      String oc_label = clink->ocsource ? ocsource.ochannel_label (clink->ochannel) : "";
+      const String oc_blurb = clink->ocsource ? ocsource.ochannel_blurb (clink->ochannel) : "";
+      String ic_label = clink->icsource ? icsource.ichannel_label (clink->ichannel) : "";
+      const String ic_blurb = clink->icsource ? icsource.ichannel_blurb (clink->ichannel) : "";
+      if (oc_label.empty())
        oc_label = "?";
-      if (!ic_label)
+      if (ic_label.empty())
        ic_label = "?";
 
       /* compose new info */
       gxk_scroll_text_clear (text);
       gxk_scroll_text_aprintf (text, "Source Module:\n");
       gxk_scroll_text_push_indent (text);
-      if (oc_blurb)
+      if (!oc_blurb.empty())
        {
          gxk_scroll_text_aprintf (text, "%s: %s:\n", oname, oc_label);
          gxk_scroll_text_push_indent (text);
@@ -142,7 +145,7 @@ clink_view_update (BstCanvasLink *clink,
       gxk_scroll_text_pop_indent (text);
       gxk_scroll_text_aprintf (text, "\nDestination Module:\n");
       gxk_scroll_text_push_indent (text);
-      if (ic_blurb)
+      if (!ic_blurb.empty())
        {
          gxk_scroll_text_aprintf (text, "%s: %s:\n", iname, ic_label);
          gxk_scroll_text_push_indent (text);
diff --git a/beast-gtk/bstcanvassource.cc b/beast-gtk/bstcanvassource.cc
index 781215c..dce262f 100644
--- a/beast-gtk/bstcanvassource.cc
+++ b/beast-gtk/bstcanvassource.cc
@@ -324,8 +324,6 @@ csource_info_update (BstCanvasSource *csource)
                      : NULL);
   if (text)
     {
-      const gchar *string;
-
       /* construct information */
       gxk_scroll_text_clear (text);
       gxk_scroll_text_aprintf (text, "%s:\n", bse_item_get_name_or_type (csource->source));
@@ -349,15 +347,15 @@ csource_info_update (BstCanvasSource *csource)
        }
       for (size_t i = 0; i < csource_source_n_ichannels; i++)
        {
-          string = bse_source_ichannel_blurb (csource->source, i);
+          const String string = csource_source.ichannel_blurb (i);
          gxk_scroll_text_aprintf (text, "%s[%s]%s\n",
-                                  bse_source_ichannel_label (csource->source, i),
-                                  bse_source_ichannel_ident (csource->source, i),
-                                  string ? ":" : "");
-         if (string)
+                                  csource_source.ichannel_label (i).c_str(),
+                                  csource_source.ichannel_ident (i).c_str(),
+                                  string.empty() ? "" : ":");
+         if (!string.empty())
            {
              gxk_scroll_text_push_indent (text);
-             gxk_scroll_text_aprintf (text, "%s\n", string);
+             gxk_scroll_text_aprintf (text, "%s\n", string.c_str());
              gxk_scroll_text_pop_indent (text);
            }
        }
@@ -373,15 +371,15 @@ csource_info_update (BstCanvasSource *csource)
        }
       for (size_t i = 0; i < csource_source_n_ochannels; i++)
        {
-         string = bse_source_ochannel_blurb (csource->source, i);
+         const String string = csource_source.ochannel_blurb (i);
          gxk_scroll_text_aprintf (text, "%s[%s]%s\n",
-                                  bse_source_ochannel_label (csource->source, i),
-                                  bse_source_ochannel_ident (csource->source, i),
-                                  string ? ":" : "");
-          if (string)
+                                  csource_source.ochannel_label (i).c_str(),
+                                  csource_source.ochannel_ident (i).c_str(),
+                                  string.empty() ? "" : ":");
+          if (!string.empty())
            {
              gxk_scroll_text_push_indent (text);
-             gxk_scroll_text_aprintf (text, "%s\n", string);
+             gxk_scroll_text_aprintf (text, "%s\n", string.c_str());
              gxk_scroll_text_pop_indent (text);
            }
        }
@@ -389,7 +387,7 @@ csource_info_update (BstCanvasSource *csource)
        gxk_scroll_text_pop_indent (text);
 
       /* description */
-      string = bse_item_get_type_blurb (csource->source);
+      const gchar *string = bse_item_get_type_blurb (csource->source);
       if (string && string[0])
        {
          gxk_scroll_text_aprintf (text, "\nDescription:\n");
@@ -468,24 +466,26 @@ bst_canvas_source_is_jchannel (BstCanvasSource *csource,
   if (!csource->source)
     return FALSE;
 
-  return bse_source_is_joint_ichannel_by_id (csource->source, ichannel);
+  Bse::SourceH csource_source = Bse::SourceH::down_cast (bse_server.from_proxy (csource->source));
+
+  return csource_source.is_joint_ichannel_by_id (ichannel);
 }
 
 gboolean
-bst_canvas_source_ichannel_free (BstCanvasSource *csource,
-                                guint            ichannel)
+bst_canvas_source_ichannel_free (BstCanvasSource *csource, uint ichannel)
 {
   assert_return (BST_IS_CANVAS_SOURCE (csource), FALSE);
 
   if (!csource->source)
     return FALSE;
 
-  if (bse_source_is_joint_ichannel_by_id (csource->source, ichannel))
+  Bse::SourceH csource_source = Bse::SourceH::down_cast (bse_server.from_proxy (csource->source));
+
+  if (csource_source.is_joint_ichannel_by_id (ichannel))
     return TRUE;
   else
     {
-      Bse::SourceH isource = Bse::SourceH::down_cast (bse_server.from_proxy (csource->source));
-      Bse::SourceH osource = isource.ichannel_get_osource (ichannel, 0);
+      Bse::SourceH osource = csource_source.ichannel_get_osource (ichannel, 0);
       return osource == NULL;
     }
 }
@@ -710,8 +710,8 @@ bst_canvas_source_build_channels (BstCanvasSource *csource,
   for (int i = 0; i < n_channels; i++)
     {
       GnomeCanvasItem *item;
-      gboolean is_jchannel = is_input && bse_source_is_joint_ichannel_by_id (csource->source, i);
-      const gchar *label = (is_input ? bse_source_ichannel_label : bse_source_ochannel_label) 
(csource->source, i);
+      gboolean is_jchannel = is_input && csource_source.is_joint_ichannel_by_id (i);
+      const String label = is_input ? csource_source.ichannel_label (i) : csource_source.ochannel_label (i);
       guint tmp_color = is_jchannel ? color2 : color1;
 
       y2 = y1 + d_y;
@@ -749,7 +749,7 @@ bst_canvas_source_build_channels (BstCanvasSource *csource,
                             "swapped_signal::destroy", channel_name_remove, csource,
                             NULL);
           gnome_canvas_text_set_zoom_size (GNOME_CANVAS_TEXT (item), FONT_HEIGHT);
-          g_object_set_data_full (G_OBJECT (item), "hint_text", g_strdup (label), g_free);
+          g_object_set_data_full (G_OBJECT (item), "hint_text", g_strdup (label.c_str()), g_free);
           csource->channel_hints = g_slist_prepend (csource->channel_hints, item);
         }
 
@@ -952,15 +952,17 @@ bst_canvas_source_event (GnomeCanvasItem *item,
        }
       else
        {
+          Bse::SourceH csource_source = Bse::SourceH::down_cast (bse_server.from_proxy (csource->source));
          guint channel;
-         const gchar *label = NULL, *prefix = NULL, *ident = NULL;
+         const gchar *prefix = NULL;
+          String label, ident;
 
          /* set i/o channel hints */
          channel = bst_canvas_source_ichannel_at (csource, event->motion.x, event->motion.y);
          if (channel != ~uint (0))
            {
-             label = bse_source_ichannel_label (csource->source, channel);
-             ident = bse_source_ichannel_ident (csource->source, channel);
+             label = csource_source.ichannel_label (channel);
+             ident = csource_source.ichannel_ident (channel);
              prefix = _("Input");
            }
          else
@@ -968,12 +970,12 @@ bst_canvas_source_event (GnomeCanvasItem *item,
              channel = bst_canvas_source_ochannel_at (csource, event->motion.x, event->motion.y);
              if (channel != ~uint (0))
                {
-                 label = bse_source_ochannel_label (csource->source, channel);
-                 ident = bse_source_ochannel_ident (csource->source, channel);
+                 label = csource_source.ochannel_label (channel);
+                 ident = csource_source.ochannel_ident (channel);
                  prefix = _("Output");
                }
            }
-         if (label)
+         if (!label.empty())
            gxk_status_printf (GXK_STATUS_IDLE_HINT, _("(Hint)"), "%s[%s]: %s", prefix, ident, label);
          else
            gxk_status_set (GXK_STATUS_IDLE_HINT, NULL, NULL);
diff --git a/beast-gtk/bstparam-automation.cc b/beast-gtk/bstparam-automation.cc
index e9dd62a..ee1e4dd 100644
--- a/beast-gtk/bstparam-automation.cc
+++ b/beast-gtk/bstparam-automation.cc
@@ -212,7 +212,8 @@ param_automation_update (GxkParam  *param,
   gxk_widget_set_tooltip (widget, tip);
   gxk_widget_set_tooltip (gxk_parent_find_descendant (widget, GTK_TYPE_BUTTON), tip);
   g_free (tip);
-  gtk_widget_set_sensitive (GTK_BIN (widget)->child, proxy && !bse_source_is_prepared (proxy));
+  Bse::SourceH source = Bse::SourceH::down_cast (bse_server.from_proxy (proxy));
+  gtk_widget_set_sensitive (GTK_BIN (widget)->child, proxy && !source.is_prepared());
 }
 
 static GxkParamEditor param_automation = {
diff --git a/beast-gtk/bstplayback.cc b/beast-gtk/bstplayback.cc
index 9c54710..7ee7c49 100644
--- a/beast-gtk/bstplayback.cc
+++ b/beast-gtk/bstplayback.cc
@@ -24,16 +24,16 @@ bst_play_back_handle_new (void)
 
   handle->snet = handle->project.create_csynth ("");
   handle->snet.auto_activate (true);
-  handle->speaker = handle->snet.create_source ("BsePcmOutput").proxy_id();
-  handle->wosc1 = handle->snet.create_source ("BseWaveOsc").proxy_id();
-  handle->wosc2 = handle->snet.create_source ("BseWaveOsc").proxy_id();
-  bse_proxy_set (handle->wosc2, "channel", 2, NULL);
-  bse_source_set_input_by_id (handle->speaker, 0, handle->wosc1, 0);
-  bse_source_set_input_by_id (handle->speaker, 1, handle->wosc2, 0);
-  handle->constant = handle->snet.create_source ("BseConstant").proxy_id();
-  bse_source_set_input_by_id (handle->wosc1, 0, handle->constant, 0);
-  bse_source_set_input_by_id (handle->wosc2, 0, handle->constant, 0);
-  bse_proxy_connect (handle->wosc1,
+  handle->speaker = handle->snet.create_source ("BsePcmOutput");
+  handle->wosc1 = handle->snet.create_source ("BseWaveOsc");
+  handle->wosc2 = handle->snet.create_source ("BseWaveOsc");
+  bse_proxy_set (handle->wosc2.proxy_id(), "channel", 2, NULL);
+  handle->speaker.set_input_by_id (0, handle->wosc1, 0);
+  handle->speaker.set_input_by_id (1, handle->wosc2, 0);
+  handle->constant = handle->snet.create_source ("BseConstant");
+  handle->wosc1.set_input_by_id (0, handle->constant, 0);
+  handle->wosc2.set_input_by_id (0, handle->constant, 0);
+  bse_proxy_connect (handle->wosc1.proxy_id(),
                     "swapped_signal::notify_pcm_position", wave_oscillator_pcm_notify, handle,
                     NULL);
   return handle;
@@ -48,9 +48,9 @@ bst_play_back_handle_set (BstPlayBackHandle *handle,
   if (esample)
     assert_return (BSE_IS_EDITABLE_SAMPLE (esample));
 
-  bse_proxy_set (handle->constant, "frequency_1", osc_freq, NULL);
-  bse_wave_osc_set_from_editable_sample (handle->wosc1, esample);
-  bse_wave_osc_set_from_editable_sample (handle->wosc2, esample);
+  bse_proxy_set (handle->constant.proxy_id(), "frequency_1", osc_freq, NULL);
+  bse_wave_osc_set_from_editable_sample (handle->wosc1.proxy_id(), esample);
+  bse_wave_osc_set_from_editable_sample (handle->wosc2.proxy_id(), esample);
 }
 
 void
@@ -68,9 +68,9 @@ bst_play_back_handle_seek_perc (BstPlayBackHandle *handle,
                                gfloat             perc)
 {
   BseIt3mSeq *iseq = bse_it3m_seq_new();
-  bse_it3m_seq_append (iseq, handle->wosc1);
+  bse_it3m_seq_append (iseq, handle->wosc1.proxy_id());
   if (handle->wosc2)
-    bse_it3m_seq_append (iseq, handle->wosc2);
+    bse_it3m_seq_append (iseq, handle->wosc2.proxy_id());
   bse_wave_osc_mass_seek_perc (iseq, perc);
   if (handle->waiting_for_notify)
     handle->discard_next_notify = TRUE;
@@ -107,7 +107,7 @@ wave_oscillator_pcm_notify (BstPlayBackHandle *handle,
 {
   gboolean discard_next_notify = handle->discard_next_notify;
 
-  assert_return (handle->wosc1 == wosc);
+  assert_return (handle->wosc1.proxy_id() == wosc);
 
   handle->waiting_for_notify = FALSE;
   handle->discard_next_notify = FALSE;
@@ -123,7 +123,7 @@ pcm_timer (gpointer data)
   GDK_THREADS_ENTER ();
   if (!handle->waiting_for_notify)
     {
-      bse_wave_osc_request_pcm_position (handle->wosc1);
+      bse_wave_osc_request_pcm_position (handle->wosc1.proxy_id());
       handle->waiting_for_notify = TRUE;
     }
   GDK_THREADS_LEAVE ();
@@ -179,7 +179,7 @@ bst_play_back_handle_destroy (BstPlayBackHandle *handle)
 
   bst_play_back_handle_stop (handle);
 
-  bse_proxy_disconnect (handle->wosc1, "any_signal", wave_oscillator_pcm_notify, handle, NULL);
+  bse_proxy_disconnect (handle->wosc1.proxy_id(), "any_signal", wave_oscillator_pcm_notify, handle, NULL);
 
   if (handle->pcm_timeout)
     g_source_remove (handle->pcm_timeout);
diff --git a/beast-gtk/bstplayback.hh b/beast-gtk/bstplayback.hh
index 7459bd4..3a743bd 100644
--- a/beast-gtk/bstplayback.hh
+++ b/beast-gtk/bstplayback.hh
@@ -13,9 +13,9 @@ typedef struct
 {
   Bse::ProjectH project;
   Bse::SNetH    snet;
-  SfiProxy speaker;
-  SfiProxy wosc1, wosc2;
-  SfiProxy constant;
+  Bse::SourceH  speaker;
+  Bse::SourceH  wosc1, wosc2;
+  Bse::SourceH  constant;
   guint             current_delay;
   guint             pcm_timeout;
   BstPlayBackNotify pcm_notify;
diff --git a/beast-gtk/bstscrollgraph.cc b/beast-gtk/bstscrollgraph.cc
index 80d7fa7..0e07e09 100644
--- a/beast-gtk/bstscrollgraph.cc
+++ b/beast-gtk/bstscrollgraph.cc
@@ -670,8 +670,7 @@ bst_scrollgraph_build_dialog (GtkWidget *alive_object, Bse::SourceH source, uint
         g_signal_connect_object (scg, "resize-values", G_CALLBACK (scrollgraph_resize_alignment), alignment, 
G_CONNECT_AFTER);
     }
   GtkWidget *dialog = (GtkWidget*) gxk_dialog_new (NULL, (GtkObject*) alive_object, GxkDialogFlags (0), 
"Scrollgraph", (GtkWidget*) radget);
-  gchar *title = g_strdup_format ("Spectrogram: %%s (%s)", bse_source_ochannel_label (source.proxy_id(), 
ochannel));
-  bst_window_sync_title_to_proxy (dialog, source.proxy_id(), title);
-  g_free (title);
+  String title = string_format ("Spectrogram: %%s (%s)", source.ochannel_label (ochannel));
+  bst_window_sync_title_to_proxy (dialog, source.proxy_id(), title.c_str());
   return dialog;
 }
diff --git a/beast-gtk/bstsnetrouter.cc b/beast-gtk/bstsnetrouter.cc
index ad3b4e7..44a02f9 100644
--- a/beast-gtk/bstsnetrouter.cc
+++ b/beast-gtk/bstsnetrouter.cc
@@ -160,7 +160,7 @@ bst_snet_router_update_links (BstSNetRouter   *self,
    */
   for (int i = 0; i < csource_source.n_ichannels(); i++)
     {
-      guint j, n_joints = bse_source_ichannel_get_n_joints (csource->source, i);
+      guint j, n_joints = csource_source.ichannel_get_n_joints (i);
       for (j = 0; j < n_joints; j++)
         {
           Bse::ObjectH obj = bse_server.from_proxy (csource->source);
@@ -170,7 +170,7 @@ bst_snet_router_update_links (BstSNetRouter   *self,
           SfiProxy osource = isource.ichannel_get_osource (i, j).proxy_id();
           if (!osource)
             continue;
-          guint ochannel = bse_source_ichannel_get_ochannel (csource->source, i, j);
+          guint ochannel = csource_source.ichannel_get_ochannel (i, j);
           BstCanvasSource *ocsource = bst_snet_router_csource_from_source (self, osource);
           if (!ocsource)
             {
@@ -623,15 +623,15 @@ bst_snet_router_root_event (BstSNetRouter   *self,
             }
           else
             {
+              Bse::SourceH csource_source = Bse::SourceH::down_cast (bse_server.from_proxy 
(csource->source));
+              Bse::SourceH drag_csource_source = Bse::SourceH::down_cast (bse_server.from_proxy 
(self->drag_csource->source));
               Bse::Error error;
               if (!csource || (self->drag_is_input ? ochannel : ichannel) == ~uint (0))
                 error = self->drag_is_input ? Bse::Error::SOURCE_NO_SUCH_OCHANNEL : 
Bse::Error::SOURCE_NO_SUCH_ICHANNEL;
               else if (self->drag_is_input)
-                error = bse_source_set_input_by_id (self->drag_csource->source, self->drag_channel,
-                                                    csource->source, ochannel);
+                error = drag_csource_source.set_input_by_id (self->drag_channel, csource_source, ochannel);
               else
-                error = bse_source_set_input_by_id (csource->source, ichannel,
-                                                    self->drag_csource->source, self->drag_channel);
+                error = csource_source.set_input_by_id (ichannel, drag_csource_source, self->drag_channel);
               self->drag_csource = NULL;
               self->drag_channel = ~0;
               bst_snet_router_reset_tool (self);
@@ -654,13 +654,13 @@ bst_snet_router_root_event (BstSNetRouter   *self,
               choice = bst_choice_menu_createv ("<BEAST-SNetRouter>/ModuleChannelPopup", NULL);
               for (int i = 0; i < csource_source.n_ochannels(); i++)
                 {
-                  gchar *name = g_strdup_format ("%d: %s", i + 1, bse_source_ochannel_label 
(csource->source, i));
+                  gchar *name = g_strdup_format ("%d: %s", i + 1, csource_source.ochannel_label (i));
                   bst_choice_menu_add_choice_and_free (choice, BST_CHOICE (monitor_ids + i, name, NONE));
                   g_free (name);
                 }
               /* create popup */
               for (int i = 0; has_inputs == 0 && i < csource_source.n_ichannels(); i++)
-                has_inputs += bse_source_ichannel_get_n_joints (csource->source, i);
+                has_inputs += csource_source.ichannel_get_n_joints (i);
               choice = bst_choice_menu_createv ("<BEAST-SNetRouter>/ModulePopup",
                                                 BST_CHOICE_TITLE (source_name),
                                                 BST_CHOICE_SEPERATOR,
@@ -727,9 +727,12 @@ bst_snet_router_root_event (BstSNetRouter   *self,
                 {
                   Bse::Error error;
                 case 1:
-                  error = bse_source_unset_input_by_id (clink->icsource->source, clink->ichannel,
-                                                        clink->ocsource->source, clink->ochannel);
-                  bst_status_eprintf (error, _("Delete Link"));
+                  {
+                    Bse::SourceH icsource = Bse::SourceH::down_cast (bse_server.from_proxy 
(clink->icsource->source));
+                    Bse::SourceH ocsource = Bse::SourceH::down_cast (bse_server.from_proxy 
(clink->ocsource->source));
+                    error = icsource.unset_input_by_id (clink->ichannel, ocsource, clink->ochannel);
+                    bst_status_eprintf (error, _("Delete Link"));
+                  }
                   break;
                 case 2:
                   bst_canvas_link_popup_view (clink);


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