Skip to content

Commit

Permalink
Migrate IBusConfig to GSettings
Browse files Browse the repository at this point in the history
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 3, 2018
1 parent d9cf5f1 commit f9195f8
Show file tree
Hide file tree
Showing 7 changed files with 445 additions and 402 deletions.
22 changes: 20 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -70,6 +87,7 @@ EXTRA_DIST = \
config.rpath \
autogen.sh \
ibus-table.appdata.xml \
$(schemas_DATA) \
@PACKAGE_NAME@.spec \
$(NULL)

Expand Down
52 changes: 27 additions & 25 deletions engine/it_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit f9195f8

Please sign in to comment.