~nmu-sscheel/gtg/rework-task-editor

« back to all changes in this revision

Viewing changes to GTG/gtk/preferences.py

  • Committer: Bertrand Rousseau
  • Date: 2012-05-09 22:33:25 UTC
  • mfrom: (1178 trunk)
  • mto: This revision was merged to the branch mainline in revision 1179.
  • Revision ID: bertrand.rousseau@gmail.com-20120509223325-a53d8nwo0x9g93bc
Merge nimit branch and trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
  ]
36
36
 
37
37
# Default plugin information text
38
 
PLUGINS_DEFAULT_DESC = _("Click on a plugin to get a description here.")
 
38
PLUGINS_DEFAULT_DESC = _("Click on a plugin name to view its description here.")
39
39
 
40
40
# columns in PreferencesDialog.plugin_store
41
41
PLUGINS_COL_ID = 0
98
98
    elif modules and dbus:
99
99
        text = '\n'.join((GnomeConfig.bmiss2, modules, dbus))
100
100
    else:
101
 
        test = ""
 
101
        text = ""
102
102
    return text
103
103
 
104
104
def plugin_error_text(plugin):
150
150
          'plugin_depends': 'PluginDepends',
151
151
          'plugin_config_dialog': 'PluginConfigDialog',
152
152
          'pref_autostart': 'pref_autostart',
153
 
          'pref_show_preview': 'pref_show_preview'
 
153
          'pref_show_preview': 'pref_show_preview',
 
154
          'bg_color_enable': 'bg_color_enable',
154
155
          }
155
156
        for attr, widget in widgets.iteritems():
156
157
            setattr(self, attr, self.builder.get_object(widget))
157
158
        # keep a reference to the parent task browser
158
159
        self.pengine = PluginEngine()
159
160
        #plugin config initiation, if never used
160
 
        if self.config.has_key("plugins"):
161
 
            if self.config["plugins"].has_key("enabled") == False:
 
161
        if "plugins" in self.config:
 
162
            if "enabled" not in self.config["plugins"]:
162
163
                self.config["plugins"]["enabled"] = []
163
164
            
164
 
            if self.config["plugins"].has_key("disabled") == False:
 
165
            if "disabled" not in self.config["plugins"]:
165
166
                self.config["plugins"]["disabled"] = []
166
 
        else:
167
 
            if self.pengine.get_plugins():
168
 
                self.config["plugins"] = {}
169
 
                self.config["plugins"]["disabled"] = \
170
 
                  [p.module_name for p in self.pengine.get_plugins("disabled")]
171
 
                self.config["plugins"]["enabled"] = \
172
 
                  [p.module_name for p in self.pengine.get_plugins("enabled")]
 
167
        elif self.pengine.get_plugins():
 
168
            self.config["plugins"] = {}
 
169
            self.config["plugins"]["disabled"] = \
 
170
              [p.module_name for p in self.pengine.get_plugins("disabled")]
 
171
            self.config["plugins"]["enabled"] = \
 
172
              [p.module_name for p in self.pengine.get_plugins("enabled")]
173
173
        # initialize tree models
174
174
        self._init_backend_tree()
175
175
        # this can't happen yet, due to the order of things in
216
216
        autostart_path = os.path.join(self.__AUTOSTART_DIRECTORY, \
217
217
                                      self.__AUTOSTART_FILE)
218
218
        self.pref_autostart.set_active(os.path.isfile(autostart_path))
219
 
        #This set_active method doesn't even understand what a boolean is!
220
 
        #what a PITA !
221
 
        if self.config_priv.get("contents_preview_enable"):
222
 
            toset = 1
223
 
        else:
224
 
            toset = 0
225
 
        self.pref_show_preview.set_active(toset)
 
219
 
 
220
        show_preview = self.config_priv.get("contents_preview_enable")
 
221
        self.pref_show_preview.set_active(show_preview)
 
222
 
 
223
        bg_color = self.config_priv.get("bg_color_enable")
 
224
        self.bg_color_enable.set_active(bg_color)
226
225
 
227
226
    def _init_plugin_tree(self):
228
227
        """Initialize the PluginTree gtk.TreeView.
279
278
          # preferences on the Tasks tab
280
279
          'on_pref_show_preview_toggled':
281
280
            self.toggle_preview,
 
281
          'on_bg_color_toggled':
 
282
            self.on_bg_color_toggled,
282
283
          'on_pref_check_spelling_toggled':
283
284
            self.toggle_spellcheck,
284
285
          # buttons on the Plugins tab
393
394
 
394
395
    def toggle_preview(self, widget):
395
396
        """Toggle previews in the task view on or off."""
396
 
        self.config_priv.set("contents_preview_enable", widget.get_active())
397
 
        view = self.req.get_tasks_tree(refresh=False)
398
 
        view.refresh_all()
 
397
        curstate = self.config_priv.get("contents_preview_enable")
 
398
        if curstate != widget.get_active():
 
399
            self.config_priv.set("contents_preview_enable", not curstate)
 
400
            view = self.req.get_tasks_tree(refresh=False)
 
401
            view.refresh_all()
 
402
 
 
403
    def on_bg_color_toggled(self, widget):
 
404
        """ Save configuration and refresh nodes to apply the change """
 
405
        curstate = self.config_priv.get("bg_color_enable")
 
406
        if curstate != widget.get_active():
 
407
            self.config_priv.set("bg_color_enable", not curstate)
 
408
            task_tree = self.req.get_tasks_tree(refresh=False).get_basetree()
 
409
            task_tree.refresh_all()
399
410
 
400
411
    def toggle_spellcheck(self, widget):
401
412
        """Toggle spell checking on or off."""