Re: [Vala] Where is the sender widget in signal callback?



I posted too quickly. This code worked with valac 0.6.

The compiler show an error because 's' is a Gtk.Style, yet 's' is the first parameter, the sender, therefore is a Gtk.Button.

Here a sample code to reproduce the problem:

void main (string[] args)
{
  Gtk.Window window;
  Gtk.Button button;

  Gtk.init (ref args);

  window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
  window.show += (s) => {
    debug ("%s", s.get_type ().name ());
  };

  button = new Gtk.Button ();
  Gtk.RcStyle rcstyle = new Gtk.RcStyle ();
  rcstyle.xthickness = rcstyle.ythickness = 0;
  button.modify_style (rcstyle);

  button.style_set += (s) => {
    s.set_size_request (2, 2);
  };
  window.add (button);

  window.show_all ();

  Gtk.main ();
}

I solved the problem by adding the missing parameter:

  button.style_set += (s, style) => {
    s.set_size_request (2, 2);
  };

It's a bug or a feature?

2009/4/10 Feng Yu <rainwoodman gmail com>
s is the sender.
the parameters begin from the second.

On Thu, Apr 9, 2009 at 2:05 PM, gege2061 <gege2061 redaction-developpez com> wrote:
Hi,

I have updated valac to version 0.7 and I compile Valide.

I have an error:

libvalide/utils.vala:199.42-199.55: error: The name `get_settings' does not exist in the context of `Gtk.Style?'

http://code.google.com/p/valide/source/browse/trunk/libvalide/utils.vala#195

Where is the parameter 'sender'?

--
Nicolas Joseph

Responsable des rubriques C et GTK+ de developpez.com /
In charge of the C and GTK+ sections on developpez.com

http://nicolasj.developpez.com

_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list





--
Nicolas Joseph

Responsable des rubriques C et GTK+ de developpez.com /
In charge of the C and GTK+ sections on developpez.com

http://nicolasj.developpez.com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]