Skip to content

Commit

Permalink
Merge branch 'swesterfeld-pport-item', closes #115
Browse files Browse the repository at this point in the history
* swesterfeld-pport-item:
  BSE: bseitem.cc: remove unused bse_item_{get|set}_property_internal()
  BEAST-GTK: bsttreestores: use seqid C++ property
  BSE: Item::seqid: port property to C++

Signed-off-by: Tim Janik <timj@gnu.org>
  • Loading branch information
tim-janik committed Aug 9, 2019
2 parents a5f707e + 6d99ebe commit a48588c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 57 deletions.
7 changes: 6 additions & 1 deletion beast-gtk/bsttreestores.cc
Expand Up @@ -185,6 +185,8 @@ bst_file_store_destroy (GtkTreeModel *model)
struct ProxyStore {
GxkListWrapper *self = NULL;
int (*row_from_proxy) (ProxyStore *ps, SfiProxy proxy) = NULL;
/* scoped handles for notification */
std::map<SfiProxy, Bse::ItemS> item_s_map;
/* child list specific */
struct {
SfiUPool *ipool = NULL;
Expand All @@ -211,8 +213,10 @@ proxy_store_item_listen_on (ProxyStore *ps,
{
int row = ps->row_from_proxy (ps, item);
assert_return (row >= 0, row);
Bse::ItemS &item_s = ps->item_s_map[item];
item_s = Bse::ItemS::__cast__ (bse_server.from_proxy (item));
item_s.on ("notify:seqid", [item,ps] { proxy_store_item_property_notify (item, "seqid", ps); });
bse_proxy_connect (item,
"signal::property-notify::seqid", proxy_store_item_property_notify, ps,
"signal::property-notify::uname", proxy_store_item_property_notify, ps,
"signal::property-notify::blurb", proxy_store_item_property_notify, ps,
NULL);
Expand All @@ -225,6 +229,7 @@ proxy_store_item_unlisten_on (ProxyStore *ps,
SfiProxy item,
gint row)
{
ps->item_s_map.erase (item); // disconnect
bse_proxy_disconnect (item,
"any_signal", proxy_store_item_property_notify, ps,
NULL);
Expand Down
3 changes: 2 additions & 1 deletion bse/bseapi.idl
Expand Up @@ -697,7 +697,8 @@ interface Item : Object {
bool internal (); ///< Check whether an item is internal, i.e. owned by another non-internal item.
bool editable_property (String property); ///< Test whether a property is editable according to object state and property options.
PropertyCandidates get_property_candidates (String property_name); ///< Retrieve tentative values for an item or item sequence property.
// int32 seqid = Range ("Sequential ID", "", ":readwrite", 0, MAXINT31, 1);

int32 seqid = Range ("Sequential ID", "", "r", 0, MAXINT31, 1, 0);
};

/// Part specific note event representation.
Expand Down
71 changes: 16 additions & 55 deletions bse/bseitem.cc
Expand Up @@ -11,25 +11,11 @@
#include <gobject/gvaluecollector.h>
#include <string.h>

enum {
PROP_0,
PROP_SEQID,
};


/* --- prototypes --- */
static void bse_item_class_init_base (BseItemClass *klass);
static void bse_item_class_finalize_base (BseItemClass *klass);
static void bse_item_class_init (BseItemClass *klass);
static void bse_item_init (BseItem *item);
static void bse_item_set_property_internal (GObject *object,
uint param_id,
const GValue *value,
GParamSpec *pspec);
static void bse_item_get_property_internal (GObject *object,
uint param_id,
GValue *value,
GParamSpec *pspec);
static void bse_item_update_state (BseItem *self);
static gboolean bse_item_real_needs_storage (BseItem *self,
BseStorage *storage);
Expand Down Expand Up @@ -93,8 +79,6 @@ bse_item_class_init (BseItemClass *klass)

parent_class = (GTypeClass*) g_type_class_peek_parent (klass);

gobject_class->get_property = bse_item_get_property_internal;
gobject_class->set_property = bse_item_set_property_internal;
gobject_class->dispose = bse_item_do_dispose;
gobject_class->finalize = bse_item_do_finalize;

Expand All @@ -104,11 +88,6 @@ bse_item_class_init (BseItemClass *klass)
klass->get_seqid = bse_item_do_get_seqid;
klass->get_undo = bse_item_default_get_undo;
klass->needs_storage = bse_item_real_needs_storage;

bse_object_class_add_param (object_class, NULL,
PROP_SEQID,
sfi_pspec_int ("seqid", "Sequential ID", NULL,
0, 0, SFI_MAXINT, 1, "r"));
}

static void
Expand All @@ -117,39 +96,6 @@ bse_item_init (BseItem *item)
item->parent = NULL;
}

static void
bse_item_set_property_internal (GObject *object,
uint param_id,
const GValue *value,
GParamSpec *pspec)
{
// BseItem *self = BSE_ITEM (object);
switch (param_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}

static void
bse_item_get_property_internal (GObject *object,
uint param_id,
GValue *value,
GParamSpec *pspec)
{
BseItem *self = BSE_ITEM (object);
switch (param_id)
{
case PROP_SEQID:
sfi_value_set_int (value, bse_item_get_seqid (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}

static void
bse_item_do_dispose (GObject *gobject)
{
Expand Down Expand Up @@ -468,7 +414,8 @@ idle_handler_seqid_changed (void *data)
while (item_seqid_changed_queue)
{
BseItem *item = (BseItem*) g_slist_pop_head (&item_seqid_changed_queue);
g_object_notify (G_OBJECT (item), "seqid");
auto impl = item->as<Bse::ItemImpl*>();
impl->notify ("seqid");
}

BSE_THREADS_LEAVE ();
Expand Down Expand Up @@ -1272,6 +1219,20 @@ ItemImpl::get_property_candidates (const String &property_name)
return PropertyCandidates();
}

int
ItemImpl::seqid() const
{
BseItem *self = const_cast<ItemImpl*> (this)->as<BseItem*>();

return bse_item_get_seqid (self);
}

void
ItemImpl::seqid (int val)
{
assert_return_unreached(); // readonly property
}

bool
ItemImpl::constrain_idl_enum (int64_t &i, const StringVector &kvlist)
{
Expand Down
2 changes: 2 additions & 0 deletions bse/bseitem.hh
Expand Up @@ -163,6 +163,8 @@ public:
virtual String get_name_or_type () override;
virtual bool internal () override;
virtual PropertyCandidates get_property_candidates (const String &property_name) override;
virtual int seqid () const override;
virtual void seqid (int val) override;
/// Save the value of @a property_name onto the undo stack.
void push_property_undo (const String &property_name);
/// Push an undo @a function onto the undo stack, the @a self argument to @a function must match @a this.
Expand Down

0 comments on commit a48588c

Please sign in to comment.