I struggled with this bug for a few hours, so I’m sharing it here.
With gtk 2.20, Gtk::Builder does NOT set the name property anymore.
I don’t really understand yet the diference between
gtk_widget_get_name and gtk_buildable_get_name, but for RG2, it means
you cannot anymore call #name to get the object id you set in glade,
if that object inherits from Gtk::Widget.
As a workaround, I wrote this in my code, since I have no use for
Gtk::Widget#name.
class Gtk::Widget
remove_method :name
end
I tried to find where in the code this method gets added to
Gtk::Widget, but I never found.
Le mercredi 07 avril 2010 à 10:50 +0200, Simon A. a écrit :
Hi
I struggled with this bug for a few hours, so I’m sharing it here.
With gtk 2.20, Gtk::Builder does NOT set the name property anymore.
I don’t really understand yet the diference between
gtk_widget_get_name and gtk_buildable_get_name, but for RG2, it means
you cannot anymore call #name to get the object id you set in glade,
if that object inherits from Gtk::Widget.
id should get exposed
Name of GtkWidget is mostly used for theming and does not have to be
unique
Name of GtkBuildable is its id, and should never have been setting the
name property imho
Name of GtkWidget is mostly used for theming and does not have to be
unique
I don’t use it at all, but that’s what I’ve seen while trying to solve
my problem.
Name of GtkBuildable is its id, and should never have been setting the
name property imho
I agree.
I don’t really like to keep “name” poiting to buildable name, hiding the
widget name but I’m not sure what would be right
It was just an experiment. I also think we should just get rid of
‘name’ in the builder.
‘id’ does not seems very smart. I would prefer ‘ui_id’ or ‘builder_id’.
I don’t like ‘glade_id’, since you can generate the xml with any tool.
Maybe create a struct/object for builder specific info. So you would
call widget.builder.id. Though, I’m not sure there is much info only
available for ‘built’ objects.
C does not have this issue as user as to explicitly call
gtk_buildable_get_name or gtk_widget_get_name…
Indeed, even if I think it’s not very smart to get the ‘id’ property
with ‘get_name’.
thanks for the tip, I spent a good couple of hours trying to
understand
what was going on before reading this thread
Will the method “builder_name” be present in the next release? I checked
out trunk and the fix isn’t there. I modified the source myself and
everything works fine but I’d be really nice to have users in the
position that they can just download and build the latest release
without tweaking the source.
thanks for the tip, I spent a good couple of hours trying to understand
what was going on before reading this thread
Will the method “builder_name” be present in the next release? I checked
out trunk and the fix isn’t there. I modified the source myself and
everything works fine but I’d be really nice to have users in the
position that they can just download and build the latest release
without tweaking the source.
It was just my opinion.
I’ve committed it now. You will be able to use
“builder_name” in the next release.
Thank for all your great work, kou, Simon and Andrea!
You guys have helped me again.
In this situation, it seems like setting the “name” property to the name
given in glade good because, the current “name” property in my program
always returns nil anyway. Also, because glade identifies this field in
their GUI as “Name.”
In [email protected]
“Re: [ruby-gnome2-devel-en] Gtk 2.20, Gtk::Builder and ‘name’” on Wed,
7 Apr 2010 12:10:06 +0200,
Simon A. [email protected] wrote:
‘id’ does not seems very smart. I would prefer ‘ui_id’ or ‘builder_id’.
with ‘get_name’.
What do you all think ?
I think this is a good solution because GTK+ 20.0 uses
‘builder name’ as key for it internally: