GNOME Bugzilla – Bug 345395
Extension support
Last modified: 2007-04-09 18:50:12 UTC
This is an enhancement proposal for plug-ins feature in F-Spot. the request was originally here: "The export code should be broken down into modules and made pluggable." in http://www.f-spot.org/To_Do
Created attachment 67681 [details] [review] plugins patch v1 A first plugin patch, creating both Plugin and ExportPlugin abstract classes. A Plugger is responsible of loading (as for now) all Plugins in all the .dll in $HOME/.gnome2/f-spot/plugins/ This patch also include a new export menu (File>Export>Export plugins) to access all the ExportPlugins. This patch also include Thomas's solution for bug #344534 I'm waiting for your comments !
Created attachment 67682 [details] DialogPlugin.cs v1 A dummy plugin, derived from Plugin, which pop-up a new message dialog. compile it this way: mcs -target:library -pkg:f-spot -pkg:gnome-sharp-2.0 DialogPlugin.cs and copy the dll in .gnome2/f-spot/plugins/
Created attachment 67683 [details] SendMailPlugin.cs v1 The first real plugin ever ! This one re-implement the "Send Mail..." capability in a plug-in. compile it this way: mcs -target:library -pkg:f-spot -pkg:gnome-sharp-2.0 SendMailPlugin.cs and copy the dll in .gnome2/f-spot/plugins/
haha, nice :)
Created attachment 67904 [details] [review] plugins patch v2 small update: check for all available plug-ins, but only load the ones defined in GConf. as usual, I'm waiting for comments ...
Created attachment 69660 [details] [review] plugin, v3 A brand new version of the plugin patch. This one was re-written from scratch with an eye at the plugin implementation of banshee. The previous plugin proposed probably won't work anymore, but I have 2 new ones for your tests. This patch does not contains (yet) the hooks for the ExportPlugins
about comment #6: the patch proposed contains also the solution proposed for bug #344534
Created attachment 69662 [details] a dummy plugin This is a dummyplugin that does nothing, but does it well !! compile it with mcs -target:library -pkg:f-spot DummyPlugin.cs
Created attachment 69663 [details] a plugin to define a user-directory for plugins 2 things I forgot to say... *) as for now (but it's marked FIXME in the code), plugins are loaded from /usr/local/lib/f-spot/plugins *) plugins will be discovered at first run. after that, you can activate them with gconf-editor (the dialog is not yet written) this proposed plugin(once activated) extends the scan directories to ~/.gnome2/f-spot/plugins nice, no ? it's like a meta-plugin
Created attachment 69721 [details] [review] plugin, v4 An updated version of the plugin patch. Major Changes: - Plugin.Preferences to handle plugin preferences - PluginCore.Reload() enhanced and made ThreadSafe (just in case) - removed the IPlugin interface - Plugin.Category is not an enum - new abstract class ExportPlugin. No hooks yet in the FSpot code. the 2 proposed plugin will still compile if you change this: public override PluginCategory Category { get { return PluginCategory.Misc; } } I'm currently writing a plugin dialog implemented as a plugin. it's quicker to compile and test ;)
if some of you are already in the mood of playing with plugins, here's 2 tips: To enable your plugin automatically AT THE FIRST TIME, do this in the constructor: public DummyPlugin () : base() { //This will enable this plugin at first load Preferences.Get("Enabled",true); } To enable your plugin EVERYTIME f-spot is started, do that Preferences.Set("Enabled", true);
Created attachment 69974 [details] [review] plugins, v5 lightly modified version, to keep you up-to-date
Created attachment 69975 [details] 3 plugins Those 3 plugins compile cleanly if you have f-spot + patch v5 installed. I packaged them as a .tar, so you have the Makefiles for free ;) included in this package: *)a DummyPlugin that does nothing *)a UserPluginDirectory plug-in that enable ~/.gnome2/f-spot/plugins as alternate repository for plugins *)a PluginDialog plug-in for enabling and disabling plug-ins at will enjoy, test and report
This is looking great, Stephane. Is this all your original code or are you borrowing from Banshee? A plugin system is a huge win for F-Spot - so many more people will be able to develop their pet feature (see Banshee!).
Gabriel, versions 1 and 2 were original code, only looking at the interface for *writing* provided by Banshee. Attempt 3 was a compelete rewrite, borrowed from banshee (but not copy-pasted, never use copy-paste to produce production code;) ). It's fun to see that there's no big difference in functionalities between the original code and the borrrowed one. The old man ones said 'the interface defines the implementation' :) version 4 and 5 are no longer in sync with the banshee code, with a lot of new stuffs, threading safety for the factory, Preferences inner class for plugins, ...
if you want to try the latest version, I forgot to include the f-spot.pc.in file from bug #344534. So get it by yourself. Hope I'will not forget it in the next patch...
Hi, I have been experimenting with the plugin patch but have not been totally successfull and thought you may be able to point out where I have gone wrong. I applied the V5 and f-spot.pc.in patches to the current CVS version and built and installed it successfully to my unstable folder. I created the /usr/local/lib/f-spot/plugins folder and gave myself permissions. The new f-spot then ran fine. I downloaded the plugins tar and extracted it and built the Dummy plugin (Having sorted the enviroment variable for the packages). I copied the DLL to the /usr/local/lib/f-spot/plugins folder. Ran f-spot, and then used gconf-editor to enable the plugin. However I can find no reference in f-spot to the plugin or how they are executed. Should it appear on the main menu, context menu or have I got the wrong end of the stick alltogether? Thanks Kevin
As for the v5 of plugins, plugins are loaded and instanciated at the first stages of f-spot (you can see lines about that in the console). There's no hooks in that release to add a plugin action to a menu or a photo. Did you see the plugin selection dialog at startup ? If no, there's something wrong... I worked this w-e on a new version, with this time hooks for export plugins and a first small export plugin and will post it today to this thread.
Created attachment 72187 [details] [review] plugins, v6 This one adds the required hooks to have ExportPlugins working. It includes bug #344534.
Created attachment 72188 [details] 4 plugins The same 3 plus a *working* SendMailPlugin
(In reply to comment #18) > Did you see the plugin selection dialog at startup ? If no, there's something > wrong... > Hi, My mistake, I had only copied the dummyplugin and did not notice its output. All seems to be working now, will give v6 a go.
Just tried V6 patch and everything compiled and ran OK. I built the new plugins and all registered fine. The export photo by email ran fine for me.
Created attachment 72243 [details] [review] plugins, v7 This version introduce a new main menu entry for managing plugins. Check the screenshot here: http://picasaweb.google.com/sdelcroix/FSpot/photo#4970895439610839058
Created attachment 72244 [details] 4 plugins, updated The plugindialog plugin no longer pop up at startup but handle events from the main menu entry to shows up. Again, check the previous screenshot.
Created attachment 72275 [details] Plugin for export to CD I thought I would have a play with the plugins and modified the DummyPlugin to wrap the CDExport routine. It dosn't do anything clever but thought I would include incase is any use. Only tested against V6 so far.
Created attachment 72646 [details] MonoDevelop project for DummyPlugin I have been playing with the plugin code in MonoDevelop and created a project file for the dummyplugin. As there has been some talk about MonoDevelop I thought I would upload it. If you use this you will need to change the reference for f-spot.exe from /home/kevin/development/f-spot/f-spot/src to whever you have your patched version built. Also you will have to manually install the dll in the bin/debug folder into ~/.gnome2/f-spot/plugins once built.
changed the name. was 'Plug-in support'. is now 'Extension support'
Created attachment 72790 [details] [review] extension, v8 A new version of the thing proviously known as the plugin patch: here's the extension patch ! What's new: - replaced plugin with extension in the source and the ui - add versions to extensions - some other things, try it as usual, this patch also contains the patch from bug #344534 Use it with the latest set of released extensions
Created attachment 72792 [details] 4 extensions this tar contain 4 extensions, the same as usual. Use them with the v8 of the extension patch. WARNING! the ExtensionDialog is not really working now ! I'll try to fix it asap
Why not keep this as close to banshee's implementation as possible? And why exactly is "Extension" a better name for a plugin than "Plugin"?
Michael, this implementation is relatively close to the banshee one. But as we don't have the same needs as banshee, we can't use exactly the same implementation. Calling them extension is a more generic way to express this, having activable parts of the code, provided as plugins or even built-in. But obviously, we can discuss all that.
Hi, I have been trying the new patch and extensions but have had some problems building the extensions. The output is below. make make all-recursive make[1]: Entering directory `/home/kevin/development/f-spot-plugins/v8/extensions' Making all in DummyExtension make[2]: Entering directory `/home/kevin/development/f-spot-plugins/v8/extensions/DummyExtension' mcs -target:library -pkg:f-spot DummyExtension.cs DummyExtension.cs(8,31): error CS0234: The type or namespace name `Extension' does not exist in the namespace `FSpot.Extensions'. Are you missing an assembly reference? Compilation failed: 1 error(s), 0 warnings make[2]: *** [DummyExtension.dll] Error 1 make[2]: Leaving directory `/home/kevin/development/f-spot-plugins/v8/extensions/DummyExtension' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/kevin/development/f-spot-plugins/v8/extensions' make: *** [all] Error 2
you probably did'nt 'make install' f-spot patched with the new extension
Created attachment 73105 [details] 5 extensions this time with a brand new plugin, best described by this screenshot: http://picasaweb.google.com/sdelcroix/FSpot/photo#4976917558906978322
*** Bug 344427 has been marked as a duplicate of this bug. ***
I have been trying this patch against the current CVS and have a few comments to report. Firstly the patch appeared to apply ok but with a bit of fuzz. Error I believe is just the changelog. Hunk #1 FAILED at 1. Hunk #2 succeeded at 457 (offset 378 lines). 1 out of 2 hunks FAILED -- saving rejects to file ChangeLog.rej patching file Makefile.am patching file configure.in Hunk #1 succeeded at 192 with fuzz 1 (offset -1 lines). patching file src/Global.cs patching file src/MainWindow.cs Hunk #1 succeeded at 67 (offset 2 lines). Hunk #2 succeeded at 118 with fuzz 1 (offset 10 lines). Hunk #3 succeeded at 201 with fuzz 1 (offset 17 lines). Hunk #4 succeeded at 404 (offset 19 lines). Hunk #5 succeeded at 691 (offset 20 lines). Hunk #6 succeeded at 2695 (offset 149 lines). patching file src/Makefile.am patching file src/Preferences.cs patching file src/f-spot.glade Hunk #1 succeeded at 8451 (offset 2 lines). Hunk #2 succeeded at 8659 (offset 2 lines). Hunk #3 succeeded at 8825 (offset 2 lines). Hunk #4 succeeded at 14621 (offset 58 lines). patching file f-spot.pc.in patching file src/ExportExtension.cs patching file src/ExportMenu.cs patching file src/Extension.cs patching file src/ExtensionCore.cs patching file src/ExtensionFactory.cs The patched version built and installed without issue. Everything ran fine except for one instance that result in a lockup. In this instance no error was reported to the terminal and I have not been able to reproduce. I beleive it may have been as I quickly selected an image before the program had finnished loading. I have had some issues with the plugins which I will report seperately but this patch seems to work fine.
When testing the 5 pack of extensions I came accoss a problem with the installer. The plugins built fine and installed the extension in /usr/local/lib/extensions however the extensions configuration remained greyed out and there was no export plugins available. The plugin mentioned above reported to the console when loaded. The installer appeared to install a file in ~/.gnome2/f-spot called extensions. Looking at the old plugin behaviour of creating a folder there call plugins containing the files, I deleted the extensions file and created an extensions folder. Rerunning the make install for the extensions populated this folder and rerunning f-spot allow the extensions to be configured and an export to email option was available. One other observation, after enabling the export plugin in Edit->Extensions the File->Export still showed no extentions until a new image was selected. Everything now operates as expected.
Hi, I do have a question regarding the extension-support. If I am writing an extension, is there right now a possibility to add a menu item (like it has been done in ExtensionDialog) without editing the MainWindows.cs? Best Regards, Fabian Schwahn
Fabian (comment #38): no, not yet. Except for ExportExtensions (File>Export>...) The main focus is now on the ExportExtensions, but we'll probably add others in the future
Created attachment 74840 [details] Extension to export to zip I have had a go at producing an export to zip extension. This is heavily based on Bug 321298 and the dummy extension but does not implement the file size reduction. It is not very pretty but any comments gratefully received.
can someone post the right procedure to test the patch? I feel a little stupid but I can't do it right :)
maxxer, patch the code with the attachment 72790 [details] [review], compile and install get the extensions from attachment 73105 [details], compile and install start f-spot I'll try to write a wiki page soon... if you still have installation issues, ask on the mailing list
The patch do not apply cleanly anymore f-spot.Plugins$ patch -p0 < /home/bengt/Desktop/extensions.v8.patch patching file ChangeLog Hunk #1 FAILED at 1. Hunk #2 succeeded at 788 (offset 709 lines). 1 out of 2 hunks FAILED -- saving rejects to file ChangeLog.rej patching file Makefile.am Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] Skipping patch. 2 out of 2 hunks ignored -- saving rejects to file Makefile.am.rej patching file configure.in Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] Skipping patch. 1 out of 1 hunk ignored -- saving rejects to file configure.in.rej patching file src/Global.cs patching file src/MainWindow.cs Hunk #1 succeeded at 67 (offset 2 lines). Hunk #2 succeeded at 117 with fuzz 1 (offset 9 lines). Hunk #3 succeeded at 196 (offset 12 lines). Hunk #4 succeeded at 405 (offset 20 lines). Hunk #5 succeeded at 693 (offset 22 lines). Hunk #6 succeeded at 2711 (offset 165 lines). patching file src/Makefile.am patching file src/Preferences.cs Hunk #1 succeeded at 96 (offset 6 lines). patching file src/f-spot.glade Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] Skipping patch. 4 out of 4 hunks ignored -- saving rejects to file src/f-spot.glade.rej The next patch would create the file f-spot.pc.in, which already exists! Assume -R? [n] Apply anyway? [n] Skipping patch. 1 out of 1 hunk ignored -- saving rejects to file f-spot.pc.in.rej patching file src/ExportExtension.cs patching file src/ExportMenu.cs patching file src/Extension.cs patching file src/ExtensionCore.cs patching file src/ExtensionFactory.cs f-spot.Plugins$ Also seems to have some problems with the extensions... Then again, I probably missed something.. f-spot.Plugins/extensions$ PKG_CONFIG_PATH=/home/bengt/development/f-spot/f-spot.Plugins/; make make all-recursive make[1]: Entering directory `/home/bengt/development/f-spot/f-spot.Plugins/extensions' Making all in DummyExtension make[2]: Entering directory `/home/bengt/development/f-spot/f-spot.Plugins/extensions/DummyExtension' mcs -target:library -pkg:f-spot DummyExtension.cs DummyExtension.cs(8,31): error CS0234: The type or namespace name `Extension' does not exist in the namespace `FSpot.Extensions'. Are you missing an assembly reference? Compilation failed: 1 error(s), 0 warnings make[2]: *** [DummyExtension.dll] Error 1 make[2]: Leaving directory `/home/bengt/development/f-spot/f-spot.Plugins/extensions/DummyExtension' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/bengt/development/f-spot/f-spot.Plugins/extensions' make: *** [all] Error 2
I experienced the same. That's why I asked for the right way to do it, I wasn't able to build but since I saw many successful tries I thought I was my fault :)
sorry maxxer, I thought that you needed help to use it... I'll try to fix this asap... don't hesitate to remind me by email if it takes too long
make install :) :) :) Always forget to do it :( anyway, after doing make install (on patched f-spot), I can compile the extensions.
I couldn't compile extensions even after make install. I followed the How_To_Test_A_Patch page. I'll wait for Stephane's fixes, then I'll try again. thanks
As per Stephanes request: (21:48:00) John H.: please report those 2 bugs (21:48:20) John H.: "default extension folder should be created at install time" (21:48:43) John H.: and "handle exception if f-spot can't find the extension folders"
In addition. make install must ensure that ~/.gnome2/f-spot/extensions exists, and if not, create it. If it exists as a file, exit with a error code. As it is now, all the extension.dll is copied to a file extensions, and same for all the other dll's
Mono.Addins is now used as Extension backend. Enabled for exports in trunk.