protected virtual void InsertProxy(Gtk.Action menuAction, Widget parent, Widget afterItem) { int position = 0; Widget item = null; if (parent is MenuItem || parent is Menu) { Menu parent_menu = ((parent is MenuItem) ? (parent as MenuItem).Submenu : parent) as Menu; position = (afterItem != null) ? Array.IndexOf(parent_menu.Children, afterItem as MenuItem) + 1 : 0; item = GetNewMenuItem(); if (item != null) { parent_menu.Insert(item, position); } } else if (parent is Toolbar) { ToolItem after_item = afterItem as ToolItem; if (after_item != null) { position = (parent as Toolbar).GetItemIndex(after_item); ToolItem tool_item = GetNewToolItem(); if (tool_item != null) { (parent as Toolbar).Insert(tool_item, position); item = tool_item; } } } if (item != null) { action.ConnectProxy(item); } }
public static Hyena.Widgets.ImageButton CreateImageButton(this Gtk.Action action) { var button = new Hyena.Widgets.ImageButton(action.ShortLabel, action.IconName); action.ConnectProxy(button); return(button); }
public CommandMapButton(string category_name, Gtk.Action action) : this(category_name) { action.ConnectProxy(this); TooltipText = action.Label; Label = action.Label; Image = new Gtk.Image(action.StockId, IconSize.Button); ImagePosition = PositionType.Top; Image.Show(); }
public static DockToolButton CreateDockToolBarItem(this Gtk.Action action) { DockToolButton item = new DockToolButton(action.StockId); action.ConnectProxy(item); item.Show(); item.TooltipText = action.Label; item.Label = string.Empty; item.Image.Show(); return(item); }
private void connectActions() { openaction = basicactions.GetAction("OpenAction"); openaction.Activated += OnOpenAction; quitaction = basicactions.GetAction("QuitAction"); quitaction.Activated += OnQuitAction; newaction = basicactions.GetAction("NewAction"); newaction.Activated += OnNewAction; playaction = basicactions.GetAction("PlayAction"); playaction.Activated += OnPlayAction; pauseaction = basicactions.GetAction("PauseAction"); pauseaction.Activated += OnPauseAction; openaction.ConnectProxy(openbutton); newaction.ConnectProxy(newbutton); playaction.ConnectProxy(playbutton); pauseaction.ConnectProxy(pausebutton); }
/// <summary> /// Initializes a new instance of the <see cref="ActionMenuItem"/> class. /// </summary> /// <param name="manager">The manager.</param> /// <param name="action">The action.</param> public ActionMenuItem( ActionManager manager, Action action) { // Saves the properties. if (manager == null) { throw new ArgumentNullException("manager"); } if (action == null) { throw new ArgumentNullException("action"); } // Attach to the action. this.action = action; action.ConnectProxy(this); // The default menu can't handle the chained accelerators, so we // remove the contents of the menu item and recreate it using a // HBox with a custom label for both. var newChild = new HBox(false, 0); displayLabel = new Label(action.Label); displayLabel.UseUnderline = true; displayLabel.Xalign = 0.0f; displayLabel.Show(); newChild.PackStart(displayLabel); // Get the keybinding label. HierarchicalPath acceleratorPath = manager.GetPrimaryAcceleratorPath(action); if (acceleratorPath != null) { // Get a formatted version of the accelerator path. string display = ActionKeybindings.FormatAcceleratorPath(acceleratorPath); keybindingLabel = new Label(display); keybindingLabel.UseUnderline = false; keybindingLabel.Xalign = 1.0f; keybindingLabel.Show(); newChild.PackStart(keybindingLabel); } // Lay out the contents in the HBox. newChild.Show(); // Remove the old child item and add this. Remove(Child); Add(newChild); // Figure out if we have an icon. if (!String.IsNullOrEmpty(action.StockId)) { IconSet iconSet = Style.LookupIconSet(action.StockId); Pixbuf image = iconSet.RenderIcon( Style, DefaultDirection, State, IconSize.Menu, this, null); var iconImage = new Image(image); Image = iconImage; } }