[Glade-devel] How glade should name new widgets

Marco Diego Aurélio Mesquita marcodiegomesquita at gmail.com
Sun Apr 2 15:08:24 UTC 2017


On Sun, Apr 2, 2017 at 11:15 AM, Tristan Van Berkom
<tristan at upstairslabs.com> wrote:
> On Sun, 2017-04-02 at 09:53 -0300, Marco Diego Aurélio Mesquita wrote:
>> Hi Tristan!
>>
>> On Sun, Apr 2, 2017 at 7:49 AM, Tristan Van Berkom
>> <tristan at upstairslabs.com> wrote:
>> >
>> > 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.

>
>> 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.
>
> Ideally though, any action which involves both:
>
>   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.

>
>> 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?


More information about the Glade-devel mailing list