RE: [gtk-list] Re: Gtk programming style/advice



> I have a fairly complicated GUI, so rather than create all the widgets
> in one function, I want to split the creation into a number 
> of functions
> - I know that some of the contents will change and this will make it
> easier for me to maintain.
> 
> Essentially, I have a 3x3 table, each cell of which contains more
> widgets. One, for example, contains a scrolled window that contains a
> CTree. Another contains a set of toggle buttons, the state of 
> which will
> effect the contents of the CTree.
> 
> Everything works fine if I create all the widgets in one function.
> 
> However, if I start to split it up and use a structure then it falls
> over almost straight away. Below is the start of the code, which seg
> faults when it tries to create the tree within the main window.
> 
> Any comments appreciated.
> 
Hi,

What I used to do was create a new widget that features combined widgets.
For the CTree widget, for example, I created a TreeView widget that inherits from a ScrolledWindow and has a CTree inside. To abstract the design I created methods that work on the CTree.  For the toggle-button you can create a method change_state (widget, boolean) that changes the state of the selected tree node (for exampe changing its icon). This way the button doesn't have to know anything about CTrees.


Hope it works,

Arjan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]