Giter Site home page Giter Site logo

Composite Controls about gtk.jl HOT 5 CLOSED

juliagraphics avatar juliagraphics commented on July 20, 2024
Composite Controls

from gtk.jl.

Comments (5)

vtjnash avatar vtjnash commented on July 20, 2024

On my phone so I'll be short:
This is like Canvas. Should it be wrapper or subtype. I think direct subtype so that convert is indempotent. Known need to fix methods in Gtk.jl anyways

from gtk.jl.

tknopp avatar tknopp commented on July 20, 2024

Not sure that I can follow you here. If MyType subtypes from GtkWidgetI doesent it than require to have a handle field? We could of course follow the following sheme

type MyWidget <: GtkWidgetI
    handle::Ptr{GObject}
    btn::GtkButton
end
function MyWidget(label)
    btn = GtkButton(label)
    MyWidget(btn.handle, btn)
end   

from gtk.jl.

vtjnash avatar vtjnash commented on July 20, 2024

the btn field would not be necessary. I would add a function called reinherit which transfers ownership of a handle from one Julia object to another and destroys the old reference object. Thus the MyWidget constructor would look something like:

type MyWidget <: Gtk.GtkButtonI
    handle::Ptr{Gtk.GObjectI}
    other_fields
function MyWidget(label)
  btn = GtkButton(label)
  Gtk.gc_move_ref(new(btn), btn)
end
end

where gc_move_ref is a function I just added to GLib:

function Gtk.gc_move_ref(old::GObjectI, new::GObjectI)
  @assert old.handle == new.handle != C_NULL
  Gtk.gc_unref(old) # destroys old, but does nothing to it's gc ref
  Gtk.gc_force_floating(new) # forced the gc ref in old to floating
  Gtk.gc_ref(new) # adopt the floating gc ref from old and return new
end

from gtk.jl.

tknopp avatar tknopp commented on July 20, 2024

@vtjnash: Like that! This should go into the documentation. The button was not the best example though. In practice one would subtype a container

from gtk.jl.

tknopp avatar tknopp commented on July 20, 2024

Great. Thanks for documenting this

from gtk.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.