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

Bug #1024847 reported by LukePH
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Screenlets
Fix Committed
Undecided
Unassigned

Bug Description

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

Related branches

Revision history for this message
Märt Põder (boamaod) wrote :

Can you use Bazaar in Launchpad? It would be okay, if you implemented the corrections yourself... If you don't want to do that, hopefully someone else will... Please let us know, how you feel about it.

Märt Põder (boamaod)
Changed in screenlets:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.