[beast: 6/12] BST: adjust to use new Bse::Item methods



commit 244bbd562be9d37aa26feb82c3fd48787a7c2403
Author: Tim Janik <timj gnu org>
Date:   Sat Sep 9 01:08:43 2017 +0200

    BST: adjust to use new Bse::Item methods
    
    Signed-off-by: Tim Janik <timj gnu org>

 beast-gtk/bstapp.cc            |   50 +++++++++++++++----------------
 beast-gtk/bstcanvaslink.cc     |   11 ++----
 beast-gtk/bstcanvassource.cc   |   44 +++++++++++++--------------
 beast-gtk/bstfiledialog.cc     |    4 +-
 beast-gtk/bstitemview.cc       |   20 +++++++-----
 beast-gtk/bstparam-choice.cc   |    3 +-
 beast-gtk/bstparam-item-seq.cc |    5 ++-
 beast-gtk/bstparam-proxy.cc    |   20 ++++++++----
 beast-gtk/bstpianoroll.cc      |    2 +-
 beast-gtk/bstpianorollctrl.cc  |   36 +++++++++-------------
 beast-gtk/bstsnetrouter.cc     |   10 +++---
 beast-gtk/bsttrackroll.cc      |    4 +-
 beast-gtk/bsttrackrollctrl.cc  |    9 ++---
 beast-gtk/bsttrackview.cc      |   57 ++++++++++++++++++++++++-----------
 beast-gtk/bsttreestores.cc     |   65 +++++++++++++++++++++++----------------
 beast-gtk/bstutils.cc          |    7 ++--
 16 files changed, 188 insertions(+), 159 deletions(-)
---
diff --git a/beast-gtk/bstapp.cc b/beast-gtk/bstapp.cc
index 3495966..0d47ff0 100644
--- a/beast-gtk/bstapp.cc
+++ b/beast-gtk/bstapp.cc
@@ -441,15 +441,14 @@ bst_app_get_current_super (BstApp *app)
 }
 
 static void
-app_update_page_item (SfiProxy     item,
-                      const gchar *property_name,
-                      BstApp      *self)
+app_update_page_item (SfiProxy itemid, const char *property_name, BstApp *self)
 {
-  GxkAssortmentEntry *entry = gxk_assortment_find_data (self->ppages, (void*) item);
+  GxkAssortmentEntry *entry = gxk_assortment_find_data (self->ppages, (void*) itemid);
   if (entry)
     {
+      Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
       g_free (entry->label);
-      entry->label = g_strdup (bse_item_get_name_or_type (item));
+      entry->label = g_strdup (item.get_name_or_type().c_str());
       gxk_assortment_changed (self->ppages, entry);
     }
 }
@@ -468,46 +467,45 @@ ppage_item_free (gpointer user_data,
 }
 
 static void
-bst_app_add_page_item (BstApp  *self,
-                       guint    position,
-                       SfiProxy item)
+bst_app_add_page_item (BstApp *self, uint position, SfiProxy itemid)
 {
-  const gchar *stock, *name = bse_item_get_name_or_type (item);
-  bse_item_use (item);
-  bse_proxy_connect (item, "signal::property-notify::uname", app_update_page_item, self, NULL);
-  gchar *tip;
-  if (BSE_IS_WAVE_REPO (item))
+  Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+  const gchar *stock;
+  String name = item.get_name_or_type();
+  bse_item_use (itemid);
+  bse_proxy_connect (itemid, "signal::property-notify::uname", app_update_page_item, self, NULL);
+  String tip;
+  if (BSE_IS_WAVE_REPO (itemid))
     {
       name = _("Waves");
       stock = BST_STOCK_MINI_WAVE_REPO;
-      tip = g_strdup (_("Wave Repository"));
+      tip = _("Wave Repository");
     }
-  else if (BSE_IS_SONG (item))
+  else if (BSE_IS_SONG (itemid))
     {
       stock = BST_STOCK_MINI_SONG;
-      tip = g_strdup_format (_("Song: %s"), name);
+      tip = string_format (_("Song: %s"), name);
     }
-  else if (BSE_IS_MIDI_SYNTH (item))
+  else if (BSE_IS_MIDI_SYNTH (itemid))
     {
       stock = BST_STOCK_MINI_MIDI_SYNTH;
-      tip = g_strdup_format (_("MIDI Synthesizer: %s"), name);
+      tip = string_format (_("MIDI Synthesizer: %s"), name);
     }
   else
     {
       stock = BST_STOCK_MINI_CSYNTH;
-      tip = g_strdup_format (_("Synthesizer: %s"), name);
+      tip = string_format (_("Synthesizer: %s"), name);
     }
   GtkWidget *page = NULL;
-  if (BSE_IS_SUPER (item))
+  if (BSE_IS_SUPER (itemid))
     {
-      page = (GtkWidget*) g_object_new (BST_TYPE_SUPER_SHELL, "super", item, NULL);
+      page = (GtkWidget*) g_object_new (BST_TYPE_SUPER_SHELL, "super", itemid, NULL);
       g_object_ref (page);
       gtk_object_sink (GTK_OBJECT (page));
     }
-  gxk_assortment_insert (self->ppages, position, name, stock, tip, (void*) item, (GObject*) page, self, 
ppage_item_free);
+  gxk_assortment_insert (self->ppages, position, name.c_str(), stock, tip.c_str(), (void*) itemid, 
(GObject*) page, self, ppage_item_free);
   if (page)
     g_object_unref (page);
-  g_free (tip);
 }
 
 static int
@@ -544,7 +542,7 @@ bst_app_reload_pages (BstApp *self)
   Bse::SuperSeq sseq = self->project.get_supers();
   // sort out internal objects
   for (Bse::SuperSeq::iterator it = sseq.begin(); it != sseq.end();)
-    if (!BST_DBG_EXT && bse_item_internal (it->proxy_id()))
+    if (!BST_DBG_EXT && it->internal())
       it = sseq.erase (it);
     else
       ++it;
@@ -613,10 +611,10 @@ bst_app_handle_delete_event (GtkWidget   *widget,
   if (self->project.is_dirty())
     {
       uint result = bst_msg_dialog (BST_MSG_WARNING,
-                                    BST_MSG_TITLE (_("Close %s"), bse_item_get_name 
(self->project.proxy_id())),
+                                    BST_MSG_TITLE (_("Close %s"), self->project.get_name()),
                                     BST_MSG_TEXT1 (_("The project has been modified.")),
                                     BST_MSG_TEXT2 (_("Changes were made to project \"%s\" since the last 
time it was saved to disk."),
-                                                   bse_item_get_name (self->project.proxy_id())),
+                                                   self->project.get_name()),
                                     BST_MSG_TEXT2 (_("Save the project before closing its window?")),
                                     BST_MSG_CHOICE   (2, _("Save Changes"), BST_STOCK_SAVE),
                                     BST_MSG_CHOICE   (1, _("Discard Changes"), BST_STOCK_DELETE),
diff --git a/beast-gtk/bstcanvaslink.cc b/beast-gtk/bstcanvaslink.cc
index 8338c3c..c294f0a 100644
--- a/beast-gtk/bstcanvaslink.cc
+++ b/beast-gtk/bstcanvaslink.cc
@@ -104,19 +104,16 @@ clink_view_update (BstCanvasLink *clink,
   if (frame)
     {
       GtkWidget *text = GTK_BIN (frame)->child;
-      const gchar *iname, *oname;
-      gchar *string;
 
       Bse::SourceH icsource = clink->icsource->source;
       Bse::SourceH ocsource = clink->ocsource->source;
 
       /* figure appropriate window title
        */
-      iname = clink->icsource ? bse_item_get_name_or_type (icsource.proxy_id()) : "<""???"">";
-      oname = clink->ocsource ? bse_item_get_name_or_type (ocsource.proxy_id()) : "<""???"">";
-      string = g_strconcat (_("Module Link: "), iname, " <=> ", oname, NULL);
-      gxk_dialog_set_title (GXK_DIALOG (clink->link_view), string);
-      g_free (string);
+      const String iname = clink->icsource ? icsource.get_name_or_type() : "<""???"">";
+      const String oname = clink->ocsource ? ocsource.get_name_or_type() : "<""???"">";
+      const String title = string_format (_("Module Link: %s <=> %s"), iname, oname);
+      gxk_dialog_set_title (GXK_DIALOG (clink->link_view), title.c_str());
 
       /* construct actuall information
        */
diff --git a/beast-gtk/bstcanvassource.cc b/beast-gtk/bstcanvassource.cc
index 0c0dade..996d393 100644
--- a/beast-gtk/bstcanvassource.cc
+++ b/beast-gtk/bstcanvassource.cc
@@ -154,24 +154,22 @@ canvas_source_set_position (BstCanvasSource *self)
 static void
 source_name_changed (BstCanvasSource *csource)
 {
-  const gchar *name;
-
   assert_return (BST_IS_CANVAS_SOURCE (csource));
 
-  name = bse_item_get_name_or_type (csource->source.proxy_id());
+  String name = csource->source.get_name_or_type();
 
   if (csource->text)
-    g_object_set (csource->text, "text", name, NULL);
+    g_object_set (csource->text, "text", name.c_str(), NULL);
 
   if (csource->params_dialog)
     {
-      gxk_dialog_set_title (GXK_DIALOG (csource->params_dialog), name);
+      gxk_dialog_set_title (GXK_DIALOG (csource->params_dialog), name.c_str());
       csource_info_update (csource);
     }
 
-  name = g_strconcat ("Info: ", name, NULL);
+  name = "Info: " + name;
   if (csource->source_info)
-    gxk_dialog_set_title (GXK_DIALOG (csource->source_info), name);
+    gxk_dialog_set_title (GXK_DIALOG (csource->source_info), name.c_str());
 }
 
 static void
@@ -181,7 +179,7 @@ source_icon_changed (BstCanvasSource *csource)
   if (csource->icon_item)
     {
       Bse::Icon icon = csource->source.icon();
-      bst_canvas_icon_set (csource->icon_item, icon, bse_item_get_type (csource->source.proxy_id()));
+      bst_canvas_icon_set (csource->icon_item, icon, csource->source.get_type().c_str());
     }
 }
 
@@ -274,7 +272,7 @@ canvas_source_create_params (BstCanvasSource *csource)
       csource->params_dialog = (GtkWidget*) gxk_dialog_new (&csource->params_dialog,
                                                             GTK_OBJECT (csource),
                                                             GXK_DIALOG_POPUP_POS,
-                                                            bse_item_get_name_or_type 
(csource->source.proxy_id()),
+                                                            csource->source.get_name_or_type().c_str(),
                                                             param_view);
       source_name_changed (csource);
     }
@@ -339,12 +337,12 @@ csource_info_update (BstCanvasSource *csource)
     {
       /* construct information */
       gxk_scroll_text_clear (text);
-      gxk_scroll_text_aprintf (text, "%s:\n", bse_item_get_name_or_type (csource->source.proxy_id()));
+      gxk_scroll_text_aprintf (text, "%s:\n", csource->source.get_name_or_type());
 
       /* type & category */
       gxk_scroll_text_push_indent (text);
-      gxk_scroll_text_aprintf (text, "Type: %s\n", bse_item_get_type_name (csource->source.proxy_id()));
-      Bse::CategorySeq cseq = bse_server.category_match_typed ("*", bse_item_get_type_name 
(csource->source.proxy_id()));
+      gxk_scroll_text_aprintf (text, "Type: %s\n", csource->source.get_type_name());
+      Bse::CategorySeq cseq = bse_server.category_match_typed ("*", csource->source.get_type_name());
       if (cseq.size())
         gxk_scroll_text_aprintf (text, "Category: %s\n", cseq[0].category);
       gxk_scroll_text_pop_indent (text);
@@ -397,9 +395,9 @@ csource_info_update (BstCanvasSource *csource)
       if (csource_source_n_ochannels)
        gxk_scroll_text_pop_indent (text);
 
-      /* description */
-      const gchar *string = bse_item_get_type_blurb (csource->source.proxy_id());
-      if (string && string[0])
+      // description
+      String string = csource->source.get_type_blurb();
+      if (!string.empty())
        {
          gxk_scroll_text_aprintf (text, "\nDescription:\n");
          gxk_scroll_text_push_indent (text);
@@ -407,14 +405,14 @@ csource_info_update (BstCanvasSource *csource)
          gxk_scroll_text_pop_indent (text);
        }
 
-      /* authors */
-      string = bse_item_get_type_authors (csource->source.proxy_id());
-      if (string && string[0])
+      // authors
+      string = csource->source.get_type_authors();
+      if (!string.empty())
         gxk_scroll_text_aprintf (text, "\nAuthors: %s\n", string);
 
-      /* license */
-      string = bse_item_get_type_license (csource->source.proxy_id());
-      if (string && string[0])
+      // license
+      string = csource->source.get_type_license();
+      if (!string.empty())
         gxk_scroll_text_aprintf (text, "\nLicense: %s\n", string);
     }
 }
@@ -441,7 +439,7 @@ bst_canvas_source_popup_info (BstCanvasSource *csource)
       csource->source_info = (GtkWidget*) gxk_dialog_new (&csource->source_info,
                                                           GTK_OBJECT (csource),
                                                           GXK_DIALOG_POPUP_POS,
-                                                          bse_item_get_name_or_type 
(csource->source.proxy_id()),
+                                                          csource->source.get_name_or_type().c_str(),
                                                           sctext);
     }
   csource_info_update (csource);
@@ -808,7 +806,7 @@ bst_canvas_source_build_async (gpointer data)
       if (!csource->text)
         {
           /* add text item, invoke name_changed callback to setup the text value */
-          guint ocolor = csource->source && bse_item_internal (csource->source.proxy_id()) ? RGBA_INTERNAL : 
RGBA_BLACK;
+          guint ocolor = csource->source && csource->source.internal() ? RGBA_INTERNAL : RGBA_BLACK;
           csource->text = gnome_canvas_item_new (group,
                                                  GNOME_TYPE_CANVAS_TEXT,
                                                  "fill_color_rgba", ocolor,
diff --git a/beast-gtk/bstfiledialog.cc b/beast-gtk/bstfiledialog.cc
index 500e627..8945030 100644
--- a/beast-gtk/bstfiledialog.cc
+++ b/beast-gtk/bstfiledialog.cc
@@ -499,7 +499,7 @@ store_bse_file (Bse::ProjectH project, SfiProxy super_proxy, const String &file_
 {
   Bse::SuperH super = Bse::SuperH::down_cast (bse_server.from_proxy (super_proxy));
   Bse::Error error = project.store_bse (super, file_name, self_contained);
-  const String title = Bse::string_format (saving_message_format.c_str(), bse_item_get_name (super_proxy ? 
super_proxy : project.proxy_id()));
+  const String title = Bse::string_format (saving_message_format.c_str(), super ? super.get_name() : 
project.get_name());
   gboolean handled = TRUE;
   gchar *msg = NULL;
   /* handle file exists cases */
@@ -507,7 +507,7 @@ store_bse_file (Bse::ProjectH project, SfiProxy super_proxy, const String &file_
     {
       if (!want_overwrite)
         {
-          gchar *text = g_strdup_format (_("Failed to save\n`%s'\nto\n`%s':\n%s"), bse_item_get_name 
(project.proxy_id()), file_name, Bse::error_blurb (error));
+          gchar *text = g_strdup_format (_("Failed to save\n`%s'\nto\n`%s':\n%s"), project.get_name(), 
file_name, Bse::error_blurb (error));
           GtkWidget *choice = bst_choice_dialog_createv (BST_CHOICE_TITLE (title),
                                                          BST_CHOICE_TEXT (text),
                                                          BST_CHOICE_D (1, BST_STOCK_OVERWRITE, NONE),
diff --git a/beast-gtk/bstitemview.cc b/beast-gtk/bstitemview.cc
index 01c8ad7..bb3cded 100644
--- a/beast-gtk/bstitemview.cc
+++ b/beast-gtk/bstitemview.cc
@@ -265,15 +265,16 @@ bst_item_view_set_container (BstItemView *self,
 
 void
 bst_item_view_select (BstItemView *self,
-                     SfiProxy     item)
+                     SfiProxy     itemid)
 {
   assert_return (BST_IS_ITEM_VIEW (self));
-  assert_return (BSE_IS_ITEM (item));
+  assert_return (BSE_IS_ITEM (itemid));
+  Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
 
-  if (self->tree && bse_item_get_parent (item) == self->container)
+  if (self->tree && item.get_parent().proxy_id() == self->container)
     {
       GtkTreeIter witer;
-      if (bst_child_list_wrapper_get_iter (self->wlist, &witer, item))
+      if (bst_child_list_wrapper_get_iter (self->wlist, &witer, itemid))
        {
          GtkTreeModel *smodel = gtk_tree_view_get_model (self->tree);
          GtkTreeIter siter;
@@ -284,21 +285,22 @@ bst_item_view_select (BstItemView *self,
          gtk_tree_selection_select_iter (gtk_tree_view_get_selection (self->tree), &siter);
        }
       else /* probably not added yet */
-       self->auto_select = item;
+       self->auto_select = itemid;
     }
 }
 
 gint
 bst_item_view_get_proxy_row (BstItemView *self,
-                             SfiProxy    item)
+                             SfiProxy    itemid)
 {
   assert_return (BST_IS_ITEM_VIEW (self), -1);
-  assert_return (BSE_IS_ITEM (item), -1);
+  assert_return (BSE_IS_ITEM (itemid), -1);
+  Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
 
-  if (self->tree && bse_item_get_parent (item) == self->container)
+  if (self->tree && item.get_parent().proxy_id() == self->container)
     {
       GtkTreeIter witer;
-      if (bst_child_list_wrapper_get_iter (self->wlist, &witer, item))
+      if (bst_child_list_wrapper_get_iter (self->wlist, &witer, itemid))
        {
          GtkTreeModel *smodel = gtk_tree_view_get_model (self->tree);
          GtkTreePath *path;
diff --git a/beast-gtk/bstparam-choice.cc b/beast-gtk/bstparam-choice.cc
index 83616cd..6819678 100644
--- a/beast-gtk/bstparam-choice.cc
+++ b/beast-gtk/bstparam-choice.cc
@@ -71,10 +71,11 @@ param_choice_create (GxkParam    *param,
   if (GXK_IS_MENU_BUTTON (widget))
     {
       SfiProxy proxy = bst_param_get_proxy (param);
+      Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (proxy));
       g_object_set (widget, "menu", menu, NULL);
       str = g_strdup_format ("<BEAST-ParamChoice>/%s(%s::%llx)",
                              param->pspec->name,
-                             proxy ? bse_item_get_type (proxy) : "0",
+                             item ? item.get_type() : "0",
                              (long long unsigned) sfi_pspec_get_choice_hash (param->pspec));
       gtk_menu_set_accel_path (GTK_MENU (menu), str);
       g_free (str);
diff --git a/beast-gtk/bstparam-item-seq.cc b/beast-gtk/bstparam-item-seq.cc
index ceda8ff..7ca2d73 100644
--- a/beast-gtk/bstparam-item-seq.cc
+++ b/beast-gtk/bstparam-item-seq.cc
@@ -91,7 +91,10 @@ param_item_seq_update (GxkParam  *param,
       if (iseq)
         {
           if (iseq->n_items == 1)
-            content = g_strdup_format ("%s", bse_item_get_name_or_type (iseq->items[0]));
+            {
+              Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (iseq->items[0]));
+              content = g_strdup (item.get_name_or_type().c_str());
+            }
           else if (iseq->n_items > 1 && (!pc->partitions || pc->partitions->n_types == 0))
             content = g_strdup_format ("#%u", iseq->n_items);
           else if (iseq->n_items > 1) /* && partitions->n_types */
diff --git a/beast-gtk/bstparam-proxy.cc b/beast-gtk/bstparam-proxy.cc
index 7aebffc..41e477d 100644
--- a/beast-gtk/bstparam-proxy.cc
+++ b/beast-gtk/bstparam-proxy.cc
@@ -44,7 +44,10 @@ param_proxy_populate (GtkWidget *chunter,
       pop->prefix = NULL;
       /* go from object to path name */
       for (i = 0; i < pop->iseq->n_items; i++)
-       pop->paths = g_straddv (pop->paths, g_strdup (bse_item_get_uname_path (pop->iseq->items[i])));
+        {
+          Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (pop->iseq->items[i]));
+          pop->paths = g_straddv (pop->paths, g_strdup (item.get_uname_path().c_str()));
+        }
       if (!pop->paths || !pop->paths[0])
        {
          param_proxy_free_population (pop);
@@ -169,15 +172,16 @@ bst_item_seq_list_match (GSList      *item_seq_slist,
       BseIt3mSeq *iseq = (BseIt3mSeq*) slist->data;
       for (i = 0; i < iseq->n_items; i++)
        {
-         const gchar *path = bse_item_get_uname_path (iseq->items[i]);
-         guint j = path ? strlen (path) : 0;
+          Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (iseq->items[i]));
+         const String path = item.get_uname_path();
+         uint j = path.size();
          if (j == l && Bse::string_cmp (text, path) == 0)
            return iseq->items[i];      /* found exact match */
          else if (!cmatch && j == l && Bse::string_casecmp (text, path) == 0)
            cmatch = iseq->items[i];    /* remember first case insensitive match */
-         else if (!tmatch && j > l && Bse::string_cmp (text, path + j - l) == 0)
+         else if (!tmatch && j > l && Bse::string_cmp (text, &path[0] + j - l) == 0)
            tmatch = iseq->items[i];    /* remember first tail match */
-         else if (!tcmatch && j > l && Bse::string_casecmp (text, path + j - l) == 0)
+         else if (!tcmatch && j > l && Bse::string_casecmp (text, &path[0] + j - l) == 0)
            tcmatch = iseq->items[i];   /* remember first case insensitive tail match */
        }
     }
@@ -226,8 +230,10 @@ static void
 param_proxy_update (GxkParam  *param,
                    GtkWidget *box)
 {
-  SfiProxy item = sfi_value_get_proxy (&param->value);
-  const gchar *cstring = item ? bse_item_get_uname_path (item) : NULL;
+  SfiProxy proxy = sfi_value_get_proxy (&param->value);
+  Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (proxy));
+  const String upath = item ? item.get_uname_path() : "";
+  const char *cstring = upath.c_str();
   GtkWidget *entry = ((GtkBoxChild*) GTK_BOX (box)->children->data)->widget;
   GtkWidget *chunter = (GtkWidget*) bst_clue_hunter_from_entry (entry);
 
diff --git a/beast-gtk/bstpianoroll.cc b/beast-gtk/bstpianoroll.cc
index 19e72be..43f732c 100644
--- a/beast-gtk/bstpianoroll.cc
+++ b/beast-gtk/bstpianoroll.cc
@@ -1232,7 +1232,7 @@ bst_piano_roll_set_part (BstPianoRoll *self, Bse::PartH part)
       self->min_note = self->part.get_min_note();
       self->max_note = self->part.get_max_note();
       piano_roll_range_changed (self);
-      SfiProxy song = bse_item_get_parent (self->part.proxy_id());
+      SfiProxy song = self->part.get_parent().proxy_id();
       if (song)
         {
           self->song = song;
diff --git a/beast-gtk/bstpianorollctrl.cc b/beast-gtk/bstpianorollctrl.cc
index db2aa61..c256af2 100644
--- a/beast-gtk/bstpianorollctrl.cc
+++ b/beast-gtk/bstpianorollctrl.cc
@@ -894,35 +894,29 @@ controller_piano_drag (BstPianoRollController *self,
                       BstPianoRollDrag       *drag)
 {
   Bse::PartH part = self->proll->part;
-  SfiProxy song_proxy = bse_item_get_parent (part.proxy_id());
-  SfiProxy projectid = song_proxy ? bse_item_get_parent (song_proxy) : 0;
-  Bse::SongH song;
+  Bse::SongH song = Bse::SongH::down_cast (part.get_parent());
+  Bse::ProjectH project;
   Bse::TrackH track;
-  if (song_proxy)
+  if (song)
     {
-      song = Bse::SongH::down_cast (bse_server.from_proxy (song_proxy));
+      project = Bse::ProjectH::down_cast (song.get_parent());
       track = song.find_track_for_part (part);
     }
 
   // printerr ("piano drag event, note=%d (valid=%d)", drag->current_note, drag->current_valid);
 
-  if (projectid && track)
+  if (project && track &&
+      (drag->type == GXK_DRAG_START ||
+       (drag->type == GXK_DRAG_MOTION &&
+        self->obj_note != drag->current_note)))
     {
-      Bse::ProjectH project = Bse::ProjectH::down_cast (bse_server.from_proxy (projectid));
-      assert_return (project);
-      if (drag->type == GXK_DRAG_START ||
-         (drag->type == GXK_DRAG_MOTION &&
-          self->obj_note != drag->current_note))
-       {
-          Bse::Error error;
-         project.auto_deactivate (5 * 1000);
-         error = project.activate();
-         self->obj_note = drag->current_note;
-         if (error == Bse::Error::NONE)
-           song.synthesize_note (track, 384 * 4, self->obj_note, 0, 1.0);
-         bst_status_eprintf (error, _("Play note"));
-         drag->state = GXK_DRAG_CONTINUE;
-       }
+      project.auto_deactivate (5 * 1000);
+      Bse::Error error = project.activate();
+      self->obj_note = drag->current_note;
+      if (error == Bse::Error::NONE)
+        song.synthesize_note (track, 384 * 4, self->obj_note, 0, 1.0);
+      bst_status_eprintf (error, _("Play note"));
+      drag->state = GXK_DRAG_CONTINUE;
     }
 
   if (drag->type == GXK_DRAG_START ||
diff --git a/beast-gtk/bstsnetrouter.cc b/beast-gtk/bstsnetrouter.cc
index eac5320..96d1dc4 100644
--- a/beast-gtk/bstsnetrouter.cc
+++ b/beast-gtk/bstsnetrouter.cc
@@ -165,14 +165,14 @@ bst_snet_router_update_links (BstSNetRouter   *self,
           assert_return (obj != NULL);
           Bse::SourceH isource = csource->source;
           assert_return (isource != NULL);
-          SfiProxy osource = isource.ichannel_get_osource (i, j).proxy_id();
+          Bse::SourceH osource = isource.ichannel_get_osource (i, j);
           if (!osource)
             continue;
           guint ochannel = csource->source.ichannel_get_ochannel (i, j);
-          BstCanvasSource *ocsource = bst_snet_router_csource_from_source (self, osource);
+          BstCanvasSource *ocsource = bst_snet_router_csource_from_source (self, osource.proxy_id());
           if (!ocsource)
             {
-              Bse::warning ("Couldn't figure CanvasSource Item from BSE module \"%s\"", 
bse_item_get_name_or_type (osource));
+              Bse::warning ("Couldn't figure CanvasSource Item from BSE module \"%s\"", 
osource.get_name_or_type());
               continue;
             }
           /* find corresponding link */
@@ -640,9 +640,9 @@ bst_snet_router_root_event (BstSNetRouter   *self,
           if (csource)
             {
               GtkWidget *choice;
-              gchar *source_name = g_strconcat (bse_item_get_type_name (csource->source.proxy_id()),
+              gchar *source_name = g_strconcat (csource->source.get_type_name().c_str(),
                                                 ": ",
-                                                bse_item_get_name (csource->source.proxy_id()),
+                                                csource->source.get_name().c_str(),
                                                 NULL);
               /* create popup sumenu */
               uint has_inputs = 0, monitor_ids = 1000000;
diff --git a/beast-gtk/bsttrackroll.cc b/beast-gtk/bsttrackroll.cc
index ae2dbb3..9325c9f 100644
--- a/beast-gtk/bsttrackroll.cc
+++ b/beast-gtk/bsttrackroll.cc
@@ -623,7 +623,7 @@ bst_track_roll_draw_canvas (GxkScrollCanvas *scc,
               PangoRectangle rect = { 0 };
              guint tick = tp.tick;
              guint duration = tp.duration;
-             const gchar *name = bse_item_get_name (tp.part.proxy_id());
+             const String name = tp.part.get_name();
              GdkRectangle area, carea;
              carea.x = tick_to_coord (self, tick);
               carea.width = ticks_to_pixels (self, duration);
@@ -638,7 +638,7 @@ bst_track_roll_draw_canvas (GxkScrollCanvas *scc,
               carea.y += YTHICKNESS (self);
               carea.height = MAX (0, carea.height - 2 * YTHICKNESS (self));
               area = carea;
-              pango_layout_set_text (PLAYOUT_CANVAS (self), name, -1);
+              pango_layout_set_text (PLAYOUT_CANVAS (self), name.c_str(), -1);
               pango_layout_get_pixel_extents (PLAYOUT_CANVAS (self), NULL, &rect);
              gdk_draw_rectangle (drawable, bg2_gc, // row == self->prelight_row ? bgp_gc : bg2_gc,
                                  TRUE, area.x, area.y, area.width, area.height);
diff --git a/beast-gtk/bsttrackrollctrl.cc b/beast-gtk/bsttrackrollctrl.cc
index 9bc6172..8a7868e 100644
--- a/beast-gtk/bsttrackrollctrl.cc
+++ b/beast-gtk/bsttrackrollctrl.cc
@@ -384,9 +384,9 @@ edit_name_start (BstTrackRollController *self,
                                      "visible", TRUE,
                                      "has_frame", FALSE,
                                      NULL);
-      const gchar *name = bse_item_get_name (self->obj_part.proxy_id());
-      if (name)
-       gtk_entry_set_text (entry, name);
+      const String name = self->obj_part.get_name();
+      if (!name.empty())
+       gtk_entry_set_text (entry, name.c_str());
       bst_track_roll_start_edit (self->troll, drag->current_row,
                                 self->obj_tick, self->obj_duration,
                                 GTK_CELL_EDITABLE (entry));
@@ -423,8 +423,7 @@ insert_start (BstTrackRollController *self,
       Bse::PartH part = track.get_part (tick);
       if (!part)
        {
-         SfiProxy songid = bse_item_get_parent (drag->current_track.proxy_id());
-          Bse::SongH song = Bse::SongH::down_cast (bse_server.from_proxy (songid));
+          Bse::SongH song = Bse::SongH::down_cast (drag->current_track.get_parent());
           song.group_undo ("Insert part");
           Bse::PartH part = song.create_part();
          if (part && track.insert_part (tick, part) > 0)
diff --git a/beast-gtk/bsttrackview.cc b/beast-gtk/bsttrackview.cc
index 578a3c2..539e683 100644
--- a/beast-gtk/bsttrackview.cc
+++ b/beast-gtk/bsttrackview.cc
@@ -118,7 +118,6 @@ track_view_fill_value (BstItemView *iview,
     return; // item is probably already destructed
   switch (column)
     {
-      const gchar *string;
       gboolean vbool;
       SfiInt vint;
       SfiProxy snet, wave, sound_font_preset;
@@ -128,7 +127,7 @@ track_view_fill_value (BstItemView *iview,
       sfi_value_take_string (value, g_strdup_format ("%03d", seqid));
       break;
     case COL_NAME:
-      g_value_set_string (value, bse_item_get_name (item.proxy_id()));
+      g_value_set_string (value, item.get_name().c_str());
       break;
     case COL_MUTE:
       bse_proxy_get (item.proxy_id(), "muted", &vbool, NULL);
@@ -143,15 +142,27 @@ track_view_fill_value (BstItemView *iview,
       wave = 0;
       sound_font_preset = 0;
       bse_proxy_get (item.proxy_id(), "snet", &snet, "wave", &wave, "sound_font_preset", &sound_font_preset, 
NULL);
-      if (snet)
-       string = bse_item_get_name (snet);
-      else if (wave)
-       string = bse_item_get_name (wave);
-      else if (sound_font_preset)
-       string = bse_item_get_name (sound_font_preset);
-      else
-       string = "";
-      g_value_set_string (value, string);
+      {
+        String string;
+        if (snet)
+          {
+            Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (snet));
+            string = item.get_name();
+          }
+        else if (wave)
+          {
+            Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (wave));
+            string = item.get_name();
+          }
+        else if (sound_font_preset)
+          {
+            Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (sound_font_preset));
+            string = item.get_name();
+          }
+        else
+          string = "";
+        g_value_set_string (value, string.c_str());
+      }
       break;
     case COL_MIDI_CHANNEL:
       bse_proxy_get (item.proxy_id(), "midi-channel", &vint, NULL);
@@ -161,7 +172,10 @@ track_view_fill_value (BstItemView *iview,
       bse_proxy_get (item.proxy_id(), "outputs", &seq, NULL);
       iseq = bse_it3m_seq_from_seq (seq);
       if (iseq && iseq->n_items == 1)
-        g_value_take_string (value, g_strdup_format ("%s", bse_item_get_name_or_type (iseq->items[0])));
+        {
+          Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (iseq->items[0]));
+          g_value_take_string (value, g_strdup_format ("%s", item.get_name_or_type()));
+        }
       else if (iseq && iseq->n_items > 1)
         g_value_take_string (value, g_strdup_format ("#%u", iseq ? iseq->n_items : 0));
       else
@@ -171,11 +185,17 @@ track_view_fill_value (BstItemView *iview,
     case COL_POST_SYNTH:
       snet = 0;
       bse_proxy_get (item.proxy_id(), "pnet", &snet, NULL);
-      g_value_set_string (value, snet ? bse_item_get_name (snet) : "");
+      {
+        Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (snet));
+        g_value_set_string (value, item ? item.get_name().c_str() : "");
+      }
       break;
     case COL_BLURB:
-      bse_proxy_get (item.proxy_id(), "blurb", &string, NULL);
-      g_value_set_string (value, string ? string : "");
+      {
+        char *cstring = NULL;
+        bse_proxy_get (item.proxy_id(), "blurb", &cstring, NULL);
+        g_value_set_string (value, cstring ? cstring : "");
+      }
       break;
     }
 }
@@ -269,10 +289,11 @@ track_view_synth_popup_cb (gpointer              data,
                            BstTrackSynthDialog  *tsdialog)
 {
   SynthPopup *sdata = (SynthPopup*) data;
+  Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (proxy));
   gxk_cell_renderer_popup_change (sdata->pcell,
-                                  proxy ? bse_item_get_uname_path (proxy) : "",
+                                  item ? item.get_uname_path().c_str() : "",
                                   FALSE,
-                                  proxy == 0);
+                                  item == NULL);
 }
 
 static void
@@ -737,7 +758,7 @@ track_view_action_exec (gpointer data,
       track = song.create_track();
       if (track)
        {
-         gchar *string = g_strdup_format ("Track-%02X", bse_item_get_seqid (track.proxy_id()));
+         gchar *string = g_strdup_format ("Track-%02X", track.get_seqid());
          bse_item_set_name (track.proxy_id(), string);
          g_free (string);
          bst_item_view_select (item_view, track.proxy_id());
diff --git a/beast-gtk/bsttreestores.cc b/beast-gtk/bsttreestores.cc
index ee4a47f..927c89f 100644
--- a/beast-gtk/bsttreestores.cc
+++ b/beast-gtk/bsttreestores.cc
@@ -288,10 +288,10 @@ child_list_wrapper_item_removed (SfiProxy    container,
 }
 
 static gint
-child_list_wrapper_row_from_proxy (ProxyStore *ps,
-                                   SfiProxy    proxy)
+child_list_wrapper_row_from_proxy (ProxyStore *ps, SfiProxy proxy)
 {
-  return bse_item_get_seqid (proxy) - 1;
+  Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (proxy));
+  return item.get_seqid() - 1;
 }
 
 static gboolean
@@ -426,26 +426,30 @@ child_list_wrapper_fill_value (GxkListWrapper *self,
                                guint           row,
                                GValue         *value)
 {
+  Bse::ItemH item;
   guint seqid = row + 1;
   switch (column)
     {
       const gchar *string;
-      SfiProxy item;
+      SfiProxy itemid;
     case BST_PROXY_STORE_SEQID:
       g_value_take_string (value, g_strdup_format ("%03u", seqid));
       break;
     case BST_PROXY_STORE_NAME:
-      item = bst_child_list_wrapper_get_proxy (self, row);
-      g_value_set_string (value, bse_item_get_name (item));
+      itemid = bst_child_list_wrapper_get_proxy (self, row);
+      item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+      g_value_set_string (value, item.get_name().c_str());
       break;
     case BST_PROXY_STORE_BLURB:
-      item = bst_child_list_wrapper_get_proxy (self, row);
-      bse_proxy_get (item, "blurb", &string, NULL);
+      itemid = bst_child_list_wrapper_get_proxy (self, row);
+      item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+      bse_proxy_get (item.proxy_id(), "blurb", &string, NULL);
       g_value_set_string (value, string ? string : "");
       break;
     case BST_PROXY_STORE_TYPE:
-      item = bst_child_list_wrapper_get_proxy (self, row);
-      g_value_set_string (value, bse_item_get_type (item));
+      itemid = bst_child_list_wrapper_get_proxy (self, row);
+      item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+      g_value_set_string (value, item.get_type().c_str());
       break;
     }
 }
@@ -473,26 +477,31 @@ item_seq_store_fill_value (GxkListWrapper *self,
                            GValue         *value)
 {
   GtkTreeModel *model = GTK_TREE_MODEL (self);
+  Bse::ItemH item;
   switch (column)
     {
       const gchar *string;
-      SfiProxy item;
+      SfiProxy itemid;
     case BST_PROXY_STORE_SEQID:
-      item = bst_item_seq_store_get_proxy (model, row);
-      g_value_take_string (value, g_strdup_format ("%03u", bse_item_get_seqid (item)));
+      itemid = bst_item_seq_store_get_proxy (model, row);
+      item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+      g_value_take_string (value, g_strdup_format ("%03u", item.get_seqid()));
       break;
     case BST_PROXY_STORE_NAME:
-      item = bst_item_seq_store_get_proxy (model, row);
-      g_value_set_string (value, bse_item_get_name (item));
+      itemid = bst_item_seq_store_get_proxy (model, row);
+      item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+      g_value_set_string (value, item.get_name().c_str());
       break;
     case BST_PROXY_STORE_BLURB:
-      item = bst_item_seq_store_get_proxy (model, row);
-      bse_proxy_get (item, "blurb", &string, NULL);
+      itemid = bst_item_seq_store_get_proxy (model, row);
+      item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+      bse_proxy_get (item.proxy_id(), "blurb", &string, NULL);
       g_value_set_string (value, string ? string : "");
       break;
     case BST_PROXY_STORE_TYPE:
-      item = bst_item_seq_store_get_proxy (model, row);
-      g_value_set_string (value, bse_item_get_type (item));
+      itemid = bst_item_seq_store_get_proxy (model, row);
+      item = Bse::ItemH::down_cast (bse_server.from_proxy (itemid));
+      g_value_set_string (value, item.get_type().c_str());
       break;
     }
 }
@@ -540,23 +549,25 @@ item_seq_store_destroy_data (gpointer data)
 }
 
 static gint
-proxy_cmp_sorted (gconstpointer   value1,
-                  gconstpointer   value2,
-                  gpointer        data)
+proxy_cmp_sorted (gconstpointer value1, gconstpointer value2, gpointer data)
 {
   SfiProxy p1 = (SfiProxy) value1;
   SfiProxy p2 = (SfiProxy) value2;
   if (!p1 || !p2)
     return p2 ? -1 : p1 != 0;
-  const gchar *s1 = bse_item_get_type (p1);
-  const gchar *s2 = bse_item_get_type (p2);
+  Bse::ItemH item1 = Bse::ItemH::down_cast (bse_server.from_proxy (p1));
+  Bse::ItemH item2 = Bse::ItemH::down_cast (bse_server.from_proxy (p2));
+  const String t1 = item1.get_type(), t2 = item2.get_type();
+  const gchar *s1 = t1.c_str();
+  const gchar *s2 = t2.c_str();
   if (!s1 || !s2)
     return s2 ? -1 : s1 != 0;
-  gint cmp = strcmp (s1, s2);
+  const int cmp = strcmp (s1, s2);
   if (cmp)
     return cmp;
-  s1 = bse_item_get_name (p1);
-  s2 = bse_item_get_name (p2);
+  const String n1 = item1.get_name(), n2 = item2.get_name();
+  s1 = n1.c_str();
+  s2 = n2.c_str();
   if (!s1 || !s2)
     return s2 ? -1 : s1 != 0;
   return strcmp (s1, s2);
diff --git a/beast-gtk/bstutils.cc b/beast-gtk/bstutils.cc
index 73708c6..c14ba43 100644
--- a/beast-gtk/bstutils.cc
+++ b/beast-gtk/bstutils.cc
@@ -202,10 +202,9 @@ typedef struct {
 static void
 sync_title (TitleSync *tsync)
 {
-  const gchar *name = bse_item_get_name (tsync->proxy);
-  gchar *s;
-
-  s = g_strconcat (tsync->title1, name ? name : "<NULL>", tsync->title2, NULL);
+  Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (tsync->proxy));
+  const String name = item.get_name();
+  gchar *s = g_strconcat (tsync->title1, name.c_str(), tsync->title2, NULL);
   g_object_set (tsync->window, "title", s, NULL);
   g_free (s);
 }


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