/// <summary> /// Register a new adjustment with Pinta, causing it to be added to the Adjustments menu. /// </summary> /// <param name="adjustment">The adjustment to register</param> /// <returns>The action created for this adjustment</returns> public void RegisterAdjustment(BaseEffect adjustment) { // Add icon to IconFactory Gtk.IconFactory fact = new Gtk.IconFactory(); ObsoleteExtensions.AddToIconFactory(fact, adjustment.Icon, new Gtk.IconSet(PintaCore.Resources.GetIcon(adjustment.Icon))); ObsoleteExtensions.AddDefaultToIconFactory(fact); // Create a gtk action for each adjustment var act = new Command(adjustment.GetType().Name, adjustment.Name + (adjustment.IsConfigurable ? Translations.GetString("...") : ""), string.Empty, adjustment.Icon); act.Activated += (o, args) => { PintaCore.LivePreview.Start(adjustment); }; PintaCore.Actions.Adjustments.Actions.Add(act); // If no key is specified, don't use an accelerated menu item if (adjustment.AdjustmentMenuKey is null) { PintaCore.Chrome.Application.AddAction(act); } else { PintaCore.Chrome.Application.AddAccelAction(act, adjustment.AdjustmentMenuKeyModifiers + adjustment.AdjustmentMenuKey); } PintaCore.Chrome.AdjustmentsMenu.AppendMenuItemSorted(act.CreateMenuItem()); adjustments.Add(adjustment, act); }
/// <summary> /// Register a new effect with Pinta, causing it to be added to the Effects menu. /// </summary> /// <param name="effect">The effect to register</param> /// <returns>The action created for this effect</returns> public void RegisterEffect(BaseEffect effect) { // Add icon to IconFactory Gtk.IconFactory fact = new Gtk.IconFactory(); ObsoleteExtensions.AddToIconFactory(fact, effect.Icon, new Gtk.IconSet(PintaCore.Resources.GetIcon(effect.Icon))); ObsoleteExtensions.AddDefaultToIconFactory(fact); // Create a gtk action and menu item for each effect var act = new Command(effect.GetType().Name, effect.Name + (effect.IsConfigurable ? Translations.GetString("...") : ""), string.Empty, effect.Icon); PintaCore.Chrome.Application.AddAction(act); act.Activated += (o, args) => { PintaCore.LivePreview.Start(effect); }; PintaCore.Actions.Effects.AddEffect(effect.EffectMenuCategory, act); effects.Add(effect, act); }