[Gtk-sharp-list] The .Label property of controls like the Gtk.Button

Philip Van Hoof spamfrommailing@freax.org
Sun, 02 Nov 2003 20:19:32 +0100

On Sat, 2003-11-01 at 17:28 -0600, Mike Kestner wrote:
> On Wed, 2003-10-29 at 03:01, Philip Van Hoof wrote:
> > Because in .NET every visible control seems to have a .Text property
> > which is used to set the contents main-label of that control, would it
> > be a good idea if I provided a patch that adds this property to controls
> > like the Gtk.Button ?

> I'm not terribly excited about this.  I think it's cleaner to obtain the
> child label control and set the text on it.  Besides, changing the label
> on a button is a good way to confuse your users, so it *should* be hard
> to do.  :)

Okay, in that case I am not going to create such a patch. Still I belive
that integration with the way of working in the .NET world should be
considered at some point. Perhaps using wrapper classes that actually
make stuff look more like the nice C#-way of doing things...

using Gtk;

public class Whatever 
  public Whatever () 
    Button b = new Button ();
    b.Label = "test";


using GtkSharper;

public class Whatever 
   public Whatever ()
       Button b = new Button ();

       // and then..

       Label l = b.Label;
       l.Text = "test";

       // and/or

       b.Text = "test";

> > I am also thinking about adding a Databind ()-method and a DataSource
> > property to widgets like the Gtk.Combo and Gtk.TreeView.

> Cool, but this might be a tiny bit premature.  I am currently working on
> a NodeStore for treeviews that is more C# friendly.  It might be better
> to add the data binding to that.  And Gtk.Combo is a "dead" widget.  As
> soon as packages for the upcoming Gtk+-2.4 are widely available, we will
> be upgrading to it, and the new sexy Gtk.ComboBox.

> So if this looks like it is going to be a lot of work to do this data
> binding it might be good to hold off a little for the new API.

Okay, in that case waiting seems to be the best option :). But I am
already looking forward to do things _like_

DataSet ds = new DataSet ();
ds.Tables.Add ("root");
ds.Tables.Add ("Level1");

TreeView tree = new TreeView ();
tree.DataSource = ds;

For example the Infragistics treeview .net components (afaik both the
WebNavigator and the Winforms stuff) work like this. Maybe taking a look
at their API is a smart move ;) as a lot .NET developers are already
used to that way of working.

Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
work: Philip dot VanHoof at cronos dot be
http://www.freax.be, http://www.freax.eu.org