cairoshell icon indicating copy to clipboard operation
cairoshell copied to clipboard

Cairo Extensibility

Open mitchellurgero opened this issue 7 years ago • 29 comments

Does Cairoshell have a module or plugin system? I'd love to develop some "native" apps for it :)

mitchellurgero avatar Feb 12 '18 15:02 mitchellurgero

A plugin system for Cairo is on the roadmap but is not yet implemented. Feel free to help out if you'd like!

dremin avatar Feb 12 '18 18:02 dremin

hmm I'll fork the code and see what I can come up with! At the very least, there needs to be, I think, some type of CairoApp framework. I think that would be awesome!

mitchellurgero avatar Feb 12 '18 19:02 mitchellurgero

I know @josuave has thought about ways to implement this in the past so hopefully he has some input. A good starting point would be the ability to host plugins inside the menu bar (a la menu extras on macOS). We would also need a way for the plugin to be able to inherit Cairo themes and common functionality.

dremin avatar Feb 12 '18 20:02 dremin

I have an idea on how, the issue is modifying the current code to call "plugin xyz" when it needs to, or display different things, etc.

mitchellurgero avatar Feb 12 '18 20:02 mitchellurgero

I will see if I can get some code posted in my fork. I was toying with a provider-based plugin system and a WindowsShell-object-model to apply to Cairo. Let me know if you want to discuss further

josuave avatar Feb 12 '18 23:02 josuave

+1 for this, should be very high priority. I would love to write plugins to display special things in the menu bar for example. I don't enable notification icons so I have a ton of empty space I'd like to make use of.

oxysoft avatar Apr 14 '18 00:04 oxysoft

This is now possible in my fork of cairoshell. I have added a plugin system and a simple object model/extension point for the PlacesMenu

josuave avatar Apr 15 '18 04:04 josuave

Submit a merge request then!

mitchellurgero avatar Apr 15 '18 13:04 mitchellurgero

@josuave Awesome, please submit a pull request when your code is ready!

dremin avatar Apr 15 '18 16:04 dremin

Will do, gotta figure out how

josuave avatar Apr 15 '18 17:04 josuave

@josuave - With the forked repo, go into "Pull Request" and select "Create" then answer a couple simple questions :)

mitchellurgero avatar Apr 15 '18 17:04 mitchellurgero

@josuave Thanks, I've merged the changes. I hope we can use this foundation throughout Cairo to improve extensibility and use the logging system for the entire app. I did run into one issue, for plugins that modify the UI like the Places menu, we need to find a way to dynamically instantiate the UI objects multiple times, since currently this won't work with multiple monitor support enabled.

dremin avatar Apr 16 '18 01:04 dremin

This would be best achieved by putting focus on a more robust object model, my next goal! The sample I made could be modified to loop over the screens/menubars and create an entry in all of the “Places” instances

josuave avatar Apr 16 '18 01:04 josuave

I will also build a couple more plugins to demonstrate how plugin dependencies work.

josuave avatar Apr 16 '18 01:04 josuave

Sounds good! I did just commit a few tweaks to the build configuration and some other minor items.

dremin avatar Apr 16 '18 02:04 dremin

@josuave is it possible for plugins to be in a subfolder? Would clean things up and prevent needing to handle some exceptions with non-managed DLLs.

dremin avatar Apr 22 '18 23:04 dremin

I’ll take a look at this tomorrow.

josuave avatar Apr 23 '18 03:04 josuave

I am looking into a simpler plugin mechanism. I have been toying with using MEF for plugins and NuGet for distribution/management. This is a cool idea as it provides a possibility for a Cairo Store in the future

josuave avatar Apr 25 '18 22:04 josuave

I have stopped the exceptions with unmanaged dlls. I can keep the current plugin implementation and use an assembly naming pattern “CairoDesktop.Plugins.*” or I can replace it using MEF. This should be simpler and should solve a lot of the dependency issues while loading assemblies from alternate locations. Let me know what you think and I will keep investigating

josuave avatar Apr 28 '18 01:04 josuave

Would be cool to combine MEF with nuget. You don't need to restrict package names -- instead you can specify a tag like cairo-desktop-plugin in your plugin package.

One tricky thing about the dependencies -- nuget packages are multi-targeting, so you cannot just go grab all the dlls and load them -- you'll end up loading duplicated assemblies for different RID, say linux or osx, or different TFM, say netcoreapp and net47.

Also, the plugins may have conflicting dependencies. Not to mention that some deps probably have custom build actions that doesn't look like anything in the nuget package itself..

I think the best way to solve these problems is to actually put all the plugins into a C# project, nuget restore and build it, then get the artifacts from the bin dir -- if everything goes well you should have all the dependencies properly put together in a shallow directory.

btw this is possible because msbuild is always available where cairoshell runs.

yatli avatar Dec 02 '20 17:12 yatli

For anyone interested, the relevant context: https://github.com/cairoshell/cairoshell/blob/ec7693eab176d803551d7f92f4ab8538711e7fb3/Cairo%20Desktop/Cairo%20Desktop/Services/PluginService.cs

yatli avatar Dec 02 '20 17:12 yatli

This is actually something we have discussed internally. ideally cairo would be able to search a repo for available packages. This is a long term goal and not currently on any active to-dos. We are activly undergoing a large refactoring that should make plugin development a bit easier going forward

josuave avatar Dec 02 '20 17:12 josuave

Cool, thanks for the heads up. When everything stablizes down I'd like to implement a window manager-ish thing.

yatli avatar Dec 02 '20 18:12 yatli

I have been thinking about long term as well, and was thinking maybe another option would be to deliver it, via a catalogue, manifest, or database. This is linked to a REST API (json response) backend, that will return relevant info, and/or extension plugins.

The backend would enable rating and giving feedback, posting screenshots, providing changelogs for info.

MrGrymReaper avatar Jul 06 '21 15:07 MrGrymReaper

I noticed this issue and some things relating to extensions for the menubar. How exactly does this work? I can't find anything related to actually making an extension for the menubar.

ashifolfi avatar Feb 25 '22 13:02 ashifolfi

I noticed this issue and some things relating to extensions for the menubar. How exactly does this work? I can't find anything related to actually making an extension for the menubar.

We have an samples repo, here: https://github.com/cairoshell/CairoExtensionSamples

Cairo is in need of many more extension points. Feel free to check everything out, make any suggestions, contributions or ask questions.

josuave avatar Feb 25 '22 13:02 josuave

I'm currently trying to make a plugin but I can't seem to get it to build. It just fails with The name 'InitializeComponent' does not exist in the current context whenever I try to build it.

I've attached the contents of the plugin folder as a zip. Could I get some help on what I'm doing wrong?

CCenter.zip

ashifolfi avatar Feb 25 '22 17:02 ashifolfi

@ashifolfi Did you get anywhere with your issue?

josuave avatar Mar 01 '22 15:03 josuave

no I still haven't figured it out

ashifolfi avatar Mar 01 '22 18:03 ashifolfi