Re: Insert different children into the same parent in GtkTreeStore?



On 16.06.2011 21:19, Phong Cao wrote:
Hello everybody,

I am trying to write a music manager software that import the files
according to artist and album. Each artist can have many album and each
album can have many songs. Therefore, I decided to use GtkTreeStore to nest
all the same-album songs into one parent (the album) and all the same-artist
albums into one parent (the artist). Here is the screenshot of the software:

Screenshot.png<http://www.dotphoto.com/Go.asp?l=42khamthien&P=35183166&AID=6391002&IID=250817449>

The problem here is, as you can see, I could not insert the albums with the
same artist under that artist, and songs with the same album under that
album. I wonder how can I achieve this? I tried to create a GtkTreeIter to
iterate through the tree and compare the name of artist/album in the
TreeStore with the artist/album I got from the stream but that did not help.
Can anyone suggest any better way?

Thank you for reading my message! I hope you guys have a good weekend!


Best regards,


Phong Cao,
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Hello. I think you need to read a tutorial first: http://scentric.net/tutorial/treeview-tutorial.html

An example from there:

  GtkListStore *treestore;
  GtkTreeIter   iter, child;

  treestore = gtk_tree_store_new(1, G_TYPE_STRING);

  /* Append an empty top-level row to the tree store.
   *  Iter will point to the new row */
  gtk_tree_store_append(treestore,&iter, NULL);

  /* Append another empty top-level row to the tree store.
   *  Iter will point to the new row */
  gtk_tree_store_append(treestore,&iter, NULL);

  /* Append a child to the row we just added.
   *  Child will point to the new row */
  gtk_tree_store_append(treestore,&child,&iter);

  /* Get the first row, and add a child to it as well (could have been done
   *  right away earlier of course, this is just for demonstration purposes) */
  if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(treestore),&iter))
  {
    /* Child will point to new row */
    gtk_tree_store_append(treestore,&child,&iter);
  }
  else
  {
    g_error("Oops, we should have a first row in the tree store!\n");
  }




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