void Update(CommandInfo cmdInfo) { lastCmdInfo = cmdInfo; updating = true; if (Active != cmdInfo.Checked) { Active = cmdInfo.Checked; } updating = false; //same as CommandToolButton //only update each if changed, else we grab focus from tooltips during the command scane if (lastDesc != cmdInfo.Description) { string toolTip; if (string.IsNullOrEmpty(cmdInfo.AccelKey)) { toolTip = cmdInfo.Description; } else { toolTip = cmdInfo.Description + " (" + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, false) + ")"; } TooltipText = toolTip; lastDesc = cmdInfo.Description; } if (Label != cmdInfo.Text) { Label = cmdInfo.Text; } if (cmdInfo.Icon != stockId) { stockId = cmdInfo.Icon; this.IconWidget = iconWidget = new ImageView(cmdInfo.Icon, Gtk.IconSize.Menu); } if (IconWidget != null && cmdInfo.Enabled != Sensitive) { iconWidget.Image = iconWidget.Image.WithStyles(cmdInfo.Enabled ? "" : "disabled").WithAlpha(cmdInfo.Enabled ? 1.0 : 0.4); } if (cmdInfo.Enabled != Sensitive) { Sensitive = cmdInfo.Enabled; } if (cmdInfo.Visible != Visible) { Visible = cmdInfo.Visible; } if (cmdInfo.Icon.IsNull) { IsImportant = true; } }
void Update(CommandInfo cmdInfo) { lastCmdInfo = cmdInfo; if (lastDesc != cmdInfo.Description) { string toolTip; if (string.IsNullOrEmpty(cmdInfo.AccelKey)) { toolTip = cmdInfo.Description; } else { toolTip = cmdInfo.Description + " (" + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, false) + ")"; } TooltipText = toolTip; lastDesc = cmdInfo.Description; } if (Label != cmdInfo.Text) { Label = cmdInfo.Text; } if (cmdInfo.Icon != stockId) { stockId = cmdInfo.Icon; this.IconWidget = iconWidget = new ImageView(cmdInfo.Icon, Gtk.IconSize.Menu); } if (IconWidget != null && cmdInfo.Enabled != Sensitive) { iconWidget.Image = iconWidget.Image.WithStyles(cmdInfo.Enabled ? "" : "disabled").WithAlpha(cmdInfo.Enabled ? 1.0 : 0.4); } if (cmdInfo.Enabled != Sensitive) { Sensitive = cmdInfo.Enabled; } if (cmdInfo.Visible != Visible) { Visible = cmdInfo.Visible; } if (cmdInfo.Icon.IsNull) { IsImportant = true; } }
void Update(CommandInfo cmdInfo) { if (lastDesc != cmdInfo.Description) { string toolTip; if (string.IsNullOrEmpty(cmdInfo.AccelKey)) { toolTip = cmdInfo.Description; } else { toolTip = cmdInfo.Description + " (" + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, false) + ")"; } TooltipText = toolTip; lastDesc = cmdInfo.Description; } if (Label != cmdInfo.Text) { Label = cmdInfo.Text; } if (cmdInfo.Icon != stockId) { stockId = cmdInfo.Icon; this.IconWidget = new Gtk.Image(cmdInfo.Icon, Gtk.IconSize.Menu); } if (cmdInfo.Enabled != Sensitive) { Sensitive = cmdInfo.Enabled; } if (cmdInfo.Visible != Visible) { Visible = cmdInfo.Visible; } if (cmdInfo.Icon.IsNull) { IsImportant = true; } }
void Update(CommandInfo cmdInfo) { if (lastCmdInfo != null) { lastCmdInfo.CancelAsyncUpdate(); lastCmdInfo.Changed -= CommandInfoChanged; } lastCmdInfo = cmdInfo; lastCmdInfo.Changed += CommandInfoChanged; if (isArray && !isArrayItem) { this.Visible = false; Gtk.Menu menu = (Gtk.Menu)Parent; if (itemArray != null) { foreach (Gtk.MenuItem item in itemArray) { menu.Remove(item); } } itemArray = new ArrayList(); int i = Array.IndexOf(menu.Children, this); if (cmdInfo.ArrayInfo != null) { foreach (CommandInfo info in cmdInfo.ArrayInfo) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem(); item.Show(); } else { item = CommandEntry.CreateMenuItem(commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem)item; mi.SetUpdateInfo(info, initialTarget); } menu.Insert(item, ++i); itemArray.Add(item); } } } else { Gtk.Widget child = Child; if (child == null) { return; } Gtk.Label accel_label = null; Gtk.Label label = null; if (!(child is Gtk.HBox)) { child = new Gtk.HBox(false, 0); accel_label = new Gtk.Label(""); accel_label.UseUnderline = false; accel_label.Xalign = 1.0f; accel_label.Show(); label = new Gtk.Label(""); label.UseUnderline = true; label.Xalign = 0.0f; label.Show(); ((Gtk.Box)child).PackStart(label); ((Gtk.Box)child).PackStart(accel_label); child.Show(); this.Remove(Child); this.Add(child); } else { accel_label = (Gtk.Label)((Gtk.Box)child).Children[1]; label = (Gtk.Label)((Gtk.Box)child).Children[0]; } if (cmdInfo.AccelKey != null) { accel_label.Text = " " + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, true); } else { accel_label.Text = String.Empty; } if (cmdInfo.UseMarkup) { label.Markup = overrideLabel ?? cmdInfo.Text; label.UseMarkup = true; } else { label.Text = overrideLabel ?? cmdInfo.Text; label.UseMarkup = false; } if (!string.IsNullOrEmpty(cmdInfo.Description) && label.TooltipText != cmdInfo.Description) { label.TooltipText = cmdInfo.Description; } label.UseUnderline = true; this.Sensitive = cmdInfo.Enabled; this.Visible = cmdInfo.Visible && (disabledVisible || cmdInfo.Enabled); if (!cmdInfo.Icon.IsNull && cmdInfo.Icon != lastIcon) { Image = new ImageView(cmdInfo.Icon, Gtk.IconSize.Menu); lastIcon = cmdInfo.Icon; } if (cmdInfo is CommandInfoSet) { CommandInfoSet ciset = (CommandInfoSet)cmdInfo; Gtk.Menu smenu = new Gtk.Menu(); Submenu = smenu; foreach (CommandInfo info in ciset.CommandInfos) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem(); item.Show(); } else { item = CommandEntry.CreateMenuItem(commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem)item; mi.SetUpdateInfo(info, initialTarget); } smenu.Add(item); } } } }
void Update(CommandInfo cmdInfo) { lastCmdInfo = cmdInfo; Gtk.Widget child = Child; if (child == null) { return; } updating = true; Gtk.Label accel_label = null; Gtk.Label label = null; if (!(child is Gtk.HBox)) { child = new Gtk.HBox(false, 0); accel_label = new Gtk.Label(""); accel_label.UseUnderline = false; accel_label.Xalign = 1.0f; accel_label.Show(); label = new Gtk.Label(""); label.UseUnderline = true; label.Xalign = 0.0f; label.Show(); ((Gtk.Box)child).PackStart(label); ((Gtk.Box)child).PackStart(accel_label); child.Show(); this.Remove(Child); this.Add(child); } else { accel_label = (Gtk.Label)((Gtk.Box)child).Children[1]; label = (Gtk.Label)((Gtk.Box)child).Children[0]; } if (cmdInfo.AccelKey != null) { accel_label.Text = " " + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, true); } else { accel_label.Text = String.Empty; } if (cmdInfo.UseMarkup) { label.Markup = overrideLabel ?? cmdInfo.Text; label.UseMarkup = true; } else { label.Text = overrideLabel ?? cmdInfo.Text; label.UseMarkup = false; } label.UseUnderline = true; Sensitive = cmdInfo.Enabled; Visible = cmdInfo.Visible && (disabledVisible || cmdInfo.Enabled); Active = cmdInfo.Checked; Inconsistent = cmdInfo.CheckedInconsistent; updating = false; }