Public bug reported:

Quite a few screenlets use theme.conf to set different settings like 
'text_color' which can then be customised by the user.
eg: AppMenu, Clock, DiskSpace, FeedReader, and Output screenlets all use these 
theme options overrides, from a quick look, there are probably many more.

But on reload, any option saved before the theme_name (in the unordered
dictionary) will be overridden by the theme options.


To reproduce this bug: If I set the shadow colour of the 'Output' screenlet and 
reload it, the shadow_color doesn't get saved, but all other colours are.

my 'Output1.ini' looks like this:

        opacity=1.0
        shadow_color=0.00000,0.00000,0.00000,0.00000
        scale=1.0
        run=dmesg
        theme_name=default
        is_sticky=False
        frame_color=0.00000,0.00000,0.00000,0.00000
        h=404
        is_widget=True
        text_color=0.08443,0.89517,0.09575,0.83922
        width=380
        iner_frame_color=0.00000,0.00000,0.00000,0.00000
        keep_above=False
        is_dragged=False
        w=380
        keep_below=True
        y=34
        x=986
        skip_taskbar=True
        height=404


My fix is:

'session.py' from line 422 in '__restore_options_from_backend'

replace:

                if opts:
                        for o in opts:
                                # get the attribute's Option-object from 
Screenlet
                                opt = screenlet.get_option_by_name(o)
                                # NOTE: set attribute in Screenlet by calling 
the
                                # on_import-function for the Option (to import
                                # the value as the required type)
                                if opt:
                                        setattr(screenlet, opt.name, 
opt.on_import(opts[o]))

with:

                if opts:
                    #theme must be read in first so the user's options are not 
overridden
                    for o in opts:
                        opt = screenlet.get_option_by_name(o)
                        if opt and opt.name=="theme_name":
                            setattr(screenlet, opt.name, opt.on_import(opts[o]))
                    
                        for o in opts:
                                # get the attribute's Option-object from 
Screenlet
                                opt = screenlet.get_option_by_name(o)
                                # NOTE: set attribute in Screenlet by calling 
the
                                # on_import-function for the Option (to import
                                # the value as the required type)
                                if opt and opt.name!="theme_name":
                                        setattr(screenlet, opt.name, 
opt.on_import(opts[o]))


There is probably also a cleaner way to do this, my python is rusty :p

** Affects: screenlets
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of
Screenlets Dev Team, which is subscribed to Screenlets.
https://bugs.launchpad.net/bugs/1024847

Title:
  Patch: Screenlets randomly overrides options with theme default on
  reload.

To manage notifications about this bug go to:
https://bugs.launchpad.net/screenlets/+bug/1024847/+subscriptions

_______________________________________________
Mailing list: https://launchpad.net/~screenlets-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~screenlets-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to