[Gtk-sharp-list] Interface concept

Leo Spalteholz leo@thewoodpecker.ca
Wed, 22 Oct 2003 00:50:17 -0700


> Hey Leo,
>
> I am not an expert either but this is what I have found so far.
>
> I figured out a way to split the application into to separate areas.  I
> used the concept of Panes.  There are widgets available for both a
> horizontal panes and vertical panes.  I created a horizontal plane and
> then used the left portion for my column of buttons and the right
> portion for my scrolled window. However, I have not been able to figure
> out how to dynamically display "services" in the scrolled portion.

Ah.. I haven't even looked at using panes yet...  It won't work for my 
needs but it is of course the natural solution to your problem. 
>
> On your point of deleting a vertical packing box and if the deleting
> trickles down to all the child widgets the answer is yes.  The packing
> box is a container just like a window so any widgets within the
> container are destroyed upon destruction of the container. 

Good.  I'm still not sure why the memory usage of mono is increasing but 
maybe I've got some references to the buttons hanging around somewhere.  I 
did some rather ugly hackish stuff with storing button references in 
ArrayLists to keep track of them... :P

> could possibly do instead of deleting and recreating a new vertical
> packing box each time....maybe hide each of the widgets within the
> packing box and then show them accordingly.  Now I figure there has to
> be a much easier way then this.  I had thought of trying to do what you
> are doing...but personally you are a better man than I because I would
> not want to deal with the deletion and recreation.  

Its actually not that bad.  Looks something like this (sorry for the crappy 
10 min coding job).

using System;
using Gtk;
class switchtest {
    public static void Main() {
        new test();
    }
}

class test {
    HPaned splitter;
    public test() {
        Application.Init();
        Window winMain = new Window("Switch Test");
        winMain.SetDefaultSize(300, 200);

        splitter = new HPaned();
        Frame frame1 = new Frame("Buttons go here");
        Frame frame2 = new Frame("Service 1");

        splitter.Pack1(frame1, false, false);
        splitter.Pack2(frame2, true, false);

        Button btnSwitch = new Button("Change Service");
        btnSwitch.Clicked += new EventHandler(EvtBtnSwitchClicked);
        frame1.Add(btnSwitch);

        winMain.Add(splitter);
        winMain.ShowAll();
        Application.Run();
    }

    public void EvtBtnSwitchClicked(object obj, EventArgs e) {
        Frame frame2 = (Frame)splitter.Child2;
        Button b = new Button("Its a new service!");
        frame2.Label = "New service goes here";
        frame2.Add(b);
        b.Show();
    }
}

Should run the way it is.  Nothing too complicated.  As you see you're 
basically just changing the contents of the other pane in the button 
clicked eventhandler.  So you could remove and replace the frame with 
something else or just change it like I've done..

> Maybe there is to
> layer the "services" on the scrolled window or in your case packing box
> like a stack where the "service" on the top of the stack is displayed.
> Accordingly you can push and pop the stack of "services" based on the
> actions of the user.  Like I said I am no expert these are just
> suggestions.  Ill keep you informed if a find a way dynamically change
> the window.  If Evolution can do then it can be done.

I suppose you could store the main container for your service in a list so 
you don't have to recreate it every time you switch to a differnet one.   
Then just swap them in the clicked eventhandler.  So you have faster 
switching between services at the expense of more memory usage I would 
think.

Let me know how it works out.

~leo
>
> Joe