[Glade-users] Viewing custom widget sub-widgets in Glade tree-view
- From: tvb at gnome.org (Tristan Van Berkom)
- Subject: [Glade-users] Viewing custom widget sub-widgets in Glade tree-view
- Date: Tue, 5 Oct 2010 23:35:50 +0900
On Tue, Oct 5, 2010 at 6:28 PM, Klaim <mjklaim at gmail.com> wrote:
Okay, so I tried to add?G_PARAM_CONSTRUCT_ONLY to my properties (that are
built in the widget so are exposed correctly in glade) and it glade if I
change the property value it will crash with "segmentation error". From the
trace I've put in my glade plugin I can see that it crashes after having
called (apprently successfully) the set-property function of my plugin. Not
sure if it's due to the way I've coded the widget...
I'm not sure to understand what?G_PARAM_CONSTRUCT_ONLY is doing exactly...
As the internal buttons are destroyed and constructed by internal code of
the widget, don't it get in conflict with this parameter option?
Its hard to say what exactly is going on here without more details.
Setting of a construct-only property in Glade is one of the more complex
things that Glade does (the core will dig out any children added by the
user and save their packing options and then add them to the newly
"rebuilt" widget and then put the new version of the widget back in
to the hierarchy).
You are implementing get-children-function to return the internal
widgets as direct children of the custom widget ?
You are calling glade_widget_adaptor_create_internal() on the internal
widgets at post-create time ?
An actual stack trace by gdb would be helpful to get the drift of what's
amiss... also the glade_widget_rebuild() code (which runs to rebuild
widgets for construct-only properties) does not expect that a widget's
internal children will change across rebuilds (i.e. it expects the number
of internal children to be constant, I would expect complaints if children
existing before the rebuild were lost/inexistent after a rebuild).
Cheers,
-Tristan
On Tue, Oct 5, 2010 at 11:18, Tristan Van Berkom <tvb at gnome.org> wrote:
Sorry I have to run out right now, but reading your mail... if I
understand correctly
I think you will be able to get away with adding the text:
? <property .... construct-only="True" />
...to the properties you declared which control how many columns/rows your
custom widget has (this will trigger the widget being rebuilt whenever the
amount of children changes... so it will call the post-create again and
add
the internal children correctly).
Ofcourse if your children have customized internal names (like
"button-c2-r5"
for the button in column 2 and row 5...) then your GtkBuildable
implementation
will have to handle that correctly too in it's own
get_internal_child() implementation,
I dont think there's going to be any problems with that though.
Cheers,
? ? ? ? ?-Tristan
On Tue, Oct 5, 2010 at 5:52 PM, Klaim <mjklaim at gmail.com> wrote:
Hi and thank you very much for answering so fast!
Your explaination is clear and I now I can clearly see how much I'm not
in
this (simple) case.
I'll explain the structure of my custom widget to help you help me.
My custom widget isn't a container. I mean that in glade, or in the code
using it,
there shouldn't be ways to add something to it directly.
Instead, the use will simply change parametters:
My widget inherit from GtkAlignment and contains only a GtkTable. Now
the
table is automatically filled with GtkToggleButtons.
I exposed column-width and column-height in parametters of my custom
widget
and when you change it, it will automatically destroy and create toggle
buttons in the table to fill it. That's all done in the custom widget.
What I want is to allow the user to edit the buttons (everithing in it,
like
normal button edit) without being allowed to touch the structure of the
custom widget other than what I voluntarly exposed in the interface.
Now, if I understood correctly, I'm in the case where I need to
?1. implement get-internal-child
?2. have to get new buttons created in the widget and make glade widgets
for
them.
That's what I've done and it almost works perfectly so far. I just had
to
add get-children to make the widgets visible in the tree view of glade
(I'm
still not sure why).
So the problem I have is that is I add 1 to the column number, the
widget
will add buttons automatically and make glade widgets too. However, only
the
widget tree view in glade will not update.
It will only update on creation of the widget, or when I load it from a
saved file.
Yesterday I found that get-internal-child is called when I load it from
a
saved file, so I was thinking that maybe I have to make a call to a
function
or send a signal for the tree-view to get internal children again?
On Mon, Oct 4, 2010 at 18:20, Tristan Van Berkom <tvb at gnome.org> wrote:
On Tue, Oct 5, 2010 at 12:18 AM, Klaim <mjklaim at gmail.com> wrote:
Hi,
as disscussed there
:?http://www.gtkforums.com/viewtopic.php?p=18030#18030
I've managed to make my sub-widgets appear where I wanted, in the
treeview.
However, the treeview content will not be updated when I'll add new
seb-widget to my custom widget, or remove some from it.
I've been analzing and trying to reproduce some techniques that are
used
in
gtk widgets plugin code that we can find here :
http://git.gnome.org/browse/glade3/tree/plugins/gtk+/glade-gtk.c
I've been trying for several days but couldn't update the tree view.
I've implemented a plugin for glade, it provide (wired in the xml
file)
:
?? ?post-create-function
?? ?set-property-function
?? ?get-internal-child-function
?? ?get-children-function
I see that the get-internal-child-function is not even called by
glade
(then
I don't undersand when it should be called) but at the moment I
implemented
get-children-function I started to see the subwidgets in the glade
tree-view.
I've been following advices given there
:?http://www.mail-archive.com/gtk-app-devel-list at gnome.org/msg12349.html
I think I'm missing something simple as the gtk glade plugin code
don't
seem
too complicated but I can't find how it makes the sub-children
updated
in
the treeview.
When I load a gui built with glade and saved with modified number of
sub-widgets in my custom widget, I get the right count of sub-widgets
in
the
tree-view. Only modifying it will not update the tree-view.
My custom widget have two properties with widgets counts that will
add
or
remove widgets from the custom widget (in the widget code).
So in the plugin I've only added in post-create-function and
set-property-functino some way to call
glade_widget_adaptor_create_internal() on new digets added to the
custom
widget.
It's the same function that is called in the two functions but it
seem
to
work only with post-create-function.
Any suggestion?
I'm not sure if that question is clear enough, but tell me if it's
not.
I'm a little confused about what exactly is not working for you.
If you have a custom widget that is a GtkContainer, so long as
it works like an ordinary container you should not need to implement
anything custom along the lines of get-children or any of that.
(take the GtkBox implementation for reference in this case; it
uses a virtual 'size' property to decide how many placeholders
to expose in the Glade workspace).
Note that get-internal-child is for indirect children of composite
widgets. Thats what lets a GtkDialog configure properties and
add children to its internal 'vbox' or 'action-area' (I think thats
out of context for you, I think you just have a normal container).
What you need to do when implementing a normal container
is usually add placeholders to it if and when appropriate; then
you need to implement add-child-function/remove-child-function
and replace-child-function (replace-child will be called if your
plugin uses GladePlaceholder ... the Glade core will replace
the placeholder with a widget from the palette; giving it the
initial packing properties of the placeholder).
So, generally you should just start with add-child and remove-child
functions... you should not need to call
glade_widget_adaptor_create_internal()
unless you are exposing an internal child of a complex composite
You dont need to implement get-children-function either unless you need
to add something to the generic child list already returned by your
container's implementation of GtkContainerClass->forall().
Does that help ?
Please let me know in more detail what is the nature of your container
so I can better help you, is it a basic container widget that only lays
out
it's children in a custom way ?
Cheers,
? ? ? ? -Tristan
Thanks for reading
Joel Lamotte.
_______________________________________________
Glade-users maillist ?- ?Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users
_______________________________________________
Glade-users maillist ?- ?Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]