Esempio n. 1
0
 def set_option(self, option, value):
     """
     Set a plugin option in configuration file
     Use a SIGNAL to call it, e.g.:
     plugin.sig_option_changed.emit('show_all', checked)
     """
     CONF.set(self.CONF_SECTION, str(option), value)
Esempio n. 2
0
def _get_run_configurations():
    history_count = CONF.get('run', 'history', 20)
    try:
        return [(filename, options)
                for filename, options in CONF.get('run', 'configurations', [])
                if osp.isfile(filename)][:history_count]
    except ValueError:
        CONF.set('run', 'configurations', [])
        return []
Esempio n. 3
0
def set_color_scheme(name, color_scheme, replace=True):
    """Set syntax color scheme"""
    section = "color_schemes"
    names = CONF.get("color_schemes", "names", [])
    for key in sh.COLOR_SCHEME_KEYS:
        option = "%s/%s" % (name, key)
        value = CONF.get(section, option, default=None)
        if value is None or replace or name not in names:
            CONF.set(section, option, color_scheme[key])
    names.append(to_text_string(name))
    CONF.set(section, "names", sorted(list(set(names))))
Esempio n. 4
0
def set_font(font, section='main', option='font'):
    """Set font"""
    CONF.set(section, option + '/family', to_text_string(font.family()))
    CONF.set(section, option + '/size', float(font.pointSize()))
    CONF.set(section, option + '/italic', int(font.italic()))
    CONF.set(section, option + '/bold', int(font.bold()))
    FONT_CACHE[(section, option)] = font
Esempio n. 5
0
 def save_historylog(self):
     """Save current history log (all text in console)"""
     title = _("Save history log")
     self.redirect_stdio.emit(False)
     filename, _selfilter = getsavefilename(
         self, title, self.historylog_filename,
         "%s (*.log)" % _("History logs"))
     self.redirect_stdio.emit(True)
     if filename:
         filename = osp.normpath(filename)
         try:
             encoding.write(to_text_string(self.get_text_with_eol()),
                            filename)
             self.historylog_filename = filename
             CONF.set('main', 'historylog_filename', filename)
         except EnvironmentError as error:
             QMessageBox.critical(
                 self, title,
                 _("<b>Unable to save file '%s'</b>"
                   "<br><br>Error message:<br>%s") %
                 (osp.basename(filename), to_text_string(error)))
Esempio n. 6
0
def set_shortcut(context, name, keystr):
    """Set keyboard shortcut (key sequence string)"""
    CONF.set('shortcuts', '%s/%s' % (context, name), keystr)
Esempio n. 7
0
 def set_firstrun_o(self):
     CONF.set('run', ALWAYS_OPEN_FIRST_RUN_OPTION,
              self.firstrun_cb.isChecked())
Esempio n. 8
0
def _set_run_configurations(configurations):
    history_count = CONF.get('run', 'history', 20)
    CONF.set('run', 'configurations', configurations[:history_count])