garetxe on master
Update version of Ubuntu for gi… (compare)
garetxe on master
Turn cabal.project into a symli… (compare)
garetxe on master
Turn cabal.project into a symli… (compare)
garetxe on master
Add Freetype2 bindings, require… Add bindings for GStreamer Edit… (compare)
garetxe on master
Add support for GValue elements… (compare)
So my question is if every newX method can be replicated with new and attributes.
Ah, I see, thanks for the explanation. (Cool approach!) I hesitate to say that all widgets can be created in this way (I cannot think of an exception now, but I'm not sure), but this certainly seems to be the direction of travel.
I tried the following and it worked !
adjustment <- new Adjustment [#value := 0.0, #lower := 0.0, #upper := 51, #stepIncrement := 0.1, #pageIncrement := 1.0, #pageSize := 1.0]
scale <- new Scale [ #orientation := OrientationVertical, #adjustment := adjustment]
So that means that every "xNew" method has corresponding attributes that are generated automatically with the same name as the name given to the function "xNew"'s arguments in the documentation ?
I tried the following and it worked !
Great :)
So that means that every "xNew" method has corresponding attributes that are generated automatically with the same name as the name given to the function "xNew"'s arguments in the documentation ?
It is not automatic, unfortunately, the writer of the C code has to make sure that the relevant arguments are exposes as GObject properties. But in practice, in Gtk at least, it seems to almost always be the case, and all the different constructors are just convenience wrappers over g_object_new
, setting the properties. Something like what you see in gtk_button_new_with_label
.
new
with attributes in haskell-gi
.
gtk_message_dialog_new
is doing internally, you can check here.
gtk_message_dialog_new
is not in the bindings is because it accepts a variable number of arguments, and we don't bind such functions.)
Nothing
if no such data exists”nullPtr
if no data exists?
gtk-doc
-> haddock
translator uses a number of heuristics to improve the Haskell side docs, one of which is replacing NULL
by Nothing
. This is almost always the right thing to do, since nullable arguments on the C side are mapped to Maybe
arguments. But this is indeed wrong for objectGetData
.
resolveAttr
, for example by doing the following inside cabal repl
for your project::set -XTypeApplications
:set -XOverloadedLabels
import qualified GI.Gtk as Gtk
import Data.GI.Base.Attributes (resolveAttr)
resolveAttr (undefined :: Gtk.Stack) #transitionType
also things like new Gtk.Box [#orientation := Gtk.OrientationHorizontal] how is new defined? is it a function? if so why isn't it prefixed with something?
new
comes from Data.GI.Base: https://hackage.haskell.org/package/haskell-gi-base/docs/Data-GI-Base.html#v:new
setSourceRGBA 0.0 0.0 0.0 0.0
withTargetSurface $ \surface -> do
liftIO $ withSurface surface $ \ptr -> do
newPtr <- return (castPtr ptr) :: IO (Ptr Cairo.Surface)
surf <- newManagedPtr newPtr (return ())
region <- Gdk.cairoRegionCreateFromSurface (Cairo.Surface surf)
Gtk.widgetShapeCombineRegion widget (Just region)
GI/HarfBuzz/Functions.hs:1772:1: error:
Could not find module ‘GI.Freetype2.Structs.Face’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
1772 | import qualified GI.Freetype2.Structs.Face as Freetype2.Face
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Failed to build gi-harfbuzz-0.0.5 (which is required by
CookieCalculator-0.1.0.0). See the build log above for details.