Re: [Vala] Use alpha in GtkColorButton in GTK3 with Vala



On Sat, 2013-06-01 at 22:27 +0200, Jonas Kulla wrote:
2013/6/1 Satyajit Sahoo <satyajit happy gmail com>

I want to use an alpha value in the color buttons in my app -
https://github.com/satya164/elegance-colors

Currently I'm using colorbutton.set_use_alpha (true);, as documented in
http://www.valadoc.org/#!api=gtk+-3.0/Gtk.ColorButton

But, while compiling, I get warnings saying,

/home/satya/Workspace/elegance-colors/elegance-colors-prefs.vala.c:4706:2:
warning: ‘gtk_color_button_set_use_alpha’ is deprecated (declared at
/usr/include/gtk-3.0/gtk/gtkcolorbutton.h:95): Use
'gtk_color_chooser_set_use_alpha' instead [-Wdeprecated-declarations]

The code samples in the valadoc website are outdated and the sample on
gnome's website doesn't use alpha. Can anyone help me fix the warning
messages?

I'm using GTK 3.8 and Vala 0.20.1.

Hi,

looking at the documentation, it seems that the "use-alpha" property
was moved out of ColorButton (and probably other color widgets)
and unified in the ColorChooser interface, but left in those concrete
classes for backwards compatibility. The problem I think is that
when you do "myButton.set_use_alpha()" valac cannot know if you
mean ColorButton::set_use_alpha or ColorChooser::set_use_alpha
and just defaults to the former.

Normally I would tell you to just ignore warnings that gcc spits out
(as there are others caused by bugs in valac), but if you really want
them gone you could remove all the use-alpha related calls from
the ColorButton class in the gtk3 vapi (although others compiling
your project would still get them).

You can cast to Gtk.ColorChooser:

  ((Gtk.ColorChooser) myButton).set_use_alpha (true);

Unfortunately, we can't really "fix" the bindings right now since
removing Gtk.ColorButton.set_use_alpha means that the bindings stop
working for older versions of GTK+.

At some point we may be able to mostly resolve this in valac (after
switching GTK+ to GIR and once Florian's recent work on the [Version]
attribute lands) by introducing a flag to remove deprecated items from
the tree when targeting a newer version of the library.


-Evan



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