From 43f43d5e73ba1c36199998bd90ea511efe0eac62 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 31 Jul 2016 18:02:55 -0400 Subject: Fix compilation with C++ --- src/Canvas.cpp | 2 +- src/boilerplate.h | 9 +++------ src/edge.c | 19 +++++++++++++++++-- src/item.c | 10 +++++----- src/module.c | 2 +- src/node.c | 4 +++- src/widget.c | 6 +++--- 7 files changed, 33 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Canvas.cpp b/src/Canvas.cpp index e31bc9d..de04f16 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -746,7 +746,7 @@ GanvCanvasImpl::layout_dot(const std::string& filename) agsafeset(e, (char*)"headport", (char*)ss.str().c_str(), (char*)""); } if (!ganv_edge_get_constraining(edge)) { - agsafeset(e, (char*)"constraint", "false", (char*)""); + agsafeset(e, (char*)"constraint", (char*)"false", (char*)""); } } else { std::cerr << "Unable to find graphviz node" << std::endl; diff --git a/src/boilerplate.h b/src/boilerplate.h index a6be001..17dd545 100644 --- a/src/boilerplate.h +++ b/src/boilerplate.h @@ -24,12 +24,9 @@ typedef gpointer gobject; #define SET_CASE(prop, type, field) \ case PROP_##prop: { \ const g##type tmp = g_value_get_##type(value); \ - if (field != tmp) { \ - field = tmp; \ - GanvItem* item = GANV_ITEM(object); \ - if (item->impl->canvas) { \ - ganv_item_request_update(item); \ - } \ + if ((field) != tmp) { \ + (field) = tmp; \ + ganv_item_request_update(GANV_ITEM(object)); \ } \ break; \ } diff --git a/src/edge.c b/src/edge.c index eab950c..c3584e1 100644 --- a/src/edge.c +++ b/src/edge.c @@ -110,13 +110,12 @@ ganv_edge_set_property(GObject* object, g_return_if_fail(object != NULL); g_return_if_fail(GANV_IS_EDGE(object)); + GanvItem* item = GANV_ITEM(object); GanvEdge* edge = GANV_EDGE(object); GanvEdgeImpl* impl = edge->impl; GanvEdgeCoords* coords = &impl->coords; switch (prop_id) { - SET_CASE(TAIL, object, impl->tail); - SET_CASE(HEAD, object, impl->head); SET_CASE(WIDTH, double, coords->width); SET_CASE(HANDLE_RADIUS, double, coords->handle_radius); SET_CASE(DASH_LENGTH, double, impl->dash_length); @@ -128,6 +127,22 @@ ganv_edge_set_property(GObject* object, SET_CASE(SELECTED, boolean, impl->selected); SET_CASE(HIGHLIGHTED, boolean, impl->highlighted); SET_CASE(GHOST, boolean, impl->ghost); + case PROP_TAIL: { + const gobject tmp = g_value_get_object(value); + if (impl->tail != tmp) { + impl->tail = GANV_NODE(tmp); + ganv_item_request_update(item); + } + break; + } + case PROP_HEAD: { + const gobject tmp = g_value_get_object(value); + if (impl->head != tmp) { + impl->head = GANV_NODE(tmp); + ganv_item_request_update(item); + } + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; diff --git a/src/item.c b/src/item.c index d645e23..ddb38af 100644 --- a/src/item.c +++ b/src/item.c @@ -42,7 +42,7 @@ enum { GANV_CANVAS_UPDATE_REQUESTED = 1 << 0, GANV_CANVAS_UPDATE_AFFINE = 1 << 1, - GANV_CANVAS_UPDATE_VISIBILITY = 1 << 2, + GANV_CANVAS_UPDATE_VISIBILITY = 1 << 2 }; #define GCI_UPDATE_MASK (GANV_CANVAS_UPDATE_REQUESTED \ @@ -662,7 +662,7 @@ ganv_item_class_init(GanvItemClass* klass) (gobject_class, ITEM_PROP_PARENT, g_param_spec_object("parent", NULL, NULL, GANV_TYPE_ITEM, - (G_PARAM_READABLE | G_PARAM_WRITABLE))); + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE))); g_object_class_install_property (gobject_class, ITEM_PROP_X, @@ -670,14 +670,14 @@ ganv_item_class_init(GanvItemClass* klass) _("X"), _("X"), -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, - (G_PARAM_READABLE | G_PARAM_WRITABLE))); + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE))); g_object_class_install_property (gobject_class, ITEM_PROP_Y, g_param_spec_double("y", _("Y"), _("Y"), -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, - (G_PARAM_READABLE | G_PARAM_WRITABLE))); + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE))); g_object_class_install_property (gobject_class, ITEM_PROP_MANAGED, @@ -685,7 +685,7 @@ ganv_item_class_init(GanvItemClass* klass) _("Managed"), _("Whether the item is managed by its parent"), 0, - (G_PARAM_READABLE | G_PARAM_WRITABLE))); + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE))); item_signals[ITEM_EVENT] = g_signal_new("event", diff --git a/src/module.c b/src/module.c index 44e4b53..0094663 100644 --- a/src/module.c +++ b/src/module.c @@ -43,7 +43,7 @@ G_DEFINE_TYPE(GanvModule, ganv_module, GANV_TYPE_BOX) static GanvBoxClass* parent_class; enum { - PROP_0, + PROP_0 }; static void diff --git a/src/node.c b/src/node.c index 6309f97..2cbeda3 100644 --- a/src/node.c +++ b/src/node.c @@ -154,7 +154,6 @@ ganv_node_set_property(GObject* object, GanvNodeImpl* impl = node->impl; switch (prop_id) { - SET_CASE(PARTNER, object, impl->partner); SET_CASE(DASH_LENGTH, double, impl->dash_length); SET_CASE(DASH_OFFSET, double, impl->dash_offset); SET_CASE(BORDER_WIDTH, double, impl->border_width); @@ -166,6 +165,9 @@ ganv_node_set_property(GObject* object, SET_CASE(HIGHLIGHTED, boolean, impl->highlighted); SET_CASE(DRAGGABLE, boolean, impl->draggable); SET_CASE(GRABBED, boolean, impl->grabbed); + case PROP_PARTNER: + impl->partner = (GanvNode*)g_value_get_object(value); + break; case PROP_SELECTED: if (impl->selected != g_value_get_boolean(value)) { GanvItem* item = GANV_ITEM(object); diff --git a/src/widget.c b/src/widget.c index 0702ca5..9af767d 100644 --- a/src/widget.c +++ b/src/widget.c @@ -218,7 +218,7 @@ ganv_widget_set_property(GObject* object, case PROP_ANCHOR: if (witem->impl->anchor != (GtkAnchorType)g_value_get_enum(value)) { - witem->impl->anchor = g_value_get_enum(value); + witem->impl->anchor = (GtkAnchorType)g_value_get_enum(value); update = TRUE; } break; @@ -436,7 +436,7 @@ ganv_widget_class_init(GanvWidgetClass* klass) GtkObjectClass* object_class = (GtkObjectClass*)klass; GanvItemClass* item_class = (GanvItemClass*)klass; - parent_class = g_type_class_peek_parent(klass); + parent_class = (GanvItemClass*)g_type_class_peek_parent(klass); g_type_class_add_private(klass, sizeof(GanvWidgetImpl)); @@ -448,7 +448,7 @@ ganv_widget_class_init(GanvWidgetClass* klass) "widget", _("Widget"), _("The widget to embed in this item."), GTK_TYPE_WIDGET, - (G_PARAM_READABLE | G_PARAM_WRITABLE))); + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE))); g_object_class_install_property( gobject_class, PROP_X, g_param_spec_double( -- cgit v1.2.1