[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.
--------------050609070100010001050506
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..

--------------050609070100010001050506
Content-Type: image/png;
 name="icon.png"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="icon.png"

iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAA
CXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1AgGDQwzS91dzQAAAB10RVh0Q29tbWVudABD
cmVhdGVkIHdpdGggVGhlIEdJTVDvZCVuAAAAW0lEQVR42mNkYGD4z0ABYGFgYGCYp6aGVTLp
1i0GBgYGhrgrtVjlF+k0MzAxUAhGDWBgYKQ0Gil2AQsDAwODus01rJI3j2gxMDAwMFw7o45V
Xsvk5mg0Dop0AAC55g8fzTr7pQAAAABJRU5ErkJggg==
--------------050609070100010001050506
Content-Type: text/x-csharp;
 name="menuTest.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="menuTest.cs"

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 ();
	}
}
--------------050609070100010001050506--