def _getPronunciations(self, profile, app=None): pronunciationSettings = {} if app is not None and app != '': baseGSettings = Settings( schema_id='org.gnome.orca', path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app)) appSpecific = True else: baseGSettings = Settings(schema_id='org.gnome.orca', path='/org/gnome/orca/profile/%s/' % profile) appSpecific = False pronunciations = baseGSettings.get_strv('pronunciations') for pronunciation in pronunciations: if appSpecific == True: pronunciationSetting = Settings( schema_id='org.gnome.orca.pronunciation', path='/org/gnome/orca/profile/%s/app/%s/pronunciation/%s/' % (profile, app, pronunciation)) else: pronunciationSetting = Settings( schema_id='org.gnome.orca.pronunciation', path='/org/gnome/orca/profile/%s/pronunciation/%s/' % (profile, pronunciation)) actualSetting = pronunciationSetting.get_string('actual') replacementSetting = pronunciationSetting.get_string('replacement') pronunciationSettings[pronunciation] = [ actualSetting, replacementSetting ] return pronunciationSettings
def addKeyCombo(self, component, localized_component, description, callback, keypress, modifiers): """ Adds the given key combination with the appropriate callbacks to the L{HotkeyManager}. If an identical description with the identical component already exists in the model, just reassign with the new callback. I{Note:} It is important that the component and description strings be unique. @param component: The component name, usually the plugin name, or "Core". @type component: string @param description: A description of the action performed during the given keycombo. @type description: string @param callback: The callback to call when the given key combination is pressed. @type callback: callable @param keypress: The key symbol of the keystroke that performs given operation. @type keypress: long @param modifiers: The modifiers that must be depressed for function to be perfomed. @type modifiers: int """ component_desc_pairs = list(zip([row[COL_COMPONENT] for row in self], [row[COL_DESC] for row in self])) if (component, description) in component_desc_pairs: path = component_desc_pairs.index((component, description)) self[path][COL_CALLBACK] = callback else: gspath = self._getComboGSettingsPath(component, description) gsettings = GSettings(schema=HOTKEYS_GSCHEMA, path=gspath) if gsettings.get_string("hotkey-combo"): final_keypress, final_modifiers = gtk.accelerator_parse(gsettings.get_string("hotkey-combo")) else: final_keypress, final_modifiers = keypress, modifiers self.append([component, description, callback, int(final_keypress), final_modifiers, localized_component])
def addKeyCombo(self, component, localized_component, description, callback, keypress, modifiers): ''' Adds the given key combination with the appropriate callbacks to the L{HotkeyManager}. If an identical description with the identical component already exists in the model, just reassign with the new callback. I{Note:} It is important that the component and description strings be unique. @param component: The component name, usually the plugin name, or "Core". @type component: string @param description: A description of the action performed during the given keycombo. @type description: string @param callback: The callback to call when the given key combination is pressed. @type callback: callable @param keypress: The key symbol of the keystroke that performs given operation. @type keypress: long @param modifiers: The modifiers that must be depressed for function to be perfomed. @type modifiers: int ''' component_desc_pairs = zip([row[COL_COMPONENT] for row in self], [row[COL_DESC] for row in self]) if (component, description) in component_desc_pairs: path = component_desc_pairs.index((component, description)) self[path][COL_CALLBACK] = callback else: gspath = self._getComboGSettingsPath(component, description) gsettings = GSettings(schema=HOTKEYS_GSCHEMA, path=gspath) if gsettings.get_string('hotkey-combo'): final_keypress, final_modifiers = gtk.accelerator_parse( gsettings.get_string('hotkey-combo')) else: final_keypress, final_modifiers = keypress, modifiers self.append([ component, description, callback, int(final_keypress), final_modifiers, localized_component ])
def _getKeybindings(self, profile, app=None): keybindingSettings = {} if app is not None and app != '': baseGSettings = Settings( schema_id='org.gnome.orca', path='/org/gnome/orca/profile/%s/app/%s/' % (profile, app)) appSpecific = True else: baseGSettings = Settings(schema_id='org.gnome.orca', path='/org/gnome/orca/profile/%s/' % profile) appSpecific = False keybindings = baseGSettings.get_strv('keybindings') for keybinding in keybindings: if appSpecific == True: keybindingSetting = Settings( schema_id='org.gnome.orca.keybinding', path='/org/gnome/orca/profile/%s/app/%s/keybinding/%s/' % (profile, app, keybinding)) else: keybindingSetting = Settings( schema_id='org.gnome.orca.keybinding', path='/org/gnome/orca/profile/%s/keybinding/%s/' % (profile, keybinding)) keySetting = keybindingSetting.get_string('key') modMaskSetting = keybindingSetting.get_string('mod-mask') modUsedSetting = keybindingSetting.get_string('mod-used') clickCountSetting = keybindingSetting.get_string('click-count') keybindingSettings[keybinding] = [[ keySetting, modMaskSetting, modUsedSetting, clickCountSetting ]] return keybindingSettings
def _onComboChanged(self, model, path, iter): """ Callback for row changes. Copies the changed key combos over to gsettings. @param model: The model that emitted the signal. Should be this class instance. @type model: L{gtk.TreeModel} @param path: The path of the row that has changed. @type path: tuple @param iter: The iter of the row that has changed. @type iter: L{gtk.TreeIter} """ if not model[iter][COL_COMPONENT] or not model[iter][COL_DESC]: return gspath = self._getComboGSettingsPath(model[iter][COL_COMPONENT], model[iter][COL_DESC]) gsettings = GSettings(schema=HOTKEYS_GSCHEMA, path=gspath) combo_name = gtk.accelerator_name(model[iter][COL_KEYPRESS], gdk.ModifierType(model[iter][COL_MOD])) key = gsettings.get_string("hotkey-combo") if key != combo_name and key != "/": gsettings.set_string("hotkey-combo", combo_name)
def _onComboChanged(self, model, path, iter): ''' Callback for row changes. Copies the changed key combos over to gsettings. @param model: The model that emitted the signal. Should be this class instance. @type model: L{gtk.TreeModel} @param path: The path of the row that has changed. @type path: tuple @param iter: The iter of the row that has changed. @type iter: L{gtk.TreeIter} ''' if not model[iter][COL_COMPONENT] or not model[iter][COL_DESC]: return gspath = self._getComboGSettingsPath(model[iter][COL_COMPONENT], model[iter][COL_DESC]) gsettings = GSettings(schema=HOTKEYS_GSCHEMA, path=gspath) combo_name = gtk.accelerator_name( model[iter][COL_KEYPRESS], gdk.ModifierType(model[iter][COL_MOD])) key = gsettings.get_string('hotkey-combo') if key != combo_name and key != '/': gsettings.set_string('hotkey-combo', combo_name)
from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GObject from gi.repository.Gio import Settings as GSettings # from gi.repository import cairo import cairo import pyatspi import string from tools import Tools, parseColorString MAX_BLINKS = 6 gsettings = GSettings(schema="org.a11y.Accerciser") BORDER_COLOR, BORDER_ALPHA = parseColorString(gsettings.get_string("highlight-border")) FILL_COLOR, FILL_ALPHA = parseColorString(gsettings.get_string("highlight-fill")) HL_DURATION = int(gsettings.get_double("highlight-duration") * 1000) class Bag(object): """ Bag class for converting a dicionary to an object with attributes. """ def __init__(self, **kwargs): self.__dict__.update(kwargs) def __str__(self):
from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GObject from gi.repository.Gio import Settings as GSettings #from gi.repository import cairo import cairo import pyatspi import string from tools import Tools, parseColorString MAX_BLINKS = 6 gsettings = GSettings(schema='org.a11y.Accerciser') BORDER_COLOR, BORDER_ALPHA = parseColorString( gsettings.get_string('highlight-border')) FILL_COLOR, FILL_ALPHA = parseColorString( gsettings.get_string('highlight-fill')) HL_DURATION = int(gsettings.get_double('highlight-duration')*1000) class Bag(object): ''' Bag class for converting a dicionary to an object with attributes. ''' def __init__(self, **kwargs): self.__dict__.update(kwargs) def __str__(self): return ', '.join(vars(self).keys())
def _getVoiceSettings(self, profile, app=None): voiceSettings = {} if app is not None and app != '': appSpecific = True else: appSpecific = False for voice in ['default', 'uppercase', 'hyperlink', 'system']: if appSpecific == True: voiceGSettings = Settings( schema_id='org.gnome.orca.voice', path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' % (profile, app, voice)) voiceGSettingsFamily = Settings( schema_id='org.gnome.orca.voice.family', path='/org/gnome/orca/profile/%s/app/%s/voice/%s/' % (profile, app, voice)) else: voiceGSettings = Settings( schema_id='org.gnome.orca.voice', path='/org/gnome/orca/profile/%s/voice/%s/' % (profile, voice)) voiceGSettingsFamily = Settings( schema_id='org.gnome.orca.voice.family', path='/org/gnome/orca/profile/%s/voice/%s/' % (profile, voice)) # Used to quickly determine whether a voice's settings have been # set and are different from the defaults voiceEstablished = voiceGSettings.get_boolean('established') voiceSetting = {} voiceSettingFamily = {} if appSpecific == False and self.voiceDefaults.__contains__(voice): voiceSetting = self.voiceDefaults[voice].copy() if voiceEstablished == True: if appSpecific == False and voiceSetting.__contains__( 'established'): voiceSetting.pop('established') for setting in ['average-pitch', 'gain', 'rate']: if voiceGSettings.get_user_value(setting) is not None: gSettingsVal = voiceGSettings.get_double(setting) debug.println( debug.LEVEL_FINEST, 'INFO: GSettings backend: Getting voice setting for voice %s with name %s = %s' % (voice, setting, gSettingsVal)) voiceSetting[setting] = gSettingsVal if voiceGSettingsFamily.get_boolean('family-set') == True: for setting in ['name', 'locale', 'dialect']: gSettingsVal = voiceGSettingsFamily.get_string(setting) debug.println( debug.LEVEL_FINEST, 'INFO: GSettings backend: Getting voice family setting for voice %s with name %s = %s' % (voice, setting, gSettingsVal)) voiceSettingFamily[setting] = gSettingsVal voiceSetting['family'] = voiceSettingFamily # The JSON backend uses acss the same way, not sure why, so will # just duplicate here to be compatible. if voiceSetting != {}: if appSpecific == True: voiceSettings[voice] = voiceSetting else: voiceSettings[voice] = acss.ACSS(voiceSetting) return voiceSettings
from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GLib from gi.repository import GObject from gi.repository.Gio import Settings as GSettings #from gi.repository import cairo import cairo import pyatspi import string from .tools import Tools, parseColorString MAX_BLINKS = 6 gsettings = GSettings(schema='org.a11y.Accerciser') BORDER_COLOR, BORDER_ALPHA = parseColorString( gsettings.get_string('highlight-border')) FILL_COLOR, FILL_ALPHA = parseColorString( gsettings.get_string('highlight-fill')) HL_DURATION = int(gsettings.get_double('highlight-duration')*1000) class Bag(object): ''' Bag class for converting a dicionary to an object with attributes. ''' def __init__(self, **kwargs): self.__dict__.update(kwargs) def __str__(self): return ', '.join(list(vars(self).keys()))