[Gtk-sharp-list] treeview help

Borja Sanchez Zamorano borsanza@terra.es
Mon, 08 Mar 2004 02:42:33 +0100


--=-30aVmGyDPnsabnDeEfKy
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

hi,
See this example... It works correctly. The order are defined in the
packstart. If pixbuf is first has warnings, but if it is second doesn't
warning.

  BorSanZa

El lun, 08-03-2004 a las 01:40, ahmed el-helw escribi=F3:
> hi,
> i've been playing around with treeview, and i got basic things setup and
> working.  but i was trying to setup a treeview that displays text and an
> icon next to it on the left.  if i set the Pixbuf attribute of a
> CellRendererPixbuf and the Text attribute of a CellRendererText and just
> do store.AppendValues(""); -- it works but gives errors on the command
> line while running.  so i am trying to figure out how to correctly do
> this.  after trying for a while, i can't figure it out, so could anyone
> help me and tell me how i could display a picture with the text by it?
>=20
> my setup code is as follows:
> public void SetupUI(){
>   TreeStore store =3D new TreeStore(typeof(string), typeof(Pixbuf));
>   treeview =3D new TreeView(store);
>   CellRendererText ct =3D new CellRendererText();
>   CellRendererPixbuf cb =3D new CellRendererPixbuf();
>   treeview.HeadersVisible =3D false;
>   TreeViewColumn column =3D new TreeViewColumn();
>   column.PackStart(cb, false);
>   column.PackStart(ct, true);
>   column.AddAttribute(cb, "pixbuf", 0);
>   column.AddAttribute(ct, "text", 1);
>   treeview.AppendColumn(column);
> }
>=20
> any help would be greatly appreciated.
> thanks,
> -ahmed

--=-30aVmGyDPnsabnDeEfKy
Content-Disposition: attachment; filename=treeview.cs
Content-Type: text/plain; name=treeview.cs; charset=iso-8859-15
Content-Transfer-Encoding: 7bit

using Gdk;
using Gtk;


namespace TryIt
{

  class tree
  {
    TreeView treeview;
    Gtk.Window win;

    static void Main ()
    {
      Application.Init ();
      new tree ();
      Application.Run ();
    }

    public tree ()
    {
      win = new Gtk.Window ("TreeView Pixmap");
      treeview = new TreeView ();
      win.Add (treeview);
      win.ShowAll ();
      win.DeleteEvent += new DeleteEventHandler (OnDeleteEvent);
      SetupUI ();
    }

    void OnDeleteEvent (object o, DeleteEventArgs args)
    {
      Application.Quit ();
    }

    public void SetupUI ()
    {
      TreeStore store = new TreeStore (typeof (string), typeof (Pixbuf));
      treeview.Model = store;
      treeview.HeadersVisible = true;

      CellRendererText ct = new CellRendererText ();
      CellRendererPixbuf cb = new CellRendererPixbuf ();
      TreeViewColumn column = new TreeViewColumn ();
      column.PackStart (ct, true);
      column.PackStart (cb, false);
      column.AddAttribute (cb, "pixbuf", 1);
      column.AddAttribute (ct, "text", 0);
      treeview.AppendColumn (column);

      Gdk.Pixbuf a = new Gdk.Pixbuf (new Gdk.Colorspace (), false, 8, 48, 48);
      a.Fill (0xff000000);
      store.AppendValues ("Hello", a);
			a = new Gdk.Pixbuf (new Gdk.Colorspace (), false, 8, 64, 32);

			      a.Fill (0x00ff0000);
      store.AppendValues ("World", a);

    }
  }
}

--=-30aVmGyDPnsabnDeEfKy--