GNOME Bugzilla – Bug 733247
Enable widget id to be recognized as automatically generated
Last modified: 2018-03-26 15:39:27 UTC
Using the box model as a layout mechanism has the inconvenient effect of generating a lot of widgets to enable the developer of getting the desired layout. As a result UI description files can contain a lot of widgets. If you want to present the user with a list of relevant widgets the developer is likely to interact with in the application, we need a way to differentiate these widgets in the UI file. In the case the developer actually cares about a widget, he's very likely to give it a particular name, whereas unimportant widgets will be left untouch with the default generated id. The attached patch is a cheap way of recognizing widgets that the developer actually cares about, by prefixing the automatically generated names with '_'.
Created attachment 280829 [details] [review] GladeWidget: generate _ prefixed default names
Hi Lionel, I sympathize with the problem, to be honest what we really want is to remove the IDs completely in the case that they are not explicitly named by the user (and there is no internal reference to them), however this is a bit difficult to implement because either: a.) Glade needs either to be refactored so that there are no internal references by ID, and only by object references... OR, b.) As a potential hack around this problem, at least all widgets loaded in Glade need to be assigned an arbitrary ID until the file is saved and closed (i.e. they could be generated at load time and ommitted at save time in the case there is no reference to them _and_ the ID was not explicitly set by the user). The proposed hack outlined in 'b' is also not as obvious as it seems, at least it would probably require a 'preflight' parse which collects the IDs which were specified and avoids generating dynamic IDs which conflict with existing ones. I believe GtkBuilder already accepts input with missing IDs, and if not, I know that a patch which makes GtkBuilder parse such an input will be welcome as well. I'm not entirely sure about whether we should go with this patch, I will discuss it with Juan and perhaps we will go with your proposed solution until which time we can completely remove the irrelevent IDs from Glade.
Ok cool. To give a bit more of background, I intend to present a tool to write applications using kind of a visual paradigm at Guadec. I want to represent UI files entries as 'ports' on boxes on a canvas : https://i.imgur.com/rWpYdqV.png As I explained, because of the box model, there are a lot of widgets and that kind of crowd the box with useless port. So if you think you will have a better solution for the next release, go ahead with it, I'll just keep my patch for the demo.
GtkBuilder can do fine without id's indeed.
*** Bug 712575 has been marked as a duplicate of this bug. ***
This is essential for being able to edit gtk+'s own ui files.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glade/issues/169.