/// <summary> /// Adds a button to the end of the button list. /// Each button has an icon and a text, and changes /// CurrentPage when clicked. /// </summary> /// <param name="icon">Icon to show at the left of the button</param> /// <param name="text">Text to show at the right of the button</param> /// <param name = "tooltiptext">Text to add to the button as tooltip</param> public void AddButton(Pixbuf icon, string text, string tooltiptext) { // If there are other buttons, add the new button to their buttonGroup RadioButton otherbutton = null; string styleName = "toggletabbutton_only"; if (buttoncontainer.Children.Any()) { otherbutton = buttoncontainer.Children.First() as RadioButton; styleName = "toggletabbutton_right"; } var button = new RadioButton(otherbutton); button.Name = styleName; button.DrawIndicator = false; var bin = new HBox(); var box = new HBox(); box.Spacing = 12; box.Add(new Gtk.Image(icon)); box.Add(new Label(text)); bin.PackStart(box, false, false, 10); button.Add(bin); // Restyle the widget that was the last (if any) int pos = buttoncontainer.Children.Length - 1; if (pos >= 0) { Widget previousLast = buttoncontainer.Children.Last(); previousLast.Name = pos == 0 ? "toggletabbutton_left" : "toggletabbutton_center"; previousLast.ResetRcStyles(); } if (tooltiptext != null) { button.TooltipText = tooltiptext; } buttoncontainer.Add(button); pos++; button.Toggled += (sender, e) => { if (button.Active) { SwitchPage(pos); } }; button.ShowAll(); }