diff options
Diffstat (limited to 'ganv')
-rw-r--r-- | ganv/Canvas.hpp | 16 | ||||
-rw-r--r-- | ganv/Item.hpp | 3 | ||||
-rw-r--r-- | ganv/canvas.h | 33 | ||||
-rw-r--r-- | ganv/item.h | 4 | ||||
-rw-r--r-- | ganv/wrap.hpp | 9 |
5 files changed, 59 insertions, 6 deletions
diff --git a/ganv/Canvas.hpp b/ganv/Canvas.hpp index e22c691..46c2d5e 100644 --- a/ganv/Canvas.hpp +++ b/ganv/Canvas.hpp @@ -25,8 +25,6 @@ #include "ganv/canvas.h" #include "ganv/wrap.hpp" -GANV_GLIB_WRAP(Canvas) - /** Ganv namespace, everything is defined under this. * * @ingroup Ganv @@ -121,6 +119,10 @@ public: RW_PROPERTY(double, height) RW_PROPERTY(GanvDirection, direction); + void set_port_order(GanvPortOrderFunc port_cmp, void* data) { + ganv_canvas_set_port_order(gobj(), port_cmp, data); + } + Gtk::Layout& widget() { return *Glib::wrap(&_gobj->layout); } @@ -143,4 +145,14 @@ private: } // namespace Ganv +namespace Glib { + +static inline Ganv::Canvas* +wrap(GanvCanvas* canvas) +{ + return (Ganv::Canvas*)ganv_canvas_get_wrapper(canvas); +} + +} // namespace Glib + #endif // GANV_CANVAS_HPP diff --git a/ganv/Item.hpp b/ganv/Item.hpp index fb2667d..a2dbadc 100644 --- a/ganv/Item.hpp +++ b/ganv/Item.hpp @@ -40,9 +40,8 @@ public: Item(GanvItem* gobj) : _gobj(gobj) { - GQuark wrapper_key = g_quark_from_string("ganvmm"); + ganv_item_set_wrapper(gobj, this); if (gobj && ganv_item_get_parent(gobj)) { - g_object_set_qdata(G_OBJECT(_gobj), wrapper_key, this); g_signal_connect( G_OBJECT(_gobj), "event", G_CALLBACK(on_item_event), this); } diff --git a/ganv/canvas.h b/ganv/canvas.h index e923f65..e2a9867 100644 --- a/ganv/canvas.h +++ b/ganv/canvas.h @@ -91,6 +91,8 @@ typedef void (*GanvEdgeFunc)(GanvEdge* edge, void* data); */ typedef void (*GanvNodeFunc)(GanvNode* node, void* data); +typedef int (*GanvPortOrderFunc)(const GanvPort*, const GanvPort*, void* data); + /** * ganv_canvas_new: * @@ -100,6 +102,22 @@ GanvCanvas* ganv_canvas_new(double width, double height); /** + * ganv_canvas_set_wrapper: + * + * Set the opaque wrapper object for the canvas. + */ +void +ganv_canvas_set_wrapper(GanvCanvas* canvas, void* wrapper); + +/** + * ganv_canvas_get_wrapper: + * + * Return an opaque pointer to the wrapper for the canvas. + */ +void* +ganv_canvas_get_wrapper(GanvCanvas* canvas); + +/** * ganv_canvas_clear: * * Remove all items from the canvas. @@ -592,6 +610,21 @@ ganv_canvas_get_move_cursor(const GanvCanvas* canvas); void ganv_canvas_move_contents_to(GanvCanvas* canvas, double x, double y); +/** + * ganv_canvas_set_port_order: + * @canvas The canvas to set the default port order on. + * @port_cmp Port comparison function. + * @data Data to be passed to order. + * + * Set a comparator function to use as the default order for ports on modules. + * If left unset, ports are shown in the order they are added. + */ +void +ganv_canvas_set_port_order(GanvCanvas* canvas, + GanvPortOrderFunc port_cmp, + void* data); + + G_END_DECLS #endif /* GANV_CANVAS_H */ diff --git a/ganv/item.h b/ganv/item.h index d6e9cc5..c538e5a 100644 --- a/ganv/item.h +++ b/ganv/item.h @@ -175,6 +175,10 @@ void ganv_item_get_bounds(GanvItem* item, void ganv_item_request_update(GanvItem* item); +void ganv_item_set_wrapper(GanvItem* item, void* wrapper); + +void* ganv_item_get_wrapper(GanvItem* item); + G_END_DECLS #endif /* GANV_ITEM_H */ diff --git a/ganv/wrap.hpp b/ganv/wrap.hpp index f907dea..c444e00 100644 --- a/ganv/wrap.hpp +++ b/ganv/wrap.hpp @@ -115,12 +115,17 @@ private: \ wrap(Ganv##Name* gobj) \ { \ if (gobj) { \ - GQuark key = g_quark_from_string("ganvmm"); \ - return (Ganv::Name*)g_object_get_qdata(G_OBJECT(gobj), key); \ + return (Ganv::Name*)ganv_item_get_wrapper(GANV_ITEM(gobj)); \ } else { \ return NULL; \ } \ } \ + /** Return a Ganv::CPPType wrapper for a CType. */ \ + static inline const Ganv::Name* \ + wrap(const Ganv##Name* gobj) \ + { \ + return wrap((Ganv##Name*)gobj); \ + } \ } #endif // GANV_WRAP_HPP |