Skip to content

GitPluginBase

Philippe Miossec edited this page Aug 23, 2019 · 4 revisions

GitPluginBase

Properties

public string Description { get; protected set; }

Name of the plugin, as it appears in Git Extensions' Plugins menu.


public string Name { get; protected set; }

Name of the plugin, as it is used in gitextensions.settings file.


public Image Icon { get; protected set; }

Icon of the plugin, as it appears in Git Extensions' Plugins menu.


public ISettingsSource Settings { get; }

Setting source that is used to read the values stored.

It must be passed to the ValueOrDefault() method of a ISetting instance to get the value of the setting.

ex: var isEnabled = _enabledSettings.ValueOrDefault(Settings);


public IGitPluginSettingsContainer SettingsContainer { get; set; }

For internal use. Should normally not be used.


Methods

public virtual void AddTranslationItems(ITranslation translation);

For internal use. Should normally not be used.


public abstract bool Execute(GitUIEventArgs args);

Is called when the plugin's name is clicked in Git Extensions' Plugins menu.

Must return true if the revision grid should be refreshed after the execution of the plugin. false, otherwise.

Help: You could call args.GitUICommands.StartSettingsDialog(this); in this method to open the setting page of the plugin.


public virtual IEnumerable<ISetting> GetSettings();

This is where you define the plugin setting page displayed in Git Extensions settings and that allows the user to configure the plugin settings.

You should return a collection of ISetting instances that could be of types:

  • BoolSetting to store a boolean (display a Checkbox control),
  • StringSetting to store a string (display a TextBox control),
  • NumberSetting to store a number (display a TextBox control),
  • ChoiceSetting to propose choices and store a string (display a ComboBox control),
  • PasswordSetting to store a password (display a password TextBox control),
  • CredentialsSetting to store a login and a password (display a login and a password fields),

See an example


public virtual void Register(IGitUICommands gitUiCommands);

Is called when the plugin is loaded. This happens every time when a repository is opened.


public virtual void TranslateItems(ITranslation translation);

For internal use. Should normally not be used.


public virtual void Unregister(IGitUICommands gitUiCommands);

Is called when the plugin is unloaded. This happens every time when a repository is closed through one of the following events:

  1. opening another repository
  2. returning to Dashboard (Repository > Close (go to Dashboard))
  3. closing Git Extensions

protected void SetNameAndDescription(string name);

Sets both the properties name and description to name.


protected void Translate();

Translate the plugin strings. Should be called in the constructor of the plugin.