/* Returns the extents of the item, in pixels relative to the main canvas window. */ static void goo_canvas_item_accessible_get_item_extents (GooCanvasItem *item, GdkRectangle *rect) { GooCanvas *canvas; GooCanvasBounds bounds; canvas = goo_canvas_item_get_canvas (item); if (!canvas) { rect->x = rect->y = rect->width = rect->height = 0; return; } /* Get the bounds in device units. */ goo_canvas_item_get_bounds (item, &bounds); /* Static items are in pixels so don't need converting. */ if (!goo_canvas_item_get_is_static (item)) { /* Convert to pixels within the entire canvas. */ goo_canvas_convert_to_pixels (canvas, &bounds.x1, &bounds.y1); goo_canvas_convert_to_pixels (canvas, &bounds.x2, &bounds.y2); /* Convert to pixels within the visible window. */ bounds.x1 -= canvas->hadjustment->value; bounds.y1 -= canvas->vadjustment->value; bounds.x2 -= canvas->hadjustment->value; bounds.y2 -= canvas->vadjustment->value; } /* Round up or down to integers. */ rect->x = floor (bounds.x1); rect->y = floor (bounds.y1); rect->width = ceil (bounds.x1) - rect->x; rect->height = ceil (bounds.y1) - rect->y; }
static void gst_editor_link_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GooCanvas * canvas; if ((object==NULL)||(!GST_IS_EDITOR_LINK(object))){ g_print("Warning: gst_editor_link_realize failed because citem %p is no gst_editor_link\n",object); return; } GstEditorLink *link = GST_EDITOR_LINK (object); gdouble d = 0.0, blah = 0.0; switch (prop_id) { case PROP_X: g_value_set_double (value, link->x); break; case PROP_Y: g_value_set_double (value, link->y); break; case PROP_X1: if (link->srcpad) { d = link->srcpad->width; canvas = goo_canvas_item_get_canvas (GOO_CANVAS_ITEM (link->srcpad)); goo_canvas_convert_from_item_space ( canvas, GOO_CANVAS_ITEM (link->srcpad), &d, &blah); if (canvas) goo_canvas_convert_to_pixels (canvas, &d, &blah); else g_print ( "fixme: Canvas Item (X2, srcpad) got no Canvas:%p, Pixels d: %f, " "blah: %f\n", canvas, d, blah); } else if (link->dragging) { d = link->x; } else { g_warning ("no src pad"); } g_value_set_double (value, d); break; case PROP_X2: if (link->sinkpad) { d = 0; canvas = goo_canvas_item_get_canvas (GOO_CANVAS_ITEM (link->sinkpad)); // g_print("Canvas:%p, Pixels d: %f, blah: %f\n",canvas, d,blah); goo_canvas_convert_from_item_space ( canvas, GOO_CANVAS_ITEM (link->sinkpad), &d, &blah); // FIXME: Segfaults here // g_print("Canvas:%p, Pixels d: %f, blah: %f\n",canvas, d,blah); if (canvas) goo_canvas_convert_to_pixels (canvas, &d, &blah); else { g_print ( "fixme: Canvas Item (X2, sinkpad) got no Canvas:%p, Pixels d: " "%f, blah: %f\n", canvas, d, blah); d = d + 5; } // g_print("Canvas:%p, Pixels d: %f, blah: %f\n",canvas, d,blah); } else if (link->dragging) { d = link->x; } else { g_warning ("no sink pad"); } g_value_set_double (value, d); break; case PROP_Y1: if (link->srcpad) { d = link->srcpad->height / 2; canvas = goo_canvas_item_get_canvas (GOO_CANVAS_ITEM (link->srcpad)); goo_canvas_convert_from_item_space ( canvas, GOO_CANVAS_ITEM (link->srcpad), &blah, &d); if (canvas) goo_canvas_convert_to_pixels (canvas, &blah, &d); else g_print ( "fixme: Canvas Item (Y1, srcpad) got no Canvas:%p, Pixels d: %f, " "blah: %f\n", canvas, d, blah); } else if (link->dragging) { d = link->y; } else { g_warning ("no src pad"); } g_value_set_double (value, d); break; case PROP_Y2: if (link->sinkpad) { d = link->sinkpad->height / 2; canvas = goo_canvas_item_get_canvas (GOO_CANVAS_ITEM (link->sinkpad)); goo_canvas_convert_from_item_space ( canvas, GOO_CANVAS_ITEM (link->sinkpad), &blah, &d); if (canvas) { goo_canvas_convert_to_pixels (canvas, &blah, &d); } else { g_print ( "fixme: Canvas Item (Y2, sinkpad) got no Canvas:%p, Pixels d: " "%f, blah: %f\n", canvas, d, blah); d = d + 5; } } else if (link->dragging) { d = link->y; } else { g_warning ("no sink pad"); } g_value_set_double (value, d); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }