Skip to content
Permalink
Browse files

Migrate IBusConfig to GSettings

IBus plans to deprecate IBusConfig and suggests to migrate to GSettings.
https://groups.google.com/forum/#!topic/ibus-devel/Mu1IoFX-bKE

The old settings are unfortunately lost, so one has to open the setup
tool and recreate ones favourite settings.

Fix some minor bugs while doing the migration:

- Use 4 as the default Chinese mode, not -1. 4 means no special
  filtering and sorting at all, which is appropriate for non-Chinese
  tables as well.
  • Loading branch information...
mike-fabian committed Aug 2, 2018
1 parent d9cf5f1 commit f9195f877c5212fef0dfa446acb328c45ba5852b
Showing with 445 additions and 402 deletions.
  1. +20 −2 Makefile.am
  2. +27 −25 engine/it_util.py
  3. +218 −269 engine/table.py
  4. +8 −5 engine/tabsqlitedb.py
  5. +53 −0 org.freedesktop.ibus.engine.table.gschema.xml
  6. +116 −98 setup/main.py
  7. +3 −3 tests/test_it.py
@@ -44,11 +44,28 @@ pkgconfigdir = $(libdir)/pkgconfig
# To register as an AppStream component to be visible in the software center
# (See http://www.freedesktop.org/software/appstream/docs/ for more details):
appdata_DATA = \
ibus-table.appdata.xml \
$(NULL)
ibus-table.appdata.xml \
$(NULL)

appdatadir = $(datadir)/metainfo

schemas_DATA = \
org.freedesktop.ibus.engine.table.gschema.xml
$(NULL)

schemasdir = $(datadir)/glib-2.0/schemas/

install-data-hook:
if test -z "$(DESTDIR)"; then \
glib-compile-schemas $(schemasdir); \
fi

uninstall-hook:
SCHEMAS_FILES=`ls $(schemasdir)/*.gschema.xml` || true; \
if test -z "$$SCHEMAS_FILES" && \
test -f $(schemasdir)/gschemas.compiled; then \
rm $(schemasdir)/gschemas.compiled; \
fi

AUX_DIST = \
config.guess \
@@ -70,6 +87,7 @@ EXTRA_DIST = \
config.rpath \
autogen.sh \
ibus-table.appdata.xml \
$(schemas_DATA) \
@PACKAGE_NAME@.spec \
$(NULL)

@@ -26,33 +26,35 @@
'''

import sys
import re
import string
from gi import require_version
require_version('GLib', '2.0')
from gi.repository import GLib

def config_section_normalize(section):
'''Replaces “_:” with “-” in the dconf section and converts to lower case
:param section: The name of the dconf section
:type section: string
:rtype: string
To make the comparison of the dconf sections work correctly.
I avoid using .lower() here because it is locale dependent, when
using .lower() this would not achieve the desired effect of
comparing the dconf sections case insentively in some locales, it
would fail for example if Turkish locale (tr_TR.UTF-8) is set.
Examples:
>>> config_section_normalize('Foo_bAr:Baz')
'foo-bar-baz'
def variant_to_value(variant):
'''
return re.sub(r'[_:]', r'-', section).translate(
bytes.maketrans(
bytes(string.ascii_uppercase.encode('ascii')),
bytes(string.ascii_lowercase.encode('ascii'))))

Convert a GLib variant to a value
'''
# pylint: disable=unidiomatic-typecheck
if type(variant) != GLib.Variant:
return variant
type_string = variant.get_type_string()
if type_string == 's':
return variant.get_string()
elif type_string == 'i':
return variant.get_int32()
elif type_string == 'b':
return variant.get_boolean()
elif type_string == 'as':
# In the latest pygobject3 3.3.4 or later, g_variant_dup_strv
# returns the allocated strv but in the previous release,
# it returned the tuple of (strv, length)
if type(GLib.Variant.new_strv([]).dup_strv()) == tuple:
return variant.dup_strv()[0]
else:
return variant.dup_strv()
else:
print('error: unknown variant type: %s' %type_string)
return variant

if __name__ == "__main__":
import doctest
Oops, something went wrong.

0 comments on commit f9195f8

Please sign in to comment.
You can’t perform that action at this time.