[Gtk-sharp-list] Two state button problems

Piotr Zurek p.zurek at gmail.com
Mon Dec 12 18:56:58 EST 2005


Hi guys,

I have a problem with my way of dealing with two-state-button.
I just create two Toolbuttons and hide one of them. After the first
one is clicked it is hidden and the other is shown.
The first problem is that the initial toolbutton.visible = (false)
doesn't hide the button.
The second problem is that after any of the buttons is clicked it is
hidden and the replacement is not shown. It is shown after I click any
other button in this toolbar (even though they have no events yet).

That is the code:

	public class ViewOptionToolbar : Toolbar
	{	
		ToolButton NotesShowButton = new ToolButton("Show Notes");
		ToolButton NotesHideButton = new ToolButton("Hides Notes");
		public ViewOptionToolbar () : base ()
		{

//... other buttons with no events yet

			NotesShowButton.StockId = (Stock.GoBack);
			NotesShowButton.Label = ("Show Notes");
			NotesHideButton.StockId = (Stock.GoForward);
			NotesHideButton.Label = ("Hide Notes");
			
			NotesHideButton.Clicked += new EventHandler
(OnNotesHideClicked);				NotesShowButton.Clicked += new EventHandler
(OnNotesShowClicked);

			this.Insert (NotesHideButton, 8);			
			this.Insert (NotesShowButton, 9);

			this.ToolbarStyle = (ToolbarStyle.Icons);
			this.IconSize = (IconSize.Menu);

			NotesHideButton.Visible = (false);
		}	
		public void OnNotesShowClicked (object o, EventArgs args)
		{
			NotesShowButton.Visible = (false);
			NotesHideButton.Visible = (true);
		}	
		public void OnNotesHideClicked (object o, EventArgs args)
		{
			NotesHideButton.Visible = (false);
			NotesShowButton.Visible = (true);
		}
	}

And one more question, when I use:
Toolbutton.IconWidget = new Gtk.Image (Gdk.Pixbuf.LoadFromResoure ("xxx.png"));
MonoDevelop compiles that without error but the GUI crashes with
unrecognized file format message.
Please, enlight me how to use custom icons in my toolbars.

Thanks in advance
--
Piotr


More information about the Gtk-sharp-list mailing list