After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 601221 - Gtk.Widget's can_focus binding is broken with vala-0.7.8
Gtk.Widget's can_focus binding is broken with vala-0.7.8
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings: GTK+ GStreamer WebKitGTK+
0.7.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-11-09 08:14 UTC by shuerhaaken
Modified: 2009-11-13 18:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (430 bytes, patch)
2009-11-09 08:14 UTC, shuerhaaken
none Details | Review
Working test case (302 bytes, text/plain)
2009-11-13 17:36 UTC, Evan Nemerson
  Details

Description shuerhaaken 2009-11-09 08:14:00 UTC
Created attachment 147249 [details] [review]
patch

Hello

When I updated to vala-0.7.8 my app stopped compiling the *_can_focus(bool a)
function in a button. This is a function inherited from Gtk.Widget.

I attached a patch to this bug report that fixes the problem in the vapi only. 

Regards
Jörn Magens
Comment 1 shuerhaaken 2009-11-09 22:20:09 UTC
Of course it is a property *.can_focus = true/false. But still, the patch is working.
Comment 2 Evan Nemerson 2009-11-13 08:05:32 UTC
I'm having trouble reproducing this—would you mind attaching a test case? I've tried var btn = new Gtk.Button (); btn.set_can_focus (false); and it seems to work. Maybe I'm misunderstanding the problem.

Thanks.
Comment 3 shuerhaaken 2009-11-13 08:18:43 UTC
Hi Evan

It's not the method "set_can_focus", but the property or public field "can_focus".

This is why I added my comment. 
The original bug report was a little misleading. Please have a look at the patch and you will see.

Thanks and Regards
Jörn Magens
Comment 4 shuerhaaken 2009-11-13 17:31:52 UTC
Ok, more details:

The following code (snippet):

public class VolumeSliderButton : Gtk.VolumeButton {
	public VolumeSliderButton() { // in the constructor
		this.can_focus = false;
	}
}

------------------------

leads to this:

xnoise-main-window.o: In function `xnoise_main_window_volume_slider_button_construct':
/home/xyz/xnoise/src/xnoise/xnoise-main-window.c:2920: undefined reference to `gtk_widget_set_can_focus'
collect2: ld returned 1 exit status
....

------------------------

The generated ccode is (snippet):

XnoiseMainWindowVolumeSliderButton* xnoise_main_window_volume_slider_button_construct (GType object_type) {
	XnoiseMainWindowVolumeSliderButton * self;
	...
	gtk_widget_set_can_focus ((GtkWidget*) self, FALSE);
	...
	return self;
}

------------------------

but it should be:

XnoiseMainWindowVolumeSliderButton* xnoise_main_window_volume_slider_button_construct (GType object_type) {
	XnoiseMainWindowVolumeSliderButton * self;
	...
	g_object_set ((GtkWidget*) self, "can-focus", FALSE, NULL);
	...
	return self;
}

The patch contains the [NoAccessorMethod] annotation for the property
public bool can_focus { get; set; }. 

Thanks and Regards
Jörn
Comment 5 Evan Nemerson 2009-11-13 17:36:02 UTC
Created attachment 147682 [details]
Working test case

Sorry, I should have mentioned in my previous comments that I tried that as well, and all seems well. Here is the test I was using, which works for me.

That btn.can_focus = true; compiles to gtk_widget_set_can_focus ((GtkWidget*) btn, TRUE);
Comment 6 Evan Nemerson 2009-11-13 17:43:16 UTC
Jörn, ah, thanks. Looks like you replied before I hit submit :)

gtk_widget_set_can_focus is works on my system--that test case output the following:

** (601221:15316): DEBUG: 601221.vala:6: get_can_focus() = false
** (601221:15316): DEBUG: 601221.vala:8: can_focus = true

What version of gtk+ are you using? Mine is 2.18.3. I'll investigate and try and figure out when it was added.
Comment 7 shuerhaaken 2009-11-13 18:07:08 UTC
Hi Evan
I use still 2.16.1 (Ubuntu Jaunty). It worked until I upgraded from vala-0.7.7 to vala-0.7.8.
Is this because vapi files should be distributed with their according version of librarie they belong to? 
If so, there is probably no fix but upgrading to a more recent distribution, is it?
Regards
Jörn
Comment 8 Evan Nemerson 2009-11-13 18:37:58 UTC
Yes, the GTK+ bindings were upgraded to 2.18 during the 0.7.8 development process, but you don't need to upgrade GTK+ to use them. I've gone ahead with your patch (actually, I edited the metadata file to generate the same change your patch made). The difference is transparent to vala users, so it's not a big deal to preserve compatibility here--it will just generate slightly less nice code than it could. Obviously you won't be able to make use of the new GTK+ 2.18 features, but hopefully the new bindings will continue to be useful to 2.16, and maybe even 2.14, users. Thanks for your patience regarding this bug.
Comment 9 Evan Nemerson 2009-11-13 18:38:22 UTC
commit 95889a88390af5e084bbf2330fe0d9a74c2e22ee
Author: Evan Nemerson <evan@coeus-group.com>
Date:   Fri Nov 13 10:25:42 2009 -0800

    gtk+-2.0: Mark Gtk.Widget.can_focus as not having an accessor method,
    to preserve compatibility with GTK+ < 2.18.
    
    Fixes bug 601221.