[Gtk-sharp-list] Gtk.Toolbar.InsertStock() : Help Needed

Fredrik Nilsson jymdman@home.se
Fri, 23 Jul 2004 10:21:00 +0200


On fre, 2004-07-23 at 04:24 +0100, wrote:
> Fredrik, First of all thanks for that info - it's pointing me in the right
> direction I think.
> I'll be honest and say that I've not tried the InsertStock() method, perhaps
> a little explanation is in order.
> 
> In order to proceed with a project that I have in mind (dont want to say too
> much just in case I need to scrap it but if I go ahead it will be GPL :-) )
> I need a comprehensive understanding of all the standard Gtk widget
> constructors(especially stock items).  When I saw that InsertStock() was
> marked as deprecated in the documentation, I made the (probably unsound)
> assumption that it had already been replaced (logic being that it must have
> been replaced in order for it to be marked as deprecated).  Hence my post.
> 
> Since it now looks like InsertStock's replacement does not yet exist, I am
> unsure as to why it is deprecated without a suitable replacement method
> being ready.  Stock items *seem* to be an such integral part of rapidly
> building Gtk apps I fail to see the logic.
> 
> I'm sure there *must* be a logic to it, but coming from an MS.net background
> it escapes me.  Perhaps deprecated doesn't mean "going out of use - use the
> new way" which is what I understood it to be ?
> 
> The more I think about it - the more sure I become that this is a
> fundemental error in logic on my part, and any help anyone can give I'd
> appreciate.
> 
> Thanks
> 
> Matt
> (A "trying hard" to convert C# developer)
> 

Ok,

After actually *looking* at the mono docs on the web, my answer differs
a little :)
InsertStock seems to be deprecated, as you said, already in gtk# 1.0
(gtk 2.2) and there is not any replacement.
The preffered methods, as said in the docs, is to use AppendItem,
PrependItem and InsertItem.
So if you want to use a stock button in your toolbar you have to use
following code:
	
	Image image = new Image (Stock.Open, IconSize.SmallToolbar);
	toolbar.AppendItem ("Open", "open", "open", image, new SignalFunc
(open_callback));

I don't really know how deprecated widgets and methods will be treated
in gtk#, but gtk+ have a API guarantee for the 2.x release cycle.
So if you use a method that is deprecated in e.g. 2.2, it should still
work in 2.8, but probably not 3.0.

In gtk# 2.0 (gtk+ 2.4) there is going to be a complete new menu and
toolbar system that is actionbased.
The menus and toolbars is defined in xml-files and you can easily merge
two menus or toolbars.
So if you can wait til october/november for pre-releases, or use the
jerone-gtk-2-4 branch from cvs, I would use that.

Hope this clear things up a bit.

/Fredrik