3 Replies Latest reply on May 22, 2009 9:31 PM by DawMatt

    Preferences for non-export plugins

    DawMatt Level 3

      Hi All,

       

      I'm working on a plugin that will have an LrExportMenuItems entry, but is not an export service or filter.  As such the typical exportPresetFields entry that would allow me to automatically load and save plugin preferences doesn't seem to be an option for me.  But I do need to maintain state informatoin (preferences) across invocations of the plugin.

       

      I've tried using "import 'LrPrefs'.prefsForPlugin()" to access preferences and then write changes back to the variable I save that value in (including rewriting some values to trigger the save).  LrPrefs doco in the SDK implies you can save preferences using this approach.  In most languages that wouldn't work but given the nature of LUA there was a chance.  Unfortunately this hasn't worked so far and I think it is because there is no export service or filter defined in this plugin.

       

      Has anyone managed to easily save preferences for non-export plugins into the lightroom preferences file?  If not, what alternative approaches have people used to save state across invocations of your plugins?

       

      Thanks,

      Matt

       

      PS Sean, John, in case your wondering a firewall was stopping the WYSIWIG editor from loading.  Killed the firewall and now I can post here and create new threads.  Stupid corporate laptop SOEs...

        • 1. Re: Preferences for non-export plugins
          escouten Adobe Employee

          This sounds like a bug. Not sure from the description if it's your bug or mine.

           

          Can you either post a code snippet or send one to me (scouten@adobe.com)?

          • 2. Re: Preferences for non-export plugins
            DawMatt Level 3

            Hi Eric,

             

            Thanks for the response.  I've emailed you the current code tor the plugin along with a walk thru of how the issues manifests itself in that code.

             

            It is possible its a bug with my code and in a way I hope it is because that would be easy to fix.  But AFAIK I'm using the SDK in the way it was intended.  And I do have other plugins (primarily export filters) that do manage to store preferences correctly so I've been using their code as a baseline.

             

            Thanks,

            Matt

            • 3. Re: Preferences for non-export plugins
              DawMatt Level 3

              Hi,

               

              For those who are interested, Eric managed to point out the bug in my code.

               

              exportPresetFields are only used with real export plugins.  As I was only creating menu items that approach wasn't appropriate. Unfortunately I copied a little too much code from a previous export plugin.

               

              prefs = import 'LrPrefs'.prefsForPlugin()

              prefs = {

               

               

                { key = 'catalogbackupdirlist', default = {} },

                { key = 'show1clickdialog', default = true },

              }

               

              What this now looks like is:

               

              prefs = import 'LrPrefs'.prefsForPlugin()

              prefs.catalogcompressdirlist = prefs.catalogbackupdirlist or {}
              if prefs.show1clickdialog == nil then
                  prefs.show1clickdialog = true
              end

               

              In the original code I tried to set defaults using the exportPresetFields approach.  What this actually did was break the ability to load/store preferences in the configuration file.  Eric's suggestion allows me to set defaults without breaking the link to the preferences file.

               

              Thanks again Eric,

              Matt