Discussion:
[Glade-devel] How glade should name new widgets
Marco Diego Aurélio Mesquita
2017-03-30 19:58:19 UTC
Permalink
Hi devs!

I've just created https://bugzilla.gnome.org/show_bug.cgi?id=780737 to
restore the old convention on the names of new widgets instead of
leaving them id-less by default. My idea behind this is that the old
behavior is generally good enough for many cases.

Also, I hope that soon glade will be integrated with gnome-builder and
having the old behavior is generally very good for rapid application
development.

Is there a good reason for leaving widget id-less that I'm not aware of?
_______________________________________________
Glade-devel maillist - Glade-***@lists.dot.net
http://lists.dot.net/mailman/listi
Marco Diego Aurélio Mesquita
2017-03-31 13:39:32 UTC
Permalink
On Fri, Mar 31, 2017 at 4:54 AM, Tristan Van Berkom
Rather, is there a reason I'm missing why one would desire to have the
project full of names, now that this is no longer a requirement ?
Integration with IDE's. If you try the latest glade version with
anjuta and drag-and-drops a signal on the source code (to create a
callback), the widget will come with the strange name __glade_unnamed;
this is strange and unintuitive. The same should happen if the user
double-clicks a widget on the inspector. It is very important for
widgets to have ID's set so that the automatic callback/member
generation will work correctly.

I do agree that ok_button is a much better name than button1, but the
user still can change its ID anyway, so it will not be a bigger effort
than with the current behavior.

Do you have any idea on how to properly ensure that widgets have ID's
before automatic callback/member generation? Should this be handled by
the IDE or by glade? Should a warning be displayed if the user tries
to drag-and-drop a signal (or double-clicks a widget on the inspector)
if the widget has no ID? Should automatic callback/member generation
be forbidden for id-less widgets? What do other interface builders do?

We have to list our options and decide which is better. What do you
think should be the adequate behavior?
_______________________________________________
Glade-devel maillist - Glade-***@lists.dot.net
http://lists.dot.
Marco Diego Aurélio Mesquita
2017-04-02 12:53:51 UTC
Permalink
Hi Tristan!

On Sun, Apr 2, 2017 at 7:49 AM, Tristan Van Berkom
Does this explanation solve the issue ?
Almost. It sure helps though.

Let me explain how the glade-anjuta integration works, so that it will
be more clear what the problem is. There are 3 ways that the
integration creates code to help the programmer: automatic member
widgets generation and callback generation (two different ways). I
recommend you to try anjuta, create a gtk application project, open
the callbacks.[ch] files and the .ui file to better see how the
integration works. Now, let me explain what anjuta does on automatic
callback/member widgets generation.

For automatic member widgets generation the user must double click a
widget (actually any object, but I'll call it widget for now) on the
glade inspector. When that happens, code will automatically be created
to include this widget as a private member of the associated class.
The name of the member is the same of the widget. So, if the widget
has no id strange things happens.

For automatic callback generation there are two ways to do it: the
user drags and drops a signal from glade to the source code editor
where it is wanted the callback to be created or the user
double-clicks the signal name and the callback code is automatically
created on the file of the associated class. The first parameter of
the callback has the same name of the widget. So, if the widget has no
id strange things happens.

From what I see, glade_widget_ensure_name creates a name for a widget
if it does not have one. This seems very good, but we would have the
call it before anjuta receives the signals to create member widgets or
callbacks. I think the best way to solve the issue is for glade the
call glade_widget_ensure_name on widgets before anjuta does anything
with id-less widgets. If you do not oppose it, I'll implement this
change. Do you agree wit it?
_______________________________________________
Glade-devel maillist - Glade-***@lists.dot.net
http://lists.dot.net/mail
Marco Diego Aurélio Mesquita
2017-04-02 15:08:24 UTC
Permalink
On Sun, Apr 2, 2017 at 11:15 AM, Tristan Van Berkom
Post by Marco Diego Aurélio Mesquita
Hi Tristan!
On Sun, Apr 2, 2017 at 7:49 AM, Tristan Van Berkom
Does this explanation solve the issue ?
Almost. It sure helps though.
Let me explain how the glade-anjuta integration works, so that it will
be more clear what the problem is. There are 3 ways that the
integration creates code to help the programmer: automatic member
widgets generation and callback generation (two different ways). I
recommend you to try anjuta, create a gtk application project, open
the callbacks.[ch] files and the .ui file to better see how the
integration works. Now, let me explain what anjuta does on automatic
callback/member widgets generation.
For automatic member widgets generation the user must double click a
widget (actually any object, but I'll call it widget for now) on the
glade inspector. When that happens, code will automatically be created
to include this widget as a private member of the associated class.
The name of the member is the same of the widget. So, if the widget
has no id strange things happens.
So at this point, instead of strange things happening, anjuta can
either set or 'ensure' the name of the widget when trapping this double
click.
Ok. I think that is doable. I just wanted it to be done on the glade
side, so that it wouldn't be needed to be done again for
gnome-builder.
Post by Marco Diego Aurélio Mesquita
For automatic callback generation there are two ways to do it: the
user drags and drops a signal from glade to the source code editor
where it is wanted the callback to be created or the user
double-clicks the signal name and the callback code is automatically
created on the file of the associated class. The first parameter of
the callback has the same name of the widget. So, if the widget has no
id strange things happens.
Which signal does the GladeSignalEditor emit that includes a widget
name ?
When dropping a signal, the name of the widget comes from
https://git.gnome.org/browse/glade/tree/gladeui/glade-signal-model.c#n957
. When the signal is double-clicked, the same information is generated
in anjuta in https://git.gnome.org/browse/anjuta/tree/plugins/language-support-cpp-java/plugin.c#n807
.
I cannot find one in Glade and suspect that Anjuta is using a custom
derived signal editor for this purpose.
Again the same applies, in response to a user activity Anjuta is free
to set or ensure a name on a widget that needs to have one.
Before continuing, I should note that undo/redo is an inherently
difficult thing to handle, I dont know if Anjuta does undo/redo, or how
well it is equipped to integrate with undo stacks in plugins.
a.) Some code added to a project buffer
b.) Some change that occurs in a Glade project
in a single user action, should be undoable/redoable in a single step.
Undo/redo after that point should safely/seamlessly repeat that
interleaved activity as one single action.
That is the ideal behavior and that is not how it is done currently.
Not a big problem though.
Post by Marco Diego Aurélio Mesquita
From what I see, glade_widget_ensure_name creates a name for a widget
if it does not have one. This seems very good, but we would have the
call it before anjuta receives the signals to create member widgets or
callbacks. I think the best way to solve the issue is for glade the
call glade_widget_ensure_name on widgets before anjuta does anything
with id-less widgets. If you do not oppose it, I'll implement this
change. Do you agree wit it?
I doubt that I agree.
It sounds like you would want Glade to introduce some behavior that
silently names widgets without the user really understanding what is
going on.
The behavior would be enabled only when running from an IDE.
Are you suggesting that if a user double clicks on a row in the
inspector in Glade (not in Anjuta), then the project will get littered
with names that are unneeded ?
My plan is that if the user double-clicks an id-less widget on glade
inspector (when running on an IDE), then it would automatically gain a
name.
Maybe this is not what you mean but I havent really figured it out, can
you suggest something that will not have a side effect of unwanted
names appearing in user projects for no reason ?
No, I can't. Maybe it should be handled on the IDE side of things
then. Just to confirm: you find it better that the IDE handle
automatic naming of widgets, is that right?
_______________________________________________
Glade-devel maillist - Glade-***@lists.dot.net
http://lis

Loading...