Open nodrygo opened 4 years ago
resolved simply adding this in _src/libcairo.cr make things works correctly
struct Rectangle
x: Float64
y: Float64
width: Float64
height: Float64
end
Hey, sorry this took me so long to look at, but to be honest it also mixes a couple of things so it's a bit harder to look at. When I run gtk_sample.cr in Ubuntu, crystal-gobject use gir1.2-freedesktop for create cairo bindings in runtime. This bindings consists from lib LibCairo and module Cairo. LibCairo wraps "raw" C struct (for example LibCairo::Rectangle). module Cairo includes wrappers-classes for these struct : Context,Device etc. In my opinion, you need install gir1.2-freedesktop package.
Hi I have installed gir1.2-freedesktop package in Ubuntu 18.04.4
I still receive the error above, do I have do any thing else besides install and update, to create cairo bindings in runtime?
thank you for your help.
I have installed XUbuntu 19.10 You can check whether "compile-time" bindings run samples/save_binding.cr . Bindings will saved in samples/cairo_binding.cr. This is bindings from my computer:
@[Link("cairo-gobject")] lib LibCairo
###########################################
###########################################
struct Context # struct _data : UInt8[0] end
struct Device # struct _data : UInt8[0] end
struct Surface # struct _data : UInt8[0] end
struct Matrix # struct _data : UInt8[0] end
struct Pattern # struct _data : UInt8[0] end
struct Region # struct _data : UInt8[0] end
struct FontOptions # struct _data : UInt8[0] end
struct FontFace # struct _data : UInt8[0] end
struct ScaledFont # struct _data : UInt8[0] end
struct Path # struct _data : UInt8[0] end
struct Rectangle # struct x : Float64 y : Float64 width : Float64 height : Float64 end
struct RectangleInt # struct x : Int32 y : Int32 width : Int32 height : Int32 end
###########################################
###########################################
alias Status = UInt32
alias Content = UInt32
alias Operator = UInt32
alias Antialias = UInt32
alias FillRule = UInt32
alias LineCap = UInt32
alias LineJoin = UInt32
alias TextClusterFlags = UInt32
alias FontSlant = UInt32
alias FontWeight = UInt32
alias SubpixelOrder = UInt32
alias HintStyle = UInt32
alias HintMetrics = UInt32
alias FontType = UInt32
alias PathDataType = UInt32
alias DeviceType = Int32
alias SurfaceType = UInt32
alias Format = Int32
alias PatternType = UInt32
alias Extend = UInt32
alias Filter = UInt32
alias RegionOverlap = UInt32
###########################################
###########################################
fun image_surface_create = cairo_image_surface_create() : Void end
module Cairo#
class Context include GObject::WrappedType
@pointer : Void*
def initialize(pointer : LibCairo::Context*)
@pointer = pointer.as(Void*)
end
def to_unsafe
@pointer.not_nil!.as(LibCairo::Context*)
end
end
class Device include GObject::WrappedType
@pointer : Void*
def initialize(pointer : LibCairo::Device*)
@pointer = pointer.as(Void*)
end
def to_unsafe
@pointer.not_nil!.as(LibCairo::Device*)
end
end
class Surface include GObject::WrappedType
@pointer : Void*
def initialize(pointer : LibCairo::Surface*)
@pointer = pointer.as(Void*)
end
def to_unsafe
@pointer.not_nil!.as(LibCairo::Surface*)
end
end
class Matrix include GObject::WrappedType
@pointer : Void*
def initialize(pointer : LibCairo::Matrix*)
@pointer = pointer.as(Void*)
end
def to_unsafe
@pointer.not_nil!.as(LibCairo::Matrix*)
end
end
class Pattern include GObject::WrappedType
@pointer : Void*
def initialize(pointer : LibCairo::Pattern*)
@pointer = pointer.as(Void*)
end
def to_unsafe
@pointer.not_nil!.as(LibCairo::Pattern*)
end
end
class Region include GObject::WrappedType
@pointer : Void*
def initialize(pointer : LibCairo::Region*)
@pointer = pointer.as(Void*)
end
def to_unsafe
@pointer.not_nil!.as(LibCairo::Region*)
end
end
enum Status : UInt32 ZERO_NONE = 0 SUCCESS = 0 NO_MEMORY = 1 INVALID_RESTORE = 2 INVALID_POP_GROUP = 3 NO_CURRENT_POINT = 4 INVALID_MATRIX = 5 INVALID_STATUS = 6 NULL_POINTER = 7 INVALID_STRING = 8 INVALID_PATH_DATA = 9 READ_ERROR = 10 WRITE_ERROR = 11 SURFACE_FINISHED = 12 SURFACE_TYPE_MISMATCH = 13 PATTERN_TYPE_MISMATCH = 14 INVALID_CONTENT = 15 INVALID_FORMAT = 16 INVALID_VISUAL = 17 FILE_NOT_FOUND = 18 INVALID_DASH = 19 INVALID_DSC_COMMENT = 20 INVALID_INDEX = 21 CLIP_NOT_REPRESENTABLE = 22 TEMP_FILE_ERROR = 23 INVALID_STRIDE = 24 FONT_TYPE_MISMATCH = 25 USER_FONT_IMMUTABLE = 26 USER_FONT_ERROR = 27 NEGATIVE_COUNT = 28 INVALID_CLUSTERS = 29 INVALID_SLANT = 30 INVALID_WEIGHT = 31 INVALID_SIZE = 32 USER_FONT_NOT_IMPLEMENTED = 33 DEVICE_TYPE_MISMATCH = 34 DEVICE_ERROR = 35 INVALID_MESH_CONSTRUCTION = 36 DEVICE_FINISHED = 37 JBIG2_GLOBAL_MISSING = 38 end
enum Content : UInt32 ZERO_NONE = 0 COLOR = 4096 ALPHA = 8192 COLOR_ALPHA = 12288 end
enum Operator : UInt32 ZERO_NONE = 0 CLEAR = 0 SOURCE = 1 OVER = 2 IN = 3 OUT = 4 ATOP = 5 DEST = 6 DEST_OVER = 7 DEST_IN = 8 DEST_OUT = 9 DEST_ATOP = 10 XOR = 11 ADD = 12 SATURATE = 13 MULTIPLY = 14 SCREEN = 15 OVERLAY = 16 DARKEN = 17 LIGHTEN = 18 COLOR_DODGE = 19 COLOR_BURN = 20 HARD_LIGHT = 21 SOFT_LIGHT = 22 DIFFERENCE = 23 EXCLUSION = 24 HSL_HUE = 25 HSL_SATURATION = 26 HSL_COLOR = 27 HSL_LUMINOSITY = 28 end
enum Antialias : UInt32 ZERO_NONE = 0 DEFAULT = 0 NONE = 1 GRAY = 2 SUBPIXEL = 3 FAST = 4 GOOD = 5 BEST = 6 end
enum FillRule : UInt32 ZERO_NONE = 0 WINDING = 0 EVEN_ODD = 1 end
enum LineCap : UInt32 ZERO_NONE = 0 BUTT = 0 ROUND = 1 SQUARE = 2 end
enum LineJoin : UInt32 ZERO_NONE = 0 MITER = 0 ROUND = 1 BEVEL = 2 end
enum TextClusterFlags : UInt32 ZERO_NONE = 0 BACKWARD = 1 end
enum FontSlant : UInt32 ZERO_NONE = 0 NORMAL = 0 ITALIC = 1 OBLIQUE = 2 end
enum FontWeight : UInt32 ZERO_NONE = 0 NORMAL = 0 BOLD = 1 end
enum SubpixelOrder : UInt32 ZERO_NONE = 0 DEFAULT = 0 RGB = 1 BGR = 2 VRGB = 3 VBGR = 4 end
enum HintStyle : UInt32 ZERO_NONE = 0 DEFAULT = 0 NONE = 1 SLIGHT = 2 MEDIUM = 3 FULL = 4 end
In my opinion, matter in different version "gir1.2-freedesktop" package for different version of Ubuntu. I added commented Rectangle structure definition in src/lib_cairo.cr file. Uncomment its definition (lines 7...12).
hello first of all thank for this great work
trying the sample _gtksample.cr I got this error
please note that crystal-gobject (another great work) samples work on my machine
is it a problem with my cairo release ? my env. is
thanks for help