[Gtk-sharp-list] ImageMenuItem

Ohmu ohmar@hot.ee
Fri, 06 Aug 2004 16:31:56 +0300

This is a multi-part message in MIME format.
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

underdog10@netcourrier.com wrote:
> Hi,
> I making a right click on a treeview, i found how to make it.
> The problem, i haven't found a method to set a different image from Stock id using the Gtk.ImageMenuItem Class
> I would like to set my own image, the same than i use in my toolbar.
> Does anyone as clue for that?
> Thanks.
> KaYa.

Awnser was in documents ;)
I made an example and attached the source and image..

Content-Type: image/png;
Content-Transfer-Encoding: base64
Content-Disposition: inline;

Content-Type: text/x-csharp;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

using System;
using Gtk;

public class menuTest
	public static void Main (string[] args)
		Application.Init ();
		// Setup window
		Gtk.Window win = new Gtk.Window ("menuTest");
		win.SetSizeRequest (250, 100);
		win.DeleteEvent += new DeleteEventHandler (OnDeleteEvent);

		Gtk.VBox box = new Gtk.VBox ();
		win.Add (box);

		// Create menubar and add menus etc
		Gtk.MenuBar mb = new Gtk.MenuBar ();
		box.PackStart (mb, false, false, 0);
		Gtk.MenuItem mi = new Gtk.MenuItem ("Test");
		mb.Append (mi);
		Gtk.Menu m = new Gtk.Menu ();
		mi.Submenu = m;
		// Add a ImageMenuItem with costum image to Menu
		Gtk.ImageMenuItem imi = new Gtk.ImageMenuItem ("My icon");
		Gtk.Image img = new Gtk.Image ("icon.png");
		imi.Image = img;
		m.Append (imi);

		win.ShowAll ();
		Application.Run ();

	public static void OnDeleteEvent (object obj, DeleteEventArgs args)
		Application.Quit ();