~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to unity/Config.py

  • Committer: Jason Conti
  • Date: 2011-04-25 20:05:41 UTC
  • Revision ID: jason.conti@gmail.com-20110425200541-fsnj07k0ydlhovsw
Added theme support. User themes are stored in ~/.config/recent-notifications/themes/, see themes/default for the proper format. The desired theme is set with the theme property in ~/.config/recent-notifications/preferences. Still need to add support for acquiring the colors from the system gtk theme.

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
    except:
123
123
      return default
124
124
 
125
 
  def set(self, key, value):
 
125
  def set(self, key, value, autosave = True):
126
126
    """Sets the value for the given key, saves the config file and notifies any
127
 
    listeners that the value has changed."""
 
127
    listeners that the value has changed. If autosave is True, the config file
 
128
    will be saved after the value is set."""
128
129
    if not (isinstance(key, str) or isinstance(key, unicode)):
129
130
      raise ConfigException("Trying to set a non-string key: {0} = {1}".format(key, value))
130
131
 
134
135
 
135
136
    with self._lock:
136
137
      self._options[key] = value
137
 
      self.save()
 
138
      if autosave:
 
139
        self.save()
138
140
    self.emit("value-changed", key, value)
139
141
 
140
 
  def set_if_unset(self, key, value):
 
142
  def set_if_unset(self, key, value, autosave = True):
141
143
    """Calls set(key, value) only if the key does not exist in this config."""
142
144
    if key not in self._options:
143
 
      self.set(key, value)
 
145
      self.set(key, value, autosave)
144
146