[Gtk-sharp-list] Losing Data of a TreeView

Pablo Fischer pablo@pablo.com.mx
Thu, 16 Oct 2003 09:46:58 -0500

Content-Type: text/plain
Content-Transfer-Encoding: 7bit


Well, I have a TreeView where Im loading the content of a xml file, and
also I have a button where I can add new content (username, password,
bla bla). Every time I add a new entry to the xml file I update the
TreeView and it works it's showing the new entries. But.. If I close
that window (that contains the TreeView) and Open It for second time the
new entries that I added dissapeared!. I also tried to print all the
entries (Console.WriteLine)  every time I open the window and the data
continues in the Object (Accounts accounts). 

Im pasting at the end of the file the method that Creates that Windows
and the Method that loads the DataAccounts.

Pablo Fischer Sandoval (pablo [arroba/at] pablo.com.mx)
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt

Content-Disposition: attachment; filename=load_data
Content-Type: text/plain; name=load_data; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

  private void LoadDataAccountsTree() {
    //Load the config file
    //    ReadConfig();
    //The iterator
    TreeIter iter = new TreeIter ();
    //The counter
    int count = 0;
    do {
      GLib.Value name = new GLib.Value(((Account)accounts.accountArray[count]).identifier);
      GLib.Value website = new GLib.Value(((Account)accounts.accountArray[count]).url);
      GLib.Value counter = new GLib.Value (count.ToString());
      accounts_treestore.Append (out iter);
      accounts_treestore.SetValue (iter, 0, name);
      accounts_treestore.SetValue (iter, 1, website);
      accounts_treestore.SetValue (iter, 2, counter);
      Console.WriteLine("El usuario: {0}", ((Account)accounts.accountArray[count]).username);
    }while(count > accounts.accountArray.Count);

Content-Disposition: attachment; filename=load_window
Content-Type: text/plain; name=load_window; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

  private void LoadAccountsWindow() {
    Glade.XML ui2  = new Glade.XML(null, "mbloggy.glade","accountsWindow", null);
    accountsWindow = (Gtk.Window)ui2["accountsWindow"];
    //Load the ScrolledWindow
    Gtk.ScrolledWindow accounts_scrolledwindow = (Gtk.ScrolledWindow)ui2["accounts_scrolledwindow"];
    //Create the treestore
    accounts_treestore = new Gtk.TreeStore((int)TypeFundamentals.TypeString,
    //Lets load the name of the accounts
    accounts_treeview = (Gtk.TreeView)ui2["accounts_treeview"];
    accounts_treeview.Model = accounts_treestore;
    accounts_treeview.HeadersVisible = true;
    accounts_treeview.Reorderable = true;
    accounts_treeview.RulesHint = true;
    //We are going to use a render to show the columns, so lets create it
    render = new Gtk.CellRendererText();
    //The columns
    Gtk.TreeViewColumn col_identifier = new Gtk.TreeViewColumn();
    col_identifier.Title = "Name"; col_identifier.Resizable = true;
    col_identifier.Reorderable = false; col_identifier.PackStart(render, false);
    col_identifier.AddAttribute(render, "text", 0); accounts_treeview.AppendColumn(col_identifier);
    //The second column (the url)
    Gtk.TreeViewColumn col_url = new Gtk.TreeViewColumn();
    col_url.Title = "Website"; col_url.Resizable = true;
    col_url.Reorderable = false; col_url.PackStart(render, false);
    col_url.AddAttribute(render, "text", 1); accounts_treeview.AppendColumn(col_url);
    //The third column (an in identifier to load faster the config file)
    Gtk.TreeViewColumn col_num = new Gtk.TreeViewColumn();
    col_num.Title = "Website"; col_num.Resizable = true; col_num.Visible = false;
    col_num.Reorderable = false; col_num.PackStart(render, false);
    col_num.AddAttribute(render, "text", 2); accounts_treeview.AppendColumn(col_num);
    //Load the data