Discussion:
[Glade-users] Userdefined Widgets in catalog file
Elmar Haneke
2017-04-25 15:42:25 UTC
Permalink
I'm trying to include some user defined widgets by using an catalog file.
The Widget itself becomes available within glade 3.20, but the
information about properties and signals is lost.

This is the catalog-file used:

<glade-catalog name="DlgUtils" depends="gtk+">
<glade-widget-classes>
<glade-widget-class name="DlgUtils_DatumEingabe"
title="DatumEingabe" parent="GtkEventBox">
<signals>
<signal id="changed"/>
</signals>
<properties>
<property id="date" default="" visible="True"/>
<property id="date-string" default=""/>
<property id="mit-zeit" default="False"/>
<property id="mit-heute-button" default="False"/>
<property id="leer" default="False"/>
</properties>
</glade-widget-class>
</glade-widget-classes>
<glade-widget-group name="DlgUtils" title="DlgUtils">
<glade-widget-class-ref name="DlgUtils_DatumEingabe" />
</glade-widget-group>
</glade-catalog>


What can be done to make it work?

Elmar

_______________________________________________
Glade-users maillist - Glade-***@lists.dot.net
http
Juan Pablo Ugarte
2017-04-25 21:43:57 UTC
Permalink
Post by Elmar Haneke
I'm trying to include some user defined widgets by using an catalog file.
The Widget itself becomes available within glade 3.20, but the
information about properties and signals is lost.
<glade-catalog name="DlgUtils" depends="gtk+">
    <glade-widget-classes>
        <glade-widget-class name="DlgUtils_DatumEingabe"
title="DatumEingabe" parent="GtkEventBox">
            <signals>
                <signal id="changed"/>
            </signals>
            <properties>
                <property id="date" default="" visible="True"/>
                <property id="date-string" default=""/>
                <property id="mit-zeit" default="False"/>
                <property id="mit-heute-button" default="False"/>
                <property id="leer" default="False"/>
            </properties>
        </glade-widget-class>
    </glade-widget-classes>
    <glade-widget-group name="DlgUtils" title="DlgUtils">
        <glade-widget-class-ref name="DlgUtils_DatumEingabe" />
    </glade-widget-group>
</glade-catalog>
What can be done to make it work?
You are not loading your library, so glade does not know the properties
DlgUtils_DatumEingabe has.

since you specified parent="GtkEventBox", glade will use that as the
base of DlgUtils_DatumEingabe but you need to specify the param spec of
each property you want to edit in glade (see https://developer.gnome.or
g/gladeui/3.20/properties.html)

I recommend trying to load your library
<glade-catalog name="foo" library="foo" depends="gtk+">

greets

JP
_______________________________________________
Glade-users maillist - Glade-***@lists.dot.n
Elmar Haneke
2017-04-26 08:51:59 UTC
Permalink
Post by Juan Pablo Ugarte
since you specified parent="GtkEventBox", glade will use that as the
base of DlgUtils_DatumEingabe but you need to specify the param spec of
each property you want to edit in glade (see https://developer.gnome.or
g/gladeui/3.20/properties.html)
That is what I did try. I cannot see an discrepance between my catalog
file and that description.
Post by Juan Pablo Ugarte
I recommend trying to load your library
<glade-catalog name="foo" library="foo" depends="gtk+">
The Widget is implemented as an GTK#-Object, I did not find an solution
to put this into an library for Glade.

Elmar
_______________________________________________
Glade-users maillist - Glade-***@lists.dot.net
http://list
Tristan Van Berkom
2017-04-26 09:10:36 UTC
Permalink
Post by Elmar Haneke
Post by Juan Pablo Ugarte
since you specified parent="GtkEventBox", glade will use that as the
base of DlgUtils_DatumEingabe but you need to specify the param spec of
each property you want to edit in glade (see https://developer.gnome.or
g/gladeui/3.20/properties.html)
That is what I did try. I cannot see an discrepance between my catalog
file and that description.
Not exactly... but the documentation does not make it that clear. Also
it looks like the documentation has fallen behind a bit, as it lacks
documentation for the newer 'parameter-spec' which replaces the old
'spec'.
Post by Elmar Haneke
Post by Juan Pablo Ugarte
I recommend trying to load your library
<glade-catalog name="foo" library="foo" depends="gtk+">
The Widget is implemented as an GTK#-Object, I did not find an solution
to put this into an library for Glade.
Right, in this case loading the library wont work, I think we only
have support for automatically loading python widgets and nothing else
non-C.

So, to explain a bit better, in order to augment a widget's properties
with completely made up properties, it's mostly important to just
specify the type of property it is, take for example the "size"
property of the GtkBox (which does not get saved to the Glade file,
but that does not have to be the case).

See: https://git.gnome.org/browse/glade/tree/plugins/gtk+/gtk+.xml.in#n655

Using the <parameter-spec> you should be able to use any existing
GParamSpec, especially for the glib fundamental types this is pretty
straight forward.

For object type properties, one needs to specify the "value-type" of
the param spec, for numeric types, one can optionally specify min/max
boundaries for those.

I dont think we ever documented this part well so, just in case you
can't figure out what you need from the above link to the GTK+
catalog, here is the code where we parse the "parameter-spec"
definitions for manually added properties in the XML file:
https://git.gnome.org/browse/glade/tree/gladeui/glade-property-class.c#n1705

Cheers,
-Tristan
_______________________________________________
Glade-users maillist - Glade-***@lists.do
Elmar Haneke
2017-04-26 15:17:24 UTC
Permalink
Post by Tristan Van Berkom
So, to explain a bit better, in order to augment a widget's properties
with completely made up properties, it's mostly important to just
specify the type of property it is, take for example the "size"
property of the GtkBox (which does not get saved to the Glade file,
but that does not have to be the case).
Ok, that does solve the main problem, glade seems to silently ignore
incomplete property information.

Can you give me some hints about defining signals?

Elmar

_______________________________________________
Glade-users maillist - Glade-***@lists.dot.net
http://lists.dot.net/mailman/listinfo/glade-u
Tristan Van Berkom
2017-04-27 11:51:27 UTC
Permalink
Post by Elmar Haneke
Post by Tristan Van Berkom
So, to explain a bit better, in order to augment a widget's properties
with completely made up properties, it's mostly important to just
specify the type of property it is, take for example the "size"
property of the GtkBox (which does not get saved to the Glade file,
but that does not have to be the case).
Ok, that does solve the main problem, glade seems to silently ignore
incomplete property information.
Can you give me some hints about defining signals?
Sorry Elmar,

This is something that was just never implemented. To be honest the
fact that you can do virtual properties like this is partly
accidental, the primary use case for this was to introduce virtual
properties in the property editor that would not be saved, but simply
allow plugin editor authors to provide a more convenient user
experience for editing widgets.

That said, over the years this has come up a couple of times and it
would be nice to be able to declare entirely virtual signals for your
type of use case, where the widget you want to edit is not going to be
available in a regular C library.

Cheers,
-Tristan
_______________________________________________
Glade-users maillist - Glade-***@lists.dot.net
http://list

Loading...