Re: buildable_set_name



Johan Dahlin wrote:
amol wrote:
Hi,
When we do gtk_buildable_set/get_name for any object created through GtkBuilder, GtkBuildable does g_object_set/get_data to return the corresponding name of object if its set/get_name are not overridden. But GtkWidget overrides set/get_name of buildable interface and does gtk_widget_set/get_name. I may create GtkWidget through GtkBuilder and after that i may set widget name accordingly (to use different styles in different cases). But when i do gtk_buildable_get_name it returns me new name which was set through widget_set_name and not through buildable_set_name.

That is correct.
There's only one name for the object, it can be set and accessed either
by using the widget or the buildable accessors.

No one except GtkAction and GtkActionGroup seems to be using buildable set/get_name.

My doubt is - What is the intention for GtkWidget to override set/get functions of GtkBuildable interface.

The intention of introduction the set/get_name is to be able to name the widget so you can access the ids used in the ui designer in runtime.

I've used the names myself for ui testing frameworks (based upon gazpacho and libglade though), and I am sure there are other uses for them.

Can we get rid of it w/o affecting any Gtk applications.

It's a nice feature which are useful in some circumstances.
I'd really like to keep it.

Gtk+ don't have any idea about the custom Id's specified in ui file while object creation. What is achieved doing by gtk_widget_set_name with Id specified in ui file.(gtkrc and ui Creator must be always in sync for themes to be work correctly ) I am planning to get rid of overriding set/get_name of buildable in GtkWidget. Does it will have any adverse effect?

I don't quite understand how this is an issue.
Yes, objects created by a UI designer will be named.
Yes, you will have to keep your gtkrc files in sync with these names.

The problem you are having is that you have a theme depending on the name property of a widget when it shouldn't.

Quoting docs:

Widgets can be named, which allows you to refer to
them from a gtkrc file. You can apply a style to widgets
with a particular name in the gtkrc file. See the
documentation for gtkrc files (on the same page as
the docs for GtkRcStyle <cid:part1.03090701.06030004@tamu.edu>).

Use the class name instead, why is that not sufficient?

Because if you are changing style of one GtkTextView
widget, you don't want to change style of every GtkTextView
(and GtkSourceView, and FooTextView, etc.) widget in
the application. And let's not get started about tooltips
again.

It was brought up here already, and the decision (quite
silent) was that either you are using widget name as in
gtk_buildable_set_name, or you are using the name
for style business, or you're screwed.

Yevgen



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