[beast: 3/9] BST: make use of Bse::ItemSeq and Bse::PropertyCandidates



commit a41ddc508dd2bf0a4c0cc0576c4271f55ad21381
Author: Tim Janik <timj gnu org>
Date:   Wed Sep 27 01:45:55 2017 +0200

    BST: make use of Bse::ItemSeq and Bse::PropertyCandidates
    
    Signed-off-by: Tim Janik <timj gnu org>

 beast-gtk/bstparam-item-seq.cc |    5 ++-
 beast-gtk/bstparam-proxy.cc    |   48 ++++++++++++++++++++--------------------
 2 files changed, 27 insertions(+), 26 deletions(-)
---
diff --git a/beast-gtk/bstparam-item-seq.cc b/beast-gtk/bstparam-item-seq.cc
index 7ca2d73..bdb7d66 100644
--- a/beast-gtk/bstparam-item-seq.cc
+++ b/beast-gtk/bstparam-item-seq.cc
@@ -25,11 +25,12 @@ param_item_seq_popup_editor (GtkWidget *widget,
   SfiProxy proxy = bst_param_get_proxy (param);
   if (proxy)
     {
-      BsePropertyCandidates *pc = bse_item_get_property_candidates (proxy, param->pspec->name);
+      Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (proxy));
+      Bse::PropertyCandidates pc = item.get_property_candidates (param->pspec->name);
       SfiSeq *seq = (SfiSeq*) g_value_get_boxed (&param->value);
       BseIt3mSeq *iseq = bse_it3m_seq_from_seq (seq);
       bst_item_seq_dialog_popup (widget, proxy,
-                                 pc->label, pc->tooltip, pc->items,
+                                 pc.label.c_str(), pc.tooltip.c_str(), pc.items,
                                  g_param_spec_get_nick (param->pspec), g_param_spec_get_blurb 
(param->pspec), iseq,
                                  param_item_seq_changed,
                                  param, NULL);
diff --git a/beast-gtk/bstparam-proxy.cc b/beast-gtk/bstparam-proxy.cc
index 41e477d..f03b966 100644
--- a/beast-gtk/bstparam-proxy.cc
+++ b/beast-gtk/bstparam-proxy.cc
@@ -4,9 +4,9 @@
 
 /* --- SfiProxy parameter editors --- */
 typedef struct {
-  BseIt3mSeq *iseq;
-  gchar      **paths;
-  gchar       *prefix;
+  Bse::ItemSeq iseq;
+  gchar      **paths = NULL;
+  gchar       *prefix = NULL;
 } ParamProxyPopulation;
 static void
 param_proxy_free_population (gpointer p)
@@ -14,8 +14,7 @@ param_proxy_free_population (gpointer p)
   ParamProxyPopulation *pop = (ParamProxyPopulation*) p;
   g_strfreev (pop->paths);
   g_free (pop->prefix);
-  bse_it3m_seq_free (pop->iseq);
-  g_free (pop);
+  delete pop;
 }
 
 static void
@@ -24,28 +23,28 @@ param_proxy_populate (GtkWidget *chunter,
 {
   BstClueHunter *ch = BST_CLUE_HUNTER (chunter);
   ParamProxyPopulation *pop = NULL;
-  BsePropertyCandidates *pc = NULL;
   SfiProxy proxy;
   gchar *p;
-  guint i, l;
+  guint l;
 
   /* clear current list */
   bst_clue_hunter_remove_matches (ch, "*");
 
   /* list candidates */
+  Bse::PropertyCandidates pc;
   proxy = bst_param_get_proxy (param);
   if (proxy)
-    pc = bse_item_get_property_candidates (proxy, param->pspec->name);
-  if (pc && pc->items)
+    pc = Bse::ItemH::down_cast (bse_server.from_proxy (proxy)).get_property_candidates (param->pspec->name);
+  if (pc.items.size())
     {
-      pop = g_new (ParamProxyPopulation, 1);
-      pop->iseq = bse_it3m_seq_copy_shallow (pc->items);
+      pop = new ParamProxyPopulation();
+      pop->iseq = pc.items;
       pop->paths = NULL;
       pop->prefix = NULL;
       /* go from object to path name */
-      for (i = 0; i < pop->iseq->n_items; i++)
+      for (size_t i = 0; i < pop->iseq.size(); i++)
         {
-          Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (pop->iseq->items[i]));
+          Bse::ItemH item = pop->iseq[i];
           pop->paths = g_straddv (pop->paths, g_strdup (item.get_uname_path().c_str()));
         }
       if (!pop->paths || !pop->paths[0])
@@ -61,7 +60,7 @@ param_proxy_populate (GtkWidget *chunter,
   /* figure common prefix, aligned to path segment boundaries (':') */
   pop->prefix = g_strdup (pop->paths[0]);
   /* intersect */
-  for (i = 0; pop->paths[i]; i++)
+  for (size_t i = 0; pop->paths[i]; i++)
     {
       const gchar *m = pop->paths[i];
       /* strdiff prefix against current path */
@@ -87,7 +86,7 @@ param_proxy_populate (GtkWidget *chunter,
   l = pop->prefix ? strlen (pop->prefix) : 0;
 
   /* add unprefixed names to clue hunter */
-  for (i = 0; pop->paths[i]; i++)
+  for (size_t i = 0; pop->paths[i]; i++)
     bst_clue_hunter_add_string (ch, pop->paths[i] + l);
 }
 
@@ -100,7 +99,7 @@ param_proxy_changed (GtkWidget *entry,
       GtkWidget *chunter = (GtkWidget*) bst_clue_hunter_from_entry (entry);
       ParamProxyPopulation *pop = (ParamProxyPopulation*) g_object_get_data (G_OBJECT (chunter), "pop");
       gchar *string = g_strdup_stripped (gtk_entry_get_text (GTK_ENTRY (entry)));
-      SfiProxy item = 0;
+      Bse::ItemH item;
       if (pop)
        {
          guint i, l = strlen (string);
@@ -110,7 +109,7 @@ param_proxy_changed (GtkWidget *entry,
              for (i = 0; pop->paths[i]; i++)
                if (strcmp (string, pop->paths[i] + j) == 0)
                  {
-                   item = pop->iseq->items[i];
+                   item = pop->iseq[i];
                    break;
                  }
            }
@@ -120,7 +119,7 @@ param_proxy_changed (GtkWidget *entry,
                guint j = strlen (pop->paths[i]);
                if (j >= l && strcmp (string, pop->paths[i] + j - l) == 0)
                  {
-                   item = pop->iseq->items[i];
+                   item = pop->iseq[i];
                    break;
                  }
              }
@@ -130,7 +129,7 @@ param_proxy_changed (GtkWidget *entry,
              for (i = 0; pop->paths[i]; i++)
                if (g_ascii_strcasecmp (string, pop->paths[i] + j) == 0)
                  {
-                   item = pop->iseq->items[i];
+                   item = pop->iseq[i];
                    break;
                  }
            }
@@ -140,15 +139,15 @@ param_proxy_changed (GtkWidget *entry,
                guint j = strlen (pop->paths[i]);
                if (j >= l && g_ascii_strcasecmp (string, pop->paths[i] + j - l) == 0)
                  {
-                   item = pop->iseq->items[i];
+                   item = pop->iseq[i];
                    break;
                  }
              }
        }
       /* we get lots of notifications from focus-out, so try to optimize */
-      if (sfi_value_get_proxy (&param->value) != item)
+      if (sfi_value_get_proxy (&param->value) != item.proxy_id())
        {
-         sfi_value_set_proxy (&param->value, item);
+         sfi_value_set_proxy (&param->value, item.proxy_id());
          gxk_param_apply_value (param);
        }
       else if (!item && string[0]) /* make sure the entry is correctly updated */
@@ -209,8 +208,9 @@ param_proxy_create (GxkParam    *param,
   SfiProxy proxy = bst_param_get_proxy (param);
   if (proxy)
     {
-      BsePropertyCandidates *pc = bse_item_get_property_candidates (proxy, param->pspec->name);
-      gxk_widget_set_tooltip (chunter, pc ? pc->tooltip : NULL);
+      Bse::ItemH item = Bse::ItemH::down_cast (bse_server.from_proxy (proxy));
+      Bse::PropertyCandidates pc = item.get_property_candidates (param->pspec->name);
+      gxk_widget_set_tooltip (chunter, pc.tooltip.c_str());
     }
   gxk_widget_add_font_requisition (widget, 16, 2);
   gxk_param_entry_connect_handlers (param, widget, param_proxy_changed);


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