Re: [Vala] How to override a "class closure for a signal"?

2016-07-28 Thread Michael Gratton


Hi Guillaume,

On Thu, Jul 28, 2016 at 9:02 PM, Guillaume Poirier-Morency 
 wrote:

When you override a virtual signal, you only override its default
handler, so you don't specify 'signal' in the new method:


Thanks for that, so it seems the first approach I suggested was the 
right one. I'll keep on digging.


So is GObject polymorphism is actually implemented using signals? I 
thought the chaining foo_class structs that happens would have been 
good enough?


//Mike

--
⊨ Michael Gratton, Percept Wrangler.
⚙ 


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] How to override a "class closure for a signal"?

2016-07-28 Thread Guillaume Poirier-Morency
When you override a virtual signal, you only override its default
handler, so you don't specify 'signal' in the new method:

public class MyListBox : Gtk.ListBox
{
    public override void set_focus_child (Widget? widget)
    {
        // override default handler here
    }
}

Not sure here, but I think that if you define a signal without a
default handler, it is not possible to override it as it does not
exist.

There's also mechanism to stop signals from bubbling in GObject if that
can help you: http://www.valadate.org:8000/#!api=gobject-2.0/GLib.Signa
l However, I don't know how to fetch the signal id from Vala.

Le jeudi 28 juillet 2016 à 18:22 +1000, Michael Gratton a écrit :
> Hey all,
> 
> I have a subclass of Gtk.ListBox and I'm trying to override 
> Gtk.Container::gtk_container_set_focus_child on it to prevent its 
> default behaviour of automatically scrolling to the new focus child. 
> The docs for that method say this:
> 
> > 
> > This function emits the GtkContainer::set_focus_child signal of 
> > container. Implementations of GtkContainer can override the
> > default 
> > behaviour by overriding the class closure of this signal.
> 
> How exactly do I do that? I tried overriding the method using:
> 
> > 
> > public override void set_focus_child(Gtk.Widget? child) { ... }
> 
> But even if I do not chain up using a call to 
> "base.set_focus_child(child)", it seems Gtk.Container's method is
> still 
> invoked.
> 
> I also tried overriding the signal body using variously:
> 
> > 
> > public override signal void set_focus_child(Gtk.Widget? child) {
> > ... }
> > public new signal void set_focus_child(Gtk.Widget? child) { ... }
> 
> But then valac complains that it "hides inherited signal" in the
> first 
> case and "Only virtual signals can have a default signal handler
> body" 
> for both.
> 
> Any hints? Thanks!
> 
> //Mike
> 
-- 
Guillaume Poirier-Morency 

Étudiant au baccalauréat en Informatique à l'Université de Montréal
Développeur d'application web

Mon blog: https://arteymix.github.io/
Mon projet de coopérative: https://pittoresque.github.io/
Clé PGP: B1AD6EA5

signature.asc
Description: This is a digitally signed message part
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


[Vala] How to override a "class closure for a signal"?

2016-07-28 Thread Michael Gratton


Hey all,

I have a subclass of Gtk.ListBox and I'm trying to override 
Gtk.Container::gtk_container_set_focus_child on it to prevent its 
default behaviour of automatically scrolling to the new focus child. 
The docs for that method say this:


This function emits the GtkContainer::set_focus_child signal of 
container. Implementations of GtkContainer can override the default 
behaviour by overriding the class closure of this signal.


How exactly do I do that? I tried overriding the method using:


public override void set_focus_child(Gtk.Widget? child) { ... }


But even if I do not chain up using a call to 
"base.set_focus_child(child)", it seems Gtk.Container's method is still 
invoked.


I also tried overriding the signal body using variously:


public override signal void set_focus_child(Gtk.Widget? child) { ... }
public new signal void set_focus_child(Gtk.Widget? child) { ... }


But then valac complains that it "hides inherited signal" in the first 
case and "Only virtual signals can have a default signal handler body" 
for both.


Any hints? Thanks!

//Mike

--
⊨ Michael Gratton, Percept Wrangler.
⚙ 


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list