From 0aa3ff942a1a7a7c3229703c9878ec416731c2df Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Mon, 7 Mar 2011 00:47:48 -0800 Subject: Generate GSettings schema instead of GConf schema. --- .gitignore | 1 + caribou/common/setting_types.py | 52 ++++++++------------------------------ caribou/common/settings.py | 37 +++++++++++++-------------- caribou/common/settings_manager.py | 1 - configure.ac | 8 ++++-- data/Makefile.am | 27 ++++++-------------- po/POTFILES.skip | 2 +- 7 files changed, 45 insertions(+), 83 deletions(-) diff --git a/.gitignore b/.gitignore index 3402137..86ad19e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ data/caribou.desktop po/.intltool-merge-cache data/caribou.schemas data/caribou.schemas.in +data/org.gnome.caribou.gschema.* diff --git a/caribou/common/setting_types.py b/caribou/common/setting_types.py index 5b8aa95..130a0b5 100644 --- a/caribou/common/setting_types.py +++ b/caribou/common/setting_types.py @@ -1,7 +1,5 @@ import gobject -from gi.repository import GConf - -GCONF_DIR="/apps/caribou/osk/" +from gi.repository import GLib ENTRY_DEFAULT=0 ENTRY_COMBO=1 @@ -56,7 +54,7 @@ class SettingsGroup(Setting): pass class ValueSetting(Setting): - gconf_type = GConf.ValueType.INVALID + variant_type = '' entry_type=ENTRY_DEFAULT def __init__(self, name, label, default, short_desc="", long_desc="", allowed=[], entry_type=ENTRY_DEFAULT, sensitive=None, @@ -80,61 +78,33 @@ class ValueSetting(Setting): @value.setter def value(self, val): - _val = self.convert_value(self._from_gconf_value(val)) + _val = self.convert_value(val.unpack()) if self.allowed and _val not in [a for a, b in self.allowed]: raise ValueError, "'%s' not a valid value" % _val self._value = _val self.emit('value-changed', _val) @property - def gconf_key(self): - return GCONF_DIR + self.name + def gsettings_key(self): + return self.name.replace('_', '-') @property def is_true(self): return bool(self.value) @property - def gconf_default(self): - return self.default - - def set_gconf_value(self, val): - if val.type == GConf.ValueType.BOOL: - return val.set_bool(self.value) - if val.type == GConf.ValueType.FLOAT: - return val.set_float(self.value) - if val.type == GConf.ValueType.INT: - return val.set_int(self.value) - if val.type == GConf.ValueType.STRING: - return val.set_string(self.value) - - def _from_gconf_value(self, val): - if not isinstance(val, GConf.Value): - return val - if val.type == GConf.ValueType.BOOL: - return val.get_bool() - if val.type == GConf.ValueType.FLOAT: - return val.get_float() - if val.type == GConf.ValueType.INT: - return val.get_int() - if val.type == GConf.ValueType.STRING: - return val.get_string() - - return val.to_string() + def gvariant(self): + return GLib.Variant(self.variant_type, self.value) class BooleanSetting(ValueSetting): - gconf_type = GConf.ValueType.BOOL + variant_type = 'b' entry_type = ENTRY_CHECKBOX def convert_value(self, val): # Almost anything could be a boolean. return bool(val) - @property - def gconf_default(self): - str(self.default).lower() - class IntegerSetting(ValueSetting): - gconf_type = GConf.ValueType.INT + variant_type = 'i' entry_type = ENTRY_SPIN def __init__(self, *args, **kwargs): self.min = kwargs.pop('min', gobject.G_MININT) @@ -145,7 +115,7 @@ class IntegerSetting(ValueSetting): return int(val) class FloatSetting(ValueSetting): - gconf_type = GConf.ValueType.FLOAT + variant_type = 'd' entry_type = ENTRY_SPIN def __init__(self, *args, **kwargs): self.min = kwargs.pop('min', gobject.G_MINFLOAT) @@ -156,7 +126,7 @@ class FloatSetting(ValueSetting): return float(val) class StringSetting(ValueSetting): - gconf_type = GConf.ValueType.STRING + variant_type = 's' def convert_value(self, val): return str(val) diff --git a/caribou/common/settings.py b/caribou/common/settings.py index 09a23a9..b5df28e 100644 --- a/caribou/common/settings.py +++ b/caribou/common/settings.py @@ -124,15 +124,19 @@ settings = SettingsGroup("_top", "", [ ]) if __name__ == "__main__": + from gi.repository import GLib + class SchemasMaker: def create_schemas(self): doc = xml.dom.minidom.Document() - gconfschemafile = doc.createElement('gconfschemafile') - schemalist = doc.createElement('schemalist') - gconfschemafile.appendChild(schemalist) - self._create_schema(settings, doc, schemalist) + schemafile = doc.createElement('schemalist') + schema = doc.createElement('schema') + schema.setAttribute("id", "org.gnome.caribou") + schema.setAttribute("path", "/apps/caribou/osk/") + schemafile.appendChild(schema) + self._create_schema(settings, doc, schema) - self._pretty_xml(gconfschemafile) + self._pretty_xml(schemafile) def _attribs(self, e): if not e.attributes.items(): @@ -159,21 +163,16 @@ if __name__ == "__main__": element.appendChild(el) def _create_schema(self, setting, doc, schemalist): - if hasattr(setting, 'gconf_key'): - schema = doc.createElement('schema') - schemalist.appendChild(schema) - self._append_children_element_value_pairs( - doc, schema, [('key', '/schemas' + setting.gconf_key), - ('applyto', setting.gconf_key), - ('owner', 'caribou'), - ('type', setting.gconf_type.value_nick), - ('default', setting.gconf_default)]) - locale = doc.createElement('locale') - locale.setAttribute('name', 'C') - schema.appendChild(locale) + if hasattr(setting, 'gsettings_key'): + key = doc.createElement('key') + key.setAttribute('name', setting.gsettings_key) + key.setAttribute('type', setting.variant_type) + schemalist.appendChild(key) self._append_children_element_value_pairs( - doc, locale, [('short', setting.short_desc), - ('long', setting.long_desc)]) + doc, key, [('default', + getattr(setting.gvariant, "print")(False)), + ('_summary', setting.short_desc), + ('_description', setting.long_desc)]) for s in setting: self._create_schema(s, doc, schemalist) diff --git a/caribou/common/settings_manager.py b/caribou/common/settings_manager.py index 37d178b..c073fef 100644 --- a/caribou/common/settings_manager.py +++ b/caribou/common/settings_manager.py @@ -62,7 +62,6 @@ class _SettingsManager(object): def _on_value_changed(self, setting, value): if value != self.gconf_client.get(setting.gconf_key): - print setting.gconf_type val = GConf.Value.new(setting.gconf_type) setting.set_gconf_value(val) self.gconf_client.set(setting.gconf_key, val) diff --git a/configure.ac b/configure.ac index c8b5830..25f5b7a 100644 --- a/configure.ac +++ b/configure.ac @@ -20,12 +20,14 @@ AC_PATH_PROG(GCONFTOOL, gconftool-2) AM_GCONF_SOURCE_2 dnl == Library dependencies == +PYGOBJECT_REQUIRED=2.27.92 GTK_REQUIRED=2.91.8 CLUTTER_REQUIRED=1.5.11 PKG_CHECK_MODULES(CARIBOU, [ - gtk+-3.0 >= $GTK_REQUIRED, - clutter-1.0 >= $CLUTTER_REQUIRED]) + pygobject-2.0 >= $PYGOBJECT_REQUIRED, + gtk+-3.0 >= $GTK_REQUIRED, + clutter-1.0 >= $CLUTTER_REQUIRED]) AC_SUBST(CARIBOU_CFLAGS) AC_SUBST(CARIBOU_LIBS) @@ -35,6 +37,8 @@ AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The gettext package]) AM_GLIB_GNU_GETTEXT +GLIB_GSETTINGS + dnl == intltool check == IT_PROG_INTLTOOL([0.35.0]) diff --git a/data/Makefile.am b/data/Makefile.am index ffdaa39..afe1950 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,9 +1,9 @@ SUBDIRS = keyboards -schemasdir = $(GCONF_SCHEMA_FILE_DIR) -schemas_in_files = caribou.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) -@INTLTOOL_SCHEMAS_RULE@ +@GSETTINGS_RULES@ +@INTLTOOL_XML_NOMERGE_RULE@ +gsettings_schemas_in_files = org.gnome.caribou.gschema.xml.in +gsettings_SCHEMAS = $(gsettings_schemas_in_files:.gschema.xml.in=.gschema.xml) desktopdir = $(datadir)/applications desktop_in_files = caribou.desktop.in @@ -12,20 +12,9 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) EXTRA_DIST = $(desktop_in_files) -caribou.schemas.in: $(top_srcdir)/caribou/common/settings.py - PYTHONPATH=$(top_srcdir) $(PYTHON) $< > $@ +org.gnome.caribou.gschema.xml.in: $(top_srcdir)/caribou/common/settings.py + PYTHONPATH=${PYTHONPATH}:$(top_srcdir) $(PYTHON) $< > $@ CLEANFILES = $(desktop_DATA) \ - $(schemas_in_files) \ - $(schemas_DATA) - -# installation of schemas -if GCONF_SCHEMAS_INSTALL -install-data-hook: - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \ - $(GCONFTOOL) --makefile-install-rule $(schemas_DATA) - -uninstall-hook: - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \ - $(GCONFTOOL) --makefile-uninstall-rule $(schemas_DATA) -endif + $(gsettings_schemas_in_files) \ + $(gsettings_SCHEMAS) diff --git a/po/POTFILES.skip b/po/POTFILES.skip index e3c0a47..7386c06 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1 +1 @@ -data/caribou.schemas.in +data/org.gnome.caribou.gschema.xml.in -- cgit v1.2.1 From 2ddf12c4bc8665f7ce55c83e8cc6de5d7e5c1ab4 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Tue, 8 Mar 2011 17:36:47 -0500 Subject: Read keyboard files from prefix correctly --- bin/caribou.in | 3 +++ caribou/common/settings.py | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/caribou.in b/bin/caribou.in index 35ef584..824c68d 100644 --- a/bin/caribou.in +++ b/bin/caribou.in @@ -45,6 +45,9 @@ if os.path.dirname(__file__) != "@prefix@/bin": sys.path.insert(1, srcdir) import caribou.common import caribou.ui + caribou.data_path = os.path.abspath(os.path.join(os.path.dirname(__file__), + "@top_srcdir@", + "data")) else: import caribou.common import caribou.ui diff --git a/caribou/common/settings.py b/caribou/common/settings.py index b5df28e..0393079 100644 --- a/caribou/common/settings.py +++ b/caribou/common/settings.py @@ -13,10 +13,6 @@ else: HAS_JSON = True def fetch_keyboards(): - if True: - const.KEYBOARDS_DIR = os.path.abspath( - os.path.join(os.path.dirname(__file__), '../../data/keyboards')) - try: files = os.listdir(const.KEYBOARDS_DIR) except: -- cgit v1.2.1 From 994014a918ce32a08e4912ee2ac7274839d823f0 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Tue, 8 Mar 2011 17:38:08 -0500 Subject: Use GSettings for caribou settings. --- caribou/common/setting_types.py | 6 ++++-- caribou/common/settings.py | 4 +++- caribou/common/settings_manager.py | 41 ++++++++++++++------------------------ 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/caribou/common/setting_types.py b/caribou/common/setting_types.py index 130a0b5..109bf1b 100644 --- a/caribou/common/setting_types.py +++ b/caribou/common/setting_types.py @@ -71,6 +71,7 @@ class ValueSetting(Setting): self.default = default self.insensitive_when_false = insensitive_when_false self.insensitive_when_true = insensitive_when_true + self.hush = False @property def value(self): @@ -78,11 +79,12 @@ class ValueSetting(Setting): @value.setter def value(self, val): - _val = self.convert_value(val.unpack()) + _val = self.convert_value(val) if self.allowed and _val not in [a for a, b in self.allowed]: raise ValueError, "'%s' not a valid value" % _val self._value = _val - self.emit('value-changed', _val) + if not self.hush: + self.emit('value-changed', _val) @property def gsettings_key(self): diff --git a/caribou/common/settings.py b/caribou/common/settings.py index 0393079..86ad86f 100644 --- a/caribou/common/settings.py +++ b/caribou/common/settings.py @@ -5,6 +5,8 @@ import caribou.common.const as const import caribou.ui.i18n import xml.dom.minidom +GSETTINGS_SCHEMA = "org.gnome.caribou" + try: import json except ImportError: @@ -127,7 +129,7 @@ if __name__ == "__main__": doc = xml.dom.minidom.Document() schemafile = doc.createElement('schemalist') schema = doc.createElement('schema') - schema.setAttribute("id", "org.gnome.caribou") + schema.setAttribute("id", GSETTINGS_SCHEMA) schema.setAttribute("path", "/apps/caribou/osk/") schemafile.appendChild(schema) self._create_schema(settings, doc, schema) diff --git a/caribou/common/settings_manager.py b/caribou/common/settings_manager.py index c073fef..66119f8 100644 --- a/caribou/common/settings_manager.py +++ b/caribou/common/settings_manager.py @@ -1,15 +1,14 @@ import os -from gi.repository import GConf +from gi.repository import Gio from setting_types import * -from settings import settings +from settings import settings, GSETTINGS_SCHEMA import const class _SettingsManager(object): def __init__(self, settings): self.groups = settings - self.gconf_client = GConf.Client.get_default() - self.gconf_client.add_dir(const.CARIBOU_GCONF, - GConf.ClientPreloadType.PRELOAD_NONE) + self._gsettings = Gio.Settings(GSETTINGS_SCHEMA) + self._gsettings.connect("changed", self._gsettings_changed_cb) self._settings_map = {} self._map_settings(self.groups) @@ -34,21 +33,12 @@ class _SettingsManager(object): for setting in self._settings_map.values(): if isinstance(setting, SettingsGroup): continue - try: - setting.value = self.gconf_client.get(setting.gconf_key) - except ValueError: - val = GConf.Value.new(setting.gconf_type) - setting.set_gconf_value(val) - self.gconf_client.set(setting.gconf_key, val) + setting.value = \ + self._gsettings.get_value(setting.gsettings_key).unpack() self._change_dependant_sensitivity(setting) - handler_id = setting.connect('value-changed', - self._on_value_changed) - - #self.gconf_client.notify_add(setting.gconf_key, - # self._gconf_setting_changed_cb, - # (setting, handler_id)) + setting.connect('value-changed', self._on_value_changed) def _change_dependant_sensitivity(self, setting): for name in setting.insensitive_when_false: @@ -61,19 +51,18 @@ class _SettingsManager(object): child.sensitive = i == index def _on_value_changed(self, setting, value): - if value != self.gconf_client.get(setting.gconf_key): - val = GConf.Value.new(setting.gconf_type) - setting.set_gconf_value(val) - self.gconf_client.set(setting.gconf_key, val) + if value != \ + self._gsettings.get_value(setting.gsettings_key).unpack(): + self._gsettings.set_value(setting.gsettings_key, setting.gvariant) self._change_dependant_sensitivity(setting) - def _gconf_setting_changed_cb(self, client, connection_id, entry, data): - setting, handler_id = data - new_value = client.get_value(setting.gconf_key) + def _gsettings_changed_cb(self, gsettings, key): + setting = getattr(self, key.replace('-', '_')) + new_value = gsettings.get_value(key).unpack() if setting.value != new_value: - setting.handler_block(handler_id) + setting.hush = True setting.value = new_value - setting.handler_unblock(handler_id) + setting.hush = False def __call__(self): return self -- cgit v1.2.1 From 6c5d8df157e084fc930be8a0b94522d1111296c8 Mon Sep 17 00:00:00 2001 From: Eitan Isaacson Date: Tue, 8 Mar 2011 23:39:28 -0500 Subject: Use CSS theming for color options. --- caribou/ui/keyboard.py | 73 +++++++++++++++++++----------------- caribou/ui/main.py | 100 ++++++++++++++++++++++++++++++++++++++++++++----- caribou/ui/scan.py | 16 ++++---- 3 files changed, 136 insertions(+), 53 deletions(-) diff --git a/caribou/ui/keyboard.py b/caribou/ui/keyboard.py index 2dc924b..1fb43ba 100644 --- a/caribou/ui/keyboard.py +++ b/caribou/ui/keyboard.py @@ -90,9 +90,8 @@ class BaseKey(object): else: self.set_label(self.label) - for name in ["normal_color", "mouse_over_color", "default_colors"]: - getattr(SettingsManager, name).connect("value-changed", - self._colors_changed) + ctx = self.get_style_context() + ctx.add_class("caribou-keyboard-button") for name in ["default_font", "key_font"]: getattr(SettingsManager, name).connect("value-changed", @@ -101,30 +100,26 @@ class BaseKey(object): if not SettingsManager.default_font.value: self._key_font_changed(None, None) - if not SettingsManager.default_colors.value: - self._colors_changed(None, None) - - def _colors_changed(self, setting, value): - if SettingsManager.default_colors.value: - self._normal_color = None - self._mouse_over_color = None - self.reset_color() - else: - self._normal_color = SettingsManager.normal_color.value - self._mouse_over_color = SettingsManager.mouse_over_color.value - self.set_color(self._normal_color, self._mouse_over_color) - def _key_font_changed(self, setting, value): if SettingsManager.default_font.value: self.reset_font() else: self.set_font(SettingsManager.key_font.value) - def scan_highlight(self, color): - if color is None: - self._colors_changed(None, None) - else: - self.set_color(color) + def scan_highlight_key(self): + raise NotImplemented + + def scan_highlight_row(self): + raise NotImplemented + + def scan_highlight_block(self): + raise NotImplemented + + def scan_highlight_cancel(self): + raise NotImplemented + + def scan_highlight_clear(self): + raise NotImplemented def _on_image_key_mapped(self, key): print @@ -152,12 +147,6 @@ class BaseKey(object): def reset_font(self): raise NotImplemented - def set_color(self, normal_color, mouse_over_color): - raise NotImplemented - - def reset_color(self): - raise NotImplemented - def _get_value(self): return self._value @@ -201,15 +190,29 @@ class Key(Gtk.Button, BaseKey): return label.modify_font(None) - def set_color(self, normal_color, mouse_over_color=None): - self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(normal_color)[1]) - if mouse_over_color: - self.modify_bg(Gtk.StateType.PRELIGHT, - Gdk.color_parse(mouse_over_color)[1]) + def _replace_scan_class_style(self, scan_class=None): + ctx = self.get_style_context() + for cls in ctx.list_classes(): + if cls.startswith('caribou-scan'): + ctx.remove_class(cls) + if scan_class: + ctx.add_class(scan_class) + self.queue_draw() + + def scan_highlight_key(self): + self._replace_scan_class_style("caribou-scan-key") + + def scan_highlight_row(self): + self._replace_scan_class_style("caribou-scan-row") + + def scan_highlight_block(self): + self._replace_scan_class_style("caribou-scan-block") + + def scan_highlight_cancel(self): + self._replace_scan_class_style("caribou-scan-cancel") - def reset_color(self): - self.modify_bg(Gtk.StateType.NORMAL, None) - self.modify_bg(Gtk.StateType.PRELIGHT, None) + def scan_highlight_clear(self): + self._replace_scan_class_style() class ModifierKey(Gtk.ToggleButton, Key): pass diff --git a/caribou/ui/main.py b/caribou/ui/main.py index 3a7d19a..1a6ac9e 100644 --- a/caribou/ui/main.py +++ b/caribou/ui/main.py @@ -2,6 +2,7 @@ import pyatspi from gi.repository import Gtk from gi.repository import Gdk from gi.repository import Gio +from string import Template from window import CaribouWindowEntry, Rectangle from keyboard import CaribouKeyboard @@ -12,6 +13,40 @@ from scan import ScanMaster debug = False +CSS_TEMPLATE = """ +.caribou-keyboard-button { +background-image: none; +background-color: $normal_bg; +} + +.caribou-keyboard-button:hover { +background-image: none; +background-color: $mouseover_bg; +} +""" + +SCAN_CSS_TEMPLATE = """ +.caribou-scan-key { +background-image: none; +background-color: $button_scan; +} + +.caribou-scan-row { +background-image: none; +background-color: $row_scan; +} + +.caribou-scan-block { +background-image: none; +background-color: $block_scan; +} + +.caribou-scan-cancel { +background-image: none; +background-color: $cancel_scan; +} +""" + class Caribou: def __init__(self, kb_factory=CaribouKeyboard, @@ -34,6 +69,50 @@ class Caribou: if SettingsManager.scan_enabled.value: self.scan_master.start() + self._custom_css_provider = Gtk.CssProvider() + + for name in ["normal_color", "mouse_over_color", "default_colors"]: + getattr(SettingsManager, name).connect("value-changed", + self._colors_changed) + self._colors_changed(None, None) + + self._scan_css_provider = Gtk.CssProvider() + Gtk.StyleContext.add_provider_for_screen( + Gdk.Screen.get_default(), + self._scan_css_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + + for name in ["button_scanning_color", + "row_scanning_color", + "block_scanning_color", + "cancel_scanning_color"]: + getattr(SettingsManager, name).connect("value-changed", + self._scan_colors_changed) + self._scan_colors_changed(None, None) + + def _colors_changed(self, setting, value): + if SettingsManager.default_colors.value: + Gtk.StyleContext.remove_provider_for_screen( + Gdk.Screen.get_default(), + self._custom_css_provider) + else: + Gtk.StyleContext.add_provider_for_screen( + Gdk.Screen.get_default(), + self._custom_css_provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + self._custom_css_provider.load_from_data( + Template(CSS_TEMPLATE).substitute( + normal_bg=SettingsManager.normal_color.value, + mouseover_bg=SettingsManager.mouse_over_color.value), -1) + + def _scan_colors_changed(self, setting, value): + self._scan_css_provider.load_from_data(Template(SCAN_CSS_TEMPLATE).substitute( + button_scan=SettingsManager.button_scanning_color.value, + row_scan=SettingsManager.row_scanning_color.value, + block_scan=SettingsManager.block_scanning_color.value, + cancel_scan=SettingsManager.cancel_scanning_color.value), -1) + + def _register_event_listeners(self): pyatspi.Registry.registerEventListener( self.on_focus, "object:state-changed:focused") @@ -70,8 +149,10 @@ class Caribou: try: settings = Gio.Settings('org.gnome.desktop.interface') atspi = settings.get_boolean("toolkit-accessibility") + print "->", atspi return atspi except: + raise from gi.repository import GConf gconfc = GConf.Client.get_default() atspi1 = gconfc.get_bool( @@ -80,6 +161,7 @@ class Caribou: "/desktop/gnome/interface/accessibility2") return atspi1 or atspi2 except: + raise return False def on_text_caret_moved(self, event): @@ -88,17 +170,17 @@ class Caribou: if debug == True: print "object:text-caret-moved in", event.host_application.name, print event.detail1, event.source.description - + def __set_text_location(self, acc): - text = acc.queryText() + text = acc.queryText() [x, y, width, height] = text.getCharacterExtents(text.caretOffset, pyatspi.DESKTOP_COORDS) self.window.set_cursor_location(Rectangle(x, y, width, height)) - + component = acc.queryComponent() entry_bb = component.getExtents(pyatspi.DESKTOP_COORDS) self.window.set_entry_location(entry_bb) self.window.show_all() - + def __set_entry_location(self, acc): text = acc.queryText() cursor_bb = Rectangle( @@ -115,7 +197,7 @@ class Caribou: self.window.set_entry_location(entry_bb) self.window.show_all() - + def on_focus(self, event): acc = event.source source_role = acc.getRole() @@ -133,7 +215,7 @@ class Caribou: print "enter text widget in", event.host_application.name elif event.detail1 == 0 and acc == self.__current_acc: self.window.hide() - self.__current_acc = None + self.__current_acc = None self.__set_location = None if debug == True: print "leave text widget in", event.host_application.name @@ -147,7 +229,7 @@ class Caribou: print "enter entry widget in", event.host_application.name elif event.detail1 == 0: self.window.hide() - self.__current_acc = None + self.__current_acc = None self.__set_location = None if debug == True: print "leave entry widget in", event.host_application.name @@ -165,5 +247,5 @@ class Caribou: def clean_exit(self): self.scan_master.stop() self._deregister_event_listeners() - - + + diff --git a/caribou/ui/scan.py b/caribou/ui/scan.py index 16680fb..94aa8c2 100644 --- a/caribou/ui/scan.py +++ b/caribou/ui/scan.py @@ -59,7 +59,7 @@ class ScanMaster(): self._ungrab_mouse_events() if self._last_block is not None: - self._multi_map(lambda x: x.reset_color(), self._last_block) + self._multi_map(lambda x: x.scan_highlight_clear(), self._last_block) if self._timer != 0: gobject.source_remove(self._timer) @@ -154,25 +154,23 @@ class ScanMaster(): if self._scan_path is None: return True if self._last_block is not None: - self._multi_map(lambda x: x.scan_highlight(None), - self._last_block) + self._multi_map(lambda x: x.scan_highlight_clear(), self._last_block) if SettingsManager.reverse_scanning.value: self._cancel, next_block = self._get_next_reverse_block() else: self._cancel, next_block = self._get_next_block() - color = SettingsManager.button_scanning_color.value - if self._cancel: - color = SettingsManager.cancel_scanning_color.value + self._multi_map(lambda x: x.scan_highlight_cancel(), next_block) elif isinstance(next_block, list): if SettingsManager.scanning_type.value == ROW: - color = SettingsManager.row_scanning_color.value + self._multi_map(lambda x: x.scan_highlight_row(), next_block) else: - color = SettingsManager.block_scanning_color.value + self._multi_map(lambda x: x.scan_highlight_block(), next_block) + else: + self._multi_map(lambda x: x.scan_highlight_key(), next_block) - self._multi_map(lambda x: x.scan_highlight(color), next_block) self._last_block = next_block return True -- cgit v1.2.1