have a look at WidgetUpdate method of WidgetController. It has the following lines:
//mark as active _widgetSettings.ActiveWidgetSystemNames.Add(widget.PluginDescriptor.SystemName); _settingService.SaveSetting(_widgetSettings);
There is the same methods for External authentication methods (MethodUpdate, ExternalAuthenticationController), Shipping providers (ProviderUpdate, ShippingController) etc, where you can find that setting you have to update to mark a plugin as active.