[Glade-users] Viewing custom widget sub-widgets in Glade tree-view
Tristan Van Berkom
tvb at gnome.org
Tue Oct 5 05:18:25 EDT 2010
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@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
>> >
>> >
>
>
More information about the Glade-users
mailing list